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);
}
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;
}
Aggregations