2014-12-05 188 views
0

我打算爲我們的項目編寫一個一致性資源管理器。有幾個緩存,分佈式和複製式。第一部分試圖獲取所有緩存的細節,取得了一些進展。Coherence資源管理器

一個瓶頸是以編程方式探索集羣,成員和高速緩存,起點是命名高速緩存。如果我沒有命名緩存,則無法識別所有緩存,成員和羣集詳細信息。 同樣在給定的時間點,其分佈式或複製。

有人可以告訴我如何進一步進行。 下面的代碼快照

// Get hold of the cache 
    NamedCache cache = CacheFactory.getCache("ias.connection.segment"); 

    // Fetch the reference of Cache Service   
    CacheService cacheService = cache.getCacheService(); 

    // Get the cluster from the service 
    Cluster theCluster = cacheService.getCluster(); 

    // Print the name of this cluster 
    String theClusterName = theCluster.getClusterName(); 
    System.out.println("\n Cluster Name : "+ theClusterName); 
    System.out.println("-------------------------------------"); 

    int countOne = 0; 
    // Iterate through the services running in this cluster 
    for (Enumeration enumService = theCluster.getServiceNames() ; enumService.hasMoreElements();) 
    { 
     countOne = countOne+1; 
     // Get Service Name 
     String serviceName = (String) enumService.nextElement(); 

     // Extract the Service Info Object from this service 
     ServiceInfo info = theCluster.getServiceInfo(serviceName); 


     //Emit out the service Name & its type 

     System.out.println(countOne+ " Service Name : [ "+serviceName + " ]"+" Service Type : [ "+ info.getServiceType() +" ]"); 
     System.out.println("--------------------------------------------");   
    } 


    // Try to extract cache names from the service 
    System.out.println("\nHere's the List of Caches \n"); 
    String cacheName ; 
    ServiceInfo serviceInformation; 
    CacheService service; 
    int count = 0; 

    for (Enumeration enums = cacheService.getCacheNames() ; enums.hasMoreElements();) 
    { 

     cacheName = (String) enums.nextElement(); 

     count=count+1; 

     cache = CacheFactory.getCache(cacheName); 

     service = cache.getCacheService(); 

     serviceInformation= service.getInfo(); 
     System.out.println(count +" Cache : ["+cacheName+" ]"+ " Service Type : [ "+ serviceInformation.getServiceType()+" ] \n"); 


    } 

    ServiceInfo theServiceInfo = cacheService.getInfo(); 

    int countThree = 0; 

    Set clusterMemebers = theCluster.getMemberSet(); 

    Iterator iter = clusterMemebers.iterator(); 

    while (iter.hasNext()) { 
     countThree = countThree +1; 
     Member theMember =(Member) iter.next(); 

     System.out.println(countThree+ " Member Details : [ "+ theMember+" ]"); 
    } 


    CacheFactory.shutdown(); 
} 

回答

0

你總是可以開始CacheFactory.getCluster()而努力「下」從那裏......

+0

謝謝你的提示,這就是我一直在尋找。 – user3526364 2015-08-27 12:36:50