use of org.apache.thrift.transport.TTransport in project pinpoint by naver.
the class TProtocolReadMessageEndInterceptor method recordRootSpan.
private void recordRootSpan(final Trace trace, final ThriftRequestProperty parentTraceInfo, Object target) {
// begin root span
SpanRecorder recorder = trace.getSpanRecorder();
recorder.recordServiceType(ThriftConstants.THRIFT_SERVER);
recorder.recordApi(this.thriftServerEntryMethodDescriptor);
if (!trace.isRoot()) {
recordParentInfo(recorder, parentTraceInfo);
}
// record connection information here as the socket may be closed by the time the Span is popped in
// TBaseAsyncProcessorProcessInterceptor's after section.
TTransport transport = ((TProtocol) target).getTransport();
recordConnection(recorder, transport);
}
use of org.apache.thrift.transport.TTransport in project pinpoint by naver.
the class WrappedTTransportConstructInterceptor method after.
@Override
public final void after(Object target, Object[] args, Object result, Throwable throwable) {
if (validateTransport(target)) {
TTransport wrappedTransport = getWrappedTransport(args);
if (validateTransport(wrappedTransport)) {
Socket socket = ((SocketFieldAccessor) wrappedTransport)._$PINPOINT$_getSocket();
((SocketFieldAccessor) target)._$PINPOINT$_setSocket(socket);
}
}
}
use of org.apache.thrift.transport.TTransport in project alluxio by Alluxio.
the class ThriftClientPool method createNewResource.
/**
* Creates a thrift client instance.
*
* @return the thrift client created
* @throws IOException if it fails to create a thrift client
*/
@Override
protected T createNewResource() throws IOException {
TTransport transport = mTransportProvider.getClientTransport(mParentSubject, mAddress);
TProtocol binaryProtocol = new TBinaryProtocol(transport);
T client = createThriftClient(new TMultiplexedProtocol(binaryProtocol, mServiceName));
TException exception;
RetryPolicy retryPolicy = new ExponentialBackoffRetry(BASE_SLEEP_MS, MAX_SLEEP_MS, RPC_MAX_NUM_RETRY);
do {
LOG.info("Alluxio client (version {}) is trying to connect with {} {} @ {}", RuntimeConstants.VERSION, mServiceName, mAddress);
try {
if (!transport.isOpen()) {
transport.open();
}
if (transport.isOpen()) {
checkVersion(client);
}
LOG.info("Client registered with {} @ {}", mServiceName, mAddress);
return client;
} catch (TTransportException e) {
if (e.getCause() instanceof java.net.SocketTimeoutException) {
// Do not retry if socket timeout.
String message = "Thrift transport open times out. Please check whether the " + "authentication types match between client and server. Note that NOSASL client " + "is not able to connect to servers with SIMPLE security mode.";
throw new IOException(message, e);
}
LOG.warn("Failed to connect ({}) to {} @ {}: {}", retryPolicy.getRetryCount(), mServiceName, mAddress, e.getMessage());
exception = e;
}
} while (retryPolicy.attemptRetry());
LOG.error("Failed after " + retryPolicy.getRetryCount() + " retries.");
Preconditions.checkNotNull(exception);
throw new IOException(exception);
}
use of org.apache.thrift.transport.TTransport in project alluxio by Alluxio.
the class TransportProviderTest method customAuthenticationEmptyPassword.
/**
* In CUSTOM mode, if client's password is empty, an exception should be thrown in server side.
*/
@Test
public void customAuthenticationEmptyPassword() throws Exception {
Configuration.set(PropertyKey.SECURITY_AUTHENTICATION_TYPE, AuthType.CUSTOM.getAuthName());
Configuration.set(PropertyKey.SECURITY_AUTHENTICATION_CUSTOM_PROVIDER_CLASS, ExactlyMatchAuthenticationProvider.class.getName());
mTransportProvider = TransportProvider.Factory.create();
// start server
startServerThread();
// check case that password is empty
mThrown.expect(TTransportException.class);
mThrown.expectMessage("Peer indicated failure: Plain authentication failed: No password provided");
TTransport client = ((PlainSaslTransportProvider) mTransportProvider).getClientTransport(ExactlyMatchAuthenticationProvider.USERNAME, "", mServerAddress);
try {
client.open();
} finally {
mServer.stop();
}
}
use of org.apache.thrift.transport.TTransport in project alluxio by Alluxio.
the class TransportProviderTest method customAuthenticationExactNamePasswordMatch.
/**
* In CUSTOM mode, the TTransport mechanism is PLAIN. When server authenticate the connected
* client user, it use configured AuthenticationProvider. If the username:password pair matches, a
* connection should be built.
*/
@Test
public void customAuthenticationExactNamePasswordMatch() throws Exception {
Configuration.set(PropertyKey.SECURITY_AUTHENTICATION_TYPE, AuthType.CUSTOM.getAuthName());
Configuration.set(PropertyKey.SECURITY_AUTHENTICATION_CUSTOM_PROVIDER_CLASS, ExactlyMatchAuthenticationProvider.class.getName());
mTransportProvider = TransportProvider.Factory.create();
// start server
startServerThread();
// when connecting, authentication happens. User's name:pwd pair matches and auth pass.
TTransport client = ((PlainSaslTransportProvider) mTransportProvider).getClientTransport(ExactlyMatchAuthenticationProvider.USERNAME, ExactlyMatchAuthenticationProvider.PASSWORD, mServerAddress);
client.open();
Assert.assertTrue(client.isOpen());
// clean up
client.close();
mServer.stop();
}
Aggregations