public void run() { try { TServerSocket serverTransport = new TServerSocket(port); Factory protFactory = new TBinaryProtocol.Factory(true, true); TServer server = new TThreadPoolServer(processor, serverTransport, protFactory); System.out.println("Starting " + name + " server on port " + port + " ..."); server.serve(); } catch( TTransportException tte ){ tte.printStackTrace(); } } };
public static void main(String[] args) { TTransport transport; try { transport = new TSocket("localhost", 2000); TProtocol protocol = new TBinaryProtocol(transport); Suggestor.Client client = new Suggestor.Client(protocol); transport.open(); List<String> suggestions = client.complete(args[0], "text"); transport.close(); System.out.println(suggestions); } catch (TTransportException e) { e.printStackTrace(); } catch (TException e) { e.printStackTrace(); } }
printHelp(getOptions(),exp.getMessage()); } catch (TTransportException e) { e.printStackTrace(); } catch (TException e) { e.printStackTrace();
/** * Accept a new connection. */ private void handleAccept() throws IOException { SelectionKey clientKey = null; TNonblockingTransport client = null; try { // accept the connection client = (TNonblockingTransport)serverTransport.accept(); clientKey = client.registerSelector(selector, SelectionKey.OP_READ); // add this key to the map FrameBuffer frameBuffer = createFrameBuffer(client, clientKey, SelectAcceptThread.this); clientKey.attach(frameBuffer); } catch (TTransportException tte) { // something went wrong accepting. LOGGER.warn("Exception trying to accept!", tte); tte.printStackTrace(); if (clientKey != null) cleanupSelectionKey(clientKey); if (client != null) client.close(); } } } // SelectAcceptThread
public void run() { try { TServerSocket serverTransport = new TServerSocket(SuggestorServer.this.port); Suggestor.Processor processor = new Suggestor.Processor(new SuggestorImpl(SuggestorServer.this.suggestor)); Factory protFactory = new TBinaryProtocol.Factory(true, true); TServer server = new TThreadPoolServer(processor, serverTransport, protFactory); System.out.println("Starting suggestor server on port " + SuggestorServer.this.port + " ..."); server.serve(); } catch( TTransportException tte ){ tte.printStackTrace(); } } };
public void run() { try { TServerSocket serverTransport = new TServerSocket(IndexerServer.this.port); Indexer.Processor processor = new Indexer.Processor(new IndexerImpl(ie, IndexerServer.this.indexer)); Factory protFactory = new TBinaryProtocol.Factory(true, true); TServer server = new TThreadPoolServer(processor, serverTransport, protFactory); System.out.println("Starting indexer server on port " + IndexerServer.this.port + " ..."); server.serve(); } catch( TTransportException tte ){ tte.printStackTrace(); } } } ;
public void run() { try { TServerSocket serverTransport = new TServerSocket(SearcherServer.this.port); Searcher.Processor processor = new Searcher.Processor(new SearcherImpl(SearcherServer.this.searcher)); Factory protFactory = new TBinaryProtocol.Factory(true, true); TServer server = new TThreadPoolServer(processor, serverTransport, protFactory); System.out.println("Starting searcher server on port " + SearcherServer.this.port + " ..."); server.serve(); } catch( TTransportException tte ){ tte.printStackTrace(); } } };
Notebook nb = new Notebook(); nb.setName("My Test Notebook"); try { AsyncNoteStoreClient asyncNoteStoreClient = mEvernoteSession.getClientFactory().createNoteStoreClient(); asyncNoteStoreClient.createNotebook(nb, new OnClientCallback<Notebook>() { @Override public void onSuccess(Notebook data) { Log.i(TAG, "onSucceess"); } @Override public void onException(Exception exception) { Log.i(TAG, "onException"); } }); } catch (TTransportException e) { e.printStackTrace(); }
public static GfacService.Client createGFacClient(String serverHost, int serverPort){ try { TTransport transport = new TSocket(serverHost, serverPort); transport.open(); TProtocol protocol = new TBinaryProtocol(transport); return new GfacService.Client(protocol); } catch (TTransportException e) { e.printStackTrace(); } return null; } }
@Override public void run() { try { CommandLine.displayWelcomeBanner(); System.out.println("System ID: " + GlobalState.SYSTEM_ID); server.start(); } catch (TTransportException e) { e.printStackTrace(); System.exit(-1); } }
public InterpreterService.Client getInterpreterServiceClient (){ try { TTransport transport = new TSocket("localhost", THRIFT_SERVER_PORT); transport.open(); TProtocol protocol = new TBinaryProtocol(transport); return new InterpreterService.Client(protocol); } catch (TTransportException e) { e.printStackTrace(); } return null; } }
private boolean fillTokenizer() { try { int length = trans.read(buf, 0, buf.length); if (length <= 0) { tokenizer = new StringTokenizer("", separator, true); return false; } String row; try { row = Text.decode(buf, 0, length); } catch (CharacterCodingException e) { throw new RuntimeException(e); } tokenizer = new StringTokenizer(row, separator, true); } catch (TTransportException e) { if(e.getType() == TTransportException.END_OF_FILE){ tokenizer = new StringTokenizer("", separator, true); return false; } e.printStackTrace(); tokenizer = null; return false; } return true; }
/** * Re-connect to Zipkin. */ private void startClient() { if (this.scribeClient == null) { TTransport transport = new TFramedTransport(new TSocket(collectorHostname, collectorPort)); try { transport.open(); } catch (TTransportException e) { e.printStackTrace(); } TProtocol protocol = protocolFactory.getProtocol(transport); this.scribeClient = new Scribe.Client(protocol); } } }
private void startThriftServer() { try { TServerSocket serverTransport = new TServerSocket(7911); ReceiverService.Processor processor = new ReceiverService.Processor(service); TBinaryProtocol.Factory protFactory = new TBinaryProtocol.Factory(true, true); TServer server = new TThreadPoolServer(processor, serverTransport, protFactory); System.out.println("Starting server on port 7911 ..."); server.serve(); } catch (TTransportException e) { e.printStackTrace(); } } }
/** * Accept a new connection. */ private void handleAccept() throws IOException { SelectionKey clientKey = null; TNonblockingTransport client = null; try { // accept the connection client = (TNonblockingTransport)serverTransport.accept(); clientKey = client.registerSelector(selector, SelectionKey.OP_READ); // add this key to the map FrameBuffer frameBuffer = new FrameBuffer(client, clientKey); clientKey.attach(frameBuffer); } catch (TTransportException tte) { // something went wrong accepting. LOGGER.warn("Exception trying to accept!", tte); tte.printStackTrace(); if (clientKey != null) cleanupSelectionkey(clientKey); if (client != null) client.close(); } }
/** * Accept a new connection. */ private void handleAccept() throws IOException { SelectionKey clientKey = null; TNonblockingTransport client = null; try { // accept the connection client = (TNonblockingTransport)serverTransport.accept(); clientKey = client.registerSelector(selector, SelectionKey.OP_READ); // add this key to the map FrameBuffer frameBuffer = new FrameBuffer(client, clientKey); clientKey.attach(frameBuffer); } catch (TTransportException tte) { // something went wrong accepting. LOGGER.warn("Exception trying to accept!", tte); tte.printStackTrace(); if (clientKey != null) cleanupSelectionkey(clientKey); if (client != null) client.close(); } }
/** * Accept a new connection. */ private void handleAccept() throws IOException { SelectionKey clientKey = null; TNonblockingTransport client = null; try { // accept the connection client = (TNonblockingTransport)serverTransport.accept(); clientKey = client.registerSelector(selector, SelectionKey.OP_READ); // add this key to the map FrameBuffer frameBuffer = new FrameBuffer(client, clientKey); clientKey.attach(frameBuffer); } catch (TTransportException tte) { // something went wrong accepting. LOGGER.warn("Exception trying to accept!", tte); tte.printStackTrace(); if (clientKey != null) cleanupSelectionkey(clientKey); if (client != null) client.close(); } }
public static void main(String[] args) { TSocket socket = new TSocket("192.168.0.100", 9160); TBinaryProtocol tBinaryProtocol = new TBinaryProtocol(socket, true, true); TTransport transport = socket; try { transport.open(); Cassandra.Client client = new Cassandra.Client(tBinaryProtocol); Map<String, List<String>> schemaVersions= client.describe_schema_versions(); transport.close(); } catch (TTransportException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } catch (TException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } catch (InvalidRequestException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } }
public static void testSSHCredential (CredentialStoreService.Client client){ try { SSHCredential sshCredential = new SSHCredential(); sshCredential.setUsername("test"); sshCredential.setGatewayId("testGateway"); sshCredential.setPassphrase("mypassphrase"); String token = client.addSSHCredential(sshCredential); System.out.println("SSH Token :" + token); SSHCredential credential = client.getSSHCredential(token, "testGateway"); Map<String, String> allSSHKeysForGateway = client.getAllSSHKeysForGateway(sshCredential.getGatewayId()); System.out.println("private key : " + credential.getPrivateKey()); System.out.println("public key : " + credential.getPublicKey()); }catch (TTransportException e) { e.printStackTrace(); } catch (TException e) { e.printStackTrace(); } }
/** * 验证对象有效性 * @param pooledObject * @return */ public boolean validateObject(PooledObject<TProtocol> pooledObject){ if (pooledObject.getObject() != null){ if (pooledObject.getObject().getTransport().isOpen()){ return true; } try { pooledObject.getObject().getTransport().open(); return true; } catch (TTransportException e) { e.printStackTrace(); } } return false; } }