OW2 Consortium
Search OW2 Mail Archive: 

Advanced Search - Powered by Google


Mail Archive Home | gotm-commits List | December 2005 Index

<--  Date Index  --> <--  Thread Index  -->

CVS update of gotm/src/java/org/objectweb/gotm/lib (5 files)


    Date: Friday, December 23, 2005 @ 12:53:38
  Author: rouvoy
    Path: /cvsroot/gotm/gotm/src/java/org/objectweb/gotm/lib

Modified: coordination/ProbeCommitProtocol.java
          factory/TransactionFactoryAdaptive.java
          factory/TransactionFactoryCache.java message/SubscriberPool.java
          probe/ProbeAbstract.java

* Updating the ACOM example.


-----------------------------------------+
 coordination/ProbeCommitProtocol.java   |   71 +++++++++++++-----------------
 factory/TransactionFactoryAdaptive.java |    7 +-
 factory/TransactionFactoryCache.java    |    5 +-
 message/SubscriberPool.java             |   19 +++++---
 probe/ProbeAbstract.java                |   21 ++++----
 5 files changed, 60 insertions(+), 63 deletions(-)


Index: 
gotm/src/java/org/objectweb/gotm/lib/coordination/ProbeCommitProtocol.java
diff -u 
gotm/src/java/org/objectweb/gotm/lib/coordination/ProbeCommitProtocol.java:1.10
 
gotm/src/java/org/objectweb/gotm/lib/coordination/ProbeCommitProtocol.java:1.11
--- 
gotm/src/java/org/objectweb/gotm/lib/coordination/ProbeCommitProtocol.java:1.10
     Tue Dec 20 16:43:33 2005
+++ 
gotm/src/java/org/objectweb/gotm/lib/coordination/ProbeCommitProtocol.java  
Fri Dec 23 12:53:38 2005
@@ -17,34 +17,33 @@
 Initial developer(s): Romain Rouvoy (romain.rouvoy@xxxxxxx)
 Contributor(s): .
 
--------------------------------------------------------------------------------
-$Id: ProbeCommitProtocol.java,v 1.10 2005/12/20 15:43:33 rouvoy Exp $
+$Id: ProbeCommitProtocol.java,v 1.11 2005/12/23 11:53:38 rouvoy Exp $
 
