Search in sources :

Example 1 with EzySimpleSessionTokenGenerator

use of com.tvd12.ezyfoxserver.service.impl.EzySimpleSessionTokenGenerator in project ezyfox-server by youngmonkeys.

the class EzyLoader method newSessionManagers.

@SuppressWarnings("rawtypes")
protected EzySessionManager newSessionManagers(EzySettings settings) {
    EzySimpleSessionManager.Builder builder = createSessionManagerBuilder(settings);
    EzySessionTokenGenerator tokenGenerator = new EzySimpleSessionTokenGenerator(settings.getNodeName());
    builder.tokenGenerator(tokenGenerator).maxSessions(settings.getMaxSessions());
    return builder.build();
}
Also used : EzySimpleSessionManager(com.tvd12.ezyfoxserver.wrapper.EzySimpleSessionManager) EzySessionTokenGenerator(com.tvd12.ezyfoxserver.service.EzySessionTokenGenerator) EzySimpleSessionTokenGenerator(com.tvd12.ezyfoxserver.service.impl.EzySimpleSessionTokenGenerator)

Example 2 with EzySimpleSessionTokenGenerator

use of com.tvd12.ezyfoxserver.service.impl.EzySimpleSessionTokenGenerator in project ezyfox-server by youngmonkeys.

the class EzyNioSocketAcceptorTest method newHandlerGroupManager.

private EzyHandlerGroupManager newHandlerGroupManager() {
    EzyNioSessionManager sessionManager = (EzyNioSessionManager) EzyNioSessionManagerImpl.builder().maxRequestPerSecond(new EzySimpleSessionManagementSetting.EzySimpleMaxRequestPerSecond()).tokenGenerator(new EzySimpleSessionTokenGenerator()).build();
    ExEzyByteToObjectDecoder decoder = new ExEzyByteToObjectDecoder();
    EzyCodecFactory codecFactory = mock(EzyCodecFactory.class);
    when(codecFactory.newDecoder(any())).thenReturn(decoder);
    ExecutorService statsThreadPool = EzyExecutors.newSingleThreadExecutor("stats");
    EzySocketStreamQueue streamQueue = new EzyBlockingSocketStreamQueue();
    EzySocketDisconnectionQueue disconnectionQueue = new EzyBlockingSocketDisconnectionQueue();
    EzySessionTicketsRequestQueues sessionTicketsRequestQueues = new EzySessionTicketsRequestQueues();
    EzySimpleSettings settings = new EzySimpleSettings();
    EzySimpleStreamingSetting streaming = settings.getStreaming();
    streaming.setEnable(true);
    EzySimpleServer server = new EzySimpleServer();
    server.setSettings(settings);
    server.setSessionManager(sessionManager);
    EzySimpleServerContext serverContext = new EzySimpleServerContext();
    serverContext.setServer(server);
    serverContext.init();
    EzySessionTicketsQueue socketSessionTicketsQueue = new EzyBlockingSessionTicketsQueue();
    EzySessionTicketsQueue webSocketSessionTicketsQueue = new EzyBlockingSessionTicketsQueue();
    EzyStatistics statistics = new EzySimpleStatistics();
    EzyHandlerGroupBuilderFactory handlerGroupBuilderFactory = EzyHandlerGroupBuilderFactoryImpl.builder().statistics(statistics).statsThreadPool(statsThreadPool).streamQueue(streamQueue).disconnectionQueue(disconnectionQueue).codecFactory(codecFactory).serverContext(serverContext).socketSessionTicketsQueue(socketSessionTicketsQueue).webSocketSessionTicketsQueue(webSocketSessionTicketsQueue).sessionTicketsRequestQueues(sessionTicketsRequestQueues).build();
    return EzyHandlerGroupManagerImpl.builder().handlerGroupBuilderFactory(handlerGroupBuilderFactory).build();
}
Also used : EzySimpleServer(com.tvd12.ezyfoxserver.EzySimpleServer) EzyHandlerGroupBuilderFactory(com.tvd12.ezyfoxserver.nio.factory.EzyHandlerGroupBuilderFactory) EzySimpleServerContext(com.tvd12.ezyfoxserver.context.EzySimpleServerContext) EzySimpleStreamingSetting(com.tvd12.ezyfoxserver.setting.EzySimpleStreamingSetting) EzyStatistics(com.tvd12.ezyfoxserver.statistics.EzyStatistics) EzyNioSessionManager(com.tvd12.ezyfoxserver.nio.wrapper.EzyNioSessionManager) EzyCodecFactory(com.tvd12.ezyfoxserver.codec.EzyCodecFactory) EzySimpleSettings(com.tvd12.ezyfoxserver.setting.EzySimpleSettings) ExecutorService(java.util.concurrent.ExecutorService) EzySimpleStatistics(com.tvd12.ezyfoxserver.statistics.EzySimpleStatistics) EzySimpleSessionTokenGenerator(com.tvd12.ezyfoxserver.service.impl.EzySimpleSessionTokenGenerator)

