예제 #1
0
  private HazelcastInstance defaultConfig(final ClusteringConfig clusteringConfig) {
    final Config hazelcastConfig = new Config();

    hazelcastConfig.setGroupConfig(
        new GroupConfig(clusteringConfig.getClusterName(), clusteringConfig.getClusterPassword()));

    final NetworkConfig networkConfig = new NetworkConfig();

    networkConfig.setPort(clusteringConfig.getMulticastPort());

    final JoinConfig joinConfig = new JoinConfig();

    final MulticastConfig multicastConfig = new MulticastConfig();

    multicastConfig.setMulticastPort(clusteringConfig.getMulticastPort());

    multicastConfig.setMulticastGroup(clusteringConfig.getMulticastGroup());

    joinConfig.setMulticastConfig(multicastConfig);

    networkConfig.setJoin(joinConfig);

    hazelcastConfig.setNetworkConfig(networkConfig);

    return Hazelcast.newHazelcastInstance(hazelcastConfig);
  }
  protected HazelcastInstance hazelcastInstance() {
    Config config = new Config();

    config.addCacheConfig(
        new CacheSimpleConfig()
            .setName("result-cache")
            .setInMemoryFormat(InMemoryFormat.BINARY)
            .setEvictionConfig(new EvictionConfig().setEvictionPolicy(EvictionPolicy.LRU))
            .setExpiryPolicyFactoryConfig(
                new CacheSimpleConfig.ExpiryPolicyFactoryConfig(
                    new CacheSimpleConfig.ExpiryPolicyFactoryConfig.TimedExpiryPolicyFactoryConfig(
                        CacheSimpleConfig.ExpiryPolicyFactoryConfig.TimedExpiryPolicyFactoryConfig
                            .ExpiryPolicyType.ACCESSED,
                        new CacheSimpleConfig.ExpiryPolicyFactoryConfig.DurationConfig(
                            20, TimeUnit.MINUTES)))));

    NetworkConfig networkConfig = new NetworkConfig();
    networkConfig.setPort(5712).setPortAutoIncrement(true);

    config.setNetworkConfig(networkConfig);
    config.setGroupConfig(new GroupConfig("ach-validation", "ach-validation"));

    TcpClusterConfigurator.configureNetwork(config.getNetworkConfig());
    TcpClusterConfigurator.configureGroup(config.getGroupConfig());

    return Hazelcast.newHazelcastInstance(config);
  }
예제 #3
0
 private Config newConfig(String mergePolicy, String mapName) {
   Config config = new Config();
   setCommonProperties(config);
   config.setProperty(GroupProperty.MERGE_FIRST_RUN_DELAY_SECONDS.getName(), "5");
   config.setProperty(GroupProperty.MERGE_NEXT_RUN_DELAY_SECONDS.getName(), "3");
   MapConfig mapConfig = config.getMapConfig(mapName);
   mapConfig.setMergePolicy(mergePolicy);
   mapConfig.setBackupCount(1);
   mapConfig.setReadBackupData(true);
   mapConfig.setStatisticsEnabled(true);
   mapConfig.setMaxIdleSeconds(0);
   mapConfig.setTimeToLiveSeconds(0);
   mapConfig.addMapIndexConfig(new MapIndexConfig("id", false));
   config.setNetworkConfig(this.getLocalhostTcpIpNetworkConfig(6701));
   config.getGroupConfig().setName(mapName);
   config.getGroupConfig().setPassword(mapName);
   return config;
 }