Search in sources :

Example 6 with CALLER_RUNS

use of com.hazelcast.internal.util.ConcurrencyUtil.CALLER_RUNS in project hazelcast by hazelcast.

the class CacheAddPartitionLostListenerMessageTask method processInternal.

@Override
protected CompletableFuture<UUID> processInternal() {
    CachePartitionLostListener listener = event -> {
        if (endpoint.isAlive()) {
            ClientMessage eventMessage = CacheAddPartitionLostListenerCodec.encodeCachePartitionLostEvent(event.getPartitionId(), event.getMember().getUuid());
            sendClientMessage(null, eventMessage);
        }
    };
    InternalCachePartitionLostListenerAdapter listenerAdapter = new InternalCachePartitionLostListenerAdapter(listener);
    EventFilter filter = new CachePartitionLostEventFilter();
    CacheService service = getService(CacheService.SERVICE_NAME);
    EventService eventService = service.getNodeEngine().getEventService();
    if (parameters.localOnly) {
        return newCompletedFuture(eventService.registerLocalListener(ICacheService.SERVICE_NAME, parameters.name, filter, listenerAdapter).getId());
    }
    return eventService.registerListenerAsync(ICacheService.SERVICE_NAME, parameters.name, filter, listenerAdapter).thenApplyAsync(EventRegistration::getId, CALLER_RUNS);
}
Also used : CALLER_RUNS(com.hazelcast.internal.util.ConcurrencyUtil.CALLER_RUNS) InternalCompletableFuture.newCompletedFuture(com.hazelcast.spi.impl.InternalCompletableFuture.newCompletedFuture) Connection(com.hazelcast.internal.nio.Connection) CachePartitionLostEventFilter(com.hazelcast.cache.impl.event.CachePartitionLostEventFilter) EventService(com.hazelcast.spi.impl.eventservice.EventService) InternalCachePartitionLostListenerAdapter(com.hazelcast.cache.impl.event.InternalCachePartitionLostListenerAdapter) CompletableFuture(java.util.concurrent.CompletableFuture) EventFilter(com.hazelcast.spi.impl.eventservice.EventFilter) EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) UUID(java.util.UUID) Node(com.hazelcast.instance.impl.Node) AbstractAddListenerMessageTask(com.hazelcast.client.impl.protocol.task.AbstractAddListenerMessageTask) CachePartitionLostListener(com.hazelcast.cache.impl.event.CachePartitionLostListener) CacheService(com.hazelcast.cache.impl.CacheService) ICacheService(com.hazelcast.cache.impl.ICacheService) Permission(java.security.Permission) CacheAddPartitionLostListenerCodec(com.hazelcast.client.impl.protocol.codec.CacheAddPartitionLostListenerCodec) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) CachePartitionLostListener(com.hazelcast.cache.impl.event.CachePartitionLostListener) EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) EventService(com.hazelcast.spi.impl.eventservice.EventService) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) CachePartitionLostEventFilter(com.hazelcast.cache.impl.event.CachePartitionLostEventFilter) CachePartitionLostEventFilter(com.hazelcast.cache.impl.event.CachePartitionLostEventFilter) EventFilter(com.hazelcast.spi.impl.eventservice.EventFilter) InternalCachePartitionLostListenerAdapter(com.hazelcast.cache.impl.event.InternalCachePartitionLostListenerAdapter) CacheService(com.hazelcast.cache.impl.CacheService) ICacheService(com.hazelcast.cache.impl.ICacheService)

Example 7 with CALLER_RUNS

use of com.hazelcast.internal.util.ConcurrencyUtil.CALLER_RUNS 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 8 with CALLER_RUNS

use of com.hazelcast.internal.util.ConcurrencyUtil.CALLER_RUNS in project hazelcast by hazelcast.

the class PromoteLiteMemberOperation method run.

