Class UnifiedHandler
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.channel.SimpleChannelInboundHandler<RequestMessage>
-
- org.apache.tinkerpop.gremlin.server.handler.UnifiedHandler
-
- All Implemented Interfaces:
io.netty.channel.ChannelHandler
,io.netty.channel.ChannelInboundHandler
@Sharable public class UnifiedHandler extends io.netty.channel.SimpleChannelInboundHandler<RequestMessage>
Handler for websockets to be used with theUnifiedChannelizer
.
-
-
Field Summary
Fields Modifier and Type Field Description protected Channelizer
channelizer
protected GraphManager
graphManager
protected GremlinExecutor
gremlinExecutor
protected static Set<String>
INVALID_BINDINGS_KEYS
This may or may not be the full set of invalid binding keys.protected ScheduledExecutorService
scheduledExecutorService
protected ExecutorService
sessionExecutor
protected ConcurrentMap<String,Session>
sessions
protected Settings
settings
-
Constructor Summary
Constructors Constructor Description UnifiedHandler(Settings settings, GraphManager graphManager, GremlinExecutor gremlinExecutor, ScheduledExecutorService scheduledExecutorService, Channelizer channelizer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
channelRead0(io.netty.channel.ChannelHandlerContext ctx, RequestMessage msg)
protected Session
createMultiTaskSession(SessionTask sessionTask, String sessionId)
Called when creating aSession
that will be long-lived to extend over multiple requests and therefore process the providedSessionTask
as well as ones that may arrive in the future.protected Session
createSingleTaskSession(SessionTask sessionTask, String sessionId)
Called when creating a single task session where the providedSessionTask
will be the only one to be executed and can therefore take a more efficient execution path.int
getActiveSessionCount()
boolean
isActiveSession(String sessionId)
void
userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt)
protected void
validateRequest(RequestMessage message, GraphManager graphManager)
-
Methods inherited from class io.netty.channel.SimpleChannelInboundHandler
acceptInboundMessage, channelRead
-
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
-
-
-
-
Field Detail
-
settings
protected final Settings settings
-
graphManager
protected final GraphManager graphManager
-
gremlinExecutor
protected final GremlinExecutor gremlinExecutor
-
scheduledExecutorService
protected final ScheduledExecutorService scheduledExecutorService
-
sessionExecutor
protected final ExecutorService sessionExecutor
-
channelizer
protected final Channelizer channelizer
-
sessions
protected final ConcurrentMap<String,Session> sessions
-
INVALID_BINDINGS_KEYS
protected static final Set<String> INVALID_BINDINGS_KEYS
This may or may not be the full set of invalid binding keys. It is dependent on the static imports made to Gremlin Server. This should get rid of the worst offenders though and provide a good message back to the calling client. Use oftoUpperCase()
on the accessor values ofT
solves an issue where theScriptEngine
ignores private scope onT
and imports static fields.
-
-
Constructor Detail
-
UnifiedHandler
public UnifiedHandler(Settings settings, GraphManager graphManager, GremlinExecutor gremlinExecutor, ScheduledExecutorService scheduledExecutorService, Channelizer channelizer)
-
-
Method Detail
-
channelRead0
protected void channelRead0(io.netty.channel.ChannelHandlerContext ctx, RequestMessage msg) throws Exception
- Specified by:
channelRead0
in classio.netty.channel.SimpleChannelInboundHandler<RequestMessage>
- Throws:
Exception
-
validateRequest
protected void validateRequest(RequestMessage message, GraphManager graphManager) throws SessionException
- Throws:
SessionException
-
userEventTriggered
public void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt) throws Exception
- Specified by:
userEventTriggered
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
userEventTriggered
in classio.netty.channel.ChannelInboundHandlerAdapter
- Throws:
Exception
-
createSingleTaskSession
protected Session createSingleTaskSession(SessionTask sessionTask, String sessionId)
Called when creating a single task session where the providedSessionTask
will be the only one to be executed and can therefore take a more efficient execution path.
-
createMultiTaskSession
protected Session createMultiTaskSession(SessionTask sessionTask, String sessionId)
Called when creating aSession
that will be long-lived to extend over multiple requests and therefore process the providedSessionTask
as well as ones that may arrive in the future.
-
isActiveSession
public boolean isActiveSession(String sessionId)
-
getActiveSessionCount
public int getActiveSessionCount()
-
-