Search in sources :

Example 1 with ServiceManager

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

the class BrokerInstanceImpl method getJMSService.

private 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) IMQService(com.sun.messaging.jmq.jmsserver.service.imq.IMQService) 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)

Example 2 with ServiceManager

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

the class ServiceConfig method updateService.

private void updateService(int port, int min, int max) throws IOException, PropertyUpdateException, BrokerException {
    ServiceManager sm = Globals.getServiceManager();
    Service svc = sm.getService(getName());
    IMQService stsvc;
    if (svc == null) {
        throw new BrokerException(rb.getString(rb.X_NO_SUCH_SERVICE, getName()));
    }
    if (!(svc instanceof IMQService)) {
        throw new BrokerException("Internal Error: can updated non-standard Service");
    }
    stsvc = (IMQService) svc;
    stsvc.updateService(port, min, max);
}
Also used : BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) 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 3 with ServiceManager

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

the class UpdateServiceHandler 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() + ": " + cmd_props);
    }
    ServiceInfo info = (ServiceInfo) getBodyObject(cmd_msg);
    int status = Status.OK;
    String errMsg = null;
    ServiceManager sm = Globals.getServiceManager();
    Service svc = null;
    HAMonitorService hamonitor = Globals.getHAMonitorService();
    if (hamonitor != null && hamonitor.inTakeover()) {
        status = Status.ERROR;
        errMsg = rb.getString(rb.E_CANNOT_PROCEED_TAKEOVER_IN_PROCESS);
        logger.log(Logger.ERROR, this.getClass().getName() + ": " + errMsg);
    } else {
        if (info.name == null || ((svc = sm.getService(info.name)) == null)) {
            status = Status.ERROR;
            errMsg = rb.getString(rb.X_NO_SUCH_SERVICE, (info.name == null ? "<null>" : info.name));
        }
    }
    // OK .. set the service information
    if (status == Status.OK) {
        if (!(svc instanceof IMQService)) {
            status = Status.ERROR;
            errMsg = "Internal Error: can updated non-standard Service";
        } else {
            // to repair this by fcs
            try {
                IMQService stsvc = (IMQService) svc;
                int port = -1;
                int min = -1;
                int max = -1;
                if (info.isModified(info.PORT)) {
                    port = info.port;
                }
                if (info.isModified(info.MIN_THREADS)) {
                    min = info.minThreads;
                }
                if (info.isModified(info.MAX_THREADS)) {
                    max = info.maxThreads;
                }
                if (port != -1 || min != -1 || max != -1) {
                    stsvc.updateService(port, min, max);
                } else {
                    status = Status.ERROR;
                    errMsg = rb.getString(rb.X_NO_SERVICE_PROPS_SET, info.name);
                }
            } catch (Exception ex) {
                logger.logStack(Logger.WARNING, rb.W_ERROR_UPDATING_SERVICE, svc.getName(), ex);
                status = Status.ERROR;
                errMsg = getMessageFromException(ex);
            }
        }
    }
    // Send reply
    Packet reply = new Packet(con.useDirectBuffers());
    reply.setPacketType(PacketType.OBJECT_MESSAGE);
    setProperties(reply, MessageType.UPDATE_SERVICE_REPLY, status, errMsg);
    parent.sendReply(con, cmd_msg, reply);
    return true;
}
Also used : ServiceInfo(com.sun.messaging.jmq.util.admin.ServiceInfo) ServiceManager(com.sun.messaging.jmq.jmsserver.service.ServiceManager) HAMonitorService(com.sun.messaging.jmq.jmsserver.cluster.api.ha.HAMonitorService) 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) HAMonitorService(com.sun.messaging.jmq.jmsserver.cluster.api.ha.HAMonitorService)

Example 4 with ServiceManager

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

