Search in sources :

Example 11 with GPacket

use of com.sun.messaging.jmq.io.GPacket in project openmq by eclipse-ee4j.

the class ClusterMessageInfo method getGPacket.

public GPacket getGPacket() throws Exception {
    assert (ref != null);
    assert (consumers != null);
    GPacket gp = GPacket.getInstance();
    gp.setType(ProtocolGlobals.G_MESSAGE_DATA);
    gp.putProp("D", Boolean.valueOf(sendMessageDeliveredAck));
    gp.putProp("C", Integer.valueOf(consumers.size()));
    if (Globals.getDestinationList().isPartitionMode()) {
        gp.putProp("partitionID", Long.valueOf(ref.getPartitionedStore().getPartitionID().longValue()));
    }
    c.marshalBrokerAddress(c.getSelfAddress(), gp);
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(bos);
    Packet roPkt = null;
    try {
        for (int i = 0; i < consumers.size(); i++) {
            ConsumerUID intid = consumers.get(i).getConsumerUID();
            ClusterConsumerInfo.writeConsumerUID(intid, dos);
            gp.putProp(PROP_PREFIX_CUID_DCT + intid.longValue(), deliveryCnts.get(i));
        }
        if (redelivered) {
            gp.putProp(PROP_REDELIVERED, Boolean.valueOf(redelivered));
        }
        roPkt = ref.getPacket();
        if (roPkt == null) {
            throw new BrokerException(Globals.getBrokerResources().getKString(BrokerResources.X_NULL_PACKET_FROM_REF, ref.toString()));
        }
        roPkt.generateTimestamp(false);
        roPkt.generateSequenceNumber(false);
        roPkt.writePacket(dos);
        dos.flush();
        bos.flush();
    } catch (Exception e) {
        String emsg = Globals.getBrokerResources().getKString(BrokerResources.X_EXCEPTION_WRITE_PKT_ON_SEND_MSG_REMOTE, ref.toString(), e.getMessage());
        if (e instanceof BrokerException) {
            logger.log(Logger.WARNING, emsg);
            throw e;
        }
        logger.logStack(Logger.WARNING, emsg, e);
        throw e;
    }
    byte[] buf = bos.toByteArray();
    gp.setPayload(ByteBuffer.wrap(buf));
    return gp;
}
Also used : GPacket(com.sun.messaging.jmq.io.GPacket) Packet(com.sun.messaging.jmq.io.Packet) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) ConsumerUID(com.sun.messaging.jmq.jmsserver.core.ConsumerUID) GPacket(com.sun.messaging.jmq.io.GPacket) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException)

Example 12 with GPacket

use of com.sun.messaging.jmq.io.GPacket in project openmq by eclipse-ee4j.

the class ClusterTakeoverInfo method getGPacket.

public GPacket getGPacket(short protocol) throws BrokerException {
    // protocol == ProtocolGlobals.G_TAKEOVER_ABORT );
    if (!Globals.getHAEnabled()) {
        throw new BrokerException(Globals.getBrokerResources().getKString(BrokerResources.E_INTERNAL_BROKER_ERROR, "Broker is not running in HA mode"));
    }
    if (pkt != null) {
        assert (pkt.getType() == protocol);
        return pkt;
    }
    GPacket gp = GPacket.getInstance();
    gp.putProp("brokerID", brokerID);
    gp.putProp("storeSession", Long.valueOf(storeSession.longValue()));
    if (protocol == ProtocolGlobals.G_TAKEOVER_COMPLETE) {
        gp.setType(protocol);
        gp.setBit(gp.A_BIT, false);
        return gp;
    }
    HAClusteredBroker cb = (HAClusteredBroker) Globals.getClusterManager().getLocalBroker();
    if (protocol == ProtocolGlobals.G_TAKEOVER_PENDING) {
        gp.setType(ProtocolGlobals.G_TAKEOVER_PENDING);
        gp.setBit(gp.A_BIT, false);
        gp.putProp("brokerSession", Long.valueOf(brokerSession.longValue()));
        gp.putProp("brokerHost", brokerHost);
        if (fromTaker) {
            taker = cb.getBrokerName();
            gp.putProp("taker", taker);
            gp.putProp("timestamp", Long.valueOf(cb.getHeartbeat()));
            gp.setBit(gp.A_BIT, true);
        } else if (timedout) {
            gp.putProp("timestamp", Long.valueOf(0));
        }
        gp.putProp("X", xid);
        return gp;
    }
    if (protocol == ProtocolGlobals.G_TAKEOVER_ABORT) {
        gp.setType(ProtocolGlobals.G_TAKEOVER_ABORT);
        if (fromTaker) {
            gp.putProp("taker", cb.getBrokerName());
        }
        gp.setBit(gp.A_BIT, false);
        gp.putProp("X", xid);
        return gp;
    }
    throw new BrokerException("Unknown protocol: " + protocol);
}
Also used : BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) HAClusteredBroker(com.sun.messaging.jmq.jmsserver.cluster.api.ha.HAClusteredBroker) GPacket(com.sun.messaging.jmq.io.GPacket)

Example 13 with GPacket

use of com.sun.messaging.jmq.io.GPacket in project openmq by eclipse-ee4j.

the class ClusterTransferFileListInfo 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("numfiles", numfiles);
    gp.putProp("module", module);
    gp.setType(ProtocolGlobals.G_TRANSFER_FILE_LIST);
    gp.setBit(gp.A_BIT, false);
    return gp;
}
Also used : GPacket(com.sun.messaging.jmq.io.GPacket)

Example 14 with GPacket

use of com.sun.messaging.jmq.io.GPacket in project openmq by eclipse-ee4j.

the class ClusterBrokerInfoReply method getGPacket.

public GPacket getGPacket() throws Exception {
    GPacket gp = GPacket.getInstance();
    gp.setType(ProtocolGlobals.G_BROKER_INFO_REPLY);
    gp.setBit(pkt.A_BIT, false);
    gp.putProp("S", Integer.valueOf(status));
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(bos);
    oos.writeObject(brokerInfo);
    oos.flush();
    oos.close();
    byte[] buf = bos.toByteArray();
    gp.setPayload(ByteBuffer.wrap(buf));
    return gp;
}
Also used : GPacket(com.sun.messaging.jmq.io.GPacket)

Example 15 with GPacket

use of com.sun.messaging.jmq.io.GPacket in project openmq by eclipse-ee4j.

the class ClusterNewMasterBrokerInfo method getGPacket.

public GPacket getGPacket() throws Exception {
    GPacket gp = GPacket.getInstance();
    gp.setType(ProtocolGlobals.G_NEW_MASTER_BROKER);
    gp.putProp("TS", Long.valueOf(System.currentTimeMillis()));
    gp.putProp("X", xid);
    gp.putProp("UUID", uuid);
    gp.putProp("oldMasterBroker", oldmaster.toProtocolString());
    c.marshalBrokerAddress(newmaster, gp);
    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