@Override
public void run() throws Exception {
    ILogger logger = getNodeEngine().getLogger(getClass());
    ExecutionService executionService = getNodeEngine().getExecutionService();
    Future<Void> future = executionService.submit(ExecutionService.ASYNC_EXECUTOR, () -> {
        getNodeEngine().getHazelcastInstance().getCluster().promoteLocalLiteMember();
        return null;
    });
    executionService.asCompletableFuture(future).whenCompleteAsync(withTryCatch(logger, (empty, error) -> sendResponse(error != null ? peel(error) : null)), CALLER_RUNS);
}
Also used : AbstractLocalOperation(com.hazelcast.spi.impl.operationservice.AbstractLocalOperation) CALLER_RUNS(com.hazelcast.internal.util.ConcurrencyUtil.CALLER_RUNS) ManagementCenterService(com.hazelcast.internal.management.ManagementCenterService) Future(java.util.concurrent.Future) ILogger(com.hazelcast.logging.ILogger) ExceptionUtil.peel(com.hazelcast.internal.util.ExceptionUtil.peel) ExceptionUtil.withTryCatch(com.hazelcast.internal.util.ExceptionUtil.withTryCatch) ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService) ILogger(com.hazelcast.logging.ILogger) ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService)

Example 9 with CALLER_RUNS

use of com.hazelcast.internal.util.ConcurrencyUtil.CALLER_RUNS in project hazelcast by hazelcast.

the class ReadMetricsOperation method run.

@Override
public void run() {
    ILogger logger = getNodeEngine().getLogger(getClass());
    MetricsService service = getService();
    CompletableFuture<RingbufferSlice<Entry<Long, byte[]>>> future = service.readMetrics(offset);
    future.whenCompleteAsync(withTryCatch(logger, (slice, error) -> doSendResponse(error != null ? peel(error) : slice)), CALLER_RUNS);
}
Also used : CALLER_RUNS(com.hazelcast.internal.util.ConcurrencyUtil.CALLER_RUNS) IdentifiedDataSerializable(com.hazelcast.nio.serialization.IdentifiedDataSerializable) ExceptionUtil.peel(com.hazelcast.internal.util.ExceptionUtil.peel) IOException(java.io.IOException) CompletableFuture(java.util.concurrent.CompletableFuture) MetricsService(com.hazelcast.internal.metrics.impl.MetricsService) ILogger(com.hazelcast.logging.ILogger) Operation(com.hazelcast.spi.impl.operationservice.Operation) ReadonlyOperation(com.hazelcast.spi.impl.operationservice.ReadonlyOperation) Entry(java.util.Map.Entry) ExceptionUtil.withTryCatch(com.hazelcast.internal.util.ExceptionUtil.withTryCatch) RingbufferSlice(com.hazelcast.internal.metrics.managementcenter.ConcurrentArrayRingbuffer.RingbufferSlice) ObjectDataOutput(com.hazelcast.nio.ObjectDataOutput) ObjectDataInput(com.hazelcast.nio.ObjectDataInput) RingbufferSlice(com.hazelcast.internal.metrics.managementcenter.ConcurrentArrayRingbuffer.RingbufferSlice) MetricsService(com.hazelcast.internal.metrics.impl.MetricsService) ILogger(com.hazelcast.logging.ILogger)

Aggregations

CALLER_RUNS (com.hazelcast.internal.util.ConcurrencyUtil.CALLER_RUNS)9 ExceptionUtil.peel (com.hazelcast.internal.util.ExceptionUtil.peel)8 ExceptionUtil.withTryCatch (com.hazelcast.internal.util.ExceptionUtil.withTryCatch)8 ILogger (com.hazelcast.logging.ILogger)8 ManagementCenterService (com.hazelcast.internal.management.ManagementCenterService)7 ExecutionService (com.hazelcast.spi.impl.executionservice.ExecutionService)7 Future (java.util.concurrent.Future)7 AbstractLocalOperation (com.hazelcast.spi.impl.operationservice.AbstractLocalOperation)4 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)3 Node (com.hazelcast.instance.impl.Node)3 Connection (com.hazelcast.internal.nio.Connection)3 Permission (java.security.Permission)3 AbstractCallableMessageTask (com.hazelcast.client.impl.protocol.task.AbstractCallableMessageTask)2 ManagementCenterConfig (com.hazelcast.config.ManagementCenterConfig)2 HazelcastException (com.hazelcast.core.HazelcastException)2 ObjectDataInput (com.hazelcast.nio.ObjectDataInput)2 ObjectDataOutput (com.hazelcast.nio.ObjectDataOutput)2 ManagementPermission (com.hazelcast.security.permission.ManagementPermission)2 IOException (java.io.IOException)2 AccessControlException (java.security.AccessControlException)2