Search in sources :

Example 1 with PropertyUpdateException

use of com.sun.messaging.jmq.jmsserver.config.PropertyUpdateException in project openmq by eclipse-ee4j.

the class Globals method getPortMapper.

public static PortMapper getPortMapper() {
    if (portMapper == null) {
        synchronized (lock) {
            if (portMapper == null) {
                portMapper = new PortMapper(getConfigName());
                try {
                    portMapper.configure(getConfig());
                    // Force portmapper to attempt to bind to port
                    portMapper.bind();
                } catch (Exception e) {
                    portMapper = null;
                    Logger logger = getLogger();
                    if (e instanceof PropertyUpdateException) {
                        logger.log(Logger.ERROR, e.getMessage());
                    } else {
                        logger.logStack(Logger.ERROR, e.getMessage(), e);
                    }
                }
            }
        }
    }
    return portMapper;
}
Also used : PropertyUpdateException(com.sun.messaging.jmq.jmsserver.config.PropertyUpdateException) PortMapper(com.sun.messaging.jmq.jmsserver.service.PortMapper) Logger(com.sun.messaging.jmq.util.log.Logger) BrokerShutdownRuntimeException(com.sun.messaging.jmq.jmsserver.util.BrokerShutdownRuntimeException) PropertyUpdateException(com.sun.messaging.jmq.jmsserver.config.PropertyUpdateException) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException)

Example 2 with PropertyUpdateException

use of com.sun.messaging.jmq.jmsserver.config.PropertyUpdateException in project openmq by eclipse-ee4j.

the class GrizzlyIPService method updateService.

protected synchronized void updateService(int port, int min, int max, boolean store) throws IOException, PropertyUpdateException, BrokerException {
    if (DEBUG) {
        logger.log(logger.INFO, "GrizzlyIPService.updateService(" + port + ", " + min + ", " + max + ", " + store + ") for service " + getName());
    }
    String[] args = { getName(), String.valueOf(port), String.valueOf(min), String.valueOf(max) };
    logger.log(Logger.INFO, BrokerResources.I_UPDATE_SERVICE_REQ, args);
    try {
        if (min > -1 || max > -1) {
            int[] rets = protocol.setMinMaxThreads(min, max, getName());
            this.setMinMaxThreadpool(protocol.getMinThreads(), protocol.getMaxThreads());
            if (store) {
                if (rets != null) {
                    if (rets[0] > -1) {
                        Globals.getConfig().updateProperty(IMQIPServiceFactory.SERVICE_PREFIX + name + ".min_threads", String.valueOf(2 * protocol.getMinThreads()));
                    }
                    if (rets[1] > -1) {
                        Globals.getConfig().updateProperty(IMQIPServiceFactory.SERVICE_PREFIX + name + ".max_threads", String.valueOf(2 * protocol.getMaxThreads()));
                    }
                }
            }
        }
    } catch (IllegalArgumentException e) {
        String emsg = Globals.getBrokerResources().getKString(BrokerResources.X_THREADPOOL_BAD_SET, String.valueOf(min), String.valueOf(max)) + ": " + e.getMessage();
        logger.logStack(logger.ERROR, emsg, e);
        throw new BrokerException(emsg, e);
    }
    if (port > -1) {
        boolean dostore = store;
        Map params = new HashMap();
        params.put("port", String.valueOf(port));
        protocol.checkParameters(params);
        Map oldparams = protocol.setParameters(params);
        if (oldparams != null) {
            Globals.getPortMapper().removeService(name);
            try {
                bindTransport(true);
            } catch (Exception e) {
                dostore = false;
                String emsg = br.getKString(br.X_BIND_TRANSPORT_FOR_SERVICE, getName(), e.getMessage());
                logger.logStack(Logger.ERROR, emsg, e);
                protocol.setParameters(oldparams);
                Globals.getPortMapper().removeService(name);
                try {
                    bindTransport(true);
                } catch (Exception ee) {
                    emsg = br.getKString(br.X_BIND_TRANSPORT_FOR_SERVICE, getName(), e.getMessage());
                    logger.logStack(Logger.ERROR, emsg, ee);
                    throw new BrokerException(emsg, ee);
                }
            }
        }
        if (dostore) {
            Globals.getConfig().updateProperty(IMQIPServiceFactory.SERVICE_PREFIX + name + "." + protocol.getType() + ".port", String.valueOf(port));
        }
    }
}
Also used : BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) IOException(java.io.IOException) PropertyUpdateException(com.sun.messaging.jmq.jmsserver.config.PropertyUpdateException) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException)

