use of org.jboss.narayana.blacktie.jatmibroker.xatmi.X_OCTET in project narayana by jbosstm.
the class TPCallXOctetZeroService method tpservice.
public Response tpservice(TPSVCINFO svcinfo) throws ConnectionException, ConfigurationException {
byte[] recv = ((X_OCTET) svcinfo.getBuffer()).getByteArray();
byte[] toSend = new byte[recv.length];
int j = recv.length;
for (int i = 0; i < toSend.length; i++) {
toSend[i] = recv[--j];
}
X_OCTET toReturn = (X_OCTET) svcinfo.getConnection().tpalloc("X_OCTET", null);
toReturn.setByteArray(toSend);
return new Response((short) 0, 0, toReturn, 0);
}
use of org.jboss.narayana.blacktie.jatmibroker.xatmi.X_OCTET in project narayana by jbosstm.
the class RollbackOnlyTprecvTPEVSVCFAILService method tpservice.
public Response tpservice(TPSVCINFO svcinfo) throws ConnectionException, ConfigurationException {
log.info("test_tprecv_TPEV_SVCFAIL_service");
int len = 60;
X_OCTET toReturn = (X_OCTET) svcinfo.getConnection().tpalloc("X_OCTET", null);
toReturn.setByteArray("test_tprecv_TPEV_SVCFAIL_service".getBytes());
return new Response(Connection.TPFAIL, 0, toReturn, 0);
}
use of org.jboss.narayana.blacktie.jatmibroker.xatmi.X_OCTET in project narayana by jbosstm.
the class RollbackOnlyTpcallTPESVCFAILService method tpservice.
public Response tpservice(TPSVCINFO svcinfo) throws ConnectionException, ConfigurationException {
log.info("test_tpcall_TPESVCFAIL_service");
int len = 60;
X_OCTET toReturn = (X_OCTET) svcinfo.getConnection().tpalloc("X_OCTET", null);
toReturn.setByteArray("test_tpcall_TPESVCFAIL_service".getBytes());
return new Response(Connection.TPFAIL, 0, toReturn, 0);
}
use of org.jboss.narayana.blacktie.jatmibroker.xatmi.X_OCTET in project narayana by jbosstm.
the class BlacktieStompAdministrationService method tpservice.
public Response tpservice(TPSVCINFO svcinfo) {
log.debug("Message received");
X_OCTET recv = (X_OCTET) svcinfo.getBuffer();
String string = new String(recv.getByteArray());
StringTokenizer st = new StringTokenizer(string, ",", false);
String operation = st.nextToken();
String serverName = st.nextToken();
String serviceName = st.nextToken();
byte[] success = new byte[1];
String server = null;
try {
if (serviceName.indexOf(".") > -1) {
server = serviceName.substring(1);
server = server.replaceAll("[0-9]", "");
} else {
ServerInfo info = SERVICE_OWNERS.get(serviceName);
if (info == null) {
server = serverName;
} else {
server = info.name;
}
}
if (server != null && server.equals(serverName)) {
log.trace("Service " + serviceName + " exists for server: " + server);
if (operation.equals("tpadvertise")) {
log.trace("Advertising: " + serviceName);
boolean conversational = st.nextToken().equals("1");
String type = st.nextToken();
String version = st.nextToken();
success[0] = (byte) deployQueue(serviceName, serverName, conversational, type, version);
log.trace("Advertised: " + serviceName);
} else if (operation.equals("decrementconsumer")) {
log.trace("Decrement consumer: " + serviceName);
success[0] = (byte) decrementConsumer(serviceName);
log.trace("Decremented consumer: " + serviceName);
} else {
log.error("Unknown operation " + operation);
success[0] = 0;
}
} else {
log.error("Service " + serviceName + " already exists for a different server (" + server + ")");
success[0] = 0;
}
X_OCTET buffer = (X_OCTET) svcinfo.getConnection().tpalloc("X_OCTET", null);
buffer.setByteArray(success);
log.debug("Responding");
return new Response(Connection.TPSUCCESS, 0, buffer, 0);
} catch (ConnectionException e) {
return new Response(Connection.TPFAIL, 0, null, 0);
} catch (ConfigurationException e) {
return new Response(Connection.TPFAIL, 0, null, 0);
} catch (UnknownHostException e) {
return new Response(Connection.TPFAIL, 0, null, 0);
}
}
use of org.jboss.narayana.blacktie.jatmibroker.xatmi.X_OCTET in project narayana by jbosstm.
the class AdministrationProxy method getServiceCounterById.
public long getServiceCounterById(String serverName, int id, String serviceName) {
log.trace("getServiceCounterById");
long counter = 0;
String command = "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;
}
Aggregations