Пример #1
0
  @Test
  public void testInitDNodeList() throws Throwable {
    SploutConfiguration config = SploutConfiguration.getTestConfig();
    QNodeHandler handler = new QNodeHandler();
    try {
      HazelcastInstance hz = Hazelcast.newHazelcastInstance(HazelcastConfigBuilder.build(config));
      CoordinationStructures coord = new CoordinationStructures(hz);

      SploutConfiguration dNodeConfig = SploutConfiguration.getTestConfig();
      dNodeConfig.setProperty(DNodeProperties.PORT, 1000);

      coord.getDNodes().put("/localhost:1000", new DNodeInfo(dNodeConfig));

      dNodeConfig = SploutConfiguration.getTestConfig();
      dNodeConfig.setProperty(DNodeProperties.PORT, 1001);

      coord.getDNodes().put("/localhost:1001", new DNodeInfo(dNodeConfig));

      try {
        handler.init(config);
      } catch (Exception e) {
        // since the handler will try to connect to "localhost:1000" we skip the Exception and
        // continue
        // the things we want to assert should be present anyway.
      }
      Assert.assertEquals(
          handler.getContext().getCoordinationStructures().getDNodes().values().size(), 2);
    } finally {
      handler.close();
      Hazelcast.shutdownAll();
    }
  }
Пример #2
0
  /** Gets only the default values and adds some desirable properties for testing, */
  public static SploutConfiguration getTestConfig() {
    SploutConfiguration properties = new SploutConfiguration();
    PropertiesConfiguration config = load("", SPLOUT_PROPERTIES + ".default", true);
    properties.addConfiguration(config);

    // Activate replica balancing for tests
    properties.setProperty(QNodeProperties.REPLICA_BALANCE_ENABLE, true);

    // Disable wait for testing speedup.
    properties.setProperty(HazelcastProperties.DISABLE_WAIT_WHEN_JOINING, true);

    // Disable warming up - set it to only one second
    // that's enough since Hazelcast joining is by far slower
    properties.setProperty(QNodeProperties.WARMING_TIME, 1);

    // Disable HZ state storage
    properties.clearProperty(HazelcastProperties.HZ_PERSISTENCE_FOLDER);
    return properties;
  }