org.apache.thrift.server.ServerContext Java Examples
The following examples show how to use
org.apache.thrift.server.ServerContext.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CatalogThriftEventHandler.java From metacat with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public ServerContext createContext(final TProtocol input, final TProtocol output) { final String userName = "metacat-thrift-interface"; String clientHost = null; //requestContext.getHeaderString("X-Forwarded-For"); final long requestThreadId = Thread.currentThread().getId(); final TTransport transport = input.getTransport(); if (transport instanceof TSocket) { final TSocket thriftSocket = (TSocket) transport; clientHost = thriftSocket.getSocket().getInetAddress().getHostAddress(); } final CatalogServerRequestContext context = new CatalogServerRequestContext( userName, null, clientHost, null, "hive", requestThreadId ); MetacatContextManager.setContext(context); return context; }
Example #2
Source File: InternalSentrySrv.java From incubator-sentry with Apache License 2.0 | 5 votes |
/** * Thrift callback when a client is disconnecting */ @Override public void deleteContext(ServerContext arg0, TProtocol arg1, TProtocol arg2) { clientList.remove(((SentryServerContext) arg0).getContextId()); LOGGER.info("Client Disonnected: " + ((SentryServerContext) arg0).getContextId()); }
Example #3
Source File: InternalSentrySrv.java From incubator-sentry with Apache License 2.0 | 5 votes |
/** * Thrift callback when a new client is connecting */ @Override public ServerContext createContext(TProtocol inputProto, TProtocol outputProto) { clientList.add(clientId.incrementAndGet()); LOGGER.info("Client Connected: " + clientId.get()); return new SentryServerContext(clientId.get()); }
Example #4
Source File: ConfigurationTest.java From ikasoa with MIT License | 4 votes |
@Override public ServerContext createContext(TProtocol arg0, TProtocol arg1) { return null; }
Example #5
Source File: InternalSentrySrv.java From incubator-sentry with Apache License 2.0 | 4 votes |
@Override public void processContext(ServerContext arg0, TTransport arg1, TTransport arg2) { }
Example #6
Source File: ThriftEchoTestServer.java From pinpoint with Apache License 2.0 | 4 votes |
@Override public ServerContext createContext(TProtocol tProtocol, TProtocol tProtocol1) { return null; }
Example #7
Source File: GfxdThriftServerThreadPool.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * Loops on processing a client forever */ @Override public void run() { TProcessor processor = null; TTransport inputTransport = null; TTransport outputTransport = null; TProtocol inputProtocol = null; TProtocol outputProtocol = null; final TServerEventHandler eventHandler = getEventHandler(); ServerContext connectionContext = null; final ConnectionListener listener = connListener; final TTransport client = this.client; Socket clientSocket = null; try { processor = processorFactory_.getProcessor(client); inputTransport = inputTransportFactory_.getTransport(client); outputTransport = outputTransportFactory_.getTransport(client); inputProtocol = inputProtocolFactory_.getProtocol(inputTransport); outputProtocol = outputProtocolFactory_.getProtocol(outputTransport); if (eventHandler != null) { connectionContext = eventHandler.createContext(inputProtocol, outputProtocol); } // register with ConnectionListener if (listener != null) { if (client instanceof GfxdTSocket) { clientSocket = ((GfxdTSocket)client).getSocket(); } else if (client instanceof TSocket) { clientSocket = ((TSocket)client).getSocket(); } listener.connectionOpened(clientSocket, this.connectionNumber); } // we check stopped_ first to make sure we're not supposed to be // shutting down. this is necessary for graceful shutdown. while (true) { if (eventHandler != null) { eventHandler.processContext(connectionContext, inputTransport, outputTransport); } if (stopped || !processor.process(inputProtocol, outputProtocol)) { break; } } } catch (TTransportException tte) { // Assume the client died and continue silently } catch (TException te) { LOGGER.error("Thrift error occurred during processing of message.", te); } catch (Exception e) { LOGGER.error("Error occurred during processing of message.", e); } if (eventHandler != null) { eventHandler.deleteContext(connectionContext, inputProtocol, outputProtocol); } if (inputTransport != null) { inputTransport.close(); } if (outputTransport != null) { outputTransport.close(); } // deregister with ConnectionListener if (listener != null) { listener.connectionClosed(clientSocket, this.connectionNumber); } }
Example #8
Source File: ConfigurationTest.java From ikasoa with MIT License | 4 votes |
@Override public void processContext(ServerContext arg0, TTransport arg1, TTransport arg2) { // Do nothing }
Example #9
Source File: ConfigurationTest.java From ikasoa with MIT License | 4 votes |
@Override public void deleteContext(ServerContext arg0, TProtocol arg1, TProtocol arg2) { // Do nothing }
Example #10
Source File: RPCServiceThriftHandler.java From incubator-iotdb with Apache License 2.0 | 4 votes |
@Override public ServerContext createContext(TProtocol arg0, TProtocol arg1) { // nothing return null; }
Example #11
Source File: GfxdThriftServerThreadPool.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * Loops on processing a client forever */ @Override public void run() { TProcessor processor = null; TTransport inputTransport = null; TTransport outputTransport = null; TProtocol inputProtocol = null; TProtocol outputProtocol = null; final TServerEventHandler eventHandler = getEventHandler(); ServerContext connectionContext = null; final ConnectionListener listener = connListener; final TTransport client = this.client; Socket clientSocket = null; try { processor = processorFactory_.getProcessor(client); inputTransport = inputTransportFactory_.getTransport(client); outputTransport = outputTransportFactory_.getTransport(client); inputProtocol = inputProtocolFactory_.getProtocol(inputTransport); outputProtocol = outputProtocolFactory_.getProtocol(outputTransport); if (eventHandler != null) { connectionContext = eventHandler.createContext(inputProtocol, outputProtocol); } // register with ConnectionListener if (listener != null) { if (client instanceof GfxdTSocket) { clientSocket = ((GfxdTSocket)client).getSocket(); } else if (client instanceof TSocket) { clientSocket = ((TSocket)client).getSocket(); } listener.connectionOpened(clientSocket, this.connectionNumber); } // we check stopped_ first to make sure we're not supposed to be // shutting down. this is necessary for graceful shutdown. while (true) { if (eventHandler != null) { eventHandler.processContext(connectionContext, inputTransport, outputTransport); } if (stopped || !processor.process(inputProtocol, outputProtocol)) { break; } } } catch (TTransportException tte) { // Assume the client died and continue silently } catch (TException te) { LOGGER.error("Thrift error occurred during processing of message.", te); } catch (Exception e) { LOGGER.error("Error occurred during processing of message.", e); } if (eventHandler != null) { eventHandler.deleteContext(connectionContext, inputProtocol, outputProtocol); } if (inputTransport != null) { inputTransport.close(); } if (outputTransport != null) { outputTransport.close(); } // deregister with ConnectionListener if (listener != null) { listener.connectionClosed(clientSocket, this.connectionNumber); } }
Example #12
Source File: CatalogThriftEventHandler.java From metacat with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public void processContext(final ServerContext serverContext, final TTransport inputTransport, final TTransport outputTransport) { validateRequest((CatalogServerRequestContext) serverContext); }
Example #13
Source File: CatalogThriftEventHandler.java From metacat with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public void deleteContext(final ServerContext serverContext, final TProtocol input, final TProtocol output) { validateRequest((CatalogServerRequestContext) serverContext); MetacatContextManager.removeContext(); }
Example #14
Source File: SyncServerThriftHandler.java From incubator-iotdb with Apache License 2.0 | 4 votes |
@Override public void processContext(ServerContext arg0, TTransport arg1, TTransport arg2) { // nothing }
Example #15
Source File: SyncServerThriftHandler.java From incubator-iotdb with Apache License 2.0 | 4 votes |
@Override public void deleteContext(ServerContext arg0, TProtocol arg1, TProtocol arg2) { //release query resources. serviceImpl.handleClientExit(); }
Example #16
Source File: SyncServerThriftHandler.java From incubator-iotdb with Apache License 2.0 | 4 votes |
@Override public ServerContext createContext(TProtocol arg0, TProtocol arg1) { // nothing return null; }
Example #17
Source File: RPCServiceThriftHandler.java From incubator-iotdb with Apache License 2.0 | 4 votes |
@Override public void processContext(ServerContext arg0, TTransport arg1, TTransport arg2) { // nothing }
Example #18
Source File: RPCServiceThriftHandler.java From incubator-iotdb with Apache License 2.0 | 4 votes |
@Override public void deleteContext(ServerContext arg0, TProtocol arg1, TProtocol arg2) { //release query resources. serviceImpl.handleClientExit(); }
Example #19
Source File: ThriftEchoTestServer.java From pinpoint with Apache License 2.0 | 2 votes |
@Override public void deleteContext(ServerContext serverContext, TProtocol tProtocol, TProtocol tProtocol1) { }
Example #20
Source File: ThriftEchoTestServer.java From pinpoint with Apache License 2.0 | 2 votes |
@Override public void processContext(ServerContext serverContext, TTransport tTransport, TTransport tTransport1) { }