예제 #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);
  }
예제 #2
0
  @LazySingleton
  @Provides
  public HazelcastInstance getInstance(ClusteringConfig clusteringConfig)
      throws FileNotFoundException {
    if (new File(clusteringConfig.getOverridePath()).exists()) {
      logger
          .with("override-path", clusteringConfig.getOverridePath())
          .info("Using hazelcast override");

      final Config hazelcastXmlConfig =
          new XmlConfigBuilder(clusteringConfig.getOverridePath()).build();

      return Hazelcast.newHazelcastInstance(hazelcastXmlConfig);
    }

    return defaultConfig(clusteringConfig);
  }