use of com.sun.messaging.jmq.io.GPacket in project openmq by eclipse-ee4j.
the class ClusterDestInfo method getGPacket.
public GPacket getGPacket(short protocol, boolean changeRecord) {
assert (d != null);
assert (protocol == ProtocolGlobals.G_REM_DESTINATION || protocol == ProtocolGlobals.G_UPDATE_DESTINATION);
GPacket gp = GPacket.getInstance();
gp.setType(protocol);
gp.putProp("N", d.getDestinationName());
gp.putProp("DT", Integer.valueOf(d.getType()));
switch(protocol) {
case ProtocolGlobals.G_REM_DESTINATION:
ChangeRecordInfo cri = d.getCurrentChangeRecordInfo(ProtocolGlobals.G_REM_DESTINATION);
if (cri != null) {
gp.putProp("shareccSeq", cri.getSeq());
gp.putProp("shareccUUID", cri.getUUID());
gp.putProp("shareccResetUUID", cri.getResetUUID());
}
break;
case ProtocolGlobals.G_UPDATE_DESTINATION:
cri = d.getCurrentChangeRecordInfo(ProtocolGlobals.G_UPDATE_DESTINATION);
if (cri != null) {
gp.putProp("shareccSeq", cri.getSeq());
gp.putProp("shareccUUID", cri.getUUID());
gp.putProp("shareccResetUUID", cri.getResetUUID());
}
if (DestType.isTemporary(d.getType())) {
ConnectionUID cuid = d.getConnectionUID();
if (cuid != null) {
gp.putProp("connectionUID", Long.valueOf(cuid.longValue()));
}
}
HashMap props = d.getDestinationProperties();
if (props == null) {
props = new HashMap();
}
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
PacketProperties.write(props, bos);
bos.flush();
} catch (IOException e) {
/* Ignore */
}
byte[] buf = bos.toByteArray();
gp.setPayload(ByteBuffer.wrap(buf));
break;
}
if (changeRecord) {
gp.putProp("M", Boolean.TRUE);
}
return gp;
}
use of com.sun.messaging.jmq.io.GPacket in project openmq by eclipse-ee4j.
the class ClusterGoodbyeInfo method getGPacket.
public GPacket getGPacket() {
GPacket gp = GPacket.getInstance();
gp.setType(ProtocolGlobals.G_GOODBYE);
gp.setBit(gp.A_BIT, true);
c.marshalBrokerAddress(c.getSelfAddress(), gp);
if (c.getSelfAddress().getHAEnabled()) {
gp.putProp("requestTakeover", Boolean.valueOf(requestTakeover));
}
return gp;
}
use of com.sun.messaging.jmq.io.GPacket in project openmq by eclipse-ee4j.
the class ClusterGoodbyeInfo method getReplyGPacket.
public static GPacket getReplyGPacket(int status) {
GPacket gp = GPacket.getInstance();
gp.setType(ProtocolGlobals.G_GOODBYE_REPLY);
gp.putProp("S", Integer.valueOf(status));
return gp;
}
use of com.sun.messaging.jmq.io.GPacket in project openmq by eclipse-ee4j.
the class ClusterMessageAckInfo method getReplyGPacket.
public GPacket getReplyGPacket(int status, String reason, ArrayList[] aes) {
assert (pkt != null);
GPacket gp = GPacket.getInstance();
gp.setType(ProtocolGlobals.G_MESSAGE_ACK_REPLY);
gp.putProp("X", pkt.getProp("X"));
gp.putProp("T", Integer.valueOf(getAckType()));
if (pkt.getProp("C") != null) {
gp.putProp("C", pkt.getProp("C"));
}
if (pkt.getProp("messageBrokerSession") != null) {
gp.putProp("messageBrokerSession", pkt.getProp("messageBrokerSession"));
}
if (pkt.getProp("messageStoreSession") != null) {
gp.putProp("messageStoreSession", pkt.getProp("messageStoreSession"));
}
if (pkt.getProp("transactionID") != null) {
gp.putProp("transactionID", pkt.getProp("transactionID"));
}
if (pkt.getProp("ackackAsync") != null) {
gp.putProp("ackackAsync", pkt.getProp("ackackAsync"));
}
gp.putProp("S", Integer.valueOf(status));
if (reason != null) {
gp.putProp("reason", reason);
}
if (aes == null) {
if (pkt.getPayload() != null) {
gp.setPayload(ByteBuffer.wrap(pkt.getPayload().array()));
}
return gp;
}
gp.putProp("notfound", Integer.valueOf(aes[0].size()));
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
for (int i = 0; i < aes[0].size(); i++) {
((SysMessageID) aes[0].get(i)).writeID(dos);
ClusterConsumerInfo.writeConsumerUID((com.sun.messaging.jmq.jmsserver.core.ConsumerUID) aes[1].get(i), dos);
}
dos.flush();
bos.flush();
byte[] buf = bos.toByteArray();
gp.setPayload(ByteBuffer.wrap(buf));
} catch (Exception e) {
Globals.getLogger().logStack(Globals.getLogger().WARNING, e.getMessage(), e);
}
return gp;
}
use of com.sun.messaging.jmq.io.GPacket in project openmq by eclipse-ee4j.
the class ClusterMessageAckInfo method getGPacket.
public GPacket getGPacket() throws IOException {
if (twophase && transactionID == null) {
throw new IOException(Globals.getBrokerResources().getKString(BrokerResources.E_INTERNAL_BROKER_ERROR, "transactionID required for two-phase ack"));
}
GPacket gp = GPacket.getInstance();
gp.setType(ProtocolGlobals.G_MESSAGE_ACK);
gp.putProp("T", Integer.valueOf(ackType));
c.marshalBrokerAddress(c.getSelfAddress(), gp);
if (msgHome.getBrokerSessionUID() != null) {
gp.putProp("messageBrokerSession", Long.valueOf(msgHome.getBrokerSessionUID().longValue()));
}
if (msgHome.getStoreSessionUID() != null) {
gp.putProp("messageStoreSession", Long.valueOf(msgHome.getStoreSessionUID().longValue()));
}
if (optionalProps != null) {
Object pn = null;
Iterator itr = optionalProps.keySet().iterator();
while (itr.hasNext()) {
pn = itr.next();
gp.putProp(pn, optionalProps.get(pn));
}
}
if (transactionID != null) {
gp.putProp("transactionID", transactionID);
if (txnStoreSession != null) {
gp.putProp("transactionStoreSession", Long.valueOf(txnStoreSession.longValue()));
}
}
if (ackackXid != null) {
gp.setBit(gp.A_BIT, true);
gp.putProp("X", ackackXid);
if (ackackAsync) {
gp.putProp("ackackAsync", Boolean.TRUE);
}
}
if (ackType == ClusterGlobals.MB_MSG_TXN_ROLLEDBACK) {
gp.putProp("C", Integer.valueOf(0));
return gp;
}
int cnt = sysids.length;
gp.putProp("C", Integer.valueOf(cnt));
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
for (int i = 0; i < cnt; i++) {
sysids[i].writeID(dos);
ClusterConsumerInfo.writeConsumerUID(intids[i], dos);
}
dos.flush();
bos.flush();
byte[] buf = bos.toByteArray();
gp.setPayload(ByteBuffer.wrap(buf));
return gp;
}
Aggregations