Search in sources :

Example 6 with ConfigurationException

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;
    }
}
Also used : ConfigurationException(org.jboss.narayana.blacktie.jatmibroker.core.conf.ConfigurationException) ConnectionException(org.jboss.narayana.blacktie.jatmibroker.xatmi.ConnectionException)

Example 7 with ConfigurationException

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;
}
Also used : Response(org.jboss.narayana.blacktie.jatmibroker.xatmi.Response) X_OCTET(org.jboss.narayana.blacktie.jatmibroker.xatmi.X_OCTET) ConfigurationException(org.jboss.narayana.blacktie.jatmibroker.core.conf.ConfigurationException) ConnectionException(org.jboss.narayana.blacktie.jatmibroker.xatmi.ConnectionException)

Example 8 with ConfigurationException

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;
}
Also used : Response(org.jboss.narayana.blacktie.jatmibroker.xatmi.Response) X_OCTET(org.jboss.narayana.blacktie.jatmibroker.xatmi.X_OCTET) ConfigurationException(org.jboss.narayana.blacktie.jatmibroker.core.conf.ConfigurationException) ConnectionException(org.jboss.narayana.blacktie.jatmibroker.xatmi.ConnectionException)

Example 9 with ConfigurationException

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);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) ConfigurationException(org.jboss.narayana.blacktie.jatmibroker.core.conf.ConfigurationException) File(java.io.File) MalformedObjectNameException(javax.management.MalformedObjectNameException) ConfigurationException(org.jboss.narayana.blacktie.jatmibroker.core.conf.ConfigurationException) IOException(java.io.IOException)

Example 10 with ConfigurationException

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;
}
Also used : Response(org.jboss.narayana.blacktie.jatmibroker.xatmi.Response) X_OCTET(org.jboss.narayana.blacktie.jatmibroker.xatmi.X_OCTET) ConfigurationException(org.jboss.narayana.blacktie.jatmibroker.core.conf.ConfigurationException) ConnectionException(org.jboss.narayana.blacktie.jatmibroker.xatmi.ConnectionException)

Aggregations

ConfigurationException (org.jboss.narayana.blacktie.jatmibroker.core.conf.ConfigurationException)13 ConnectionException (org.jboss.narayana.blacktie.jatmibroker.xatmi.ConnectionException)10 Response (org.jboss.narayana.blacktie.jatmibroker.xatmi.Response)7 X_OCTET (org.jboss.narayana.blacktie.jatmibroker.xatmi.X_OCTET)7 IOException (java.io.IOException)2 StringTokenizer (java.util.StringTokenizer)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 Constructor (java.lang.reflect.Constructor)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 UnknownHostException (java.net.UnknownHostException)1 List (java.util.List)1 Properties (java.util.Properties)1 PostConstruct (javax.annotation.PostConstruct)1 TimerConfig (javax.ejb.TimerConfig)1 MalformedObjectNameException (javax.management.MalformedObjectNameException)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 StreamSource (javax.xml.transform.stream.StreamSource)1 CodecFactory (org.jboss.narayana.blacktie.jatmibroker.codec.CodecFactory)1 Codec (org.jboss.narayana.blacktie.jatmibroker.core.transport.Codec)1