geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgenen...@apache.org
Subject svn commit: r454718 - in /geronimo/sandbox/gcache/server/src: main/java/org/apache/geronimo/gcache/command/ main/java/org/apache/geronimo/gcache/server/impl/ main/java/org/apache/geronimo/gcache/transports/tcp/ main/java/org/apache/geronimo/gcache/util...
Date Tue, 10 Oct 2006 12:09:17 GMT
Author: jgenender
Date: Tue Oct 10 05:09:16 2006
New Revision: 454718

URL: http://svn.apache.org/viewvc?view=rev&rev=454718
Log:
Clean up code add log debugging

Added:
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/HexDump.java
  (with props)
Modified:
    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/command/ClearCacheCommand.java
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/Command.java
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/GetCacheCommand.java
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/MessageAckCommand.java
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/PutEntryCommand.java
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/PutSessionCommand.java
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/RemoveEntryCommand.java
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/RemoveSessionCommand.java
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/impl/DefaultThreadPoolImpl.java
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/DefaultSelectionKeyProcessor.java
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/SelectionKeyProcessor.java
    geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/BaseCommandTest.java
    geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/CachePayloadBaseCommandTest.java
    geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/ClearCacheCommandTest.java
    geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/PutEntryCommandTest.java
    geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/PutSessionCommandTest.java
    geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/RemoveEntryCommandTest.java
    geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/RemoveSessionCommandTest.java
    geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/AbstractServer.java
    geronimo/sandbox/gcache/server/src/test/resources/log4j.xml

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=454718&r1=454717&r2=454718
==============================================================================
--- 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
Tue Oct 10 05:09:16 2006
@@ -18,12 +18,11 @@
  */
 package org.apache.geronimo.gcache.command;
 
-import org.apache.geronimo.gcache.CacheInfoHolder;
-import org.apache.geronimo.gcache.transports.CommandVisitor;
-
+import java.io.IOException;
 import java.nio.channels.ReadableByteChannel;
 import java.nio.channels.WritableByteChannel;
-import java.io.IOException;
+
+import org.apache.geronimo.gcache.transports.CommandVisitor;
 
 /**
  * This command is letting the client or server know that it can expext

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/ClearCacheCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/ClearCacheCommand.java?view=diff&rev=454718&r1=454717&r2=454718
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/ClearCacheCommand.java
(original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/ClearCacheCommand.java
Tue Oct 10 05:09:16 2006
@@ -18,11 +18,9 @@
  */
 package org.apache.geronimo.gcache.command;
 
-import net.sf.ehcache.Cache;
-import org.apache.geronimo.gcache.CacheInfoHolder;
-import org.apache.geronimo.gcache.transports.CommandVisitor;
-
 import java.io.IOException;
