use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class ClientEngineImpl method getConnectedClientStats.
@Override
public Map<ClientType, Integer> getConnectedClientStats() {
int numberOfCppClients = 0;
int numberOfDotNetClients = 0;
int numberOfJavaClients = 0;
int numberOfNodeJSClients = 0;
int numberOfPythonClients = 0;
int numberOfOtherClients = 0;
OperationService operationService = node.nodeEngine.getOperationService();
Map<ClientType, Integer> resultMap = new HashMap<ClientType, Integer>();
Map<String, ClientType> clientsMap = new HashMap<String, ClientType>();
for (Member member : node.getClusterService().getMembers()) {
Address target = member.getAddress();
Operation clientInfoOperation = new GetConnectedClientsOperation();
Future<Map<String, ClientType>> future = operationService.invokeOnTarget(SERVICE_NAME, clientInfoOperation, target);
try {
Map<String, ClientType> endpoints = future.get();
if (endpoints == null) {
continue;
}
//Merge connected clients according to their uuid.
for (Map.Entry<String, ClientType> entry : endpoints.entrySet()) {
clientsMap.put(entry.getKey(), entry.getValue());
}
} catch (Exception e) {
logger.warning("Cannot get client information from: " + target.toString(), e);
}
}
//Now we are regrouping according to the client type
for (ClientType clientType : clientsMap.values()) {
switch(clientType) {
case JAVA:
numberOfJavaClients++;
break;
case CSHARP:
numberOfDotNetClients++;
break;
case CPP:
numberOfCppClients++;
break;
case NODEJS:
numberOfNodeJSClients++;
break;
case PYTHON:
numberOfPythonClients++;
break;
default:
numberOfOtherClients++;
}
}
resultMap.put(ClientType.CPP, numberOfCppClients);
resultMap.put(ClientType.CSHARP, numberOfDotNetClients);
resultMap.put(ClientType.JAVA, numberOfJavaClients);
resultMap.put(ClientType.NODEJS, numberOfNodeJSClients);
resultMap.put(ClientType.PYTHON, numberOfPythonClients);
resultMap.put(ClientType.OTHER, numberOfOtherClients);
return resultMap;
}
use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class TransactionLogTest method prepare_partitionSpecificRecord.
@Test
public void prepare_partitionSpecificRecord() throws Exception {
OperationService operationService = mock(OperationService.class);
NodeEngine nodeEngine = mock(NodeEngine.class);
when(nodeEngine.getOperationService()).thenReturn(operationService);
TransactionLog log = new TransactionLog();
TransactionLogRecord partitionRecord = mock(TransactionLogRecord.class);
Operation partitionOperation = new DummyPartitionOperation();
when(partitionRecord.newPrepareOperation()).thenReturn(partitionOperation);
log.add(partitionRecord);
log.prepare(nodeEngine);
verify(operationService, times(1)).invokeOnPartition(partitionOperation.getServiceName(), partitionOperation, partitionOperation.getPartitionId());
}
use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class TransactionLogTest method prepare_targetAwareRecord.
@Test
public void prepare_targetAwareRecord() throws Exception {
OperationService operationService = mock(OperationService.class);
NodeEngine nodeEngine = mock(NodeEngine.class);
when(nodeEngine.getOperationService()).thenReturn(operationService);
TransactionLog log = new TransactionLog();
Address target = new Address(InetAddress.getLocalHost(), 5000);
TargetAwareTransactionLogRecord targetRecord = mock(TargetAwareTransactionLogRecord.class);
when(targetRecord.getTarget()).thenReturn(target);
DummyTargetOperation targetOperation = new DummyTargetOperation();
when(targetRecord.newPrepareOperation()).thenReturn(targetOperation);
log.add(targetRecord);
log.prepare(nodeEngine);
verify(operationService, times(1)).invokeOnTarget(targetOperation.getServiceName(), targetOperation, target);
}
use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class TransactionLogTest method rollback_partitionSpecificRecord.
@Test
public void rollback_partitionSpecificRecord() throws Exception {
OperationService operationService = mock(OperationService.class);
NodeEngine nodeEngine = mock(NodeEngine.class);
when(nodeEngine.getOperationService()).thenReturn(operationService);
TransactionLog log = new TransactionLog();
TransactionLogRecord partitionRecord = mock(TransactionLogRecord.class);
Operation partitionOperation = new DummyPartitionOperation();
when(partitionRecord.newRollbackOperation()).thenReturn(partitionOperation);
log.add(partitionRecord);
log.rollback(nodeEngine);
verify(operationService, times(1)).invokeOnPartition(partitionOperation.getServiceName(), partitionOperation, partitionOperation.getPartitionId());
}
use of com.hazelcast.spi.OperationService in project hazelcast by hazelcast.
the class TransactionLogTest method rollback_targetAwareRecord.
@Test
public void rollback_targetAwareRecord() throws Exception {
OperationService operationService = mock(OperationService.class);
NodeEngine nodeEngine = mock(NodeEngine.class);
when(nodeEngine.getOperationService()).thenReturn(operationService);
TransactionLog log = new TransactionLog();
Address target = new Address(InetAddress.getLocalHost(), 5000);
TargetAwareTransactionLogRecord targetRecord = mock(TargetAwareTransactionLogRecord.class);
when(targetRecord.getTarget()).thenReturn(target);
DummyTargetOperation targetOperation = new DummyTargetOperation();
when(targetRecord.newRollbackOperation()).thenReturn(targetOperation);
log.add(targetRecord);
log.rollback(nodeEngine);
verify(operationService, times(1)).invokeOnTarget(targetOperation.getServiceName(), targetOperation, target);
}
Aggregations