Hi,

I'm having problems with replication at startup of a second cache.

Using the code below, I'm starting 2 CacheTest applications (each configured as a 
replicated asyn service), one as a server the other as a client.

1. I start the server first, it adds objects into the cache (under /a/b) ok. After 
these objects have been added, I start the client and query it for objects under /a/b. 
The getChildrenNames() returns null.

2. I start the client first, then start the server, objects are added into both caches 
ok.

The xml config file "META-INF/replAsync-service.xml" is unchanged from the release.

Each CacheTest is started from a separate DOS window under Windows XP with Java 1.4.2 
under the same host (PC).

I'm at a loss for why the client is not being replicated upon its startup (case 1).

Any help is much appreciated.

Many Thanks.



import org.jboss.cache.*;
import org.jboss.cache.aop.TreeCacheAop;
import org.jboss.cache.lock.*;

import java.lang.System.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.Set;

public class CacheTest implements TreeCacheListener
{
        public TreeCacheAop myTree;
        public String myType;
        
        public CacheTest(String theCacheType)
        {
                System.out.println("Start");
                myType = theCacheType;
                
                try
                {
                        myTree = new TreeCacheAop();
                        myTree.addTreeCacheListener(this);
                        PropertyConfigurator config = new PropertyConfigurator(); // 
configure tree cache.
                        config.configure(myTree, "META-INF/replAsync-service.xml");
                        myTree.setClusterName("vtest");
                        
                        long time0 = System.currentTimeMillis();
                        
                        myTree.start();

                        if (theCacheType.compareTo("server") == 0)
                        {
                                createObjects();
                        }
                        
                        long time1 = System.currentTimeMillis();
                        long time = time1 - time0;
                        System.out.println("Start Service took [" + time + "]");

                }
                catch (Exception excep)
                {
                        System.out.println("Exception");
                }
                
                System.out.println("End");

        }
        
        public void cacheStopped(TreeCache theCache)
        {
        }
        
        public void cacheStarted(TreeCache theCache)
        {
                System.out.println("cacheStarted");
        }
        
        public void nodeCreated(Fqn theFqn)
        {
                System.out.println("nodeCreated");
        }
        
        public void nodeVisited(Fqn theFqn)
        {
        }
        
        public void nodeRemoved(Fqn theFqn)
        {
        }
        
        public void nodeEvicted(Fqn theFqn)
        {
        }
        
        public void nodeLoaded(Fqn theFqn)
        {
                System.out.println("nodeLoaded");
        }
        
        public void nodeModified(Fqn theFqn)
        {
        }
        
        public void viewChange(org.jgroups.View new_view)
        {
        }
        
        public void queryCache()
        {
                try
                {
                        // Query for names
                        Set aset = myTree.getChildrenNames("/a/b");
                        if (aset == null)
                        {
                                System.out.println("Cache contents is EMPTY");
                        }
                        else
                        {
                                System.out.println("Cache contents = " + 
aset.toString());
                        }
                }
                catch (LockingException excep)
                {
                        System.out.println("query cache LockingException");
                }
                catch (TimeoutException excep)
                {
                        System.out.println("query cache TimeoutException");
                }

        }
        
        public void stopCache()
        {
                myTree.stop();
        }
        
        public static void main(String args[])
        {
                System.out.println("args=" + args[0]);
                CacheTest ct = new CacheTest(args[0]);
                String line;
                BufferedReader keyInput = new BufferedReader(new 
InputStreamReader(System.in));
                
                System.out.println("Options:");
                System.out.println("1 exit");
                System.out.println("2 ...");
                
                try
                {
                        while ((line = keyInput.readLine()) != null)
                        {
                                
                                if (line.compareTo("1") == 0)
                                {
                                        ct.stopCache();
                                        break;
                                }
                                else if (line.compareTo("3") == 0)
                                {
                                        ct.queryCache();
                                }
                                System.out.println("Options:");
                                System.out.println("1 = exit");
                                System.out.println("2 = start cache");
                                System.out.println("3 = query cache");
                                System.out.print("Enter Option: ");

                        }
                }
                catch (IOException exception)
                {
                }
        }


public void createObjects()
{
.... create an object, "object" ...
        try
        {
                myTree.putObject("/a/b", object);
        }
        catch (Exception excpt)
        {               

        }

}
}

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3847770#3847770

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3847770


-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM. 
Deadline: Sept. 13. Go here: http://sf.net/ppc_contest.php
_______________________________________________
JBoss-Development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to