Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 75980 invoked from network); 13 Sep 2006 23:09:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 13 Sep 2006 23:09:18 -0000 Received: (qmail 82123 invoked by uid 500); 13 Sep 2006 23:09:18 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 82084 invoked by uid 500); 13 Sep 2006 23:09:18 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 82073 invoked by uid 99); 13 Sep 2006 23:09:17 -0000 Received: from idunn.apache.osuosl.org (HELO idunn.apache.osuosl.org) (140.211.166.84) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Sep 2006 16:09:17 -0700 Authentication-Results: idunn.apache.osuosl.org smtp.mail=jgenender@apache.org; spf=permerror X-ASF-Spam-Status: No, hits=-9.8 required=5.0 tests=ALL_TRUSTED,NO_REAL_NAME Received-SPF: error (idunn.apache.osuosl.org: domain apache.org from 140.211.166.113 cause and error) Received: from ([140.211.166.113:50019] helo=eris.apache.org) by idunn.apache.osuosl.org (ecelerity 2.1 r(10620)) with ESMTP id 4E/A3-00682-15F88054 for ; Wed, 13 Sep 2006 16:08:02 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id B28A41A981A; Wed, 13 Sep 2006 16:07:59 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r443162 - in /geronimo/sandbox/gcache: ./ server/ server/src/main/java/org/apache/geronimo/gcache/server/ server/src/main/java/org/apache/geronimo/gcache/server/config/ server/src/main/java/org/apache/geronimo/gcache/server/core/ server/src... Date: Wed, 13 Sep 2006 23:07:59 -0000 To: scm@geronimo.apache.org From: jgenender@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20060913230759.B28A41A981A@eris.apache.org> X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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 @@ + backport-util-concurrent + backport-util-concurrent + 2.0_01_pd + + + junit junit 3.8.1 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 @@ + backport-util-concurrent + backport-util-concurrent + + + junit junit 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 + *

+ * 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 + *

+ * 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; + + 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 + *

+ * 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 + *

+ * 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 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 + *

+ * 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 + *

+ * 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 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 + *

+ * 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 + *

+ * 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. + */ + +/** + * 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 + *

+ * 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 + *

+ * 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 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