Search in sources :

Example 41 with OperationService

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

the class RingbufferProxy method addAllAsync.

@Override
public ICompletableFuture<Long> addAllAsync(Collection<? extends E> collection, OverflowPolicy overflowPolicy) {
    checkNotNull(collection, "collection can't be null");
    checkNotNull(overflowPolicy, "overflowPolicy can't be null");
    checkFalse(collection.isEmpty(), "collection can't be empty");
    checkTrue(collection.size() <= MAX_BATCH_SIZE, "collection can't be larger than " + MAX_BATCH_SIZE);
    Operation op = new AddAllOperation(name, toDataArray(collection), overflowPolicy).setPartitionId(partitionId);
    OperationService operationService = getOperationService();
    return operationService.createInvocationBuilder(null, op, partitionId).setCallTimeout(Long.MAX_VALUE).invoke();
}
Also used : AddAllOperation(com.hazelcast.ringbuffer.impl.operations.AddAllOperation) AddAllOperation(com.hazelcast.ringbuffer.impl.operations.AddAllOperation) GenericOperation(com.hazelcast.ringbuffer.impl.operations.GenericOperation) ReadOneOperation(com.hazelcast.ringbuffer.impl.operations.ReadOneOperation) ReadManyOperation(com.hazelcast.ringbuffer.impl.operations.ReadManyOperation) AddOperation(com.hazelcast.ringbuffer.impl.operations.AddOperation) Operation(com.hazelcast.spi.Operation) OperationService(com.hazelcast.spi.OperationService)

Example 42 with OperationService

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

the class RequestMapDataOperation method run.

@Override
public void run() throws Exception {
    ILogger logger = getLogger();
    int partitionId = getPartitionId();
    Address callerAddress = getCallerAddress();
    if (logger.isFineEnabled()) {
        logger.fine("Caller { " + callerAddress + " } requested copy of map: " + name + " partitionId=" + partitionId);
    }
    ReplicatedMapService service = getService();
    PartitionContainer container = service.getPartitionContainer(partitionId);
    ReplicatedRecordStore store = container.getOrCreateRecordStore(name);
    store.setLoaded(true);
    if (getNodeEngine().getThisAddress().equals(callerAddress)) {
        return;
    }
    long version = store.getVersion();
    Set<RecordMigrationInfo> recordSet = getRecordSet(store);
    SyncReplicatedMapDataOperation op = new SyncReplicatedMapDataOperation(name, recordSet, version);
    op.setPartitionId(partitionId);
    op.setValidateTarget(false);
    OperationService operationService = getNodeEngine().getOperationService();
    operationService.createInvocationBuilder(SERVICE_NAME, op, callerAddress).setTryCount(INVOCATION_TRY_COUNT).invoke();
}
Also used : Address(com.hazelcast.nio.Address) PartitionContainer(com.hazelcast.replicatedmap.impl.PartitionContainer) ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) ILogger(com.hazelcast.logging.ILogger) OperationService(com.hazelcast.spi.OperationService) RecordMigrationInfo(com.hazelcast.replicatedmap.impl.record.RecordMigrationInfo)

Example 43 with OperationService

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

the class ReplicatedMapProxy method clear.

@Override
public void clear() {
    OperationService operationService = nodeEngine.getOperationService();
    try {
        Map<Integer, Object> results = operationService.invokeOnAllPartitions(SERVICE_NAME, new ClearOperationFactory(name));
        int deletedEntrySize = 0;
        for (Object deletedEntryPerPartition : results.values()) {
            deletedEntrySize += (Integer) deletedEntryPerPartition;
        }
        ReplicatedMapEventPublishingService eventPublishingService = service.getEventPublishingService();
        eventPublishingService.fireMapClearedEvent(deletedEntrySize, name);
    } catch (Throwable t) {
        throw rethrow(t);
    }
}
Also used : AbstractDistributedObject(com.hazelcast.spi.AbstractDistributedObject) InitializingObject(com.hazelcast.spi.InitializingObject) OperationService(com.hazelcast.spi.OperationService) ClearOperationFactory(com.hazelcast.replicatedmap.impl.operation.ClearOperationFactory)

Example 44 with OperationService

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

the class ReplicatedMapProxy method requestDataForPartition.

private void requestDataForPartition(int partitionId) {
    RequestMapDataOperation requestMapDataOperation = new RequestMapDataOperation(name);
    OperationService operationService = nodeEngine.getOperationService();
    operationService.createInvocationBuilder(SERVICE_NAME, requestMapDataOperation, partitionId).setTryCount(ReplicatedMapService.INVOCATION_TRY_COUNT).invoke();
}
Also used : RequestMapDataOperation(com.hazelcast.replicatedmap.impl.operation.RequestMapDataOperation) OperationService(com.hazelcast.spi.OperationService)

Example 45 with OperationService

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

the class CheckReplicaVersionOperation method requestDataFromOwner.

private void requestDataFromOwner(String name) {
    OperationService operationService = getNodeEngine().getOperationService();
    RequestMapDataOperation requestMapDataOperation = new RequestMapDataOperation(name);
    operationService.createInvocationBuilder(SERVICE_NAME, requestMapDataOperation, getPartitionId()).setTryCount(INVOCATION_TRY_COUNT).invoke();
}
Also used : OperationService(com.hazelcast.spi.OperationService)

Aggregations

OperationService (com.hazelcast.spi.OperationService)135 Test (org.junit.Test)49 QuickTest (com.hazelcast.test.annotation.QuickTest)48 ParallelTest (com.hazelcast.test.annotation.ParallelTest)46 HazelcastInstance (com.hazelcast.core.HazelcastInstance)45 Operation (com.hazelcast.spi.Operation)39 NodeEngine (com.hazelcast.spi.NodeEngine)30 Address (com.hazelcast.nio.Address)26 Future (java.util.concurrent.Future)26 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)24 Config (com.hazelcast.config.Config)21 InternalCompletableFuture (com.hazelcast.spi.InternalCompletableFuture)21 Member (com.hazelcast.core.Member)19 Data (com.hazelcast.nio.serialization.Data)14 ArrayList (java.util.ArrayList)11 Node (com.hazelcast.instance.Node)7 InternalOperationService (com.hazelcast.spi.impl.operationservice.InternalOperationService)7 ExecutionException (java.util.concurrent.ExecutionException)7 TimeoutException (java.util.concurrent.TimeoutException)7 OperationTimeoutException (com.hazelcast.core.OperationTimeoutException)6