the class GetMetricsHandler 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() + ": " + cmd_props);
    }
    int status = Status.OK;
    String errMsg = null;
    String service = (String) cmd_props.get(MessageType.JMQ_SERVICE_NAME);
    String destination = (String) cmd_props.get(MessageType.JMQ_DESTINATION);
    Integer type = (Integer) cmd_props.get(MessageType.JMQ_DEST_TYPE);
    Object replyobj = null;
    String msgtype = null;
    if (destination != null) {
        try {
            Destination[] ds = DL.getDestination(null, destination, DestType.isQueue((type == null ? 0 : type.intValue())));
            // PART
            Destination d = ds[0];
            if (d == null) {
                status = Status.NOT_FOUND;
                int mytype = (type == null ? 0 : type.intValue());
                errMsg = rb.getString(rb.E_NO_SUCH_DESTINATION, getDestinationType(mytype), destination);
            } else {
                replyobj = d.getMetrics();
            }
        } catch (Exception ex) {
            int mytype = (type == null ? 0 : type.intValue());
            errMsg = rb.getString(rb.E_NO_SUCH_DESTINATION, getDestinationType(mytype), destination);
            status = Status.ERROR;
            // log the error
            logger.logStack(Logger.ERROR, rb.E_INTERNAL_BROKER_ERROR, this.getClass().getName() + ": failed to get destination (" + DestType.toString(mytype) + ":" + destination + ")", ex);
        }
        msgtype = "DESTINATION";
    } else {
        ServiceManager sm = Globals.getServiceManager();
        MetricManager mm = Globals.getMetricManager();
        MetricCounters mc = null;
        if (service != null && sm.getServiceType(service) == ServiceType.UNKNOWN) {
            status = Status.NOT_FOUND;
            errMsg = rb.getString(rb.X_NO_SUCH_SERVICE, service);
        } else {
            // If service is null getMetricCounters() will get counters
            // for all services
            mc = mm.getMetricCounters(service);
            if (service != null) {
                msgtype = "SERVICE";
            }
            replyobj = mc;
        }
    }
    // Send reply
    Packet reply = new Packet(con.useDirectBuffers());
    reply.setPacketType(PacketType.OBJECT_MESSAGE);
    Hashtable pr = new Hashtable();
    if (msgtype != null) {
        pr.put(MessageType.JMQ_BODY_TYPE, msgtype);
    }
    setProperties(reply, MessageType.GET_METRICS_REPLY, status, errMsg, pr);
    if (replyobj != null) {
        setBodyObject(reply, replyobj);
    }
    parent.sendReply(con, cmd_msg, reply);
    return true;
}
Also used : Destination(com.sun.messaging.jmq.jmsserver.core.Destination) MetricManager(com.sun.messaging.jmq.jmsserver.service.MetricManager) ServiceManager(com.sun.messaging.jmq.jmsserver.service.ServiceManager) MetricCounters(com.sun.messaging.jmq.util.MetricCounters) Hashtable(java.util.Hashtable)

Example 5 with ServiceManager

use of com.sun.messaging.jmq.jmsserver.service.ServiceManager 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)

Aggregations

ServiceManager (com.sun.messaging.jmq.jmsserver.service.ServiceManager)7 Service (com.sun.messaging.jmq.jmsserver.service.Service)5 IMQService (com.sun.messaging.jmq.jmsserver.service.imq.IMQService)5 MetricManager (com.sun.messaging.jmq.jmsserver.service.MetricManager)2 IMQDirectService (com.sun.messaging.jmq.jmsserver.service.imq.IMQDirectService)2 JMSService (com.sun.messaging.jmq.jmsservice.JMSService)2 ServiceInfo (com.sun.messaging.jmq.util.admin.ServiceInfo)2 HAMonitorService (com.sun.messaging.jmq.jmsserver.cluster.api.ha.HAMonitorService)1 Destination (com.sun.messaging.jmq.jmsserver.core.Destination)1 ConnectionManager (com.sun.messaging.jmq.jmsserver.service.ConnectionManager)1 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)1 MetricCounters (com.sun.messaging.jmq.util.MetricCounters)1 Hashtable (java.util.Hashtable)1