Example 3 with EzySimpleSessionTokenGenerator

use of com.tvd12.ezyfoxserver.service.impl.EzySimpleSessionTokenGenerator in project ezyfox-server by youngmonkeys.

the class EzySimpleWsHandlerGroupTest method newHandlerGroup.

@SuppressWarnings("rawtypes")
private EzySimpleWsHandlerGroup newHandlerGroup(boolean streamEnable) throws IOException {
    EzySessionTicketsQueue socketSessionTicketsQueue = new EzyBlockingSessionTicketsQueue();
    EzySessionTicketsQueue webSocketSessionTicketsQueue = new EzyBlockingSessionTicketsQueue();
    EzySessionManager sessionManager = EzyNioSessionManagerImpl.builder().maxRequestPerSecond(new EzySimpleSessionManagementSetting.EzySimpleMaxRequestPerSecond()).tokenGenerator(new EzySimpleSessionTokenGenerator()).build();
    EzyStatistics statistics = new EzySimpleStatistics();
    EzySimpleSettings settings = new EzySimpleSettings();
    EzySimpleStreamingSetting streaming = settings.getStreaming();
    streaming.setEnable(streamEnable);
    EzySimpleServer server = new EzySimpleServer();
    server.setSettings(settings);
    server.setSessionManager(sessionManager);
    EzyServerControllers controllers = mock(EzyServerControllers.class);
    server.setControllers(controllers);
    EzySimpleConfig config = new EzySimpleConfig();
    server.setConfig(config);
    EzySimpleServerContext serverContext = new EzySimpleServerContext();
    serverContext.setServer(server);
    serverContext.init();
    EzyChannel channel = mock(EzyChannel.class);
    when(channel.isConnected()).thenReturn(true);
    when(channel.getConnection()).thenReturn(SocketChannel.open());
    when(channel.getConnectionType()).thenReturn(EzyConnectionType.WEBSOCKET);
    ExecutorService statsThreadPool = EzyExecutors.newFixedThreadPool(1, "stats");
    EzySocketStreamQueue streamQueue = new EzyBlockingSocketStreamQueue();
    EzySessionTicketsRequestQueues sessionTicketsRequestQueues = new EzySessionTicketsRequestQueues();
    EzySimpleSession session = mock(EzySimpleSession.class);
    when(session.getChannel()).thenReturn(channel);
    EzyHandlerGroupBuilderFactory handlerGroupBuilderFactory = EzyHandlerGroupBuilderFactoryImpl.builder().statistics(statistics).serverContext(serverContext).statsThreadPool(statsThreadPool).streamQueue(streamQueue).codecFactory(new ExCodecFactory()).sessionTicketsRequestQueues(sessionTicketsRequestQueues).socketSessionTicketsQueue(socketSessionTicketsQueue).webSocketSessionTicketsQueue(webSocketSessionTicketsQueue).build();
    return (EzySimpleWsHandlerGroup) handlerGroupBuilderFactory.newBuilder(channel, EzyConnectionType.WEBSOCKET).session(session).build();
}
Also used : EzySimpleConfig(com.tvd12.ezyfoxserver.config.EzySimpleConfig) EzySimpleWsHandlerGroup(com.tvd12.ezyfoxserver.nio.websocket.EzySimpleWsHandlerGroup) EzySimpleServer(com.tvd12.ezyfoxserver.EzySimpleServer) EzySimpleSessionManagementSetting(com.tvd12.ezyfoxserver.setting.EzySimpleSessionManagementSetting) EzyHandlerGroupBuilderFactory(com.tvd12.ezyfoxserver.nio.factory.EzyHandlerGroupBuilderFactory) EzySimpleServerContext(com.tvd12.ezyfoxserver.context.EzySimpleServerContext) EzyStatistics(com.tvd12.ezyfoxserver.statistics.EzyStatistics) EzySimpleStreamingSetting(com.tvd12.ezyfoxserver.setting.EzySimpleStreamingSetting) EzySessionManager(com.tvd12.ezyfoxserver.wrapper.EzySessionManager) EzyServerControllers(com.tvd12.ezyfoxserver.wrapper.EzyServerControllers) EzySimpleSettings(com.tvd12.ezyfoxserver.setting.EzySimpleSettings) EzySimpleSession(com.tvd12.ezyfoxserver.nio.entity.EzySimpleSession) ExecutorService(java.util.concurrent.ExecutorService) EzySimpleStatistics(com.tvd12.ezyfoxserver.statistics.EzySimpleStatistics) EzySimpleSessionTokenGenerator(com.tvd12.ezyfoxserver.service.impl.EzySimpleSessionTokenGenerator)

