Search in sources :

Example 16 with X_OCTET

use of org.jboss.narayana.blacktie.jatmibroker.xatmi.X_OCTET 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 17 with X_OCTET

use of org.jboss.narayana.blacktie.jatmibroker.xatmi.X_OCTET 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 18 with X_OCTET

use of org.jboss.narayana.blacktie.jatmibroker.xatmi.X_OCTET in project narayana by jbosstm.

the class BlacktieStompAdministrationServiceTest method processStompCommand.

private void processStompCommand(String command, int expectation) throws ConnectionException, ConfigurationException {
    byte[] toSend = command.getBytes();
    X_OCTET buffer = (X_OCTET) connection.tpalloc("X_OCTET", null);
    buffer.setByteArray(toSend);
    Response response = connection.tpcall("BTStompAdmin", buffer, 0);
    byte[] responseData = ((X_OCTET) response.getBuffer()).getByteArray();
    assertEquals(expectation, responseData[0]);
}
Also used : Response(org.jboss.narayana.blacktie.jatmibroker.xatmi.Response) X_OCTET(org.jboss.narayana.blacktie.jatmibroker.xatmi.X_OCTET)

Example 19 with X_OCTET

use of org.jboss.narayana.blacktie.jatmibroker.xatmi.X_OCTET in project narayana by jbosstm.

the class BlacktieStompAdministrationServiceTest method processDomainCommand.

private void processDomainCommand(String command, int expectation) throws ConnectionException, ConfigurationException {
    byte[] toSend = command.getBytes();
    X_OCTET buffer = (X_OCTET) connection.tpalloc("X_OCTET", null);
    buffer.setByteArray(toSend);
    Response response = connection.tpcall("BTDomainAdmin", buffer, 0);
    byte[] responseData = ((X_OCTET) response.getBuffer()).getByteArray();
    assertEquals(expectation, responseData[0]);
}
Also used : Response(org.jboss.narayana.blacktie.jatmibroker.xatmi.Response) X_OCTET(org.jboss.narayana.blacktie.jatmibroker.xatmi.X_OCTET)

Example 20 with X_OCTET

use of org.jboss.narayana.blacktie.jatmibroker.xatmi.X_OCTET 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

Response (org.jboss.narayana.blacktie.jatmibroker.xatmi.Response)29 X_OCTET (org.jboss.narayana.blacktie.jatmibroker.xatmi.X_OCTET)29 ConnectionException (org.jboss.narayana.blacktie.jatmibroker.xatmi.ConnectionException)9 ConfigurationException (org.jboss.narayana.blacktie.jatmibroker.core.conf.ConfigurationException)8 StringTokenizer (java.util.StringTokenizer)3 IOException (java.io.IOException)2 List (java.util.List)2 StringReader (java.io.StringReader)1 UnknownHostException (java.net.UnknownHostException)1 ArrayList (java.util.ArrayList)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 Buffer (org.jboss.narayana.blacktie.jatmibroker.xatmi.Buffer)1 ConnectionFactory (org.jboss.narayana.blacktie.jatmibroker.xatmi.ConnectionFactory)1 ResponseException (org.jboss.narayana.blacktie.jatmibroker.xatmi.ResponseException)1 X_COMMON (org.jboss.narayana.blacktie.jatmibroker.xatmi.X_COMMON)1 X_C_TYPE (org.jboss.narayana.blacktie.jatmibroker.xatmi.X_C_TYPE)1 Document (org.w3c.dom.Document)1 InputSource (org.xml.sax.InputSource)1