You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jcs-dev@jakarta.apache.org by tv...@apache.org on 2007/05/10 18:04:27 UTC

svn commit: r536904 [3/38] - in /jakarta/jcs/trunk: ./ auxiliary-builds/javagroups/ auxiliary-builds/javagroups/src/java/org/apache/jcs/auxiliary/javagroups/ auxiliary-builds/javagroups/src/test/org/apache/jcs/auxiliary/javagroups/ auxiliary-builds/jdk...

Modified: jakarta/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/lateral/javagroups/JGConnectionHolder.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/lateral/javagroups/JGConnectionHolder.java?view=diff&rev=536904&r1=536903&r2=536904
==============================================================================
--- jakarta/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/lateral/javagroups/JGConnectionHolder.java (original)
+++ jakarta/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/lateral/javagroups/JGConnectionHolder.java Thu May 10 09:03:42 2007
@@ -1,155 +1,158 @@
-package org.apache.jcs.auxiliary.lateral.javagroups;
-
-/*
- * Copyright 2001-2004 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.
- */
-
-import java.io.IOException;
-import java.util.HashMap;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheAttributes;
-import org.apache.jcs.auxiliary.lateral.javagroups.behavior.IJGConstants;
-import org.apache.jcs.auxiliary.lateral.javagroups.behavior.ILateralCacheJGListener;
-import org.apache.jcs.auxiliary.lateral.javagroups.utils.JGRpcOpener;
-import org.apache.jcs.auxiliary.lateral.javagroups.utils.JGSocketOpener;
-import org.jgroups.Channel;
-import org.jgroups.blocks.RpcDispatcher;
-
-/**
- * This holds connections, or channels, for jgroups.
- */
-public class JGConnectionHolder
-{
-
-    private final static Log log = LogFactory.getLog( JGConnectionHolder.class );
-
-    private Channel jg;
-
-    private RpcDispatcher disp;
-
-    private ILateralCacheAttributes ilca;
-
-    /**
-     * Description of the Field
-     */
-    protected final static HashMap instances = new HashMap();
-
-    /**
-     * Gets the instance attribute of the LateralGroupCacheJGListener class
-     * 
-     * @return The instance value
-     * @param ilca
-     */
-    public static JGConnectionHolder getInstance( ILateralCacheAttributes ilca )
-    {
-        //throws IOException, NotBoundException
-        //JGConnectionHolder ins = (JGConnectionHolder) instances.get( ilca.getJGChannelProperties() );
-        JGConnectionHolder ins = (JGConnectionHolder) instances.get( ilca.getCacheName() );
-        try
-        {
-            synchronized ( JGConnectionHolder.class )
-            {
-                if ( ins == null )
-                {
-                    ins = new JGConnectionHolder( ilca );
-                }
-                if ( log.isDebugEnabled() )
-                {
-                    log.debug( "created new listener " + ilca.getJGChannelProperties() );
-                }
-                instances.put( ilca.getJGChannelProperties(), ins );
-            }
-        }
-        catch ( Exception e )
-        {
-            log.error( "trouble intializing", e );
-        }
-        return ins;
-    }
-
-    /**
-     * Constructor for the JGConnectionHolder object
-     * 
-     * @param lca
-     * @param ilca
-     */
-    private JGConnectionHolder( ILateralCacheAttributes ilca )
-    {
-        this.ilca = ilca;
-    }
-
-    /**
-     * Creates a channel.
-     * 
-     * @return channel
-     * @exception IOException
-     */
-    public synchronized Channel getChannel()
-        throws IOException
-    {
-        if ( jg == null )
-        {
-            //jg = JGSocketOpener.openSocket( ilca, 5000, IJGConstants.DEFAULT_JG_GROUP_NAME );
-            jg = JGSocketOpener.openSocket( ilca, 5000, this.ilca.getCacheName() );
-            if ( log.isInfoEnabled() )
-            {
-                log.info( "Created channel " + jg + " for region name " + this.ilca.getCacheName() );
-                if ( jg != null )
-                {
-                    log.info( "Channel connection status; Connected = " + jg.isConnected() + " Open = " + jg.isOpen() );                    
-                }
-            }
-        }
-        return jg;
-    }
-
-    /**
-     * Gets the Dispatcher attribute of the JGConnectionHolder object
-     * 
-     * @return The Dispatcher value
-     * @exception IOException
-     */
-    public synchronized RpcDispatcher getDispatcher()
-        throws IOException
-    {
-        if ( log.isDebugEnabled() )
-        {
-            log.debug( "Creating Dispatcher, jgroups group name " + IJGConstants.RPC_JG_GROUP_NAME );
-        }
-
-        try
-        {
-            if ( disp == null )
-            {
-                synchronized ( JGConnectionHolder.class )
-                {
-                    if ( disp == null )
-                    {
-                        disp = JGRpcOpener.openSocket( (ILateralCacheJGListener) LateralGroupCacheJGListener
-                            .getInstance( ilca ), ilca, 5000, IJGConstants.RPC_JG_GROUP_NAME );
-                    }
-                }
-            }
-        }
-        catch ( Exception e )
-        {
-            log.error( "Problem creating dispatcher", e );
-        }
-        return disp;
-    }
-
-}
+package org.apache.jcs.auxiliary.lateral.javagroups;
+
+/*
+ * 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.
+ */
+
+import java.io.IOException;
+import java.util.HashMap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheAttributes;
+import org.apache.jcs.auxiliary.lateral.javagroups.behavior.IJGConstants;
+import org.apache.jcs.auxiliary.lateral.javagroups.behavior.ILateralCacheJGListener;
+import org.apache.jcs.auxiliary.lateral.javagroups.utils.JGRpcOpener;
+import org.apache.jcs.auxiliary.lateral.javagroups.utils.JGSocketOpener;
+import org.jgroups.Channel;
+import org.jgroups.blocks.RpcDispatcher;
+
+/**
+ * This holds connections, or channels, for jgroups.
+ */
+public class JGConnectionHolder
+{
+
+    private final static Log log = LogFactory.getLog( JGConnectionHolder.class );
+
+    private Channel jg;
+
+    private RpcDispatcher disp;
+
+    private ILateralCacheAttributes ilca;
+
+    /**
+     * Description of the Field
+     */
+    protected final static HashMap instances = new HashMap();
+
+    /**
+     * Gets the instance attribute of the LateralGroupCacheJGListener class
+     *
+     * @return The instance value
+     * @param ilca
+     */
+    public static JGConnectionHolder getInstance( ILateralCacheAttributes ilca )
+    {
+        //throws IOException, NotBoundException
+        //JGConnectionHolder ins = (JGConnectionHolder) instances.get( ilca.getJGChannelProperties() );
+        JGConnectionHolder ins = (JGConnectionHolder) instances.get( ilca.getCacheName() );
+        try
+        {
+            synchronized ( JGConnectionHolder.class )
+            {
+                if ( ins == null )
+                {
+                    ins = new JGConnectionHolder( ilca );
+                }
+                if ( log.isDebugEnabled() )
+                {
+                    log.debug( "created new listener " + ilca.getJGChannelProperties() );
+                }
+                instances.put( ilca.getJGChannelProperties(), ins );
+            }
+        }
+        catch ( Exception e )
+        {
+            log.error( "trouble intializing", e );
+        }
+        return ins;
+    }
+
+    /**
+     * Constructor for the JGConnectionHolder object
+     *
+     * @param lca
+     * @param ilca
+     */
+    private JGConnectionHolder( ILateralCacheAttributes ilca )
+    {
+        this.ilca = ilca;
+    }
+
+    /**
+     * Creates a channel.
+     *
+     * @return channel
+     * @exception IOException
+     */
+    public synchronized Channel getChannel()
+        throws IOException
+    {
+        if ( jg == null )
+        {
+            //jg = JGSocketOpener.openSocket( ilca, 5000, IJGConstants.DEFAULT_JG_GROUP_NAME );
+            jg = JGSocketOpener.openSocket( ilca, 5000, this.ilca.getCacheName() );
+            if ( log.isInfoEnabled() )
+            {
+                log.info( "Created channel " + jg + " for region name " + this.ilca.getCacheName() );
+                if ( jg != null )
+                {
+                    log.info( "Channel connection status; Connected = " + jg.isConnected() + " Open = " + jg.isOpen() );
+                }
+            }
+        }
+        return jg;
+    }
+
+    /**
+     * Gets the Dispatcher attribute of the JGConnectionHolder object
+     *
+     * @return The Dispatcher value
+     * @exception IOException
+     */
+    public synchronized RpcDispatcher getDispatcher()
+        throws IOException
+    {
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( "Creating Dispatcher, jgroups group name " + IJGConstants.RPC_JG_GROUP_NAME );
+        }
+
+        try
+        {
+            if ( disp == null )
+            {
+                synchronized ( JGConnectionHolder.class )
+                {
+                    if ( disp == null )
+                    {
+                        disp = JGRpcOpener.openSocket( (ILateralCacheJGListener) LateralGroupCacheJGListener
+                            .getInstance( ilca ), ilca, 5000, IJGConstants.RPC_JG_GROUP_NAME );
+                    }
+                }
+            }
+        }
+        catch ( Exception e )
+        {
+            log.error( "Problem creating dispatcher", e );
+        }
+        return disp;
+    }
+
+}

