new MBeanNotificationInfo(notificationTypes, Notification.class.getName(), "A GemFire manager, cache, or other member has joined this distributed system."); new MBeanNotificationInfo(notificationTypes, Notification.class.getName(), "A GemFire manager, cache, or other member has left the distributed system."); new MBeanNotificationInfo(notificationTypes, Notification.class.getName(), "A member of this distributed system has crashed instead of leaving cleanly."); new MBeanNotificationInfo(notificationTypes, Notification.class.getName(), "A member of this distributed system has generated an alert."); new MBeanNotificationInfo(notificationTypes, Notification.class.getName(), "A GemFire manager, cache, or other member has joined this distributed system."); new MBeanNotificationInfo(notificationTypes, Notification.class.getName(), "A cache got created on a member of this distributed system."); notificationsInfo[6] = new MBeanNotificationInfo(notificationTypes, Notification.class.getName(), "A cache is closed on a member of this distributed system."); new MBeanNotificationInfo(notificationTypes, Notification.class.getName(), "A region is created in a cache on a member of this distributed system."); new MBeanNotificationInfo(notificationTypes, Notification.class.getName(), "A region was removed from a cache on a member of this distributed system.");
if (notifInfo.length > 0) { for (int i = 0; i < notifInfo.length; i++) { log.info(" ** NAME: \t" + notifInfo[i].getName()); log.info(" DESCR: \t" + notifInfo[i].getDescription()); String notifTypes[] = notifInfo[i].getNotifTypes(); for (int j = 0; j < notifTypes.length; j++) { log.info(" TYPE: \t" + notifTypes[j]);
@Test public void testNotificationMetadata() throws Exception { ModelMBeanInfo info = (ModelMBeanInfo) getMBeanInfo(); MBeanNotificationInfo[] notifications = info.getNotifications(); assertEquals("Incorrect number of notifications", 1, notifications.length); assertEquals("Incorrect notification name", "My Notification", notifications[0].getName()); String[] notifTypes = notifications[0].getNotifTypes(); assertEquals("Incorrect number of notification types", 2, notifTypes.length); assertEquals("Notification type.foo not found", "type.foo", notifTypes[0]); assertEquals("Notification type.bar not found", "type.bar", notifTypes[1]); }
System.out.println("NI: " + ai.getName() + " -- " + ai.getDescription());
@Override protected void accept(final NotificationSupport connector) throws MBeanException { if (connector == null) throw new MBeanException(new NullPointerException("Managed resource doesn't support notifications")); for (final MBeanNotificationInfo notification : connector.getNotificationInfo()) if (ArrayUtils.contains(notification.getNotifTypes(), notificationType)) { metadata = DescriptorUtils.asDictionary(notification.getDescriptor()); return; } }
@Override public int hashCode( final MBeanNotificationInfo o ) { return o.getName().hashCode(); }
@Override public boolean equals( final MBeanNotificationInfo a, final MBeanNotificationInfo b ) { return a == b || a.getName().equals( b.getName() ) && Arrays.equals( a.getNotifTypes(), b.getNotifTypes() ); } }
/** * 暴露通知信息 * * @return */ public MBeanNotificationInfo[] getNotificationInfo() { return new MBeanNotificationInfo[]{ new MBeanNotificationInfo(new String[]{ATTRIBUTE_CHANGE}, "Data Change Notification", "数据改变通知") }; } }
/** {@inheritDoc} */ @Override protected JSONObject extractData(MBeanInfo pMBeanInfo, String pNotification) { JSONObject notMap = new JSONObject(); for (MBeanNotificationInfo notInfo : pMBeanInfo.getNotifications()) { if (pNotification == null || notInfo.getName().equals(pNotification)) { JSONObject map = new JSONObject(); map.put(NAME.getKey(), notInfo.getName()); map.put(DESCRIPTION.getKey(), notInfo.getDescription()); String[] types = notInfo.getNotifTypes(); JSONArray tList = new JSONArray(); for (String type : types) { tList.add(type); } map.put(TYPES.getKey(), tList); } } return notMap; } }
public static MBeanNotificationInfo[] getDefaultNotificationInfo() { String[] types = new String[] {NOTIFY_INIT, NOTIFY_CONNECT, NOTIFY_ABANDON, SLOW_QUERY_NOTIFICATION, FAILED_QUERY_NOTIFICATION, SUSPECT_ABANDONED_NOTIFICATION}; String name = Notification.class.getName(); String description = "A connection pool error condition was met."; MBeanNotificationInfo info = new MBeanNotificationInfo(types, name, description); return new MBeanNotificationInfo[] {info}; }
public String stringify(Object o) { final MBeanNotificationInfo notif = (MBeanNotificationInfo) o; String result = notif.getName() + ":"; final String[] notifTypes = notif.getNotifTypes(); result = result + ArrayStringifier.stringify(notifTypes, mOptions.mArrayDelimiter); if (mOptions.mIncludeDescription) { result = result + ",\"" + notif.getDescription() + "\""; } return (result); }
@Override public MBeanNotificationInfo[] getNotificationInfo() { // XXX: temporary hack MBeanNotificationInfo status = new MBeanNotificationInfo(new String[] { "jmx.attribute.change" }, "status", "status attribute changes"); return new MBeanNotificationInfo[] { status }; }
public String stringify(Object o) { final MBeanNotificationInfo notif = (MBeanNotificationInfo) o; String result = notif.getName() + ":"; final String[] notifTypes = notif.getNotifTypes(); result = result + ArrayStringifier.stringify(notifTypes, mOptions.mArrayDelimiter); if (mOptions.mIncludeDescription) { result = result + ",\"" + notif.getDescription() + "\""; } return (result); }
protected Object createObject() throws SAXException { return new MBeanNotificationInfo(notificationTypes, name, description); } }
private void addNotifications(Map pMBeanMap,MBeanInfo pMBeanInfo) { Map notMap = new HashMap(); for (MBeanNotificationInfo notInfo : pMBeanInfo.getNotifications()) { Map map = new HashMap(); map.put(KEY_NAME,notInfo.getName()); map.put(KEY_DESCRIPTION,notInfo.getDescription()); map.put(KEY_TYPES,notInfo.getNotifTypes()); } if (notMap.size() > 0) { pMBeanMap.put(KEY_NOTIFICATION,notMap); } }
public MBeanNotificationInfo[] getNotificationInfo() { //logger.debug("getNotificationInfo"); String[] notificationTypes = new String[] { USAGE_NOTIFICATION_TYPE }; MBeanNotificationInfo[] mbeanNotificationInfo = new MBeanNotificationInfo[] { new MBeanNotificationInfo( notificationTypes, "UsageNotifications", "Notification of SBB usage") }; return mbeanNotificationInfo; }
public void serialize(QName name, Attributes attributes, Object value, SerializationContext context) throws IOException { MBeanNotificationInfo info = (MBeanNotificationInfo)value; context.startElement(name, attributes); context.serialize(NAME_QNAME, null, info.getName()); context.serialize(DESCRIPTION_QNAME, null, info.getDescription()); context.serialize(NOTIFICATION_TYPES_QNAME, null, info.getNotifTypes()); context.endElement(); }
@Override public MBeanNotificationInfo[] getNotificationInfo() { String[] types = new String[]{ AttributeChangeNotification.ATTRIBUTE_CHANGE }; String name = "notification on faliure"; String description = "An instance has failed"; MBeanNotificationInfo info = new MBeanNotificationInfo(types, name, description); return new MBeanNotificationInfo[]{info}; }
private void displayNotifications(MBeanInfo info) { Session session = getSession(); MBeanNotificationInfo[] notificationInfos = info.getNotifications(); if (notificationInfos.length == 0) { session.output.printMessage("there's no notifications"); return; } int index = 0; session.output.println(TEXT_NOTIFICATIONS); for (MBeanNotificationInfo notification : notificationInfos) { session.output.println(String.format(" %%%-3d - %s(%s)" + (showDescription ? ", %s" : ""), index++, notification.getName(), StringUtils.join(notification.getNotifTypes(), ","), notification.getDescription())); } }
/** * Returns the MBeanNotificationInfo from this class. * * @return the type of the field or {@code null} if it wasn't found */ public MBeanNotificationInfo getNotificationInfo() { String[] notificationTypes = new String[1]; notificationTypes[0] = m_field; MBeanNotificationInfo mbni = new MBeanNotificationInfo( notificationTypes, m_name, m_description); return mbni; } }