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/02 19:25:26 UTC
svn commit: r452135 - in /geronimo/sandbox/gcache/server/src:
main/java/org/apache/geronimo/gcache/server/impl/
main/java/org/apache/geronimo/gcache/transports/tcp/
main/java/org/apache/geronimo/gcache/util/
test/java/org/apache/geronimo/gcache/transpo...
Author: jgenender
Date: Mon Oct 2 10:25:25 2006
New Revision: 452135
URL: http://svn.apache.org/viewvc?view=rev&rev=452135
Log:
Add in thread pool
Added:
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/DefaultSelectionKeyProcessorFactory.java (with props)
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/SelectionKeyProcessorFactory.java (with props)
geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/MockSelectionKeyProcessorFactory.java (with props)
Modified:
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/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/BufferChannelInputStream.java
geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/MockSelectionKeyProcessor.java
geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/TcpSocketServerTest.java
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=452135&r1=452134&r2=452135
==============================================================================
--- 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 Mon Oct 2 10:25:25 2006
@@ -19,7 +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.*;
+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
@@ -41,6 +44,8 @@
*/
private final ThreadPoolExecutor pool;
+ private ArrayBlockingQueue workQueue = null;
+
/**
* Default constructor
*/
@@ -61,7 +66,8 @@
* @param poolSize - Size of the pool
*/
public DefaultThreadPoolImpl(int coreSize, int poolSize, long keepAliveTime, int queueSize) {
- pool = new ThreadPoolExecutor(poolSize, poolSize, keepAliveTime, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(queueSize));
+ this.workQueue = new ArrayBlockingQueue(queueSize);
+ pool = new ThreadPoolExecutor(poolSize, poolSize, keepAliveTime, TimeUnit.MILLISECONDS, workQueue);
}
/**
@@ -69,7 +75,7 @@
* @param command
*/
public void execute(Runnable command) {
- pool.execute(command);
+ pool.submit(command);
}
/**
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=452135&r1=452134&r2=452135
==============================================================================
--- 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 Mon Oct 2 10:25:25 2006
@@ -18,34 +18,38 @@
*/
package org.apache.geronimo.gcache.transports.tcp;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.geronimo.gcache.CacheInfoHolder;
-import org.apache.geronimo.gcache.util.BufferChannelInputStream;
-import org.apache.geronimo.gcache.util.BufferChannelReader;
import org.apache.geronimo.gcache.command.Command;
import org.apache.geronimo.gcache.command.CommandTypes;
-import org.apache.geronimo.gcache.command.BaseCommand;
+import org.apache.geronimo.gcache.util.BufferChannelReader;
-import java.io.IOException;
import java.io.ByteArrayInputStream;
+import java.io.IOException;
import java.nio.ByteBuffer;
+import java.nio.channels.Channels;
+import java.nio.channels.ReadableByteChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;
-import java.nio.channels.ReadableByteChannel;
-import java.nio.channels.Channels;
import java.util.Arrays;
-import java.util.zip.Checksum;
import java.util.zip.CRC32;
+import java.util.zip.Checksum;
-public class DefaultSelectionKeyProcessor implements SelectionKeyProcessor {
+public class DefaultSelectionKeyProcessor extends SelectionKeyProcessor {
+
+ 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) {
+ public DefaultSelectionKeyProcessor(CacheInfoHolder infoHolder, SelectionKey key) {
this.infoHolder = infoHolder;
+ this.key = key;
}
- public void process(SelectionKey key) throws IOException {
+ public void process() throws IOException {
SocketChannel channel = (SocketChannel) key.channel();
// HEADER BREAKDOWN
@@ -56,7 +60,6 @@
// 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) {
@@ -128,5 +131,6 @@
}
channel.close();
}
+
}
Added: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/DefaultSelectionKeyProcessorFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/DefaultSelectionKeyProcessorFactory.java?view=auto&rev=452135
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/DefaultSelectionKeyProcessorFactory.java (added)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/DefaultSelectionKeyProcessorFactory.java Mon Oct 2 10:25:25 2006
@@ -0,0 +1,36 @@
+/*
+ * 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.transports.tcp;
+
+import org.apache.geronimo.gcache.CacheInfoHolder;
+
+import java.nio.channels.SelectionKey;
+
+public class DefaultSelectionKeyProcessorFactory implements SelectionKeyProcessorFactory{
+
+ private CacheInfoHolder infoHolder;
+
+ public DefaultSelectionKeyProcessorFactory(CacheInfoHolder infoHolder) {
+ this.infoHolder = infoHolder;
+ }
+
+ public SelectionKeyProcessor createSelectionKeyProcessor(SelectionKey key) {
+ return new DefaultSelectionKeyProcessor(infoHolder, key);
+ }
+}
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/DefaultSelectionKeyProcessorFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/DefaultSelectionKeyProcessorFactory.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/DefaultSelectionKeyProcessorFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
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=452135&r1=452134&r2=452135
==============================================================================
--- 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 Mon Oct 2 10:25:25 2006
@@ -18,20 +18,28 @@
*/
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;
/**
* Processes the reciept of data
- * $Revision$
+ * $Revision$
*/
-public interface SelectionKeyProcessor {
- /**
- * the key is expected to contain cache updates
- * first byte is the command identifier
- *
- * @param key
- * @throws IOException
- */
- void process(SelectionKey key) throws IOException;
+public abstract class SelectionKeyProcessor implements Runnable {
+
+ private static Log log = LogFactory.getLog(SelectionKeyProcessor.class);
+
+ abstract void process() throws IOException;
+
+ public void run() {
+ try {
+ process();
+ } catch (IOException e) {
+ log.error(e);
+ }
+ }
+
}
Added: 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=auto&rev=452135
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/SelectionKeyProcessorFactory.java (added)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/SelectionKeyProcessorFactory.java Mon Oct 2 10:25:25 2006
@@ -0,0 +1,29 @@
+/*
+ * 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.transports.tcp;
+
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.Log;
+
+import java.nio.channels.SelectionKey;
+
+public interface SelectionKeyProcessorFactory {
+
+ SelectionKeyProcessor createSelectionKeyProcessor(SelectionKey key);
+}
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/SelectionKeyProcessorFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/SelectionKeyProcessorFactory.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/transports/tcp/SelectionKeyProcessorFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
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=452135&r1=452134&r2=452135
==============================================================================
--- 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 10:25:25 2006
@@ -27,26 +27,30 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.geronimo.gcache.ThreadSupport;
+import org.apache.geronimo.gcache.server.spi.ThreadPool;
/**
*/
public class TCPSocketHandler extends ThreadSupport {
Log log = LogFactory.getLog(TCPSocketHandler.class);
- private SelectionKeyProcessor processor;
+ private SelectionKeyProcessorFactory processorFactory;
private Selector selector = null;
private int timeOut = 0;
+ private ThreadPool pool;
- public TCPSocketHandler(int timeOut, SelectionKeyProcessor processor) throws IOException{
+ public TCPSocketHandler(int timeOut, SelectionKeyProcessorFactory processorFactory, ThreadPool pool) throws IOException {
this.timeOut = timeOut;
- this.processor = processor;
+ this.processorFactory = processorFactory;
+
+ this.pool = pool;
selector = Selector.open();
}
- public void register(SelectableChannel channel, int ops) throws IOException{
+ public void register(SelectableChannel channel, int ops) throws IOException {
channel.configureBlocking(false);
channel.register(selector, ops);
}
@@ -69,7 +73,7 @@
//Pull it off the queue for handling
iter.remove();
- if (!key.isValid()){
+ if (!key.isValid()) {
key.cancel();
}
@@ -81,7 +85,8 @@
register(channel, SelectionKey.OP_READ);
}
if (key.isReadable()) {
- processor.process(key);
+ key.interestOps(key.interestOps() & (~SelectionKey.OP_READ));
+ pool.execute(processorFactory.createSelectionKeyProcessor(key));
}
}
} catch (Exception e) {
@@ -96,7 +101,7 @@
selector.wakeup();
//Wait until everything is shutdown
- while (isRunning()){
+ while (isRunning()) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
@@ -116,13 +121,4 @@
throw new RuntimeException(e);
}
}
-
- public SelectionKeyProcessor getProcessor() {
- return processor;
- }
-
- public void setProcessor(SelectionKeyProcessor processor) {
- this.processor = processor;
- }
-
}
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=452135&r1=452134&r2=452135
==============================================================================
--- 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 10:25:25 2006
@@ -32,14 +32,14 @@
private ThreadPool pool = null;
private TCPSocketHandler handler = null;
private int timeOut = 0;
- private SelectionKeyProcessor processor;
+ private SelectionKeyProcessorFactory processorFactory;
- public TCPSocketTransportServer(String address, int port, ThreadPool threadPool, int timeOut, SelectionKeyProcessor processor) {
+ public TCPSocketTransportServer(String address, int port, ThreadPool threadPool, int timeOut, SelectionKeyProcessorFactory processorFactory) {
inet = new InetSocketAddress(address, port);
pool = threadPool;
this.timeOut = timeOut;
- this.processor = processor;
+ this.processorFactory = processorFactory;
}
@@ -48,7 +48,7 @@
server = ServerSocketChannel.open();
server.configureBlocking(false);
//TODO: refactor so this impl is not created here but instead its deferred
- handler = new TCPSocketHandler(timeOut, processor);
+ handler = new TCPSocketHandler(timeOut, processorFactory, pool);
// bind the server to the address
ServerSocket socket = server.socket();
Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/BufferChannelInputStream.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/BufferChannelInputStream.java?view=diff&rev=452135&r1=452134&r2=452135
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/BufferChannelInputStream.java (original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/util/BufferChannelInputStream.java Mon Oct 2 10:25:25 2006
@@ -18,15 +18,13 @@
*/
package org.apache.geronimo.gcache.util;
-import java.io.InputStream;
import java.io.IOException;
-import java.nio.channels.SelectableChannel;
-import java.nio.channels.Channel;
-import java.nio.channels.SocketChannel;
-import java.nio.channels.Selector;
-import java.nio.channels.SelectionKey;
-import java.nio.ByteBuffer;
+import java.io.InputStream;
import java.nio.BufferUnderflowException;
+import java.nio.ByteBuffer;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.Selector;
+import java.nio.channels.SocketChannel;
/**
* Provides an input stream to read a socket channel and fill a buffer
Modified: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/MockSelectionKeyProcessor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/MockSelectionKeyProcessor.java?view=diff&rev=452135&r1=452134&r2=452135
==============================================================================
--- geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/MockSelectionKeyProcessor.java (original)
+++ geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/MockSelectionKeyProcessor.java Mon Oct 2 10:25:25 2006
@@ -27,9 +27,15 @@
/**
* Provides a simple processor that will print what it reads
*/
-public class MockSelectionKeyProcessor implements SelectionKeyProcessor {
+public class MockSelectionKeyProcessor extends SelectionKeyProcessor {
- public void process(SelectionKey key) throws IOException {
+ private SelectionKey key;
+
+ public MockSelectionKeyProcessor(SelectionKey key) {
+ this.key = key;
+ }
+
+ public void process() throws IOException {
System.out.println("READ");
SocketChannel channel = (SocketChannel) key.channel();
Added: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/MockSelectionKeyProcessorFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/MockSelectionKeyProcessorFactory.java?view=auto&rev=452135
==============================================================================
--- geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/MockSelectionKeyProcessorFactory.java (added)
+++ geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/MockSelectionKeyProcessorFactory.java Mon Oct 2 10:25:25 2006
@@ -0,0 +1,27 @@
+/*
+ * 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.transports.tcp;
+
+import java.nio.channels.SelectionKey;
+
+public class MockSelectionKeyProcessorFactory implements SelectionKeyProcessorFactory{
+ public SelectionKeyProcessor createSelectionKeyProcessor(SelectionKey key) {
+ return new MockSelectionKeyProcessor(key);
+ }
+}
Propchange: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/MockSelectionKeyProcessorFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/MockSelectionKeyProcessorFactory.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/MockSelectionKeyProcessorFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/TcpSocketServerTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/TcpSocketServerTest.java?view=diff&rev=452135&r1=452134&r2=452135
==============================================================================
--- geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/TcpSocketServerTest.java (original)
+++ geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/TcpSocketServerTest.java Mon Oct 2 10:25:25 2006
@@ -38,6 +38,7 @@
private static final String host = "localhost";
TransportServer server = null;
+ ThreadPool pool;
@Test()
public void sendSession() throws Exception {
@@ -67,12 +68,12 @@
@BeforeSuite
public void setUp() throws Exception{
- ThreadPool pool = new DefaultThreadPoolImpl(10);
+ pool = new DefaultThreadPoolImpl(10);
CacheManager mgr = CacheManager.create();
CacheInfoHolder info = new CacheInfoHolder(mgr);
- DefaultSelectionKeyProcessor kp = new DefaultSelectionKeyProcessor(info);
+ DefaultSelectionKeyProcessorFactory factory = new DefaultSelectionKeyProcessorFactory(info);
- server = new TCPSocketTransportServer(host, port, pool, 2000, kp);
+ server = new TCPSocketTransportServer(host, port, pool, 2000, factory);
server.start();
}
@@ -80,6 +81,7 @@
@AfterSuite(alwaysRun=true)
public void shutdown() throws Exception{
server.stop();
+ pool.shutdown();
}
}