administrationProxy = new AdministrationProxy();
}
public Response tpservice(TPSVCINFO svcinfo) {
log.trace("Message received");
X_OCTET recv = (X_OCTET) svcinfo.getBuffer();
String string = new String(recv.getByteArray());
StringTokenizer parameters = new StringTokenizer(string, ",", false);
String operation = parameters.nextToken();
byte[] toReturn = null;
try {
if (operation.equals("getDomainName")) {
String response = getDomainName();
toReturn = response.getBytes();
} else if (operation.equals("getServerName")) {
String serviceName = getString(parameters);
String response = getServerName(serviceName);
toReturn = response.getBytes();
} else if (operation.equals("getSoftwareVersion")) {
String response = getSoftwareVersion();
toReturn = response.getBytes();
} else if (operation.equals("pauseDomain")) {
boolean response = pauseDomain();
toReturn = convertBoolean(response);
} else if (operation.equals("resumeDomain")) {
boolean response = resumeDomain();
toReturn = convertBoolean(response);
} else if (operation.equals("getServerList")) {
List<String> response = getServerList();
toReturn = convertListString(response);
} else if (operation.equals("listRunningServers")) {
List<String> response = listRunningServers();
toReturn = convertListString(response);
} else if (operation.equals("listRunningInstanceIds")) {
String serverName = getString(parameters);
List<Integer> response = listRunningInstanceIds(serverName);
toReturn = convertListInt(response);
} else if (operation.equals("getServersStatus")) {
Element response = getServersStatus();
toReturn = response.toString().getBytes();
} else if (operation.equals("listServiceStatus")) {
String serverName = getString(parameters);
String serviceName = getString(parameters);
Element response = listServiceStatus(serverName, serviceName);
toReturn = response.toString().getBytes();
} else if (operation.equals("advertise")) {
String serverName = getString(parameters);
String serviceName = getString(parameters);
boolean response = advertise(serverName, serviceName);
toReturn = convertBoolean(response);
} else if (operation.equals("unadvertise")) {
String serverName = getString(parameters);
String serviceName = getString(parameters);
boolean response = unadvertise(serverName, serviceName);
toReturn = convertBoolean(response);
} else if (operation.equals("shutdown")) {
String serverName = getString(parameters);
int id = getInt(parameters);
shutdown(serverName, id);
toReturn = new byte[1];
toReturn[0] = 1;
} else if (operation.equals("getServiceCounterById")) {
String serverName = getString(parameters);
int id = getInt(parameters);
String serviceName = getString(parameters);
long response = getServiceCounterById(serverName, id,
serviceName);
toReturn = convertLong(response);
} else if (operation.equals("getServiceCounter")) {
String serverName = getString(parameters);
String serviceName = getString(parameters);
long response = getServiceCounter(serverName, serviceName);
toReturn = convertLong(response);
} else if (operation.equals("getErrorCounter")) {
String serverName = getString(parameters);
String serviceName = getString(parameters);
long response = getErrorCounter(serverName, serviceName);
toReturn = convertLong(response);
} else if (operation.equals("reloadDomain")) {
boolean response = reloadDomain();
toReturn = convertBoolean(response);
} else if (operation.equals("reloadServer")) {
String serverName = getString(parameters);
boolean response = reloadServer(serverName);
toReturn = convertBoolean(response);
} else if (operation.equals("listServiceStatusById")) {
String serverName = getString(parameters);
int id = getInt(parameters);
String serviceName = getString(parameters);
Element response = listServiceStatusById(serverName, id,
serviceName);
toReturn = response.toString().getBytes();
} else if (operation.equals("getDomainStatus")) {
boolean response = getDomainStatus();
toReturn = convertBoolean(response);
} else if (operation.equals("getResponseTime")) {
String serverName = getString(parameters);
String serviceName = getString(parameters);
String times = getResponseTime(serverName, serviceName);
toReturn = times.getBytes();
} else if (operation.equals("getQueueDepth")) {
String serverName = getString(parameters);
String serviceName = getString(parameters);
int depth = getQueueDepth(serverName, serviceName);
toReturn = (new StringBuffer().append(depth)).toString()
.getBytes();
} else if (operation.equals("getServerVersionById")) {
String serverName = getString(parameters);
int id = getInt(parameters);
String response = getServerVersionById(serverName, id);
toReturn = response.getBytes();
} else {
log.error("Unknown operation: " + operation);
return new Response(Connection.TPFAIL, 0, null, 0);
}
X_OCTET buffer = (X_OCTET) svcinfo.getConnection().tpalloc(
"X_OCTET", null, toReturn.length);
buffer.setByteArray(toReturn);
log.debug("Responding");
return new Response(Connection.TPSUCCESS, 0, buffer, 0);
} catch (ConnectionException e) {
return new Response(Connection.TPFAIL, 0, null, 0);
} catch (IOException e) {