Package com.sun.messaging.jmq.util

Examples of com.sun.messaging.jmq.util.UID


        return new BrokerAddressImpl(a.getHostName(),
                     a.getProperty("instName"),
                     a.getPort(),
           !(ha == null),
                     a.getProperty("brokerID"),
                     new UID(Long.valueOf(a.getProperty("brokerSessionUID")).longValue()),
                     ((ha == null) ? null:
                      new UID(Long.valueOf(a.getProperty("storeSessionUID")).longValue())));
    }
View Full Code Here


        String instName = (String)gp.getProp("instanceName");
        String host = (String)gp.getProp("host");
        int port = ((Integer)gp.getProp("port")).intValue();
        Long brokerSession = (Long)gp.getProp("brokerSession");
        Long storeSession = (Long)gp.getProp("storeSession");
        UID buid = null
        UID suid = null
        if (brokerSession != null) buid = new UID(brokerSession.longValue());
        if (storeSession != null) suid = new UID(storeSession.longValue());
        BrokerAddressImpl ba = new BrokerAddressImpl(host, instName, port, ha, brokerID, buid, suid);
        return ba;
    }
View Full Code Here

        Iterator itr = null;
        synchronized(takingoverTargets) {
            itr = takingoverTargets.iterator();
            while (itr.hasNext()) {
                target = (TakingoverTracker)itr.next();
                UID ss = target.getStoreSessionUID();
                if (target.getBrokerID().equals(brokerID) &&
                    ((ss == null &&
                      target.getDownStoreSessionUID().equals(storeSession)) ||
                     (ss != null &&
                      (ss.equals(storeSession) ||
                       target.getDownStoreSessionUID().equals(storeSession))))) {
                    return true;
                }
            }
        }
View Full Code Here

        BrokerAddress currAddr = ref.getAddress();
        if (oldAddr == null && currAddr == null) return false;
        if ((oldAddr == null && currAddr != null) ||
            (oldAddr != null && currAddr == null)) return true;
        if (!oldAddr.equals(currAddr)) return true;
        UID oldUID = oldAddr.getBrokerSessionUID();
        UID currUID = currAddr.getBrokerSessionUID();
        if (oldUID == null || currUID == null) return false;
        if (!oldUID.equals(currUID)) return true;
        return false;
    }
