@Test public void testIsValid() throws MalformedObjectNameException { ObjectName o = new ObjectName("domain", "key", "value"); Set<String> mapNames = ImmutableSet.of("foo"); HazelcastMapMetricsReporter hazelcastMapMetricsReporter = new HazelcastMapMetricsReporter(); boolean isValid = hazelcastMapMetricsReporter.isValid(o, mapNames, "cluster"); assertFalse(isValid); String c = "foo"; o = new ObjectName("com.hazelcast", "key", "value"); isValid = hazelcastMapMetricsReporter.isValid(o, mapNames, c); assertFalse(isValid); o = new ObjectName("com.hazelcast", "name", "foo"); isValid = hazelcastMapMetricsReporter.isValid(o, mapNames, c); assertFalse(isValid); Hashtable<String, String> keys = new Hashtable<>(); keys.put("name", "foo"); keys.put("type", "IMap"); o = new ObjectName("com.hazelcast", keys); isValid = hazelcastMapMetricsReporter.isValid(o, mapNames, c); assertFalse(isValid); keys = new Hashtable<>(); keys.put("name", "foo"); keys.put("type", "IMap"); keys.put("instance", "foo"); o = new ObjectName("com.hazelcast", keys); isValid = hazelcastMapMetricsReporter.isValid(o, mapNames, c); assertTrue(isValid); }
boolean isValid(ObjectName name, Set<String> mapNames, String clusterName) { if (!"com.hazelcast".equals(name.getDomain())) { return false; } String propertyName = name.getKeyProperty("name"); if (!mapNames.isEmpty() && !mapNames.contains(propertyName)) { return false; } String typeProperty = name.getKeyProperty("type"); if (StringUtils.isBlank(typeProperty) || !"IMap".equals(name.getKeyProperty("type"))) { return false; } String instanceProperty = name.getKeyProperty("instance"); if (StringUtils.isBlank(instanceProperty) || !instanceProperty.contains(clusterName)) { return false; } return true; }
HazelcastMapMetricsReporter extends AbstractReportingTask { boolean isValid(ObjectName name, Set<String> mapNames, String clusterName) { if (!"com.hazelcast".equals(name.getDomain())) { return false; } String propertyName = name.getKeyProperty("name"); if (!mapNames.isEmpty() && !mapNames.contains(propertyName)) { return false; } String typeProperty = name.getKeyProperty("type"); if (StringUtils.isBlank(typeProperty) || !"IMap".equals(name.getKeyProperty("type"))) { return false; } String instanceProperty = name.getKeyProperty("instance"); if (StringUtils.isBlank(instanceProperty) || !instanceProperty.contains(clusterName)) { return false; } return true; } }
HazelcastMapMetricsReporter extends AbstractReportingTask { boolean isValid(ObjectName name, Set<String> mapNames, String clusterName) { if (!"com.hazelcast".equals(name.getDomain())) { return false; } String propertyName = name.getKeyProperty("name"); if (!mapNames.isEmpty() && !mapNames.contains(propertyName)) { return false; } String typeProperty = name.getKeyProperty("type"); if (StringUtils.isBlank(typeProperty) || !"IMap".equals(name.getKeyProperty("type"))) { return false; } String instanceProperty = name.getKeyProperty("instance"); if (StringUtils.isBlank(instanceProperty) || !instanceProperty.contains(clusterName)) { return false; } return true; }  }
HazelcastMapMetricsReporter extends AbstractReportingTask { boolean isValid(ObjectName name, Set<String> mapNames, String clusterName) { if (!"com.hazelcast".equals(name.getDomain())) { return false; } String propertyName = name.getKeyProperty("name"); if (!mapNames.isEmpty() && !mapNames.contains(propertyName)) { return false; } String typeProperty = name.getKeyProperty("type"); if (StringUtils.isBlank(typeProperty) || !"IMap".equals(name.getKeyProperty("type"))) { return false; } String instanceProperty = name.getKeyProperty("instance"); if (StringUtils.isBlank(instanceProperty) || !instanceProperty.contains(clusterName)) { return false; } return true; }  @OnScheduled void startup(ConfigurationContext context); @Override void onTrigger(ReportingContext context); @Override final List<PropertyDescriptor> getSupportedPropertyDescriptors(); }
HazelcastMapMetricsReporter extends AbstractReportingTask { boolean isValid(ObjectName name, Set<String> mapNames, String clusterName) { if (!"com.hazelcast".equals(name.getDomain())) { return false; } String propertyName = name.getKeyProperty("name"); if (!mapNames.isEmpty() && !mapNames.contains(propertyName)) { return false; } String typeProperty = name.getKeyProperty("type"); if (StringUtils.isBlank(typeProperty) || !"IMap".equals(name.getKeyProperty("type"))) { return false; } String instanceProperty = name.getKeyProperty("instance"); if (StringUtils.isBlank(instanceProperty) || !instanceProperty.contains(clusterName)) { return false; } return true; }  @OnScheduled void startup(ConfigurationContext context); @Override void onTrigger(ReportingContext context); @Override final List<PropertyDescriptor> getSupportedPropertyDescriptors();  }