private Config newConfig() {
   Config config = new Config();
   config.setProperty(GroupProperty.MERGE_FIRST_RUN_DELAY_SECONDS, "5");
   config.setProperty(GroupProperty.MERGE_NEXT_RUN_DELAY_SECONDS, "3");
   config.getGroupConfig().setName(generateRandomString(10));
   return config;
 }
Пример #2
0
  @Repeat(25)
  @Test
  public void testEachConnectionUseDifferentSelectorEventually() {
    Config config = new Config();
    config.setProperty(GroupProperties.PROP_IO_BALANCER_INTERVAL_SECONDS, "1");
    config.setProperty(GroupProperties.PROP_IO_THREAD_COUNT, "2");

    HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
    HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(config);
    HazelcastInstance instance3 = Hazelcast.newHazelcastInstance(config);

    instance2.shutdown();
    instance2 = Hazelcast.newHazelcastInstance(config);

    IMap<Integer, Integer> map = instance1.getMap(randomMapName());

    long deadLine = System.currentTimeMillis() + TEST_DURATION_SECONDS * 1000;
    for (int i = 0; System.currentTimeMillis() < deadLine; i++) {
      map.put(i % 1000, i);
    }

    assertBalanced(instance1);
    assertBalanced(instance2);
    assertBalanced(instance3);
  }
 private BasicBackPressureService newEnabledBackPressureService() {
   Config config = new Config();
   config.setProperty(GroupProperties.PROP_BACKPRESSURE_ENABLED, "true");
   config.setProperty(GroupProperties.PROP_BACKPRESSURE_SYNCWINDOW, "" + SYNC_WINDOW);
   GroupProperties groupProperties = new GroupProperties(config);
   return new BasicBackPressureService(groupProperties, logger);
 }
 @Test(expected = IllegalArgumentException.class)
 public void testConstruction_invalidSyncWindow() {
   Config config = new Config();
   config.setProperty(GroupProperties.PROP_BACKPRESSURE_ENABLED, "true");
   config.setProperty(GroupProperties.PROP_BACKPRESSURE_SYNCWINDOW, "" + 0);
   GroupProperties groupProperties = new GroupProperties(config);
   new BasicBackPressureService(groupProperties, logger);
 }
  @Before
  public void setup() {
    Config config = new Config();
    config.setProperty(BACKPRESSURE_ENABLED, "false");
    config.setProperty(OPERATION_CALL_TIMEOUT_MILLIS, "20000");
    local = createHazelcastInstance(config);
    warmUpPartitions(local);
    nodeEngine = getNodeEngineImpl(local);

    operationService = getOperationServiceImpl(local);
    invocationRegistry = operationService.invocationRegistry;
  }
Пример #6
0
  private Config createChunkedMapLoaderConfig(
      String mapName, int chunkSize, ChunkedLoader chunkedLoader) {
    Config cfg = getConfig();
    cfg.setProperty(GroupProperty.PARTITION_COUNT, "1");
    cfg.setProperty(GroupProperty.MAP_LOAD_CHUNK_SIZE, String.valueOf(chunkSize));

    MapStoreConfig mapStoreConfig = new MapStoreConfig();
    mapStoreConfig.setEnabled(true);
    mapStoreConfig.setImplementation(chunkedLoader);

    MapConfig mapConfig = cfg.getMapConfig(mapName);
    mapConfig.setMapStoreConfig(mapStoreConfig);
    return cfg;
  }
Пример #7
0
  @Test
  public void testWaitingIndefinitely() throws InterruptedException {
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(5);
    final Config config = new Config();
    config.setProperty(GroupProperties.PROP_OPERATION_CALL_TIMEOUT_MILLIS, "2000");
    final HazelcastInstance[] instances = factory.newInstances(config);

    instances[0].getLock("testWaitingIndefinitely").lock();

    final CountDownLatch latch = new CountDownLatch(1);
    new Thread() {
      public void run() {
        try {
          // because max timeout=2000 we get timeout exception which we should not
          instances[1].getLock("testWaitingIndefinitely").lock();
          latch.countDown();
        } catch (Exception ignored) {
        }
      }
    }.start();

    // wait for enough time which is greater than max-timeout (2000)
    Thread.sleep(10000);

    instances[0].getLock("testWaitingIndefinitely").unlock();

    assertTrue(latch.await(5, TimeUnit.SECONDS));
  }