+
+import org.apache.geronimo.gcache.transports.CommandVisitor;
 
 public class ClearCacheCommand extends CacheBaseCommand {
 

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/Command.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/Command.java?view=diff&rev=454718&r1=454717&r2=454718
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/Command.java
(original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/Command.java
Tue Oct 10 05:09:16 2006
@@ -18,11 +18,10 @@
  */
 package org.apache.geronimo.gcache.command;
 
+import java.io.IOException;
+
 import org.apache.geronimo.gcache.marshal.MarshalAware;
-import org.apache.geronimo.gcache.CacheInfoHolder;
 import org.apache.geronimo.gcache.transports.CommandVisitor;
-
-import java.io.IOException;
 
 /**
  * Commands are pushed around the cluster to the various nodes and they are

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/GetCacheCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/GetCacheCommand.java?view=diff&rev=454718&r1=454717&r2=454718
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/GetCacheCommand.java
(original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/GetCacheCommand.java
Tue Oct 10 05:09:16 2006
@@ -18,13 +18,9 @@
  */
 package org.apache.geronimo.gcache.command;
 
-import org.apache.geronimo.gcache.CacheInfoHolder;
-import org.apache.geronimo.gcache.transports.CommandVisitor;
-
 import java.io.IOException;
-import java.util.List;
 
-import net.sf.ehcache.Cache;
+import org.apache.geronimo.gcache.transports.CommandVisitor;
 
 /**
  * This class represents a request to obtain a copy of an

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/MessageAckCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/MessageAckCommand.java?view=diff&rev=454718&r1=454717&r2=454718
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/MessageAckCommand.java
(original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/MessageAckCommand.java
Tue Oct 10 05:09:16 2006
@@ -18,12 +18,11 @@
  */
 package org.apache.geronimo.gcache.command;
 
-import org.apache.geronimo.gcache.CacheInfoHolder;
-import org.apache.geronimo.gcache.transports.CommandVisitor;
-
 import java.io.IOException;
 import java.nio.channels.ReadableByteChannel;
 import java.nio.channels.WritableByteChannel;
+
+import org.apache.geronimo.gcache.transports.CommandVisitor;
 
 public class MessageAckCommand extends BaseCommand{
 

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/PutEntryCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/PutEntryCommand.java?view=diff&rev=454718&r1=454717&r2=454718
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/PutEntryCommand.java
(original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/PutEntryCommand.java
Tue Oct 10 05:09:16 2006
@@ -18,16 +18,9 @@
  */
 package org.apache.geronimo.gcache.command;
 
-import org.apache.geronimo.gcache.CacheInfoHolder;
-import org.apache.geronimo.gcache.transports.CommandVisitor;
-import org.apache.geronimo.gcache.util.ByteArray;
-import net.sf.ehcache.Cache;
-import net.sf.ehcache.Element;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Collections;
 import java.io.IOException;
+
+import org.apache.geronimo.gcache.transports.CommandVisitor;
 
 public class PutEntryCommand extends CachePayloadBaseCommand {
 

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/PutSessionCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/PutSessionCommand.java?view=diff&rev=454718&r1=454717&r2=454718
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/PutSessionCommand.java
(original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/PutSessionCommand.java
Tue Oct 10 05:09:16 2006
@@ -18,12 +18,6 @@
  */
 package org.apache.geronimo.gcache.command;
 
-import org.apache.geronimo.gcache.util.ByteArray;
-import org.apache.geronimo.gcache.util.ByteArrayInputStream;
-import org.apache.geronimo.gcache.util.ByteArrayOutputStream;
-import org.apache.geronimo.gcache.CacheInfoHolder;
-import org.apache.geronimo.gcache.transports.CommandVisitor;
-
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.channels.Channels;
@@ -34,8 +28,10 @@
 import java.util.Map;
 import java.util.Set;
 
-import net.sf.ehcache.Cache;
-import net.sf.ehcache.Element;
+import org.apache.geronimo.gcache.transports.CommandVisitor;
+import org.apache.geronimo.gcache.util.ByteArray;
+import org.apache.geronimo.gcache.util.ByteArrayInputStream;
+import org.apache.geronimo.gcache.util.ByteArrayOutputStream;
 
 public class PutSessionCommand extends CachePayloadBaseCommand {
 

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/RemoveEntryCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/RemoveEntryCommand.java?view=diff&rev=454718&r1=454717&r2=454718
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/RemoveEntryCommand.java
(original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/RemoveEntryCommand.java
Tue Oct 10 05:09:16 2006
@@ -18,17 +18,9 @@
  */
 package org.apache.geronimo.gcache.command;
 
-import org.apache.geronimo.gcache.CacheInfoHolder;
-import org.apache.geronimo.gcache.transports.CommandVisitor;
-import org.apache.geronimo.gcache.util.ByteArray;
-
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Collections;
 import java.io.IOException;
 
-import net.sf.ehcache.Element;
-import net.sf.ehcache.Cache;
+import org.apache.geronimo.gcache.transports.CommandVisitor;
 
 public class RemoveEntryCommand extends CacheBaseCommand{
 

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/RemoveSessionCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/RemoveSessionCommand.java?view=diff&rev=454718&r1=454717&r2=454718
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/RemoveSessionCommand.java
(original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/RemoveSessionCommand.java
Tue Oct 10 05:09:16 2006
@@ -18,11 +18,9 @@
  */
 package org.apache.geronimo.gcache.command;
 
-import net.sf.ehcache.Cache;
-import org.apache.geronimo.gcache.CacheInfoHolder;
-import org.apache.geronimo.gcache.transports.CommandVisitor;
-
 import java.io.IOException;
+
+import org.apache.geronimo.gcache.transports.CommandVisitor;
 
 public class RemoveSessionCommand extends CacheBaseCommand{
 

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/impl/DefaultThreadPoolImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/impl/DefaultThreadPoolImpl.java?view=diff&rev=454718&r1=454717&r2=454718
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/impl/DefaultThreadPoolImpl.java
(original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/impl/DefaultThreadPoolImpl.java
Tue Oct 10 05:09:16 2006
@@ -19,10 +19,10 @@
 package org.apache.geronimo.gcache.server.impl;
 
 import org.apache.geronimo.gcache.server.spi.ThreadPool;
+
 import edu.emory.mathcs.backport.java.util.concurrent.ArrayBlockingQueue;
 import edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor;
 import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
-import edu.emory.mathcs.backport.java.util.concurrent.Executors;
 
 /**
  * Default implementation for a simple Thread Pool

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/DefaultSelectionKeyProcessor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/DefaultSelectionKeyProcessor.java?view=diff&rev=454718&r1=454717&r2=454718
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/DefaultSelectionKeyProcessor.java
(original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/DefaultSelectionKeyProcessor.java
Tue Oct 10 05:09:16 2006
@@ -24,6 +24,7 @@
 import org.apache.geronimo.gcache.command.Command;
 import org.apache.geronimo.gcache.command.CommandTypes;
 import org.apache.geronimo.gcache.util.BufferChannelReader;
+import org.apache.geronimo.gcache.util.HexDump;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
@@ -38,105 +39,168 @@
 
 public class DefaultSelectionKeyProcessor extends SelectionKeyProcessor {
 
-    private static Log log = LogFactory.getLog(DefaultSelectionKeyProcessor.class);
+    private static Log log = LogFactory
+	    .getLog(DefaultSelectionKeyProcessor.class);
 
     private final static int HEADER_SIZE = Constants.MAGIC.length + 1 + 8 + 4;
+
     private CacheInfoHolder infoHolder = null;
+
     private SelectionKey key;
 
-    public DefaultSelectionKeyProcessor(CacheInfoHolder infoHolder, SelectionKey key) {
-        this.infoHolder = infoHolder;
-        this.key = key;
+    public DefaultSelectionKeyProcessor(CacheInfoHolder infoHolder,
+	    SelectionKey key) {
+	this.infoHolder = infoHolder;
+	this.key = key;
     }
 
     public void process() throws IOException {
-        SocketChannel channel = (SocketChannel) key.channel();
+	SocketChannel channel = (SocketChannel) key.channel();
 
-        // HEADER BREAKDOWN
-        // ---------------------------------------------------------
-        // MAGIC HEADER - 6 bytes
-        // COMMAND - 1 byte
-        // CHECKSUM - 8 bytes
-        // COMMAND LENGTH - 4 bytes
-        // COMMAND - ? bytes as defined above
-        ByteBuffer buffer = ByteBuffer.allocate(HEADER_SIZE);
-        BufferChannelReader bcr = new BufferChannelReader(channel, buffer);
-        int count = bcr.readBuffer(HEADER_SIZE);
-        if (count < HEADER_SIZE) {
-            //Nope...we are outta here
-            disconnect(channel);
-            return;
-        }
-        buffer.flip();
-
-        //Read the magic
-        byte magic[] = new byte[Constants.MAGIC.length];
-        buffer.get(magic);
-
-        //Better match the Magic
-        if (!Arrays.equals(Constants.MAGIC, magic)) {
-            //Magic doesn't match, so close the socket
-            disconnect(channel);
-            return;
-        }
-
-        //Get the command
-        byte commandIdentifier = buffer.get();
-
-        //Get the checksum
-        long checksum = buffer.getLong();
-
-        //Get the command length
-        int length = buffer.getInt();
-
-        //TODO - This really should be done with a ByteBuffer pool
-        ByteBuffer commandBuffer = ByteBuffer.allocate(length);
-        bcr.reset(channel, commandBuffer);
-        count = bcr.readBuffer(length);
-        if (count < 0) {
-            //Remove the endpoint from the list of clients
-            infoHolder.getEndpointManager().removeEndpoint(new TCPEndpoint(channel));
-            channel.close();
-            return;
-        }
-        if (count < length) {
-            //Command was bad
-            //TODO - Send back a resend?
-            return;
-
-        }
-
-        byte commandArray[] = commandBuffer.array();
-        Checksum calcChecksum = new CRC32();
-        calcChecksum.update(commandArray, 0, commandArray.length);
-        long newCheck  = calcChecksum.getValue();
-        if (newCheck != checksum){
-            //TODO send a resubmit??
-            return;
-        }
-
-        ByteArrayInputStream bias = new ByteArrayInputStream(commandBuffer.array());
-        ReadableByteChannel readChannel = Channels.newChannel(bias);
-
-        //Create the command and unmarshal the data
-        Command command = CommandTypes.createCommand(commandIdentifier);
-        command.readExternal(readChannel);
-
-        //Do something with the data
-        TCPCommandVisitor visitor = new TCPCommandVisitor(infoHolder, key);
-        command.execute(visitor);
+	if (log.isDebugEnabled()) {
+	    log.debug("Process called and receiving data from "
+		    + channel.socket().getRemoteSocketAddress());
+	}
+
+	// HEADER BREAKDOWN
+	// ---------------------------------------------------------
+	// MAGIC HEADER - 6 bytes
+	// COMMAND - 1 byte
+	// CHECKSUM - 8 bytes
+	// COMMAND LENGTH - 4 bytes
+	// COMMAND - ? bytes as defined above
+	ByteBuffer buffer = ByteBuffer.allocate(HEADER_SIZE);
+	BufferChannelReader bcr = new BufferChannelReader(channel, buffer);
+	int count = bcr.readBuffer(HEADER_SIZE);
+	if (count < HEADER_SIZE) {
+	    if (log.isDebugEnabled()) {
+		log.debug("Header != " + HEADER_SIZE
+			+ " in length...disconnecting client.");
+	    }
+
+	    infoHolder.getEndpointManager().removeEndpoint(
+		    new TCPEndpoint(channel));
+
+	    // Nope...we are outta here
+	    disconnect(channel);
+	    return;
+	}
+	buffer.flip();
+	if (log.isDebugEnabled()) {
+	    log.debug("Header read:");
+	    log.debug(HexDump.hexString(buffer.array()));
+	}
+
+	// Read the magic
+	byte magic[] = new byte[Constants.MAGIC.length];
+	buffer.get(magic);
+
+	// Better match the Magic
+	if (!Arrays.equals(Constants.MAGIC, magic)) {
+
+	    // Magic doesn't match, so close the socket
+	    if (log.isDebugEnabled()) {
+		log.debug("Magic did not match...disconnecting client.");
+	    }
+	    infoHolder.getEndpointManager().removeEndpoint(
+		    new TCPEndpoint(channel));
+
+	    disconnect(channel);
+	    return;
+	}
+
+	if (log.isDebugEnabled()) {
+	    log.debug("Magic found");
+	}
+
+	// Get the command
+	byte commandIdentifier = buffer.get();
+	if (log.isDebugEnabled()) {
+	    log.debug("Command Identifier = " + commandIdentifier);
+	}
+
+	// Get the checksum
+	long checksum = buffer.getLong();
+	if (log.isDebugEnabled()) {
+	    log.debug("Command checksum = " + checksum);
+	}
+
+	// Get the command length
+	int length = buffer.getInt();
+	if (log.isDebugEnabled()) {
+	    log.debug("Command length = " + length);
+	}
+
+	// TODO - This really should be done with a ByteBuffer pool
+	ByteBuffer commandBuffer = ByteBuffer.allocate(length);
+	bcr.reset(channel, commandBuffer);
+	count = bcr.readBuffer(length);
+	if (count < 0) {
+	    if (log.isDebugEnabled()) {
+		log.debug("Client disconnected...removing endpoint.");
+	    }
+	    // Remove the endpoint from the list of clients
+	    infoHolder.getEndpointManager().removeEndpoint(
+		    new TCPEndpoint(channel));
+	    channel.close();
+	    return;
+	}
+	if (count < length) {
+	    // Command was bad
+	    if (log.isDebugEnabled()) {
+		log.debug("Command read size (" + count
+			+ ") did not equal expected length (" + length + ")");
+	    }
+	    // TODO - Send back a resend?
+	    return;
+
+	}
+
+	byte commandArray[] = commandBuffer.array();
+
+	if (log.isDebugEnabled()) {
+	    log.debug("Command read:");
+	    log.debug(HexDump.hexString(commandArray));
+	}
+	Checksum calcChecksum = new CRC32();
+	calcChecksum.update(commandArray, 0, commandArray.length);
+	long newCheck = calcChecksum.getValue();
+	if (newCheck != checksum) {
+	    if (log.isDebugEnabled()) {
+		log.debug("Calculated checksum (" + newCheck + " did not equal expected ("+ checksum +
")");
+	    }
+	    // TODO send a resubmit??
+	    return;
+	}
+	if (log.isDebugEnabled()) {
+	    log.debug("Checksums matched.");
+	}
+
+	ByteArrayInputStream bias = new ByteArrayInputStream(commandBuffer
+		.array());
+	ReadableByteChannel readChannel = Channels.newChannel(bias);
+
+	// Create the command and unmarshal the data
+	Command command = CommandTypes.createCommand(commandIdentifier);
+	if (log.isDebugEnabled()) {
+	    log.debug("Command is a " + command.getClass().getSimpleName());
+	}
+	command.readExternal(readChannel);
+
+	// Do something with the data
+	TCPCommandVisitor visitor = new TCPCommandVisitor(infoHolder, key);
+	command.execute(visitor);
 
     }
 
     private void disconnect(SocketChannel channel) throws IOException {
-        try {
-            channel.socket().shutdownOutput();
-        } catch (IOException e) {
-            // It seems you have to ignore this due to lots of
-            // transport endpoint not connected issues.
-        }
-        channel.close();
+	try {
+	    channel.socket().shutdownOutput();
+	} catch (IOException e) {
+	    // It seems you have to ignore this due to lots of
+	    // transport endpoint not connected issues.
+	}
+	channel.close();
     }
-
 
 }

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/SelectionKeyProcessor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/SelectionKeyProcessor.java?view=diff&rev=454718&r1=454717&r2=454718
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/SelectionKeyProcessor.java
(original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/SelectionKeyProcessor.java
Tue Oct 10 05:09:16 2006
@@ -18,11 +18,10 @@
  */
 package org.apache.geronimo.gcache.transports.tcp;
 
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.logging.Log;
-
 import java.io.IOException;
-import java.nio.channels.SelectionKey;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * Processes the reciept of data

Added: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/HexDump.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/HexDump.java?view=auto&rev=454718
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/HexDump.java
(added)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/HexDump.java
Tue Oct 10 05:09:16 2006
@@ -0,0 +1,49 @@
+/**
+ *
+ * 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.util;
+
+public class HexDump {
+    
+    public static String hexString(byte[] b) {
+	StringBuffer sb = new StringBuffer();
+        sb.append("\n");
+        for (int i = 0; i < b.length; ++i) {
+            if (i % 16 == 0) {
+                sb.append(Integer.toHexString ((i & 0xFFFF) | 0x10000).substring(1,5)
+ " - ");
+            }
+            sb.append(Integer.toHexString((b[i]&0xFF) | 0x100).substring(1,3) + " ");
+            if (i % 16 == 15 || i == b.length - 1)
+            {
+                int j;
+                for (j = 16 - i % 16; j > 1; --j)
+                    sb.append("   ");
+                sb.append(" - ");
+                int start = (i / 16) * 16;
+                int end = (b.length < i + 1) ? b.length : (i + 1);
+                for (j = start; j < end; ++j)
+                    if (b[j] >= 32 && b[j] <= 126)
+                        sb.append((char)b[j]);
+                    else
+                        sb.append(".");
+                sb.append("\n");
+            }
+        }
+        return 	sb.toString();
+    }
+    
+}

Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/HexDump.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/HexDump.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/HexDump.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/BaseCommandTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/BaseCommandTest.java?view=diff&rev=454718&r1=454717&r2=454718
==============================================================================
--- geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/BaseCommandTest.java
(original)
+++ geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/BaseCommandTest.java
Tue Oct 10 05:09:16 2006
@@ -18,15 +18,6 @@
  */
 package org.apache.geronimo.gcache.command;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.nio.ByteBuffer;
-import java.nio.channels.Channels;
-import java.nio.channels.ReadableByteChannel;
-import java.nio.channels.WritableByteChannel;
-import java.nio.charset.Charset;
-
-import org.testng.annotations.Test;
 
 public class BaseCommandTest {
 /**

Modified: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/CachePayloadBaseCommandTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/CachePayloadBaseCommandTest.java?view=diff&rev=454718&r1=454717&r2=454718
==============================================================================
--- geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/CachePayloadBaseCommandTest.java
(original)
+++ geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/CachePayloadBaseCommandTest.java
Tue Oct 10 05:09:16 2006
@@ -18,11 +18,11 @@
  */
 package org.apache.geronimo.gcache.command;
 
-import org.testng.annotations.Test;
-
 import java.io.ByteArrayInputStream;
-import java.nio.channels.ReadableByteChannel;
 import java.nio.channels.Channels;
+import java.nio.channels.ReadableByteChannel;
+
+import org.testng.annotations.Test;
 
 public class CachePayloadBaseCommandTest {
 
@@ -49,7 +49,7 @@
         readCommand.readExternal(channel);
 
         byte readData[] = readCommand.getRawPayload();
-        String readString = (String)readCommand.convertObjectFromBytes(readData);
+        String readString = (String)BaseCommand.convertObjectFromBytes(readData);
         assert readString.equals(data);
 
         assert readCommand.getCommandId() == commandId;

Modified: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/ClearCacheCommandTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/ClearCacheCommandTest.java?view=diff&rev=454718&r1=454717&r2=454718
==============================================================================
--- geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/ClearCacheCommandTest.java
(original)
+++ geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/ClearCacheCommandTest.java
Tue Oct 10 05:09:16 2006
@@ -18,15 +18,13 @@
  */
 package org.apache.geronimo.gcache.command;
 
-import org.testng.annotations.Test;
-import org.apache.geronimo.gcache.CacheInfoHolder;
-import org.apache.geronimo.gcache.transports.tcp.TCPCommandVisitor;
-import net.sf.ehcache.CacheManager;
 import net.sf.ehcache.Cache;
+import net.sf.ehcache.CacheManager;
 import net.sf.ehcache.Element;
 
-import java.nio.channels.SelectionKey;
-import java.nio.channels.Channels;
+import org.apache.geronimo.gcache.CacheInfoHolder;
+import org.apache.geronimo.gcache.transports.tcp.TCPCommandVisitor;
+import org.testng.annotations.Test;
 
 public class ClearCacheCommandTest {
 

Modified: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/PutEntryCommandTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/PutEntryCommandTest.java?view=diff&rev=454718&r1=454717&r2=454718
==============================================================================
--- geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/PutEntryCommandTest.java
(original)
+++ geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/PutEntryCommandTest.java
Tue Oct 10 05:09:16 2006
@@ -59,10 +59,10 @@
         assert element != null;
 
         Map sessionMap = (Map)element.getObjectValue();
-        byte rawKey[] = command.convertObjectToBytes(key);
+        byte rawKey[] = BaseCommand.convertObjectToBytes(key);
         byte[] testData = (byte[])sessionMap.get(new ByteArray(rawKey));
         assert testData != null;
-        String savedString = (String)command.convertObjectFromBytes(testData);
+        String savedString = (String)BaseCommand.convertObjectFromBytes(testData);
         assert data.equals(savedString);
     }
 }

Modified: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/PutSessionCommandTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/PutSessionCommandTest.java?view=diff&rev=454718&r1=454717&r2=454718
==============================================================================
--- geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/PutSessionCommandTest.java
(original)
+++ geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/PutSessionCommandTest.java
Tue Oct 10 05:09:16 2006
@@ -18,21 +18,18 @@
  */
 package org.apache.geronimo.gcache.command;
 
-import org.testng.annotations.Test;
-import org.testng.annotations.BeforeSuite;
-import org.apache.geronimo.gcache.CacheInfoHolder;
-import org.apache.geronimo.gcache.transports.tcp.TCPCommandVisitor;
-import org.apache.geronimo.gcache.util.ByteArray;
-import net.sf.ehcache.CacheManager;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
 import net.sf.ehcache.Cache;
+import net.sf.ehcache.CacheManager;
 import net.sf.ehcache.Element;
 
-import java.io.IOException;
-import java.util.Map;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.HashMap;
-import java.util.Collections;
+import org.apache.geronimo.gcache.CacheInfoHolder;
+import org.apache.geronimo.gcache.transports.tcp.TCPCommandVisitor;
+import org.testng.annotations.Test;
 
 public class PutSessionCommandTest {
 

Modified: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/RemoveEntryCommandTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/RemoveEntryCommandTest.java?view=diff&rev=454718&r1=454717&r2=454718
==============================================================================
--- geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/RemoveEntryCommandTest.java
(original)
+++ geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/RemoveEntryCommandTest.java
Tue Oct 10 05:09:16 2006
@@ -32,6 +32,7 @@
 public class RemoveEntryCommandTest {
 
     @Test
+    @SuppressWarnings("unchecked")
     public void testRemoveEntry() throws Exception {
         String cacheName = "Test";
         String key = "My Key";
@@ -69,7 +70,7 @@
 
         Map theSession = (Map)element.getObjectValue();
 
-        byte rawKey[] = command.convertObjectToBytes(key);
+        byte rawKey[] = BaseCommand.convertObjectToBytes(key);
 
         //Should not find any data
         byte[] testData = (byte[])theSession.get(new ByteArray(rawKey));

Modified: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/RemoveSessionCommandTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/RemoveSessionCommandTest.java?view=diff&rev=454718&r1=454717&r2=454718
==============================================================================
--- geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/RemoveSessionCommandTest.java
(original)
+++ geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/RemoveSessionCommandTest.java
Tue Oct 10 05:09:16 2006
@@ -31,6 +31,7 @@
 
 public class RemoveSessionCommandTest {
     @Test
+    @SuppressWarnings("unchecked")
     public void testRemoveEntry() throws Exception {
         String cacheName = "Test";
         String key = "My Key";

Modified: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/AbstractServer.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/AbstractServer.java?view=diff&rev=454718&r1=454717&r2=454718
==============================================================================
--- geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/AbstractServer.java
(original)
+++ geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/AbstractServer.java
Tue Oct 10 05:09:16 2006
@@ -40,9 +40,7 @@
 import org.apache.geronimo.gcache.util.BufferChannelWriter;
 import org.apache.geronimo.gcache.util.ByteArrayInputStream;
 import org.testng.annotations.AfterClass;
-import org.testng.annotations.AfterSuite;
 import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeSuite;
 
 public abstract class AbstractServer {
     protected static final int port = 45678;

Modified: geronimo/sandbox/gcache/server/src/test/resources/log4j.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/test/resources/log4j.xml?view=diff&rev=454718&r1=454717&r2=454718
==============================================================================
--- geronimo/sandbox/gcache/server/src/test/resources/log4j.xml (original)
+++ geronimo/sandbox/gcache/server/src/test/resources/log4j.xml Tue Oct 10 05:09:16 2006
@@ -15,7 +15,7 @@
    </category>
 
 	<root>
-		<priority value="info"/>
+		<priority value="debug"/>
 		<appender-ref ref="ConsoleAppender"/>
 	</root>
 



Mime
View raw message