Modified: jakarta/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/lateral/javagroups/LateralCacheJGListener.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/lateral/javagroups/LateralCacheJGListener.java?view=diff&rev=536904&r1=536903&r2=536904
==============================================================================
--- jakarta/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/lateral/javagroups/LateralCacheJGListener.java (original)
+++ jakarta/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/lateral/javagroups/LateralCacheJGListener.java Thu May 10 09:03:42 2007
@@ -1,305 +1,308 @@
-package org.apache.jcs.auxiliary.lateral.javagroups;
-
-/*
- * Copyright 2001-2004 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.
- */
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.HashMap;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jcs.auxiliary.lateral.LateralCacheInfo;
-import org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheAttributes;
-import org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheListener;
-import org.apache.jcs.auxiliary.lateral.javagroups.behavior.ILateralCacheJGListener;
-import org.apache.jcs.engine.behavior.ICache;
-import org.apache.jcs.engine.behavior.ICacheElement;
-import org.apache.jcs.engine.behavior.ICompositeCacheManager;
-import org.apache.jcs.engine.control.CompositeCache;
-import org.apache.jcs.engine.control.CompositeCacheManager;
-
-/**
- * JavaGroups listener. Good for distributing cache data accross multiple vms on
- * the same machine. You also don't need to know the number of listerners for
- * configuration.
- *  
- */
-public class LateralCacheJGListener
-    implements ILateralCacheJGListener, Serializable
-{
-    private final static Log log = LogFactory.getLog( LateralCacheJGListener.class );
-
-    /**
-     * Description of the Field
-     */
-    protected transient ICompositeCacheManager cacheMgr;
-
-    /**
-     * Description of the Field
-     */
-    protected final static HashMap instances = new HashMap();
-
-    // instance vars
-    private LateralJGReceiver receiver;
-
-    private ILateralCacheAttributes ilca;
-
-    private int puts = 0;
-
-    /**
-     * Only need one since it does work for all regions, just reference by
-     * multiple region names.
-     * 
-     * @param ilca
-     */
-    protected LateralCacheJGListener( ILateralCacheAttributes ilca )
-    {
-        this.ilca = ilca;
-    }
-
-    /**
-     * Description of the Method
-     */
-    public void init()
-    {
-        try
-        {
-            // need to connect based on type
-            //ILateralCacheListener ilcl = this;
-            receiver = new LateralJGReceiver( ilca, this );
-            Thread t = new Thread( receiver );
-            t.start();
-        }
-        catch ( Exception ex )
-        {
-            log.error( ex );
-            throw new IllegalStateException( ex.getMessage() );
-        }
-    }
-
-    /**
-     * let the lateral cache set a listener_id. Since there is only one
-     * listerenr for all the regions and every region gets registered? the id
-     * shouldn't be set if it isn't zero. If it is we assume that it is a
-     * reconnect.
-     * 
-     * @param id
-     *            The new listenerId value
-     * @exception IOException
-     */
-    public void setListenerId( long id )
-        throws IOException
-    {
-        LateralCacheInfo.listenerId = id;
-        if ( log.isDebugEnabled() )
-        {
-            log.debug( "set listenerId = " + id );
-        }
-    }
-
-    /**
-     * Gets the listenerId attribute of the LateralCacheJGListener object
-     * 
-     * @return The listenerId value
-     * @exception IOException
-     */
-    public long getListenerId()
-        throws IOException
-    {
-
-        if ( log.isDebugEnabled() )
-        {
-            log.debug( "get listenerId = " + LateralCacheInfo.listenerId );
-        }
-        return LateralCacheInfo.listenerId;
-    }
-
-    /**
-     * Gets the instance attribute of the LateralCacheJGListener class
-     * 
-     * @return The instance value
-     * @param ilca
-     * @param cacheMgr
-     */
-    public static ILateralCacheListener getInstance( ILateralCacheAttributes ilca, ICompositeCacheManager cacheMgr )
-    {
-
-        //throws IOException, NotBoundException
-        ILateralCacheListener ins = (ILateralCacheListener) instances.get( ilca.getJGChannelProperties() );
-
-        synchronized ( LateralCacheJGListener.class )
-        {
-            if ( ins == null )
-            {
-                ins = new LateralCacheJGListener( ilca );
-
-                ins.setCacheManager( cacheMgr );
-
-                ins.init();
-            }
-            if ( log.isInfoEnabled() )
-            {
-                log.info( "created new listener " + ilca.getJGChannelProperties() );
-            }
-            instances.put( ilca.getJGChannelProperties(), ins );
-        }
-
-        return ins;
-    }
-
-    //////////////////////////// implements the ILateralCacheListener
-    // interface. //////////////
-    /**
-     * @param element
-     * @param cb
-     * @exception IOException
-     */
-    public void handlePut( ICacheElement element )
-        throws IOException
-    {
-        if ( log.isDebugEnabled() )
-        {
-            log.debug( "PUTTING ELEMENT FROM LATERAL" );
-        }
-
-        puts++;
-        if ( log.isInfoEnabled() )
-        {
-            if ( puts % 100 == 0 )
-            {
-                log.info( "puts = " + puts );
-            }
-        }
-
-        getCache( element.getCacheName() ).localUpdate( element );
-
-    }
-
-    /**
-     * Description of the Method
-     * 
-     * @param cacheName
-     * @param key
-     * @exception IOException
-     */
-    public void handleRemove( String cacheName, Serializable key )
-        throws IOException
-    {
-        if ( log.isDebugEnabled() )
-        {
-            log.debug( "handleRemove> cacheName=" + cacheName + ", key=" + key );
-        }
-
-        getCache( cacheName ).localRemove( key );
-    }
-
-    /**
-     * Description of the Method
-     * 
-     * @param cacheName
-     * @exception IOException
-     */
-    public void handleRemoveAll( String cacheName )
-        throws IOException
-    {
-        if ( log.isDebugEnabled() )
-        {
-            log.debug( "handleRemoveAll> cacheName=" + cacheName );
-        }
-
-        ICache cache = getCache( cacheName );
-        cache.removeAll();
-    }
-
-    /**
-     * Test get implementation.
-     * 
-     * @return
-     * @param cacheName
-     * @param key
-     * @exception IOException
-     */
-    public Serializable handleGet( String cacheName, Serializable key )
-        throws IOException
-    {
-        if ( log.isDebugEnabled() )
-        {
-            log.debug( "handleGet> cacheName=" + cacheName + ", key = " + key );
-        }
-
-        return getCache( cacheName ).localGet( key );
-    }
-
-    /**
-     * Description of the Method
-     * 
-     * @param cacheName
-     * @exception IOException
-     */
-    public void handleDispose( String cacheName )
-        throws IOException
-    {
-        if ( log.isDebugEnabled() )
-        {
-            log.debug( "handleDispose> cacheName=" + cacheName );
-        }
-        // TODO handle active disposal
-        //this.getCacheManager().freeCache( cacheName, true );
-    }
-
-    /**
-     * Gets the cacheManager attribute of the LateralCacheTCPListener object
-     * 
-     * @param name
-     * @return CompositeCache
-     */
-    protected CompositeCache getCache( String name )
-    {
-        if ( cacheMgr == null )
-        {
-            cacheMgr = CompositeCacheManager.getInstance();
-
-            if ( log.isDebugEnabled() )
-            {
-                log.debug( "cacheMgr = " + cacheMgr );
-            }
-        }
-
-        return cacheMgr.getCache( name );
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheListener#setCacheManager(org.apache.jcs.engine.behavior.ICompositeCacheManager)
-     */
-    public void setCacheManager( ICompositeCacheManager cacheMgr )
-    {
-        this.cacheMgr = cacheMgr;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheListener#getCacheManager()
-     */
-    public ICompositeCacheManager getCacheManager()
-    {
-        return this.cacheMgr;
-    }
-
-}
+package org.apache.jcs.auxiliary.lateral.javagroups;
+
+/*
+ * 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.
+ */
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.HashMap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jcs.auxiliary.lateral.LateralCacheInfo;
+import org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheAttributes;
+import org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheListener;
+import org.apache.jcs.auxiliary.lateral.javagroups.behavior.ILateralCacheJGListener;
+import org.apache.jcs.engine.behavior.ICache;
+import org.apache.jcs.engine.behavior.ICacheElement;
+import org.apache.jcs.engine.behavior.ICompositeCacheManager;
+import org.apache.jcs.engine.control.CompositeCache;
+import org.apache.jcs.engine.control.CompositeCacheManager;
+
+/**
+ * JavaGroups listener. Good for distributing cache data accross multiple vms on
+ * the same machine. You also don't need to know the number of listerners for
+ * configuration.
+ *
+ */
+public class LateralCacheJGListener
+    implements ILateralCacheJGListener, Serializable
+{
+    private final static Log log = LogFactory.getLog( LateralCacheJGListener.class );
+
+    /**
+     * Description of the Field
+     */
+    protected transient ICompositeCacheManager cacheMgr;
+
+    /**
+     * Description of the Field
+     */
+    protected final static HashMap instances = new HashMap();
+
+    // instance vars
+    private LateralJGReceiver receiver;
+
+    private ILateralCacheAttributes ilca;
+
+    private int puts = 0;
+
+    /**
+     * Only need one since it does work for all regions, just reference by
+     * multiple region names.
+     *
+     * @param ilca
+     */
+    protected LateralCacheJGListener( ILateralCacheAttributes ilca )
+    {
+        this.ilca = ilca;
+    }
+
+    /**
+     * Description of the Method
+     */
+    public void init()
+    {
+        try
+        {
+            // need to connect based on type
+            //ILateralCacheListener ilcl = this;
+            receiver = new LateralJGReceiver( ilca, this );
+            Thread t = new Thread( receiver );
+            t.start();
+        }
+        catch ( Exception ex )
+        {
+            log.error( ex );
+            throw new IllegalStateException( ex.getMessage() );
+        }
+    }
+
+    /**
+     * let the lateral cache set a listener_id. Since there is only one
+     * listerenr for all the regions and every region gets registered? the id
+     * shouldn't be set if it isn't zero. If it is we assume that it is a
+     * reconnect.
+     *
+     * @param id
+     *            The new listenerId value
+     * @exception IOException
+     */
+    public void setListenerId( long id )
+        throws IOException
+    {
+        LateralCacheInfo.listenerId = id;
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( "set listenerId = " + id );
+        }
+    }
+
+    /**
+     * Gets the listenerId attribute of the LateralCacheJGListener object
+     *
+     * @return The listenerId value
+     * @exception IOException
+     */
+    public long getListenerId()
+        throws IOException
+    {
+
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( "get listenerId = " + LateralCacheInfo.listenerId );
+        }
+        return LateralCacheInfo.listenerId;
+    }
+
+    /**
+     * Gets the instance attribute of the LateralCacheJGListener class
+     *
+     * @return The instance value
+     * @param ilca
+     * @param cacheMgr
+     */
+    public static ILateralCacheListener getInstance( ILateralCacheAttributes ilca, ICompositeCacheManager cacheMgr )
+    {
+
+        //throws IOException, NotBoundException
+        ILateralCacheListener ins = (ILateralCacheListener) instances.get( ilca.getJGChannelProperties() );
+
+        synchronized ( LateralCacheJGListener.class )
+        {
+            if ( ins == null )
+            {
+                ins = new LateralCacheJGListener( ilca );
+
+                ins.setCacheManager( cacheMgr );
+
+                ins.init();
+            }
+            if ( log.isInfoEnabled() )
+            {
+                log.info( "created new listener " + ilca.getJGChannelProperties() );
+            }
+            instances.put( ilca.getJGChannelProperties(), ins );
+        }
+
+        return ins;
+    }
+
+    //////////////////////////// implements the ILateralCacheListener
+    // interface. //////////////
+    /**
+     * @param element
+     * @param cb
+     * @exception IOException
+     */
+    public void handlePut( ICacheElement element )
+        throws IOException
+    {
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( "PUTTING ELEMENT FROM LATERAL" );
+        }
+
+        puts++;
+        if ( log.isInfoEnabled() )
+        {
+            if ( puts % 100 == 0 )
+            {
+                log.info( "puts = " + puts );
+            }
+        }
+
+        getCache( element.getCacheName() ).localUpdate( element );
+
+    }
+
+    /**
+     * Description of the Method
+     *
+     * @param cacheName
+     * @param key
+     * @exception IOException
+     */
+    public void handleRemove( String cacheName, Serializable key )
+        throws IOException
+    {
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( "handleRemove> cacheName=" + cacheName + ", key=" + key );
+        }
+
+        getCache( cacheName ).localRemove( key );
+    }
+
+    /**
+     * Description of the Method
+     *
+     * @param cacheName
+     * @exception IOException
+     */
+    public void handleRemoveAll( String cacheName )
+        throws IOException
+    {
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( "handleRemoveAll> cacheName=" + cacheName );
+        }
+
+        ICache cache = getCache( cacheName );
+        cache.removeAll();
+    }
+
+    /**
+     * Test get implementation.
+     *
+     * @return
+     * @param cacheName
+     * @param key
+     * @exception IOException
+     */
+    public Serializable handleGet( String cacheName, Serializable key )
+        throws IOException
+    {
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( "handleGet> cacheName=" + cacheName + ", key = " + key );
+        }
+
+        return getCache( cacheName ).localGet( key );
+    }
+
+    /**
+     * Description of the Method
+     *
+     * @param cacheName
+     * @exception IOException
+     */
+    public void handleDispose( String cacheName )
+        throws IOException
+    {
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( "handleDispose> cacheName=" + cacheName );
+        }
+        // TODO handle active disposal
+        //this.getCacheManager().freeCache( cacheName, true );
+    }
+
+    /**
+     * Gets the cacheManager attribute of the LateralCacheTCPListener object
+     *
+     * @param name
+     * @return CompositeCache
+     */
+    protected CompositeCache getCache( String name )
+    {
+        if ( cacheMgr == null )
+        {
+            cacheMgr = CompositeCacheManager.getInstance();
+
+            if ( log.isDebugEnabled() )
+            {
+                log.debug( "cacheMgr = " + cacheMgr );
+            }
+        }
+
+        return cacheMgr.getCache( name );
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheListener#setCacheManager(org.apache.jcs.engine.behavior.ICompositeCacheManager)
+     */
+    public void setCacheManager( ICompositeCacheManager cacheMgr )
+    {
+        this.cacheMgr = cacheMgr;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheListener#getCacheManager()
+     */
+    public ICompositeCacheManager getCacheManager()
+    {
+        return this.cacheMgr;
+    }
+
+}

Modified: jakarta/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/lateral/javagroups/LateralGroupCacheJGListener.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/lateral/javagroups/LateralGroupCacheJGListener.java?view=diff&rev=536904&r1=536903&r2=536904
==============================================================================
--- jakarta/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/lateral/javagroups/LateralGroupCacheJGListener.java (original)
+++ jakarta/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/lateral/javagroups/LateralGroupCacheJGListener.java Thu May 10 09:03:42 2007
@@ -1,108 +1,111 @@
-package org.apache.jcs.auxiliary.lateral.javagroups;
-
-/*
- * Copyright 2001-2004 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.
- */
-
-import org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheAttributes;
-import org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheListener;
-import org.apache.jcs.auxiliary.lateral.javagroups.behavior.ILateralCacheJGListener;
-
-import org.apache.jcs.engine.control.CompositeCacheManager;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @version $Id: LateralGroupCacheJGListener.java,v 1.6 2002/02/15 04:33:37
- *          jtaylor Exp $
- */
-public class LateralGroupCacheJGListener
-    extends LateralCacheJGListener
-    implements ILateralCacheJGListener
-{
-    private final static Log log = LogFactory.getLog( LateralGroupCacheJGListener.class );
-
-    /**
-     * Constructor for the LateralGroupCacheJGListener object
-     * 
-     * @param ilca
-     */
-    protected LateralGroupCacheJGListener( ILateralCacheAttributes ilca )
-    {
-        super( ilca );
-        log.debug( "creating LateralGroupCacheJGListener" );
-    }
-
-    /**
-     * Gets the instance attribute of the LateralGroupCacheJGListener class
-     * @param ilca
-     * 
-     * @return The instance value
-     */
-    public static ILateralCacheListener getInstance( ILateralCacheAttributes ilca )
-    {
-        //throws IOException, NotBoundException
-        ILateralCacheListener ins = (ILateralCacheListener) instances
-            .get( String.valueOf( ilca.getUdpMulticastAddr() ) );
-        synchronized ( LateralGroupCacheJGListener.class )
-        {
-            if ( ins == null )
-            {
-                ins = new LateralGroupCacheJGListener( ilca );
-                ins.init();
-            }
-            if ( log.isDebugEnabled() )
-            {
-                log.debug( "created new listener " + ilca.getUdpMulticastAddr() );
-            }
-            instances.put( String.valueOf( ilca.getUdpMulticastAddr() ), ins );
-        }
-
-        return ins;
-    }
-
-    // override for new funcitonality
-    // lazy init is too slow, find a better way
-    /**
-     * Gets the cacheManager attribute of the LateralGroupCacheJGListener object
-     */
-    protected void ensureCacheManager()
-    {
-        try
-        {
-            if ( cacheMgr == null )
-            {
-                cacheMgr = CompositeCacheManager.getInstance();
-                if ( log.isDebugEnabled() )
-                {
-                    log.debug( " groupcache cacheMgr = " + cacheMgr );
-                }
-            }
-            else
-            {
-                if ( log.isDebugEnabled() )
-                {
-                    log.debug( "already got groupcache cacheMgr = " + cacheMgr );
-                }
-            }
-        }
-        catch ( Exception e )
-        {
-            log.error( e );
-        }
-    }
-
-}
+package org.apache.jcs.auxiliary.lateral.javagroups;
+
+/*
+ * 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.
+ */
+
+import org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheAttributes;
+import org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheListener;
+import org.apache.jcs.auxiliary.lateral.javagroups.behavior.ILateralCacheJGListener;
+
+import org.apache.jcs.engine.control.CompositeCacheManager;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @version $Id: LateralGroupCacheJGListener.java,v 1.6 2002/02/15 04:33:37
+ *          jtaylor Exp $
+ */
+public class LateralGroupCacheJGListener
+    extends LateralCacheJGListener
+    implements ILateralCacheJGListener
+{
+    private final static Log log = LogFactory.getLog( LateralGroupCacheJGListener.class );
+
+    /**
+     * Constructor for the LateralGroupCacheJGListener object
+     *
+     * @param ilca
+     */
+    protected LateralGroupCacheJGListener( ILateralCacheAttributes ilca )
+    {
+        super( ilca );
+        log.debug( "creating LateralGroupCacheJGListener" );
+    }
+
+    /**
+     * Gets the instance attribute of the LateralGroupCacheJGListener class
+     * @param ilca
+     *
+     * @return The instance value
+     */
+    public static ILateralCacheListener getInstance( ILateralCacheAttributes ilca )
+    {
+        //throws IOException, NotBoundException
+        ILateralCacheListener ins = (ILateralCacheListener) instances
+            .get( String.valueOf( ilca.getUdpMulticastAddr() ) );
+        synchronized ( LateralGroupCacheJGListener.class )
+        {
+            if ( ins == null )
+            {
+                ins = new LateralGroupCacheJGListener( ilca );
+                ins.init();
+            }
+            if ( log.isDebugEnabled() )
+            {
+                log.debug( "created new listener " + ilca.getUdpMulticastAddr() );
+            }
+            instances.put( String.valueOf( ilca.getUdpMulticastAddr() ), ins );
+        }
+
+        return ins;
+    }
+
+    // override for new funcitonality
+    // lazy init is too slow, find a better way
+    /**
+     * Gets the cacheManager attribute of the LateralGroupCacheJGListener object
+     */
+    protected void ensureCacheManager()
+    {
+        try
+        {
+            if ( cacheMgr == null )
+            {
+                cacheMgr = CompositeCacheManager.getInstance();
+                if ( log.isDebugEnabled() )
+                {
+                    log.debug( " groupcache cacheMgr = " + cacheMgr );
+                }
+            }
+            else
+            {
+                if ( log.isDebugEnabled() )
+                {
+                    log.debug( "already got groupcache cacheMgr = " + cacheMgr );
+                }
+            }
+        }
+        catch ( Exception e )
+        {
+            log.error( e );
+        }
+    }
+
+}

Modified: jakarta/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/lateral/javagroups/LateralJGCacheFactory.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/lateral/javagroups/LateralJGCacheFactory.java?view=diff&rev=536904&r1=536903&r2=536904
==============================================================================
--- jakarta/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/lateral/javagroups/LateralJGCacheFactory.java (original)
+++ jakarta/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/lateral/javagroups/LateralJGCacheFactory.java Thu May 10 09:03:42 2007
@@ -1,111 +1,114 @@
-package org.apache.jcs.auxiliary.lateral.javagroups;
-
-/*
- * Copyright 2001-2004 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.
- */
-
-import java.util.ArrayList;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jcs.auxiliary.AuxiliaryCache;
-import org.apache.jcs.auxiliary.AuxiliaryCacheAttributes;
-import org.apache.jcs.auxiliary.lateral.LateralCacheAbstractFactory;
-import org.apache.jcs.auxiliary.lateral.LateralCacheAttributes;
-import org.apache.jcs.auxiliary.lateral.LateralCacheNoWait;
-import org.apache.jcs.auxiliary.lateral.LateralCacheNoWaitFacade;
-import org.apache.jcs.engine.behavior.ICache;
-import org.apache.jcs.engine.behavior.ICompositeCacheManager;
-
-/**
- * Constructs a LateralCacheNoWaitFacade for the given configuration. Each
- * lateral service / local relationship is managed by one manager. This manager
- * canl have multiple caches. The remote relationships are consolidated and
- * restored via these managers. The facade provides a front to the composite
- * cache so the implmenetation is transparent.
- * 
- * @deprecated use the new TYPE specific lateral factories.
- */
-public class LateralJGCacheFactory
-    extends LateralCacheAbstractFactory
-{
-    private final static Log log = LogFactory.getLog( LateralJGCacheFactory.class );
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.jcs.auxiliary.AuxiliaryCacheFactory#createCache(org.apache.jcs.auxiliary.AuxiliaryCacheAttributes,
-     *      org.apache.jcs.engine.behavior.ICompositeCacheManager)
-     */
-    public AuxiliaryCache createCache( AuxiliaryCacheAttributes iaca, ICompositeCacheManager cacheMgr )
-    {
-
-        LateralCacheAttributes lac = (LateralCacheAttributes) iaca;
-        ArrayList noWaits = new ArrayList();
-
-        LateralJGCacheManager lcm = LateralJGCacheManager.getInstance( lac, cacheMgr );
-        ICache ic = lcm.getCache( lac.getCacheName() );
-        if ( ic != null )
-        {
-            noWaits.add( ic );
-        }
-
-        createListener( lac, cacheMgr );
-
-        // create the no wait facade.
-        LateralCacheNoWaitFacade lcnwf = new LateralCacheNoWaitFacade( (LateralCacheNoWait[]) noWaits
-            .toArray( new LateralCacheNoWait[0] ), iaca.getCacheName() );
-
-        return lcnwf;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.jcs.auxiliary.lateral.LateralCacheAbstractFactory#createListener(org.apache.jcs.auxiliary.lateral.LateralCacheAttributes,
-     *      org.apache.jcs.engine.behavior.ICompositeCacheManager)
-     */
-    public void createListener( LateralCacheAttributes lac, ICompositeCacheManager cacheMgr )
-    {
-        // don't create a listener if we are not receiving.
-        if ( lac.isReceive() )
-        {
-
-            if ( log.isInfoEnabled() )
-            {
-                log.info( "Creating listener for " + lac );
-            }
-
-            try
-            {
-
-                LateralCacheJGListener.getInstance( lac, cacheMgr );
-
-            }
-            catch ( Exception e )
-            {
-                log.error( "Problem creating lateral listener", e );
-            }
-        }
-        else
-        {
-            if ( log.isDebugEnabled() )
-            {
-                log.debug( "Not creating a listener since we are not receiving." );
-            }
-        }
-    }
-
-}
+package org.apache.jcs.auxiliary.lateral.javagroups;
+
+/*
+ * 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.
+ */
+
+import java.util.ArrayList;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jcs.auxiliary.AuxiliaryCache;
+import org.apache.jcs.auxiliary.AuxiliaryCacheAttributes;
+import org.apache.jcs.auxiliary.lateral.LateralCacheAbstractFactory;
+import org.apache.jcs.auxiliary.lateral.LateralCacheAttributes;
+import org.apache.jcs.auxiliary.lateral.LateralCacheNoWait;
+import org.apache.jcs.auxiliary.lateral.LateralCacheNoWaitFacade;
+import org.apache.jcs.engine.behavior.ICache;
+import org.apache.jcs.engine.behavior.ICompositeCacheManager;
+
+/**
+ * Constructs a LateralCacheNoWaitFacade for the given configuration. Each
+ * lateral service / local relationship is managed by one manager. This manager
+ * canl have multiple caches. The remote relationships are consolidated and
+ * restored via these managers. The facade provides a front to the composite
+ * cache so the implmenetation is transparent.
+ *
+ * @deprecated use the new TYPE specific lateral factories.
+ */
+public class LateralJGCacheFactory
+    extends LateralCacheAbstractFactory
+{
+    private final static Log log = LogFactory.getLog( LateralJGCacheFactory.class );
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.apache.jcs.auxiliary.AuxiliaryCacheFactory#createCache(org.apache.jcs.auxiliary.AuxiliaryCacheAttributes,
+     *      org.apache.jcs.engine.behavior.ICompositeCacheManager)
+     */
+    public AuxiliaryCache createCache( AuxiliaryCacheAttributes iaca, ICompositeCacheManager cacheMgr )
+    {
+
+        LateralCacheAttributes lac = (LateralCacheAttributes) iaca;
+        ArrayList noWaits = new ArrayList();
+
+        LateralJGCacheManager lcm = LateralJGCacheManager.getInstance( lac, cacheMgr );
+        ICache ic = lcm.getCache( lac.getCacheName() );
+        if ( ic != null )
+        {
+            noWaits.add( ic );
+        }
+
+        createListener( lac, cacheMgr );
+
+        // create the no wait facade.
+        LateralCacheNoWaitFacade lcnwf = new LateralCacheNoWaitFacade( (LateralCacheNoWait[]) noWaits
+            .toArray( new LateralCacheNoWait[0] ), iaca.getCacheName() );
+
+        return lcnwf;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.apache.jcs.auxiliary.lateral.LateralCacheAbstractFactory#createListener(org.apache.jcs.auxiliary.lateral.LateralCacheAttributes,
+     *      org.apache.jcs.engine.behavior.ICompositeCacheManager)
+     */
+    public void createListener( LateralCacheAttributes lac, ICompositeCacheManager cacheMgr )
+    {
+        // don't create a listener if we are not receiving.
+        if ( lac.isReceive() )
+        {
+
+            if ( log.isInfoEnabled() )
+            {
+                log.info( "Creating listener for " + lac );
+            }
+
+            try
+            {
+
+                LateralCacheJGListener.getInstance( lac, cacheMgr );
+
+            }
+            catch ( Exception e )
+            {
+                log.error( "Problem creating lateral listener", e );
+            }
+        }
+        else
+        {
+            if ( log.isDebugEnabled() )
+            {
+                log.debug( "Not creating a listener since we are not receiving." );
+            }
+        }
+    }
+
+}