==============================================================================*/
 package org.objectweb.gotm.lib.coordination;
 
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.objectweb.gotm.lib.factory.Configurable;
 import org.objectweb.gotm.lib.probe.ProbeAbstract;
 import org.objectweb.gotm.lib.state.Status;
 
 /**
  * @author <a href="mailto:Romain.Rouvoy@xxxxxxx";>Romain Rouvoy</a>
- * @version $Revision: 1.10 $
+ * @version $Revision: 1.11 $
  */
 public class ProbeCommitProtocol
         extends ProbeAbstract {
     /** <code>WINDOW</code> size of the window of visibility. */
     public static final int WINDOW = 20;
 
+    /**
+     * @fractal.ac value="20"
+     */
+    protected int window = WINDOW ;
+    
     private static final String[] conf2pcpc = {
             "org.objectweb.gotm.lib.protocol.coordinator.Fc2PCPC",
             "org.objectweb.gotm.lib.protocol.participant.Fc2PCPC" };
 
     private static final String[] conf2pcpa = {
             "org.objectweb.gotm.lib.protocol.coordinator.Fc2PCPA",
-
             "org.objectweb.gotm.lib.protocol.participant.Fc2PCPA", };
 
     /**
@@ -54,51 +53,43 @@
         super(new String[] { Status.COMMIT_ACK, Status.ABORT_ACK });
     }
 
-    private int count(List l, String e) {
+    private final int count(String[] l, String e) {
         int count = 0;
-        int stop = 0;
-        for (Iterator i = l.iterator(); i.hasNext();) {
-            if (i.next().equals(e)) count++;
-            if (++stop >= WINDOW) break;
+        for (int i=0;i<window;i++) {
+            if (l[i].equals(e)) 
+                count++;
         }
         return count;
     }
+    
+    /**
+     * @param conf
+     */
+    private final void use (String[] conf) {
+        this.configurable.setAttribute("gotm-protocol", conf[0]);
+        this.configurable.setAttribute("gotm-2pc-participant", conf[1]);
+    }
 
     /*
      * (non-Javadoc)
      * @see 
org.objectweb.gotm.lib.probe.ProbeAbstract#configure(java.util.LinkedList,
      *      org.objectweb.gotm.lib.current.Configurable)
      */
-    protected void configure(LinkedList topics, Configurable component) {
-        if (topics.size() < WINDOW) {
-            System.out.println("[T=" + topics.size()
-                    + "]==> No adaptatation during warm up!");
+    protected void configure(String[] topics) {
+        if (topics.length < window) {
+            System.out.println("[T=" + topics.length + "]==> No adaptatation 
during warm up!");
             return;
         }
-        int commit = count(topics, Status.COMMITTED);
-        int abort = count(topics, Status.ABORTED);
+        int commit = count(topics, Status.COMMIT_ACK);
+        int abort = count(topics, Status.ABORT_ACK);
         int dec = (100 * commit) / (commit + abort);
-        if (dec <= 55
-                && !this.configurable.getAttribute("gotm-protocol").equals(
-                        conf2pcpa[0])) {
-            System.out.println("[T=" + topics.size()
-                    + "]==> Switching to the 2PCPA commit protocol (commit="
-                    + dec + "%<=55%[" + (commit) + "|" + (commit + abort)
-                    + "])...");
-            component.setAttribute("gotm-protocol", conf2pcpa[0]);
-            component.setAttribute("gotm-2pc-participant", conf2pcpa[1]);
-        } else if (dec > 55
-                && !this.configurable.getAttribute("gotm-protocol").equals(
-                        conf2pcpc[0])) {
-            System.out.println("[T=" + topics.size()
-                    + "]==> Switching to the 2PCPC commit protocol (commit="
-                    + dec + "%>=55%[" + (commit) + "|" + (commit + abort)
-                    + "])...");
-            component.setAttribute("gotm-protocol", conf2pcpc[0]);
-            component.setAttribute("gotm-2pc-participant", conf2pcpc[1]);
+        if (dec<=55 && 
!this.configurable.getAttribute("gotm-protocol").equals(conf2pcpa[0])) {
+            System.out.println("[T=" + topics.length + "]==> Switching to 
the 2PCPA protocol (commit=" + dec + "%<=55%[" + (commit) + "|" + (commit + 
abort) + "])");
+            use(conf2pcpa);
+        } else if (dec>55 && 
!this.configurable.getAttribute("gotm-protocol").equals(conf2pcpc[0])) {
+            System.out.println("[T=" + topics.length + "]==> Switching to 
the 2PCPC protocol (commit=" + dec + "%>=55%[" + (commit) + "|" + (commit + 
abort) + "])");
+            use(conf2pcpc);
         } else
-            System.out.println("[T=" + topics.size()
-                    + "]==> No adaptation is required (commit=" + dec + "%["
-                    + (commit) + "|" + (commit + abort) + "])");
+            System.out.println("[T=" + topics.length + "]==> No adaptation 
is required (commit=" + dec + "%[" + (commit) + "|" + (commit + abort) + 
"])");
     }
 }
Index: 
gotm/src/java/org/objectweb/gotm/lib/factory/TransactionFactoryAdaptive.java
diff -u 
gotm/src/java/org/objectweb/gotm/lib/factory/TransactionFactoryAdaptive.java:1.4
 
gotm/src/java/org/objectweb/gotm/lib/factory/TransactionFactoryAdaptive.java:1.5
--- 
gotm/src/java/org/objectweb/gotm/lib/factory/TransactionFactoryAdaptive.java:1.4
    Fri Dec 16 17:03:22 2005
+++ 
gotm/src/java/org/objectweb/gotm/lib/factory/TransactionFactoryAdaptive.java  
      Fri Dec 23 12:53:38 2005
@@ -17,7 +17,7 @@
 Initial developer(s): Romain Rouvoy (romain.rouvoy@xxxxxxx)
 Contributor(s): .
 
--------------------------------------------------------------------------------
-$Id: TransactionFactoryAdaptive.java,v 1.4 2005/12/16 16:03:22 rouvoy Exp $
+$Id: TransactionFactoryAdaptive.java,v 1.5 2005/12/23 11:53:38 rouvoy Exp $
 
==============================================================================*/
 package org.objectweb.gotm.lib.factory;
 
@@ -33,7 +33,7 @@
 
 /**
  * @author <a href="mailto:Romain.Rouvoy@xxxxxxx";>Romain Rouvoy</a>
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
  */
 public class TransactionFactoryAdaptive
         extends TransactionFactoryObservable
@@ -58,7 +58,8 @@
         this.pending.clear();
         this.txFactory = (Factory) this.txFactories.get(txConfiguration);
         this.txStack = (Stack) this.txStacks.get(txConfiguration);
-        if (this.txStack == null) this.txStack = new Stack();
+        if (this.txStack == null)
+            this.txStack = new Stack();
     }
 
     /*
Index: 
gotm/src/java/org/objectweb/gotm/lib/factory/TransactionFactoryCache.java
diff -u 
gotm/src/java/org/objectweb/gotm/lib/factory/TransactionFactoryCache.java:1.7 
gotm/src/java/org/objectweb/gotm/lib/factory/TransactionFactoryCache.java:1.8
--- 
gotm/src/java/org/objectweb/gotm/lib/factory/TransactionFactoryCache.java:1.7 
      Fri Dec 16 18:22:55 2005
+++ gotm/src/java/org/objectweb/gotm/lib/factory/TransactionFactoryCache.java 
  Fri Dec 23 12:53:38 2005
@@ -17,7 +17,7 @@
 Initial developer(s): Romain Rouvoy (romain.rouvoy@xxxxxxx)
 Contributor(s): .
 
--------------------------------------------------------------------------------
-$Id: TransactionFactoryCache.java,v 1.7 2005/12/16 17:22:55 rouvoy Exp $
+$Id: TransactionFactoryCache.java,v 1.8 2005/12/23 11:53:38 rouvoy Exp $
 
==============================================================================*/
 package org.objectweb.gotm.lib.factory;
 
@@ -29,11 +29,12 @@
 
 /**
  * @author <a href="mailto:Romain.Rouvoy@xxxxxxx";>Romain Rouvoy</a>
- * @version $Revision: 1.7 $
+ * @version $Revision: 1.8 $
  */
 public class TransactionFactoryCache
         extends TransactionFactoryImpl
         implements CacheController {
+    
     /** <code>txStack</code> list of recyclable transactions. */
     protected transient Stack txStack = new Stack();
 
Index: gotm/src/java/org/objectweb/gotm/lib/message/SubscriberPool.java
diff -u gotm/src/java/org/objectweb/gotm/lib/message/SubscriberPool.java:1.5 
gotm/src/java/org/objectweb/gotm/lib/message/SubscriberPool.java:1.6
--- gotm/src/java/org/objectweb/gotm/lib/message/SubscriberPool.java:1.5      
  Thu Dec 22 17:48:16 2005
+++ gotm/src/java/org/objectweb/gotm/lib/message/SubscriberPool.java    Fri 
Dec 23 12:53:38 2005
@@ -17,7 +17,7 @@
 Initial developer(s): Romain Rouvoy (romain.rouvoy@xxxxxxx)
 Contributor(s): .
 
--------------------------------------------------------------------------------
-$Id: SubscriberPool.java,v 1.5 2005/12/22 16:48:16 rouvoy Exp $
+$Id: SubscriberPool.java,v 1.6 2005/12/23 11:53:38 rouvoy Exp $
 
==============================================================================*/
 package org.objectweb.gotm.lib.message;
 
@@ -32,7 +32,7 @@
 
 /**
  * @author <a href="mailto:Romain.Rouvoy@xxxxxxx";>Romain Rouvoy</a>
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
  */
 public class SubscriberPool
         extends ComponentImpl
@@ -47,12 +47,17 @@
      * @return the list of listeners of topic.
      */
     protected final ArrayList subscribers(final String topic) {
-        ArrayList subscribers = (ArrayList) this.topics.get(topic);
-        if (subscribers != null) 
+        try {
+            ArrayList subscribers = (ArrayList) this.topics.get(topic);
+            if (subscribers != null) 
+                return subscribers;
+            subscribers = new ArrayList();
+            this.topics.put(topic, subscribers);
             return subscribers;
-        subscribers = new ArrayList();
-        this.topics.put(topic, subscribers);
-        return subscribers;
+        } catch (ClassCastException e) {
+            System.err.println("[SubscriberPool] subscribers(...): 
"+e.getMessage());
+            throw e;
+        }
     }
     
     /*
Index: gotm/src/java/org/objectweb/gotm/lib/probe/ProbeAbstract.java
diff -u gotm/src/java/org/objectweb/gotm/lib/probe/ProbeAbstract.java:1.7 
gotm/src/java/org/objectweb/gotm/lib/probe/ProbeAbstract.java:1.8
--- gotm/src/java/org/objectweb/gotm/lib/probe/ProbeAbstract.java:1.7   Tue 
Dec 20 16:43:34 2005
+++ gotm/src/java/org/objectweb/gotm/lib/probe/ProbeAbstract.java       Fri 
Dec 23 12:53:38 2005
@@ -17,7 +17,7 @@
 Initial developer(s): Romain Rouvoy (romain.rouvoy@xxxxxxx)
 Contributor(s): .
 
--------------------------------------------------------------------------------
-$Id: ProbeAbstract.java,v 1.7 2005/12/20 15:43:34 rouvoy Exp $
+$Id: ProbeAbstract.java,v 1.8 2005/12/23 11:53:38 rouvoy Exp $
 
==============================================================================*/
 package org.objectweb.gotm.lib.probe;
 
@@ -30,7 +30,7 @@
 
 /**
  * @author <a href="mailto:Romain.Rouvoy@xxxxxxx";>Romain Rouvoy</a>
- * @version $Revision: 1.7 $
+ * @version $Revision: 1.8 $
  */
 public abstract class ProbeAbstract
         extends ComponentImpl
@@ -41,30 +41,30 @@
     /**
      * @fractal.ac value="5"
      */
-    protected int refresh;
-
-    private final LinkedList occurrences = new LinkedList();
+    protected int refresh = REFRESH;
 
     /**
      * @fractal.bc
      */
     protected Configurable configurable;
 
-    protected final String[] messages;
+    protected final String[] issues;
     
+    private final LinkedList occurrences = new LinkedList();
+
     /**
      * ProbeAbstract object contructor.
      * @param messages
      */
     protected ProbeAbstract(String[] messages) {
-        this.messages = messages;
+        this.issues = messages;
     }
     
     /* (non-Javadoc)
      * @see org.objectweb.transaction.api.message.PublishFeature#messages()
      */
     public String[] messages() {
-        return this.messages;
+        return this.issues;
     }
 
     /* (non-Javadoc)
@@ -74,12 +74,11 @@
     public void notify(String topic, Map context) {
         occurrences.addFirst(topic);
         if (occurrences.size() % refresh == 0)
-            configure(occurrences, this.configurable);
+            configure((String[]) occurrences.toArray(new String[0]));
     }
 
     /**
      * @param topics the list of event observed.
-     * @param component the component to configure.
      */
-    protected abstract void configure(LinkedList topics, Configurable 
component);
+    protected abstract void configure(String[] topics);
 }
\ No newline at end of file



<--  Date Index  --> <--  Thread Index  -->

Reply via email to:

Powered by MHonArc.

Copyright © 2006-2007, OW2 Consortium | contact | webmaster.