Ejemplo n.º 1
0
 public void join() {
   final long joinStartTime = joiner != null ? joiner.getStartTime() : Clock.currentTimeMillis();
   final long maxJoinMillis = getGroupProperties().MAX_JOIN_SECONDS.getInteger() * 1000;
   try {
     if (joiner == null) {
       logger.warning("No join method is enabled! Starting standalone.");
       setAsMaster();
     } else {
       joiner.join(joined);
     }
   } catch (Exception e) {
     if (Clock.currentTimeMillis() - joinStartTime < maxJoinMillis) {
       logger.warning("Trying to rejoin: " + e.getMessage());
       rejoin();
     } else {
       logger.severe("Could not join cluster, shutting down!", e);
       shutdown(false, true);
     }
   }
 }
Ejemplo n.º 2
0
  @Test
  public void testEvictionLFU2() {
    try {
      final int k = 2;
      final int size = 10000;
      final String mapName = "testEvictionLFU2";
      Config cfg = new Config();
      MapConfig mc = cfg.getMapConfig(mapName);
      mc.setEvictionPolicy(MapConfig.EvictionPolicy.LFU);
      mc.setEvictionPercentage(90);
      MaxSizeConfig msc = new MaxSizeConfig();
      msc.setMaxSizePolicy(MaxSizeConfig.MaxSizePolicy.PER_NODE);
      msc.setSize(size);
      mc.setMaxSizeConfig(msc);

      TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(k);
      final HazelcastInstance[] instances = factory.newInstances(cfg);
      IMap<Object, Object> map = instances[0].getMap(mapName);

      for (int i = 0; i < size; i++) {
        map.put(i, i);
      }

      for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 100; j++) {
          assertNotNull(map.get(j));
        }
        for (int j = size - 100; j < size; j++) {
          assertNotNull(map.get(j));
        }
        Thread.sleep(1000);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }