You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tv...@apache.org on 2018/08/21 08:39:31 UTC

svn commit: r1838532 - in /commons/proper/jcs/branches/commons-jcs-2.2.x/commons-jcs-core/src: main/java/org/apache/commons/jcs/auxiliary/remote/server/ main/java/org/apache/commons/jcs/auxiliary/remote/server/behavior/ test/java/org/apache/commons/jcs...

Author: tv
Date: Tue Aug 21 08:39:31 2018
New Revision: 1838532

URL: http://svn.apache.org/viewvc?rev=1838532&view=rev
Log:
The BasicRemoteCacheClientServerUnitTest errors surfaced again. Try to finally fix this.

Modified:
    commons/proper/jcs/branches/commons-jcs-2.2.x/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RegistryKeepAliveRunner.java
    commons/proper/jcs/branches/commons-jcs-2.2.x/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerAttributes.java
    commons/proper/jcs/branches/commons-jcs-2.2.x/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java
    commons/proper/jcs/branches/commons-jcs-2.2.x/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/behavior/IRemoteCacheServerAttributes.java
    commons/proper/jcs/branches/commons-jcs-2.2.x/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactoryUnitTest.java

Modified: commons/proper/jcs/branches/commons-jcs-2.2.x/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RegistryKeepAliveRunner.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2.x/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RegistryKeepAliveRunner.java?rev=1838532&r1=1838531&r2=1838532&view=diff
==============================================================================
--- commons/proper/jcs/branches/commons-jcs-2.2.x/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RegistryKeepAliveRunner.java (original)
+++ commons/proper/jcs/branches/commons-jcs-2.2.x/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RegistryKeepAliveRunner.java Tue Aug 21 08:39:31 2018
@@ -41,6 +41,9 @@ public class RegistryKeepAliveRunner
     /** The URL of the service to look for. */
     private String namingURL;
 
+    /** The service name. */
+    private String serviceName;
+
     /** the port on which to start the registry */
     private int registryPort;
 
@@ -55,6 +58,7 @@ public class RegistryKeepAliveRunner
     public RegistryKeepAliveRunner( String registryHost, int registryPort, String serviceName )
     {
         this.namingURL = RemoteUtils.getNamingURL(registryHost, registryPort, serviceName);
+        this.serviceName = serviceName;
         this.registryPort = registryPort;
     }
 
@@ -104,27 +108,27 @@ public class RegistryKeepAliveRunner
             {
                 cacheEventLogger.logError( "RegistryKeepAliveRunner", "Naming.lookup", message + ":" + ex.getMessage() );
             }
-            createAndRegister( namingURL );
+            createAndRegister( serviceName );
         }
     }
 
     /**
      * Creates the registry and registers the server.
      * <p>
-     * @param registry
+     * @param serviceName the service name
      */
-    protected void createAndRegister( String registry )
+    protected void createAndRegister( String serviceName )
     {
-        createReqistry( registry );
-        registerServer( registry );
+        Registry reg = createReqistry( serviceName );
+        registerServer(reg, serviceName );
     }
 
     /**
      * Try to create the registry. Log errors
      * <p>
-     * @param registry
+     * @param serviceName the service name
      */
-    protected void createReqistry( String registry )
+    protected Registry createReqistry( String serviceName )
     {
         Registry reg = RemoteUtils.createRegistry(registryPort);
 
@@ -133,28 +137,30 @@ public class RegistryKeepAliveRunner
             if (reg != null)
             {
                 cacheEventLogger.logApplicationEvent( "RegistryKeepAliveRunner", "createRegistry",
-                        "Successfully created registry [" + registry + "]." );
+                        "Successfully created registry [" + serviceName + "]." );
             }
             else
             {
                 cacheEventLogger.logError( "RegistryKeepAliveRunner", "createRegistry",
-                        "Could not start registry [" + registry + "]." );
+                        "Could not start registry [" + serviceName + "]." );
             }
         }
+
+        return reg;
     }
 
     /**
      * Try to rebind the server.
      * <p>
-     * @param registry
+     * @param serviceName the service name
      */