Пример #8
0
  @Test
  public void testWaitingIndefinitely() throws InterruptedException {
    final Config config = new Config();
    config.setProperty(GroupProperties.PROP_OPERATION_CALL_TIMEOUT_MILLIS, "3000");

    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
    final HazelcastInstance[] instances = factory.newInstances(config);

    // need to warm-up partitions,
    // since waiting for lock backup can take up to 5 seconds
    // and that may cause OperationTimeoutException with "No response for 4000 ms" error.
    warmUpPartitions(instances);

    final String name = "testWaitingIndefinitely";
    ILock lock = instances[0].getLock(name);
    lock.lock();

    final CountDownLatch latch = new CountDownLatch(1);
    new Thread() {
      public void run() {
        try {
          // because max timeout=3000 we get timeout exception which we should not
          instances[1].getLock(name).lock();
          latch.countDown();
        } catch (Exception ignored) {
        }
      }
    }.start();

    // wait for enough time which is greater than max-timeout (3000)
    sleepSeconds(10);
    lock.unlock();

    assertTrue(latch.await(20, TimeUnit.SECONDS));
  }
Пример #9
0
  @Test
  public void testClientListenerDisconnected() throws InterruptedException {
    Config config = new Config();
    config.setProperty(GroupProperties.PROP_IO_THREAD_COUNT, "1");

    final HazelcastInstance hz = Hazelcast.newHazelcastInstance(config);
    final HazelcastInstance hz2 = Hazelcast.newHazelcastInstance(config);

    int clientCount = 10;
    ClientDisconnectedListenerLatch listenerLatch =
        new ClientDisconnectedListenerLatch(2 * clientCount);
    hz.getClientService().addClientListener(listenerLatch);
    hz2.getClientService().addClientListener(listenerLatch);

    Collection<HazelcastInstance> clients = new LinkedList<HazelcastInstance>();
    for (int i = 0; i < clientCount; i++) {
      HazelcastInstance client = HazelcastClient.newHazelcastClient();
      IMap<Object, Object> map = client.getMap(randomMapName());

      map.addEntryListener(new EntryAdapter<Object, Object>(), true);
      map.put(generateKeyOwnedBy(hz), "value");
      map.put(generateKeyOwnedBy(hz2), "value");

      clients.add(client);
    }

    ExecutorService ex = Executors.newFixedThreadPool(4);
    try {
      for (final HazelcastInstance client : clients) {
        ex.execute(
            new Runnable() {
              @Override
              public void run() {
                client.shutdown();
              }
            });
      }

      assertOpenEventually(listenerLatch, 30);

      assertTrueEventually(
          new AssertTask() {
            @Override
            public void run() throws Exception {
              assertEquals(0, hz.getClientService().getConnectedClients().size());
            }
          },
          10);
      assertTrueEventually(
          new AssertTask() {
            @Override
            public void run() throws Exception {
              assertEquals(0, hz2.getClientService().getConnectedClients().size());
            }
          },
          10);
    } finally {
      ex.shutdown();
    }
  }
Пример #10
0
  @Test
  public void testPutInterruption() throws InterruptedException {
    Config config = new Config();
    config.setProperty(GroupProperties.PROP_OPERATION_CALL_TIMEOUT_MILLIS, "1000");
    config.getQueueConfig("default").setMaxSize(1);

    HazelcastInstance instance = createHazelcastInstance(config);
    final IQueue<Object> queue = instance.getQueue(randomName());
    final AtomicBoolean interrupted = new AtomicBoolean();

    assertTrue(queue.offer("item"));

    Thread t =
        new Thread() {
          public void run() {
            try {
              queue.put("item");
            } catch (InterruptedException e) {
              interrupted.set(true);
            }
          }
        };
    t.start();

    sleepSeconds(1);
    t.interrupt();
    t.join(5000);

    assertTrue(interrupted.get());
  }
