Search in sources :

Example 1 with MultiMapPutAllOperationFactory

use of com.hazelcast.multimap.impl.operations.MultiMapPutAllOperationFactory in project hazelcast by hazelcast.

the class MultiMapDataSerializerHook method createFactory.

public DataSerializableFactory createFactory() {
    ConstructorFunction<Integer, IdentifiedDataSerializable>[] constructors = new ConstructorFunction[PUT_ALL_PARTITION_AWARE_FACTORY + 1];
    constructors[CLEAR_BACKUP] = arg -> new ClearBackupOperation();
    constructors[CLEAR] = arg -> new ClearOperation();
    constructors[CONTAINS_ENTRY] = arg -> new ContainsEntryOperation();
    constructors[COUNT] = arg -> new CountOperation();
    constructors[ENTRY_SET] = arg -> new EntrySetOperation();
    constructors[GET_ALL] = arg -> new GetAllOperation();
    constructors[KEY_SET] = arg -> new KeySetOperation();
    constructors[PUT_BACKUP] = arg -> new PutBackupOperation();
    constructors[PUT] = arg -> new PutOperation();
    constructors[REMOVE_ALL_BACKUP] = arg -> new RemoveAllBackupOperation();
    constructors[REMOVE_ALL] = arg -> new RemoveAllOperation();
    constructors[REMOVE_BACKUP] = arg -> new RemoveBackupOperation();
    constructors[REMOVE] = arg -> new RemoveOperation();
    constructors[SIZE] = arg -> new SizeOperation();
    constructors[VALUES] = arg -> new ValuesOperation();
    constructors[TXN_COMMIT_BACKUP] = arg -> new TxnCommitBackupOperation();
    constructors[TXN_COMMIT] = arg -> new TxnCommitOperation();
    constructors[TXN_GENERATE_RECORD_ID] = arg -> new TxnGenerateRecordIdOperation();
    constructors[TXN_LOCK_AND_GET] = arg -> new TxnLockAndGetOperation();
    constructors[TXN_PREPARE_BACKUP] = arg -> new TxnPrepareBackupOperation();
    constructors[TXN_PREPARE] = arg -> new TxnPrepareOperation();
    constructors[TXN_PUT] = arg -> new TxnPutOperation();
    constructors[TXN_PUT_BACKUP] = arg -> new TxnPutBackupOperation();
    constructors[TXN_REMOVE] = arg -> new TxnRemoveOperation();
    constructors[TXN_REMOVE_BACKUP] = arg -> new TxnRemoveBackupOperation();
    constructors[TXN_REMOVE_ALL] = arg -> new TxnRemoveAllOperation();
    constructors[TXN_REMOVE_ALL_BACKUP] = arg -> new TxnRemoveAllBackupOperation();
    constructors[TXN_ROLLBACK_BACKUP] = arg -> new TxnRollbackBackupOperation();
    constructors[TXN_ROLLBACK] = arg -> new TxnRollbackOperation();
    constructors[MULTIMAP_OP_FACTORY] = arg -> new MultiMapOperationFactory();
    constructors[MULTIMAP_TRANSACTION_LOG_RECORD] = arg -> new MultiMapTransactionLogRecord();
    constructors[MULTIMAP_EVENT_FILTER] = arg -> new MultiMapEventFilter();
    constructors[MULTIMAP_RECORD] = arg -> new MultiMapRecord();
    constructors[MULTIMAP_REPLICATION_OPERATION] = arg -> new MultiMapReplicationOperation();
    constructors[MULTIMAP_RESPONSE] = arg -> new MultiMapResponse();
    constructors[ENTRY_SET_RESPONSE] = arg -> new EntrySetResponse();
    constructors[MERGE_CONTAINER] = arg -> new MultiMapMergeContainer();
    constructors[MERGE_OPERATION] = arg -> new MergeOperation();
    constructors[MERGE_BACKUP_OPERATION] = arg -> new MergeBackupOperation();
    constructors[DELETE] = arg -> new DeleteOperation();
    constructors[DELETE_BACKUP] = arg -> new DeleteBackupOperation();
    constructors[PUT_ALL] = arg -> new PutAllOperation();
    constructors[PUT_ALL_BACKUP] = arg -> new PutAllBackupOperation();
    constructors[PUT_ALL_PARTITION_AWARE_FACTORY] = arg -> new MultiMapPutAllOperationFactory();
    return new ArrayDataSerializableFactory(constructors);
}
Also used : TxnRemoveAllOperation(com.hazelcast.multimap.impl.txn.TxnRemoveAllOperation) RemoveAllOperation(com.hazelcast.multimap.impl.operations.RemoveAllOperation) PutAllBackupOperation(com.hazelcast.multimap.impl.operations.PutAllBackupOperation) GetAllOperation(com.hazelcast.multimap.impl.operations.GetAllOperation) TxnRemoveBackupOperation(com.hazelcast.multimap.impl.txn.TxnRemoveBackupOperation) TxnPrepareBackupOperation(com.hazelcast.multimap.impl.txn.TxnPrepareBackupOperation) EntrySetResponse(com.hazelcast.multimap.impl.operations.EntrySetResponse) ClearBackupOperation(com.hazelcast.multimap.impl.operations.ClearBackupOperation) DeleteOperation(com.hazelcast.multimap.impl.operations.DeleteOperation) DeleteBackupOperation(com.hazelcast.multimap.impl.operations.DeleteBackupOperation) TxnCommitOperation(com.hazelcast.multimap.impl.txn.TxnCommitOperation) MultiMapOperationFactory(com.hazelcast.multimap.impl.operations.MultiMapOperationFactory) TxnRemoveAllOperation(com.hazelcast.multimap.impl.txn.TxnRemoveAllOperation) TxnPrepareOperation(com.hazelcast.multimap.impl.txn.TxnPrepareOperation) KeySetOperation(com.hazelcast.multimap.impl.operations.KeySetOperation) TxnPutBackupOperation(com.hazelcast.multimap.impl.txn.TxnPutBackupOperation) PutBackupOperation(com.hazelcast.multimap.impl.operations.PutBackupOperation) ContainsEntryOperation(com.hazelcast.multimap.impl.operations.ContainsEntryOperation) CountOperation(com.hazelcast.multimap.impl.operations.CountOperation) SizeOperation(com.hazelcast.multimap.impl.operations.SizeOperation) TxnPutOperation(com.hazelcast.multimap.impl.txn.TxnPutOperation) MultiMapTransactionLogRecord(com.hazelcast.multimap.impl.txn.MultiMapTransactionLogRecord) MergeOperation(com.hazelcast.multimap.impl.operations.MergeOperation) TxnRollbackOperation(com.hazelcast.multimap.impl.txn.TxnRollbackOperation) PutOperation(com.hazelcast.multimap.impl.operations.PutOperation) TxnPutOperation(com.hazelcast.multimap.impl.txn.TxnPutOperation) TxnRemoveAllBackupOperation(com.hazelcast.multimap.impl.txn.TxnRemoveAllBackupOperation) TxnRemoveOperation(com.hazelcast.multimap.impl.txn.TxnRemoveOperation) RemoveOperation(com.hazelcast.multimap.impl.operations.RemoveOperation) ClearOperation(com.hazelcast.multimap.impl.operations.ClearOperation) EntrySetOperation(com.hazelcast.multimap.impl.operations.EntrySetOperation) TxnRemoveOperation(com.hazelcast.multimap.impl.txn.TxnRemoveOperation) ConstructorFunction(com.hazelcast.internal.util.ConstructorFunction) TxnPutBackupOperation(com.hazelcast.multimap.impl.txn.TxnPutBackupOperation) TxnCommitBackupOperation(com.hazelcast.multimap.impl.txn.TxnCommitBackupOperation) MergeBackupOperation(com.hazelcast.multimap.impl.operations.MergeBackupOperation) TxnLockAndGetOperation(com.hazelcast.multimap.impl.txn.TxnLockAndGetOperation) TxnRemoveAllBackupOperation(com.hazelcast.multimap.impl.txn.TxnRemoveAllBackupOperation) RemoveAllBackupOperation(com.hazelcast.multimap.impl.operations.RemoveAllBackupOperation) MultiMapPutAllOperationFactory(com.hazelcast.multimap.impl.operations.MultiMapPutAllOperationFactory) TxnGenerateRecordIdOperation(com.hazelcast.multimap.impl.txn.TxnGenerateRecordIdOperation) MultiMapResponse(com.hazelcast.multimap.impl.operations.MultiMapResponse) TxnRollbackBackupOperation(com.hazelcast.multimap.impl.txn.TxnRollbackBackupOperation) RemoveBackupOperation(com.hazelcast.multimap.impl.operations.RemoveBackupOperation) TxnRemoveBackupOperation(com.hazelcast.multimap.impl.txn.TxnRemoveBackupOperation) MultiMapReplicationOperation(com.hazelcast.multimap.impl.operations.MultiMapReplicationOperation) PutAllOperation(com.hazelcast.multimap.impl.operations.PutAllOperation) ArrayDataSerializableFactory(com.hazelcast.internal.serialization.impl.ArrayDataSerializableFactory) ValuesOperation(com.hazelcast.multimap.impl.operations.ValuesOperation)

