Author: fhanik Date: Thu May 18 11:25:46 2006 New Revision: 407603 URL: http://svn.apache.org/viewvc?rev=407603&view=rev Log: Remove the byte[] pool, its the wrong approach, will implement a buffer cache instead Add in the ability to calculate the size of a data package without serializing it
Removed: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/BytePool.java tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/BytePool15Impl.java Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/ThroughputInterceptor.java tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ChannelData.java tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/XByteBuffer.java tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/MemberImpl.java Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/ThroughputInterceptor.java URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/ThroughputInterceptor.java?rev=407603&r1=407602&r2=407603&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/ThroughputInterceptor.java (original) +++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/ThroughputInterceptor.java Thu May 18 11:25:46 2006 @@ -45,7 +45,7 @@ int addrlength = 0; public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException { - long bytes = XByteBuffer.getDataPackageLength(((ChannelData)msg).getDataPackageLength(addrlength)); + long bytes = XByteBuffer.getDataPackageLength(((ChannelData)msg).getDataPackageLength()); long start = System.currentTimeMillis(); super.sendMessage(destination,msg,payload); long stop = System.currentTimeMillis(); Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ChannelData.java URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ChannelData.java?rev=407603&r1=407602&r2=407603&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ChannelData.java (original) +++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ChannelData.java Thu May 18 11:25:46 2006 @@ -164,14 +164,14 @@ setUniqueId(data); } - public int getDataPackageLength(int addrlength) { + public int getDataPackageLength() { int length = 4 + //options 8 + //timestamp off=4 4 + //unique id length off=12 uniqueId.length+ //id data off=12+uniqueId.length 4 + //addr length off=12+uniqueId.length+4 - addrlength+ //member data off=12+uniqueId.length+4+add.length + ((MemberImpl)address).getDataLength()+ //member data off=12+uniqueId.length+4+add.length 4 + //message length off=12+uniqueId.length+4+add.length+4 message.getLength(); return length; @@ -184,7 +184,7 @@ */ public byte[] getDataPackage() { byte[] addr = ((MemberImpl)address).getData(false); - int length = getDataPackageLength(addr.length); + int length = getDataPackageLength(); byte[] data = new byte[length]; int offset = 0; XByteBuffer.toBytes(options,data,offset); Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/XByteBuffer.java URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/XByteBuffer.java?rev=407603&r1=407602&r2=407603&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/XByteBuffer.java (original) +++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/XByteBuffer.java Thu May 18 11:25:46 2006 @@ -94,8 +94,7 @@ * @todo use a pool of byte[] for performance */ public XByteBuffer(int size, boolean discard) { - //buf = new byte[size]; - buf = BytePool.getBytePool().getArray(size); + buf = new byte[size]; this.discard = discard; } @@ -105,13 +104,12 @@ public XByteBuffer(byte[] data, int size,boolean discard) { int length = Math.max(data.length,size); - //buf = new byte[length]; - buf = BytePool.getBytePool().getArray(length); + buf = new byte[length]; System.arraycopy(data,0,buf,0,data.length); bufSize = data.length; this.discard = discard; } - + public int getLength() { return bufSize; } @@ -130,8 +128,7 @@ * Returns the bytes in the buffer, in its exact length */ public byte[] getBytes() { - //byte[] b = new byte[bufSize]; - byte[] b = BytePool.getBytePool().getFixedArray(bufSize); + byte[] b = new byte[bufSize]; System.arraycopy(buf,0,b,0,bufSize); return b; } @@ -239,8 +236,7 @@ public void expand(int newcount) { //don't change the allocation strategy - //byte newbuf[] = new byte[Math.max(buf.length << 1, newcount)]; - byte newbuf[] = BytePool.getBytePool().getArray(Math.max(buf.length << 1, newcount)); + byte newbuf[] = new byte[Math.max(buf.length << 1, newcount)]; System.arraycopy(buf, 0, newbuf, 0, bufSize); buf = newbuf; } @@ -311,8 +307,7 @@ int psize = countPackages(true); if (psize == 0) throw new java.lang.IllegalStateException("No package exists in XByteBuffer"); int size = toInt(buf, START_DATA.length); - //byte[] data = new byte[size]; - byte[] data = BytePool.getBytePool().getFixedArray(size); + byte[] data = new byte[size]; System.arraycopy(buf, START_DATA.length + 4, data, 0, size); if (clearFromBuffer) { int totalsize = START_DATA.length + 4 + size + END_DATA.length; @@ -352,8 +347,7 @@ public static byte[] createDataPackage(byte[] data) { int length = getDataPackageLength(data.length); - //byte[] result = new byte[length]; - byte[] result = BytePool.getBytePool().getFixedArray(length); + byte[] result = new byte[length]; return createDataPackage(data,0,data.length,result,0); } Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/MemberImpl.java URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/MemberImpl.java?rev=407603&r1=407602&r2=407603&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/MemberImpl.java (original) +++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/MemberImpl.java Thu May 18 11:25:46 2006 @@ -24,7 +24,6 @@ import org.apache.catalina.tribes.Member; import org.apache.catalina.tribes.io.XByteBuffer; import org.apache.catalina.tribes.transport.SenderState; -import org.apache.catalina.tribes.io.BytePool; /** * A <b>membership</b> implementation using simple multicast. @@ -151,6 +150,11 @@ return getData(getalive,false); } + + public int getDataLength() { + return 8+4+1+host.length+16+4+payload.length; + } + /** * * @param getalive boolean - calculate memberAlive time @@ -180,13 +184,10 @@ //uniqueId - 16 bytes //payload length - 4 bytes //payload plen bytes - - byte[] addr = host; long alive=System.currentTimeMillis()-getServiceStartTime(); byte hl = (byte)addr.length; - //byte[] data = new byte[8+4+1+addr.length+16+4+payload.length]; - byte[] data = BytePool.getBytePool().getFixedArray(8+4+1+addr.length+16+4+payload.length); + byte[] data = new byte[getDataLength()]; int pos = 0; //alive data XByteBuffer.toBytes((long)alive,data,0); @@ -258,7 +259,6 @@ member.payload = payload; member.dataPkg = new byte[data.length]; - //member.dataPkg = BytePool.getBytePool().getFixedArray(data.length); System.arraycopy(data,0,member.dataPkg,0,data.length); return member; @@ -409,8 +409,7 @@ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { int length = in.readInt(); - //byte[] message = new byte[length]; - byte[] message = BytePool.getBytePool().getFixedArray(length); + byte[] message = new byte[length]; in.read(message); getMember(message,this); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]