Пример #11
0
  @Test
  @Category(ProblematicTest.class) // TODO
  public void testLockInterruption() throws InterruptedException {
    Config config = new Config();
    config.setProperty(GroupProperties.PROP_OPERATION_CALL_TIMEOUT_MILLIS, "5000");
    final TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory(1);
    final HazelcastInstance hz = nodeFactory.newHazelcastInstance(config);

    final Lock lock = hz.getLock("testLockInterruption2");
    final CountDownLatch latch = new CountDownLatch(1);
    Thread t =
        new Thread(
            new Runnable() {
              public void run() {
                try {
                  lock.tryLock(60, TimeUnit.SECONDS);
                } catch (InterruptedException ignored) {
                  latch.countDown();
                }
              }
            });
    lock.lock();
    t.start();
    Thread.sleep(2000);
    t.interrupt();
    assertTrue("tryLock() is not interrupted!", latch.await(30, TimeUnit.SECONDS));
    lock.unlock();
    assertTrue("Could not acquire lock!", lock.tryLock());
  }
Пример #12
0
  private void multicastJoin(int count, final boolean sleep) throws InterruptedException {
    final TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory(count);

    final Config config = new Config();
    config.setProperty("hazelcast.wait.seconds.before.join", "5");
    config.getNetworkConfig().getJoin().getMulticastConfig().setMulticastTimeoutSeconds(25);
    final ConcurrentMap<Integer, HazelcastInstance> map =
        new ConcurrentHashMap<Integer, HazelcastInstance>();
    final CountDownLatch latch = new CountDownLatch(count);
    final ExecutorService ex = Executors.newCachedThreadPool();
    for (int i = 0; i < count; i++) {
      final int index = i;
      ex.execute(
          new Runnable() {
            public void run() {
              if (sleep) {
                try {
                  Thread.sleep((int) (1000 * Math.random()));
                } catch (InterruptedException ignored) {
                }
              }
              HazelcastInstance h = nodeFactory.newHazelcastInstance(config);
              map.put(index, h);
              latch.countDown();
            }
          });
    }
    assertOpenEventually(latch);
    for (HazelcastInstance h : map.values()) {
      assertEquals(count, h.getCluster().getMembers().size());
    }
    ex.shutdown();
  }
  @Test
  public void testSerialization() {
    Config config = new Config();
    config.setProperty(GroupProperties.PROP_MC_MAX_VISIBLE_SLOW_OPERATION_COUNT, "127");

    SlowOperationInvocationDTO slowOperationInvocationDTO = new SlowOperationInvocationDTO();
    slowOperationInvocationDTO.id = 12345;
    slowOperationInvocationDTO.durationMs = 15000;
    slowOperationInvocationDTO.startedAt = 12381912;
    slowOperationInvocationDTO.operationDetails = "TestOperationDetails";

    List<SlowOperationInvocationDTO> invocationList = new ArrayList<SlowOperationInvocationDTO>();
    invocationList.add(slowOperationInvocationDTO);

    SlowOperationDTO slowOperationDTO = new SlowOperationDTO();
    slowOperationDTO.operation = "TestOperation";
    slowOperationDTO.stackTrace = "stackTrace";
    slowOperationDTO.totalInvocations = 4;
    slowOperationDTO.invocations = invocationList;

    HazelcastInstance hazelcastInstance = createHazelcastInstance(config);
    Node node = getNode(hazelcastInstance);
    LocalOperationStatsImpl localOperationStats = new LocalOperationStatsImpl(node);
    localOperationStats.getSlowOperations().add(slowOperationDTO);

    LocalOperationStatsImpl deserialized = new LocalOperationStatsImpl();
    deserialized.fromJson(localOperationStats.toJson());

    assertEquals(localOperationStats.getCreationTime(), deserialized.getCreationTime());
    assertEquals(
        localOperationStats.getMaxVisibleSlowOperationCount(),
        deserialized.getMaxVisibleSlowOperationCount());
    assertEqualsSlowOperationDTOs(
        localOperationStats.getSlowOperations(), deserialized.getSlowOperations());
  }
  HazelcastInstance getSingleNodeCluster(int slowOperationThresholdMillis) {
    Config config = new Config();
    config.setProperty(
        GroupProperty.SLOW_OPERATION_DETECTOR_THRESHOLD_MILLIS.getName(),
        valueOf(slowOperationThresholdMillis));

    return createHazelcastInstance(config);
  }
 @Test
 public void testDisablingSystemLogs() throws Exception {
   Config config = new Config();
   config.setProperty(GroupProperties.PROP_SYSTEM_LOG_ENABLED, "true");
   config.getGroupConfig().setName("testDisablingSystemLogs");
   HazelcastInstance instance = Hazelcast.newHazelcastInstance(config);
   HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(config);
   instance.getMap("map").put("key", "value");
   Node node = TestUtil.getNode(instance);
   assertTrue(node.getSystemLogService().getLogBundle().size() > 0);
   Hazelcast.shutdownAll();
   config.setProperty(GroupProperties.PROP_SYSTEM_LOG_ENABLED, "false");
   instance = Hazelcast.newHazelcastInstance(config);
   instance2 = Hazelcast.newHazelcastInstance(config);
   instance.getMap("map").put("key2", "value2");
   assertTrue(node.getSystemLogService().getLogBundle().size() == 0);
 }
