Coherence Explorer

时间:2014-12-05 10:50:02

标签: caching cluster-computing oracle-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();
}

1 个答案:

答案 0 :(得分:0)

你总是可以从CacheFactory.getCluster()开始工作" down"从那里......