Search in sources :

Example 1 with MQAddress

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

the class MQAddressUtil method getServiceMQAddress.

/**
 * Return connection service MQAddress. Connection service addresses can have 2 forms and the bypassPortmapper parameter
 * allows the caller to select which one is desired. The 2 forms depend on whether the client will contact the
 * portmapper (mq://host:port) or the connection service directly ({mqtcp,mqssl}://host:port/svcname).
 *
 * @param svcName Connection service name.
 * @param port Portmapper port or connection service port.
 * @param bypassPortmapper Boolean to indicate which type of address is desired. If the value for bypassPortmapper is
 * false, the address will be of the form mq://host:port/svcName. If the value is true, the scheme will be one of mqtcp
 * or mqssl. The address will be of the form scheme://host:svc_port/svc_name. e.g. mqtcp://myhost:87635/jms
 * @return Connection service address.
 */
public static MQAddress getServiceMQAddress(String svcName, Integer port, boolean bypassPortmapper) {
    MQAddress addr = null;
    String scheme = "mq";
    Logger logger = Globals.getLogger();
    if ((svcName == null) || (svcName.equals("")) || (port == null)) {
        if (DEBUG) {
            logger.log(Logger.DEBUG, "Null service name and/or port passed in to getServiceMQAddress()");
        }
        return (null);
    }
    if (bypassPortmapper) {
        scheme = getScheme(svcName);
    }
    if (scheme == null) {
        return (null);
    }
    if (bypassPortmapper) {
        try {
            String url = scheme + "://" + Globals.getMQAddress().getHostName() + ":" + port.toString() + "/" + svcName;
            addr = MQAddress.getMQAddress(url);
        } catch (Exception e) {
            if (DEBUG) {
                logger.log(Logger.DEBUG, "Failed to create service address", e);
            }
        }
    } else {
        try {
            String url = Globals.getMQAddress().getHostName() + ":" + port.toString() + "/" + svcName;
            addr = PortMapperMQAddress.createAddress(url);
        } catch (Exception e) {
            if (DEBUG) {
                logger.log(Logger.DEBUG, "Failed to create service address", e);
            }
        }
    }
    return (addr);
}
Also used : MQAddress(com.sun.messaging.jmq.io.MQAddress) Logger(com.sun.messaging.jmq.util.log.Logger)

Example 2 with MQAddress

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

the class MQAddressUtil method getPortMapperMQAddress.

/**
 * Return portmapper MQAddress. This MQAddress does not include the service name and is of the form mq://host:port
 *
 * @param port Portmapper port
 * @return Portmapper address. This MQAddress does not include the service name. It is of the form mq://host:port.
 */
public static MQAddress getPortMapperMQAddress(Integer port) {
    MQAddress addr = null;
    if (port == null) {
        if (DEBUG) {
            Logger logger = Globals.getLogger();
            logger.log(Logger.DEBUG, "Null port passed in to getPortMapperMQAddress()");
        }
        return (null);
    }
    try {
        String url = Globals.getMQAddress().getHostName() + ":" + port.toString();
        addr = PortMapperMQAddress.createAddress(url);
    } catch (Exception e) {
        if (DEBUG) {
            Logger logger = Globals.getLogger();
            logger.log(Logger.DEBUG, "Failed to create portmapper address", e);
        }
    }
    return (addr);
}
Also used : MQAddress(com.sun.messaging.jmq.io.MQAddress) Logger(com.sun.messaging.jmq.util.log.Logger)

Example 3 with MQAddress

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

the class Agent method getDefaultJMXUrlPathBase.

