Search in sources :

Example 31 with ExecutionService

use of com.hazelcast.spi.impl.executionservice.ExecutionService in project hazelcast by hazelcast.

the class PartitionContainer method createRecordStore.

private RecordStore createRecordStore(String name) {
    MapServiceContext serviceContext = mapService.getMapServiceContext();
    MapContainer mapContainer = serviceContext.getMapContainer(name);
    MapConfig mapConfig = mapContainer.getMapConfig();
    NodeEngine nodeEngine = serviceContext.getNodeEngine();
    IPartitionService ps = nodeEngine.getPartitionService();
    OperationService opService = nodeEngine.getOperationService();
    ExecutionService execService = nodeEngine.getExecutionService();
    HazelcastProperties hazelcastProperties = nodeEngine.getProperties();
    MapKeyLoader keyLoader = new MapKeyLoader(name, opService, ps, nodeEngine.getClusterService(), execService, mapContainer.toData(), serviceContext.getNodeWideLoadedKeyLimiter());
    keyLoader.setMaxBatch(hazelcastProperties.getInteger(ClusterProperty.MAP_LOAD_CHUNK_SIZE));
    keyLoader.setMaxSize(getMaxSizePerNode(mapConfig.getEvictionConfig()));
    keyLoader.setHasBackup(mapConfig.getTotalBackupCount() > 0);
    keyLoader.setMapOperationProvider(serviceContext.getMapOperationProvider(name));
    if (!mapContainer.isGlobalIndexEnabled()) {
        Indexes indexesForMap = mapContainer.createIndexes(false);
        indexes.putIfAbsent(name, indexesForMap);
    }
    RecordStore recordStore = serviceContext.createRecordStore(mapContainer, partitionId, keyLoader);
    recordStore.init();
    return recordStore;
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) IPartitionService(com.hazelcast.internal.partition.IPartitionService) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) MapConfig(com.hazelcast.config.MapConfig) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService) Indexes(com.hazelcast.query.impl.Indexes)

Example 32 with ExecutionService

use of com.hazelcast.spi.impl.executionservice.ExecutionService in project hazelcast by hazelcast.

the class SplitBrainProtectionServiceImpl method start.

public void start() {
    // before starting, no splitBrainProtections are used, just SplitBrainProtectionService dependency is
    // provided to services which depend on it so it's safe to initialize splitBrainProtections here (and we have
    // ClusterService already constructed)
    this.splitBrainProtections = Collections.unmodifiableMap(initializeSplitBrainProtections());
    scanSplitBrainProtections();
    initializeListeners();
    if (isInactive()) {
        return;
    }
    ExecutionService executionService = nodeEngine.getExecutionService();
    // single thread split brain protection executor
    executionService.register(SPLIT_BRAIN_PROTECTION_EXECUTOR, 1, Integer.MAX_VALUE, ExecutorType.CACHED);
    long heartbeatInterval = nodeEngine.getProperties().getSeconds(ClusterProperty.HEARTBEAT_INTERVAL_SECONDS);
    executionService.scheduleWithRepetition(SPLIT_BRAIN_PROTECTION_EXECUTOR, new UpdateSplitBrainProtections(), heartbeatInterval, heartbeatInterval, TimeUnit.SECONDS);
}
Also used : ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService)

Example 33 with ExecutionService

use of com.hazelcast.spi.impl.executionservice.ExecutionService in project hazelcast by hazelcast.

the class ShutdownClusterMessageTask method call.

@Override
protected Object call() throws Exception {
    ILogger logger = nodeEngine.getLogger(getClass());
    ExecutionService executionService = nodeEngine.getExecutionService();
    Future<Void> future = executionService.submit(ExecutionService.ASYNC_EXECUTOR, () -> {
        nodeEngine.getClusterService().shutdown();
        return null;
    });
    executionService.asCompletableFuture(future).whenCompleteAsync(withTryCatch(logger, (empty, error) -> sendResponse(error != null ? peel(error) : null)), CALLER_RUNS);
    return null;
}
Also used : CALLER_RUNS(com.hazelcast.internal.util.ConcurrencyUtil.CALLER_RUNS) ManagementCenterService(com.hazelcast.internal.management.ManagementCenterService) ManagementPermission(com.hazelcast.security.permission.ManagementPermission) Connection(com.hazelcast.internal.nio.Connection) ExceptionUtil.peel(com.hazelcast.internal.util.ExceptionUtil.peel) ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService) Node(com.hazelcast.instance.impl.Node) Future(java.util.concurrent.Future) AbstractCallableMessageTask(com.hazelcast.client.impl.protocol.task.AbstractCallableMessageTask) ILogger(com.hazelcast.logging.ILogger) Permission(java.security.Permission) ExceptionUtil.withTryCatch(com.hazelcast.internal.util.ExceptionUtil.withTryCatch) MCShutdownClusterCodec(com.hazelcast.client.impl.protocol.codec.MCShutdownClusterCodec) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) ILogger(com.hazelcast.logging.ILogger) ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService)

