List of usage examples for org.apache.thrift.transport THttpClient setConnectTimeout
public void setConnectTimeout(int timeout)
From source file:com.rubenlaguna.en4j.sync.EvernoteProtocolUtil.java
License:Open Source License
private NoteStore.Client getValidNoteStore() throws TTransportException, EDAMUserException, EDAMSystemException, TException { if (isAboutToExpire()) { // Set up the NoteStore AuthenticationResult authResult = getValidAuthenticationResult(); if (null == noteStoreUrl.get()) { //noteStoreUrl must be cached because we don't get a User in //from refreshAuthentication User user = authResult.getUser(); noteStoreUrl.set(noteStoreUrlBase + user.getShardId()); }//from w ww.j a va 2 s . co m THttpClient noteStoreTrans = new THttpClient(noteStoreUrl.get()); noteStoreTrans.setConnectTimeout(30000); //30s noteStoreTrans.setReadTimeout(180 * 1000);//180s TBinaryProtocol noteStoreProt = new TBinaryProtocol(noteStoreTrans); currentNoteStore.set(new NoteStore.Client(noteStoreProt, noteStoreProt)); } return currentNoteStore.get(); }
From source file:org.apache.airavata.cloud.aurora.client.AuroraSchedulerClientFactory.java
License:Apache License
/** * Gets the t protocol.//from w w w . j a v a2 s. co m * * @param connectionUrl the connection url * @param connectionTimeout the connection timeout * @return the t protocol * @throws Exception the exception */ private static TProtocol getTProtocol(String connectionUrl, int connectionTimeout) throws Exception { try { THttpClient client = new THttpClient(connectionUrl); client.setConnectTimeout(connectionTimeout); TTransport transport = client; transport.open(); TProtocol protocol = new TJSONProtocol(transport); return protocol; } catch (Exception ex) { logger.error(ex.getMessage(), ex); throw ex; } }