@Override public void afterPropertiesSet() throws Exception { URL xml = getClass().getResource("/hazelcast.xml"); if (xml == null) { throw new FileNotFoundException("Configuration file hazelcast.xml was not found"); } Config config = new UrlXmlConfig(xml); String instanceName = cyclosProperties == null ? null : cyclosProperties.getProperty("cyclos.instanceHandler.instanceName"); if (StringUtils.isEmpty(instanceName)) { instanceName = "cyclos"; } config.setInstanceName(instanceName); hazelcastInstance = Hazelcast.newHazelcastInstance(config); member = hazelcastInstance.getCluster().getLocalMember(); }
@Override public void afterPropertiesSet() throws Exception { URL xml = getClass().getResource("/hazelcast.xml"); if (xml == null) { throw new FileNotFoundException("Configuration file hazelcast.xml was not found"); } Config config = new UrlXmlConfig(xml); String instanceName = cyclosProperties == null ? null : cyclosProperties.getProperty("cyclos.instanceHandler.instanceName"); if (StringHelper.isEmpty(instanceName)) { instanceName = "cyclos"; } config.setInstanceName(instanceName); hazelcastInstance = Hazelcast.newHazelcastInstance(config); member = hazelcastInstance.getCluster().getLocalMember(); }
public HazelcastInstance loadInstance() throws CacheException { if (instance != null && instance.getLifecycleService().isRunning()) { logger.log(Level.WARNING, "Current HazelcastInstance is already loaded and running! " + "Returning current instance..."); return instance; } String configResourcePath = null; if (props != null) { instanceName = CacheEnvironment.getInstanceName(props); useLiteMember = CacheEnvironment.isLiteMember(props); if (!useLiteMember && props.contains(CacheEnvironment.USE_SUPER_CLIENT)) { useLiteMember = CacheEnvironment.isSuperClient(props); logger.log(Level.WARNING, "'" + CacheEnvironment.USE_SUPER_CLIENT + "' property is deprecated!" + " Please use '" + CacheEnvironment.USE_LITE_MEMBER + "' instead..."); } configResourcePath = CacheEnvironment.getConfigFilePath(props); } if (useLiteMember) { logger.log(Level.WARNING, "Creating Hazelcast node as Lite-Member. " + "Be sure this node has access to an already running cluster..."); } if (StringHelper.isEmpty(configResourcePath)) { // If both useLiteMember and instanceName is not set // then just use default instance. if (!useLiteMember && instanceName == null) { staticInstance = true; } } else { URL url = ConfigHelper.locateConfig(configResourcePath); try { config = new UrlXmlConfig(url); } catch (IOException e) { throw new CacheException(e); } } if (instanceName != null) { instance = Hazelcast.getHazelcastInstanceByName(instanceName); if (instance == null) { try { createOrGetInstance(); } catch (DuplicateInstanceNameException ignored) { instance = Hazelcast.getHazelcastInstanceByName(instanceName); } } } else { createOrGetInstance(); } return instance; }