diff options
author | Marc Laukien <marc@zeroc.com> | 2003-01-30 17:31:35 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2003-01-30 17:31:35 +0000 |
commit | f457f9df92650c658fbc78c670db6703f33f29a0 (patch) | |
tree | 0dcccf682d3ce1a52be876cad5eb673f46eb4108 /java/src/IceInternal/TcpEndpoint.java | |
parent | compression cleanup (diff) | |
download | ice-f457f9df92650c658fbc78c670db6703f33f29a0.tar.bz2 ice-f457f9df92650c658fbc78c670db6703f33f29a0.tar.xz ice-f457f9df92650c658fbc78c670db6703f33f29a0.zip |
compression cleanup
Diffstat (limited to 'java/src/IceInternal/TcpEndpoint.java')
-rw-r--r-- | java/src/IceInternal/TcpEndpoint.java | 66 |
1 files changed, 63 insertions, 3 deletions
diff --git a/java/src/IceInternal/TcpEndpoint.java b/java/src/IceInternal/TcpEndpoint.java index 2aaa3f791e9..c61f1d51cf0 100644 --- a/java/src/IceInternal/TcpEndpoint.java +++ b/java/src/IceInternal/TcpEndpoint.java @@ -19,12 +19,13 @@ final class TcpEndpoint implements Endpoint final static short TYPE = 1; public - TcpEndpoint(Instance instance, String ho, int po, int ti) + TcpEndpoint(Instance instance, String ho, int po, int ti, boolean co) { _instance = instance; _host = ho; _port = po; _timeout = ti; + _compress = co; calcHashValue(); } @@ -35,6 +36,7 @@ final class TcpEndpoint implements Endpoint _host = null; _port = 0; _timeout = -1; + _compress = false; String[] arr = str.split("[ \t\n\r]+"); @@ -122,6 +124,19 @@ final class TcpEndpoint implements Endpoint break; } + case 'z': + { + if(argument != null) + { + Ice.EndpointParseException e = new Ice.EndpointParseException(); + e.str = "tcp " + str; + throw e; + } + + _compress = true; + break; + } + default: { Ice.EndpointParseException e = new Ice.EndpointParseException(); @@ -147,6 +162,7 @@ final class TcpEndpoint implements Endpoint _host = s.readString(); _port = s.readInt(); _timeout = s.readInt(); + _compress = s.readBool(); s.endReadEncaps(); calcHashValue(); } @@ -162,6 +178,7 @@ final class TcpEndpoint implements Endpoint s.writeString(_host); s.writeInt(_port); s.writeInt(_timeout); + s.writeBool(_compress); s.endWriteEncaps(); } @@ -176,6 +193,10 @@ final class TcpEndpoint implements Endpoint { s += " -t " + _timeout; } + if(_compress) + { + s += " -z"; + } return s; } @@ -212,7 +233,35 @@ final class TcpEndpoint implements Endpoint } else { - return new TcpEndpoint(_instance, _host, _port, timeout); + return new TcpEndpoint(_instance, _host, _port, timeout, _compress); + } + } + + // + // Return true if the endpoints support bzip2 compress, or false + // otherwise. + // + public boolean + compress() + { + return _compress; + } + + // + // Return a new endpoint with a different compression value, + // provided that compression is supported by the + // endpoint. Otherwise the same endpoint is returned. + // + public Endpoint + compress(boolean compress) + { + if(compress == _compress) + { + return this; + } + else + { + return new TcpEndpoint(_instance, _host, _port, _timeout, compress); } } @@ -288,7 +337,7 @@ final class TcpEndpoint implements Endpoint acceptor(EndpointHolder endpoint) { TcpAcceptor p = new TcpAcceptor(_instance, _host, _port); - endpoint.value = new TcpEndpoint(_instance, _host, p.effectivePort(), _timeout); + endpoint.value = new TcpEndpoint(_instance, _host, p.effectivePort(), _timeout, _compress); return p; } @@ -369,6 +418,15 @@ final class TcpEndpoint implements Endpoint return 1; } + if(!_compress && p._compress) + { + return -1; + } + else if(!p._compress && _compress) + { + return 1; + } + if(!_host.equals(p._host)) { // @@ -403,11 +461,13 @@ final class TcpEndpoint implements Endpoint _hashCode = _host.hashCode(); _hashCode = 5 * _hashCode + _port; _hashCode = 5 * _hashCode + _timeout; + _hashCode = 5 * _hashCode + (_compress ? 1 : 0); } private Instance _instance; private String _host; private int _port; private int _timeout; + private boolean _compress; private int _hashCode; } |