Example 4 with EzySimpleSessionTokenGenerator

use of com.tvd12.ezyfoxserver.service.impl.EzySimpleSessionTokenGenerator in project ezyfox-server by youngmonkeys.

the class EzyHandlerGroupManagerImplTest method newHandlerGroupManager.

public EzyHandlerGroupManager newHandlerGroupManager() {
    EzyNioSessionManager sessionManager = (EzyNioSessionManager) EzyNioSessionManagerImpl.builder().maxRequestPerSecond(new EzySimpleSessionManagementSetting.EzySimpleMaxRequestPerSecond()).tokenGenerator(new EzySimpleSessionTokenGenerator()).build();
    ExEzyByteToObjectDecoder decoder = new ExEzyByteToObjectDecoder();
    EzyCodecFactory codecFactory = mock(EzyCodecFactory.class);
    when(codecFactory.newDecoder(any())).thenReturn(decoder);
    ExecutorService statsThreadPool = EzyExecutors.newSingleThreadExecutor("stats");
    EzySocketStreamQueue streamQueue = new EzyBlockingSocketStreamQueue();
    EzySocketDisconnectionQueue disconnectionQueue = new EzyBlockingSocketDisconnectionQueue();
    EzySessionTicketsRequestQueues sessionTicketsRequestQueues = new EzySessionTicketsRequestQueues();
    EzySimpleSettings settings = new EzySimpleSettings();
    EzySimpleStreamingSetting streaming = settings.getStreaming();
    streaming.setEnable(true);
    EzySimpleServer server = new EzySimpleServer();
    server.setSettings(settings);
    server.setSessionManager(sessionManager);
    EzySimpleServerContext serverContext = new EzySimpleServerContext();
    serverContext.setServer(server);
    serverContext.init();
    EzySessionTicketsQueue socketSessionTicketsQueue = new EzyBlockingSessionTicketsQueue();
    EzySessionTicketsQueue webSocketSessionTicketsQueue = new EzyBlockingSessionTicketsQueue();
    EzyStatistics statistics = new EzySimpleStatistics();
    EzyHandlerGroupBuilderFactory handlerGroupBuilderFactory = EzyHandlerGroupBuilderFactoryImpl.builder().statistics(statistics).statsThreadPool(statsThreadPool).streamQueue(streamQueue).disconnectionQueue(disconnectionQueue).codecFactory(codecFactory).serverContext(serverContext).socketSessionTicketsQueue(socketSessionTicketsQueue).webSocketSessionTicketsQueue(webSocketSessionTicketsQueue).socketSessionTicketsQueue(webSocketSessionTicketsQueue).sessionTicketsRequestQueues(sessionTicketsRequestQueues).build();
    return EzyHandlerGroupManagerImpl.builder().handlerGroupBuilderFactory(handlerGroupBuilderFactory).build();
}
Also used : EzySimpleServer(com.tvd12.ezyfoxserver.EzySimpleServer) EzyHandlerGroupBuilderFactory(com.tvd12.ezyfoxserver.nio.factory.EzyHandlerGroupBuilderFactory) EzySimpleServerContext(com.tvd12.ezyfoxserver.context.EzySimpleServerContext) EzySimpleStreamingSetting(com.tvd12.ezyfoxserver.setting.EzySimpleStreamingSetting) EzyStatistics(com.tvd12.ezyfoxserver.statistics.EzyStatistics) EzyNioSessionManager(com.tvd12.ezyfoxserver.nio.wrapper.EzyNioSessionManager) EzyCodecFactory(com.tvd12.ezyfoxserver.codec.EzyCodecFactory) EzySimpleSettings(com.tvd12.ezyfoxserver.setting.EzySimpleSettings) ExecutorService(java.util.concurrent.ExecutorService) EzySimpleStatistics(com.tvd12.ezyfoxserver.statistics.EzySimpleStatistics) EzySimpleSessionTokenGenerator(com.tvd12.ezyfoxserver.service.impl.EzySimpleSessionTokenGenerator)

