use of com.hazelcast.spi.impl.operationservice.BinaryOperationFactory in project hazelcast by hazelcast.
the class MapProxySupport method clearInternal.
public void clearInternal() {
try {
Operation clearOperation = operationProvider.createClearOperation(name);
clearOperation.setServiceName(SERVICE_NAME);
BinaryOperationFactory factory = new BinaryOperationFactory(clearOperation, getNodeEngine());
Map<Integer, Object> resultMap = operationService.invokeOnAllPartitions(SERVICE_NAME, factory);
int clearedCount = 0;
for (Object object : resultMap.values()) {
clearedCount += (Integer) object;
}
if (clearedCount > 0) {
publishMapEvent(clearedCount, CLEAR_ALL);
}
incrementOtherOperationsStat();
} catch (Throwable t) {
throw rethrow(t);
}
}
use of com.hazelcast.spi.impl.operationservice.BinaryOperationFactory in project hazelcast by hazelcast.
the class EntryProcessorTest method multiple_entry_with_predicate_operation_returns_empty_response_when_map_is_empty.
@Test
public void multiple_entry_with_predicate_operation_returns_empty_response_when_map_is_empty() throws Exception {
Config config = getConfig();
MapConfig mapConfig = config.getMapConfig(MAP_NAME);
mapConfig.setInMemoryFormat(inMemoryFormat);
HazelcastInstance node = createHazelcastInstance(config);
NodeEngineImpl nodeEngineImpl = getNodeEngineImpl(node);
OperationServiceImpl operationService = nodeEngineImpl.getOperationService();
int keyCount = 1000;
Set<Data> dataKeys = new HashSet<>();
for (int i = 0; i < keyCount; i++) {
dataKeys.add(nodeEngineImpl.toData(i));
}
Operation operation = new MultipleEntryWithPredicateOperation(MAP_NAME, dataKeys, new NoOpEntryProcessor<>(), Predicates.sql("this < " + keyCount));
OperationFactory operationFactory = new BinaryOperationFactory(operation, nodeEngineImpl);
Map<Integer, Object> partitionResponses = operationService.invokeOnAllPartitions(MapService.SERVICE_NAME, operationFactory);
for (Object response : partitionResponses.values()) {
assertEquals(0, ((MapEntries) response).size());
}
}
use of com.hazelcast.spi.impl.operationservice.BinaryOperationFactory in project hazelcast by hazelcast.
the class MapProxySupport method evictAllInternal.
protected void evictAllInternal() {
try {
Operation operation = operationProvider.createEvictAllOperation(name);
BinaryOperationFactory factory = new BinaryOperationFactory(operation, getNodeEngine());
Map<Integer, Object> resultMap = operationService.invokeOnAllPartitions(SERVICE_NAME, factory);
int evictedCount = 0;
for (Object object : resultMap.values()) {
evictedCount += (Integer) object;
}
if (evictedCount > 0) {
publishMapEvent(evictedCount, EntryEventType.EVICT_ALL);
}
} catch (Throwable t) {
throw rethrow(t);
}
}
use of com.hazelcast.spi.impl.operationservice.BinaryOperationFactory in project hazelcast by hazelcast.
the class MapProxySupport method addIndex.
@Override
public void addIndex(IndexConfig indexConfig) {
checkNotNull(indexConfig, "Index config cannot be null.");
checkFalse(isNativeMemoryAndBitmapIndexingEnabled(indexConfig.getType()), "BITMAP indexes are not supported by NATIVE storage");
IndexConfig indexConfig0 = IndexUtils.validateAndNormalize(name, indexConfig);
try {
AddIndexOperation addIndexOperation = new AddIndexOperation(name, indexConfig0);
operationService.invokeOnAllPartitions(SERVICE_NAME, new BinaryOperationFactory(addIndexOperation, getNodeEngine()));
} catch (Throwable t) {
throw rethrow(t);
}
}
use of com.hazelcast.spi.impl.operationservice.BinaryOperationFactory in project hazelcast by hazelcast.
the class MapProxySupport method flush.
@Override
public void flush() {
// TODO: add a feature to Management Center to sync cache to db completely
try {
MapOperation mapFlushOperation = operationProvider.createMapFlushOperation(name);
BinaryOperationFactory operationFactory = new BinaryOperationFactory(mapFlushOperation, getNodeEngine());
Map<Integer, Object> results = operationService.invokeOnAllPartitions(SERVICE_NAME, operationFactory);
List<Future> futures = new ArrayList<>();
for (Entry<Integer, Object> entry : results.entrySet()) {
Integer partitionId = entry.getKey();
Long count = ((Long) entry.getValue());
if (count != 0) {
Operation operation = new AwaitMapFlushOperation(name, count);
futures.add(operationService.invokeOnPartition(MapService.SERVICE_NAME, operation, partitionId));
}
}
for (Future future : futures) {
future.get();
}
} catch (Throwable t) {
throw rethrow(t);
}
}
Aggregations