You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jg...@apache.org on 2006/10/03 00:29:53 UTC

svn commit: r452247 - in /geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache: command/ marshal/ server/ server/config/ server/core/ server/spi/ transports/tcp/ util/

Author: jgenender
Date: Mon Oct  2 15:29:51 2006
New Revision: 452247

URL: http://svn.apache.org/viewvc?view=rev&rev=452247
Log:
Some changes for GERONIMO-2457

Modified:
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/BaseCommand.java
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/BulkSendCommand.java
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/marshal/MarshalAware.java
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/GCacheServer.java
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/config/Configuration.java
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/core/GCacheThread.java
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/spi/ThreadPool.java
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/SelectionKeyProcessorFactory.java
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPSocketHandler.java
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPSocketTransportServer.java
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/ByteArray.java
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/ByteSequence.java

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/BaseCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/BaseCommand.java?view=diff&rev=452247&r1=452246&r2=452247
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/BaseCommand.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/BaseCommand.java Mon Oct  2 15:29:51 2006
@@ -18,13 +18,6 @@
  */
 package org.apache.geronimo.gcache.command;
 
-import org.apache.geronimo.gcache.CacheInfoHolder;
-import org.apache.geronimo.gcache.transports.tcp.Constants;
-import org.apache.geronimo.gcache.transports.CommandVisitor;
-import org.apache.geronimo.gcache.util.ByteArrayInputStream;
-import org.apache.geronimo.gcache.util.ByteArrayOutputStream;
-import org.apache.geronimo.gcache.util.UniqueId;
-
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
@@ -34,18 +27,38 @@
 import java.nio.channels.ReadableByteChannel;
 import java.nio.channels.WritableByteChannel;
 import java.nio.charset.Charset;
-import java.util.zip.Checksum;
 import java.util.zip.CRC32;
