Search in sources :

Example 6 with Service

use of com.sun.messaging.jmq.jmsserver.service.Service in project openmq by eclipse-ee4j.

the class JMSRA_BrokerProcess method getJMSService.

/**
 * Return the named JMS Service that supports 'DIRECT' in-JVM Java EEJMS clients.
 *
 * @param serviceName The name of the service to return
 *
 * @throws IllegalStateException if the broker is already stopped
 */
@Override
public JMSService getJMSService(String serviceName) throws IllegalStateException {
    ServiceManager sm = Globals.getServiceManager();
    Service svc;
    IMQService imqSvc;
    IMQDirectService imqDirectSvc;
    if (sm == null) {
        return (null);
    }
    svc = sm.getService(serviceName);
    if (svc == null) {
        return (null);
    }
    if (!(svc instanceof IMQService)) {
        return (null);
    }
    imqSvc = (IMQService) svc;
    if (!imqSvc.isDirect()) {
        return (null);
    }
    if (!(imqSvc instanceof IMQDirectService)) {
        return (null);
    }
    imqDirectSvc = (IMQDirectService) imqSvc;
    return imqDirectSvc.getJMSService();
}
Also used : IMQDirectService(com.sun.messaging.jmq.jmsserver.service.imq.IMQDirectService) ServiceManager(com.sun.messaging.jmq.jmsserver.service.ServiceManager) JMSService(com.sun.messaging.jmq.jmsservice.JMSService) IMQDirectService(com.sun.messaging.jmq.jmsserver.service.imq.IMQDirectService) Service(com.sun.messaging.jmq.jmsserver.service.Service) IMQService(com.sun.messaging.jmq.jmsserver.service.imq.IMQService) IMQService(com.sun.messaging.jmq.jmsserver.service.imq.IMQService)

Example 7 with Service

use of com.sun.messaging.jmq.jmsserver.service.Service in project openmq by eclipse-ee4j.

the class ConnectionUtil method getConnectionInfoList.

/**
 * Returns a List of ConnectionInfo for the given service or all services if the passed service is null.
 */
public static List getConnectionInfoList(String service) {
    ConnectionManager cm = Globals.getConnectionManager();
    List connections, connectionInfoList = new ArrayList();
    IMQConnection cxn;
    ConnectionInfo cxnInfo;
    try {
        Service s = null;
        if (service != null) {
            s = Globals.getServiceManager().getService(service);
            /*
                 * If service object is null, service may not exist or is inactive
                 */
            if (s == null) {
                return (connectionInfoList);
            }
        }
        connections = cm.getConnectionList(s);
    } catch (Exception e) {
        BrokerResources rb = Globals.getBrokerResources();
        Logger logger = Globals.getLogger();
        logger.log(Logger.WARNING, rb.getString(rb.W_JMX_FAILED_TO_OBTAIN_CONNECTION_LIST), e);
        return (connectionInfoList);
    }
    if (connections.size() == 0) {
        return (connectionInfoList);
    }
    Iterator iter = connections.iterator();
    while (iter.hasNext()) {
        cxn = (IMQConnection) iter.next();
        cxnInfo = cxn.getConnectionInfo();
        connectionInfoList.add(cxnInfo);
    }
    return (connectionInfoList);
}
Also used : ConnectionManager(com.sun.messaging.jmq.jmsserver.service.ConnectionManager) IMQConnection(com.sun.messaging.jmq.jmsserver.service.imq.IMQConnection) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Service(com.sun.messaging.jmq.jmsserver.service.Service) List(java.util.List) ArrayList(java.util.ArrayList) ConnectionInfo(com.sun.messaging.jmq.util.admin.ConnectionInfo) Logger(com.sun.messaging.jmq.util.log.Logger) BrokerResources(com.sun.messaging.jmq.jmsserver.resources.BrokerResources)

Example 8 with Service

use of com.sun.messaging.jmq.jmsserver.service.Service in project openmq by eclipse-ee4j.

the class GetServicesHandler method getServiceInfo.

