List of usage examples for org.apache.commons.jcs.auxiliary.remote.server RemoteCacheServerFactory startup
public static void startup(String host, int port, Properties props) throws IOException
From source file:org.tinygroup.cache.jcs.applicationprocessor.JcsCacheProcessor.java
private void startCluster() { int registryPort = DEFAULT_REGISTRY_PORT; try {/*from www.j a v a 2s. c o m*/ Properties props = PropertyLoader.loadProperties(DEFAULT_PROPS_FILE_NAME); if (props != null) { String portS = props.getProperty("registry.port", String.valueOf(DEFAULT_REGISTRY_PORT)); try { registryPort = Integer.parseInt(portS); } catch (NumberFormatException e) { LOGGER.errorMessage("Problem converting port to an int.", e); } } } catch (Exception e) { LOGGER.errorMessage("Problem loading props.", e); } // we will always use the local machine for the registry String registryHost; try { registryHost = InetAddress.getLocalHost().getHostAddress(); LOGGER.logMessage(LogLevel.DEBUG, "registryHost =[{}]", registryHost); if ("localhost".equals(registryHost) || "127.0.0.1".equals(registryHost)) { LOGGER.logMessage(LogLevel.WARN, "The local address [{}] is INVALID. Other machines must be able to use the address to reach this server.", registryHost); } try { LocateRegistry.createRegistry(registryPort); } catch (RemoteException e) { LOGGER.errorMessage("Problem creating registry. It may already be started. {}", e, e.getMessage()); } catch (Exception t) { LOGGER.errorMessage("Problem creating registry.", t); } try { RemoteCacheServerFactory.startup(registryHost, registryPort, "/" + DEFAULT_PROPS_FILE_NAME); } catch (IOException e) { LOGGER.errorMessage("Problem starting remote cache server.", e); } catch (Exception t) { LOGGER.errorMessage("Problem starting remote cache server.", t); } } catch (UnknownHostException e) { LOGGER.errorMessage("Could not get local address to use for the registry!", e); } }