You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by dj...@apache.org on 2013/02/10 08:43:24 UTC

svn commit: r1444491 - in /felix/trunk/scr/src/main/java/org/apache/felix/scr/impl: ScrCommand.java config/ScrConfiguration.java config/ScrManagedServiceMetaTypeProvider.java manager/AbstractComponentManager.java

Author: djencks
Date: Sun Feb 10 07:43:24 2013
New Revision: 1444491

URL: http://svn.apache.org/r1444491
Log:
FELIX-3888 Make the lock timeout a configuration property, and expose it in the config command

Modified:
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrConfiguration.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrManagedServiceMetaTypeProvider.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java?rev=1444491&r1=1444490&r2=1444491&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java Sun Feb 10 07:43:24 2013
@@ -457,6 +457,8 @@ public class ScrCommand implements ScrIn
         out.println(scrConfiguration.isFactoryEnabled() ? "Supported" : "Unsupported");
         out.print("Keep instances with no references: ");
         out.println(scrConfiguration.keepInstances() ? "Supported" : "Unsupported");
+        out.print("Lock timeount milliseconds: ");
+        out.println(scrConfiguration.lockTimeout());
         out.print("Info Service registered: ");
         out.println(scrConfiguration.infoAsService() ? "Supported" : "Unsupported");
     }

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrConfiguration.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrConfiguration.java?rev=1444491&r1=1444490&r2=1444491&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrConfiguration.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrConfiguration.java Sun Feb 10 07:43:24 2013
@@ -64,6 +64,8 @@ public class ScrConfiguration
 
     public static final String PROP_INFO_SERVICE = "ds.info.service";
     
+    public static final String PROP_LOCK_TIMEOUT = "ds.lock.timeout.milliseconds";
+    
     public static final String PROP_LOGLEVEL = "ds.loglevel";
 
     private static final String LOG_LEVEL_DEBUG = "debug";
@@ -85,6 +87,8 @@ public class ScrConfiguration
     private boolean keepInstances;
     
     private boolean infoAsService;
+    
+    private long lockTimeout = 5000;//milliseconds
 
     private BundleContext bundleContext;
 
@@ -139,6 +143,7 @@ public class ScrConfiguration
                 factoryEnabled = false;
                 keepInstances = false;
                 infoAsService = false;
+                lockTimeout = 5000;
             }
             else
             {
@@ -146,6 +151,7 @@ public class ScrConfiguration
                 factoryEnabled = getDefaultFactoryEnabled();
                 keepInstances = getDefaultKeepInstances();
                 infoAsService = getDefaultInfoAsService();
+                lockTimeout = getDefaultLockTimeout();
             }
         }
         else
@@ -154,6 +160,8 @@ public class ScrConfiguration
             factoryEnabled = VALUE_TRUE.equalsIgnoreCase( String.valueOf( config.get( PROP_FACTORY_ENABLED ) ) );
             keepInstances = VALUE_TRUE.equalsIgnoreCase( String.valueOf( config.get( PROP_DELAYED_KEEP_INSTANCES ) ) );
             infoAsService = VALUE_TRUE.equalsIgnoreCase( String.valueOf( config.get( PROP_INFO_SERVICE) ) );
+            Long timeout = ( Long ) config.get( PROP_LOCK_TIMEOUT );
+            lockTimeout = timeout == null? 5000: timeout;
         }
         if ( scrCommand != null )
         {
@@ -187,6 +195,10 @@ public class ScrConfiguration
         return infoAsService;
     }
 
+    public long lockTimeout()
+    {
+        return lockTimeout;
+    }
 
     private boolean getDefaultFactoryEnabled()
     {
@@ -210,6 +222,16 @@ public class ScrConfiguration
         return VALUE_TRUE.equalsIgnoreCase( bundleContext.getProperty( PROP_INFO_SERVICE) );
     }
 
+    private long getDefaultLockTimeout()
+    {
+        String val = bundleContext.getProperty( PROP_LOCK_TIMEOUT);
+        if ( val == null)
+        {
+            return 5000;
+        }
+        return Long.parseLong( val );
+    }
+
 
     private int getLogLevel( final Object levelObject )
     {

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrManagedServiceMetaTypeProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrManagedServiceMetaTypeProvider.java?rev=1444491&r1=1444490&r2=1444491&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrManagedServiceMetaTypeProvider.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrManagedServiceMetaTypeProvider.java Sun Feb 10 07:43:24 2013
@@ -105,9 +105,17 @@ class ScrManagedServiceMetaTypeProvider 
         adList.add( new AttributeDefinitionImpl(
                 ScrConfiguration.PROP_INFO_SERVICE,
                 "Bind Info Service",
-                "Whether to bind a service backing the console commands providing info on components ", 
+                "Whether to bind a service backing the console commands providing info on components.", 
                 this.getScrConfiguration().infoAsService() ) );
 
+        adList.add( new AttributeDefinitionImpl(
+                ScrConfiguration.PROP_LOCK_TIMEOUT,
+                "Lock timeout milliseconds",
+                "How long a lock is held before releasing due to suspected deadlock", 
+                AttributeDefinition.LONG,
+                new String[] { String.valueOf(this.getScrConfiguration().lockTimeout())}, 
+                0, null, null) );
+
         return new ObjectClassDefinition()
         {
 

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java?rev=1444491&r1=1444490&r2=1444491&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java Sun Feb 10 07:43:24 2013
@@ -105,8 +105,6 @@ public abstract class AbstractComponentM
 
     private final ReentrantLock m_stateLock;
 
-    private long m_timeout = 5000;
-
     protected volatile boolean enabled;
     protected volatile CountDownLatch enabledLatch;
     private final Object enabledLatchLock = new Object();
@@ -180,7 +178,7 @@ public abstract class AbstractComponentM
     {
         try
         {
-            if (!m_stateLock.tryLock( m_timeout, TimeUnit.MILLISECONDS ) )
+            if (!m_stateLock.tryLock( getActivator().getConfiguration().lockTimeout(), TimeUnit.MILLISECONDS ) )
             {
             	dumpThreads();
                 throw new IllegalStateException( "Could not obtain lock" );