Author: jgenender
Date: Wed Sep 13 16:07:58 2006
New Revision: 443162
URL: http://svn.apache.org/viewvc?view=rev&rev=443162
Log:
Begin adding contracts and threadpool
Added:
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/GCacheServer.java
(with props)
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/config/
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/config/Configuration.java
(with props)
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/core/
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/core/GCacheThread.java
(with props)
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/impl/
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/impl/DefaultThreadPoolImpl.java
(with props)
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/spi/
geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/spi/ThreadPool.java
(with props)
Modified:
geronimo/sandbox/gcache/pom.xml
geronimo/sandbox/gcache/server/pom.xml
Modified: geronimo/sandbox/gcache/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/pom.xml?view=diff&rev=443162&r1=443161&r2=443162
==============================================================================
--- geronimo/sandbox/gcache/pom.xml (original)
+++ geronimo/sandbox/gcache/pom.xml Wed Sep 13 16:07:58 2006
@@ -39,6 +39,12 @@
</dependency>
<dependency>
+ <groupId>backport-util-concurrent</groupId>
+ <artifactId>backport-util-concurrent</artifactId>
+ <version>2.0_01_pd</version>
+ </dependency>
+
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
Modified: geronimo/sandbox/gcache/server/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/pom.xml?view=diff&rev=443162&r1=443161&r2=443162
==============================================================================
--- geronimo/sandbox/gcache/server/pom.xml (original)
+++ geronimo/sandbox/gcache/server/pom.xml Wed Sep 13 16:07:58 2006
@@ -17,6 +17,11 @@
<dependencies>
<dependency>
+ <groupId>backport-util-concurrent</groupId>
+ <artifactId>backport-util-concurrent</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
Added: 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=auto&rev=443162
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/GCacheServer.java
(added)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/GCacheServer.java
Wed Sep 13 16:07:58 2006
@@ -0,0 +1,31 @@
+package org.apache.geronimo.gcache.server;
+
+import org.apache.geronimo.gcache.server.config.Configuration;
+
+/**
+ * Copyright 2006 The Apache Software Foundation
+ * <p/>
+ * Licensed 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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;
+
+ public GCacheServer(Configuration config) {
+ this.config = config;
+ }
+
+ public static void main(String[] args) {
+
+ }
+}
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/GCacheServer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/GCacheServer.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/GCacheServer.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: 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=auto&rev=443162
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/config/Configuration.java
(added)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/config/Configuration.java
Wed Sep 13 16:07:58 2006
@@ -0,0 +1,30 @@
+package org.apache.geronimo.gcache.server.config;
+
+import org.apache.geronimo.gcache.server.spi.ThreadPool;
+
+/**
+ * Copyright 2006 The Apache Software Foundation
+ * <p/>
+ * Licensed 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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 Configuration {
+ private ThreadPool threadPool = null;
+
+ public ThreadPool getThreadPool() {
+ return threadPool;
+ }
+
+ public void setThreadPool(ThreadPool threadPool) {
+ this.threadPool = threadPool;
+ }
+}
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/config/Configuration.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/config/Configuration.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/config/Configuration.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: 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=auto&rev=443162
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/core/GCacheThread.java
(added)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/core/GCacheThread.java
Wed Sep 13 16:07:58 2006
@@ -0,0 +1,57 @@
+package org.apache.geronimo.gcache.server.core;
+
+import org.apache.geronimo.gcache.server.spi.ThreadPool;
+import org.apache.geronimo.gcache.server.config.Configuration;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.nio.channels.ServerSocketChannel;
+
+/**
+ * Copyright 2006 The Apache Software Foundation
+ * <p/>
+ * Licensed 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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 GCacheThread extends Thread{
+
+ private boolean stopped;
+ private boolean running;
+ private final ThreadPool pool;
+
+ public GCacheThread(Configuration config) {
+ stopped = true;
+ running = false;
+ this.pool = config.getThreadPool();
+ }
+
+ public void run() {
+
+ stopped = false;
+ running = true;
+
+ while(!stopped){
+
+ //Comm component goes here...openwire preferred
+ }
+
+ running = false;
+ }
+
+ public void halt(){
+ stopped = true;
+ }
+
+ public boolean isRunning(){
+ return running;
+ }
+}
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/core/GCacheThread.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/core/GCacheThread.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/core/GCacheThread.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: 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=auto&rev=443162
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/impl/DefaultThreadPoolImpl.java
(added)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/impl/DefaultThreadPoolImpl.java
Wed Sep 13 16:07:58 2006
@@ -0,0 +1,88 @@
+package org.apache.geronimo.gcache.server.impl;
+
+import org.apache.geronimo.gcache.server.spi.ThreadPool;
+import edu.emory.mathcs.backport.java.util.concurrent.*;
+
+/**
+ * Copyright 2006 The Apache Software Foundation
+ * <p/>
+ * Licensed 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ */
+
+/**
+ * Default implementation for a simple Thread Pool
+ * This thread pool will be used unless one is provided using
+ * the ThreadPool interface. This allows the GCache server to
+ * leverage ThreadPools from application servers or custom
+ * thread pools. If custom, then an adapter utilizing
+ * the ThreadPool interface will need to be created.
+ */
+public class DefaultThreadPoolImpl implements ThreadPool{
+
+ public static final int DEFAULT_CORE_SIZE = 10;
+ public static final int DEFAULT_MAX_SIZE = 10;
+ public static final long DEFAULT_KEEP_ALIVE_TIME = 10;
+ public static final int DEFAULT_BLOCKING_QUEUE_SIZE = 100;
+
+ /**
+ * Thread pool
+ */
+ private final ThreadPoolExecutor pool;
+
+ /**
+ * Default constructor
+ */
+ public DefaultThreadPoolImpl() {
+ this(DEFAULT_CORE_SIZE, DEFAULT_MAX_SIZE, DEFAULT_KEEP_ALIVE_TIME, DEFAULT_BLOCKING_QUEUE_SIZE);
+ }
+
+ /**
+ * Constructor with pool size
+ * @param poolSize
+ */
+ public DefaultThreadPoolImpl(int poolSize) {
+ this(poolSize, poolSize, DEFAULT_KEEP_ALIVE_TIME, DEFAULT_BLOCKING_QUEUE_SIZE);
+ }
+
+ /**
+ * Constructor
+ * @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));
+ }
+
+ /**
+ * Executes a command within the confines of the thread pool
+ * @param command
+ */
+ public void execute(Runnable command) {
+ pool.execute(command);
+ }
+
+ /**
+ * Shuts down the thread pool
+ */
+ public void shutdown() {
+ if (!pool.isShutdown())
+ pool.shutdownNow();
+ }
+
+ /**
+ * Returns a thread pool size
+ * @return size of the thread pool
+ */
+ public int getPoolSize() {
+ return pool.getPoolSize();
+ }
+}
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/impl/DefaultThreadPoolImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/impl/DefaultThreadPoolImpl.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/impl/DefaultThreadPoolImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: 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=auto&rev=443162
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/spi/ThreadPool.java
(added)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/spi/ThreadPool.java
Wed Sep 13 16:07:58 2006
@@ -0,0 +1,36 @@
+package org.apache.geronimo.gcache.server.spi;
+
+/**
+ * Copyright 2006 The Apache Software Foundation
+ * <p/>
+ * Licensed 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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 interface ThreadPool {
+
+ /**
+ * Executes a command within the guidelines of the pool
+ * @param command
+ */
+ public void execute(Runnable command);
+
+ /**
+ * Shuts down the threadpool
+ */
+ public void shutdown();
+
+ /**
+ * Returns the size of teh thread pool
+ * @return thread pool size
+ */
+ public int getPoolSize();
+}
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/spi/ThreadPool.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/spi/ThreadPool.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/server/spi/ThreadPool.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
|