Modified: jakarta/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/lateral/javagroups/LateralJGCacheManager.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/lateral/javagroups/LateralJGCacheManager.java?view=diff&rev=536904&r1=536903&r2=536904
==============================================================================
--- jakarta/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/lateral/javagroups/LateralJGCacheManager.java (original)
+++ jakarta/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/lateral/javagroups/LateralJGCacheManager.java Thu May 10 09:03:42 2007
@@ -1,325 +1,328 @@
-package org.apache.jcs.auxiliary.lateral.javagroups;
-
-/*
- * Copyright 2001-2004 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.
- */
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jcs.auxiliary.AuxiliaryCache;
-import org.apache.jcs.auxiliary.lateral.LateralCache;
-import org.apache.jcs.auxiliary.lateral.LateralCacheAbstractManager;
-import org.apache.jcs.auxiliary.lateral.LateralCacheAttributes;
-import org.apache.jcs.auxiliary.lateral.LateralCacheMonitor;
-import org.apache.jcs.auxiliary.lateral.LateralCacheNoWait;
-import org.apache.jcs.auxiliary.lateral.LateralCacheWatchRepairable;
-import org.apache.jcs.auxiliary.lateral.ZombieLateralCacheService;
-import org.apache.jcs.auxiliary.lateral.ZombieLateralCacheWatch;
-import org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheAttributes;
-import org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheListener;
-import org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheManager;
-import org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheService;
-import org.apache.jcs.engine.behavior.ICompositeCacheManager;
-
-/**
- * Creates lateral caches. Lateral caches are primarily used for removing non
- * laterally configured caches. Non laterally configured cache regions should
- * still bea ble to participate in removal. But if there is a non laterally
- * configured cache hub, then lateral removals may be necessary. For flat
- * webserver production environments, without a strong machine at the app server
- * level, distribution and search may need to occur at the lateral cache level.
- * This is currently not implemented in the lateral cache.
- * <p>
- * 
- * @TODO: - need freeCache, release, getStats - need to find an interface
- *        acceptible for all - cache managers or a manager within a type
- * 
- * @deprecated use individual cache managers
- */
-public class LateralJGCacheManager
-    extends LateralCacheAbstractManager
-{
-    private final static Log log = LogFactory.getLog( LateralJGCacheManager.class );
-
-    private static LateralCacheMonitor monitor;
-
-    final static Map instances = new HashMap();
-
-    // each manager instance has caches
-    final Map caches = new HashMap();
-
-    /**
-     * Description of the Field
-     */
-    protected ILateralCacheAttributes lca;
-
-    private int clients;
-
-    /**
-     * Handle to the lateral cache service; or a zombie handle if failed to
-     * connect.
-     */
-    private ILateralCacheService lateralService;
-
-    /**
-     * Wrapper of the lateral cache watch service; or wrapper of a zombie
-     * service if failed to connect.
-     */
-    private LateralCacheWatchRepairable lateralWatch;
-
-    private ICompositeCacheManager cacheMgr;
-
-    /**
-     * Returns an instance of the LateralCacheManager.
-     * 
-     * @param lca
-     * @param cacheMgr
-     *            this allows the auxiliary to be passed a cache manager.
-     * @return
-     */
-    public static LateralJGCacheManager getInstance( ILateralCacheAttributes lca, ICompositeCacheManager cacheMgr )
-    {
-        LateralJGCacheManager ins = (LateralJGCacheManager) instances.get( lca.toString() );
-        synchronized ( instances )
-        {
-            if ( ins == null )
-            {
-                log.info( "Instance for [" + lca.toString() + "] is null, creating" );
-
-                ins = (LateralJGCacheManager) instances.get( lca.toString() );
-                if ( ins == null )
-                {
-                    ins = new LateralJGCacheManager( lca, cacheMgr );
-                    instances.put( lca.toString(), ins );
-                }
-            }
-        }
-
-        createMonitor( ins );
-
-        return ins;
-    }
-
-    /**
-     * The monitor needs reference to one instance, acutally just a type.
-     * 
-     * refactor this.
-     * 
-     * @param instance
-     */
-    private static synchronized void createMonitor( ILateralCacheManager instance )
-    {
-        //      only want one monitor per lateral type
-        // Fires up the monitoring daemon.
-        if ( monitor == null )
-        {
-            monitor = new LateralCacheMonitor( instance );
-            // Should never be null
-            if ( monitor != null )
-            {
-                Thread t = new Thread( monitor );
-                t.setDaemon( true );
-                t.start();
-            }
-        }
-
-    }
-
-    /**
-     * Constructor for the LateralCacheManager object
-     * 
-     * @param lcaA
-     * @param cacheMgr
-     */
-    private LateralJGCacheManager( ILateralCacheAttributes lcaA, ICompositeCacheManager cacheMgr )
-    {
-        this.lca = lcaA;
-
-        this.cacheMgr = cacheMgr;
-
-        if ( log.isDebugEnabled() )
-        {
-            log.debug( "Creating lateral cache service, lca = " + this.lca );
-        }
-
-        // need to create the service based on the type
-
-        try
-        {
-            if ( this.lca.getTransmissionType() == ILateralCacheAttributes.JAVAGROUPS )
-            {
-                log.debug( "Creating JAVAGROUPS service" );
-
-                this.lateralService = new LateralJGService( this.lca );
-            }
-
-            else
-            {
-                log.error( "Type not recognized, must zombie" );
-
-                throw new Exception( "no known transmission type for lateral cache." );
-            }
-
-            if ( this.lateralService == null )
-            {
-                log.error( "No service created, must zombie" );
-
-                throw new Exception( "No service created for lateral cache." );
-            }
-
-            this.lateralWatch = new LateralCacheWatchRepairable();
-            this.lateralWatch.setCacheWatch( new ZombieLateralCacheWatch() );
-
-        }
-        catch ( Exception ex )
-        {
-            // Failed to connect to the lateral server.
-            // Configure this LateralCacheManager instance to use the
-            // "zombie" services.
-
-            log.error( "Failure, lateral instance will use zombie service", ex );
-
-            this.lateralService = new ZombieLateralCacheService();
-            this.lateralWatch = new LateralCacheWatchRepairable();
-            this.lateralWatch.setCacheWatch( new ZombieLateralCacheWatch() );
-
-            // Notify the cache monitor about the error, and kick off
-            // the recovery process.
-
-            createMonitor( this );
-            monitor.notifyError();
-        }
-    }
-
-    /**
-     * Adds the lateral cache listener to the underlying cache-watch service.
-     * 
-     * @param cacheName
-     *            The feature to be added to the LateralCacheListener attribute
-     * @param listener
-     *            The feature to be added to the LateralCacheListener attribute
-     * @exception IOException
-     */
-    public void addLateralCacheListener( String cacheName, ILateralCacheListener listener )
-        throws IOException
-    {
-        synchronized ( this.caches )
-        {
-            this.lateralWatch.addCacheListener( cacheName, listener );
-        }
-    }
-
-    /**
-     * Called to access a precreated region or construct one with defaults.
-     * Since all aux cache access goes through the manager, this will never be
-     * called.
-     * <p>
-     * After getting the manager instance for a server, the factory gets a cache
-     * for the region name it is constructing.
-     * <p>
-     * There should be one manager per server and one cache per region per
-     * manager.
-     * 
-     * @return AuxiliaryCache
-     * @param cacheName
-     */
-    public AuxiliaryCache getCache( String cacheName )
-    {
-        LateralCacheNoWait c = null;
-        synchronized ( this.caches )
-        {
-            c = (LateralCacheNoWait) this.caches.get( cacheName );
-            if ( c == null )
-            {
-                LateralCacheAttributes attr = (LateralCacheAttributes) lca.copy();
-                attr.setCacheName( cacheName );
-                LateralCache cache = new LateralCache( attr, this.lateralService, monitor );
-                if ( log.isDebugEnabled() )
-                {
-                    log.debug( "Created cache for noWait, cache = [" + cache + "]" );
-                }
-                c = new LateralCacheNoWait( cache );
-                this.caches.put( cacheName, c );
-
-                log.info( "Created LateralCacheNoWait for " + this.lca + " LateralCacheNoWait = [" + c + "]" );
-            }
-        }
-
-        // don't create a listener if we are not receiving.
-        if ( lca.isReceive() )
-        {
-            try
-            {
-
-                addLateralCacheListener( cacheName, LateralCacheJGListener.getInstance( this.lca, cacheMgr ) );
-
-            }
-            catch ( IOException ioe )
-            {
-                log.error( "Problem creating lateral listener", ioe );
-            }
-            catch ( Exception e )
-            {
-                log.error( "Problem creating lateral listener", e );
-            }
-        }
-        else
-        {
-            if ( log.isDebugEnabled() )
-            {
-                log.debug( "Not creating a listener since we are not receiving." );
-            }
-        }
-
-        // TODO: need listener repair
-
-        return c;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheManager#getInstances()
-     */
-    public Map getInstances()
-    {
-        return instances;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheManager#fixService()
-     */
-    public Object fixService()
-        throws IOException
-    {
-        Object service = null;
-        try
-        {
-            // TODO, do we need to do something here?
-        }
-        catch ( Exception ex )
-        {
-            log.error( "Can't fix " + ex.getMessage() );
-            throw new IOException( "Can't fix " + ex.getMessage() );
-        }
-        return service;
-    }
-}
+package org.apache.jcs.auxiliary.lateral.javagroups;
+
+/*
+ * 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.
+ */
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jcs.auxiliary.AuxiliaryCache;
+import org.apache.jcs.auxiliary.lateral.LateralCache;
+import org.apache.jcs.auxiliary.lateral.LateralCacheAbstractManager;
+import org.apache.jcs.auxiliary.lateral.LateralCacheAttributes;
+import org.apache.jcs.auxiliary.lateral.LateralCacheMonitor;
+import org.apache.jcs.auxiliary.lateral.LateralCacheNoWait;
+import org.apache.jcs.auxiliary.lateral.LateralCacheWatchRepairable;
+import org.apache.jcs.auxiliary.lateral.ZombieLateralCacheService;
+import org.apache.jcs.auxiliary.lateral.ZombieLateralCacheWatch;
+import org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheAttributes;
+import org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheListener;
+import org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheManager;
+import org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheService;
+import org.apache.jcs.engine.behavior.ICompositeCacheManager;
+
+/**
+ * Creates lateral caches. Lateral caches are primarily used for removing non
+ * laterally configured caches. Non laterally configured cache regions should
+ * still bea ble to participate in removal. But if there is a non laterally
+ * configured cache hub, then lateral removals may be necessary. For flat
+ * webserver production environments, without a strong machine at the app server
+ * level, distribution and search may need to occur at the lateral cache level.
+ * This is currently not implemented in the lateral cache.
+ * <p>
+ *
+ * @TODO: - need freeCache, release, getStats - need to find an interface
+ *        acceptible for all - cache managers or a manager within a type
+ *
+ * @deprecated use individual cache managers
+ */
+public class LateralJGCacheManager
+    extends LateralCacheAbstractManager
+{
+    private final static Log log = LogFactory.getLog( LateralJGCacheManager.class );
+
+    private static LateralCacheMonitor monitor;
+
+    final static Map instances = new HashMap();
+
+    // each manager instance has caches
+    final Map caches = new HashMap();
+
+    /**
+     * Description of the Field
+     */
+    protected ILateralCacheAttributes lca;
+
+    private int clients;
+
+    /**
+     * Handle to the lateral cache service; or a zombie handle if failed to
+     * connect.
+     */
+    private ILateralCacheService lateralService;
+
+    /**
+     * Wrapper of the lateral cache watch service; or wrapper of a zombie
+     * service if failed to connect.
+     */
+    private LateralCacheWatchRepairable lateralWatch;
+
+    private ICompositeCacheManager cacheMgr;
+
+    /**
+     * Returns an instance of the LateralCacheManager.
+     *
+     * @param lca
+     * @param cacheMgr
+     *            this allows the auxiliary to be passed a cache manager.
+     * @return
+     */
+    public static LateralJGCacheManager getInstance( ILateralCacheAttributes lca, ICompositeCacheManager cacheMgr )
+    {
+        LateralJGCacheManager ins = (LateralJGCacheManager) instances.get( lca.toString() );
+        synchronized ( instances )
+        {
+            if ( ins == null )
+            {
+                log.info( "Instance for [" + lca.toString() + "] is null, creating" );
+
+                ins = (LateralJGCacheManager) instances.get( lca.toString() );
+                if ( ins == null )
+                {
+                    ins = new LateralJGCacheManager( lca, cacheMgr );
+                    instances.put( lca.toString(), ins );
+                }
+            }
+        }
+
+        createMonitor( ins );
+
+        return ins;
+    }
+
+    /**
+     * The monitor needs reference to one instance, acutally just a type.
+     *
+     * refactor this.
+     *
+     * @param instance
+     */
+    private static synchronized void createMonitor( ILateralCacheManager instance )
+    {
+        //      only want one monitor per lateral type
+        // Fires up the monitoring daemon.
+        if ( monitor == null )
+        {
+            monitor = new LateralCacheMonitor( instance );
+            // Should never be null
+            if ( monitor != null )
+            {
+                Thread t = new Thread( monitor );
+                t.setDaemon( true );
+                t.start();
+            }
+        }
+
+    }
+
+    /**
+     * Constructor for the LateralCacheManager object
+     *
+     * @param lcaA
+     * @param cacheMgr
+     */
+    private LateralJGCacheManager( ILateralCacheAttributes lcaA, ICompositeCacheManager cacheMgr )
+    {
+        this.lca = lcaA;
+
+        this.cacheMgr = cacheMgr;
+
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( "Creating lateral cache service, lca = " + this.lca );
+        }
+
+        // need to create the service based on the type
+
+        try
+        {
+            if ( this.lca.getTransmissionType() == ILateralCacheAttributes.JAVAGROUPS )
+            {
+                log.debug( "Creating JAVAGROUPS service" );
+
+                this.lateralService = new LateralJGService( this.lca );
+            }
+
+            else
+            {
+                log.error( "Type not recognized, must zombie" );
+
+                throw new Exception( "no known transmission type for lateral cache." );
+            }
+
+            if ( this.lateralService == null )
+            {
+                log.error( "No service created, must zombie" );
+
+                throw new Exception( "No service created for lateral cache." );
+            }
+
+            this.lateralWatch = new LateralCacheWatchRepairable();
+            this.lateralWatch.setCacheWatch( new ZombieLateralCacheWatch() );
+
+        }
+        catch ( Exception ex )
+        {
+            // Failed to connect to the lateral server.
+            // Configure this LateralCacheManager instance to use the
+            // "zombie" services.
+
+            log.error( "Failure, lateral instance will use zombie service", ex );
+
+            this.lateralService = new ZombieLateralCacheService();
+            this.lateralWatch = new LateralCacheWatchRepairable();
+            this.lateralWatch.setCacheWatch( new ZombieLateralCacheWatch() );
+
+            // Notify the cache monitor about the error, and kick off
+            // the recovery process.
+
+            createMonitor( this );
+            monitor.notifyError();
+        }
+    }
+
+    /**
+     * Adds the lateral cache listener to the underlying cache-watch service.
+     *
+     * @param cacheName
+     *            The feature to be added to the LateralCacheListener attribute
+     * @param listener
+     *            The feature to be added to the LateralCacheListener attribute
+     * @exception IOException
+     */
+    public void addLateralCacheListener( String cacheName, ILateralCacheListener listener )
+        throws IOException
+    {
+        synchronized ( this.caches )
+        {
+            this.lateralWatch.addCacheListener( cacheName, listener );
+        }
+    }
+
+    /**
+     * Called to access a precreated region or construct one with defaults.
+     * Since all aux cache access goes through the manager, this will never be
+     * called.
+     * <p>
+     * After getting the manager instance for a server, the factory gets a cache
+     * for the region name it is constructing.
+     * <p>
+     * There should be one manager per server and one cache per region per
+     * manager.
+     *
+     * @return AuxiliaryCache
+     * @param cacheName
+     */
+    public AuxiliaryCache getCache( String cacheName )
+    {
+        LateralCacheNoWait c = null;
+        synchronized ( this.caches )
+        {
+            c = (LateralCacheNoWait) this.caches.get( cacheName );
+            if ( c == null )
+            {
+                LateralCacheAttributes attr = (LateralCacheAttributes) lca.copy();
+                attr.setCacheName( cacheName );
+                LateralCache cache = new LateralCache( attr, this.lateralService, monitor );
+                if ( log.isDebugEnabled() )
+                {
+                    log.debug( "Created cache for noWait, cache = [" + cache + "]" );
+                }
+                c = new LateralCacheNoWait( cache );
+                this.caches.put( cacheName, c );
+
+                log.info( "Created LateralCacheNoWait for " + this.lca + " LateralCacheNoWait = [" + c + "]" );
+            }
+        }
+
+        // don't create a listener if we are not receiving.
+        if ( lca.isReceive() )
+        {
+            try
+            {
+
+                addLateralCacheListener( cacheName, LateralCacheJGListener.getInstance( this.lca, cacheMgr ) );
+
+            }
+            catch ( IOException ioe )
+            {
+                log.error( "Problem creating lateral listener", ioe );
+            }
+            catch ( Exception e )
+            {
+                log.error( "Problem creating lateral listener", e );
+            }
+        }
+        else
+        {
+            if ( log.isDebugEnabled() )
+            {
+                log.debug( "Not creating a listener since we are not receiving." );
+            }
+        }
+
+        // TODO: need listener repair
+
+        return c;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheManager#getInstances()
+     */
+    public Map getInstances()
+    {
+        return instances;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheManager#fixService()
+     */
+    public Object fixService()
+        throws IOException
+    {
+        Object service = null;
+        try
+        {
+            // TODO, do we need to do something here?
+        }
+        catch ( Exception ex )
+        {
+            log.error( "Can't fix " + ex.getMessage() );
+            throw new IOException( "Can't fix " + ex.getMessage() );
+        }
+        return service;
+    }
+}

Modified: jakarta/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/lateral/javagroups/LateralJGReceiver.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/lateral/javagroups/LateralJGReceiver.java?view=diff&rev=536904&r1=536903&r2=536904
==============================================================================
--- jakarta/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/lateral/javagroups/LateralJGReceiver.java (original)
+++ jakarta/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/lateral/javagroups/LateralJGReceiver.java Thu May 10 09:03:42 2007
@@ -1,158 +1,161 @@
-package org.apache.jcs.auxiliary.lateral.javagroups;
-
-/*
- * Copyright 2001-2004 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.
- */
-
-import java.io.IOException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheAttributes;
-import org.apache.jcs.auxiliary.lateral.javagroups.behavior.IJGConstants;
-import org.apache.jcs.auxiliary.lateral.javagroups.behavior.ILateralCacheJGListener;
-import org.jgroups.Channel;
-import org.jgroups.ChannelNotConnectedException;
-import org.jgroups.Message;
-import org.jgroups.blocks.RpcDispatcher;
-
-/**
- * Processes commands from the server socket.
- * 
- * @version $Id: LateralJGReceiver.java 224346 2005-06-04 02:01:59Z asmuts $
- */
-public class LateralJGReceiver
-    implements IJGConstants, Runnable
-{
-    private final static Log log = LogFactory.getLog( LateralJGReceiver.class );
-
-    private ILateralCacheJGListener ilcl;
-
-    private ILateralCacheAttributes ilca;
-
-    /**
-     * Main processing method for the LateralJGReceiver object
-     */
-    public void run()
-    {
-        try
-        {
-            if ( log.isDebugEnabled() )
-            {
-                log.debug( "Listening" );
-            }
-
-            JGConnectionHolder holder = JGConnectionHolder.getInstance( ilca );
-            Channel javagroups = holder.getChannel();
-
-            // don't need a dispatcher unless we are allowing gets.
-            // gets are not supported right now.
-            if ( !ilca.getPutOnlyMode() )
-            {
-                RpcDispatcher disp = holder.getDispatcher();
-                if ( log.isDebugEnabled() )
-                {
-                    log.debug( "Dispatcher = " + disp );
-                }
-            }
-
-            if ( javagroups == null )
-            {
-                log.error( "JavaGroups is null" );
-                throw new IOException( "javagroups is null" );
-            }
-
-            int conProbCnt = 0;
-            while ( true )
-            {
-                if ( log.isDebugEnabled() )
-                {
-                    log.debug( "Wating for messages." );
-                }
-
-                Message mes = null;
-                try
-                {
-                    Object obj = javagroups.receive( 0 );
-                    if ( obj != null && obj instanceof org.jgroups.Message )
-                    {
-                        mes = (Message) obj;
-                        if ( log.isDebugEnabled() )
-                        {
-                            log.debug( "Starting new socket node." );
-                        }
-                        new Thread( new LateralJGReceiverConnection( mes, ilcl ) ).start();
-                    }
-                    else
-                    {
-                        if ( log.isDebugEnabled() )
-                        {
-                            log.debug( "Received unknown object from jgroups = " + obj );
-                        }
-                    }
-                }
-                catch ( ChannelNotConnectedException cnce )
-                {
-                    if ( conProbCnt % 20 == 0 )
-                    {
-                        log.warn( cnce );
-                    }
-                    conProbCnt++;
-
-                    if ( conProbCnt >= 2000 )
-                    {
-                        log.error( "Couldn't get connected to group after " + conProbCnt + " tries" );
-                        break;
-                    }
-                    // slow the connection try process down
-                    synchronized ( this )
-                    {
-                        this.wait( 100 );
-                    }
-                    // this will cycle unitl connected and eat up the processor
-                    // need to throw out and recover
-                    // seems to periodically require about 50 tries.
-                }
-                catch ( Exception e )
-                {
-                    // should zombie
-                    log.error( "problem receiving", e );
-                }
-
-            }
-        }
-        catch ( Exception e )
-        {
-            log.error( "Major connection problem", e );
-        }
-    }
-
-    /**
-     * Constructor for the LateralJGReceiver object
-     * 
-     * @param ilcl
-     * @param ilca
-     */
-    public LateralJGReceiver( ILateralCacheAttributes ilca, ILateralCacheJGListener ilcl )
-    {
-
-        this.ilcl = ilcl;
-        this.ilca = ilca;
-        if ( log.isDebugEnabled() )
-        {
-            log.debug( "ilcl = " + ilcl );
-        }
-    }
-}
+package org.apache.jcs.auxiliary.lateral.javagroups;
+
+/*
+ * 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.
+ */
+
+import java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jcs.auxiliary.lateral.behavior.ILateralCacheAttributes;
+import org.apache.jcs.auxiliary.lateral.javagroups.behavior.IJGConstants;
+import org.apache.jcs.auxiliary.lateral.javagroups.behavior.ILateralCacheJGListener;
+import org.jgroups.Channel;
+import org.jgroups.ChannelNotConnectedException;
+import org.jgroups.Message;
+import org.jgroups.blocks.RpcDispatcher;
+
+/**
+ * Processes commands from the server socket.
+ *
+ * @version $Id: LateralJGReceiver.java 224346 2005-06-04 02:01:59Z asmuts $
+ */
+public class LateralJGReceiver
+    implements IJGConstants, Runnable
+{
+    private final static Log log = LogFactory.getLog( LateralJGReceiver.class );
+
+    private ILateralCacheJGListener ilcl;
+
+    private ILateralCacheAttributes ilca;
+
+    /**
+     * Main processing method for the LateralJGReceiver object
+     */
+    public void run()
+    {
+        try
+        {
+            if ( log.isDebugEnabled() )
+            {
+                log.debug( "Listening" );
+            }
+
+            JGConnectionHolder holder = JGConnectionHolder.getInstance( ilca );
+            Channel javagroups = holder.getChannel();
+
+            // don't need a dispatcher unless we are allowing gets.
+            // gets are not supported right now.
+            if ( !ilca.getPutOnlyMode() )
+            {
+                RpcDispatcher disp = holder.getDispatcher();
+                if ( log.isDebugEnabled() )
+                {
+                    log.debug( "Dispatcher = " + disp );
+                }
+            }
+
+            if ( javagroups == null )
+            {
+                log.error( "JavaGroups is null" );
+                throw new IOException( "javagroups is null" );
+            }
+
+            int conProbCnt = 0;
+            while ( true )
+            {
+                if ( log.isDebugEnabled() )
+                {
+                    log.debug( "Wating for messages." );
+                }
+
+                Message mes = null;
+                try
+                {
+                    Object obj = javagroups.receive( 0 );
+                    if ( obj != null && obj instanceof org.jgroups.Message )
+                    {
+                        mes = (Message) obj;
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Starting new socket node." );
+                        }
+                        new Thread( new LateralJGReceiverConnection( mes, ilcl ) ).start();
+                    }
+                    else
+                    {
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "Received unknown object from jgroups = " + obj );
+                        }
+                    }
+                }
+                catch ( ChannelNotConnectedException cnce )
+                {
+                    if ( conProbCnt % 20 == 0 )
+                    {
+                        log.warn( cnce );
+                    }
+                    conProbCnt++;
+
+                    if ( conProbCnt >= 2000 )
+                    {
+                        log.error( "Couldn't get connected to group after " + conProbCnt + " tries" );
+                        break;
+                    }
+                    // slow the connection try process down
+                    synchronized ( this )
+                    {
+                        this.wait( 100 );
+                    }
+                    // this will cycle unitl connected and eat up the processor
+                    // need to throw out and recover
+                    // seems to periodically require about 50 tries.
+                }
+                catch ( Exception e )
+                {
+                    // should zombie
+                    log.error( "problem receiving", e );
+                }
+
+            }
+        }
+        catch ( Exception e )
+        {
+            log.error( "Major connection problem", e );
+        }
+    }
+
+    /**
+     * Constructor for the LateralJGReceiver object
+     *
+     * @param ilcl
+     * @param ilca
+     */
+    public LateralJGReceiver( ILateralCacheAttributes ilca, ILateralCacheJGListener ilcl )
+    {
+
+        this.ilcl = ilcl;
+        this.ilca = ilca;
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( "ilcl = " + ilcl );
+        }
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: jcs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jcs-dev-help@jakarta.apache.org