Search in sources :

Example 6 with GPacket

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

the class ClusterDestInfo method getGPacket.

public GPacket getGPacket(short protocol, boolean changeRecord) {
    assert (d != null);
    assert (protocol == ProtocolGlobals.G_REM_DESTINATION || protocol == ProtocolGlobals.G_UPDATE_DESTINATION);
    GPacket gp = GPacket.getInstance();
    gp.setType(protocol);
    gp.putProp("N", d.getDestinationName());
    gp.putProp("DT", Integer.valueOf(d.getType()));
    switch(protocol) {
        case ProtocolGlobals.G_REM_DESTINATION:
            ChangeRecordInfo cri = d.getCurrentChangeRecordInfo(ProtocolGlobals.G_REM_DESTINATION);
            if (cri != null) {
                gp.putProp("shareccSeq", cri.getSeq());
                gp.putProp("shareccUUID", cri.getUUID());
                gp.putProp("shareccResetUUID", cri.getResetUUID());
            }
            break;
        case ProtocolGlobals.G_UPDATE_DESTINATION:
            cri = d.getCurrentChangeRecordInfo(ProtocolGlobals.G_UPDATE_DESTINATION);
            if (cri != null) {
                gp.putProp("shareccSeq", cri.getSeq());
                gp.putProp("shareccUUID", cri.getUUID());
                gp.putProp("shareccResetUUID", cri.getResetUUID());
            }
            if (DestType.isTemporary(d.getType())) {
                ConnectionUID cuid = d.getConnectionUID();
                if (cuid != null) {
                    gp.putProp("connectionUID", Long.valueOf(cuid.longValue()));
                }
            }
            HashMap props = d.getDestinationProperties();
            if (props == null) {
                props = new HashMap();
            }
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            try {
                PacketProperties.write(props, bos);
                bos.flush();
            } catch (IOException e) {
            /* Ignore */
            }
            byte[] buf = bos.toByteArray();
            gp.setPayload(ByteBuffer.wrap(buf));
            break;
    }
    if (changeRecord) {
        gp.putProp("M", Boolean.TRUE);
    }
    return gp;
}
Also used : ChangeRecordInfo(com.sun.messaging.jmq.jmsserver.persist.api.ChangeRecordInfo) ConnectionUID(com.sun.messaging.jmq.jmsserver.service.ConnectionUID) GPacket(com.sun.messaging.jmq.io.GPacket)

Example 7 with GPacket

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

the class ClusterGoodbyeInfo method getGPacket.

public GPacket getGPacket() {
    GPacket gp = GPacket.getInstance();
    gp.setType(ProtocolGlobals.G_GOODBYE);
    gp.setBit(gp.A_BIT, true);
    c.marshalBrokerAddress(c.getSelfAddress(), gp);
    if (c.getSelfAddress().getHAEnabled()) {
        gp.putProp("requestTakeover", Boolean.valueOf(requestTakeover));
    }
    return gp;
}
Also used : GPacket(com.sun.messaging.jmq.io.GPacket)

Example 8 with GPacket

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

the class ClusterGoodbyeInfo method getReplyGPacket.

public static GPacket getReplyGPacket(int status) {
    GPacket gp = GPacket.getInstance();
    gp.setType(ProtocolGlobals.G_GOODBYE_REPLY);
    gp.putProp("S", Integer.valueOf(status));
    return gp;
}
Also used : GPacket(com.sun.messaging.jmq.io.GPacket)

Example 9 with GPacket

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

the class ClusterMessageAckInfo method getReplyGPacket.