+import java.util.zip.Checksum;
+
+import org.apache.geronimo.gcache.marshal.MarshalAware;
+import org.apache.geronimo.gcache.transports.CommandVisitor;
+import org.apache.geronimo.gcache.util.ByteArrayInputStream;
+import org.apache.geronimo.gcache.util.ByteArrayOutputStream;
+import org.apache.geronimo.gcache.util.UniqueId;
 
 public class BaseCommand implements Command {
 
+    /**
+     * a unique identifier for this command, used specifically in situations
+     * where a response is required as a coorilation id.
+     */
     private long commandId = 0;
-    private Checksum checksum = null;
 
+    /**
+     * Get the command type. Types are integers and are used by gcache to create
+     * a new instance of the correct command when the command arrives at its destination.
+     */
     public byte getCommandType() throws IOException {
-        throw new IOException("Invalid command type");
+        throw new IOException("Invalid command type - subclasses must over ride getCommandType");
     }
 
+    /**
+     * The command id is used to uniquely identify this command and is
+     * specifically used in the case where a response is required.
+     * If the command id is still set to the default 0 a unique id is generated by the 
+     * UniqueId class.
+     * @see org.apache.geronimo.gcache.util.UniqueId
+     */
     public long getCommandId() {
         if (commandId == 0){
             commandId = UniqueId.get();
@@ -53,21 +66,39 @@
         return commandId;
     }
 
+    /**
+     * This method is provided for the cases where a specfic id is required to
+     * coordinate with another (external) framework. Typical use will not
+     * require this method to be called, the default mechanism will suffice.
+     * 
+     * @param commandId
+     */
     public void setCommandId(long commandId) {
+        //TODO - should this method be here. I am leaning towards this being a read only property.
         this.commandId = commandId;
     }
 
 
+    /**
+     * This default implementation does nothing, subclasses will perform
+     * whatever task this command is supposed to do.
+     */
     public void execute(CommandVisitor visitor) throws IOException{
         // nothing to do in the base
     }
 
+    /**
+     * @see org.apache.geronimo.gcache.marshal.MarshalAware.readExternal(ReadableByteChannel) 
+     */
     public void readExternal(ReadableByteChannel channel) throws IOException {
         // this is the root so no super impl, others should call super first
         commandId = readLong(channel);
 
     }
 
+    /**
+     * @see org.apache.geronimo.gcache.marshal.MarshalAware.writeExternal(WritableByteChannel) 
+     */
     public void writeExternal(WritableByteChannel channel) throws IOException {
         // this is the root so no super impl, others should call super first
 
@@ -77,6 +108,19 @@
         writeLong(channel, commandId);
     }
 
+    /**
+     * Create a byte array to hold the data for this command. Header information
+     * (the first 13 bytes) are written first The first byte is the command
+     * type, the second 8 bytes are a checksum, the next 4 bytes are the command
+     * length. The remainder of the bytes will be the result of the
+     * writeExternal implementation of the command.
+     * 
+     * @return
+     * @throws IOException
+     */
+    // TODO: Is this the place for this method? Seems higher level to me, this
+    // class should not know how
+    // to make a packet IMO.
     public byte[] createPacket() throws IOException{
         // COMMAND TYPE - 1 byte
         // CHECKSUM - 8 bytes
@@ -96,6 +140,7 @@
 
         //Marshal the command
         writeExternal(channel);
+        //TODO error handeling
         channel.close();
 
         int commandStart = 13;
@@ -116,6 +161,12 @@
         return command;
     }
 
+    // TODO - how is marshal used differently than createPacket? Seems
+    // redundant.
+    // It apears from the usage that this is a test utility method that makes it
+    // easier to test writeExternal/readExternal.
+    // No problem with that but I'd prefer it be part of the test code instead
+    // of here.
     public byte[] marshal() throws IOException {
         ByteArrayOutputStream baos = new ByteArrayOutputStream(34);
         WritableByteChannel channel = Channels.newChannel(baos);
@@ -124,6 +175,13 @@
         return baos.toByteArray();
     }
 
+    /**
+     * Rebuld an object from an array of bytes.
+     * @param data
+     * @return
+     * @throws IOException
+     */
+    //TODO - this method hoses MarshalAware - IMO this is not the place for this method, its a utility method
     public static Object convertObjectFromBytes(byte data[]) throws IOException {
         if (data == null)
             return null;
@@ -145,15 +203,15 @@
             buffer.flip();
             intValue = buffer.getInt();
         } else {
-            throw new IOException("Could not read identifier length from the channel");
+            throw new IOException(
+                    "Could not read an int from the channel - not enough data -"
+                            + " expected length = 4, actual length = " + read);
         }
 
         return intValue;
     }
 
     protected void writeInt(WritableByteChannel channel, int intValue) throws IOException {
-
-        // first the length of the string
         ByteBuffer buffer = ByteBuffer.allocateDirect(4);
         buffer.putInt(intValue);
 
@@ -170,7 +228,9 @@
             buffer.flip();
             longValue = buffer.getLong();
         } else {
-            throw new IOException("Could not read identifier length from the channel");
+            throw new IOException(
+                    "Could not read a long from the channel - not enough data -"
+                            + " expected length = 8, actual length = " + read);
         }
 
         return longValue;
@@ -190,25 +250,31 @@
     protected String readString(ReadableByteChannel channel) throws IOException {
         ByteBuffer buffer = ByteBuffer.allocateDirect(4);
         int read = channel.read(buffer);
-        int idLength = 0;
+        int stringLength = 0;
         if (read == 4) {
             buffer.flip();
-            idLength = buffer.getInt();
+            stringLength = buffer.getInt();
         } else {
-            throw new IOException("Could not read identifier length from the channel");
+            throw new IOException(
+                    "Could not read the string length from the channel - not enough data -"
+                            + " expected length = 4, actual length = " + read);
         }
-        if (idLength == -1)
+        if (stringLength == -1)
             return null;
 
         buffer = null;
-        // should read idLength * 2 bytes from the channel to get the string
-        // the length method on String returns the number of 16 bit characters
-        buffer = ByteBuffer.allocateDirect(idLength);
+        // should read stringLength bytes from the channel to get the string
+        buffer = ByteBuffer.allocateDirect(stringLength);
         read = channel.read(buffer);
-        if (read != idLength) {
-            throw new IOException("Could not read identifier from the channel");
+        if (read != stringLength) {
+            throw new IOException(
+                    "Could not read the string from the channel - expected "
+                            + stringLength + " bytes but got " + read + ".");
         }
         buffer.flip();
+        //TODO - not sure which character set to use so going with default but that will
+        // not work in case where two machines have different charsets as default so
+        // this needs to be revisited at some point
         String str = Charset.defaultCharset().decode(buffer).toString();
         buffer = null;
 
@@ -219,15 +285,16 @@
 
         // first the length of the string
         ByteBuffer buffer = ByteBuffer.allocateDirect(4);
-        if (str != null)
+        if (str != null) {
             buffer.putInt(str.length());
-        else
+        } else {
             buffer.putInt(-1);
-
+        }
+        
         buffer.flip();
         channel.write(buffer);
 
-        // now write the string - buffer comes back flipped
+        // now write the string - buffer comes back flipped and ready to be written to the channel
         if (str != null){
             buffer = Charset.defaultCharset().encode(str);
             channel.write(buffer);
@@ -240,23 +307,27 @@
 
         //Read size
         int read = channel.read(buffer);
-        int idLength = 0;
+        int byteCount = 0;
         if (read == 4) {
             buffer.flip();
-            idLength = buffer.getInt();
+            byteCount = buffer.getInt();
         } else {
-            throw new IOException("Could not read identifier length from the channel");
+            throw new IOException(
+                    "Could not read bytes length from the channel - "
+                            + " expected 4 bytes but got " + read + ".");
         }
         buffer = null;
 
-        if (idLength == -1)
+        if (byteCount == -1)
             return null;
 
         //Read the bytes
-        buffer = ByteBuffer.allocate(idLength);
+        buffer = ByteBuffer.allocate(byteCount);
         read = channel.read(buffer);
-        if (read != idLength) {
-            throw new IOException("Could not read identifier from the channel");
+        if (read != byteCount) {
+            throw new IOException(
+                    "Could not read bytes from the channel - expected "
+                            + byteCount + " bytes but got " + read + ".");
         }
         buffer.flip();
         return buffer.array();
@@ -279,27 +350,13 @@
     }
 
     public static byte[] convertObjectToBytes(Object object) throws IOException {
-
-        if (object instanceof Serializable) {
-            ByteArrayOutputStream baos = new ByteArrayOutputStream();
-            ObjectOutputStream stream = new ObjectOutputStream(baos);
-            stream.writeObject(object);
-            stream.flush();
-            stream.close();
-            return baos.toByteArray();
-        } else {
-            throw new RuntimeException("Invalid argument - Object"
-                    + " is not an instance of java.io.Serializable"
-                    + " or MarshalAware");
-        }
-
-        /**
-         *
-         * I don't think MarshalAware is necessary here anymore...Bill?
-         *
-         * Commenting this out until Bill agrees
-         *
-         *
+        /*
+         * MarshalAware is requried so objects that get put into the cache can
+         * take advantage of the faster way of serializaing objects, if they
+         * don't want to then they can skip it or for simplicity's sake they
+         * can start with Serizliazable then implement MarshalAware if 
+         * serizlization performance becomes a concern.
+         */
         if (object instanceof MarshalAware) {
             ByteArrayOutputStream baos = new ByteArrayOutputStream(34);
             WritableByteChannel channel = Channels.newChannel(baos);
@@ -318,8 +375,6 @@
                     + " is not an instance of java.io.Serializable"
                     + " or MarshalAware");
         }
-         *
-         */
     }
 
 }

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/BulkSendCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/BulkSendCommand.java?view=diff&rev=452247&r1=452246&r2=452247
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/BulkSendCommand.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/BulkSendCommand.java Mon Oct  2 15:29:51 2006
@@ -25,7 +25,11 @@
 import java.nio.channels.WritableByteChannel;
 import java.io.IOException;
 
-public class BulkSendCommand extends BaseCommand{
+/**
+ * This command is letting the client or server know that it can expext
+ * 'x' number of commands to follow
+ */
+public class BulkSendCommand extends BaseCommand {
 
     private int numberOfCommands;
 
@@ -54,7 +58,7 @@
         writeInt(channel, numberOfCommands);
     }
 
-    public void execute(CommandVisitor visitor) throws IOException{
+    public void execute(CommandVisitor visitor) throws IOException {
 
         visitor.processBulkSend(this);
     }

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/marshal/MarshalAware.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/marshal/MarshalAware.java?view=diff&rev=452247&r1=452246&r2=452247
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/marshal/MarshalAware.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/marshal/MarshalAware.java Mon Oct  2 15:29:51 2006
@@ -23,17 +23,33 @@
 import java.nio.channels.WritableByteChannel;
 
 /**
- * Implement this interface to specify that you want to marshal the object your self 
+ * Implementing this interface provides a way to optimize serilazation for
+ * distributed caching scenarios. If simply implementing java.io.Serializable
+ * provides sufficient performance then do that because its much simpler.
+ * 
+ * Implementors of this interface are expected to write/read any state into the
+ * channel that is provided. The read and write methods should read and write
+ * the data in the same order.
+ * 
+ * The gcache uses this interface to serialize and deserialize objects around
+ * the distributed cache. If this interface is not implemented the framework
+ * will revert to using java.io.Serializable to do the (de)serialization.
  */
 public interface MarshalAware {
     /**
-     * if you are part of a hiearchy call super.readExternal then read your bits
+     * Read data from <code>channel</code> to reconstitute the object. The
+     * data is read in the same order it was written in the writeExternal
+     * method.
+     * 
      * @param channel
      * @throws IOException
      */
     void readExternal(ReadableByteChannel channel) throws IOException;
     /**
-     * if you are part of a hiearchy call super.writeExternal then write your bits
+     * Write data into <code>channel</code> to save the state of the object.
+     * The data should be written in the same order it is expected in the
+     * readExternal method.
+     * 
      * @param channel
      * @throws IOException
      */

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/GCacheServer.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/GCacheServer.java?view=diff&rev=452247&r1=452246&r2=452247
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/GCacheServer.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/GCacheServer.java Mon Oct  2 15:29:51 2006
@@ -1,25 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 package org.apache.geronimo.gcache.server;
 
 import org.apache.geronimo.gcache.server.config.Configuration;
 import org.apache.geronimo.gcache.server.core.GCacheThread;
 
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
 public class GCacheServer {
 
     private final Configuration config;

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/config/Configuration.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/config/Configuration.java?view=diff&rev=452247&r1=452246&r2=452247
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/config/Configuration.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/config/Configuration.java Mon Oct  2 15:29:51 2006
@@ -1,8 +1,4 @@
-package org.apache.geronimo.gcache.server.config;
-
-import org.apache.geronimo.gcache.server.spi.ThreadPool;
-
-/**
+/*
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -19,6 +15,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+package org.apache.geronimo.gcache.server.config;
+
+import org.apache.geronimo.gcache.server.spi.ThreadPool;
+
 public class Configuration {
     private ThreadPool threadPool = null;
 

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/core/GCacheThread.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/core/GCacheThread.java?view=diff&rev=452247&r1=452246&r2=452247
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/core/GCacheThread.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/core/GCacheThread.java Mon Oct  2 15:29:51 2006
@@ -1,12 +1,4 @@
-package org.apache.geronimo.gcache.server.core;
-
-import org.apache.geronimo.gcache.server.spi.ThreadPool;
-import org.apache.geronimo.gcache.server.config.Configuration;
-
-import net.sf.ehcache.CacheManager;
-import net.sf.ehcache.Cache;
-
-/**
+/*
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -23,7 +15,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-public class GCacheThread extends Thread{
+package org.apache.geronimo.gcache.server.core;
+
+import net.sf.ehcache.CacheManager;
+
+import org.apache.geronimo.gcache.server.config.Configuration;
+import org.apache.geronimo.gcache.server.spi.ThreadPool;
+
+public class GCacheThread extends Thread {
 
     private boolean stopped;
     private boolean running;
@@ -47,7 +46,7 @@
 
         //TODO configure the cache here
 
-        while(!stopped){
+        while(!stopped) {
 
             //Comm component goes here...openwire preferred
         }

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/spi/ThreadPool.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/spi/ThreadPool.java?view=diff&rev=452247&r1=452246&r2=452247
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/spi/ThreadPool.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/spi/ThreadPool.java Mon Oct  2 15:29:51 2006
@@ -1,7 +1,4 @@
-package org.apache.geronimo.gcache.server.spi;
-
-/**
- *
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -17,6 +14,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+package org.apache.geronimo.gcache.server.spi;
+
 public interface ThreadPool {
 
     /**

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/SelectionKeyProcessorFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/SelectionKeyProcessorFactory.java?view=diff&rev=452247&r1=452246&r2=452247
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/SelectionKeyProcessorFactory.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/SelectionKeyProcessorFactory.java Mon Oct  2 15:29:51 2006
@@ -18,9 +18,6 @@
  */
 package org.apache.geronimo.gcache.transports.tcp;
 
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.logging.Log;
-
 import java.nio.channels.SelectionKey;
 
 public interface SelectionKeyProcessorFactory {

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPSocketHandler.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPSocketHandler.java?view=diff&rev=452247&r1=452246&r2=452247
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPSocketHandler.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPSocketHandler.java Mon Oct  2 15:29:51 2006
@@ -30,14 +30,16 @@
 import org.apache.geronimo.gcache.server.spi.ThreadPool;
 
 /**
+ * This class is the main worker of the gcache functionality. Essentialy this 
  */
 public class TCPSocketHandler extends ThreadSupport {
+    public static int DEFAULT_TIMEOUT = 2000;
     Log log = LogFactory.getLog(TCPSocketHandler.class);
 
     private SelectionKeyProcessorFactory processorFactory;
 
     private Selector selector = null;
-    private int timeOut = 0;
+    private int timeOut = DEFAULT_TIMEOUT;
     private ThreadPool pool;
 
     public TCPSocketHandler(int timeOut, SelectionKeyProcessorFactory processorFactory, ThreadPool pool) throws IOException {

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPSocketTransportServer.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPSocketTransportServer.java?view=diff&rev=452247&r1=452246&r2=452247
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPSocketTransportServer.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/TCPSocketTransportServer.java Mon Oct  2 15:29:51 2006
@@ -16,14 +16,14 @@
  */
 package org.apache.geronimo.gcache.transports.tcp;
 
-import org.apache.geronimo.gcache.server.spi.ThreadPool;
-import org.apache.geronimo.gcache.transports.TransportServer;
-
-import java.nio.channels.ServerSocketChannel;
-import java.nio.channels.SelectionKey;
+import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.net.ServerSocket;
-import java.io.IOException;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.ServerSocketChannel;
+
+import org.apache.geronimo.gcache.server.spi.ThreadPool;
+import org.apache.geronimo.gcache.transports.TransportServer;
 
 public class TCPSocketTransportServer implements TransportServer {
 
@@ -31,7 +31,7 @@
     private InetSocketAddress inet = null;
     private ThreadPool pool = null;
     private TCPSocketHandler handler = null;
-    private int timeOut = 0;
+    private int timeOut = TCPSocketHandler.DEFAULT_TIMEOUT;
     private SelectionKeyProcessorFactory processorFactory;
 
     public TCPSocketTransportServer(String address, int port, ThreadPool threadPool, int timeOut, SelectionKeyProcessorFactory processorFactory) {

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/ByteArray.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/ByteArray.java?view=diff&rev=452247&r1=452246&r2=452247
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/ByteArray.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/ByteArray.java Mon Oct  2 15:29:51 2006
@@ -85,7 +85,6 @@
         if (this.hash != 0){
             return this.hash;
         }
-        byte[] larray = array;
 
         int hash = length;
         for (int i = 0; i < length; i++) {

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/ByteSequence.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/ByteSequence.java?view=diff&rev=452247&r1=452246&r2=452247
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/ByteSequence.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/ByteSequence.java Mon Oct  2 15:29:51 2006
@@ -16,24 +16,6 @@
  */
 package org.apache.geronimo.gcache.util;
 
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
 public class ByteSequence {
     public byte[] data;
     public int offset;