How do I get the names of all caches in an Oracle Coherence cluster?

I am running an Oracle consistency cluster and using extended clients to connect to the cluster. If there are multiple extended clients that keep the connection and leave the oracle consistency cluster, then there is a possibility that one service created some caches and left the cluster, but those caches are present in the cluster.

I want all cache names to be present in the cluster at any given time.

Is it possible to get all cache names?

There is an API in cacheService

called getCacheNames

that returns all cache names corresponding to this service.

But how to get the names of caches generated by other services owned by clients that are not active, but caches are present in the cluster?

[UPDATE]: - There is a command called "maps" which gives all the caches present on the server (created by all clients). But I cannot find an APi to do the same operation.

Is there any API for executing maps command or any way to execute this command directly using JAVA code.

+3


source to share


1 answer


Better late than never...

here is an example example, needs a little tidying up if you want to use it in production ...



Enumeration serviceNames = CacheFactory.getCluster().getServiceNames();
while(serviceNames.hasMoreElements()){
    String serviceName = (String)serviceNames.nextElement();
    Service service = null;
    try{
        service = CacheFactory.getService(serviceName);
    }catch(Exception e){
        continue;
    }
    if(service instanceof CacheService){
        CacheService cacheService = (CacheService)service;
        Enumeration cacheNames = cacheService.getCacheNames();
        while(cacheNames.hasMoreElements()){
            String cacheName = (String)cacheNames.nextElement();
            System.out.println("<<<" + cacheName);
        }
    }
}

      

+2


source







All Articles