use of com.sun.messaging.jmq.io.GPacket in project openmq by eclipse-ee4j.
the class ClusterSubscriptionInfo method getGPacket.
public GPacket getGPacket(short protocol, boolean changeRecord) {
assert (subscription != null);
assert (protocol == ProtocolGlobals.G_NEW_INTEREST || protocol == ProtocolGlobals.G_DURABLE_ATTACH || protocol == ProtocolGlobals.G_REM_DURABLE_INTEREST);
if (changeRecord) {
assert (protocol == ProtocolGlobals.G_NEW_INTEREST || protocol == ProtocolGlobals.G_REM_DURABLE_INTEREST);
}
GPacket gp = null;
switch(protocol) {
case ProtocolGlobals.G_NEW_INTEREST:
ClusterConsumerInfo cci = ClusterConsumerInfo.newInstance(subscription, null);
gp = cci.getGPacket(protocol);
if (changeRecord) {
gp.putProp("N", subscription.getDurableName());
String clientID = subscription.getClientID();
gp.putProp("I", (clientID == null ? "" : clientID));
gp.putProp("M", Boolean.TRUE);
gp.putProp("shared", Boolean.valueOf(subscription.getShared()));
gp.putProp("jmsshared", Boolean.valueOf(subscription.getJMSShared()));
} else {
ChangeRecordInfo cri = subscription.getCurrentChangeRecordInfo(ProtocolGlobals.G_NEW_INTEREST);
if (cri != null) {
gp.putProp("shareccSeq" + 1, cri.getSeq());
gp.putProp("shareccUUID" + 1, cri.getUUID());
gp.putProp("shareccResetUUID" + 1, cri.getResetUUID());
}
}
break;
case ProtocolGlobals.G_DURABLE_ATTACH:
{
assert (consumer != null);
gp = GPacket.getInstance();
gp.setType(protocol);
String dname = subscription.getDurableName();
if (dname != null) {
gp.putProp("N", dname);
}
String clientID = subscription.getClientID();
gp.putProp("I", (clientID == null ? "" : clientID));
String ndsubname = subscription.getNDSubscriptionName();
if (ndsubname != null) {
gp.putProp("NDN", ndsubname);
}
ClusterManager cm = Globals.getClusterManager();
int csize = 1;
if (cm != null) {
csize = cm.getConfigBrokerCount();
if (csize <= 0) {
csize = 1;
}
}
int prefetch = consumer.getPrefetchForRemote() / csize;
if (prefetch <= 0) {
prefetch = 1;
}
gp.putProp(consumer.getConsumerUID().longValue() + ":" + Consumer.PREFETCH, Integer.valueOf(prefetch));
gp.putProp("allowsNonDurable", Boolean.TRUE);
c.marshalBrokerAddress(c.getSelfAddress(), gp);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
try {
ClusterConsumerInfo.writeConsumer(consumer, dos);
dos.flush();
bos.flush();
} catch (IOException e) {
/* Ignore */
}
gp.setPayload(ByteBuffer.wrap(bos.toByteArray()));
}
break;
case ProtocolGlobals.G_REM_DURABLE_INTEREST:
{
gp = GPacket.getInstance();
gp.setType(protocol);
gp.putProp("C", Integer.valueOf(1));
String dname = subscription.getDurableName();
String clientID = subscription.getClientID();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
try {
dos.writeUTF(dname);
dos.writeUTF((clientID == null ? "" : clientID));
dos.flush();
bos.flush();
} catch (IOException e) {
/* Ignore */
}
gp.setPayload(ByteBuffer.wrap(bos.toByteArray()));
if (changeRecord) {
gp.putProp("N", dname);
gp.putProp("I", (clientID == null ? "" : clientID));
gp.putProp("M", Boolean.TRUE);
} else {
ChangeRecordInfo cri = subscription.getCurrentChangeRecordInfo(ProtocolGlobals.G_REM_DURABLE_INTEREST);
if (cri != null) {
gp.putProp("shareccSeq" + 1, cri.getSeq());
gp.putProp("shareccUUID" + 1, cri.getUUID());
gp.putProp("shareccResetUUID" + 1, cri.getResetUUID());
}
}
}
break;
}
return gp;
}
use of com.sun.messaging.jmq.io.GPacket in project openmq by eclipse-ee4j.
the class ClusterSubscriptionInfo method getReplyGPacket.
public static GPacket getReplyGPacket(short protocol, int status) {
GPacket gp = GPacket.getInstance();
gp.setType(protocol);
gp.putProp("S", Integer.valueOf(status));
return gp;
}
use of com.sun.messaging.jmq.io.GPacket in project openmq by eclipse-ee4j.
the class ClusterTakeoverMEInfo method getReplyGPacket.
public GPacket getReplyGPacket(int status, String reason) {
assert (pkt != null);
GPacket gp = GPacket.getInstance();
gp.setType(ProtocolGlobals.G_TAKEOVER_ME_REPLY);
gp.putProp("X", pkt.getProp("X"));
gp.putProp("S", Integer.valueOf(status));
if (reason != null) {
gp.putProp("reason", reason);
}
return gp;
}
use of com.sun.messaging.jmq.io.GPacket in project openmq by eclipse-ee4j.
the class ClusterTakeoverMEInfo method getReplyAckGPacket.
public static GPacket getReplyAckGPacket(GPacket reply) {
GPacket gp = GPacket.getInstance();
gp.setType(ProtocolGlobals.G_TAKEOVER_ME_REPLY_ACK);
gp.putProp("X", reply.getProp("X"));
gp.putProp("S", Integer.valueOf(Status.OK));
return gp;
}
use of com.sun.messaging.jmq.io.GPacket in project openmq by eclipse-ee4j.
the class ClusterTransferFileEndInfo method getGPacket.
public GPacket getGPacket() throws BrokerException {
if (pkt != null) {
return pkt;
}
GPacket gp = GPacket.getInstance();
gp.putProp("uuid", uuid);
gp.putProp("module", module);
gp.putProp("brokerID", brokerID);
gp.putProp("filename", filename);
gp.putProp("morefiles", moreFiles);
gp.setType(ProtocolGlobals.G_TRANSFER_FILE_END);
gp.setPayload(ByteBuffer.wrap(digest));
gp.setBit(gp.A_BIT, true);
return gp;
}
Aggregations