Author: manik.surtani(a)jboss.com
Date: 2008-04-29 19:52:14 -0400 (Tue, 29 Apr 2008)
New Revision: 5764
Modified:
core/trunk/src/main/etc/META-INF/total-replication-cache-service.xml
core/trunk/src/main/release/build.xml
core/trunk/src/test/java/org/jboss/cache/demo/JBossCacheGUI.java
core/trunk/src/test/java/org/jboss/cache/demo/JBossCacheView.java
Log:
Fixed GUI tutorial
Modified: core/trunk/src/main/etc/META-INF/total-replication-cache-service.xml
===================================================================
--- core/trunk/src/main/etc/META-INF/total-replication-cache-service.xml 2008-04-29
23:46:22 UTC (rev 5763)
+++ core/trunk/src/main/etc/META-INF/total-replication-cache-service.xml 2008-04-29
23:52:14 UTC (rev 5764)
@@ -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,7 +122,13 @@
</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
state (ie. the contents of the cache) are retrieved from
Modified: core/trunk/src/main/release/build.xml
===================================================================
--- core/trunk/src/main/release/build.xml 2008-04-29 23:46:22 UTC (rev 5763)
+++ core/trunk/src/main/release/build.xml 2008-04-29 23:52:14 UTC (rev 5764)
@@ -18,9 +18,11 @@
<!-- 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 +121,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 +148,8 @@
<jvmarg value="${jvm.ipv4}"/>
<jvmarg value="${jvm.localhost}"/>
<arg value="-console"/>
+ <arg value="-config"/>
+ <arg value="${demo.cfg.file}"/>
</java>
</target>
Modified: core/trunk/src/test/java/org/jboss/cache/demo/JBossCacheGUI.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/demo/JBossCacheGUI.java 2008-04-29 23:46:22
UTC (rev 5763)
+++ core/trunk/src/test/java/org/jboss/cache/demo/JBossCacheGUI.java 2008-04-29 23:52:14
UTC (rev 5764)
@@ -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)
{
@@ -569,7 +572,7 @@
/**
* Recursively adds GUI nodes starting from fqn
*/
- private void addGuiNode(Fqn fqn)
+ private void addGuiNode(Fqn<String> fqn)
{
Set<Object> children;
@@ -584,7 +587,7 @@
{
for (Object child_name : children)
{
- addGuiNode(Fqn.fromRelativeElements(fqn, child_name));
+ addGuiNode(new Fqn<String>(fqn, (String) child_name));
}
}
}
@@ -595,7 +598,7 @@
Fqn<String> fqnToPath;
if (path.length == 0) fqnToPath = Fqn.ROOT;
List<String> elements = convertMyNodeArrayToStringArray(path);
- fqnToPath = Fqn.fromList(elements);
+ fqnToPath = new Fqn<String>(elements);
if (root.hasChild(fqnToPath))
{
return root.getChild(fqnToPath);
@@ -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" +
CachePrinter.printCacheLockingInfo(cache));
+ 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/trunk/src/test/java/org/jboss/cache/demo/JBossCacheView.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/demo/JBossCacheView.java 2008-04-29 23:46:22
UTC (rev 5763)
+++ core/trunk/src/test/java/org/jboss/cache/demo/JBossCacheView.java 2008-04-29 23:52:14
UTC (rev 5764)
@@ -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();
}
}