01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc.objectserver.control;
06:
07: import java.io.IOException;
08: import java.net.Socket;
09:
10: public abstract class ServerControlBase implements ServerControl {
11:
12: private final int adminPort;
13: private final String host;
14: private final int dsoPort;
15:
16: public ServerControlBase(String host, int dsoPort, int adminPort) {
17: this .host = host;
18: this .dsoPort = dsoPort;
19: this .adminPort = adminPort;
20: }
21:
22: public boolean isRunning() {
23: Socket socket = null;
24: try {
25: socket = new Socket(host, adminPort);
26: if (!socket.isConnected())
27: throw new AssertionError();
28: return true;
29: } catch (IOException e) {
30: return false;
31: } finally {
32: if (socket != null) {
33: try {
34: socket.close();
35: } catch (IOException ioe) {
36: // ignore
37: }
38: }
39: }
40: }
41:
42: public int getAdminPort() {
43: return adminPort;
44: }
45:
46: public int getDsoPort() {
47: return dsoPort;
48: }
49:
50: protected String getHost() {
51: return host;
52: }
53:
54: }
|