use of com.hazelcast.internal.server.Server in project hazelcast by hazelcast.
the class TextCommandServiceImpl method getStats.
@Override
public Stats getStats() {
Stats stats = new Stats();
stats.setUptime((int) ((Clock.currentTimeMillis() - startTime) / MILLIS_TO_SECONDS));
stats.setCmdGet(getMisses.get() + getHits.get());
stats.setCmdSet(sets.get());
stats.setCmdTouch(touches.get());
stats.setGetHits(getHits.get());
stats.setGetMisses(getMisses.get());
stats.setDeleteHits(deleteHits.get());
stats.setDeleteMisses(deleteMisses.get());
stats.setIncrHits(incrementHits.get());
stats.setIncrMisses(incrementMisses.get());
stats.setDecrHits(decrementHits.get());
stats.setDecrMisses(decrementMisses.get());
Server server = node.getServer();
ServerConnectionManager cm = server.getConnectionManager(MEMCACHE);
int memcachedCount = cm == null ? 0 : cm.connectionCount(c -> Protocols.MEMCACHE.equals(c.getConnectionType()));
stats.setCurrConnections(memcachedCount);
stats.setTotalConnections(server.connectionCount());
return stats;
}
use of com.hazelcast.internal.server.Server in project hazelcast by hazelcast.
the class HttpGetCommandProcessor method handleCluster.
/**
* Sets the HTTP response to a string containing basic cluster information:
* <ul>
* <li>Member list</li>
* <li>Client connection count</li>
* <li>Connection count</li>
* </ul>
*
* @param command the HTTP request
*/
private void handleCluster(HttpGetCommand command) {
Node node = textCommandService.getNode();
Server server = node.getServer();
ClusterServiceImpl clusterService = node.getClusterService();
JsonArray membersArray = new JsonArray();
clusterService.getMembers().stream().map(m -> new JsonObject().add("address", m.getAddress().toString()).add("liteMember", m.isLiteMember()).add("localMember", m.localMember()).add("uuid", m.getUuid().toString()).add("memberVersion", m.getVersion().toString())).forEach(membersArray::add);
ServerConnectionManager cm = server.getConnectionManager(CLIENT);
int clientCount = cm == null ? 0 : cm.connectionCount(ServerConnection::isClient);
JsonObject response = new JsonObject().add("members", membersArray).add("connectionCount", clientCount).add("allConnectionCount", server.connectionCount());
prepareResponse(command, response);
}
use of com.hazelcast.internal.server.Server in project hazelcast by hazelcast.
the class AbstractOutOfMemoryHandlerTest method tearDown.
@After
public void tearDown() {
if (hazelcastInstance != null) {
hazelcastInstance.shutdown();
}
if (hazelcastInstanceThrowsException != null) {
Server server = hazelcastInstanceThrowsException.node.getServer();
// Failing connection manager throws error, so we should disable this behaviour to shutdown instance properly
((FailingServer) server).switchToDummyMode();
hazelcastInstanceThrowsException.shutdown();
}
}
use of com.hazelcast.internal.server.Server in project hazelcast by hazelcast.
the class TestNodeContext method mockServer.
private static Server mockServer() {
Server server = mock(Server.class);
when(server.getConnectionManager(ArgumentMatchers.<EndpointQualifier>any())).thenReturn(mock(ServerConnectionManager.class));
return server;
}
use of com.hazelcast.internal.server.Server in project hazelcast by hazelcast.
the class FirewallingConnectionManagerConstructorTest method testConstructor.
@Test
public void testConstructor() throws Exception {
Server delegate = mock(Server.class);
Address address = new Address("172.16.16.1", 4223);
Set<Address> blockedAddresses = Collections.singleton(address);
FirewallingServer ns = new FirewallingServer(delegate, blockedAddresses);
FirewallingNetworkingInstanceConstructor constructor = new FirewallingNetworkingInstanceConstructor(FirewallingServer.class);
FirewallingServer clonedConnectionManager = (FirewallingServer) constructor.createNew(ns);
assertEquals(delegate, getFieldValueReflectively(clonedConnectionManager, "delegate"));
assertEquals(blockedAddresses, getFieldValueReflectively(clonedConnectionManager, "blockedAddresses"));
}
Aggregations