Examples of GPacket


Examples of com.sun.messaging.jmq.io.GPacket

    }

    public GPacket getReplyGPacket(int status) {
        assert ( pkt != null );

        GPacket gp = GPacket.getInstance();
        gp.setType(ProtocolGlobals.G_MESSAGE_DATA_REPLY);
        gp.putProp("S", new Integer(status));
        // TBD: ADD SysMessageID as property?

        return gp;
    }
View Full Code Here

Examples of com.sun.messaging.jmq.io.GPacket

        if (pkt != null) {
            assert ( pkt.getType() == protocol );
           return pkt;
        }

        GPacket gp = GPacket.getInstance();
        gp.putProp("brokerID", brokerID);
        gp.putProp("storeSession", new Long(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", new Long(brokerSession.longValue()));
            gp.putProp("brokerHost",  brokerHost);
            if (fromTaker) {
                taker = cb.getBrokerName();
                gp.putProp("taker", taker);
                gp.putProp("timestamp", new Long(cb.getHeartbeat()));
                gp.setBit(gp.A_BIT, true);
            } else if (timedout) {
                gp.putProp("timestamp", new Long(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);
    }
View Full Code Here

Examples of com.sun.messaging.jmq.io.GPacket

    public GPacket getReplyGPacket(short protocol, int status, String reason) {
        assert ( pkt != null );
        assert ( protocol == ProtocolGlobals.G_TAKEOVER_PENDING_REPLY );

        GPacket gp = GPacket.getInstance();
        gp.setType(protocol);
        gp.putProp("X", (Long)pkt.getProp("X"));
        gp.putProp("brokerID", pkt.getProp("brokerID"));
        gp.putProp("storeSession", pkt.getProp("storeSession"));
        gp.putProp("taker", pkt.getProp("taker"));
        gp.putProp("S", new Integer(status));
        if (reason != null) gp.putProp("reason", reason);

        return gp;
    }
View Full Code Here

Examples of com.sun.messaging.jmq.io.GPacket

        return new ClusterGoodbyeInfo(pkt, c);
    }

    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;
    }
View Full Code Here

Examples of com.sun.messaging.jmq.io.GPacket

        }
        return sender.toString();
    }

    public static GPacket getReplyGPacket(int status) {
        GPacket gp = GPacket.getInstance();
        gp.setType(ProtocolGlobals.G_GOODBYE_REPLY);
        gp.putProp("S", new Integer(status));
        return gp;
    }
View Full Code Here

Examples of com.sun.messaging.jmq.io.GPacket

        return new HeartbeatInfo();
    }

    public static HeartbeatInfo newInstance(byte[] data) throws IOException {
        ByteArrayInputStream bis = new ByteArrayInputStream(data);
        GPacket pkt = GPacket.getInstance();
        pkt.read(bis);
        int ver = ((Integer)pkt.getProp("protocolVersion")).intValue();
        if (ver < HEARTBEAT_PROTOCOL_VERSION) {
            throw new IOException("Protocol version not supported:"+ver);
        }
        return new HeartbeatInfo(pkt);
    }
View Full Code Here

Examples of com.sun.messaging.jmq.io.GPacket

        }
        return new HeartbeatInfo(pkt);
    }

    public GPacket getGPacket() {
        GPacket gp = GPacket.getInstance();
        gp.generateSequenceNumber(false);
        gp.setType(HEARTBEAT_ALIVE);
        gp.setSequence(sequence);
        gp.putProp("protocolVersion", new Integer(HEARTBEAT_PROTOCOL_VERSION));
        gp.putProp("brokerID", brokerID);
        gp.putProp("brokerSession", new Long(brokerSession));
        gp.putProp("brokerAddress", brokerAddress.toString());
        gp.putProp("toBrokerID", toBrokerID);
        gp.putProp("toBrokerSession", new Long(toBrokerSession));
        return gp;
    }
View Full Code Here

Examples of com.sun.messaging.jmq.io.GPacket

            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", new Integer(ackType));
        c.marshalBrokerAddress(c.getSelfAddress(), gp);
        if (msgHome.getBrokerSessionUID() != null) {
        gp.putProp("messageBrokerSession", new Long(msgHome.getBrokerSessionUID().longValue()));
        }
        if (msgHome.getHAEnabled()) {
        gp.putProp("messageStoreSession", new Long(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 (ackackXid != null) {
            gp.setBit(gp.A_BIT, true);
            gp.putProp("X", ackackXid);
            if (ackackAsync) {
                gp.putProp("ackackAsync", Boolean.valueOf(true));
            }
        }

        if (ackType == ClusterGlobals.MB_MSG_TXN_ROLLEDBACK) {
            gp.putProp("C", new Integer(0));
            return gp;
        }
        int cnt = sysids.length;
        gp.putProp("C", new Integer(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;
    }
View Full Code Here

Examples of com.sun.messaging.jmq.io.GPacket

    }

    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", (Long)pkt.getProp("X"));
        gp.putProp("T", new Integer(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", new Integer(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", new Integer(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;
View Full Code Here

Examples of com.sun.messaging.jmq.io.GPacket

        return new ClusterTxnInquiryInfo(pkt);
    }

    public GPacket getGPacket() throws IOException {

        GPacket gp = GPacket.getInstance();
        gp.setType(ProtocolGlobals.G_TRANSACTION_INQUIRY);
        gp.putProp("transactionID", transactionID);
        gp.setBit(gp.A_BIT, true);
        if (replyXid != null) gp.putProp("X", replyXid);
        if (txnhome != null) gp.putProp("transactionHome", txnhome.toProtocolString());

        return gp;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.