incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1511600 - /sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java
Date Thu, 08 Aug 2013 07:05:06 GMT
Author: cziegeler
Date: Thu Aug  8 07:05:06 2013
New Revision: 1511600

URL: http://svn.apache.org/r1511600
Log:
Update locking code to handle SNS

Modified:
    sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java

Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java?rev=1511600&r1=1511599&r2=1511600&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java
(original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java
Thu Aug  8 07:05:06 2013
@@ -1151,9 +1151,10 @@ public class JobManagerImpl
         ResourceResolver resolver = null;
         try {
             resolver = this.resourceResolverFactory.getAdministrativeResourceResolver(null);
+            final String lockName = ResourceHelper.filterName(id);
             final StringBuilder sb = new StringBuilder(this.configuration.getLocksPath());
             sb.append('/');
-            sb.append(ResourceHelper.filterName(id));
+            sb.append(lockName);
             final String path = sb.toString();
 
             Resource lockResource = resolver.getResource(path);
@@ -1169,12 +1170,21 @@ public class JobManagerImpl
                             path,
                             props);
 
-                    final ValueMap vm = lockResource.adaptTo(ValueMap.class);
-                    if ( logger.isDebugEnabled() ) {
-                        logger.debug("Got lock resource on instance {} with {}", Environment.APPLICATION_ID,
vm.get(Utility.PROPERTY_LOCK_CREATED_APP));
-                    }
-                    if ( vm.get(Utility.PROPERTY_LOCK_CREATED_APP).equals(Environment.APPLICATION_ID)
) {
-                        hasLock = true;
+                    // check if lock resource has correct name (SNS)
+                    if ( !lockResource.getName().equals(lockName) ) {
+                        if ( logger.isDebugEnabled() ) {
+                            logger.debug("Created SNS lock resource on instance {} - discarding",
Environment.APPLICATION_ID);
+                        }
+                        resolver.delete(lockResource);
+                        resolver.commit();
+                    } else {
+                        final ValueMap vm = lockResource.adaptTo(ValueMap.class);
+                        if ( logger.isDebugEnabled() ) {
+                            logger.debug("Got lock resource on instance {} with {}", Environment.APPLICATION_ID,
vm.get(Utility.PROPERTY_LOCK_CREATED_APP));
+                        }
+                        if ( vm.get(Utility.PROPERTY_LOCK_CREATED_APP).equals(Environment.APPLICATION_ID)
) {
+                            hasLock = true;
+                        }
                     }
                 } catch (final PersistenceException ignore) {
                     // ignore



Mime
View raw message