/** * Creates a {@link HazelcastBucketManagerFactory} from hazelcast config * @param config the {@link Config} * @return the HazelCastBucketManagerFactory instance * @throws NullPointerException when config is null */ public HazelcastBucketManagerFactory get(Config config)throws NullPointerException { requireNonNull(config, "config is required"); HazelcastInstance hazelcastInstance = Hazelcast.getOrCreateHazelcastInstance(config); return new DefaultHazelcastBucketManagerFactory(hazelcastInstance); }
/** * Creates a {@link HazelcastBucketManagerFactory} from configuration map * @param configurations the configuration map * @return the HazelCastBucketManagerFactory instance * @throws NullPointerException when configurations is null */ public HazelcastBucketManagerFactory get(Map<String, String> configurations) throws NullPointerException { List<String> servers = configurations.keySet().stream().filter(s -> s.startsWith("hazelcast-hoster-")) .collect(Collectors.toList()); Config config = new Config(configurations.getOrDefault("hazelcast-instanceName", "hazelcast-instanceName")); HazelcastInstance hazelcastInstance = Hazelcast.getOrCreateHazelcastInstance(config); return new DefaultHazelcastBucketManagerFactory(hazelcastInstance); }
public static HazelcastInstance getInstance() { if (hazelcastInstance == null) { Config config = new XmlConfigBuilder().build(); config.setInstanceName(Thread.currentThread().getName()); hazelcastInstance = Hazelcast.getOrCreateHazelcastInstance(config); } return hazelcastInstance; }
private HazelcastInstance getDefaultInstance() { if (hazelcastInstance == null) { // if there is no default instance in use (not created yet and not specified): // 1. locate default ClientConfig: if it specifies an instance name, get-or-create an instance by that name // 2. otherwise start a new Hazelcast member Config config = getDefaultConfig(); if (isNullOrEmptyAfterTrim(config.getInstanceName())) { hazelcastInstance = Hazelcast.newHazelcastInstance(); } else { hazelcastInstance = Hazelcast.getOrCreateHazelcastInstance(config); } } return hazelcastInstance; }
private HazelcastInstance getDefaultInstance() { if (hazelcastInstance == null) { // if there is no default instance in use (not created yet and not specified): // 1. locate default ClientConfig: if it specifies an instance name, get-or-create an instance by that name // 2. otherwise start a new Hazelcast member Config config = getDefaultConfig(); if (isNullOrEmptyAfterTrim(config.getInstanceName())) { hazelcastInstance = Hazelcast.newHazelcastInstance(); } else { hazelcastInstance = Hazelcast.getOrCreateHazelcastInstance(config); } } return hazelcastInstance; }
/** * Gets an existing {@link HazelcastInstance} by {@code instanceName} or, * if not found, creates a new {@link HazelcastInstance} with the default * configuration and given {@code instanceName}. * * @param instanceName name to lookup an existing {@link HazelcastInstance} * or to create a new one * @return a {@link HazelcastInstance} with the given {@code instanceName} */ private HazelcastInstance getOrCreateByInstanceName(String instanceName) { HazelcastInstance instance = Hazelcast.getHazelcastInstanceByName(instanceName); if (instance == null) { Config config = getDefaultConfig(); config.setInstanceName(instanceName); instance = Hazelcast.getOrCreateHazelcastInstance(config); } return instance; }
/** * Gets an existing {@link HazelcastInstance} by {@code instanceName} or, * if not found, creates a new {@link HazelcastInstance} with the default * configuration and given {@code instanceName}. * * @param instanceName name to lookup an existing {@link HazelcastInstance} * or to create a new one * @return a {@link HazelcastInstance} with the given {@code instanceName} */ private HazelcastInstance getOrCreateByInstanceName(String instanceName) { HazelcastInstance instance = Hazelcast.getHazelcastInstanceByName(instanceName); if (instance == null) { Config config = getDefaultConfig(); config.setInstanceName(instanceName); instance = Hazelcast.getOrCreateHazelcastInstance(config); } return instance; }
/** * Create hazelcast full instance. * * @param configLocation the config location * @return the hazelcast instance */ public static HazelcastInstance createHazelcastFullInstance(String configLocation) { Config config; try { if (configLocation == null) { config = new XmlConfigBuilder().build(); } else { config = ConfigLoader.load(configLocation); } } catch (IOException e) { throw new RuntimeException("failed to load config", e); } checkNotNull(config, "failed to find configLocation: " + configLocation); config.setInstanceName(DEFAULT_INSTANCE_NAME); return Hazelcast.getOrCreateHazelcastInstance(config); } }
} else if (config != null) { if (ObjectHelper.isNotEmpty(config.getInstanceName())) { hzInstance = Hazelcast.getOrCreateHazelcastInstance(config); } else { hzInstance = Hazelcast.newHazelcastInstance(config);
this.hazelcastInstance = Hazelcast.getOrCreateHazelcastInstance(this.hazelcastConfig);
this.hazelcastInstance = Hazelcast.getOrCreateHazelcastInstance(this.hazelcastConfig);
return Hazelcast.getOrCreateHazelcastInstance(config); } else { ClientConfig clientConfig = new ClientConfig();
this.hazelcastInstance = Hazelcast.getOrCreateHazelcastInstance(config);
hazelcastInstance = Hazelcast.getOrCreateHazelcastInstance( config );