private static TTransportException rewriteException(TTransportException e, HostAndPort address) { return new TTransportException(e.getType(), String.format("%s: %s", address, e.getMessage()), e); }
getSaslProperties()); } catch (TTransportException e) { throw new LoginException(e.getMessage());
@Test public void testRunThriftServerWithHeaderBufferLength() throws Exception { // Test thrift server with HTTP header length less than 64k try { runThriftServer(1024 * 63); } catch (TTransportException tex) { assertFalse(tex.getMessage().equals("HTTP Response code: 431")); } // Test thrift server with HTTP header length more than 64k, expect an exception exception.expect(TTransportException.class); exception.expectMessage("HTTP Response code: 431"); runThriftServer(1024 * 64); }
log.debug("Server : {} msg : {}", server, e.getMessage()); timeoutTracker.errorOccured(); throw new IOException(e);
log.warn("Error attempting to create server at {}. Error: {}", address, e.getMessage());
if (e.getMessage().startsWith("Cannot read. Remote side has closed")) { if (transport != null) { totalRead = transport.getBytesRead();
public TransfortWrapper(TTransport transport, String host, int port,boolean isOpen) { this.transport = transport; this.host = host; this.port = port; this.lastUseTime =new Date(); if (isOpen) { try { transport.open(); } catch (TTransportException e) { //e.printStackTrace(); System.err.println(host + ":" + port + " " + e.getMessage()); isDead =true; } } }
private static TTransportException rewriteException(TTransportException e, HostAndPort address) { return new TTransportException(e.getType(), String.format("%s: %s", address, e.getMessage()), e); }
/** * Helper method to create a {@link org.apache.thrift.transport.TServerSocket} for the RPC server * * @return a thrift server socket */ private TServerSocket createThriftServerSocket() { try { return new TServerSocket(NetworkAddressUtils.getBindAddress(ServiceType.WORKER_RPC, mTachyonConf)); } catch (TTransportException tte) { LOG.error(tte.getMessage(), tte); throw Throwables.propagate(tte); } } }
private static TTransportException rewriteException(final TTransportException e, final String host) { return new TTransportException(e.getType(), String.format("%s: %s", host, e.getMessage()), e.getCause()); }
private static TTransportException rewriteException(TTransportException e, String host) { return new TTransportException(e.getType(), String.format("%s: %s", host, e.getMessage()), e.getCause()); }
private static TTransportException rewriteException(final TTransportException e, final String host) { return new TTransportException(e.getType(), String.format("%s: %s", host, e.getMessage()), e.getCause()); }
public TTransportFactory getAuthTransFactory() throws LoginException { TTransportFactory transportFactory; if (authTypeStr.equalsIgnoreCase(AuthTypes.KERBEROS.getAuthName())) { try { transportFactory = saslServer.createTransportFactory(getSaslProperties()); } catch (TTransportException e) { throw new LoginException(e.getMessage()); } } else if (authTypeStr.equalsIgnoreCase(AuthTypes.NONE.getAuthName())) { transportFactory = PlainSaslHelper.getPlainTransportFactory(authTypeStr); } else if (authTypeStr.equalsIgnoreCase(AuthTypes.LDAP.getAuthName())) { transportFactory = PlainSaslHelper.getPlainTransportFactory(authTypeStr); } else if (authTypeStr.equalsIgnoreCase(AuthTypes.PAM.getAuthName())) { transportFactory = PlainSaslHelper.getPlainTransportFactory(authTypeStr); } else if (authTypeStr.equalsIgnoreCase(AuthTypes.NOSASL.getAuthName())) { transportFactory = new TTransportFactory(); } else if (authTypeStr.equalsIgnoreCase(AuthTypes.CUSTOM.getAuthName())) { transportFactory = PlainSaslHelper.getPlainTransportFactory(authTypeStr); } else { throw new LoginException("Unsupported authentication type " + authTypeStr); } return transportFactory; }
public TTransportFactory getAuthTransFactory() throws LoginException { TTransportFactory transportFactory; if (authTypeStr.equalsIgnoreCase(AuthTypes.KERBEROS.getAuthName())) { try { transportFactory = saslServer.createTransportFactory(getSaslProperties()); } catch (TTransportException e) { throw new LoginException(e.getMessage()); } } else if (authTypeStr.equalsIgnoreCase(AuthTypes.NONE.getAuthName())) { transportFactory = PlainSaslHelper.getPlainTransportFactory(authTypeStr); } else if (authTypeStr.equalsIgnoreCase(AuthTypes.LDAP.getAuthName())) { transportFactory = PlainSaslHelper.getPlainTransportFactory(authTypeStr); } else if (authTypeStr.equalsIgnoreCase(AuthTypes.PAM.getAuthName())) { transportFactory = PlainSaslHelper.getPlainTransportFactory(authTypeStr); } else if (authTypeStr.equalsIgnoreCase(AuthTypes.NOSASL.getAuthName())) { transportFactory = new TTransportFactory(); } else if (authTypeStr.equalsIgnoreCase(AuthTypes.CUSTOM.getAuthName())) { transportFactory = PlainSaslHelper.getPlainTransportFactory(authTypeStr); } else { throw new LoginException("Unsupported authentication type " + authTypeStr); } return transportFactory; }
@Override public Object createClient(String protocol, String hostName, int port) throws DataEndpointException, DataEndpointAgentConfigurationException { if (protocol.equalsIgnoreCase(DataEndpointConfiguration.Protocol.TCP.toString())) { int socketTimeout = AgentHolder.getInstance().getDataEndpointAgent(DataEndpointConstants.THRIFT_DATA_AGENT_TYPE). getAgentConfiguration().getSocketTimeoutMS(); TTransport receiverTransport = new TSocket(hostName, port, socketTimeout); TProtocol tProtocol = new TBinaryProtocol(receiverTransport); ThriftEventTransmissionService.Client client = new ThriftEventTransmissionService.Client(tProtocol); try { receiverTransport.open(); } catch (TTransportException e) { throw new DataEndpointException("Error while making the connection." + e.getMessage(), e); } return client; } throw new DataEndpointException("Unsupported protocol :" + protocol + " used to authenticate the client, only " + DataEndpointConfiguration.Protocol.TCP.toString() + " is supported"); }
@Override public Object createClient(String protocol, String hostName, int port) throws DataEndpointException, DataEndpointAgentConfigurationException { if (protocol.equalsIgnoreCase(DataEndpointConfiguration.Protocol.TCP.toString())) { int socketTimeout = AgentHolder.getInstance(). getDataEndpointAgent(DataEndpointConstants.THRIFT_DATA_AGENT_TYPE). getAgentConfiguration().getSocketTimeoutMS(); TTransport receiverTransport = new TSocket(hostName, port, socketTimeout); TProtocol tProtocol = new TBinaryProtocol(receiverTransport); ThriftEventTransmissionService.Client client = new ThriftEventTransmissionService.Client(tProtocol); try { receiverTransport.open(); } catch (TTransportException e) { throw new DataEndpointException("Error while making the connection." + e.getMessage(), e); } return client; } throw new DataEndpointException("Unsupported protocol :" + protocol + " used to authenticate the client, only " + DataEndpointConfiguration.Protocol.TCP.toString() + " is supported"); }
public ThriftKeyValidatorClient() throws APISecurityException { try { thriftUtils = ThriftUtils.getInstance(); sessionId = thriftUtils.getSessionId(); //create new APIKeyValidator client TSSLTransportFactory.TSSLTransportParameters param = new TSSLTransportFactory.TSSLTransportParameters(); param.setTrustStore(thriftUtils.getTrustStorePath(), thriftUtils.getTrustStorePassword()); TTransport transport = TSSLTransportFactory.getClientSocket( ThriftUtils.getThriftServerHost(), thriftUtils.getThriftPort(), thriftUtils.getThriftClientConnectionTimeOut(), param); //TProtocol protocol = new TCompactProtocol(transport); //TODO:needs to decide on the optimum protocol. TProtocol protocol = new TBinaryProtocol(transport); //create thrift based entitlement service client and invoke keyValClient = new APIKeyValidationService.Client(protocol); } catch (TTransportException e) { log.error("Could not connect to Thrift host", e); throw new APISecurityException(APISecurityConstants.API_AUTH_GENERAL_ERROR, e.getMessage(), e); } }
@Test public void testRunThriftServerWithHeaderBufferLength() throws Exception { // Test thrift server with HTTP header length less than 64k try { runThriftServer(1024 * 63); } catch (TTransportException tex) { assertFalse(tex.getMessage().equals("HTTP Response code: 431")); } // Test thrift server with HTTP header length more than 64k, expect an exception exception.expect(TTransportException.class); exception.expectMessage("HTTP Response code: 431"); runThriftServer(1024 * 64); }
public ThriftKeyValidatorClient() throws APISecurityException { try { thriftUtils = ThriftUtils.getInstance(); sessionId = thriftUtils.getSessionId(); //create new APIKeyValidator client TSSLTransportFactory.TSSLTransportParameters param = new TSSLTransportFactory.TSSLTransportParameters(); param.setTrustStore(thriftUtils.getTrustStorePath(), thriftUtils.getTrustStorePassword()); TTransport transport = TSSLTransportFactory.getClientSocket( thriftUtils.getThriftServerHost(), thriftUtils.getThriftPort(), thriftUtils.getThriftClientConnectionTimeOut(), param); //TProtocol protocol = new TCompactProtocol(transport); //TODO:needs to decide on the optimum protocol. TProtocol protocol = new TBinaryProtocol(transport); //create thrift based entitlement service client and invoke keyValClient = new APIKeyValidationService.Client(protocol); } catch (TTransportException e) { throw new APISecurityException(APISecurityConstants.API_AUTH_GENERAL_ERROR, e.getMessage()); } }
@Test public void testRunThriftServerWithHeaderBufferLength() throws Exception { // Test thrift server with HTTP header length less than 64k try { runThriftServer(1024 * 63); } catch (TTransportException tex) { assertFalse(tex.getMessage().equals("HTTP Response code: 431")); } // Test thrift server with HTTP header length more than 64k, expect an exception exception.expect(TTransportException.class); exception.expectMessage("HTTP Response code: 431"); runThriftServer(1024 * 64); }