Search in sources :

Example 1 with Server

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;
}
Also used : Clock(com.hazelcast.internal.util.Clock) ADD(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.ADD) RestCallCollector(com.hazelcast.internal.ascii.rest.RestCallCollector) TextEncoder(com.hazelcast.internal.nio.ascii.TextEncoder) Thread.currentThread(java.lang.Thread.currentThread) StatsCommandProcessor(com.hazelcast.internal.ascii.memcache.StatsCommandProcessor) HttpPostCommandProcessor(com.hazelcast.internal.ascii.rest.HttpPostCommandProcessor) ByteBuffer(java.nio.ByteBuffer) GET_END(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.GET_END) UNKNOWN(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.UNKNOWN) OutOfMemoryErrorDispatcher(com.hazelcast.instance.impl.OutOfMemoryErrorDispatcher) HTTP_POST(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.HTTP_POST) EmptyStatement.ignore(com.hazelcast.internal.util.EmptyStatement.ignore) GetCommandProcessor(com.hazelcast.internal.ascii.memcache.GetCommandProcessor) Map(java.util.Map) HTTP_GET(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.HTTP_GET) BULK_GET(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.BULK_GET) TouchCommandProcessor(com.hazelcast.internal.ascii.memcache.TouchCommandProcessor) Set(java.util.Set) Server(com.hazelcast.internal.server.Server) BlockingQueue(java.util.concurrent.BlockingQueue) ThreadUtil.createThreadName(com.hazelcast.internal.util.ThreadUtil.createThreadName) Node(com.hazelcast.instance.impl.Node) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) ERROR_CLIENT(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.ERROR_CLIENT) HttpDeleteCommandProcessor(com.hazelcast.internal.ascii.rest.HttpDeleteCommandProcessor) TOUCH(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.TOUCH) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) BulkGetCommandProcessor(com.hazelcast.internal.ascii.memcache.BulkGetCommandProcessor) REPLACE(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.REPLACE) INCREMENT(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.INCREMENT) VersionCommandProcessor(com.hazelcast.internal.ascii.memcache.VersionCommandProcessor) APPEND(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.APPEND) SET(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.SET) SimpleCommandProcessor(com.hazelcast.internal.ascii.memcache.SimpleCommandProcessor) ERROR_SERVER(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.ERROR_SERVER) Protocols(com.hazelcast.internal.nio.Protocols) PREPEND(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.PREPEND) DeleteCommandProcessor(com.hazelcast.internal.ascii.memcache.DeleteCommandProcessor) ILogger(com.hazelcast.logging.ILogger) STATS(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.STATS) Stats(com.hazelcast.internal.ascii.memcache.Stats) HTTP_HEAD(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.HTTP_HEAD) HTTP_PUT(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.HTTP_PUT) EntryConverter(com.hazelcast.internal.ascii.memcache.EntryConverter) SetCommandProcessor(com.hazelcast.internal.ascii.memcache.SetCommandProcessor) ServerConnectionManager(com.hazelcast.internal.server.ServerConnectionManager) HazelcastInstance(com.hazelcast.core.HazelcastInstance) HttpHeadCommandProcessor(com.hazelcast.internal.ascii.rest.HttpHeadCommandProcessor) Data(com.hazelcast.internal.serialization.Data) QUIT(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.QUIT) VERSION(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.VERSION) NO_OP(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.NO_OP) DECREMENT(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.DECREMENT) TimeUnit(java.util.concurrent.TimeUnit) MEMCACHE(com.hazelcast.instance.EndpointQualifier.MEMCACHE) AtomicLong(java.util.concurrent.atomic.AtomicLong) GET(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.GET) ErrorCommandProcessor(com.hazelcast.internal.ascii.memcache.ErrorCommandProcessor) RestValue(com.hazelcast.internal.ascii.rest.RestValue) HttpGetCommandProcessor(com.hazelcast.internal.ascii.rest.HttpGetCommandProcessor) IncrementCommandProcessor(com.hazelcast.internal.ascii.memcache.IncrementCommandProcessor) HTTP_DELETE(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.HTTP_DELETE) DELETE(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.DELETE) IMap(com.hazelcast.map.IMap) Server(com.hazelcast.internal.server.Server) ServerConnectionManager(com.hazelcast.internal.server.ServerConnectionManager) Stats(com.hazelcast.internal.ascii.memcache.Stats)