Example 2 with MultiMapPutAllOperationFactory

use of com.hazelcast.multimap.impl.operations.MultiMapPutAllOperationFactory in project hazelcast by hazelcast.

the class MultiMapProxySupport method invokePutAllOperation.

// NB: this method is generally copied from MapProxySupport#invokePutAllOperation
private InternalCompletableFuture<Void> invokePutAllOperation(Address address, List<Integer> memberPartitions, MapEntries[] entriesPerPartition) {
    int size = memberPartitions.size();
    int[] partitions = new int[size];
    int index = 0;
    for (Integer partitionId : memberPartitions) {
        if (entriesPerPartition[partitionId] != null) {
            partitions[index++] = partitionId;
        }
    }
    if (index == 0) {
        return newCompletedFuture(null);
    }
    // trim partition array to real size
    if (index < size) {
        partitions = Arrays.copyOf(partitions, index);
        size = index;
    }
    index = 0;
    MapEntries[] entries = new MapEntries[size];
    long totalSize = 0;
    for (int partitionId : partitions) {
        totalSize += entriesPerPartition[partitionId].size();
        entries[index++] = entriesPerPartition[partitionId];
        entriesPerPartition[partitionId] = null;
    }
    if (totalSize == 0) {
        return newCompletedFuture(null);
    }
    OperationFactory factory = new MultiMapPutAllOperationFactory(name, partitions, entries);
    long startTimeNanos = System.nanoTime();
    CompletableFuture<Map<Integer, Object>> future = operationService.invokeOnPartitionsAsync(MultiMapService.SERVICE_NAME, factory, singletonMap(address, asIntegerList(partitions)));
    InternalCompletableFuture<Void> resultFuture = new InternalCompletableFuture<>();
    long finalTotalSize = totalSize;
    future.whenCompleteAsync((response, t) -> {
        if (t == null) {
            getService().getLocalMultiMapStatsImpl(name).incrementPutLatencyNanos(finalTotalSize, System.nanoTime() - startTimeNanos);
            resultFuture.complete(null);
        } else {
            resultFuture.completeExceptionally(t);
        }
    }, CALLER_RUNS);
    return resultFuture;
}
Also used : InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MultiMapPutAllOperationFactory(com.hazelcast.multimap.impl.operations.MultiMapPutAllOperationFactory) MapEntries(com.hazelcast.map.impl.MapEntries) Map(java.util.Map) Collections.singletonMap(java.util.Collections.singletonMap) MultiMapOperationFactory(com.hazelcast.multimap.impl.operations.MultiMapOperationFactory) MultiMapPutAllOperationFactory(com.hazelcast.multimap.impl.operations.MultiMapPutAllOperationFactory) OperationFactory(com.hazelcast.spi.impl.operationservice.OperationFactory)

