Package com.sun.messaging.jmq.jmsserver.core

Examples of com.sun.messaging.jmq.jmsserver.core.BrokerMQAddress


        }
        return buf.toString();
    }

    public BrokerAddress fromProtocolString(String s) throws Exception {
        BrokerMQAddress a = BrokerMQAddress.createAddress(s);
        String ha = (String)a.getProperty("ha");
        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


        SimpleType.BOOLEAN, // success flag
        SimpleType.INTEGER, // status code
        SimpleType.STRING, // detail message
    };

    BrokerMQAddress oldmba = null;
    BrokerMQAddress newmba = null;

    try {
      oldmba = BrokerMQAddress.createAddress(oldMasterBroker);
      newmba = BrokerMQAddress.createAddress(newMasterBroker);
    } catch (Exception e) {
View Full Code Here

                    Globals.getBrokerResources().getKString(
                        BrokerResources.X_ADMIN_CHANGE_MASTER_NOT_FROM_JMSRA));
            }

            ClusterManager cm = Globals.getClusterManager();
            BrokerMQAddress self = (BrokerMQAddress)cm.getMQAddress();
            BrokerMQAddress master = (cm.getMasterBroker() == null ?
                                      null:(BrokerMQAddress)cm.getMasterBroker().getBrokerURL());
            BrokerMQAddress newmba = BrokerMQAddress.createAddress(newmb);
            BrokerMQAddress oldmba = null;
            if (oldmb != null) {
                oldmba = BrokerMQAddress.createAddress(oldmb);
            }
            if (notificationOnly) {
                if (master == null) {
                    emsg = "IllegalStateException for notification "+
                            MessageType.getString(MessageType.CHANGE_CLUSTER_MASTER_BROKER)+
                            ": No master broker";
                    logger.log(logger.ERROR, emsg);
                    sendReply(Status.ERROR, emsg, con, cmd_msg);
                    Broker.getBroker().exit(1, emsg, BrokerEvent.Type.ERROR);
                    throw new IllegalStateException(emsg);
                }
                if (newmba.equals(self)) {
                    if (!master.equals(self)) {
                        emsg = "IllegalStateException for notification "+
                            MessageType.getString(MessageType.CHANGE_CLUSTER_MASTER_BROKER)+
                            ": This broker, which has master broker "+master+
                            ", is not the master broker as expected";
                        logger.log(logger.ERROR, emsg);
                        sendReply(Status.ERROR, emsg, con, cmd_msg);
                        Broker.getBroker().exit(1, emsg, BrokerEvent.Type.ERROR);
                        return true;
                    }
                }
                if (oldmba != null && oldmba.equals(self)) {
                    if (!master.equals(newmba)) {
                        emsg = "IllegalStateException for notification "+
                            MessageType.getString(MessageType.CHANGE_CLUSTER_MASTER_BROKER)+
                            ": This broker, which is the old master broker "+oldmba+
                            ", does not have "+newmba+" as the master broker as expected";
                        logger.log(logger.ERROR, emsg);
                        sendReply(Status.ERROR, emsg, con, cmd_msg);
                        Broker.getBroker().exit(1, emsg, BrokerEvent.Type.ERROR);
                        return true;
                    }
                }
                sendReply(Status.OK, null, con, cmd_msg);
                return true;
            }
            if (master == null) {
                throw new BrokerException(Globals.getBrokerResources().getKString(
                    BrokerResources.X_CLUSTER_NO_MASTER_BROKER_REJECT_CHANGE_MASTER),
                    Status.PRECONDITION_FAILED);
            }
            if (newmba.equals(master)) {
                logger.log(logger.INFO, Globals.getBrokerResources().getKString(
                    BrokerResources.I_CLUSTER_CHANGE_MASTER_BROKER_SAME, newmba));
                sendReply(Status.OK, null, con, cmd_msg);
                return true;
            }
            if (oldmba == null) {
                oldmba = master;
            }
            if (!oldmba.equals(master)) {
                throw new BrokerException(Globals.getBrokerResources().getKString(
                    BrokerResources.X_CLUSTER_CHANGE_MASTER_BROKER_MISMATCH,
                    oldmba.toString(), master), Status.PRECONDITION_FAILED);
            }
            if (!self.equals(master)) {
                if (!Globals.isJMSRAManagedBroker()) {
                    throw new BrokerException(Globals.getBrokerResources().getKString(
                        BrokerResources.X_CLUSTER_THIS_BROKER_NOT_MASTER_BROKER_REJECT_CHANGE_MASTER,
View Full Code Here

        return (addr.toString());
    }

    public static String getShortBrokerAddress(String brokerID)  {
  BrokerMQAddress ba = null;
  String longAddr = getBrokerAddress(brokerID);
  Logger logger = Globals.getLogger();

  if (longAddr == null)  {
      return (null);
  }

  try  {
      ba = BrokerMQAddress.createAddress(longAddr);
  } catch (Exception e)  {
            BrokerResources  rb = Globals.getBrokerResources();

            logger.log(Logger.WARNING,
    rb.getString(rb.W_JMX_FAILED_TO_OBTAIN_BKR_ADDRESS_FROM_ID, brokerID),
    e);

      return (null);
  }

  if (ba == null)  {
      return (null);
  }

        return (ba.getHost().getHostName() + ":" + ba.getPort());
    }
View Full Code Here

    String instName = cb.getInstanceName();
    //uncomment when ready to change
    //h.put(BrokerClusterInfo.INSTNAME, (instName == null ? "", instName));


        BrokerMQAddress bm = (BrokerMQAddress)cb.getBrokerURL();
        String address = bm.getHostAddressNPort();
        h.put(BrokerClusterInfo.ADDRESS, address);

  /*
   * Substitute "Version" with BrokerClusterInfo.VERSION if/when
   * that constant is added. It's not there now because we don't
View Full Code Here

            configServer = null;
            configServerResolved = false;
            throw new BrokerException(e.getMessage(), e);
        }

        BrokerMQAddress key = configServer.getMQAddress();
        if (key.equals(self.getMQAddress())) {
            configServer = self;
            configServerResolved = true;
            return;
        }
View Full Code Here

     * this broker.
     */
    private void initBrokerList() throws BrokerException {
        connectList = Collections.synchronizedMap(new HashMap());

        BrokerMQAddress selfKey = self.getMQAddress();
        if (DEBUG) {
            logger.log(Logger.INFO,
                "ClusterImpl:initBrokerList. selfKey =" + selfKey);
        }

        ClusteredBroker cb = null;
        BrokerAddressImpl b = null;
        BrokerLink link = null;
        Iterator itr = clsmgr.getConfigBrokers();
        int i = 0;
        while (itr.hasNext()) {
            cb = (ClusteredBroker)itr.next();
            try {
                b = new BrokerAddressImpl((BrokerMQAddress)cb.getBrokerURL(), null,
                                          Globals.getHAEnabled(), cb.getBrokerName());
            }
            catch (Exception e) {
                throw new BrokerException(e.getMessage(), e);
            }
            BrokerMQAddress key = b.getMQAddress();
            if (!key.equals(selfKey)) {
                link = new BrokerLink(self, b, this);
                link.setAutoConnect(true);
                connectList.put(key, link);
                i++;
                if (DEBUG) {
View Full Code Here

            if (configServer == null) {
                return false; // Illegal config, reject cluster connections.
            }

            BrokerMQAddress key = b.getMQAddress();
            if (key.equals(configServer.getMQAddress())) {
                configServer = b;
                configServerResolved = true;

                if (warningTask != null) {
                    warningTask.cancel();
View Full Code Here

        // This can happen if the brokers are started like this -
        //     broker -name A -cluster B ...
        //     broker -name B -cluster A ...
        //

        BrokerMQAddress key = remote.getMQAddress();
        BrokerLink oldlink = null;
        synchronized (connectList) {
            oldlink = (BrokerLink) connectList.get(key);
            if (oldlink != null) {
                if (connectionInitiator(remote)) {
View Full Code Here

            if (DEBUG) {
            logger.log(logger.INFO, "ClusterImpl:brokerAdded: Ignore dynamic broker "+broker);
            }
            return;
        }
        BrokerMQAddress key = (BrokerMQAddress)broker.getBrokerURL();
        if (!key.equals(self.getMQAddress()) && !connectList.containsKey(key)) {
            if (connectList.size() > connLimit) { //XXX limit check in clmgr 
                logger.log(Logger.ERROR, br.E_MBUS_CONN_LIMIT, Integer.toString(connLimit + 1));
                return;
            }
View Full Code Here

TOP

Related Classes of com.sun.messaging.jmq.jmsserver.core.BrokerMQAddress

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.