protected boolean isAllowedToRegister(ObjectName name) { boolean result = true; if (suppressMBean != null && suppressMBeanList != null) { for (ObjectName attr : suppressMBeanList) { if (attr.apply(name)) { result = false; break; } } } return result; }
public ObjectName[] listGatewaySenderObjectNames(String member) throws Exception { validateMember(member); DistributedMember distributedMember = CliUtil.getDistributedMemberByNameOrId(member, cache); List<ObjectName> listName = null; ObjectName pattern = new ObjectName(ManagementConstants.GATEWAY_SENDER_PATTERN); Set<ObjectName> mbeanSet = service.queryMBeanNames(distributedMember); if (mbeanSet != null && mbeanSet.size() > 0) { listName = new ArrayList<>(); for (ObjectName name : mbeanSet) { if (pattern.apply(name)) { listName.add(name); } } } if (listName != null && listName.size() > 0) { ObjectName[] array = new ObjectName[listName.size()]; return listName.toArray(array); } return ManagementConstants.NO_DATA_OBJECTNAME; }
continue; if (aggregatemMBeanPattern.apply(objectName)) { continue;
/** * Whether the key matches the given MBean name * * @param pKey to match * @return true if the given mbean matches the Mbean encapsulated by this key */ public boolean matches(HistoryKey pKey) { return mBean.apply(pKey.mBean); }
@Override public boolean apply(ObjectName name) { return pattern.apply(name); }
/** * Given a MBean name return a pattern previously added and which matches this MBean name. Note, * that patterns might not overlap since the order in which they are tried is undefined. * * @param pName name to match against * @return the pattern found or <code>null</code> if none has been found. */ ObjectName findMatchingMBeanPattern(ObjectName pName) { // Check all stored patterns for a match and return the pattern if one is found for (ObjectName pattern : patterns) { if (pattern.apply(pName)) { return pattern; } } return null; } }
protected boolean isAllowedToRegister(ObjectName name) { boolean result = true; if (suppressMBean != null && suppressMBeanList != null) { for (ObjectName attr : suppressMBeanList) { if (attr.apply(name)) { result = false; break; } } } return result; }
protected boolean isAllowedToRegister(ObjectName name) { boolean result = true; if (suppressMBean != null && suppressMBeanList != null) { for (ObjectName attr : suppressMBeanList) { if (attr.apply(name)) { result = false; break; } } } return result; }
/** * Whether the key matches the given MBean name * * @param pKey to match * @return true if the given mbean matches the Mbean encapsulated by this key */ public boolean matches(HistoryKey pKey) { return mBean.apply(pKey.mBean); }
/** * Whether the key matches the given MBean name * * @param pKey to match * @return true if the given mbean matches the Mbean encapsulated by this key */ public boolean matches(HistoryKey pKey) { return mBean.apply(pKey.mBean); }
/** * Determines whether a name matches a pattern * * @param pattern the pattern to match (null to match anything) * @param target the target object name * @return does the target match the pattern? */ public static boolean match(ObjectName pattern, ObjectName target) { return pattern == null || pattern.apply(target); }
protected boolean isAllowedToRegister(ObjectName name) { boolean result = true; if (suppressMBean != null && suppressMBeanList != null) { for (ObjectName attr : suppressMBeanList) { if (attr.apply(name)) { result = false; break; } } } return result; }
/** * Whether the key matches the given MBean name * * @param pKey to match * @return true if the given mbean matches the Mbean encapsulated by this key */ public boolean matches(HistoryKey pKey) { return mBean.apply(pKey.mBean); }
private static void patternMatch(ObjectName target, String pattern) throws MalformedObjectNameException { ObjectName matcher = new ObjectName(pattern); System.out.printf("ObjectName[%s] matches pattern[%s] : %s\n", target, pattern, matcher.apply(target)); } }
@Override public synchronized boolean isNotificationEnabled(Notification notif) { if (notif instanceof MBeanServerNotification) { MBeanServerNotification mbsn = (MBeanServerNotification) notif; return pattern.apply(mbsn.getMBeanName()); } return false; } }
@Test public void notMatchingObjectName() { when(descriptor.ismBeanAttributeIsReadable()).thenReturn(true); when(descriptor.getmBeanObjectName()).thenReturn("java.lang:type=Memory"); when(assignment.getObjectName()).thenReturn(objectName); when(objectName.apply(Matchers.<ObjectName> any())).thenReturn(false); boolean matches = filter.matches(assignment, descriptor); assertThat(matches, is(false)); }
@Test public void matchingSpecificAttribute() { String attributeName = "attribute"; when(descriptor.ismBeanAttributeIsReadable()).thenReturn(true); when(descriptor.getmBeanObjectName()).thenReturn("java.lang:type=Memory"); when(descriptor.getAttributeName()).thenReturn(attributeName); when(assignment.getObjectName()).thenReturn(objectName); when(assignment.getAttributes()).thenReturn(Collections.singleton(attributeName)); when(objectName.apply(Matchers.<ObjectName> any())).thenReturn(true); boolean matches = filter.matches(assignment, descriptor); assertThat(matches, is(true)); }
@Test public void notMatchingAttribute() { when(descriptor.ismBeanAttributeIsReadable()).thenReturn(true); when(descriptor.getmBeanObjectName()).thenReturn("java.lang:type=Memory"); when(descriptor.getAttributeName()).thenReturn("attribute"); when(assignment.getAttributes()).thenReturn(Collections.singleton("not matching")); when(assignment.getObjectName()).thenReturn(objectName); when(objectName.apply(Matchers.<ObjectName> any())).thenReturn(true); boolean matches = filter.matches(assignment, descriptor); assertThat(matches, is(false)); } }
@Test public void matchingAllAttributes() { when(descriptor.ismBeanAttributeIsReadable()).thenReturn(true); when(descriptor.getmBeanObjectName()).thenReturn("java.lang:type=Memory"); when(descriptor.getAttributeName()).thenReturn("attribute"); when(assignment.getObjectName()).thenReturn(objectName); when(assignment.getAttributes()).thenReturn(Collections.<String> emptySet()); when(objectName.apply(Matchers.<ObjectName> any())).thenReturn(true); boolean matches = filter.matches(assignment, descriptor); assertThat(matches, is(true)); }
private List<Measurement> measure(Registry registry, List<JmxConfig> configs, JmxData data) { List<Measurement> ms = new ArrayList<>(); for (JmxConfig cfg : configs) { if (cfg.getQuery().apply(data.getName())) { for (JmxMeasurementConfig c : cfg.getMeasurements()) { c.measure(registry, data, ms); } } } return ms; }