-    protected void registerServer( String registry )
+    protected void registerServer(Registry reg, String serviceName )
     {
         try
         {
             // try to rebind anyway
-            RemoteCacheServerFactory.registerServer( registry, RemoteCacheServerFactory.getRemoteCacheServer() );
-            String message = "Successfully rebound server to registry [" + registry + "].";
+            RemoteCacheServerFactory.registerServer(reg, serviceName, RemoteCacheServerFactory.getRemoteCacheServer() );
+            String message = "Successfully rebound server to registry [" + serviceName + "].";
             if ( cacheEventLogger != null )
             {
                 cacheEventLogger.logApplicationEvent( "RegistryKeepAliveRunner", "registerServer", message );
@@ -166,7 +172,7 @@ public class RegistryKeepAliveRunner
         }
         catch ( RemoteException e )
         {
-            String message = "Could not rebind server to registry [" + registry + "].";
+            String message = "Could not rebind server to registry [" + serviceName + "].";
             log.error( message, e );
             if ( cacheEventLogger != null )
             {

Modified: commons/proper/jcs/branches/commons-jcs-2.2.x/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerAttributes.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2.x/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerAttributes.java?rev=1838532&r1=1838531&r2=1838532&view=diff
==============================================================================
--- commons/proper/jcs/branches/commons-jcs-2.2.x/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerAttributes.java (original)
+++ commons/proper/jcs/branches/commons-jcs-2.2.x/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerAttributes.java Tue Aug 21 08:39:31 2018
@@ -201,7 +201,6 @@ public class RemoteCacheServerAttributes
         buf.append( "\n allowClusterGet = [" + this.isAllowClusterGet() + "]" );
         buf.append( "\n configFileName = [" + this.getConfigFileName() + "]" );
         buf.append( "\n rmiSocketFactoryTimeoutMillis = [" + this.getRmiSocketFactoryTimeoutMillis() + "]" );
-        buf.append( "\n startRegistry = [" + this.isStartRegistry() + "]" );
         buf.append( "\n useRegistryKeepAlive = [" + this.isUseRegistryKeepAlive() + "]" );
         buf.append( "\n registryKeepAliveDelayMillis = [" + this.getRegistryKeepAliveDelayMillis() + "]" );
         buf.append( "\n eventQueueType = [" + this.getEventQueueType() + "]" );

Modified: commons/proper/jcs/branches/commons-jcs-2.2.x/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2.x/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java?rev=1838532&r1=1838531&r2=1838532&view=diff
==============================================================================
--- commons/proper/jcs/branches/commons-jcs-2.2.x/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java (original)
+++ commons/proper/jcs/branches/commons-jcs-2.2.x/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java Tue Aug 21 08:39:31 2018
@@ -94,11 +94,11 @@ public class RemoteCacheServerFactory
      * <p>
      * A remote cache is either a local cache or a cluster cache.
      * <p>
-     * @param host the host name 
+     * @param host the host name
      * @param port the port number
      * @param propFile the remote cache hub configuration file
      * @throws IOException
-     * 
+     *
      * @deprecated Use startup(String, int, Properties) instead
      */
     @Deprecated
@@ -119,12 +119,12 @@ public class RemoteCacheServerFactory
      * <p>
      * A remote cache is either a local cache or a cluster cache.
      * <p>
-     * @param host the host name 
+     * @param host the host name
      * @param port the port number
      * @param props the remote cache hub configuration
      * @param propFile the remote cache hub configuration file
      * @throws IOException
-     * 
+     *
      * @deprecated Use startup(String, int, Properties) instead
      */
     @Deprecated
@@ -199,13 +199,10 @@ public class RemoteCacheServerFactory
             remoteCacheServer.setCacheEventLogger( cacheEventLogger );
 
             // START THE REGISTRY
-            if (rcsa.isStartRegistry())
-            {
-            	registry = RemoteUtils.createRegistry(port);
-            }
+        	registry = RemoteUtils.createRegistry(port);
 
             // REGISTER THE SERVER
-            registerServer( RemoteUtils.getNamingURL(host, port, serviceName), remoteCacheServer );
+            registerServer( registry, serviceName, remoteCacheServer );
 
             // KEEP THE REGISTRY ALIVE
             if ( rcsa.isUseRegistryKeepAlive() )
@@ -277,11 +274,12 @@ public class RemoteCacheServerFactory
      * Registers the server with the registry. I broke this off because we might want to have code
      * that will restart a dead registry. It will need to rebind the server.
      * <p>
-     * @param namingURL
-     * @param server
+     * @param registry the RMI registry
+     * @param serviceName the name of the service
+     * @param server the server object to bind
      * @throws RemoteException
      */
-    protected static void registerServer( String namingURL, Remote server )
+    protected static void registerServer(Registry registry, String serviceName, Remote server )
         throws RemoteException
     {
         if ( server == null )
@@ -291,18 +289,10 @@ public class RemoteCacheServerFactory
 
         if ( log.isInfoEnabled() )
         {
-            log.info( "Binding server to " + namingURL );
+            log.info( "Binding server to " + serviceName );
         }
 
-        try
-        {
-            Naming.rebind( namingURL, server );
-        }
-        catch ( MalformedURLException ex )
-        {
-            // impossible case.
-            throw new IllegalArgumentException( ex.getMessage() + "; url=" + namingURL );
-        }
+        registry.rebind( serviceName, server );
     }
 
     /**
@@ -516,12 +506,12 @@ public class RemoteCacheServerFactory
 
     /**
      * Look up the remote cache service admin instance
-     *  
+     *
      * @param config the configuration properties
      * @param port the local port
      * @return the admin object instance
-     * 
-     * @throws Exception if lookup fails 
+     *
+     * @throws Exception if lookup fails
      */
     private static ICacheServiceAdmin lookupCacheServiceAdmin(Properties config, int port) throws Exception
     {
@@ -537,10 +527,10 @@ public class RemoteCacheServerFactory
         {
             log.debug( "server found" );
         }
-        
+
         return (ICacheServiceAdmin) obj;
     }
-    
+
     /**
      * @param serviceName the serviceName to set
      */

Modified: commons/proper/jcs/branches/commons-jcs-2.2.x/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/behavior/IRemoteCacheServerAttributes.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2.x/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/behavior/IRemoteCacheServerAttributes.java?rev=1838532&r1=1838531&r2=1838532&view=diff
==============================================================================
--- commons/proper/jcs/branches/commons-jcs-2.2.x/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/behavior/IRemoteCacheServerAttributes.java (original)
+++ commons/proper/jcs/branches/commons-jcs-2.2.x/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/behavior/IRemoteCacheServerAttributes.java Tue Aug 21 08:39:31 2018
@@ -89,6 +89,7 @@ public interface IRemoteCacheServerAttri
      * Should we start the registry
      * <p>
      * @param startRegistry the startRegistry to set
+     * @deprecated Always true, to be removed
      */
     void setStartRegistry( boolean startRegistry );
 
@@ -96,6 +97,7 @@ public interface IRemoteCacheServerAttri
      * Should we start the registry
      * <p>
      * @return the startRegistry
+     * @deprecated Always true, to be removed
      */
     boolean isStartRegistry();
 

Modified: commons/proper/jcs/branches/commons-jcs-2.2.x/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactoryUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2.x/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactoryUnitTest.java?rev=1838532&r1=1838531&r2=1838532&view=diff
==============================================================================
--- commons/proper/jcs/branches/commons-jcs-2.2.x/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactoryUnitTest.java (original)
+++ commons/proper/jcs/branches/commons-jcs-2.2.x/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactoryUnitTest.java Tue Aug 21 08:39:31 2018
@@ -1,5 +1,11 @@
 package org.apache.commons.jcs.auxiliary.remote.server;
 
+import java.rmi.server.RMISocketFactory;
+import java.util.Properties;
+
+import org.apache.commons.jcs.auxiliary.remote.behavior.ICommonRemoteCacheAttributes;
+import org.apache.commons.jcs.auxiliary.remote.behavior.IRemoteCacheConstants;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -20,11 +26,6 @@ package org.apache.commons.jcs.auxiliary
  */
 
 import junit.framework.TestCase;
-import org.apache.commons.jcs.auxiliary.remote.behavior.ICommonRemoteCacheAttributes;
-import org.apache.commons.jcs.auxiliary.remote.behavior.IRemoteCacheConstants;
-
-import java.rmi.server.RMISocketFactory;
-import java.util.Properties;
 
 /** Unit tests for the factory */
 public class RemoteCacheServerFactoryUnitTest
@@ -103,21 +104,6 @@ public class RemoteCacheServerFactoryUni
         assertEquals( "Wrong useRegistryKeepAlive", useRegistryKeepAlive, result.isUseRegistryKeepAlive() );
     }
 
-    /** verify that we get the startRegistry value */
-    public void testConfigureRemoteCacheServerAttributes_startRegistryPresent()
-    {
-        // SETUP
-        boolean startRegistry = false;
-        Properties props = new Properties();
-        props.put( IRemoteCacheConstants.CACHE_SERVER_ATTRIBUTES_PROPERTY_PREFIX + ".startRegistry", String.valueOf( startRegistry ) );
-
-        // DO WORK
-        RemoteCacheServerAttributes result = RemoteCacheServerFactory.configureRemoteCacheServerAttributes( props );
-
-        // VERIFY
-        assertEquals( "Wrong startRegistry", startRegistry, result.isStartRegistry() );
-    }
-
     /** verify that we get the registryKeepAliveDelayMillis value */
     public void testConfigureRemoteCacheServerAttributes_rmiSocketFactoryTimeoutMillisPresent()
     {
@@ -133,7 +119,7 @@ public class RemoteCacheServerFactoryUni
         assertEquals( "Wrong rmiSocketFactoryTimeoutMillis", rmiSocketFactoryTimeoutMillis, result.getRmiSocketFactoryTimeoutMillis() );
     }
 
-    /** verify that we get the startRegistry value */
+    /** verify that we get the allowClusterGet value */
     public void testConfigureRemoteCacheServerAttributes_allowClusterGetPresent()
     {
         // SETUP
@@ -148,7 +134,7 @@ public class RemoteCacheServerFactoryUni
         assertEquals( "Wrong allowClusterGet", allowClusterGet, result.isAllowClusterGet() );
     }
 
-    /** verify that we get the startRegistry value */
+    /** verify that we get the localClusterConsistency value */
     public void testConfigureRemoteCacheServerAttributes_localClusterConsistencyPresent()
     {
         // SETUP
@@ -163,7 +149,7 @@ public class RemoteCacheServerFactoryUni
         assertEquals( "Wrong localClusterConsistency", localClusterConsistency, result.isLocalClusterConsistency() );
     }
 
-    /** verify that we get the timeout value */
+    /** verify that we get the testStringProperty value */
     public void testConfigureObjectSpecificCustomFactory_withProperty()
     {
         // SETUP