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();
}
}
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);
}
}
}
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);
}
}
}
}
Aggregations