Search in sources :

Example 11 with NodeEngine

use of com.hazelcast.spi.NodeEngine in project hazelcast by hazelcast.

the class QueueProxySupport method invoke.

private InternalCompletableFuture invoke(Operation operation) {
    final NodeEngine nodeEngine = getNodeEngine();
    OperationService operationService = nodeEngine.getOperationService();
    return operationService.invokeOnPartition(QueueService.SERVICE_NAME, operation, getPartitionId());
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) OperationService(com.hazelcast.spi.OperationService)

Example 12 with NodeEngine

use of com.hazelcast.spi.NodeEngine in project hazelcast by hazelcast.

the class QueueReplicationOperation method run.

@Override
public void run() {
    QueueService service = getService();
    NodeEngine nodeEngine = getNodeEngine();
    Config config = nodeEngine.getConfig();
    for (Map.Entry<String, QueueContainer> entry : migrationData.entrySet()) {
        String name = entry.getKey();
        QueueContainer container = entry.getValue();
        QueueConfig conf = config.findQueueConfig(name);
        container.setConfig(conf, nodeEngine, service);
        service.addContainer(name, container);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) QueueConfig(com.hazelcast.config.QueueConfig) Config(com.hazelcast.config.Config) QueueConfig(com.hazelcast.config.QueueConfig) QueueContainer(com.hazelcast.collection.impl.queue.QueueContainer) QueueService(com.hazelcast.collection.impl.queue.QueueService) HashMap(java.util.HashMap) Map(java.util.Map)

Example 13 with NodeEngine

use of com.hazelcast.spi.NodeEngine in project hazelcast by hazelcast.

the class CacheCreateConfigOperation method run.

@Override
public void run() throws Exception {
    ICacheService service = getService();
    if (!ignoreLocal) {
        response = service.putCacheConfigIfAbsent(config);
    }
    if (createAlsoOnOthers) {
        NodeEngine nodeEngine = getNodeEngine();
        Collection<Member> members = nodeEngine.getClusterService().getMembers();
        int remoteNodeCount = members.size() - 1;
        if (remoteNodeCount > 0) {
            postponeReturnResponse();
            ExecutionCallback<Object> callback = new CacheConfigCreateCallback(this, remoteNodeCount);
            OperationService operationService = nodeEngine.getOperationService();
            for (Member member : members) {
                if (!member.localMember()) {
                    CacheCreateConfigOperation op = new CacheCreateConfigOperation(config, false);
                    operationService.createInvocationBuilder(ICacheService.SERVICE_NAME, op, member.getAddress()).setExecutionCallback(callback).invoke();
                }
            }
        }
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) ICacheService(com.hazelcast.cache.impl.ICacheService) OperationService(com.hazelcast.spi.OperationService) Member(com.hazelcast.core.Member)

Example 14 with NodeEngine

use of com.hazelcast.spi.NodeEngine in project hazelcast by hazelcast.

the class CacheDestroyOperation method destroyCacheOnAllMembers.

private void destroyCacheOnAllMembers(String name, String callerUuid) {
    NodeEngine nodeEngine = getNodeEngine();
    OperationService operationService = nodeEngine.getOperationService();
    Collection<Member> members = nodeEngine.getClusterService().getMembers();
    for (Member member : members) {
        if (!member.localMember() && !member.getUuid().equals(callerUuid)) {
            CacheDestroyOperation op = new CacheDestroyOperation(name, true);
            operationService.invokeOnTarget(ICacheService.SERVICE_NAME, op, member.getAddress());
        }
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) OperationService(com.hazelcast.spi.OperationService) Member(com.hazelcast.core.Member)

Example 15 with NodeEngine

use of com.hazelcast.spi.NodeEngine in project hazelcast by hazelcast.

the class AbstractMapReduceTask method processMessage.

@Override
protected void processMessage() {
    MapReduceService mapReduceService = getService(MapReduceService.SERVICE_NAME);
    NodeEngine nodeEngine = mapReduceService.getNodeEngine();
    ClusterService clusterService = nodeEngine.getClusterService();
    if (clusterService.getSize(MemberSelectors.DATA_MEMBER_SELECTOR) == 0) {
        throw new IllegalStateException("Could not register map reduce job since there are no nodes owning a partition");
    }
    final String objectName = getDistributedObjectName();
    AbstractJobTracker jobTracker = (AbstractJobTracker) mapReduceService.createDistributedObject(objectName);
    TrackableJobFuture jobFuture = new TrackableJobFuture(objectName, getJobId(), jobTracker, nodeEngine, null);
    if (jobTracker.registerTrackableJob(jobFuture)) {
        startSupervisionTask(jobTracker);
        jobFuture.andThen(this);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) TrackableJobFuture(com.hazelcast.mapreduce.impl.task.TrackableJobFuture) ClusterService(com.hazelcast.internal.cluster.ClusterService) MapReduceService(com.hazelcast.mapreduce.impl.MapReduceService) AbstractJobTracker(com.hazelcast.mapreduce.impl.AbstractJobTracker)

Aggregations

NodeEngine (com.hazelcast.spi.NodeEngine)157 Data (com.hazelcast.nio.serialization.Data)50 OperationService (com.hazelcast.spi.OperationService)30 Address (com.hazelcast.nio.Address)20 ILogger (com.hazelcast.logging.ILogger)14 Operation (com.hazelcast.spi.Operation)14 Member (com.hazelcast.core.Member)12 Future (java.util.concurrent.Future)12 InternalCompletableFuture (com.hazelcast.spi.InternalCompletableFuture)11 IPartitionService (com.hazelcast.spi.partition.IPartitionService)11 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)10 Test (org.junit.Test)10 InitializingObject (com.hazelcast.spi.InitializingObject)9 ParallelTest (com.hazelcast.test.annotation.ParallelTest)9 QuickTest (com.hazelcast.test.annotation.QuickTest)9 AbstractDistributedObject (com.hazelcast.spi.AbstractDistributedObject)8 HazelcastInstance (com.hazelcast.core.HazelcastInstance)7 InternalPartitionServiceImpl (com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl)7 Config (com.hazelcast.config.Config)6 ArrayList (java.util.ArrayList)6