Пример #16
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;
 }
  private Config hazelcast() {
    Config conf = new Config();
    conf.getNetworkConfig().setPort(hazelCastPort);
    conf.getNetworkConfig().setPortAutoIncrement(false);

    conf.setProperty("hazelcast.initial.min.cluster.size", "1");
    conf.setProperty("hazelcast.shutdownhook.enabled", "false");

    JoinConfig join = conf.getNetworkConfig().getJoin();

    boolean isAws = System.getProperty("hazelcast.aws", "false").equals("true");
    log.info("Setting up Joiner with this being " + (isAws ? "AWS" : "Multicast"));

    join.getAwsConfig().setEnabled(isAws);
    if (isAws) {
      join.getAwsConfig().setAccessKey(System.getProperty("hazelcast.access-key"));
      join.getAwsConfig().setSecretKey(System.getProperty("hazelcast.access-secret"));
    }
    join.getMulticastConfig().setEnabled(!isAws);

    ListConfig jobConfig = new ListConfig();
    jobConfig.setName(JOBS);

    conf.addListConfig(jobConfig);

    ListConfig replicateConfig = new ListConfig();
    replicateConfig.setName(REPLICATE_WEIGHTS);

    conf.addListConfig(replicateConfig);

    ListConfig topicsConfig = new ListConfig();
    topicsConfig.setName(TOPICS);

    conf.addListConfig(topicsConfig);

    ListConfig updatesConfig = new ListConfig();
    updatesConfig.setName(UPDATES);

    conf.addListConfig(updatesConfig);

    ListConfig availableWorkersConfig = new ListConfig();
    availableWorkersConfig.setName(AVAILABLE_WORKERS);
    conf.addListConfig(availableWorkersConfig);

    MapConfig heartbeatConfig = new MapConfig();
    heartbeatConfig.setName(HEART_BEAT);
    conf.addMapConfig(heartbeatConfig);

    MapConfig workerEnabledConifg = new MapConfig();
    workerEnabledConifg.setName(WORKER_ENABLED);
    conf.addMapConfig(workerEnabledConifg);

    return conf;
  }
 @Test(expected = RuntimeException.class, timeout = 120000)
 public void testFailingSocketInterceptor() {
   Config config = new Config();
   config.setProperty(GroupProperties.PROP_MAX_JOIN_SECONDS, "3");
   SocketInterceptorConfig sic = new SocketInterceptorConfig();
   MySocketInterceptor mySocketInterceptor = new MySocketInterceptor(false);
   sic.setImplementation(mySocketInterceptor);
   config.getNetworkConfig().setSocketInterceptorConfig(sic);
   HazelcastInstance h1 = Hazelcast.newHazelcastInstance(config);
   HazelcastInstance h2 = Hazelcast.newHazelcastInstance(config);
 }
