diff options
author | Michi Henning <michi@zeroc.com> | 2003-03-03 06:24:23 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2003-03-03 06:24:23 +0000 |
commit | 5e8a973ee6753d30e5debba2399c1a541c38a766 (patch) | |
tree | 5e646a0a9290f382eb1f05221282a2ea55daa8e8 /java | |
parent | Removed UDP endpoint versions (left over from testing). (diff) | |
download | ice-5e8a973ee6753d30e5debba2399c1a541c38a766.tar.bz2 ice-5e8a973ee6753d30e5debba2399c1a541c38a766.tar.xz ice-5e8a973ee6753d30e5debba2399c1a541c38a766.zip |
Backed out previous check-in -- didn't get a branch for some reason.
Diffstat (limited to 'java')
-rw-r--r-- | java/src/IceInternal/BasicStream.java | 43 | ||||
-rw-r--r-- | java/src/IceInternal/Connection.java | 148 | ||||
-rw-r--r-- | java/src/IceInternal/Protocol.java | 15 | ||||
-rw-r--r-- | java/src/IceInternal/ThreadPool.java | 46 | ||||
-rw-r--r-- | java/src/IceInternal/TraceUtil.java | 18 | ||||
-rw-r--r-- | java/src/IceInternal/UdpEndpoint.java | 189 |
6 files changed, 59 insertions, 400 deletions
diff --git a/java/src/IceInternal/BasicStream.java b/java/src/IceInternal/BasicStream.java index 12e6f64ceb1..50b96d75c22 100644 --- a/java/src/IceInternal/BasicStream.java +++ b/java/src/IceInternal/BasicStream.java @@ -171,8 +171,7 @@ public class BasicStream public void startWriteEncaps() { - writeByte(Protocol.encodingMajor); - writeByte(Protocol.encodingMinor); + writeByte((byte)0); // Encoding writeInt(0); // Placeholder for the encapsulation length WriteEncaps curr = _writeEncapsCache; if(curr != null) @@ -183,6 +182,7 @@ public class BasicStream { curr = new WriteEncaps(); } + curr.encoding = 0; curr.start = _buf.position(); curr.next = _writeEncapsStack; _writeEncapsStack = curr; @@ -208,17 +208,11 @@ public class BasicStream public void startReadEncaps() { - byte eMajor = readByte(); - byte eMinor = readByte(); - if(eMajor != Protocol.encodingMajor || eMinor > Protocol.encodingMinor) - { - Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException(); - e.badMajor = eMajor < 0 ? eMajor + 255 : eMajor; - e.badMinor = eMinor < 0 ? eMinor + 255 : eMinor; - e.major = Protocol.encodingMajor; - e.minor = Protocol.encodingMinor; - throw e; - } + byte encoding = readByte(); + if(encoding != 0) + { + throw new Ice.UnsupportedEncodingException(); + } // // I don't use readSize() and writeSize() for encapsulations, // because when creating an encapsulation, I must know in @@ -241,8 +235,7 @@ public class BasicStream { curr = new ReadEncaps(); } - curr.encodingMajor = eMajor; - curr.encodingMinor = eMinor; + curr.encoding = encoding; curr.start = _buf.position(); curr.next = _readEncapsStack; _readEncapsStack = curr; @@ -321,17 +314,11 @@ public class BasicStream public void skipEncaps() { - byte version = readByte(); // Ignore major - version = readByte(); // Ignore minor - - // - // We don't check the encoding here because encapsulations always - // have the encoding followed by the size of the encapsulation - // (regardless of the version of the encoding). We care about the - // version information only if we want to decode what's in the - // encapsulation. - // - + byte encoding = readByte(); + if(encoding != 0) + { + throw new Ice.UnsupportedEncodingException(); + } int sz = readInt(); if(sz < 0) { @@ -1336,8 +1323,7 @@ public class BasicStream private static final class ReadEncaps { int start; - byte encodingMajor; - byte encodingMinor; + byte encoding; java.util.ArrayList objectsRead; ReadEncaps next; } @@ -1345,6 +1331,7 @@ public class BasicStream private static final class WriteEncaps { int start; + byte encoding; java.util.IdentityHashMap objectsWritten; WriteEncaps next; } diff --git a/java/src/IceInternal/Connection.java b/java/src/IceInternal/Connection.java index e761caaf906..35ae3e5ce69 100644 --- a/java/src/IceInternal/Connection.java +++ b/java/src/IceInternal/Connection.java @@ -158,14 +158,8 @@ public final class Connection extends EventHandler // respect to connection validation. // BasicStream os = new BasicStream(_instance); - os.writeByte((byte)0x49); // 'I' - os.writeByte((byte)0x63); // 'c' - os.writeByte((byte)0x65); // 'e' - os.writeByte((byte)0x50); // 'P' - os.writeByte(Protocol.protocolMajor); - os.writeByte(Protocol.protocolMinor); - os.writeByte(Protocol.encodingMajor); - os.writeByte(Protocol.encodingMinor); + os.writeByte(Protocol.protocolVersion); + os.writeByte(Protocol.encodingVersion); os.writeByte(Protocol.validateConnectionMsg); os.writeInt(Protocol.headerSize); // Message size. TraceUtil.traceHeader("sending validate connection", os, _logger, _traceLevels); @@ -184,60 +178,16 @@ public final class Connection extends EventHandler int pos = is.pos(); assert(pos >= Protocol.headerSize); is.pos(0); - byte[] magic = new byte[4]; - magic[0] = is.readByte(); - magic[1] = is.readByte(); - magic[2] = is.readByte(); - magic[3] = is.readByte(); - if(magic[0] != 0x49 || magic[1] != 0x63 || magic[2] != 0x65 || magic[3] != 0x50) + byte protVer = is.readByte(); + if(protVer != Protocol.protocolVersion) { - Ice.BadMagicException ex = new Ice.BadMagicException(); - ex.badMagic = magic; - throw ex; + throw new Ice.UnsupportedProtocolException(); } - byte pMajor = is.readByte(); - byte pMinor = is.readByte(); - - // - // We only check the major version number here. The minor version - // number is irrelevant -- no matter what minor version number is offered - // by the server, we can be certain that the server supports at least minor version 0. - // As the client, we are obliged to never produce a message with a minor - // version number that is larger than what the server can understand, but we don't - // care if the server understands more than we do. - // - // Note: Once we add minor versions, we need to modify the client side to never produce - // a message with a minor number that is greater than what the server can handle. Similarly, - // the server side will have to be modified so it never replies with a minor version that is - // greater than what the client can handle. - // - if(pMajor != Protocol.protocolMajor) - { - Ice.UnsupportedProtocolException e = new Ice.UnsupportedProtocolException(); - e.badMajor = pMajor < 0 ? pMajor + 255 : pMajor; - e.badMinor = pMinor < 0 ? pMinor + 255 : pMinor; - e.major = Protocol.protocolMajor; - e.minor = Protocol.protocolMinor; - throw e; - } - - byte eMajor = is.readByte(); - byte eMinor = is.readByte(); - - // - // The same applies here as above -- only the major version number - // of the encoding is relevant. - // - if(eMajor != Protocol.encodingMajor) + byte encVer = is.readByte(); + if(encVer != Protocol.encodingVersion) { - Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException(); - e.badMajor = eMajor < 0 ? eMajor + 255 : eMajor; - e.badMinor = eMinor < 0 ? eMinor + 255 : eMinor; - e.major = Protocol.encodingMajor; - e.minor = Protocol.encodingMinor; - throw e; + throw new Ice.UnsupportedEncodingException(); } - byte messageType = is.readByte(); if(messageType != Protocol.validateConnectionMsg) { @@ -313,11 +263,8 @@ public final class Connection extends EventHandler private final static byte[] _requestHdr = { - (byte)0x49, (byte)0x63, (byte)0x65, (byte)0x50, // 'I', 'c', 'e', 'P' - Protocol.protocolMajor, - Protocol.protocolMinor, - Protocol.encodingMajor, - Protocol.encodingMinor, + Protocol.protocolVersion, + Protocol.encodingVersion, Protocol.requestMsg, (byte)0, (byte)0, (byte)0, (byte)0, // Message size (placeholder). (byte)0, (byte)0, (byte)0, (byte)0 // Request ID (placeholder). @@ -343,7 +290,7 @@ public final class Connection extends EventHandler try { BasicStream os = out.os(); - os.pos(9); + os.pos(3); // // Fill in the message size and request ID. @@ -402,7 +349,7 @@ public final class Connection extends EventHandler try { BasicStream os = out.__os(); - os.pos(9); + os.pos(3); // // Fill in the message size and request ID. @@ -442,11 +389,8 @@ public final class Connection extends EventHandler private final static byte[] _requestBatchHdr = { - (byte)0x49, (byte)0x63, (byte)0x65, (byte)0x50, // 'I', 'c', 'e', 'P' - Protocol.protocolMajor, - Protocol.protocolMinor, - Protocol.encodingMajor, - Protocol.encodingMinor, + Protocol.protocolVersion, + Protocol.encodingVersion, Protocol.requestBatchMsg, (byte)0, (byte)0, (byte)0, (byte)0, // Message size (placeholder). (byte)0, (byte)0, (byte)0, (byte)0 // Number of requests in batch (placeholder). @@ -554,7 +498,7 @@ public final class Connection extends EventHandler try { - _batchStream.pos(9); + _batchStream.pos(3); // // Fill in the message size. @@ -610,7 +554,7 @@ public final class Connection extends EventHandler // // Fill in the message size. // - os.pos(9); + os.pos(3); final int sz = os.size(); os.writeInt(sz); @@ -742,11 +686,8 @@ public final class Connection extends EventHandler private final static byte[] _replyHdr = { - (byte)0x49, (byte)0x63, (byte)0x65, (byte)0x50, // 'I', 'c', 'e', 'P' - Protocol.protocolMajor, - Protocol.protocolMinor, - Protocol.encodingMajor, - Protocol.encodingMinor, + Protocol.protocolVersion, + Protocol.encodingVersion, Protocol.replyMsg, (byte)0, (byte)0, (byte)0, (byte)0 // Message size (placeholder). }; @@ -777,44 +718,7 @@ public final class Connection extends EventHandler try { assert(stream.pos() == stream.size()); - stream.pos(0); - - byte[] magic = new byte[4]; - magic[0] = stream.readByte(); - magic[1] = stream.readByte(); - magic[2] = stream.readByte(); - magic[3] = stream.readByte(); - if(magic[0] != 0x49 || magic[1] != 0x63 || magic[2] != 0x65 || magic[3] != 0x50) - { - Ice.BadMagicException ex = new Ice.BadMagicException(); - ex.badMagic = magic; - throw ex; - } - - byte pMajor = stream.readByte(); - byte pMinor = stream.readByte(); - if(pMajor != Protocol.protocolMajor || pMinor > Protocol.protocolMinor) - { - Ice.UnsupportedProtocolException e = new Ice.UnsupportedProtocolException(); - e.badMajor = pMajor < 0 ? pMajor + 255 : pMajor; - e.badMinor = pMinor < 0 ? pMinor + 255 : pMinor; - e.major = Protocol.protocolMajor; - e.minor = Protocol.protocolMinor; - throw e; - } - - byte eMajor = stream.readByte(); - byte eMinor = stream.readByte(); - if(eMajor != Protocol.encodingMajor || eMinor > Protocol.encodingMinor) - { - Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException(); - e.badMajor = eMajor < 0 ? eMajor + 255 : eMajor; - e.badMinor = eMinor < 0 ? eMinor + 255 : eMinor; - e.major = Protocol.encodingMajor; - e.minor = Protocol.encodingMinor; - throw e; - } - + stream.pos(2); byte messageType = stream.readByte(); stream.pos(Protocol.headerSize); @@ -1052,8 +956,8 @@ public final class Connection extends EventHandler _transceiver = transceiver; _endpoint = endpoint; _adapter = adapter; - _logger = instance.logger(); // Cached for better performance. - _traceLevels = instance.traceLevels(); // Cached for better performance. + _logger = instance.logger(); // Chached for better performance. + _traceLevels = instance.traceLevels(); // Chached for better performance. _registeredWithPool = false; _warn = false; _acmTimeout = 0; @@ -1268,14 +1172,8 @@ public final class Connection extends EventHandler // message. // BasicStream os = new BasicStream(_instance); - os.writeByte((byte)0x49); // 'I' - os.writeByte((byte)0x63); // 'c' - os.writeByte((byte)0x65); // 'e' - os.writeByte((byte)0x50); // 'P' - os.writeByte(Protocol.protocolMajor); - os.writeByte(Protocol.protocolMinor); - os.writeByte(Protocol.encodingMajor); - os.writeByte(Protocol.encodingMinor); + os.writeByte(Protocol.protocolVersion); + os.writeByte(Protocol.encodingVersion); os.writeByte(Protocol.closeConnectionMsg); os.writeInt(Protocol.headerSize); // Message size. _transceiver.write(os, _endpoint.timeout()); diff --git a/java/src/IceInternal/Protocol.java b/java/src/IceInternal/Protocol.java index 526c850da72..c38f47fc06c 100644 --- a/java/src/IceInternal/Protocol.java +++ b/java/src/IceInternal/Protocol.java @@ -19,23 +19,18 @@ final class Protocol // // Size of the Ice protocol header // - // Magic number (4 bytes): 'I', 'c', 'e', 'P' in ASCII encoding - // Protocol version major (Byte) - // Protocol version minor (Byte) - // Encoding version major (Byte) - // Encoding version minor (Byte) + // Protocol version (Byte) + // Encoding version (Byte) // Message type (Byte) // Message size (Int) // - final static int headerSize = 13; + final static int headerSize = 7; // // The current Ice protocol and encoding version // - final static byte protocolMajor = 1; - final static byte protocolMinor = 0; - final static byte encodingMajor = 1; - final static byte encodingMinor = 0; + final static byte protocolVersion = 0; + final static byte encodingVersion = 0; // // The Ice protocol message types diff --git a/java/src/IceInternal/ThreadPool.java b/java/src/IceInternal/ThreadPool.java index 6078c616a13..203eec0ffe2 100644 --- a/java/src/IceInternal/ThreadPool.java +++ b/java/src/IceInternal/ThreadPool.java @@ -658,42 +658,16 @@ public final class ThreadPool int pos = stream.pos(); assert(pos >= Protocol.headerSize); stream.pos(0); - byte[] magic = new byte[4]; - magic[0] = stream.readByte(); - magic[1] = stream.readByte(); - magic[2] = stream.readByte(); - magic[3] = stream.readByte(); - if(magic[0] != 0x49 || magic[1] != 0x63 || magic[2] != 0x65 || magic[3] != 0x50) - { - Ice.BadMagicException ex = new Ice.BadMagicException(); - ex.badMagic = magic; - throw ex; - } - - byte pMajor = stream.readByte(); - byte pMinor = stream.readByte(); - if(pMajor != Protocol.protocolMajor || pMinor > Protocol.protocolMinor) - { - Ice.UnsupportedProtocolException e = new Ice.UnsupportedProtocolException(); - e.badMajor = pMajor < 0 ? pMajor + 255 : pMajor; - e.badMinor = pMinor < 0 ? pMinor + 255 : pMinor; - e.major = Protocol.protocolMajor; - e.minor = Protocol.protocolMinor; - throw e; - } - - byte eMajor = stream.readByte(); - byte eMinor = stream.readByte(); - if(eMajor != Protocol.encodingMajor || eMinor > Protocol.encodingMinor) - { - Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException(); - e.badMajor = eMajor < 0 ? eMajor + 255 : eMajor; - e.badMinor = eMinor < 0 ? eMinor + 255 : eMinor; - e.major = Protocol.encodingMajor; - e.minor = Protocol.encodingMinor; - throw e; - } - + byte protVer = stream.readByte(); + if(protVer != Protocol.protocolVersion) + { + throw new Ice.UnsupportedProtocolException(); + } + byte encVer = stream.readByte(); + if(encVer != Protocol.encodingVersion) + { + throw new Ice.UnsupportedEncodingException(); + } byte messageType = stream.readByte(); int size = stream.readInt(); if(size < Protocol.headerSize) diff --git a/java/src/IceInternal/TraceUtil.java b/java/src/IceInternal/TraceUtil.java index 52771b1fc96..8ce03d4b7ec 100644 --- a/java/src/IceInternal/TraceUtil.java +++ b/java/src/IceInternal/TraceUtil.java @@ -333,19 +333,11 @@ final class TraceUtil { try { - byte[] magic = new byte[4]; - magic[0] = stream.readByte(); - magic[1] = stream.readByte(); - magic[2] = stream.readByte(); - magic[3] = stream.readByte(); - - byte pMajor = stream.readByte(); - byte pMinor = stream.readByte(); -// out.write("\nprotocol version = " + (int)pMajor + "." + (int)pMinor); - - byte eMajor = stream.readByte(); - byte eMinor = stream.readByte(); -// out.write("\nencoding version = " + (int)eMajor + "." + (int)eMinor); + byte protVer = stream.readByte(); +// out.write("\nprotocol version = " + (int)protVer); + + byte encVer = stream.readByte(); +// out.write("\nencoding version = " + (int)encVer); byte type = stream.readByte(); out.write("\nmessage type = " + (int)type + ' '); diff --git a/java/src/IceInternal/UdpEndpoint.java b/java/src/IceInternal/UdpEndpoint.java index ce9bc3d71e2..b9c5c953c41 100644 --- a/java/src/IceInternal/UdpEndpoint.java +++ b/java/src/IceInternal/UdpEndpoint.java @@ -24,10 +24,6 @@ final class UdpEndpoint implements Endpoint _instance = instance; _host = ho; _port = po; - _protocolMajor = Protocol.protocolMajor; - _protocolMinor = Protocol.protocolMinor; - _encodingMajor = Protocol.encodingMajor; - _encodingMinor = Protocol.encodingMinor; _connect = false; _compress = co; calcHashValue(); @@ -69,118 +65,6 @@ final class UdpEndpoint implements Endpoint switch(option.charAt(1)) { - case 'v': - { - if(argument == null) - { - Ice.EndpointParseException e = new Ice.EndpointParseException(); - e.str = "udp " + str; - throw e; - } - - int pos = argument.indexOf('.'); - if(pos == -1) - { - Ice.EndpointParseException e = new Ice.EndpointParseException(); - e.str = "udp " + str; - throw e; - } - - String majStr = argument.substring(0, pos); - String minStr = argument.substring(pos + 1, argument.length()); - int majVersion; - int minVersion; - try - { - majVersion = Integer.parseInt(majStr); - minVersion = Integer.parseInt(minStr); - } - catch(NumberFormatException ex) - { - Ice.EndpointParseException e = new Ice.EndpointParseException(); - e.str = "udp " + str; - throw e; - } - - if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255) - { - Ice.EndpointParseException e = new Ice.EndpointParseException(); - e.str = "udp " + str; - throw e; - } - - if(majVersion != Protocol.protocolMajor) - { - Ice.UnsupportedProtocolException e = new Ice.UnsupportedProtocolException(); - e.badMajor = majVersion < 0 ? majVersion + 255 : majVersion; - e.badMinor = minVersion < 0 ? minVersion + 255 : minVersion; - e.major = Protocol.protocolMajor; - e.minor = Protocol.protocolMinor; - throw e; - } - - _protocolMajor = (byte)majVersion; - _protocolMinor = (byte)minVersion; - - break; - } - - case 'e': - { - if(argument == null) - { - Ice.EndpointParseException e = new Ice.EndpointParseException(); - e.str = "udp " + str; - throw e; - } - - int pos = argument.indexOf('.'); - if(pos == -1) - { - Ice.EndpointParseException e = new Ice.EndpointParseException(); - e.str = "udp " + str; - throw e; - } - - String majStr = argument.substring(0, pos); - String minStr = argument.substring(pos + 1, argument.length()); - int majVersion; - int minVersion; - try - { - majVersion = Integer.parseInt(majStr); - minVersion = Integer.parseInt(minStr); - } - catch(NumberFormatException ex) - { - Ice.EndpointParseException e = new Ice.EndpointParseException(); - e.str = "udp " + str; - throw e; - } - - if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255) - { - Ice.EndpointParseException e = new Ice.EndpointParseException(); - e.str = "udp " + str; - throw e; - } - - if(majVersion != Protocol.encodingMajor) - { - Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException(); - e.badMajor = majVersion < 0 ? majVersion + 255 : majVersion; - e.badMinor = minVersion < 0 ? minVersion + 255 : minVersion; - e.major = Protocol.encodingMajor; - e.minor = Protocol.encodingMinor; - throw e; - } - - _encodingMajor = (byte)majVersion; - _encodingMinor = (byte)minVersion; - - break; - } - case 'h': { if(argument == null) @@ -267,28 +151,6 @@ final class UdpEndpoint implements Endpoint s.startReadEncaps(); _host = s.readString(); _port = s.readInt(); - _protocolMajor = s.readByte(); - _protocolMinor = s.readByte(); - _encodingMajor = s.readByte(); - _encodingMinor = s.readByte(); - if(_protocolMajor != Protocol.protocolMajor) - { - Ice.UnsupportedProtocolException e = new Ice.UnsupportedProtocolException(); - e.badMajor = _protocolMajor < 0 ? _protocolMajor + 255 : _protocolMajor; - e.badMinor = _protocolMinor < 0 ? _protocolMinor + 255 : _protocolMinor; - e.major = Protocol.protocolMajor; - e.minor = Protocol.protocolMinor; - throw e; - } - if(_encodingMajor != Protocol.encodingMajor) - { - Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException(); - e.badMajor = _encodingMajor < 0 ? _encodingMajor + 255 : _encodingMajor; - e.badMinor = _encodingMinor < 0 ? _encodingMinor + 255 : _encodingMinor; - e.major = Protocol.encodingMajor; - e.minor = Protocol.encodingMinor; - throw e; - } // Not transmitted. //_connect = s.readBool(); _connect = false; @@ -307,10 +169,6 @@ final class UdpEndpoint implements Endpoint s.startWriteEncaps(); s.writeString(_host); s.writeInt(_port); - s.writeByte(_protocolMajor); - s.writeByte(_protocolMinor); - s.writeByte(_encodingMajor); - s.writeByte(_encodingMinor); // Not transmitted. //s.writeBool(_connect); s.writeBool(_compress); @@ -323,12 +181,7 @@ final class UdpEndpoint implements Endpoint public String toString() { - String s = "udp"; - s += " -v " + (_protocolMajor < 0 ? (int)_protocolMajor + 255 : _protocolMajor) - + "." + (_protocolMinor < 0 ? (int)_protocolMinor + 255 : _protocolMinor); - s += " -e " + (_encodingMajor < 0 ? (int)_encodingMajor + 255 : _encodingMajor) - + "." + (_encodingMinor < 0 ? (int)_encodingMinor + 255 : _encodingMinor); - s += " -h " + _host + " -p " + _port; + String s = "udp -h " + _host + " -p " + _port; if(_connect) { s += " -c"; @@ -560,42 +413,6 @@ final class UdpEndpoint implements Endpoint return 1; } - if(_protocolMajor < p._protocolMajor) - { - return -1; - } - else if(p._protocolMajor < _protocolMajor) - { - return 1; - } - - if(_protocolMinor < p._protocolMinor) - { - return -1; - } - else if(p._protocolMinor < _protocolMinor) - { - return 1; - } - - if(_encodingMajor < p._encodingMajor) - { - return -1; - } - else if(p._encodingMajor < _encodingMajor) - { - return 1; - } - - if(_encodingMinor < p._encodingMinor) - { - return -1; - } - else if(p._encodingMinor < _encodingMinor) - { - return 1; - } - if(!_host.equals(p._host)) { // @@ -636,10 +453,6 @@ final class UdpEndpoint implements Endpoint private Instance _instance; private String _host; private int _port; - private byte _protocolMajor; - private byte _protocolMinor; - private byte _encodingMajor; - private byte _encodingMinor; private boolean _connect; private boolean _compress; private int _hashCode; |