Search in sources :

Example 6 with PUService

use of com.sun.messaging.portunif.PUService in project openmq by eclipse-ee4j.

the class PortMapper method destroy.

public void destroy() {
    running = false;
    try {
        if (serverSocket != null) {
            serverSocket.close();
        }
    } catch (IOException ex) {
        logger.logStack(Logger.INFO, "Error closing portmapper", ex);
    }
    serverSocket = null;
    PUService pu = Globals.getPUService();
    if (pu != null) {
        try {
            pu.destroy();
        } catch (IOException ex) {
            logger.logStack(Logger.INFO, "Error closing Grizzly PU service transport", ex);
        }
    }
    if (threadPool != null) {
        threadPool.shutdownNow();
    }
}
Also used : PUService(com.sun.messaging.portunif.PUService)

Example 7 with PUService

use of com.sun.messaging.portunif.PUService in project openmq by eclipse-ee4j.

the class PortMapper method setPort.

/**
 * Change the portmapper service's port
 */
private synchronized void setPort(int port) {
    if (port == this.port) {
        return;
    }
    this.port = port;
    addService(SERVICE_NAME, "tcp", "PORTMAPPER", port, portmapperMap);
    LockFile lf = LockFile.getCurrentLockFile();
    try {
        if (lf != null) {
            lf.updatePort(port, Globals.getUseFileLockForLockFile());
        }
    } catch (IOException e) {
        logger.log(Logger.WARNING, rb.E_LOCKFILE_BADUPDATE, e);
    }
    if (serverSocket != null) {
        // one with the new port
        try {
            serverSocket.close();
        } catch (IOException e) {
        }
    }
    PUService pu = Globals.getPUService();
    if (pu != null) {
        try {
            pu.rebind(new InetSocketAddress(bindAddr, port), backlog);
        } catch (IOException e) {
            logger.logStack(logger.ERROR, Globals.getBrokerResources().getKString(BrokerResources.X_PU_SERVICE_REBIND, (bindAddr == null ? "" : bindAddr.getHostAddress()) + ":" + port), e);
        }
    }
}
Also used : PUService(com.sun.messaging.portunif.PUService) LockFile(com.sun.messaging.jmq.jmsserver.util.LockFile)

Example 8 with PUService

use of com.sun.messaging.portunif.PUService in project openmq by eclipse-ee4j.

the class PortMapper method setHostname.

/**
 * Change the portmapper service's host interface
 */
private synchronized void setHostname(String hostname, boolean initOnly) throws PropertyUpdateException {
    MQAddress mqaddr = null;
    try {
        String h = hostname;
        if (hostname != null && hostname.equals(Globals.HOSTNAME_ALL)) {
            h = null;
        }
        mqaddr = MQAddress.getMQAddress(h, getPort());
    } catch (Exception e) {
        throw new PropertyUpdateException(hostname + ": " + e.toString(), e);
    }
    if (hostname == null || hostname.equals(Globals.HOSTNAME_ALL) || hostname.trim().length() == 0) {
        // Bind to all
        this.hostname = null;
        this.bindAddr = null;
        mqaddress = mqaddr;
        if (!initOnly) {
            PUService pu = Globals.getPUService();
            if (pu != null) {
                try {
                    pu.rebind(new InetSocketAddress(bindAddr, port), backlog);
                } catch (IOException e) {
                    logger.logStack(logger.ERROR, Globals.getBrokerResources().getKString(BrokerResources.X_PU_SERVICE_REBIND, (bindAddr == null ? "" : bindAddr.getHostAddress()) + ":" + port), e);
                }
            }
        }
        return;
    }
    if (hostname.equals(this.hostname)) {
        return;
    }
    try {
        if (Globals.isConfigForCluster()) {
            String hn = hostname;
            if (hn.equals("localhost")) {
                hn = null;
            }
            this.bindAddr = BrokerMQAddress.resolveBindAddress(hn, true);
            mqaddr = MQAddress.getMQAddress(this.bindAddr.getHostAddress(), getPort());
        } else {
            this.bindAddr = InetAddress.getByName(hostname);
        }
    } catch (Exception e) {
        throw new PropertyUpdateException(rb.getString(rb.E_BAD_HOSTNAME, hostname), e);
    }
    this.hostname = hostname;
    this.mqaddress = mqaddr;
    LockFile lf = LockFile.getCurrentLockFile();
    try {
        if (lf != null) {
            lf.updateHostname(mqaddress.getHostName(), Globals.getUseFileLockForLockFile());
        }
    } catch (IOException e) {
        logger.log(Logger.WARNING, rb.E_LOCKFILE_BADUPDATE, e);
    }
    if (serverSocket != null) {
        // one with the new port
        try {
            serverSocket.close();
        } catch (IOException e) {
        }
    }
    if (!initOnly) {
        PUService pu = Globals.getPUService();
        if (pu != null) {
            try {
                pu.rebind(new InetSocketAddress(bindAddr, port), backlog);
            } catch (IOException e) {
                logger.logStack(logger.ERROR, Globals.getBrokerResources().getKString(BrokerResources.X_PU_SERVICE_REBIND, (bindAddr == null ? "" : bindAddr.getHostAddress()) + ":" + port), e);
            }
        }
    }
}
Also used : PUService(com.sun.messaging.portunif.PUService) MQAddress(com.sun.messaging.jmq.io.MQAddress) BrokerMQAddress(com.sun.messaging.jmq.jmsserver.core.BrokerMQAddress) LockFile(com.sun.messaging.jmq.jmsserver.util.LockFile) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException)

Aggregations

PUService (com.sun.messaging.portunif.PUService)8 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)2 LockFile (com.sun.messaging.jmq.jmsserver.util.LockFile)2 Properties (java.util.Properties)2 LogSimpleFormatter (com.sun.messaging.bridge.api.LogSimpleFormatter)1 MQAddress (com.sun.messaging.jmq.io.MQAddress)1 BrokerMQAddress (com.sun.messaging.jmq.jmsserver.core.BrokerMQAddress)1 StompProtocolFinder (com.sun.messaging.portunif.StompProtocolFinder)1 Message (jakarta.jms.Message)1 InetSocketAddress (java.net.InetSocketAddress)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 FileHandler (java.util.logging.FileHandler)1 FilterChain (org.glassfish.grizzly.filterchain.FilterChain)1 FilterChainBuilder (org.glassfish.grizzly.filterchain.FilterChainBuilder)1 TransportFilter (org.glassfish.grizzly.filterchain.TransportFilter)1 PUProtocol (org.glassfish.grizzly.portunif.PUProtocol)1 SSLEngineConfigurator (org.glassfish.grizzly.ssl.SSLEngineConfigurator)1