return idToKeys;
}
protected void putAllInternal(final Map<? extends Object, ? extends Object> entries) {
final NodeEngine nodeEngine = getNodeEngine();
final MapService mapService = getService();
int factor = 3;
InternalPartitionService partitionService = nodeEngine.getPartitionService();
OperationService operationService = nodeEngine.getOperationService();
int partitionCount = partitionService.getPartitionCount();
boolean tooManyEntries = entries.size() > (partitionCount * factor);
try {
if (tooManyEntries) {
List<Future> futures = new LinkedList<Future>();
Map<Integer, MapEntrySet> entryMap
= new HashMap<Integer, MapEntrySet>(nodeEngine.getPartitionService().getPartitionCount());
for (Entry entry : entries.entrySet()) {
if (entry.getKey() == null) {
throw new NullPointerException(NULL_KEY_IS_NOT_ALLOWED);
}
if (entry.getValue() == null) {
throw new NullPointerException(NULL_VALUE_IS_NOT_ALLOWED);
}
int partitionId = partitionService.getPartitionId(entry.getKey());
if (!entryMap.containsKey(partitionId)) {
entryMap.put(partitionId, new MapEntrySet());
}
entryMap.get(partitionId).add(
new AbstractMap.SimpleImmutableEntry<Data, Data>(mapService.getMapServiceContext().toData(
entry.getKey(),
partitionStrategy),
mapService.getMapServiceContext()
.toData(entry.getValue())
));
}
for (final Map.Entry<Integer, MapEntrySet> entry : entryMap.entrySet()) {
final Integer partitionId = entry.getKey();
final PutAllOperation op = new PutAllOperation(name, entry.getValue());
op.setPartitionId(partitionId);
futures.add(operationService.invokeOnPartition(SERVICE_NAME, op, partitionId));
}
for (Future future : futures) {
future.get();
}
} else {
for (Entry entry : entries.entrySet()) {
if (entry.getKey() == null) {
throw new NullPointerException(NULL_KEY_IS_NOT_ALLOWED);
}
if (entry.getValue() == null) {
throw new NullPointerException(NULL_VALUE_IS_NOT_ALLOWED);
}
putInternal(mapService.getMapServiceContext().toData(entry.getKey(), partitionStrategy),
mapService.getMapServiceContext().toData(entry.getValue()),
-1,
TimeUnit.MILLISECONDS);
}
}
} catch (Exception e) {