Loading kinetic-client/src/main/java/com/seagate/kinetic/client/io/provider/nio/tcp/TcpNioTransportProvider.java +96 −83 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import io.netty.channel.EventLoopGroup; import io.netty.channel.socket.nio.NioSocketChannel; import java.io.IOException; import java.net.InetSocketAddress; import java.util.logging.Level; import java.util.logging.Logger; Loading Loading @@ -92,7 +93,23 @@ public class TcpNioTransportProvider implements ClientTransportProvider { bootstrap.group(workerGroup).channel(NioSocketChannel.class) .handler(nioChannelInitializer); if (config.getLocalAddress() == null) { channel = bootstrap.connect(host, port).sync().channel(); } else { // remote address InetSocketAddress remote = new InetSocketAddress(host, port); // remote port InetSocketAddress local = new InetSocketAddress( config.getLocalAddress(), config.getLocalPort()); channel = bootstrap.connect(remote, local).sync().channel(); logger.info("connected to remote with local address: " + config.getLocalAddress() + ", local port=" + config.getLocalPort()); } } catch (Exception e) { // release allocated resources Loading @@ -101,9 +118,7 @@ public class TcpNioTransportProvider implements ClientTransportProvider { } logger.info("TcpNio client transport provider connecting to host:port =" + host + ":" + port); + host + ":" + port); } /** Loading Loading @@ -134,16 +149,14 @@ public class TcpNioTransportProvider implements ClientTransportProvider { } logger.info("Kinetic nio client transport provider closed, url =" + host + ":" + port); + host + ":" + port); } /** * {@inheritDoc} */ @Override public void init(ClientMessageService mservice) throws KineticException { public void init(ClientMessageService mservice) throws KineticException { this.mservice = mservice; Loading kinetic-client/src/main/java/kinetic/client/ClientConfiguration.java +450 −392 Original line number Diff line number Diff line Loading @@ -49,7 +49,8 @@ public class ClientConfiguration extends Properties { /** * current supported kinetic protocol version on kinetic-protocol repo. */ public static final String PROTOCOL_VERSION = Kinetic.Local.getDefaultInstance().getProtocolVersion(); public static final String PROTOCOL_VERSION = Kinetic.Local .getDefaultInstance().getProtocolVersion(); /** * current supported protocol source commit hash on kinetic-protocol repo. Loading @@ -62,6 +63,12 @@ public class ClientConfiguration extends Properties { // kinetic server port private int port = 8123; // local address used to connect to server private String localAddress = null; // local port used to connect to server private int localPort = 0; // user id private long userId = 1; Loading @@ -86,7 +93,6 @@ public class ClientConfiguration extends Properties { */ private volatile boolean useSsl = Boolean.getBoolean("kinetic.io.ssl"); /** * ssl default port if useSsl is set to true. */ Loading Loading @@ -143,6 +149,51 @@ public class ClientConfiguration extends Properties { this.host = host; } /** * Set local address client used to connect to server. * * @param localAddress * local address client used to connect to server */ public void setLocalAddress(String localAddress) { this.localAddress = localAddress; } /** * Set local address port client used to connect to the server. * * @param localPort * local address port client used to connect to the server */ public void setLocalPort(int localPort) { this.localPort = localPort; } /** * Get local address client used to connect to server. * <p> * The local address the socket is bound to, or null for the anyLocal * address. Default is set to null. * * @return local address client used to connect to server. */ public String getLocalAddress() { return this.localAddress; } /** * * Get local port client used to connect to server. * <p> * The local port the socket is bound to or zero for a system selected free * port. * * @return local port local port client used to connect to server */ public int getLocalPort() { return this.localPort; } /** * Set server port. * Loading Loading @@ -257,7 +308,8 @@ public class ClientConfiguration extends Properties { */ public void setUseNio(boolean flag) { // XXX chiaming 07/19/2014: This will be re-enabled when it is compatible with 3.0.0 // XXX chiaming 07/19/2014: This will be re-enabled when it is // compatible with 3.0.0 logger.warning("Method is disabled., Only NIO is supported."); // this.useNio = flag; Loading Loading @@ -348,7 +400,8 @@ public class ClientConfiguration extends Properties { + " is not supported. Using default request timeout (30 seconds)"); millis = DEFAULT_REQUEST_TIMEOUT; } else if (millis < DEFAULT_REQUEST_TIMEOUT) { logger.warning("request timeout set to " + millis logger.warning("request timeout set to " + millis + " milli seconds. This may cause the client runtime library not to receive responses in time when network/service is slow."); } Loading Loading @@ -437,20 +490,25 @@ public class ClientConfiguration extends Properties { * Get Kinetic protocol version supported by the current API implementation. * The protocol version is defined at the kinetic-protocol repository. * * @return Kinetic protocol version supported by the current API implementation. * @return Kinetic protocol version supported by the current API * implementation. * * @see <a href="https://github.com/Seagate/kinetic-protocol">kinetic-protocol</a> * @see <a * href="https://github.com/Seagate/kinetic-protocol">kinetic-protocol</a> */ public static String getProtocolVersion() { return PROTOCOL_VERSION; } /** * Get the supported protocol source commit hash at the kinetic-protocol repository. * Get the supported protocol source commit hash at the kinetic-protocol * repository. * * @return protocol source commit hash value at the kinetic-protocol repository. * @return protocol source commit hash value at the kinetic-protocol * repository. * * @see <a href="https://github.com/Seagate/kinetic-protocol">kinetic-protocol</a> * @see <a * href="https://github.com/Seagate/kinetic-protocol">kinetic-protocol</a> */ public static String getProtocolSourceHash() { return PROTOCOL_SOURCE_HASH; Loading Loading
kinetic-client/src/main/java/com/seagate/kinetic/client/io/provider/nio/tcp/TcpNioTransportProvider.java +96 −83 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import io.netty.channel.EventLoopGroup; import io.netty.channel.socket.nio.NioSocketChannel; import java.io.IOException; import java.net.InetSocketAddress; import java.util.logging.Level; import java.util.logging.Logger; Loading Loading @@ -92,7 +93,23 @@ public class TcpNioTransportProvider implements ClientTransportProvider { bootstrap.group(workerGroup).channel(NioSocketChannel.class) .handler(nioChannelInitializer); if (config.getLocalAddress() == null) { channel = bootstrap.connect(host, port).sync().channel(); } else { // remote address InetSocketAddress remote = new InetSocketAddress(host, port); // remote port InetSocketAddress local = new InetSocketAddress( config.getLocalAddress(), config.getLocalPort()); channel = bootstrap.connect(remote, local).sync().channel(); logger.info("connected to remote with local address: " + config.getLocalAddress() + ", local port=" + config.getLocalPort()); } } catch (Exception e) { // release allocated resources Loading @@ -101,9 +118,7 @@ public class TcpNioTransportProvider implements ClientTransportProvider { } logger.info("TcpNio client transport provider connecting to host:port =" + host + ":" + port); + host + ":" + port); } /** Loading Loading @@ -134,16 +149,14 @@ public class TcpNioTransportProvider implements ClientTransportProvider { } logger.info("Kinetic nio client transport provider closed, url =" + host + ":" + port); + host + ":" + port); } /** * {@inheritDoc} */ @Override public void init(ClientMessageService mservice) throws KineticException { public void init(ClientMessageService mservice) throws KineticException { this.mservice = mservice; Loading
kinetic-client/src/main/java/kinetic/client/ClientConfiguration.java +450 −392 Original line number Diff line number Diff line Loading @@ -49,7 +49,8 @@ public class ClientConfiguration extends Properties { /** * current supported kinetic protocol version on kinetic-protocol repo. */ public static final String PROTOCOL_VERSION = Kinetic.Local.getDefaultInstance().getProtocolVersion(); public static final String PROTOCOL_VERSION = Kinetic.Local .getDefaultInstance().getProtocolVersion(); /** * current supported protocol source commit hash on kinetic-protocol repo. Loading @@ -62,6 +63,12 @@ public class ClientConfiguration extends Properties { // kinetic server port private int port = 8123; // local address used to connect to server private String localAddress = null; // local port used to connect to server private int localPort = 0; // user id private long userId = 1; Loading @@ -86,7 +93,6 @@ public class ClientConfiguration extends Properties { */ private volatile boolean useSsl = Boolean.getBoolean("kinetic.io.ssl"); /** * ssl default port if useSsl is set to true. */ Loading Loading @@ -143,6 +149,51 @@ public class ClientConfiguration extends Properties { this.host = host; } /** * Set local address client used to connect to server. * * @param localAddress * local address client used to connect to server */ public void setLocalAddress(String localAddress) { this.localAddress = localAddress; } /** * Set local address port client used to connect to the server. * * @param localPort * local address port client used to connect to the server */ public void setLocalPort(int localPort) { this.localPort = localPort; } /** * Get local address client used to connect to server. * <p> * The local address the socket is bound to, or null for the anyLocal * address. Default is set to null. * * @return local address client used to connect to server. */ public String getLocalAddress() { return this.localAddress; } /** * * Get local port client used to connect to server. * <p> * The local port the socket is bound to or zero for a system selected free * port. * * @return local port local port client used to connect to server */ public int getLocalPort() { return this.localPort; } /** * Set server port. * Loading Loading @@ -257,7 +308,8 @@ public class ClientConfiguration extends Properties { */ public void setUseNio(boolean flag) { // XXX chiaming 07/19/2014: This will be re-enabled when it is compatible with 3.0.0 // XXX chiaming 07/19/2014: This will be re-enabled when it is // compatible with 3.0.0 logger.warning("Method is disabled., Only NIO is supported."); // this.useNio = flag; Loading Loading @@ -348,7 +400,8 @@ public class ClientConfiguration extends Properties { + " is not supported. Using default request timeout (30 seconds)"); millis = DEFAULT_REQUEST_TIMEOUT; } else if (millis < DEFAULT_REQUEST_TIMEOUT) { logger.warning("request timeout set to " + millis logger.warning("request timeout set to " + millis + " milli seconds. This may cause the client runtime library not to receive responses in time when network/service is slow."); } Loading Loading @@ -437,20 +490,25 @@ public class ClientConfiguration extends Properties { * Get Kinetic protocol version supported by the current API implementation. * The protocol version is defined at the kinetic-protocol repository. * * @return Kinetic protocol version supported by the current API implementation. * @return Kinetic protocol version supported by the current API * implementation. * * @see <a href="https://github.com/Seagate/kinetic-protocol">kinetic-protocol</a> * @see <a * href="https://github.com/Seagate/kinetic-protocol">kinetic-protocol</a> */ public static String getProtocolVersion() { return PROTOCOL_VERSION; } /** * Get the supported protocol source commit hash at the kinetic-protocol repository. * Get the supported protocol source commit hash at the kinetic-protocol * repository. * * @return protocol source commit hash value at the kinetic-protocol repository. * @return protocol source commit hash value at the kinetic-protocol * repository. * * @see <a href="https://github.com/Seagate/kinetic-protocol">kinetic-protocol</a> * @see <a * href="https://github.com/Seagate/kinetic-protocol">kinetic-protocol</a> */ public static String getProtocolSourceHash() { return PROTOCOL_SOURCE_HASH; Loading