public static ServiceInfo getServiceInfo(String name) {
    ServiceManager sm = Globals.getServiceManager();
    ConnectionManager cm = Globals.getConnectionManager();
    MetricManager mm = Globals.getMetricManager();
    /*
         * XXX REVISIT dipol 10/17/00 we should probably put this logic into the ServiceManager so knowledge of property names
         * is encapsulated there.
         */
    String proto = props.getProperty(SERVICE_PREFIX + name + ".protocoltype");
    // Fill in admin service info object
    ServiceInfo si = new com.sun.messaging.jmq.util.admin.ServiceInfo();
    si.name = name;
    si.protocol = proto;
    // strange kludge here ...
    // if protocol is tcp or tls, it defaults to 0
    int default_value = -1;
    if (si.protocol != null) {
        if (si.protocol.equals("tcp") || si.protocol.equals("tls")) {
            default_value = 0;
        }
    }
    si.port = props.getIntProperty(SERVICE_PREFIX + name + "." + proto + ".port", default_value);
    if (si.port == 0) {
        si.dynamicPort = true;
    } else {
        si.dynamicPort = false;
    }
    si.minThreads = props.getIntProperty(SERVICE_PREFIX + name + ".min_threads");
    si.maxThreads = props.getIntProperty(SERVICE_PREFIX + name + ".max_threads");
    si.type = sm.getServiceType(name);
    Service service = sm.getService(name);
    if (service != null) {
        si.nConnections = cm.getNumConnections(service);
        si.state = service.getState();
        if (service instanceof IMQService) {
            IMQService ss = (IMQService) service;
            si.currentThreads = ss.getActiveThreadpool();
            si.minThreads = ss.getMinThreadpool();
            si.maxThreads = ss.getMaxThreadpool();
            // port number that is acutally being used
            if (si.port == 0 && ss.getProtocol() != null) {
                si.port = ss.getProtocol().getLocalPort();
            }
        }
        if (mm != null) {
            si.metrics = mm.getMetricCounters(name);
        } else {
            si.metrics = null;
        }
    } else {
        // Service is not intitialized
        si.state = ServiceState.UNKNOWN;
    }
    return si;
}
Also used : ServiceInfo(com.sun.messaging.jmq.util.admin.ServiceInfo) MetricManager(com.sun.messaging.jmq.jmsserver.service.MetricManager) ConnectionManager(com.sun.messaging.jmq.jmsserver.service.ConnectionManager) ServiceManager(com.sun.messaging.jmq.jmsserver.service.ServiceManager) IMQService(com.sun.messaging.jmq.jmsserver.service.imq.IMQService) Service(com.sun.messaging.jmq.jmsserver.service.Service) IMQService(com.sun.messaging.jmq.jmsserver.service.imq.IMQService)

Example 9 with Service

use of com.sun.messaging.jmq.jmsserver.service.Service in project openmq by eclipse-ee4j.

the class DebugHandler method getAllCxnInfo.

private Hashtable getAllCxnInfo(String svc) throws Exception {
    Service s = null;
    Hashtable debugHash = new Hashtable();
    if (svc != null) {
        s = Globals.getServiceManager().getService(svc);
        debugHash.put("threadPool", getThreadPoolInfo(svc));
        debugHash.put("threads", SupportUtil.getAllStackTraces(""));
    }
    Iterator itr = Globals.getConnectionManager().getConnectionList(s).iterator();
    while (itr.hasNext()) {
        IMQConnection c = (IMQConnection) itr.next();
        debugHash.put(c.getRemoteConnectionString(), c.getDebugState());
    }
    return debugHash;
}
Also used : IMQConnection(com.sun.messaging.jmq.jmsserver.service.imq.IMQConnection) Hashtable(java.util.Hashtable) Iterator(java.util.Iterator) Service(com.sun.messaging.jmq.jmsserver.service.Service)

Example 10 with Service

use of com.sun.messaging.jmq.jmsserver.service.Service in project openmq by eclipse-ee4j.

the class GetConnectionsHandler method handle.

/**
 * Handle the incomming administration message.
 *
 * @param con The Connection the message came in on.
 * @param cmd_msg The administration message
 * @param cmd_props The properties from the administration message
 */
