diff options
Diffstat (limited to 'sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMemberImpl.java')
-rw-r--r-- | sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMemberImpl.java | 38 |
1 files changed, 13 insertions, 25 deletions
diff --git a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMemberImpl.java b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMemberImpl.java index ec6ecb609c..893d5fcb1b 100644 --- a/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMemberImpl.java +++ b/sandbox/dougsleite/guardian-model/src/main/java/org/apache/tuscany/sca/guardian/GuardianMemberImpl.java @@ -41,12 +41,15 @@ public class GuardianMemberImpl implements GuardianMember { @Reference(name = "guardian_group", required = true) public GuardianGroup guardianGroup; private int id; + //FIXME: Review the usage of this variable + private boolean exceptionThrown; public GuardianMemberImpl() { contextList = new Stack<Context>(); contextList.add(Context.INIT_CONTEXT); exceptionQueue = new LinkedList<GlobalException>(); participantState = GuardianGroup.NORMAL_PARTICIPANT_STATE; + exceptionThrown = false; } @Init @@ -82,7 +85,7 @@ public class GuardianMemberImpl implements GuardianMember { if (contextList.size() == 2) { JoinException ex = new JoinException(); ex.setSignalingContext(context); - ex.setSignalingParticipant(getParticipantIdentifier()); + ex.putSignalingParticipant(getParticipantIdentifier()); gthrow(ex, null); } @@ -94,7 +97,6 @@ public class GuardianMemberImpl implements GuardianMember { } } - //Adapt to allow a regular expression //If participantList is null then signal to ALL participants public void gthrow(GlobalExceptionInterface ex, List<String> participantList) { //1)Block the participant until raise an exception @@ -102,28 +104,16 @@ public class GuardianMemberImpl implements GuardianMember { if (!(ex instanceof SuspendException)) { //Set the exception's parameters ex.setSignalingContext(getCurrentContext()); - ex.setSignalingParticipant(getParticipantIdentifier()); + ex.putSignalingParticipant(getParticipantIdentifier()); guardianGroup.gthrow(ex, participantList); + exceptionThrown = true; } else { /*if (service instanceof BlockingInterface && !service.isBlocked()) { - service.block(); + service.block(); }*/ - participantState = GuardianGroup.SUSPENDED_PARTICIPANT_STATE; + setParticipantState(GuardianGroup.SUSPENDED_PARTICIPANT_STATE); } - - //*Is here the best place to receive such kind of msg? - // - //2B)When receive exception_msg from GuardianGroup do - // if participant is not suspended then suspend it - // if participant supports interrupts then - // interrupt it, add SuspendException in the exception_queue, and invoke checkExceptionStatus - // else invoke checkExceptionStatus periodically - // - //4)Once ALL required participants are SUSPENDED (suspended point), invoke the defined Recovery Rules - // 4.1) recovery_rules < signaled exceptions + context_list of all participant > target context + exception to raise - // 4.2) raise the resolved exception in each participant -> it goes to the exception_queue - } public boolean propagate(GlobalExceptionInterface ex) { @@ -132,19 +122,18 @@ public class GuardianMemberImpl implements GuardianMember { } public void checkExceptionStatus() throws GlobalException { - //1)Chek the exception queue - // 1.1) if exception_queue is empty then return - // else if first element on the exception_queue is SuspendException then - // the method blocks until the next exception is received. The method raises the first non-SuspendException in the queue //Blocks until the state be diferent the SUSPENDED_STATE - while (participantState == GuardianGroup.SUSPENDED_PARTICIPANT_STATE) { + while (participantState == GuardianGroup.SUSPENDED_PARTICIPANT_STATE && exceptionThrown) { + System.out.println(getParticipantIdentifier() + ": I am blocked!"); try { - Thread.sleep(5000); + Thread.sleep(5000); } catch (InterruptedException ex) { Logger.getLogger(GuardianMemberImpl.class.getName()).log(Level.SEVERE, null, ex); } } + exceptionThrown = false; + System.out.println(getParticipantIdentifier() + ": I am not blocked!"); GlobalException exc; @@ -170,7 +159,6 @@ public class GuardianMemberImpl implements GuardianMember { public String getParticipantIdentifier() { //1) Return the participant identifier -> context list dot separated StringBuffer participantIdentifier = new StringBuffer(); - //id.append(this.id + "." + Context.INIT_CONTEXT.getName()); participantIdentifier.append(this.id); for (int i = 0; i < contextList.size(); i++) { participantIdentifier.append("." + contextList.get(i).getName()); |