Skip to content

Commit

Permalink
fix socket timewait for storage client
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicole00 committed Oct 9, 2024
1 parent ace391f commit 75c7783
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ public StorageConnPoolFactory(StoragePoolConfig config) {
@Override
public PooledObject<GraphStorageConnection> makeObject(HostAddress address) throws Exception {
GraphStorageConnection connection = new GraphStorageConnection();
connection.open(
address,
config.getTimeout(),
config.isEnableSSL(),
config.getSslParam());
return new DefaultPooledObject<>(connection);
}

Expand All @@ -47,7 +52,7 @@ public boolean validateObject(HostAddress hostAndPort,
return connection.transport.isOpen();
} catch (Exception e) {
LOGGER.warn(String.format("storage connection with %s:%d is not open",
hostAndPort.getHost(), hostAndPort.getPort()), e);
hostAndPort.getHost(), hostAndPort.getPort()), e);
return false;
}
}
Expand All @@ -56,11 +61,12 @@ public boolean validateObject(HostAddress hostAndPort,
public void activateObject(HostAddress address,
PooledObject<GraphStorageConnection> pooledObject)
throws Exception {
pooledObject.getObject().open(
address,
config.getTimeout(),
config.isEnableSSL(),
config.getSslParam());
if (pooledObject.getObject() == null) {
throw new RuntimeException("The connection is null.");
}
if (!pooledObject.getObject().transport.isOpen()) {
throw new RuntimeException("The connection is broken.");
}
}

@Override
Expand Down

0 comments on commit 75c7783

Please sign in to comment.