use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.
the class CachePutAllTest method testPutAll_whenEntryExpiresOnCreate.
@Test
public void testPutAll_whenEntryExpiresOnCreate() {
Factory<? extends ExpiryPolicy> expiryPolicyFactory = FactoryBuilder.factoryOf(new CreatedExpiryPolicy(Duration.ZERO));
CacheConfig<String, String> cacheConfig = new CacheConfig<String, String>();
cacheConfig.setTypes(String.class, String.class);
cacheConfig.setExpiryPolicyFactory(expiryPolicyFactory);
cacheConfig.setStatisticsEnabled(true);
cacheConfig.setBackupCount(1);
Cache<String, String> cache = createCache(cacheConfig);
String key = generateKeyOwnedBy(hazelcastInstance);
// need to count the number of backup failures on backup member
OperationService operationService = getOperationService(hazelcastInstances[1]);
MetricsRegistry metricsRegistry = getMetricsRegistry(hazelcastInstances[1]);
assertEquals(0L, OperationServiceAccessor.getFailedBackupsCount(hazelcastInstances[1]).get());
Map<String, String> entries = new HashMap<String, String>();
entries.put(key, randomString());
cache.putAll(entries);
assertNull(cache.get(key));
// force collect metrics
metricsRegistry.provideMetrics(operationService);
assertEquals(0L, OperationServiceAccessor.getFailedBackupsCount(hazelcastInstances[1]).get());
}
use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.
the class ConnectedClientOperationTest method testGetConnectedClientsOperation_WhenMoreThanZeroClientConnects.
@Test
public void testGetConnectedClientsOperation_WhenMoreThanZeroClientConnects() throws Exception {
HazelcastInstance instance = factory.newHazelcastInstance();
factory.newHazelcastClient();
factory.newHazelcastClient();
Node node = getNode(instance);
Operation operation = new GetConnectedClientsOperation();
OperationService operationService = node.nodeEngine.getOperationService();
Future<Map<String, String>> future = operationService.invokeOnTarget(ClientEngineImpl.SERVICE_NAME, operation, node.address);
Map<String, String> clients = future.get();
assertEquals(2, clients.size());
}
use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.
the class InternalPartitionServiceImpl method sendPartitionRuntimeState.
void sendPartitionRuntimeState(Address target) {
if (!isLocalMemberMaster()) {
return;
}
assert partitionStateManager.isInitialized();
PartitionRuntimeState partitionState = createPartitionStateInternal();
assert partitionState != null;
if (logger.isFineEnabled()) {
logger.fine("Sending partition state, stamp: " + partitionState.getStamp() + ", to " + target);
}
OperationService operationService = nodeEngine.getOperationService();
PartitionStateOperation op = new PartitionStateOperation(partitionState, true);
operationService.invokeOnTarget(SERVICE_NAME, op, target);
}
use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.
the class InternalPartitionServiceImpl method checkClusterPartitionRuntimeStates.
void checkClusterPartitionRuntimeStates() {
if (!partitionStateManager.isInitialized()) {
return;
}
if (!isLocalMemberMaster()) {
return;
}
if (!areMigrationTasksAllowed()) {
// migration is disabled because of a member leave, wait till enabled!
return;
}
long stamp = getPartitionStateStamp();
if (logger.isFineEnabled()) {
logger.fine("Checking partition state, stamp: " + stamp);
}
OperationService operationService = nodeEngine.getOperationService();
Collection<Member> members = node.clusterService.getMembers();
for (Member member : members) {
if (!member.localMember()) {
PartitionStateCheckOperation op = new PartitionStateCheckOperation(stamp);
InvocationFuture<Boolean> future = operationService.invokeOnTarget(SERVICE_NAME, op, member.getAddress());
future.whenCompleteAsync((response, throwable) -> {
if (throwable == null) {
if (!Boolean.TRUE.equals(response)) {
logger.fine(member + " has a stale partition state. Will send the most recent partition state now.");
sendPartitionRuntimeState(member.getAddress());
}
} else {
logger.fine("Failure while checking partition state on " + member, throwable);
sendPartitionRuntimeState(member.getAddress());
}
});
}
}
}
use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.
the class BasicRecordStoreLoader method sendOperation.
/**
* Invokes an operation to put the provided key-value pairs to the partition
* record store.
*
* @param loadingSequence the list of serialised key-value-(expirationTime)
* sequences
* @return the future representing the pending completion of the put operation
*/
private Future<?> sendOperation(List<Data> loadingSequence) {
OperationService operationService = mapServiceContext.getNodeEngine().getOperationService();
NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
Operation operation = createOperation(loadingSequence);
operation.setNodeEngine(nodeEngine);
operation.setPartitionId(partitionId);
OperationAccessor.setCallerAddress(operation, nodeEngine.getThisAddress());
operation.setCallerUuid(nodeEngine.getLocalMember().getUuid());
operation.setServiceName(MapService.SERVICE_NAME);
return operationService.invokeOnPartition(MapService.SERVICE_NAME, operation, partitionId);
}
Aggregations