Search in sources :

Example 16 with GPacket

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

Example 17 with GPacket

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

Example 18 with GPacket

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

Example 19 with GPacket

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

Example 20 with GPacket

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

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