public GPacket getReplyGPacket(int status, String reason, ArrayList[] aes) {
    assert (pkt != null);
    GPacket gp = GPacket.getInstance();
    gp.setType(ProtocolGlobals.G_MESSAGE_ACK_REPLY);
    gp.putProp("X", pkt.getProp("X"));
    gp.putProp("T", Integer.valueOf(getAckType()));
    if (pkt.getProp("C") != null) {
        gp.putProp("C", pkt.getProp("C"));
    }
    if (pkt.getProp("messageBrokerSession") != null) {
        gp.putProp("messageBrokerSession", pkt.getProp("messageBrokerSession"));
    }
    if (pkt.getProp("messageStoreSession") != null) {
        gp.putProp("messageStoreSession", pkt.getProp("messageStoreSession"));
    }
    if (pkt.getProp("transactionID") != null) {
        gp.putProp("transactionID", pkt.getProp("transactionID"));
    }
    if (pkt.getProp("ackackAsync") != null) {
        gp.putProp("ackackAsync", pkt.getProp("ackackAsync"));
    }
    gp.putProp("S", Integer.valueOf(status));
    if (reason != null) {
        gp.putProp("reason", reason);
    }
    if (aes == null) {
        if (pkt.getPayload() != null) {
            gp.setPayload(ByteBuffer.wrap(pkt.getPayload().array()));
        }
        return gp;
    }
    gp.putProp("notfound", Integer.valueOf(aes[0].size()));
    try {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        DataOutputStream dos = new DataOutputStream(bos);
        for (int i = 0; i < aes[0].size(); i++) {
            ((SysMessageID) aes[0].get(i)).writeID(dos);
            ClusterConsumerInfo.writeConsumerUID((com.sun.messaging.jmq.jmsserver.core.ConsumerUID) aes[1].get(i), dos);
        }
        dos.flush();
        bos.flush();
        byte[] buf = bos.toByteArray();
        gp.setPayload(ByteBuffer.wrap(buf));
    } catch (Exception e) {
        Globals.getLogger().logStack(Globals.getLogger().WARNING, e.getMessage(), e);
    }
    return gp;
}
Also used : SysMessageID(com.sun.messaging.jmq.io.SysMessageID) GPacket(com.sun.messaging.jmq.io.GPacket) AckEntryNotFoundException(com.sun.messaging.jmq.jmsserver.util.AckEntryNotFoundException)

Example 10 with GPacket

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

the class ClusterMessageAckInfo method getGPacket.

public GPacket getGPacket() throws IOException {
    if (twophase && transactionID == null) {
        throw new IOException(Globals.getBrokerResources().getKString(BrokerResources.E_INTERNAL_BROKER_ERROR, "transactionID required for two-phase ack"));
    }
    GPacket gp = GPacket.getInstance();
    gp.setType(ProtocolGlobals.G_MESSAGE_ACK);
    gp.putProp("T", Integer.valueOf(ackType));
    c.marshalBrokerAddress(c.getSelfAddress(), gp);
    if (msgHome.getBrokerSessionUID() != null) {
        gp.putProp("messageBrokerSession", Long.valueOf(msgHome.getBrokerSessionUID().longValue()));
    }
    if (msgHome.getStoreSessionUID() != null) {
        gp.putProp("messageStoreSession", Long.valueOf(msgHome.getStoreSessionUID().longValue()));
    }
    if (optionalProps != null) {
        Object pn = null;
        Iterator itr = optionalProps.keySet().iterator();
        while (itr.hasNext()) {
            pn = itr.next();
            gp.putProp(pn, optionalProps.get(pn));
        }
    }
    if (transactionID != null) {
        gp.putProp("transactionID", transactionID);
        if (txnStoreSession != null) {
            gp.putProp("transactionStoreSession", Long.valueOf(txnStoreSession.longValue()));
        }
    }
    if (ackackXid != null) {
        gp.setBit(gp.A_BIT, true);
        gp.putProp("X", ackackXid);
        if (ackackAsync) {
            gp.putProp("ackackAsync", Boolean.TRUE);
        }
    }
    if (ackType == ClusterGlobals.MB_MSG_TXN_ROLLEDBACK) {
        gp.putProp("C", Integer.valueOf(0));
        return gp;
    }
    int cnt = sysids.length;
    gp.putProp("C", Integer.valueOf(cnt));
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(bos);
    for (int i = 0; i < cnt; i++) {
        sysids[i].writeID(dos);
        ClusterConsumerInfo.writeConsumerUID(intids[i], dos);
    }
    dos.flush();
    bos.flush();
    byte[] buf = bos.toByteArray();
    gp.setPayload(ByteBuffer.wrap(buf));
    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