use of org.apache.thrift.transport.TTransportException in project eiger by wlloyd.
the class TCustomServerSocket method acceptImpl.
@Override
protected TCustomSocket acceptImpl() throws TTransportException {
if (serverSocket_ == null)
throw new TTransportException(TTransportException.NOT_OPEN, "No underlying server socket.");
TCustomSocket tsocket = null;
Socket socket = null;
try {
socket = serverSocket_.accept();
tsocket = new TCustomSocket(socket);
tsocket.setTimeout(0);
} catch (IOException iox) {
throw new TTransportException(iox);
}
try {
socket.setKeepAlive(this.keepAlive);
} catch (SocketException se) {
logger.warn("Failed to set keep-alive on Thrift socket.", se);
}
if (this.sendBufferSize != null) {
try {
socket.setSendBufferSize(this.sendBufferSize.intValue());
} catch (SocketException se) {
logger.warn("Failed to set send buffer size on Thrift socket.", se);
}
}
if (this.recvBufferSize != null) {
try {
socket.setReceiveBufferSize(this.recvBufferSize.intValue());
} catch (SocketException se) {
logger.warn("Failed to set receive buffer size on Thrift socket.", se);
}
}
return tsocket;
}
use of org.apache.thrift.transport.TTransportException in project simba-os by cegeka.
the class SimbaGateway method createAuthenticationService.
/**
* @return always creates a new client
* @throws SimbaUnavailableException
*/
AuthenticationFilterService.Client createAuthenticationService() throws SimbaUnavailableException {
try {
tHttpClient = getTHttpClient();
authenticationFilterService = simbaServiceFactory.createJSONAuthenticationFilterService(tHttpClient);
} catch (TTransportException | RuntimeException e) {
if (tHttpClient != null) {
tHttpClient.close();
}
logger.error("Simba is down?", e);
throw new SimbaUnavailableException(e);
}
return authenticationFilterService;
}
use of org.apache.thrift.transport.TTransportException in project simba-os by cegeka.
the class SimbaGatewayTest method isSimbaAlive_WhenTHttpFlushThrewSocketException_ReturnFalse.
@Test
public void isSimbaAlive_WhenTHttpFlushThrewSocketException_ReturnFalse() throws Exception {
when(simbaServiceFactoryMock.createTHttpClient(SIMBA_WEB_URL + "/" + SIMBA_AUTHENTICATION_SERVICE)).thenThrow(new TTransportException(new SocketException()));
assertThat(simbaGateway.isSimbaAlive()).isFalse();
}
use of org.apache.thrift.transport.TTransportException in project simba-os by cegeka.
the class SimbaGatewayTest method isSimbaAlive_WhenTHttpCouldFlushWithoutSocketException_ReturnTrue.
@Test
public void isSimbaAlive_WhenTHttpCouldFlushWithoutSocketException_ReturnTrue() throws Exception {
when(simbaServiceFactoryMock.createTHttpClient(SIMBA_WEB_URL + "/" + SIMBA_AUTHENTICATION_SERVICE)).thenThrow(new TTransportException("HTTP Response code: 404"));
assertThat(simbaGateway.isSimbaAlive()).isTrue();
}
use of org.apache.thrift.transport.TTransportException in project hbase by apache.
the class TBoundedThreadPoolServer method serve.
public void serve() {
try {
serverTransport_.listen();
} catch (TTransportException ttx) {
LOG.error("Error occurred during listening.", ttx);
return;
}
Runtime.getRuntime().addShutdownHook(new Thread(getClass().getSimpleName() + "-shutdown-hook") {
@Override
public void run() {
TBoundedThreadPoolServer.this.stop();
}
});
stopped = false;
while (!stopped && !Thread.interrupted()) {
TTransport client = null;
try {
client = serverTransport_.accept();
} catch (TTransportException ttx) {
if (!stopped) {
LOG.warn("Transport error when accepting message", ttx);
continue;
} else {
// The server has been stopped
break;
}
}
ClientConnnection command = new ClientConnnection(client);
try {
executorService.execute(command);
} catch (RejectedExecutionException rex) {
if (client.getClass() == TSocket.class) {
// We expect the client to be TSocket.
LOG.warn(QUEUE_FULL_MSG + " from " + ((TSocket) client).getSocket().getRemoteSocketAddress());
} else {
LOG.warn(QUEUE_FULL_MSG, rex);
}
client.close();
}
}
shutdownServer();
}
Aggregations