felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1551422 - in /felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl: CoordinationImpl.java CoordinationMgr.java CoordinatorImpl.java
Date Tue, 17 Dec 2013 00:42:17 GMT
Author: cziegeler
Date: Tue Dec 17 00:42:17 2013
New Revision: 1551422

URL: http://svn.apache.org/r1551422
Log:
FELIX-2647 : Implement Coordinator Service - further fixes for the CT tests cases, 59 of 61
passing (implemented nested failure handling, wrong thread)

Modified:
    felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationImpl.java
    felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationMgr.java
    felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinatorImpl.java

Modified: felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationImpl.java?rev=1551422&r1=1551421&r2=1551422&view=diff
==============================================================================
--- felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationImpl.java
(original)
+++ felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationImpl.java
Tue Dec 17 00:42:17 2013
@@ -160,10 +160,20 @@ public class CoordinationImpl implements
      */
     public void end()
     {
+        if ( !this.isTerminated() && this.associatedThread != null && Thread.currentThread()
!= this.associatedThread )
+        {
+            throw new CoordinationException("Coordination is associated with different thread",
this, CoordinationException.WRONG_THREAD);
+        }
+
         if (startTermination())
         {
-            // TODO check for WRONG_THREAD
-            boolean partialFailure = this.owner.endNestedCoordinations(this);
+
+            final CoordinationException nestedFailed = this.owner.endNestedCoordinations(this);
+            if ( nestedFailed != null )
+            {
+                this.failReason = nestedFailed;
+            }
+            boolean partialFailure = false;
             this.owner.unregister(this, true);
 
             final List<Participant> releaseList = new ArrayList<Participant>();
@@ -178,7 +188,14 @@ public class CoordinationImpl implements
                 final Participant part = releaseList.get(i);
                 try
                 {
-                    part.ended(this);
+                    if ( this.failReason != null )
+                    {
+                        part.failed(this);
+                    }
+                    else
+                    {
+                        part.ended(this);
+                    }
                 }
                 catch (final Exception e)
                 {
@@ -197,6 +214,11 @@ public class CoordinationImpl implements
                 this.waitLock.notifyAll();
             }
 
+            if ( this.failReason != null )
+            {
+                throw new CoordinationException("Nested coordination failed", this,
+                        CoordinationException.FAILED, this.failReason);
+            }
             if (partialFailure)
             {
                 throw new CoordinationException("One or more participants threw while ending
the coordination", this,

Modified: felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationMgr.java
URL: http://svn.apache.org/viewvc/felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationMgr.java?rev=1551422&r1=1551421&r2=1551422&view=diff
==============================================================================
--- felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationMgr.java
(original)
+++ felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinationMgr.java
Tue Dec 17 00:42:17 2013
@@ -408,9 +408,9 @@ public class CoordinationMgr implements 
 		return null;
 	}
 
-	public boolean endNestedCoordinations(final CoordinationImpl c)
+	public CoordinationException endNestedCoordinations(final CoordinationImpl c)
 	{
-	    boolean partiallyFailed = false;
+	    CoordinationException partiallyFailed = null;
         final Stack<CoordinationImpl> stack = this.getThreadStack(false);
         if ( stack != null )
         {
@@ -423,11 +423,15 @@ public class CoordinationMgr implements 
         			final CoordinationImpl nested = stack.pop();
         			try
         			{
+        			    if ( partiallyFailed != null)
+        			    {
+        			        nested.fail(partiallyFailed);
+        			    }
     			        nested.end();
         			}
         			catch ( final CoordinationException ce)
         			{
-        			    partiallyFailed = true;
+        			    partiallyFailed = ce;
         			}
         		}
         	}

Modified: felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinatorImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinatorImpl.java?rev=1551422&r1=1551421&r2=1551422&view=diff
==============================================================================
--- felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinatorImpl.java
(original)
+++ felix/trunk/coordinator/src/main/java/org/apache/felix/coordinator/impl/CoordinatorImpl.java
Tue Dec 17 00:42:17 2013
@@ -23,6 +23,7 @@ import java.util.TimerTask;
 
 import org.osgi.framework.Bundle;
 import org.osgi.service.coordinator.Coordination;
+import org.osgi.service.coordinator.CoordinationException;
 import org.osgi.service.coordinator.Coordinator;
 import org.osgi.service.coordinator.Participant;
 
@@ -255,7 +256,7 @@ public class CoordinatorImpl implements 
 		return mgr.getEnclosingCoordination(c);
 	}
 
-	boolean endNestedCoordinations(final CoordinationImpl c)
+	CoordinationException endNestedCoordinations(final CoordinationImpl c)
 	{
 		return this.mgr.endNestedCoordinations(c);
 	}



Mime
View raw message