Aggregations

MultiMapOperationFactory (com.hazelcast.multimap.impl.operations.MultiMapOperationFactory)2 MultiMapPutAllOperationFactory (com.hazelcast.multimap.impl.operations.MultiMapPutAllOperationFactory)2 ArrayDataSerializableFactory (com.hazelcast.internal.serialization.impl.ArrayDataSerializableFactory)1 ConstructorFunction (com.hazelcast.internal.util.ConstructorFunction)1 MapEntries (com.hazelcast.map.impl.MapEntries)1 ClearBackupOperation (com.hazelcast.multimap.impl.operations.ClearBackupOperation)1 ClearOperation (com.hazelcast.multimap.impl.operations.ClearOperation)1 ContainsEntryOperation (com.hazelcast.multimap.impl.operations.ContainsEntryOperation)1 CountOperation (com.hazelcast.multimap.impl.operations.CountOperation)1 DeleteBackupOperation (com.hazelcast.multimap.impl.operations.DeleteBackupOperation)1 DeleteOperation (com.hazelcast.multimap.impl.operations.DeleteOperation)1 EntrySetOperation (com.hazelcast.multimap.impl.operations.EntrySetOperation)1 EntrySetResponse (com.hazelcast.multimap.impl.operations.EntrySetResponse)1 GetAllOperation (com.hazelcast.multimap.impl.operations.GetAllOperation)1 KeySetOperation (com.hazelcast.multimap.impl.operations.KeySetOperation)1 MergeBackupOperation (com.hazelcast.multimap.impl.operations.MergeBackupOperation)1 MergeOperation (com.hazelcast.multimap.impl.operations.MergeOperation)1 MultiMapReplicationOperation (com.hazelcast.multimap.impl.operations.MultiMapReplicationOperation)1 MultiMapResponse (com.hazelcast.multimap.impl.operations.MultiMapResponse)1 PutAllBackupOperation (com.hazelcast.multimap.impl.operations.PutAllBackupOperation)1