public String getDefaultJMXUrlPathBase() throws BrokerException {
    MQAddress addr = Globals.getMQAddress();
    String rmiRegHostName, brokerHostName, ret = null;
    int brokerPort, rmiRegistryPort;
    if (addr == null) {
        return (null);
    }
    /*
         * These other methods work too. Would be good if we could obtain a fully qualified hostname i.e. with domain.
         * brokerHostName = Globals.getBrokerHostName(); brokerHostName = Globals.getBrokerInetAddress().getCanonicalHostName();
         */
    brokerHostName = addr.getHostName();
    rmiRegHostName = Globals.getJMXHostname();
    brokerPort = addr.getPort();
    rmiRegistryPort = getRmiRegistryPort();
    /*
         * rmiRegHostName can be null if imq.jmx.hostname or imq.hostname is not set.
         */
    if (rmiRegHostName == null) {
        rmiRegHostName = brokerHostName;
    } else {
        try {
            rmiRegHostName = MQAddress.getMQAddress(rmiRegHostName, rmiRegistryPort).getHostName();
        } catch (MalformedURLException e) {
            throw new BrokerException(e.toString(), e);
        }
    }
    /*
         * The default urlpath base is: /jndi/rmi://<brokerhost>:<rmiport>/<brokerhost>/<brokerport>/ e.g
         * /jndi/rmi://myhost:1099/myhost/7676/
         */
    ret = "/jndi/rmi://" + rmiRegHostName + ":" + Integer.toString(rmiRegistryPort) + "/" + brokerHostName + "/" + Integer.toString(brokerPort) + "/";
    return (ret);
}
Also used : MalformedURLException(java.net.MalformedURLException) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) MQAddress(com.sun.messaging.jmq.io.MQAddress)

Example 4 with MQAddress

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

the class ClusterMonitor method getLocalBrokerInfo.

public CompositeData getLocalBrokerInfo() throws MBeanException {
    ClusterManager cm = Globals.getClusterManager();
    CompositeData cd = null;
    if (cm == null) {
        return (null);
    }
    MQAddress address = cm.getMQAddress();
    String id = null;
    try {
        id = cm.lookupBrokerID(BrokerMQAddress.createAddress(address.toString()));
    } catch (Exception e) {
        handleGetterException(ClusterAttributes.LOCAL_BROKER_INFO, e);
    }
    if ((id == null) || (id.equals(""))) {
        return (null);
    }
    try {
        ClusteredBroker cb = cm.getBroker(id);
        if (cb == null) {
            return (null);
        }
        cd = getCompositeData(cb);
    } catch (Exception e) {
        handleGetterException(ClusterAttributes.LOCAL_BROKER_INFO, e);
    }
    return (cd);
}
Also used : MQAddress(com.sun.messaging.jmq.io.MQAddress) BrokerMQAddress(com.sun.messaging.jmq.jmsserver.core.BrokerMQAddress) CompositeData(javax.management.openmbean.CompositeData) OpenDataException(javax.management.openmbean.OpenDataException) MBeanException(javax.management.MBeanException)

Example 5 with MQAddress

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

the class ClusterManagerImpl method mqAddressChanged.

/**
 * Method called when the MQAddress is changed on the system.
 *
 * @param address the new address of the local brokers portmapper
 */
protected void mqAddressChanged(MQAddress address) throws Exception {
    ClusteredBroker cb = getLocalBroker();
    MQAddress oldAddress = cb.getBrokerURL();
    cb.setBrokerURL(address);
    brokerChanged(ClusterReason.ADDRESS_CHANGED, cb.getBrokerName(), oldAddress, address, null, null);
}
Also used : MQAddress(com.sun.messaging.jmq.io.MQAddress) BrokerMQAddress(com.sun.messaging.jmq.jmsserver.core.BrokerMQAddress)

Aggregations

MQAddress (com.sun.messaging.jmq.io.MQAddress)22 BrokerMQAddress (com.sun.messaging.jmq.jmsserver.core.BrokerMQAddress)16 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)11 MalformedURLException (java.net.MalformedURLException)4 UnknownHostException (java.net.UnknownHostException)3 MBeanException (javax.management.MBeanException)3 CompositeData (javax.management.openmbean.CompositeData)3 PropertyUpdateException (com.sun.messaging.jmq.jmsserver.config.PropertyUpdateException)2 UID (com.sun.messaging.jmq.util.UID)2 Logger (com.sun.messaging.jmq.util.log.Logger)2 Packet (com.sun.messaging.jmq.io.Packet)1 ClusterManager (com.sun.messaging.jmq.jmsserver.cluster.api.ClusterManager)1 DestinationList (com.sun.messaging.jmq.jmsserver.core.DestinationList)1 TakeoverLockException (com.sun.messaging.jmq.jmsserver.persist.api.TakeoverLockException)1 LockFile (com.sun.messaging.jmq.jmsserver.util.LockFile)1 StoreBeingTakenOverException (com.sun.messaging.jmq.jmsserver.util.StoreBeingTakenOverException)1 PUService (com.sun.messaging.portunif.PUService)1 Properties (java.util.Properties)1 Set (java.util.Set)1 OpenDataException (javax.management.openmbean.OpenDataException)1