use of com.sun.messaging.jmq.io.GPacket in project openmq by eclipse-ee4j.
the class TakingoverEntry method main.
public static void main(String[] args) throws Exception {
Map<TakingoverEntry, TakingoverEntry> map = Collections.synchronizedMap(new LinkedHashMap<TakingoverEntry, TakingoverEntry>());
String broker2 = "broker2";
String host2 = "10.133.184.56";
UID ssuid = new UID();
UID buid = new UID();
Long xid1 = Long.valueOf(UniqueID.generateID(UID.getPrefix()));
ClusterTakeoverInfo cti1 = ClusterTakeoverInfo.newInstance(broker2, ssuid, host2, buid, xid1, true);
Thread.sleep(10);
buid = new UID();
Long xid2 = Long.valueOf(UniqueID.generateID(UID.getPrefix()));
ClusterTakeoverInfo cti2 = ClusterTakeoverInfo.newInstance(broker2, ssuid, host2, buid, xid2, true);
Thread.sleep(10);
buid = new UID();
Long xid3 = Long.valueOf(UniqueID.generateID(UID.getPrefix()));
ClusterTakeoverInfo cti3 = ClusterTakeoverInfo.newInstance(broker2, ssuid, host2, buid, xid3, true);
TakingoverEntry toe = TakingoverEntry.addTakingoverEntry(map, cti2);
toe.preTakeoverDone(xid2);
System.out.println("Added entry " + toe.toLongString());
toe = TakingoverEntry.addTakingoverEntry(map, cti3);
toe.preTakeoverDone(xid3);
System.out.println("Added entry " + toe.toLongString());
toe = TakingoverEntry.addTakingoverEntry(map, cti1);
toe.preTakeoverDone(xid1);
System.out.println("Added entry " + toe.toLongString());
toe = new TakingoverEntry(broker2, ssuid);
// ClusterTakeoverInfo cti = ClusterTakeoverInfo.newInstance(broker2, ssuid);
// TakingoverEntry.takeoverComplete(map, cti);
// Thread.sleep(60000);
toe = map.get(toe);
System.out.println("getNotificationGPackets() for " + toe.toLongString());
GPacket[] gps = toe.getNotificationGPackets();
for (int i = 0; i < gps.length; i++) {
System.out.println("returned: " + ClusterTakeoverInfo.newInstance(gps[i]).toString());
}
BrokerAddress addr = new BrokerAddressImpl("joe-s10-3", broker2, 7677, true, broker2, ssuid, ssuid);
System.out.println("getNotificationGPacket(" + addr + ") for " + toe.toLongString());
GPacket gp = toe.getNotificationGPacket(addr);
if (gp != null) {
System.out.println("returned: " + ClusterTakeoverInfo.newInstance(gp).toString());
} else {
System.out.println("returned null");
}
}
use of com.sun.messaging.jmq.io.GPacket in project openmq by eclipse-ee4j.
the class ClusterTransferFileRequestInfo method getReplyGPacket.
public GPacket getReplyGPacket(int status, String reason) {
assert (pkt != null);
GPacket gp = GPacket.getInstance();
gp.setType(ProtocolGlobals.G_TRANSFER_FILE_REQUEST_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 ClusterTransferFileRequestInfo method getGPacket.
public GPacket getGPacket() throws BrokerException {
if (pkt != null) {
return pkt;
}
GPacket gp = GPacket.getInstance();
gp.putProp("uuid", uuid);
gp.putProp("brokerID", brokerID);
gp.putProp("X", xid);
gp.setType(ProtocolGlobals.G_TRANSFER_FILE_REQUEST);
gp.setBit(gp.A_BIT, true);
return gp;
}
use of com.sun.messaging.jmq.io.GPacket in project openmq by eclipse-ee4j.
the class ChangeRecord method processChangeRecords.
private static void processChangeRecords(List<ChangeRecordInfo> records, ChangeRecordCallback cb, MessageBusCallback mbcb, RaptorProtocol proto) throws BrokerException {
Globals.getLogger().log(Logger.INFO, Globals.getBrokerResources().getKString(BrokerResources.I_CLUSTER_PROCESS_CHANGE_RECORDS, Integer.valueOf(records.size())));
boolean resetFlag = false;
if (records.size() > 0 && records.get(0).isSelectAll()) {
resetFlag = true;
}
String resetUUID = null;
try {
ArrayList l = new ArrayList();
for (int i = 0; i < records.size(); i++) {
ByteArrayInputStream bis = new ByteArrayInputStream(records.get(i).getRecord());
DataInputStream dis = new DataInputStream(bis);
GPacket gp = GPacket.getInstance();
gp.read(dis);
if (gp.getType() != records.get(i).getType()) {
throw new BrokerException(Globals.getBrokerResources().getKString(BrokerResources.X_SHARECC_RECORD_TYPE_CORRUPT, ProtocolGlobals.getPacketTypeString(gp.getType()), records.get(i).toString()));
}
if (gp.getType() == ProtocolGlobals.G_RESET_PERSISTENCE) {
String uuid = records.get(i).getUUID();
if (resetUUID != null && !resetUUID.equals(uuid)) {
throw new BrokerException(Globals.getBrokerResources().getKString(BrokerResources.X_SHARECC_RESET_RECORD_UUID_CORRUPT, ProtocolGlobals.getPacketTypeString(ProtocolGlobals.G_RESET_PERSISTENCE), "[" + resetUUID + ", " + uuid + "]"));
} else if (resetUUID == null) {
resetUUID = uuid;
}
}
if (resetFlag) {
l.add(gp);
} else {
proto.handleGPacket(mbcb, Globals.getMyAddress(), gp);
}
}
if (resetFlag) {
proto.applyPersistentStateChanges(Globals.getMyAddress(), l);
}
if (records.size() > 0) {
ChangeRecordInfo rec = records.get(records.size() - 1);
cb.setLastSyncedChangeRecord(rec);
storeLastSeq(rec.getSeq());
if (resetFlag && resetUUID != null) {
rec.setResetUUID(resetUUID);
storeLastResetUUID(resetUUID);
}
}
} catch (Throwable t) {
Globals.getLogger().logStack(Logger.ERROR, Globals.getBrokerResources().getKString(BrokerResources.E_FAIL_PROCESS_SHARECC_RECORDS, t.getMessage()), t);
if (t instanceof BrokerException) {
throw (BrokerException) t;
}
throw new BrokerException(t.getMessage(), t);
}
}
use of com.sun.messaging.jmq.io.GPacket in project openmq by eclipse-ee4j.
the class ChangeRecord method recordCreateSubscription.
public static void recordCreateSubscription(Subscription sub, ChangeRecordCallback cb) throws BrokerException {
ClusterSubscriptionInfo csi = ClusterSubscriptionInfo.newInstance(sub);
GPacket gp = csi.getGPacket(ProtocolGlobals.G_NEW_INTEREST, true);
ChangeRecordInfo cri = storeChangeRecord(gp, cb);
sub.setCurrentChangeRecordInfo(ProtocolGlobals.G_NEW_INTEREST, cri);
}
Aggregations