/** * Creates a new HazelcastInstance (a new node in a cluster). * This method allows you to create and run multiple instances * of Hazelcast cluster members on the same JVM. * <p/> * To shutdown all running HazelcastInstances (all members on this JVM) * call {@link #shutdownAll()}. * * @param config Configuration for the new HazelcastInstance (member) * @return the new HazelcastInstance * @see #shutdownAll() * @see #getHazelcastInstanceByName(String) */ public static HazelcastInstance newHazelcastInstance(Config config) { return HazelcastInstanceFactory.newHazelcastInstance(config); }
/** * Gets or creates a HazelcastInstance with the default XML configuration looked up in: * <ol> * <li> * System property: Hazelcast will first check if "hazelcast.config" system property is set to a file or a * {@code classpath:...} path. * Examples: -Dhazelcast.config=C:/myhazelcast.xml , -Dhazelcast.config=classpath:the-hazelcast-config.xml , * -Dhazelcast.config=classpath:com/mydomain/hazelcast.xml * </li> * <li> * "hazelcast.xml" file in current working directory * </li> * <li> * Classpath: Hazelcast will check classpath for hazelcast.xml file. * </li> * </ol> * * If a configuration file is not located, an {@link IllegalArgumentException} will be thrown. * * If a Hazelcast instance with the same name as the configuration exists, then it is returned, otherwise it is created. * * @return the HazelcastInstance * @throws IllegalArgumentException if the instance name of the config is null or empty or if no config file can be * located. */ public static HazelcastInstance getOrCreateHazelcastInstance() { return HazelcastInstanceFactory.getOrCreateHazelcastInstance(null); }
/** * Return real name for the hazelcast instance's instance * * @param instanceName - template of the name * @param config - config * @return - real hazelcast instance's name */ public static String getInstanceName(String instanceName, Config config) { String name = instanceName; if (name == null || name.trim().length() == 0) { name = createInstanceName(config); } return name; }
OutOfMemoryErrorDispatcher.registerServer(hazelcastInstance); proxy = newHazelcastProxy(hazelcastInstance); boolean firstMember = isFirstMember(node); long initialWaitSeconds = node.getProperties().getSeconds(GroupProperty.INITIAL_WAIT_SECONDS); if (initialWaitSeconds > 0) { awaitMinimalClusterSize(hazelcastInstance, node, firstMember); future.set(proxy); hazelcastInstance.lifecycleService.fireLifecycleEvent(STARTED);
/** * Creates a new Hazelcast instance. * * @param config the configuration to use; if <code>null</code>, the set of defaults * as specified in the XSD for the configuration XML will be used. * @param instanceName the name of the {@link HazelcastInstance} * @param nodeContext the {@link NodeContext} to use * @return the configured {@link HazelcastInstance} */ public static HazelcastInstance newHazelcastInstance(Config config, String instanceName, NodeContext nodeContext) { if (config == null) { config = new XmlConfigBuilder().build(); } String name = getInstanceName(instanceName, config); InstanceFuture future = new InstanceFuture(); if (INSTANCE_MAP.putIfAbsent(name, future) != null) { throw new DuplicateInstanceNameException("HazelcastInstance with name '" + name + "' already exists!"); } try { return constructHazelcastInstance(config, name, nodeContext, future); } catch (Throwable t) { INSTANCE_MAP.remove(name, future); future.setFailure(t); throw ExceptionUtil.rethrow(t); } }
/** * Returns an existing HazelcastInstance with instanceName. * <p/> * To shutdown all running HazelcastInstances (all members on this JVM) * call {@link #shutdownAll()}. * * @param instanceName Name of the HazelcastInstance (member) * @return an existing HazelcastInstance * @see #newHazelcastInstance(Config) * @see #shutdownAll() */ public static HazelcastInstance getHazelcastInstanceByName(String instanceName) { return HazelcastInstanceFactory.getHazelcastInstance(instanceName); }
/** * Returns all active/running HazelcastInstances on this JVM. * <p/> * To shutdown all running HazelcastInstances (all members on this JVM) * call {@link #shutdownAll()}. * * @return all active/running HazelcastInstances on this JVM * @see #newHazelcastInstance(Config) * @see #getHazelcastInstanceByName(String) * @see #shutdownAll() */ public static Set<HazelcastInstance> getAllHazelcastInstances() { return HazelcastInstanceFactory.getAllHazelcastInstances(); }
public static HazelcastInstance getOrCreateHazelcastInstance(Config config) { if (config == null) { config = new XmlConfigBuilder().build(); } String name = config.getInstanceName(); checkHasText(name, "instanceName must contain text"); InstanceFuture future = INSTANCE_MAP.get(name); if (future != null) { return future.get(); } future = new InstanceFuture(); InstanceFuture found = INSTANCE_MAP.putIfAbsent(name, future); if (found != null) { return found.get(); } try { return constructHazelcastInstance(config, name, new DefaultNodeContext(), future); } catch (Throwable t) { INSTANCE_MAP.remove(name, future); future.setFailure(t); throw ExceptionUtil.rethrow(t); } }
OutOfMemoryErrorDispatcher.registerServer(hazelcastInstance); proxy = newHazelcastProxy(hazelcastInstance); boolean firstMember = isFirstMember(node); long initialWaitSeconds = node.getProperties().getSeconds(GroupProperty.INITIAL_WAIT_SECONDS); if (initialWaitSeconds > 0) { awaitMinimalClusterSize(hazelcastInstance, node, firstMember); future.set(proxy); hazelcastInstance.lifecycleService.fireLifecycleEvent(STARTED);
/** * Creates a new Hazelcast instance. * * @param config the configuration to use; if <code>null</code>, the set of defaults * as specified in the XSD for the configuration XML will be used. * @param instanceName the name of the {@link HazelcastInstance} * @param nodeContext the {@link NodeContext} to use * @return the configured {@link HazelcastInstance} */ public static HazelcastInstance newHazelcastInstance(Config config, String instanceName, NodeContext nodeContext) { if (config == null) { config = new XmlConfigBuilder().build(); } String name = getInstanceName(instanceName, config); InstanceFuture future = new InstanceFuture(); if (INSTANCE_MAP.putIfAbsent(name, future) != null) { throw new DuplicateInstanceNameException("HazelcastInstance with name '" + name + "' already exists!"); } try { return constructHazelcastInstance(config, name, nodeContext, future); } catch (Throwable t) { INSTANCE_MAP.remove(name, future); future.setFailure(t); throw ExceptionUtil.rethrow(t); } }
/** * Returns an existing HazelcastInstance with instanceName. * <p/> * To shutdown all running HazelcastInstances (all members on this JVM) * call {@link #shutdownAll()}. * * @param instanceName Name of the HazelcastInstance (member) * @return an existing HazelcastInstance * @see #newHazelcastInstance(Config) * @see #shutdownAll() */ public static HazelcastInstance getHazelcastInstanceByName(String instanceName) { return HazelcastInstanceFactory.getHazelcastInstance(instanceName); }
/** * Returns all active/running HazelcastInstances on this JVM. * <p/> * To shutdown all running HazelcastInstances (all members on this JVM) * call {@link #shutdownAll()}. * * @return all active/running HazelcastInstances on this JVM * @see #newHazelcastInstance(Config) * @see #getHazelcastInstanceByName(String) * @see #shutdownAll() */ public static Set<HazelcastInstance> getAllHazelcastInstances() { return HazelcastInstanceFactory.getAllHazelcastInstances(); }
public static HazelcastInstance getOrCreateHazelcastInstance(Config config) { if (config == null) { config = new XmlConfigBuilder().build(); } String name = config.getInstanceName(); checkHasText(name, "instanceName must contain text"); InstanceFuture future = INSTANCE_MAP.get(name); if (future != null) { return future.get(); } future = new InstanceFuture(); InstanceFuture found = INSTANCE_MAP.putIfAbsent(name, future); if (found != null) { return found.get(); } try { return constructHazelcastInstance(config, name, new DefaultNodeContext(), future); } catch (Throwable t) { INSTANCE_MAP.remove(name, future); future.setFailure(t); throw ExceptionUtil.rethrow(t); } }
/** * Creates a new HazelcastInstance (a new node in a cluster). * This method allows you to create and run multiple instances * of Hazelcast cluster members on the same JVM. * <p/> * To shutdown all running HazelcastInstances (all members on this JVM) * call {@link #shutdownAll()}. * * @param config Configuration for the new HazelcastInstance (member) * @return the new HazelcastInstance * @see #shutdownAll() * @see #getHazelcastInstanceByName(String) */ public static HazelcastInstance newHazelcastInstance(Config config) { return HazelcastInstanceFactory.newHazelcastInstance(config); }
/** * Gets or creates the HazelcastInstance with a certain name. * * If a Hazelcast instance with the same name as the configuration exists, then it is returned, otherwise it is created. * * If {@code config} is {@code null}, then an XML configuration file is looked up in the following order: * <ol> * <li> * System property: Hazelcast will first check if "hazelcast.config" system property is set to a file or a * {@code classpath:...} path. * Examples: -Dhazelcast.config=C:/myhazelcast.xml , -Dhazelcast.config=classpath:the-hazelcast-config.xml , * -Dhazelcast.config=classpath:com/mydomain/hazelcast.xml * </li> * <li> * "hazelcast.xml" file in current working directory * </li> * <li> * Classpath: Hazelcast will check classpath for hazelcast.xml file. * </li> * </ol> * * @param config the Config. * @return the HazelcastInstance * @throws IllegalArgumentException if the instance name of the config is null or empty or if no config file can be * located. */ public static HazelcastInstance getOrCreateHazelcastInstance(Config config) { return HazelcastInstanceFactory.getOrCreateHazelcastInstance(config); }
/** * Return real name for the hazelcast instance's instance * * @param instanceName - template of the name * @param config - config * @return - real hazelcast instance's name */ public static String getInstanceName(String instanceName, Config config) { String name = instanceName; if (name == null || name.trim().length() == 0) { name = createInstanceName(config); } return name; }
return HazelcastInstanceFactory.newHazelcastInstance(null);
/** * Gets or creates the HazelcastInstance with a certain name. * * If a Hazelcast instance with the same name as the configuration exists, then it is returned, otherwise it is created. * * If {@code config} is {@code null}, then an XML configuration file is looked up in the following order: * <ol> * <li> * System property: Hazelcast will first check if "hazelcast.config" system property is set to a file or a * {@code classpath:...} path. * Examples: -Dhazelcast.config=C:/myhazelcast.xml , -Dhazelcast.config=classpath:the-hazelcast-config.xml , * -Dhazelcast.config=classpath:com/mydomain/hazelcast.xml * </li> * <li> * "hazelcast.xml" file in current working directory * </li> * <li> * Classpath: Hazelcast will check classpath for hazelcast.xml file. * </li> * </ol> * * @param config the Config. * @return the HazelcastInstance * @throws IllegalArgumentException if the instance name of the config is null or empty or if no config file can be * located. */ public static HazelcastInstance getOrCreateHazelcastInstance(Config config) { return HazelcastInstanceFactory.getOrCreateHazelcastInstance(config); }
return HazelcastInstanceFactory.newHazelcastInstance(null);
/** * Gets or creates a HazelcastInstance with the default XML configuration looked up in: * <ol> * <li> * System property: Hazelcast will first check if "hazelcast.config" system property is set to a file or a * {@code classpath:...} path. * Examples: -Dhazelcast.config=C:/myhazelcast.xml , -Dhazelcast.config=classpath:the-hazelcast-config.xml , * -Dhazelcast.config=classpath:com/mydomain/hazelcast.xml * </li> * <li> * "hazelcast.xml" file in current working directory * </li> * <li> * Classpath: Hazelcast will check classpath for hazelcast.xml file. * </li> * </ol> * * If a configuration file is not located, an {@link IllegalArgumentException} will be thrown. * * If a Hazelcast instance with the same name as the configuration exists, then it is returned, otherwise it is created. * * @return the HazelcastInstance * @throws IllegalArgumentException if the instance name of the config is null or empty or if no config file can be * located. */ public static HazelcastInstance getOrCreateHazelcastInstance() { return HazelcastInstanceFactory.getOrCreateHazelcastInstance(null); }