Example 3 with PropertyUpdateException

use of com.sun.messaging.jmq.jmsserver.config.PropertyUpdateException in project openmq by eclipse-ee4j.

the class WebSocketIPService method updateService.

protected synchronized void updateService(int port, int min, int max, boolean store) throws IOException, PropertyUpdateException, BrokerException {
    if (DEBUG) {
        logger.log(logger.INFO, "WebSocketIPService.updateService(" + port + ", " + min + ", " + max + ", " + store + ") for service " + getName());
    }
    String[] args = { getName(), String.valueOf(port), String.valueOf(min), String.valueOf(max) };
    logger.log(Logger.INFO, BrokerResources.I_UPDATE_SERVICE_REQ, args);
    try {
        if (min > -1 || max > -1) {
            int[] rets = protocol.setMinMaxThreads(min, max, getName());
            this.setMinMaxThreadpool(protocol.getMinThreads(), protocol.getMaxThreads());
            if (store) {
                if (rets != null) {
                    if (rets[0] > -1) {
                        Globals.getConfig().updateProperty(IMQIPServiceFactory.SERVICE_PREFIX + name + ".min_threads", String.valueOf(2 * protocol.getMinThreads()));
                    }
                    if (rets[1] > -1) {
                        Globals.getConfig().updateProperty(IMQIPServiceFactory.SERVICE_PREFIX + name + ".max_threads", String.valueOf(2 * protocol.getMaxThreads()));
                    }
                }
            }
        }
    } catch (IllegalArgumentException e) {
        String emsg = Globals.getBrokerResources().getKString(BrokerResources.X_THREADPOOL_BAD_SET, String.valueOf(min), String.valueOf(max)) + ": " + e.getMessage();
        logger.logStack(logger.ERROR, emsg, e);
        throw new BrokerException(emsg, e);
    }
    if (port > -1) {
        boolean dostore = store;
        Map params = new HashMap();
        params.put("port", String.valueOf(port));
        protocol.checkParameters(params);
        Map oldparams = protocol.setParameters(params);
        if (oldparams != null) {
            Globals.getPortMapper().removeService(name);
            try {
                bindTransport(true);
            } catch (Exception e) {
                dostore = false;
                String emsg = br.getKString(br.X_BIND_TRANSPORT_FOR_SERVICE, getName(), e.getMessage());
                logger.logStack(Logger.ERROR, emsg, e);
                protocol.setParameters(oldparams);
                Globals.getPortMapper().removeService(name);
                try {
                    bindTransport(true);
                } catch (Exception ee) {
                    emsg = br.getKString(br.X_BIND_TRANSPORT_FOR_SERVICE, getName(), e.getMessage());
                    logger.logStack(Logger.ERROR, emsg, ee);
                    throw new BrokerException(emsg, ee);
                }
            }
        }
        if (dostore) {
            Globals.getConfig().updateProperty(IMQIPServiceFactory.SERVICE_PREFIX + name + "." + protocol.getType() + ".port", String.valueOf(port));
        }
    }
}
Also used : BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) IOException(java.io.IOException) PropertyUpdateException(com.sun.messaging.jmq.jmsserver.config.PropertyUpdateException) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException)

Aggregations

PropertyUpdateException (com.sun.messaging.jmq.jmsserver.config.PropertyUpdateException)3 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)3 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 PortMapper (com.sun.messaging.jmq.jmsserver.service.PortMapper)1 BrokerShutdownRuntimeException (com.sun.messaging.jmq.jmsserver.util.BrokerShutdownRuntimeException)1 Logger (com.sun.messaging.jmq.util.log.Logger)1