private static boolean regionExists(Cache cache, String regionPath) { boolean regionFound = false; if (regionPath != null && !Region.SEPARATOR.equals(regionPath)) { ManagementService managementService = ManagementService.getExistingManagementService(cache); DistributedSystemMXBean dsMBean = managementService.getDistributedSystemMXBean(); String[] allRegionPaths = dsMBean.listAllRegionPaths(); for (int i = 0; i < allRegionPaths.length; i++) { if (allRegionPaths[i].equals(regionPath)) { regionFound = true; break; } } } return regionFound; }
private static boolean regionExists(Cache cache, String regionPath) { boolean regionFound = false; if (regionPath != null && !Region.SEPARATOR.equals(regionPath)) { ManagementService managementService = ManagementService.getExistingManagementService(cache); DistributedSystemMXBean dsMBean = managementService.getDistributedSystemMXBean(); String[] allRegionPaths = dsMBean.listAllRegionPaths(); for (int i = 0; i < allRegionPaths.length; i++) { if (allRegionPaths[i].equals(regionPath)) { regionFound = true; break; } } } return regionFound; }
private boolean diskStoreExists(Cache cache, String diskStoreName) { ManagementService managementService = ManagementService.getExistingManagementService(cache); DistributedSystemMXBean dsMXBean = managementService.getDistributedSystemMXBean(); Map<String, String[]> diskstore = dsMXBean.listMemberDiskstore(); Set<Entry<String, String[]>> entrySet = diskstore.entrySet(); for (Entry<String, String[]> entry : entrySet) { String[] value = entry.getValue(); if (CliUtil.contains(value, diskStoreName)) { return true; } } return false; }
private boolean diskStoreExists(Cache cache, String diskStoreName) { ManagementService managementService = ManagementService.getExistingManagementService(cache); DistributedSystemMXBean dsMXBean = managementService.getDistributedSystemMXBean(); Map<String, String[]> diskstore = dsMXBean.listMemberDiskstore(); Set<Entry<String, String[]>> entrySet = diskstore.entrySet(); for (Entry<String, String[]> entry : entrySet) { String[] value = entry.getValue(); if (CliUtil.contains(value, diskStoreName)) { return true; } } return false; }
private boolean diskStoreExists(String diskStoreName) { Cache cache = getCache(); ManagementService managementService = ManagementService.getExistingManagementService(cache); DistributedSystemMXBean dsMXBean = managementService.getDistributedSystemMXBean(); Map<String, String[]> diskstore = dsMXBean.listMemberDiskstore(); Set<Entry<String, String[]>> entrySet = diskstore.entrySet(); for (Entry<String, String[]> entry : entrySet) { String[] value = entry.getValue(); if (CliUtil.contains(value, diskStoreName)) { return true; } } return false; }
private boolean diskStoreExists(String diskStoreName) { Cache cache = getCache(); ManagementService managementService = ManagementService.getExistingManagementService(cache); DistributedSystemMXBean dsMXBean = managementService.getDistributedSystemMXBean(); Map<String, String[]> diskstore = dsMXBean.listMemberDiskstore(); Set<Entry<String, String[]>> entrySet = diskstore.entrySet(); for (Entry<String, String[]> entry : entrySet) { String[] value = entry.getValue(); if (CliUtil.contains(value, diskStoreName)) { return true; } } return false; }
public boolean existsInCluster(Cache cache) { boolean existsInCluster = false; if (cache != null) { ManagementService managementService = ManagementService.getExistingManagementService(cache); if (managementService.isManager()) { existsInCluster = managementService != null && managementService.getDistributedRegionMXBean(regionPath) != null; } else { throw new ManagementException("Not a cache from Manager member."); } } return existsInCluster; }
public boolean existsInCluster(Cache cache) { boolean existsInCluster = false; if (cache != null) { ManagementService managementService = ManagementService.getExistingManagementService(cache); if (managementService.isManager()) { existsInCluster = managementService != null && managementService.getDistributedRegionMXBean(regionPath) != null; } else { throw new ManagementException("Not a cache from Manager member."); } } return existsInCluster; }
@Override public void run() { Random random = new Random(System.nanoTime()); int randomInteger = random.nextInt(10); String query = "query --query=\"select ID , status , createTime , pk, floatMinValue from " + DATA_PAR_REGION_NAME_PATH + " where ID <= " + randomInteger + "\" --interactive=false"; ManagementService service = ManagementService.getExistingManagementService(getCache()); MemberMXBean member = service.getMemberMXBean(); String cmdResult = member.processCommand(query); assertNotNull(cmdResult); Log.getLogWriter().info("Text Command Output : " + cmdResult); } });
public void run() { Cache cache = GemFireCacheImpl.getInstance(); assertNotNull(cache); ManagementService service = ManagementService .getExistingManagementService(cache); assertNotNull(service); assertTrue(service.isManager()); LocatorMXBean bean = service.getLocalLocatorMXBean(); assertEquals(locatorPort, bean.getPort()); DistributedSystemMXBean dsBean = service.getDistributedSystemMXBean(); ObjectName[] names = dsBean.listMemberObjectNames(); assertEquals(2,dsBean.listMemberObjectNames().length); } });
/** * Start the default management service using the provided Cache. * * @param cache * Cache to use when creating the management service */ private void verifyManagementServiceStarted(Cache cache) { assert(cache != null); this.managementService = ManagementService.getExistingManagementService(cache); assertNotNull(this.managementService); assertTrue(this.managementService.isManager()); assertTrue(ManagementUtil.checkIfCommandsAreLoadedOrNot()); }
public static void logManagerStatus() { Cache theCache = CacheHelper.getCache(); if (theCache == null) { Log.getLogWriter().info("Cache does not exist in this jvm so cannot log manager status"); } else { ManagementService service = ManagementService.getExistingManagementService(theCache); StringBuffer aStr = new StringBuffer(); aStr.append("manager status\n"); aStr.append("isManager: " + service.isManager() + "\n"); Log.getLogWriter().info(aStr.toString()); if (service.isManager()) { Object value = JMXManagerBlackboard.getInstance().getSharedMap().get(RemoteTestModule.getMyVmid()); if (value != null) { Log.getLogWriter().info("This member is a manager and the jmx endpoint is " + value); } } } }
/** Verify the set of local region MBeans in this member. * */ private static void verifyLocalRegionMBeans() { ManagementService service = ManagementService.getExistingManagementService(CacheHelper.getCache()); Log.getLogWriter().info("Verifying presence of local region MBeans in this member, isManager: " + service.isManager()); if (service.isManager()) { verifyLocalRegionMBeans_manager(); } else { verifyLocalRegionMBeans_nonManager(); } }
public Object call() throws Exception { GemFireCacheImpl cache = GemFireCacheImpl.getInstance(); ManagementService service = ManagementService .getExistingManagementService(cache); assertNotNull(service); LocatorMXBean bean = service.getLocalLocatorMXBean(); assertNotNull(bean); assertEquals(locPort, bean.getPort()); getLogWriter().info("Log of Locator" + bean.viewLog()); getLogWriter().info("BindAddress" + bean.getBindAddress()); assertEquals(isPeer, bean.isPeerLocator()); return null; } });
/** * Adds an off-heap notification listener to the MemberMXBean. */ protected void addOffHeapNotificationListener() { ManagementService service = ManagementService.getExistingManagementService(getCache()); assertNotNull(service); assertTrue(service.isManager()); MemberMXBean memberBean = service.getMemberMXBean(); assertNotNull(memberBean); assertTrue(memberBean instanceof MemberMBean); ((MemberMBean) memberBean).addNotificationListener(notificationListener, null, null); }
public void run() { Cache cache = GemFireCacheImpl.getInstance(); assertNotNull(cache); SystemManagementService service = (SystemManagementService)ManagementService .getExistingManagementService(cache); assertNotNull(service); assertFalse(service.isManager()); assertNotNull(service.getMemberMXBean()); service.getLocalManager().runManagementTaskAdhoc(); } });
public Object call() throws Exception { GemFireCacheImpl cache = GemFireCacheImpl.getInstance(); ManagementService service = ManagementService .getExistingManagementService(cache); assertNotNull(service); LocatorMXBean bean = MBeanUtil.getLocatorMbeanProxy(member); assertNotNull(bean); getLogWriter().info("Log of Locator" + bean.viewLog()); getLogWriter().info("BindAddress" + bean.getBindAddress()); return null; } });
/** * Asserts that the off heap region data is available and enabled. */ protected void assertOffHeapRegionAttributes() { ManagementService service = ManagementService.getExistingManagementService(getCache()); assertNotNull(service); assertTrue(service.isManager()); RegionMXBean regionBean = service.getLocalRegionMBean(OFF_HEAP_REGION_PATH); assertNotNull(regionBean); RegionAttributesData regionData = regionBean.listRegionAttributes(); assertNotNull(regionData); assertTrue(regionData.getEnableOffHeapMemory()); }
public void testIssue51048() throws InterruptedException { SystemManagementService service = (SystemManagementService) ManagementService.getExistingManagementService(cache); DistributedSystemMXBean dsmbean = service.getDistributedSystemMXBean(); CachePerfStats cachePerfStats = ((GemFireCacheImpl) cache).getCachePerfStats(); for (int i = 1; i <= 10; i++) { cachePerfStats.incCreates(); } sample(); service.getLocalManager().runManagementTaskAdhoc(); assertTrue(dsmbean.getAverageWrites() == 10); sample(); service.getLocalManager().runManagementTaskAdhoc(); assertTrue(dsmbean.getAverageWrites() == 0); }
/** * Asserts that OffHeapMetrics match input parameters. * @param freeMemory total off-heap free memory in bytes. * @param allocatedMemory allocated (or used) off-heap memory in bytes. * @param objects number of objects stored in off-heap memory. * @param fragmentation the fragmentation percentage. */ protected void assertOffHeapMetrics(long freeMemory,long allocatedMemory,long objects, int fragmentation) { ManagementService service = ManagementService.getExistingManagementService(getCache()); assertNotNull(service); assertTrue(service.isManager()); MemberMXBean memberBean = service.getMemberMXBean(); assertNotNull(memberBean); assertEquals(freeMemory,memberBean.getOffHeapFreeMemory()); assertEquals(allocatedMemory,memberBean.getOffHeapUsedMemory()); assertEquals(objects,memberBean.getOffHeapObjects()); assertEquals(fragmentation,memberBean.getOffHeapFragmentation()); }