Java Code Examples for org.ehcache.clustered.server.EhcacheStateServiceImpl

Following code examples demonstrate how to use org.ehcache.clustered.server.EhcacheStateServiceImpl from ehcache. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.ehcache.clustered.server.EhcacheStateServiceImpl and various code implementation of this class.
Example 1
Project : ehcache Source File : EhcacheStateServiceProvider.java View Source Code on GitHub

      if (configuration instanceof EhcacheStateServiceConfig) {
        EhcacheStateServiceConfig stateServiceConfig = (EhcacheStateServiceConfig) configuration;
        EhcacheStateServiceImpl storeManagerService = new EhcacheStateServiceImpl(
          offHeapResourcesProvider, stateServiceConfig.getConfig().getConfiguration(), stateServiceConfig.getMapper(),
          service -> serviceMap.remove(stateServiceConfig.getConfig().getIdentifier(), service));
        result = serviceMap.putIfAbsent(stateServiceConfig.getConfig().getIdentifier(), storeManagerService);
        if (result == null) {
          result = storeManagerService;
        }
      } else if (configuration instanceof EhcacheStoreStateServiceConfig) {
        EhcacheStoreStateServiceConfig storeStateServiceConfig = (EhcacheStoreStateServiceConfig) configuration;
        result = serviceMap.get(storeStateServiceConfig.getManagerIdentifier());
      } else {
        throw new IllegalArgumentException("Unexpected configuration type: " + configuration);
      }
			
Example 2
Project : ehcache Source File : ClusterTierActiveEntityTest.java View Source Code on GitHub

  public void testLoadExistingRecoversInflightInvalidationsForEventualCache() throws Exception {
    ClusterTierActiveEntity activeEntity = new ClusterTierActiveEntity(defaultRegistry, defaultConfiguration, DEFAULT_MAPPER);
    EhcacheStateServiceImpl ehcacheStateService = defaultRegistry.getStoreManagerService();

    InvalidationTracker invalidationTracker = ehcacheStateService.getInvalidationTracker(defaultStoreName);

    Random random = new Random();
    random.ints(0, 100).limit(10).forEach(invalidationTracker::trackHashInvalidation);

    activeEntity.loadExisting();

    assertThat(activeEntity.getInflightInvalidations().isEmpty(), is(false));
  }
			
Example 3
Project : ehcache Source File : ClusterTierActiveEntityTest.java View Source Code on GitHub

  public void testActiveMessageTracking() throws Exception {
    ClusterTierActiveEntity activeEntity = new ClusterTierActiveEntity(defaultRegistry, defaultConfiguration, DEFAULT_MAPPER);
    EhcacheStateServiceImpl ehcacheStateService = defaultRegistry.getStoreManagerService();

    TestInvokeContext context = new TestInvokeContext();
    activeEntity.connected(context.getClientDescriptor());

    assertSuccess(activeEntity.invokeActive(context, new LifecycleMessage.ValidateServerStore(defaultStoreName, defaultStoreConfiguration)));

    context.incrementCurrentTransactionId();

    ServerStoreOpMessage.AppendMessage message = new ServerStoreOpMessage.AppendMessage(1L, createPayload(1L));
    EhcacheEntityResponse expected = activeEntity.invokeActive(context, message);

    message = new ServerStoreOpMessage.AppendMessage(1L, createPayload(1L));

    assertThat(actual, sameInstance(expected));
  }