[jbosscache-commits] JBoss Cache SVN: r5763 - in core/branches/2.1.X/src: main/release and 1 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Tue Apr 29 19:46:22 EDT 2008


Author: manik.surtani at jboss.com
Date: 2008-04-29 19:46:22 -0400 (Tue, 29 Apr 2008)
New Revision: 5763

Modified:
   core/branches/2.1.X/src/main/etc/META-INF/total-replication-cache-service.xml
   core/branches/2.1.X/src/main/release/build.xml
   core/branches/2.1.X/src/test/java/org/jboss/cache/demo/JBossCacheGUI.java
   core/branches/2.1.X/src/test/java/org/jboss/cache/demo/JBossCacheView.java
Log:
Fixed tutorial GUI

Modified: core/branches/2.1.X/src/main/etc/META-INF/total-replication-cache-service.xml
===================================================================
--- core/branches/2.1.X/src/main/etc/META-INF/total-replication-cache-service.xml	2008-04-29 23:27:26 UTC (rev 5762)
+++ core/branches/2.1.X/src/main/etc/META-INF/total-replication-cache-service.xml	2008-04-29 23:46:22 UTC (rev 5763)
@@ -101,15 +101,15 @@
                  oob_thread_pool.queue_max_size="10"
                  oob_thread_pool.rejection_policy="Run"/>
 
-            <PING timeout="2000" num_initial_members="3"/>
+            <PING timeout="2000" num_initial_members="2"/>
             <MERGE2 max_interval="30000" min_interval="10000"/>
             <FD_SOCK/>
             <FD timeout="10000" max_tries="5" shun="true"/>
             <VERIFY_SUSPECT timeout="1500"/>
             <pbcast.NAKACK
-                    use_mcast_xmit="false" gc_lag="0"
-                    retransmit_timeout="300,600,1200,2400,4800"
-                    discard_delivered_msgs="true"/>
+                  use_mcast_xmit="false" gc_lag="0"
+                  retransmit_timeout="300,600,1200,2400,4800"
+                  discard_delivered_msgs="true"/>
             <UNICAST timeout="300,600,1200,2400,3600"/>
             <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
                            max_bytes="400000"/>
@@ -122,6 +122,11 @@
          </config>
       </attribute>
 
+      <!--
+       Whether or not to fetch state on joining a cluster
+       NOTE this used to be called FetchStateOnStartup and has been renamed to be more descriptive.
+      -->
+      <attribute name="FetchInMemoryState">true</attribute>
 
       <!--
           The max amount of time (in milliseconds) we wait until the

Modified: core/branches/2.1.X/src/main/release/build.xml
===================================================================
--- core/branches/2.1.X/src/main/release/build.xml	2008-04-29 23:27:26 UTC (rev 5762)
+++ core/branches/2.1.X/src/main/release/build.xml	2008-04-29 23:46:22 UTC (rev 5763)
@@ -18,8 +18,9 @@
    <!-- JVM args for when running tests -->
    <property name="jvm.ipv4" value="-Djava.net.preferIPv4Stack=true"/>
    <property name="jvm.localhost" value="-Dbind.address=127.0.0.1"/>
-   <property name="jvm.ms" value="-Xms128M" />
-   <property name="jvm.mx" value="-Xms1024M" />
+   <property name="jvm.ms" value="-Xms128M"/>
+   <property name="jvm.mx" value="-Xms1024M"/>
+   <property name="demo.cfg.file" value="META-INF/total-replication-cache-service.xml"/>
 
    <!-- Test if JDK5 is available -->
    <available classname="java.lang.Enum" property="HAVE_JDK_1.5"/>
@@ -119,8 +120,8 @@
          <classfileset dir="${build}" includes="${test}.class"/>
          <jvmarg value="${jvm.ipv4}"/>
          <jvmarg value="${jvm.localhost}"/>
-         <jvmarg value="${jvm.ms}" />
-         <jvmarg value="${jvm.mx}" />
+         <jvmarg value="${jvm.ms}"/>
+         <jvmarg value="${jvm.mx}"/>
       </testng>
    </target>
 
@@ -146,6 +147,8 @@
          <jvmarg value="${jvm.ipv4}"/>
          <jvmarg value="${jvm.localhost}"/>
          <arg value="-console"/>
+         <arg value="-config"/>
+         <arg value="${demo.cfg.file}"/>
       </java>
    </target>
 

Modified: core/branches/2.1.X/src/test/java/org/jboss/cache/demo/JBossCacheGUI.java
===================================================================
--- core/branches/2.1.X/src/test/java/org/jboss/cache/demo/JBossCacheGUI.java	2008-04-29 23:27:26 UTC (rev 5762)
+++ core/branches/2.1.X/src/test/java/org/jboss/cache/demo/JBossCacheGUI.java	2008-04-29 23:46:22 UTC (rev 5763)
@@ -12,7 +12,6 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.Cache;
-import org.jboss.cache.CacheImpl;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.Node;
 import org.jboss.cache.lock.TimeoutException;
@@ -26,6 +25,7 @@
 import org.jboss.cache.notifications.event.NodeEvent;
 import org.jboss.cache.notifications.event.NodeModifiedEvent;
 import org.jboss.cache.notifications.event.ViewChangedEvent;
+import org.jboss.cache.util.CachePrinter;
 import org.jgroups.Address;
 
 import javax.swing.*;
@@ -92,6 +92,7 @@
    private List<Address> membership = new LinkedList<Address>();
    private Address coordinator = null;
    private boolean useConsole = false;