Example 5 with EzySimpleSessionTokenGenerator

use of com.tvd12.ezyfoxserver.service.impl.EzySimpleSessionTokenGenerator in project ezyfox-server by youngmonkeys.

the class EzyNioSocketReaderTest method newHandlerGroupManager.

private EzyHandlerGroupManager newHandlerGroupManager() {
    EzyNioSessionManager sessionManager = (EzyNioSessionManager) EzyNioSessionManagerImpl.builder().maxRequestPerSecond(new EzySimpleSessionManagementSetting.EzySimpleMaxRequestPerSecond()).tokenGenerator(new EzySimpleSessionTokenGenerator()).build();
    ExEzyByteToObjectDecoder decoder = new ExEzyByteToObjectDecoder();
    EzyCodecFactory codecFactory = mock(EzyCodecFactory.class);
    when(codecFactory.newDecoder(any())).thenReturn(decoder);
    ExecutorService statsThreadPool = EzyExecutors.newSingleThreadExecutor("stats");
    EzySocketStreamQueue streamQueue = new EzyBlockingSocketStreamQueue();
    EzySocketDisconnectionQueue disconnectionQueue = new EzyBlockingSocketDisconnectionQueue();
    EzySessionTicketsRequestQueues sessionTicketsRequestQueues = new EzySessionTicketsRequestQueues();
    EzySimpleSettings settings = new EzySimpleSettings();
    EzySimpleStreamingSetting streaming = settings.getStreaming();
    streaming.setEnable(true);
    EzySimpleServer server = new EzySimpleServer();
    server.setSettings(settings);
    server.setSessionManager(sessionManager);
    EzySimpleServerContext serverContext = new EzySimpleServerContext();
    serverContext.setServer(server);
    serverContext.init();
    EzySessionTicketsQueue socketSessionTicketsQueue = new EzyBlockingSessionTicketsQueue();
    EzySessionTicketsQueue webSocketSessionTicketsQueue = new EzyBlockingSessionTicketsQueue();
    EzyStatistics statistics = new EzySimpleStatistics();
    EzyHandlerGroupBuilderFactory handlerGroupBuilderFactory = EzyHandlerGroupBuilderFactoryImpl.builder().statistics(statistics).statsThreadPool(statsThreadPool).streamQueue(streamQueue).disconnectionQueue(disconnectionQueue).codecFactory(codecFactory).serverContext(serverContext).socketSessionTicketsQueue(socketSessionTicketsQueue).webSocketSessionTicketsQueue(webSocketSessionTicketsQueue).sessionTicketsRequestQueues(sessionTicketsRequestQueues).build();
    return EzyHandlerGroupManagerImpl.builder().handlerGroupBuilderFactory(handlerGroupBuilderFactory).build();
}
Also used : EzySimpleServer(com.tvd12.ezyfoxserver.EzySimpleServer) EzyHandlerGroupBuilderFactory(com.tvd12.ezyfoxserver.nio.factory.EzyHandlerGroupBuilderFactory) EzySimpleServerContext(com.tvd12.ezyfoxserver.context.EzySimpleServerContext) EzySimpleStreamingSetting(com.tvd12.ezyfoxserver.setting.EzySimpleStreamingSetting) EzyStatistics(com.tvd12.ezyfoxserver.statistics.EzyStatistics) EzyNioSessionManager(com.tvd12.ezyfoxserver.nio.wrapper.EzyNioSessionManager) EzyCodecFactory(com.tvd12.ezyfoxserver.codec.EzyCodecFactory) EzySimpleSettings(com.tvd12.ezyfoxserver.setting.EzySimpleSettings) ExecutorService(java.util.concurrent.ExecutorService) EzySimpleStatistics(com.tvd12.ezyfoxserver.statistics.EzySimpleStatistics) EzySimpleSessionTokenGenerator(com.tvd12.ezyfoxserver.service.impl.EzySimpleSessionTokenGenerator)