Example 34 with ExecutionService

use of com.hazelcast.spi.impl.executionservice.ExecutionService in project hazelcast by hazelcast.

the class RaftGroupMembershipManager method init.

void init() {
    if (raftService.getLocalCPMember() == null || !initialized.compareAndSet(false, true)) {
        return;
    }
    ExecutionService executionService = nodeEngine.getExecutionService();
    // scheduleWithRepetition skips subsequent execution if one is already running.
    executionService.scheduleWithRepetition(CP_SUBSYSTEM_MANAGEMENT_EXECUTOR, new RaftGroupDestroyHandlerTask(), MANAGEMENT_TASK_PERIOD_IN_MILLIS, MANAGEMENT_TASK_PERIOD_IN_MILLIS, MILLISECONDS);
    executionService.scheduleWithRepetition(CP_SUBSYSTEM_MANAGEMENT_EXECUTOR, new RaftGroupMembershipChangeHandlerTask(), MANAGEMENT_TASK_PERIOD_IN_MILLIS, MANAGEMENT_TASK_PERIOD_IN_MILLIS, MILLISECONDS);
    executionService.scheduleWithRepetition(CP_SUBSYSTEM_MANAGEMENT_EXECUTOR, new CheckLocalRaftNodesTask(), CHECK_LOCAL_RAFT_NODES_TASK_PERIOD, CHECK_LOCAL_RAFT_NODES_TASK_PERIOD, SECONDS);
    int leadershipRebalancePeriod = nodeEngine.getProperties().getInteger(LEADERSHIP_BALANCE_TASK_PERIOD);
    executionService.scheduleWithRepetition(CP_SUBSYSTEM_MANAGEMENT_EXECUTOR, new RaftGroupLeadershipBalanceTask(), leadershipRebalancePeriod, leadershipRebalancePeriod, SECONDS);
}
Also used : ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService) RaftEndpoint(com.hazelcast.cp.internal.raft.impl.RaftEndpoint)

Example 35 with ExecutionService

use of com.hazelcast.spi.impl.executionservice.ExecutionService in project hazelcast by hazelcast.

the class RaftService method init.

@Override
public void init(NodeEngine nodeEngine, Properties properties) {
    if (!metadataGroupManager.init()) {
        return;
    }
    if (config.getMissingCPMemberAutoRemovalSeconds() > 0) {
        ExecutionService executionService = nodeEngine.getExecutionService();
        executionService.scheduleWithRepetition(CP_SUBSYSTEM_MANAGEMENT_EXECUTOR, new AutoRemoveMissingCPMemberTask(), REMOVE_MISSING_MEMBER_TASK_PERIOD_SECONDS, REMOVE_MISSING_MEMBER_TASK_PERIOD_SECONDS, SECONDS);
    }
    MetricsRegistry metricsRegistry = this.nodeEngine.getMetricsRegistry();
    metricsRegistry.scheduleAtFixedRate(new PublishNodeMetricsTask(), metricsPeriod, SECONDS, ProbeLevel.INFO);
}
Also used : MetricsRegistry(com.hazelcast.internal.metrics.MetricsRegistry) ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService)

Aggregations

ExecutionService (com.hazelcast.spi.impl.executionservice.ExecutionService)46 ILogger (com.hazelcast.logging.ILogger)10 ManagementCenterService (com.hazelcast.internal.management.ManagementCenterService)7 CALLER_RUNS (com.hazelcast.internal.util.ConcurrencyUtil.CALLER_RUNS)7 ExceptionUtil.peel (com.hazelcast.internal.util.ExceptionUtil.peel)7 ExceptionUtil.withTryCatch (com.hazelcast.internal.util.ExceptionUtil.withTryCatch)7 HazelcastProperties (com.hazelcast.spi.properties.HazelcastProperties)7 Future (java.util.concurrent.Future)7 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)6 QuickTest (com.hazelcast.test.annotation.QuickTest)6 Test (org.junit.Test)6 CountDownLatch (java.util.concurrent.CountDownLatch)5 IExecutorService (com.hazelcast.core.IExecutorService)4 AbstractLocalOperation (com.hazelcast.spi.impl.operationservice.AbstractLocalOperation)4 HazelcastInstance (com.hazelcast.core.HazelcastInstance)3 Node (com.hazelcast.instance.impl.Node)3 NodeEngine (com.hazelcast.spi.impl.NodeEngine)3 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)3 ExecutorService (java.util.concurrent.ExecutorService)3 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)2