Examples of GPacket


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

        return new ClusterNewMasterBrokerInfo(pkt, c);
    }

    public GPacket getGPacket() throws Exception {

        GPacket gp = GPacket.getInstance();
        gp.setType(ProtocolGlobals.G_NEW_MASTER_BROKER);
        gp.putProp("TS", new Long(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;
    }
View Full Code Here

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

        return (Long)pkt.getProp("TS");
    }

    public GPacket getReplyGPacket(int status, String reason) {
        assert( pkt != null);
        GPacket gp = GPacket.getInstance();
        gp.setType(ProtocolGlobals.G_NEW_MASTER_BROKER_REPLY);
        gp.putProp("X", (Long)pkt.getProp("X"));
        gp.putProp("UUID", (String)pkt.getProp("UUID"));
        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 ClusterTxnInfoInfo(pkt, c);
    }

    public GPacket getGPacket() throws IOException {

        GPacket gp = GPacket.getInstance();
        gp.setType(ProtocolGlobals.G_TRANSACTION_INFO);
        gp.putProp("transactionID", transactionID);
        gp.putProp("transactionState", new Integer(transactionState));
        if (owner) {
        gp.putProp("owner", Boolean.valueOf(true));
        c.marshalBrokerAddress(c.getSelfAddress(), gp);
        }
        if (brokers != null) {
            StringBuffer buf = new StringBuffer();
            for (int i = 0; i < brokers.length; i++) {
                if (i > 0) buf.append(",");
                buf.append(brokers[i].toProtocolString());
            }
            gp.putProp("brokers", buf.toString());
        }
        if (waitfor != null) {
            StringBuffer buf = new StringBuffer();
            for (int i = 0; i < waitfor.length; i++) {
                if (i > 0) buf.append(",");
                buf.append(waitfor[i].toProtocolString());
            }
            gp.putProp("waitfor", buf.toString());
        }
        if (txnHome != null) {
            gp.putProp("transactionHome", txnHome.toProtocolString());
        }
        if (xid != null) gp.putProp("X", xid);
        gp.setBit(gp.A_BIT, false);

        return gp;
    }
View Full Code Here

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

        assert ( subtype == ProtocolGlobals.G_NEW_PRIMARY_INTEREST || // not effectively used ?
                 subtype == ProtocolGlobals.G_REM_INTEREST ||
                 subtype == ProtocolGlobals.G_DURABLE_DETACH );
        }

        GPacket gp = GPacket.getInstance();
        gp.setType(protocol);
        gp.putProp("C", new Integer(consumers.size()));
        if (broker != null && pendingMsgs != null && pendingMsgs.size() > 0) {
            List l = (List)pendingMsgs.get(broker);
            if (l != null) {
                StringBuffer sb = new StringBuffer();
                Iterator itr = l.iterator();
                while (itr.hasNext()) {
                    SysMessageID sysid = (SysMessageID)itr.next();
                    sb.append(sysid).append(" ");
                }
                gp.putProp("pendingMessages", new String(sb.toString()));
            }
        }
        if (cleanup) gp.putProp("cleanup", new Boolean(true));
        if (c != null) c.marshalBrokerAddress(c.getSelfAddress(), gp);

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        DataOutputStream dos = new DataOutputStream(bos);

        switch (protocol) {
            case ProtocolGlobals.G_NEW_INTEREST:

            try {
                int i = 0;
                Iterator itr = consumers.iterator();
                while (itr.hasNext()) {
                    i++;
                    Consumer c = (Consumer) itr.next();
                    gp.putProp(String.valueOf(c.getConsumerUID().longValue())+":"
                                              +Consumer.PREFETCH,
                               new Integer(c.getPrefetch()));
                    writeConsumer(c, dos);
                    if (!(c instanceof Subscription)) {
                        continue;
                    }
                    ChangeRecordInfo cri =
                        ((Subscription)c).getCurrentChangeRecordInfo(
                                          ProtocolGlobals.G_NEW_INTEREST);
                    if (cri == null) {
                        continue;
                    }
                    gp.putProp("shareccSeq"+i, cri.getSeq());
                    gp.putProp("shareccUUID"+i, cri.getUUID());
                    gp.putProp("shareccResetUUID"+i, cri.getResetUUID());
                }
                dos.flush();
                bos.flush();
            }
            catch (IOException e) { /* Ignore */ }

            gp.setPayload(ByteBuffer.wrap(bos.toByteArray()));
            break;

            case ProtocolGlobals.G_INTEREST_UPDATE:

            gp.putProp("T", new Integer(subtype));
            try {
                Iterator itr = consumers.iterator();
                while (itr.hasNext()) {
                    Consumer c = (Consumer)itr.next();
                    writeConsumerUID(c.getConsumerUID(), dos);
                }
                dos.flush();
                bos.flush();
            }
            catch (IOException e) { /* Ignore */ }

            gp.setPayload(ByteBuffer.wrap(bos.toByteArray()));
            break;
        }

        return gp;
    }
View Full Code Here

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

        cuid.setBrokerAddress(brokeraddr);
        return cuid;
    }

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

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

    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", new Integer(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", new Long(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.valueOf(true));

        return gp;
    }
View Full Code Here

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

        return new ClusterNewMasterBrokerPrepareInfo(pkt, c);
    }

    public GPacket getGPacket() throws Exception {

        GPacket gp = GPacket.getInstance();
        gp.setType(ProtocolGlobals.G_NEW_MASTER_BROKER_PREPARE);
        gp.putProp("TS", new Long(System.currentTimeMillis()));
        gp.putProp("C", new Integer(records.size()));
        gp.putProp("X", xid);
        gp.putProp("UUID", uuid);
        c.marshalBrokerAddress(newmaster, gp);

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        for (int i = 0; i < records.size(); i++) {
            byte[] rec = records.get(i).getRecord();
            bos.write(rec, 0, rec.length);
        }
        bos.flush();
        byte[] buf = bos.toByteArray();
        gp.setPayload(ByteBuffer.wrap(buf));
        gp.setBit(gp.A_BIT, true);

        return gp;
    }
View Full Code Here

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

        return buf;
    }

    public GPacket getReplyGPacket(int status, String reason) {
        assert( pkt != null);
        GPacket gp = GPacket.getInstance();
        gp.setType(ProtocolGlobals.G_NEW_MASTER_BROKER_PREPARE_REPLY);
        gp.putProp("X", (Long)pkt.getProp("X"));
        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

        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());
                gp.putProp("I", subscription.getClientID());
                gp.putProp("M", Boolean.valueOf(true));
            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", new String(dname));
            }

            String clientID = subscription.getClientID();
            gp.putProp("I", new String(clientID));

            gp.putProp(String.valueOf(consumer.getConsumerUID().longValue())+":"+
                       Consumer.PREFETCH, new Integer(consumer.getPrefetch()));
            gp.putProp("allowsNonDurable", new 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", new Integer(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);
                dos.flush();
                bos.flush();
            }
            catch (IOException e) { /* Ignore */ }

            gp.setPayload(ByteBuffer.wrap(bos.toByteArray()));

            if (changeRecord) {
                gp.putProp("N", new String(dname));
                gp.putProp("I", new String(clientID));
                gp.putProp("M", new 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;
View Full Code Here

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

        assert ( pkt != null );
        return pkt.getBit(pkt.A_BIT);
    }

    public static GPacket getReplyGPacket(short protocol, int status) {
        GPacket gp = GPacket.getInstance();
        gp.setType(protocol);
        gp.putProp("S", new Integer(status));
        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.