use of org.jboss.narayana.blacktie.jatmibroker.core.conf.ConfigurationException in project narayana by jbosstm.
the class AdministrationProxy method shutdown.
public Boolean shutdown(String serverName, int id) {
log.trace("shutdown");
List<String> servers = listRunningServers();
if (servers.contains(serverName)) {
String command = "serverdone";
boolean shutdown = false;
try {
if (id == 0) {
List<Integer> ids = listRunningInstanceIds(serverName);
ConnectionException toRethrow = null;
for (int i = 0; i < ids.size(); i++) {
try {
callAdminService(serverName, ids.get(i), command);
} catch (ConnectionException e) {
log.error("call server " + serverName + " id " + id + " failed with " + e.getTperrno(), e);
if (e.getTperrno() == org.jboss.narayana.blacktie.jatmibroker.xatmi.Connection.TPETIME) {
callAdminService(serverName, ids.get(i), command);
} else {
toRethrow = e;
}
} catch (ConfigurationException e) {
log.error("call server " + serverName + " id " + id + " failed with configuration exception", e);
toRethrow = new ConnectionException(Connection.TPEOS, "Configuration issue: " + e.getMessage(), e);
}
}
if (toRethrow != null) {
throw toRethrow;
}
} else {
callAdminService(serverName, id, command);
}
int timeout = 40;
while (true) {
List<Integer> ids = listRunningInstanceIds(serverName);
if (id == 0 && ids.size() > 0 || ids.contains(id)) {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
timeout--;
} else {
shutdown = true;
break;
}
if (timeout == 0) {
log.warn("Server did not shutdown in time: " + serverName + ": " + id);
break;
}
}
return shutdown;
} catch (ConnectionException e) {
log.error("call server " + serverName + " id " + id + " failed with " + e.getTperrno(), e);
return false;
} catch (RuntimeException e) {
log.error("Could not shutdown server: " + e.getMessage(), e);
throw e;
} catch (ConfigurationException e) {
log.error("call server " + serverName + " id " + id + " failed with configuration exception", e);
return false;
}
} else {
log.error("Server not configured: " + serverName);
return false;
}
}
use of org.jboss.narayana.blacktie.jatmibroker.core.conf.ConfigurationException in project narayana by jbosstm.
the class AdministrationProxy method getErrorCounterById.
public long getErrorCounterById(String serverName, int id, String serviceName) {
log.trace("getErrorCounterById");
long counter = 0;
String command = "error_counter," + serviceName + ",";
try {
Response buf = callAdminService(serverName, id, command);
if (buf != null) {
byte[] received = ((X_OCTET) buf.getBuffer()).getByteArray();
counter = Long.parseLong(new String(received, 1, received.length - 1));
}
} catch (ConnectionException e) {
log.error("call server " + serverName + " id " + id + " failed with " + e.getTperrno());
} catch (ConfigurationException e) {
log.error("call server " + serverName + " id " + id + " failed with configuration exception", e);
}
return counter;
}
use of org.jboss.narayana.blacktie.jatmibroker.core.conf.ConfigurationException in project narayana by jbosstm.
the class AdministrationProxy method getResponseTimeById.
public String getResponseTimeById(String serverName, int id, String serviceName) {
log.trace("getResponseTimeById");
String command = "responsetime," + serviceName + ",";
log.trace("response command is " + command);
try {
Response buf = callAdminService(serverName, id, command);
if (buf != null) {
byte[] received = ((X_OCTET) buf.getBuffer()).getByteArray();
String result = new String(received, 1, received.length - 1);
log.trace("response result is " + result);
return result;
}
} catch (ConnectionException e) {
log.error("call server " + serverName + " id " + id + " failed with " + e.getTperrno(), e);
} catch (RuntimeException e) {
log.error("Could not get response time from server: " + e.getMessage(), e);
throw e;
} catch (ConfigurationException e) {
log.error("call server " + serverName + " id " + id + " failed with configuration exception", e);
}
return null;
}
use of org.jboss.narayana.blacktie.jatmibroker.core.conf.ConfigurationException in project narayana by jbosstm.
the class BTAdmin method main.
public static void main(String[] args) throws IOException {
int exitStatus = -1;
if (System.getProperty("log4j.configuration") == null && !new File("log4cxx.properties").exists() && !new File("log4j.xml").exists()) {
BasicConfigurator.configure();
log.info("BasicConfigurator ran");
}
boolean interactive = args.length == 0;
boolean done = false;
try {
CommandHandler commandHandler = new CommandHandler();
do {
if (interactive) {
System.out.print("> ");
// split on white space
args = br.readLine().split("\\s+");
}
try {
exitStatus = commandHandler.handleCommand(args);
if (exitStatus == 0) {
log.trace("Command was successful");
} else {
log.trace("Command failed");
}
if (args.length > 0 && args[0].equals("quit")) {
done = true;
}
} catch (Exception e) {
log.error("Could not invoke command: " + e.getMessage(), e);
}
} while (interactive && !done);
} catch (MalformedObjectNameException e) {
log.error("MBean name was badly structured: " + e.getMessage(), e);
} catch (ConfigurationException e) {
log.error("BlackTie Configuration invalid: " + e.getMessage(), e);
}
if (!interactive) {
// Exit the launcher with the value of the command
// This must be a halt so that any executed servers are not reaped
// by the JVM. If spawned servers die when launcher does we will
// need to investigate using setppid or something to set the
// spawned process as daemons
Runtime.getRuntime().halt(exitStatus);
}
}
use of org.jboss.narayana.blacktie.jatmibroker.core.conf.ConfigurationException in project narayana by jbosstm.
the class AdministrationProxy method getServerVersionById.
public String getServerVersionById(String serverName, int id) {
log.trace("getServerVersionById");
String command = "version";
Response buf = null;
String version = null;
try {
buf = callAdminService(serverName, id, command);
if (buf != null) {
byte[] received = ((X_OCTET) buf.getBuffer()).getByteArray();
if (received[0] == '1') {
version = new String(received, 1, received.length - 1);
log.debug("version is " + version);
}
}
} catch (ConnectionException e) {
log.error("call server " + serverName + " id " + id + " failed with " + e.getTperrno(), e);
} catch (ConfigurationException e) {
log.error("call server " + serverName + " id " + id + " failed with configuration exception", e);
}
return version;
}
Aggregations