Search in sources :

Example 1 with CacheCreateConfigOperation

use of com.hazelcast.cache.impl.operation.CacheCreateConfigOperation in project hazelcast by hazelcast.

the class HazelcastServerCacheManager method createCacheConfig.

@Override
protected <K, V> CacheConfig<K, V> createCacheConfig(String cacheName, CacheConfig<K, V> config, boolean createAlsoOnOthers, boolean syncCreate) {
    CacheConfig<K, V> currentCacheConfig = cacheService.getCacheConfig(cacheName);
    OperationService operationService = nodeEngine.getOperationService();
    // Create cache config on all nodes.
    CacheCreateConfigOperation op = new CacheCreateConfigOperation(config, createAlsoOnOthers);
    // Run "CacheCreateConfigOperation" on this node. Its itself handles interaction with other nodes.
    // This operation doesn't block operation thread even "syncCreate" is specified.
    // In that case, scheduled thread is used, not operation thread.
    InternalCompletableFuture future = operationService.invokeOnTarget(CacheService.SERVICE_NAME, op, nodeEngine.getThisAddress());
    if (syncCreate) {
        return (CacheConfig<K, V>) future.join();
    } else {
        return currentCacheConfig;
    }
}
Also used : CacheCreateConfigOperation(com.hazelcast.cache.impl.operation.CacheCreateConfigOperation) InternalCompletableFuture(com.hazelcast.spi.InternalCompletableFuture) OperationService(com.hazelcast.spi.OperationService) CacheConfig(com.hazelcast.config.CacheConfig)

Aggregations

CacheCreateConfigOperation (com.hazelcast.cache.impl.operation.CacheCreateConfigOperation)1 CacheConfig (com.hazelcast.config.CacheConfig)1 InternalCompletableFuture (com.hazelcast.spi.InternalCompletableFuture)1 OperationService (com.hazelcast.spi.OperationService)1