Aggregations

EzySimpleSessionTokenGenerator (com.tvd12.ezyfoxserver.service.impl.EzySimpleSessionTokenGenerator)15 EzySimpleServer (com.tvd12.ezyfoxserver.EzySimpleServer)13 EzySimpleServerContext (com.tvd12.ezyfoxserver.context.EzySimpleServerContext)13 EzySimpleSettings (com.tvd12.ezyfoxserver.setting.EzySimpleSettings)13 EzySimpleStreamingSetting (com.tvd12.ezyfoxserver.setting.EzySimpleStreamingSetting)12 EzySimpleStatistics (com.tvd12.ezyfoxserver.statistics.EzySimpleStatistics)12 EzyStatistics (com.tvd12.ezyfoxserver.statistics.EzyStatistics)12 ExecutorService (java.util.concurrent.ExecutorService)12 EzyHandlerGroupBuilderFactory (com.tvd12.ezyfoxserver.nio.factory.EzyHandlerGroupBuilderFactory)11 EzySimpleSessionManagementSetting (com.tvd12.ezyfoxserver.setting.EzySimpleSessionManagementSetting)9 Test (org.testng.annotations.Test)9 EzySessionManager (com.tvd12.ezyfoxserver.wrapper.EzySessionManager)8 BaseTest (com.tvd12.test.base.BaseTest)8 EzyNioSession (com.tvd12.ezyfoxserver.nio.entity.EzyNioSession)7 EzyCodecFactory (com.tvd12.ezyfoxserver.codec.EzyCodecFactory)6 EzySimpleNioHandlerGroup (com.tvd12.ezyfoxserver.nio.handler.EzySimpleNioHandlerGroup)5 EzyNioSessionManager (com.tvd12.ezyfoxserver.nio.wrapper.EzyNioSessionManager)5 ByteBuffer (java.nio.ByteBuffer)5 EzyAbstractSession (com.tvd12.ezyfoxserver.entity.EzyAbstractSession)4 EzySimpleSession (com.tvd12.ezyfoxserver.nio.entity.EzySimpleSession)2