View Full Code Here

          int requestedProtocol = 0;
          int highestProtocol = con.getHighestSupportedProtocol();
          int lowestProtocol = PacketType.VERSION1;

          String expectedClusterID = null;
          UID expectedSessionID = null;
          ConnectionUID oldCID = null;
          Integer bufsize = null;
          boolean badClientType = false;
          if (hello_props != null) {
              Integer level = (Integer)hello_props.get("JMQProtocolLevel");
              if (level == null) {
                  requestedProtocol=PacketType.VERSION1;
              } else {
                  requestedProtocol=level.intValue();
              }
               bufsize = (Integer)hello_props.get("JMQSize");
              if (bufsize == null) { //XXX try old protocol
                  bufsize = (Integer)hello_props.get("JMQRBufferSize");
              }

              // Retrieve HA related properties
              Long longUID = (Long)hello_props.get("JMQStoreSession");
              if (longUID != null) {
                  expectedSessionID = new UID(longUID.longValue());
              }

              expectedClusterID = (String)hello_props.get("JMQClusterID");

              Boolean reconnectable = (Boolean)hello_props.get("JMQReconnectable");
              Boolean haclient = (Boolean)hello_props.get("JMQHAClient");
              if (Globals.getHAEnabled() && haclient != null && haclient.booleanValue()) {
                  reconnectable = haclient;
              }

              String s = (String)hello_props.get("JMQUserAgent");
              if (!ALLOW_C_CLIENTS && s != null &&  s.indexOf("C;") != -1) {
                  badClientType = true;
              }
              if (s != null) {
                con.addClientData(IMQConnection.USER_AGENT, s);
              }

              longUID = (Long)hello_props.get("JMQConnectionID");

              if (longUID != null) {
                  logger.log(Logger.DEBUG,"Have old connectionUID");
                  oldCID = new ConnectionUID(longUID.longValue());
                  logger.log(Logger.INFO,
                         BrokerResources.I_RECONNECTING, oldCID);
                  logger.log(Logger.DEBUG,"Checking for active connection");

                  Connection oldcon = Globals.getConnectionManager().getConnection(oldCID);
                  DUMP("Before connection Destroy");
                  if (oldcon != null) {
                      logger.log(Logger.DEBUG,"Destroying old connection " + oldCID);
                      oldcon.destroyConnection(true,GoodbyeReason.ADMIN_KILLED_CON, "Destroying old connection with same connectionUID " + oldCID + " - reconnect is happening before connection was reaped");
                  }
/* LKS
                  DUMP();

                  logger.log(Logger.DEBUG,"Updating connection in id list " +
                           "["+oldcid + "," + uid + "]");
                  // old code
                  con.setConnectionUID(oldcid);
                  Globals.getConnectionManager().updateConnectionUID(
                         oldcid, uid);
                  //Globals.getConnectionManager().updateConnectionUID(
                  //       uid, oldcid);
*/
                  DUMP("After Connection Destroy");
              }

              con.getConnectionUID().setCanReconnect(reconnectable == null ? false :
                      reconnectable.booleanValue());

              Long interval = (Long)hello_props.get("JMQInterval");

              // LKS - XXX just override for testing
              long itime = interval == null ? 10000 : interval.intValue();
              con.setReconnectInterval(itime);
              
          } else {
              requestedProtocol=PacketType.VERSION1;
          }

          int supportedProtocol = 0;
          if (requestedProtocol > highestProtocol) {
              supportedProtocol = highestProtocol;
          } else if (requestedProtocol < lowestProtocol) {
              supportedProtocol = lowestProtocol;
          else {
              supportedProtocol = requestedProtocol;
          }
          con.setClientProtocolVersion(supportedProtocol);

           if (bufsize != null) {
              logger.log(Logger.DEBUG, "Received JMQRBufferSize -" + bufsize);
              con.setFlowCount(bufsize.intValue());
           }


          Packet pkt = new Packet(con.useDirectBuffers());
          pkt.setPacketType(PacketType.HELLO_REPLY);
          pkt.setConsumerID(msg.getConsumerID());
          Hashtable hash = new Hashtable();
          reason = "unavailable";
          int status = Status.UNAVAILABLE;

          // If the connection's remote IP address was not set by the
          // protocol, then use the IP in the message packet.
          if (con.getRemoteIP() == null) {
            con.setRemoteIP(msg.getIP());
          }


          if ((alreadyAuthenticated || alreadyStarted)
                  && !msg.getIndempotent() ) { // handle ibit
              status = Status.ERROR;
              reason = "Connection reuse not allowed";
              if (alreadyAuthenticated) {
                  logger.log(Logger.WARNING,"Internal Error: " +
                    " received HELLO on already authenticated connection "
                    + con.getRemoteConnectionString() +
                    " " + con.getConnectionUID());
              } else {
                  logger.log(Logger.WARNING,"Internal Error: " +
                    " received HELLO on already started connection "
                    + con.getRemoteConnectionString() +
                    " " + con.getConnectionUID());
              }
         
          } else if (badClientType) {
              logger.log(Logger.ERROR, rb.E_FEATURE_UNAVAILABLE,
                   Globals.getBrokerResources().getString(
                        BrokerResources.M_C_API));
              reason = "C clients not allowed on this version";
        status = Status.UNAVAILABLE;
          } else if (!CAN_RECONNECT && con.getConnectionUID().getCanReconnect()) {
              logger.log(Logger.ERROR, rb.E_FEATURE_UNAVAILABLE,
                   Globals.getBrokerResources().getString(
                        BrokerResources.M_CLIENT_FAILOVER));
              reason = "Client Failover not allowed on this version";
          } else if (requestedProtocol != supportedProtocol) {
              // Bad protocol level.
              logger.log(Logger.WARNING, rb.W_BAD_PROTO_VERSION,
                Integer.toString(requestedProtocol),
                Integer.toString(supportedProtocol));

              reason = "bad version";
        status = Status.BAD_VERSION;
          } else if (con.getConnectionState() != Connection.STATE_UNAVAILABLE) {
              /**
               * connection may not be able to be created e.g:
               * licensing, being destroyed (e.g due to timeout)
               */
              if (con.setConnectionState(Connection.STATE_INITIALIZED)) {
                  reason = null;
                  status = Status.OK;
              } else {
                  status = Status.UNAVAILABLE;
        }
          } else {
        status = Status.UNAVAILABLE;
          }
         
          UID brokerSessionID = Globals.getBrokerSessionID();
          if (brokerSessionID!=null){
            hash.put("JMQBrokerSessionID",new Long(brokerSessionID.longValue()));
          }
         
          // OK, handle the HA properties HERE

          String clusterID = null;
          UID sessionUID = null;
          Set supportedSessions = null;

          ClusterManager cfg = Globals.getClusterManager();
          if (cfg != null) {
              clusterID = cfg.getClusterId();
              sessionUID = cfg.getStoreSessionUID();

              hash.put("JMQHA",Boolean.valueOf(cfg.isHA()));

              if (clusterID != null) {
                  hash.put("JMQClusterID", clusterID);
              }
              if (sessionUID != null)  {
                  hash.put("JMQStoreSession",new Long(sessionUID.longValue()));
              }

              String list = null;
              Iterator itr = null;
              if (((IMQService)con.getService()).getServiceType() != ServiceType.ADMIN) {
View Full Code Here

                }
            }
        }
        Iterator itr = brokerSessions.iterator();
        while (itr.hasNext()) {
            removeBroker(cb, new UID(((Long)itr.next()).longValue()));
        }

        hbe = new HeartbeatEntry();
        try {
            hbe.brokerID = cb.getBrokerName();
View Full Code Here

            } else {
            logger.log(logger.WARNING, br.getKString(br.W_CLUSTER_HB_TIMEOUT, entry)+": "+
                                       (reason == null ? "": reason.getMessage()), reason);
            }
            HAClusteredBroker cb = (HAClusteredBroker)clsmgr.getBroker(entry.brokerID);
            cb.setBrokerInDoubt(true, new UID(hbe.sessionUID));
            synchronized (entry) {
                entry.indoubtTimestamp = System.currentTimeMillis();
            }
        }
    }
