Search in sources :

Example 21 with GPacket

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");
    }
}
Also used : UID(com.sun.messaging.jmq.util.UID) BrokerAddressImpl(com.sun.messaging.jmq.jmsserver.multibroker.fullyconnected.BrokerAddressImpl) GPacket(com.sun.messaging.jmq.io.GPacket) BrokerAddress(com.sun.messaging.jmq.jmsserver.core.BrokerAddress)

Example 22 with GPacket

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;
}
Also used : GPacket(com.sun.messaging.jmq.io.GPacket)

Example 23 with GPacket

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;
}
Also used : GPacket(com.sun.messaging.jmq.io.GPacket)

Example 24 with GPacket

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);
    }
}
Also used : BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) ArrayList(java.util.ArrayList) ChangeRecordInfo(com.sun.messaging.jmq.jmsserver.persist.api.ChangeRecordInfo) GPacket(com.sun.messaging.jmq.io.GPacket)

Example 25 with GPacket

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);
}
Also used : ChangeRecordInfo(com.sun.messaging.jmq.jmsserver.persist.api.ChangeRecordInfo) GPacket(com.sun.messaging.jmq.io.GPacket) ClusterSubscriptionInfo(com.sun.messaging.jmq.jmsserver.multibroker.raptor.ClusterSubscriptionInfo)

Aggregations

GPacket (com.sun.messaging.jmq.io.GPacket)51 ChangeRecordInfo (com.sun.messaging.jmq.jmsserver.persist.api.ChangeRecordInfo)9 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)8 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 SysMessageID (com.sun.messaging.jmq.io.SysMessageID)2 ClusterManager (com.sun.messaging.jmq.jmsserver.cluster.api.ClusterManager)2 ClusterDestInfo (com.sun.messaging.jmq.jmsserver.multibroker.raptor.ClusterDestInfo)2 ClusterSubscriptionInfo (com.sun.messaging.jmq.jmsserver.multibroker.raptor.ClusterSubscriptionInfo)2 ClusterTransferFileEndInfo (com.sun.messaging.jmq.jmsserver.multibroker.raptor.ClusterTransferFileEndInfo)2 ClusterTransferFileListInfo (com.sun.messaging.jmq.jmsserver.multibroker.raptor.ClusterTransferFileListInfo)2 ClusterTransferFileStartInfo (com.sun.messaging.jmq.jmsserver.multibroker.raptor.ClusterTransferFileStartInfo)2 LoadException (com.sun.messaging.jmq.jmsserver.persist.api.LoadException)2 LoopbackAddressException (com.sun.messaging.jmq.jmsserver.util.LoopbackAddressException)2 ArrayList (java.util.ArrayList)2 Packet (com.sun.messaging.jmq.io.Packet)1 HAClusteredBroker (com.sun.messaging.jmq.jmsserver.cluster.api.ha.HAClusteredBroker)1 BrokerAddress (com.sun.messaging.jmq.jmsserver.core.BrokerAddress)1 Consumer (com.sun.messaging.jmq.jmsserver.core.Consumer)1 ConsumerUID (com.sun.messaging.jmq.jmsserver.core.ConsumerUID)1 Subscription (com.sun.messaging.jmq.jmsserver.core.Subscription)1