MicroStrategy ONE

Obtaining the First 10 Caches

The sample code below illustrates how to obtain the top ten caches, as ranked by their hit count, for all the projects in MicroStrategy Intelligence Server.

 // create a WebObjectsFactory instance

 WebObjectsFactory factory = WebObjectsFactory.getInstance();

 

 // Get the cache source object

 CacheSource source = (CacheSource) factory.getMonitorSource(EnumWebMonitorType.WebMonitorTypeCache);

 

 // Add a sort criterion that we will sort the cache by its hit count in descending order

 MonitorSort msort = source.getSortCriteria();

 msort.add(EnumDSSXMLCacheInfo.DssXmlCacheInfoHitCount, EnumDSSXMLOrder.DssXmlDescending);

 

 // Set the incremental fetch settings, starting from the first cache and block count to be 10

 source.setBlockBegin(1);

 source.setBlockCount(10);

 

 try {

      // Sends the request to Intelligence Server to retrieve cache information

      CacheResults results = source.getCaches();

      // Loop through the results to print out information of caches

      for (int j = 0; j < results.size(); j++) {

           // Caches are group on project level, so get the cache collection for each project

           Caches result = results.get(j);

 

           System.out.print("Project \"" + result.getProjectName());

           System.out.println("\t\" has cache count:" + result.getCount());

 

          // Print out each cache information, such as cache ID, hit count, etc.

           for (int i = 0; i < result.getCount(); i++) {

                Cache cache = result.get(i);

                System.out.println("\t\tCache id: " + cache.getID() + ", cache hit count: " + cache.getHitCount());

           }

 

           System.out.println();

      }

 catch (WebObjectsAdminException woae) {

         woae.printStackTrace();

 }

Because there is no project filter, the cache information for all projects in Intelligence Server is returned by default.