View Full Code Here

                 pkt.getType() == ProtocolGlobals.G_TAKEOVER_PENDING ||
                 pkt.getType() == ProtocolGlobals.G_TAKEOVER_ABORT );

        this.pkt = pkt;
        brokerID = (String)pkt.getProp("brokerID");
        storeSession = new UID(((Long)pkt.getProp("storeSession")).longValue());
        Long v = (Long)pkt.getProp("brokerSession");
        if (v != null) brokerSession = new UID(v.longValue());
        brokerHost =(String)pkt.getProp("brokerHost");
        taker = (String)pkt.getProp("taker");
        fromTaker = (taker != null);
        timestamp = (Long)pkt.getProp("timestamp");
        if (timestamp != null) timedout = (timestamp.equals(new Long(0)));
View Full Code Here

                    long timeout = (hbe.heartbeatInterval * hb.getTimeoutThreshold()) * 1000L;
                    if (hbe.lastTimestamp < (System.currentTimeMillis() - timeout)) {
                        if (hbe.indoubtTimestamp < (System.currentTimeMillis() - timeout)) {
                            logger.log(logger.WARNING, br.getKString(br.W_CLUSTER_HB_TIMEOUT, hbe));
                            ClusteredBroker cb = clsmgr.getBroker(hbe.brokerID);
                            cb.setBrokerInDoubt(true,  new UID(hbe.sessionUID));
                            entry  = (HeartbeatEntry)brokers.get(hbe);
                            if (entry != null) {
                                entry.indoubtTimestamp = System.currentTimeMillis();
                            }
                        }
View Full Code Here

        if ( !Globals.getHAEnabled() ) {
            // Do this only if store session is missing from session table
            String brokerID = Globals.getBrokerID();
            StoreSessionDAO sessionDAO = daoFactory.getStoreSessionDAO();
            if ( sessionDAO.getStoreSession( conn, brokerID ) <= 0 ) {
                sessionDAO.insert( conn, brokerID, new UID().longValue(), true );
            }
        }

        PropertyDAO dao = daoFactory.getPropertyDAO();
        dao.update( conn, STORE_PROPERTY_SUPPORT_JMSBRIDGE, Boolean.valueOf(true));
View Full Code Here

TOP

Related Classes of com.sun.messaging.jmq.util.UID

Copyright © 2018 www.massapicom. 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.