Пример #19
0
  @Test(expected = IllegalArgumentException.class)
  public void testLockFail_whenGreaterThanMaxLeaseTimeUsed() {
    Config config = new Config();
    config.setProperty(GroupProperties.PROP_LOCK_MAX_LEASE_TIME_SECONDS, "1");

    factory.newHazelcastInstance(config);

    HazelcastInstance hz = factory.newHazelcastClient();
    ILock lock = hz.getLock(randomName());

    lock.lock(10, TimeUnit.SECONDS);
  }
  @Before
  public void setup() throws Exception {
    loggingService =
        new LoggingServiceImpl("foo", "jdk", new BuildInfo("1", "1", "1", 1, false, (byte) 1));

    serializationService = new DefaultSerializationServiceBuilder().build();
    config = new Config();
    config.setProperty(GroupProperty.PARTITION_COUNT, "10");
    config.setProperty(GroupProperty.PARTITION_OPERATION_THREAD_COUNT, "10");
    config.setProperty(GroupProperty.GENERIC_OPERATION_THREAD_COUNT, "10");
    thisAddress = new Address("localhost", 5701);
    threadGroup =
        new HazelcastThreadGroup(
            "foo",
            loggingService.getLogger(HazelcastThreadGroup.class),
            Thread.currentThread().getContextClassLoader());
    nodeExtension = new DefaultNodeExtension();
    handlerFactory = new DummyOperationRunnerFactory();

    metricsRegistry = new MetricsRegistryImpl(Logger.getLogger(MetricsRegistry.class), INFO);
    responsePacketHandler = new DummyResponsePacketHandler();
  }
  @BeforeClass
  public static void setUp() {
    Config config = new Config();
    config.setProperty("hazelcast.partition.count", "" + PARTITION_COUNT);

    instance = Hazelcast.newHazelcastInstance(config);
    HazelcastInstance remoteInstance = Hazelcast.newHazelcastInstance(config);
    warmUpPartitions(instance, remoteInstance);

    ClientConfig clientconfig = new ClientConfig();
    clientconfig.setProperty("hazelcast.partition.count", "" + PARTITION_COUNT);

    client = HazelcastClient.newHazelcastClient(clientconfig);
  }
  @Test
  public void testNodeConstructor() {
    Config config = new Config();
    config.setProperty(GroupProperties.PROP_MC_MAX_VISIBLE_SLOW_OPERATION_COUNT, "139");

    HazelcastInstance hazelcastInstance = createHazelcastInstance(config);
    Node node = getNode(hazelcastInstance);
    LocalOperationStatsImpl localOperationStats = new LocalOperationStatsImpl(node);

    assertEquals(139, localOperationStats.getMaxVisibleSlowOperationCount());
    assertEquals(0, localOperationStats.getSlowOperations().size());
    assertTrue(localOperationStats.getCreationTime() > 0);
    assertNotNull(localOperationStats.toString());
  }
  private static Config createConfig(String licenceKey) {
    Config config = new Config();
    config.setLicenseKey(licenceKey);
    config.setProperty("hazelcast.wait.seconds.before.join", "0");
    SecurityInterceptorConfig securityInterceptorConfig = new SecurityInterceptorConfig();
    securityInterceptorConfig.setClassName(MySecurityInterceptor.class.getName());
    SecurityConfig securityConfig = config.getSecurityConfig();
    securityConfig.setEnabled(true).addSecurityInterceptorConfig(securityInterceptorConfig);

    // when you enable security all client requests are denied, so we need to give permission first
    // security-interceptor will be run after checking this permission
    PermissionConfig permissionConfig =
        new PermissionConfig(PermissionConfig.PermissionType.ALL, "", null);
    securityConfig.addClientPermissionConfig(permissionConfig);
    return config;
  }
Пример #24
0
 private static Config buildConfig(boolean multicastEnabled) {
   Config c = new Config();
   c.getGroupConfig().setName("group").setPassword("pass");
   c.setProperty(GroupProperties.PROP_MERGE_FIRST_RUN_DELAY_SECONDS, "10");
   c.setProperty(GroupProperties.PROP_MERGE_NEXT_RUN_DELAY_SECONDS, "5");
   c.setProperty(GroupProperties.PROP_MAX_NO_HEARTBEAT_SECONDS, "10");
   c.setProperty(GroupProperties.PROP_MASTER_CONFIRMATION_INTERVAL_SECONDS, "2");
   c.setProperty(GroupProperties.PROP_MAX_NO_MASTER_CONFIRMATION_SECONDS, "10");
   c.setProperty(GroupProperties.PROP_MEMBER_LIST_PUBLISH_INTERVAL_SECONDS, "10");
   final NetworkConfig networkConfig = c.getNetworkConfig();
   networkConfig.getJoin().getMulticastConfig().setEnabled(multicastEnabled);
   networkConfig.getJoin().getTcpIpConfig().setEnabled(!multicastEnabled);
   networkConfig.setPortAutoIncrement(false);
   return c;
 }
  @Test(timeout = 120000)
  public void testOneMemberWriteThroughWithLRU() throws Exception {
    final int size = 10000;
    TestMapStore testMapStore = new TestMapStore(size * 2, 1, 1);
    testMapStore.setLoadAllKeys(false);
    Config config = newConfig(testMapStore, 0);
    config.setProperty(GroupProperty.PARTITION_COUNT, "1");
    MaxSizeConfig maxSizeConfig = new MaxSizeConfig();
    maxSizeConfig.setSize(size);
    MapConfig mapConfig = config.getMapConfig("default");
    mapConfig.setEvictionPolicy(EvictionPolicy.LRU);
    mapConfig.setMaxSizeConfig(maxSizeConfig);
    mapConfig.setMinEvictionCheckMillis(0);
    TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory(3);

    HazelcastInstance h1 = nodeFactory.newHazelcastInstance(config);
    IMap map = h1.getMap("default");
    final CountDownLatch countDownLatch = new CountDownLatch(size);
    map.addEntryListener(
        new EntryAdapter() {
          @Override
          public void entryEvicted(EntryEvent event) {
            countDownLatch.countDown();
          }
        },
        false);

    for (int i = 0; i < size * 2; i++) {
      // trigger eviction.
      if (i == (size * 2) - 1 || i == size) {
        sleepMillis(1001);
      }
      map.put(i, new Employee("joe", i, true, 100.00));
    }
    assertEquals(testMapStore.getStore().size(), size * 2);
    assertOpenEventually(countDownLatch);
    final String msgFailure = String.format("map size: %d put count: %d", map.size(), size);
    assertTrue(msgFailure, map.size() > size / 2);
    assertTrue(msgFailure, map.size() <= size);
    assertEquals(testMapStore.getStore().size(), size * 2);
  }