+   JConsole bshConsole;
 
    /**
     * Run any work that happens in this interface in a separate thread.  This is good practise. Unless there's a
@@ -148,7 +149,7 @@
       {
          String welcomeMessage = getWelcomeMessage();
 
-         JConsole bshConsole = new JConsole();
+         bshConsole = new JConsole();
          Interpreter interpreter = new Interpreter(bshConsole);
 
          configureInterpreter(interpreter, cacheDelegate);
@@ -230,6 +231,8 @@
       setCacheModelDelegate(cacheDelegate);
       init();
       setVisible(true);
+      tree_model.setRoot(myNodeRoot);
+      tree_model.reload();
 
       if (useConsole)
       {
@@ -685,7 +688,7 @@
       JBossCacheGUI.AddModifyDataForNodeAction addModAction = new JBossCacheGUI.AddModifyDataForNodeAction();
       addModAction.putValue(AbstractAction.NAME, "Add/Modify data");
       JBossCacheGUI.PrintLockInfoAction print_locks = new JBossCacheGUI.PrintLockInfoAction();
-      print_locks.putValue(AbstractAction.NAME, "Print lock information (stdout)");
+      print_locks.putValue(AbstractAction.NAME, "Print lock information" + (useConsole ? "" : " (stdout)"));
       JBossCacheGUI.ExitAction exitAction = new JBossCacheGUI.ExitAction();
       exitAction.putValue(AbstractAction.NAME, "Exit");
       JBossCacheGUI.StartTransaction start_tx = new JBossCacheGUI.StartTransaction();
@@ -1064,7 +1067,27 @@
 
       public void actionPerformed(ActionEvent e)
       {
-         System.out.println("\n*** lock information ****\n" + ((CacheImpl) cache).printLockInfo());
+         if (bshConsole != null)
+         {
+            new Thread()
+            {
+               public void run()
+               {
+                  bshConsole.getOut().println("\n*** lock information ****\n" + CachePrinter.printCacheLockingInfo(cache));
+               }
+            }.start();
+
+         }
+         else
+         {
+            new Thread()
+            {
+               public void run()
+               {
+                  System.out.println("\n*** lock information ****\n" + CachePrinter.printCacheLockingInfo(cache));
+               }
+            }.start();
+         }
       }
    }
 
@@ -1095,6 +1118,7 @@
          {
             log.trace("node added/modified, updating GUI: " + e);
          }
+         if (selected_node == null) return;
 
          clearTable();
          Map<String, String> data = selected_node.getData();

Modified: core/branches/2.1.X/src/test/java/org/jboss/cache/demo/JBossCacheView.java
===================================================================
--- core/branches/2.1.X/src/test/java/org/jboss/cache/demo/JBossCacheView.java	2008-04-29 23:27:26 UTC (rev 5762)
+++ core/branches/2.1.X/src/test/java/org/jboss/cache/demo/JBossCacheView.java	2008-04-29 23:46:22 UTC (rev 5763)
@@ -46,7 +46,7 @@
    /**
     * Cache configuration file.
     */
-   private String configurationFile = "META-INF/replSync-service.xml";
+   private String configurationFile = null;
 
    /**
     * The cache model.
@@ -84,10 +84,15 @@
    {
       parseParameters(args);
 
+      if (configurationFile == null)
+      {
+         help();
+         throw new Exception("Configuration file cannot be null, please specify with the -config parameter when starting!");
+      }
+
       CacheModelDelegate cacheModelDelegate = createCacheDelegate();
-      startCacheModelDelegate(cacheModelDelegate);
+      cacheModelDelegate.getGenericCache().start();
       setCacheModelDelegate(cacheModelDelegate);
-
       start();
    }
 
@@ -102,7 +107,7 @@
       {
          log.info("start(): creating the GUI");
          System.out.println("start(): creating the GUI");
-         gui = createCacheGUI(cacheModelDelegate, useConsole);
+         gui = new JBossCacheGUI(cacheModelDelegate, useConsole);
       }
    }
 
@@ -171,47 +176,23 @@
    {
       CacheFactory<String, String> factory = new DefaultCacheFactory();
       Cache<String, String> cache = factory.createCache(configurationFile, false);
-      // hack to prevent a state transfer for now
-      cache.getConfiguration().setFetchInMemoryState(false);
-
       CacheModelDelegate delegate = new JBossCacheModelDelegate();
       delegate.setCacheShellVariable(cache);
 
       return delegate;
    }
 
-   /**
-    * Factory method that creates a cache GUI instance
-    *
-    * @param cacheDelegate cache model instance
-    * @param useConsole    whether to enable the embedded beanshell console
-    * @return instance of cache GUI
-    * @throws Exception
-    */
-   protected JBossCacheGUI createCacheGUI(CacheModelDelegate cacheDelegate, boolean useConsole) throws Exception
-   {
-      return new JBossCacheGUI(cacheDelegate, useConsole);
-   }
-
-   /**
-    * Starts the cache model
-    *
-    * @param cacheModelDelegate cache model instance to start
-    */
-   private void startCacheModelDelegate(CacheModelDelegate cacheModelDelegate)
-   {
-      cacheModelDelegate.getGenericCache().start();
-   }
-
    private static void help()
    {
       System.out.println("JBossCacheView [-help] " +
             "[-console] " +
-            "[-config <path to configuration file to use>] ");
+            "[-config <path to configuration file to use>]");
 
       System.out.println();
       System.out.println("-console enables the embedded BeanShell console");
       System.out.println("-config allows you to provide a path to the configuration file to use.");
+      System.out.println();
+      System.out.println();
    }
 }
 




More information about the jbosscache-commits mailing list