Example 2 with Server

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);
}
Also used : JsonArray(com.hazelcast.internal.json.JsonArray) Address(com.hazelcast.cluster.Address) LoggingServiceImpl(com.hazelcast.logging.impl.LoggingServiceImpl) ServerConnection(com.hazelcast.internal.server.ServerConnection) JsonArray(com.hazelcast.internal.json.JsonArray) Level(java.util.logging.Level) Json(com.hazelcast.internal.json.Json) ClusterService(com.hazelcast.internal.cluster.ClusterService) SC_500(com.hazelcast.internal.ascii.rest.HttpStatusCode.SC_500) CPGroup(com.hazelcast.cp.CPGroup) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) StringUtil.equalsIgnoreCase(com.hazelcast.internal.util.StringUtil.equalsIgnoreCase) CPSession(com.hazelcast.cp.session.CPSession) JsonObject(com.hazelcast.internal.json.JsonObject) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) CPGroupId(com.hazelcast.cp.CPGroupId) ServerConnectionManager(com.hazelcast.internal.server.ServerConnectionManager) TextCommandService(com.hazelcast.internal.ascii.TextCommandService) StringUtil(com.hazelcast.internal.util.StringUtil) ExceptionUtil.peel(com.hazelcast.internal.util.ExceptionUtil.peel) CPSubsystemManagementService(com.hazelcast.cp.CPSubsystemManagementService) Collection(java.util.Collection) Server(com.hazelcast.internal.server.Server) NodeState(com.hazelcast.instance.impl.NodeState) MAP(com.hazelcast.internal.ascii.rest.RestCallExecution.ObjectType.MAP) Node(com.hazelcast.instance.impl.Node) CLIENT(com.hazelcast.instance.EndpointQualifier.CLIENT) CompletionStage(java.util.concurrent.CompletionStage) CPMember(com.hazelcast.cp.CPMember) ClusterState(com.hazelcast.cluster.ClusterState) CPSubsystem(com.hazelcast.cp.CPSubsystem) QUEUE(com.hazelcast.internal.ascii.rest.RestCallExecution.ObjectType.QUEUE) Server(com.hazelcast.internal.server.Server) ServerConnectionManager(com.hazelcast.internal.server.ServerConnectionManager) Node(com.hazelcast.instance.impl.Node) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) JsonObject(com.hazelcast.internal.json.JsonObject)

Example 3 with Server

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();
    }
}
Also used : Server(com.hazelcast.internal.server.Server) After(org.junit.After)

Example 4 with Server

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;
}
Also used : Server(com.hazelcast.internal.server.Server) ServerConnectionManager(com.hazelcast.internal.server.ServerConnectionManager)

Example 5 with 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"));
}
Also used : FirewallingServer(com.hazelcast.internal.server.FirewallingServer) Server(com.hazelcast.internal.server.Server) FirewallingServer(com.hazelcast.internal.server.FirewallingServer) Address(com.hazelcast.cluster.Address) FirewallingNetworkingInstanceConstructor(com.hazelcast.test.starter.constructor.FirewallingNetworkingInstanceConstructor) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

Server (com.hazelcast.internal.server.Server)4 Address (com.hazelcast.cluster.Address)2 Node (com.hazelcast.instance.impl.Node)2 ServerConnectionManager (com.hazelcast.internal.server.ServerConnectionManager)2 ClusterState (com.hazelcast.cluster.ClusterState)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 CPGroup (com.hazelcast.cp.CPGroup)1 CPGroupId (com.hazelcast.cp.CPGroupId)1 CPMember (com.hazelcast.cp.CPMember)1 CPSubsystem (com.hazelcast.cp.CPSubsystem)1 CPSubsystemManagementService (com.hazelcast.cp.CPSubsystemManagementService)1 CPSession (com.hazelcast.cp.session.CPSession)1 CLIENT (com.hazelcast.instance.EndpointQualifier.CLIENT)1 MEMCACHE (com.hazelcast.instance.EndpointQualifier.MEMCACHE)1 NodeState (com.hazelcast.instance.impl.NodeState)1 OutOfMemoryErrorDispatcher (com.hazelcast.instance.impl.OutOfMemoryErrorDispatcher)1 ADD (com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.ADD)1 APPEND (com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.APPEND)1 BULK_GET (com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.BULK_GET)1 DECREMENT (com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.DECREMENT)1