Пример #26
0
  @Test
  public void testWaitingInfinitelyForTryLock() throws InterruptedException {
    final Config config = new Config();
    config.setProperty(GroupProperties.PROP_OPERATION_CALL_TIMEOUT_MILLIS, "2000");
    final HazelcastInstance hz = createHazelcastInstance(config);
    final CountDownLatch latch = new CountDownLatch(1);

    hz.getLock("testWaitingInfinitelyForTryLock").lock();

    new Thread() {
      public void run() {
        try {
          hz.getLock("testWaitingInfinitelyForTryLock").tryLock(5, TimeUnit.SECONDS);
          latch.countDown();
        } catch (Exception ignored) {
        }
      }
    }.start();

    assertTrue(latch.await(15, TimeUnit.SECONDS));
  }
  @Test
  public void testMapConfigUpdate_reflectedToRecordStore()
      throws ExecutionException, InterruptedException {
    String mapName = randomMapName();

    Config config = getConfig();
    config.setProperty(GroupProperty.PARTITION_COUNT.getName(), "1");

    HazelcastInstance node = createHazelcastInstance(config);

    IMap<Integer, Integer> map = node.getMap(mapName);
    map.put(1, 1); // trigger recordStore creation.

    boolean beforeUpdate = isRecordStoreExpirable(map) && isEvictionEnabled(map);
    updateMapConfig(mapName, node);
    boolean afterUpdate = isRecordStoreExpirable(map) && isEvictionEnabled(map);

    assertFalse(
        "Before MapConfig update, RecordStore should not be expirable and evictable", beforeUpdate);
    assertTrue("RecordStore should be expirable and evictable after MapConfig update", afterUpdate);
  }
Пример #28
0
  @Test
  public void testMaxLockLeaseTime() {
    Config config = new Config();
    config.setProperty(GroupProperties.PROP_LOCK_MAX_LEASE_TIME_SECONDS, "1");

    factory.newHazelcastInstance(config);

    HazelcastInstance hz = factory.newHazelcastClient();
    final ILock lock = hz.getLock(randomName());

    lock.lock();

    assertTrueEventually(
        new AssertTask() {
          @Override
          public void run() throws Exception {
            assertFalse("Lock should be released after lease expires!", lock.isLocked());
          }
        },
        30);
  }
 private BasicBackPressureService newDisabledBackPressureService() {
   Config config = new Config();
   config.setProperty(GroupProperties.PROP_BACKPRESSURE_ENABLED, "false");
   GroupProperties groupProperties = new GroupProperties(config);
   return new BasicBackPressureService(groupProperties, logger);
 }
 private Config newConfig() {
   Config config = new Config();
   config.setProperty(GroupProperties.PROP_MERGE_FIRST_RUN_DELAY_SECONDS, "30");
   config.setProperty(GroupProperties.PROP_MERGE_NEXT_RUN_DELAY_SECONDS, "3");
   return config;
 }