2 Replies Latest reply on Jan 31, 2012 6:04 PM by Dan Berindei

    How to get the primary cache adress of one key value in 5.1.0.final?

    zhang ni Newbie

      Hi all,

      The code is as following.

      When I enforce these codes, the aa always is null, and can not get the value of aa.primaryLocation("key");

      Is there are any configuration I should do?

       

       

      new DefaultCacheManager(

                      GlobalConfigurationBuilder.defaultClusteredBuilder()

                            .transport().addProperty("configurationFile", "jgroups.xml")

                            .build(),  

                  new ConfigurationBuilder()

                        .clustering()

                           .cacheMode(CacheMode.DIST_SYNC)

                           .hash().numOwners(2)

                        .build()

            );

       

      HashConfiguration bb = cache.getCacheConfiguration().clustering().hash();
      System.out.print("bb\n");
      if(bb!=null)
      {
      System.out.print("bb no null\n");
         
          ConsistentHash aa = bb.consistentHash();
          System.out.print("aa\n");
          if(aa!=null)
          {
          System.out.print("aa no null\n");
          Address cc = aa.primaryLocation("key");
          String str =cc.toString();
              System.out.print(str);
          }
      }