Package one.nio.rpc
Class RpcSession<S,M>
- java.lang.Object
-
- one.nio.net.Session
-
- one.nio.rpc.RpcSession<S,M>
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class RpcSession<S,M> extends Session
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classRpcSession.AsyncRequest-
Nested classes/interfaces inherited from class one.nio.net.Session
Session.ArrayQueueItem, Session.QueueItem
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[]bufferprotected static intBUFFER_SIZEprotected intbytesReadprotected static byteHTTP_REQUEST_UIDprotected static org.slf4j.LoggerlogSerializeprotected java.net.InetSocketAddresspeerprotected booleanproxyProtocolprotected intrequestSizeprotected longrequestStartTimeprotected RpcServer<S>server-
Fields inherited from class one.nio.net.Session
ACTIVE, closing, CLOSING, EVENT_MASK, events, eventsToListen, IDLE, lastAccessTime, log, queueHead, READABLE, selector, slot, socket, SSL, STALE, wasSelected, WRITEABLE
-
-
Constructor Summary
Constructors Constructor Description RpcSession(Socket socket, RpcServer<S> server)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private byte[]expandBuffer(int requestSize)protected voidhandleDeserializationException(java.lang.Exception e)protected voidhandleRejectedExecution(java.util.concurrent.RejectedExecutionException e, java.lang.Object request)protected voidinvoke(java.lang.Object request, M meta)protected booleanisAsyncRequest(java.lang.Object request)protected MonRequestRead()private voidparseProxyProtocol()protected voidprocessRead(byte[] unusedBuffer)private intreadHttpHeader()private static booleanstartsWith(byte[] buffer, int from, java.lang.String s)protected voidstreamCommunicate(StreamProxy streamProxy)protected intwriteResponse(java.lang.Object response)-
Methods inherited from class one.nio.net.Session
checkStatus, close, getQueueStats, getRemoteHost, handleException, isSsl, lastAccessTime, listen, process, processWrite, read, readRaw, scheduleClose, socket, write, write, write
-
-
-
-
Field Detail
-
logSerialize
protected static final org.slf4j.Logger logSerialize
-
BUFFER_SIZE
protected static final int BUFFER_SIZE
- See Also:
- Constant Field Values
-
HTTP_REQUEST_UID
protected static final byte HTTP_REQUEST_UID
-
peer
protected java.net.InetSocketAddress peer
-
proxyProtocol
protected boolean proxyProtocol
-
buffer
protected byte[] buffer
-
bytesRead
protected int bytesRead
-
requestSize
protected int requestSize
-
requestStartTime
protected long requestStartTime
-
-
Method Detail
-
processRead
protected void processRead(byte[] unusedBuffer) throws java.lang.Exception- Overrides:
processReadin classSession- Throws:
java.lang.Exception
-
parseProxyProtocol
private void parseProxyProtocol() throws java.io.IOException- Throws:
java.io.IOException
-
expandBuffer
private byte[] expandBuffer(int requestSize)
-
readHttpHeader
private int readHttpHeader() throws java.io.IOException- Throws:
java.io.IOException
-
startsWith
private static boolean startsWith(byte[] buffer, int from, java.lang.String s)
-
isAsyncRequest
protected boolean isAsyncRequest(java.lang.Object request)
-
onRequestRead
protected M onRequestRead()
-
writeResponse
protected int writeResponse(java.lang.Object response) throws java.io.IOException- Throws:
java.io.IOException
-
streamCommunicate
protected void streamCommunicate(StreamProxy streamProxy) throws java.io.IOException
- Throws:
java.io.IOException
-
invoke
protected void invoke(java.lang.Object request, M meta) throws java.lang.Exception- Throws:
java.lang.Exception
-
handleDeserializationException
protected void handleDeserializationException(java.lang.Exception e) throws java.io.IOException- Throws:
java.io.IOException
-
handleRejectedExecution
protected void handleRejectedExecution(java.util.concurrent.RejectedExecutionException e, java.lang.Object request) throws java.io.IOException- Throws:
java.io.IOException
-
-