@Override
public boolean handle(IMQConnection con, Packet cmd_msg, Hashtable cmd_props) {
    if (DEBUG) {
        logger.log(Logger.DEBUG, this.getClass().getName() + ": " + "GetConnections: " + cmd_props);
    }
    ConnectionManager cm = Globals.getConnectionManager();
    String serviceName = (String) cmd_props.get(MessageType.JMQ_SERVICE_NAME);
    Long cxnId = (Long) cmd_props.get(MessageType.JMQ_CONNECTION_ID);
    int status = Status.OK;
    String errMsg = null;
    Vector v = new Vector();
    Service s = null;
    if (serviceName != null) {
        s = Globals.getServiceManager().getService(serviceName);
        if (s == null) {
            status = Status.NOT_FOUND;
            errMsg = rb.getString(rb.X_NO_SUCH_SERVICE, serviceName);
        }
    }
    if (status == Status.OK) {
        ConnectionInfo cxnInfo = null;
        IMQConnection cxn = null;
        if (cxnId != null) {
            // Get info for one connection
            cxn = (IMQConnection) cm.getConnection(new ConnectionUID(cxnId.longValue()));
            if (cxn != null) {
                if (DEBUG) {
                    cxn.dump();
                }
                cxnInfo = cxn.getConnectionInfo();
                v.add(getConnectionInfoHashtable(cxnInfo));
            } else {
                status = Status.NOT_FOUND;
                errMsg = rb.getString(rb.E_NO_SUCH_CONNECTION, String.valueOf(cxnId.longValue()));
            }
        } else {
            // Get info for all connections on a service
            List connections = cm.getConnectionList(s);
            Iterator itr = connections.iterator();
            while (itr.hasNext()) {
                cxn = (IMQConnection) itr.next();
                cxnInfo = cxn.getConnectionInfo();
                v.add(getConnectionInfoHashtable(cxnInfo));
            }
        }
    }
    // Send reply
    Packet reply = new Packet(con.useDirectBuffers());
    reply.setPacketType(PacketType.OBJECT_MESSAGE);
    setProperties(reply, MessageType.GET_CONNECTIONS_REPLY, status, errMsg);
    setBodyObject(reply, v);
    parent.sendReply(con, cmd_msg, reply);
    return true;
}
Also used : ConnectionManager(com.sun.messaging.jmq.jmsserver.service.ConnectionManager) IMQConnection(com.sun.messaging.jmq.jmsserver.service.imq.IMQConnection) Iterator(java.util.Iterator) Service(com.sun.messaging.jmq.jmsserver.service.Service) ConnectionUID(com.sun.messaging.jmq.jmsserver.service.ConnectionUID) List(java.util.List) ConnectionInfo(com.sun.messaging.jmq.util.admin.ConnectionInfo) Vector(java.util.Vector)

Aggregations

Service (com.sun.messaging.jmq.jmsserver.service.Service)12 Iterator (java.util.Iterator)6 ServiceManager (com.sun.messaging.jmq.jmsserver.service.ServiceManager)5 IMQService (com.sun.messaging.jmq.jmsserver.service.imq.IMQService)5 List (java.util.List)5 ConnectionManager (com.sun.messaging.jmq.jmsserver.service.ConnectionManager)4 IMQConnection (com.sun.messaging.jmq.jmsserver.service.imq.IMQConnection)4 Hashtable (java.util.Hashtable)4 TransactionList (com.sun.messaging.jmq.jmsserver.data.TransactionList)2 BrokerResources (com.sun.messaging.jmq.jmsserver.resources.BrokerResources)2 ConnectionUID (com.sun.messaging.jmq.jmsserver.service.ConnectionUID)2 IMQDirectService (com.sun.messaging.jmq.jmsserver.service.imq.IMQDirectService)2 JMSService (com.sun.messaging.jmq.jmsservice.JMSService)2 ConnectionInfo (com.sun.messaging.jmq.util.admin.ConnectionInfo)2 ServiceInfo (com.sun.messaging.jmq.util.admin.ServiceInfo)2 Logger (com.sun.messaging.jmq.util.log.Logger)2 ArrayList (java.util.ArrayList)2 FaultInjection (com.sun.messaging.jmq.jmsserver.FaultInjection)1 HAMonitorService (com.sun.messaging.jmq.jmsserver.cluster.api.ha.HAMonitorService)1 Consumer (com.sun.messaging.jmq.jmsserver.core.Consumer)1