public void handleNotification(Notification notification, Object handback) { cat.debug("Received notification: "+notification.getType()); registerAppenderMBean((Appender) notification.getUserData() ); }
@Override public void handleNotification(Notification notification, Object handback) { try { GcTracker tracker = (GcTracker) handback; CompositeData cdata = (CompositeData) notification.getUserData(); CompositeData gcInfo = (CompositeData) cdata.get("gcInfo"); tracker.processGcEvent(gcInfo); } catch (JMException e) { // ignore } catch (IOException e) { // ignore } } }
private static Map buildOperationNotificationPacket(Notification note) { Map<String, Object> result = new HashMap<String, Object>(); result.put("event", note.getType()); result.put("source", note.getSource()); result.put("sequenceNumber", note.getSequenceNumber()); result.put("timeStamp", note.getTimeStamp()); result.put("data", note.getUserData()); return result; } }
String notifType = notif.getType(); if (notifType.equals(MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED)) { CompositeData cd = (CompositeData) notif.getUserData(); final MemoryNotificationInfo info = MemoryNotificationInfo.from(cd); String name = info.getPoolName();
public static void handleNotification(SystemMemberJmx member, Notification notification, Object hb) { if (RefreshNotificationType.SYSTEM_MEMBER_CONFIG.getType().equals(notification.getType()) && ((ManagedResource) member).getMBeanName().equals(notification.getUserData())) {
&& getMBeanName().equals(notification.getUserData()) && !adminDSJmx.isRmiClientCountZero()) { try {
@Override public void handleNotification(javax.management.Notification notification, Object handback) { if (GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION.equals(notification.getType())) { final GcInfo gcInfo = GarbageCollectionNotificationInfo.from((CompositeData) notification.getUserData()).getGcInfo(); final Duration duration = Duration.milliseconds(gcInfo.getDuration()); if (duration.compareTo(gcWarningThreshold) > 0) { LOG.warn("Last GC run with {} took longer than {} (last duration={})", gc.getName(), gcWarningThreshold, duration); final Notification systemNotification = notificationService.buildNow() .addNode(nodeId.toString()) .addTimestamp(Tools.nowUTC()) .addSeverity(Notification.Severity.URGENT) .addType(Notification.Type.GC_TOO_LONG) .addDetail("gc_name", gc.getName()) .addDetail("gc_duration_ms", duration.toMilliseconds()) .addDetail("gc_threshold_ms", gcWarningThreshold.toMilliseconds()) .addDetail("gc_collection_count", gc.getCollectionCount()) .addDetail("gc_collection_time", gc.getCollectionTime()); if (!notificationService.publishIfFirst(systemNotification)) { LOG.debug("Couldn't publish notification: {}", notification); } } } } };
public void handleNotification(Notification notification, Object handback) { cat.debug("Received notification: "+notification.getType()); registerAppenderMBean((Appender) notification.getUserData() ); }
@Override public synchronized void handleNotification(Notification notification, Object handback) { GarbageCollectionNotificationInfo info = GarbageCollectionNotificationInfo.from((CompositeData) notification.getUserData()); GcInfo gcInfo = info.getGcInfo(); Map<String, MemoryUsage> memoryUsageBeforeGc = gcInfo.getMemoryUsageBeforeGc(); Map<String, MemoryUsage> memoryUsageAfterGc = gcInfo.getMemoryUsageAfterGc(); for (Map.Entry<String, MemoryUsage> entry : memoryUsageBeforeGc.entrySet()) { String memoryPool = entry.getKey(); long before = entry.getValue().getUsed(); long after = memoryUsageAfterGc.get(memoryPool).getUsed(); handleMemoryPool(memoryPool, before, after); } }
private static void addMemoryWatchDog(final Reporter r) { final NotificationListener listener = (notification, handback) -> { final String type = notification.getType(); if (type.equals(MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED)) { final CompositeData cd = (CompositeData) notification.getUserData(); final MemoryNotificationInfo memInfo = MemoryNotificationInfo .from(cd); CommandLineMessage.report(memInfo.getPoolName() + " has exceeded the shutdown threshold : " + memInfo.getCount() + " times.\n" + memInfo.getUsage()); r.done(ExitCode.OUT_OF_MEMORY); } else { LOG.warning("Unknown notification: " + notification); } }; MemoryWatchdog.addWatchDogToAllPools(90, listener); }
@Test //INT-2275 public void publishStringMessageWithinChain() throws Exception { assertNotNull( this.beanFactory.getBean( "chainWithJmxNotificationPublishing$child." + "jmx-notification-publishing-channel-adapter-within-chain.handler", MessageHandler.class)); assertNull(listener.lastNotification); Message<?> message = MessageBuilder.withPayload("XYZ") .setHeader(JmxHeaders.NOTIFICATION_TYPE, "test.type").build(); publishingWithinChainChannel.send(message); assertNotNull(listener.lastNotification); Notification notification = listener.lastNotification; assertEquals("XYZ", notification.getMessage()); assertEquals("test.type", notification.getType()); assertNull(notification.getUserData()); Set<ObjectName> names = server .queryNames(new ObjectName("*:type=MessageHandler," + "name=\"chainWithJmxNotificationPublishing$child." + "jmx-notification-publishing-channel-adapter-within-chain\",*"), null); assertEquals(1, names.size()); names = server .queryNames(new ObjectName("*:type=MessageChannel," + "name=org.springframework.integration.test.anon,source=anonymous,*"), null); assertEquals(1, names.size()); }
@Test public void publishUserData() throws Exception { assertNull(listener.lastNotification); TestData data = new TestData(); Message<?> message = MessageBuilder.withPayload(data) .setHeader(JmxHeaders.NOTIFICATION_TYPE, "test.type").build(); channel.send(message); assertNotNull(listener.lastNotification); Notification notification = listener.lastNotification; assertNull(notification.getMessage()); assertEquals(data, notification.getUserData()); assertEquals("test.type", notification.getType()); }
@Test public void publishStringMessage() throws Exception { adviceCalled = 0; assertNull(listener.lastNotification); Message<?> message = MessageBuilder.withPayload("XYZ") .setHeader(JmxHeaders.NOTIFICATION_TYPE, "test.type").build(); channel.send(message); assertNotNull(listener.lastNotification); Notification notification = listener.lastNotification; assertEquals("XYZ", notification.getMessage()); assertEquals("test.type", notification.getType()); assertNull(notification.getUserData()); assertEquals(1, adviceCalled); }
@Override public void handleNotification(Notification notification, Object ref) { final String type = notification.getType(); if (type.equals(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION)) { CompositeData cd = (CompositeData) notification.getUserData(); GarbageCollectionNotificationInfo info = GarbageCollectionNotificationInfo.from(cd); processGcEvent(info); } } }
public void handleNotification(Notification notification, Object handback) { cat.debug("Received notification: "+notification.getType()); registerAppenderMBean((Appender) notification.getUserData() ); }
@Override public void handleNotification(Notification notification, Object ref) { final String type = notification.getType(); if (type.equals(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION)) { CompositeData cd = (CompositeData) notification.getUserData(); GarbageCollectionNotificationInfo info = GarbageCollectionNotificationInfo.from(cd); processGcEvent(info); } } }
private static Map buildOperationNotificationPacket(Notification note) { Map<String, Object> result = new HashMap<String, Object>(); result.put("event", note.getType()); result.put("source", note.getSource()); result.put("sequenceNumber", note.getSequenceNumber()); result.put("timeStamp", note.getTimeStamp()); result.put("data", note.getUserData()); return result; } }
public void handleNotification(Notification notification, Object handback) { cat.debug("Received notification: "+notification.getType()); registerAppenderMBean((Appender) notification.getUserData() ); }
public void handleNotification(Notification notification, Object handback) { cat.debug("Received notification: "+notification.getType()); registerAppenderMBean((Appender) notification.getUserData() ); }
protected void onSerialize(SerializationContext context, Notification notification) throws IOException { context.serialize(CLASS_NAME_QNAME, null, notification.getType()); context.serialize(SOURCE_QNAME, null, notification.getSource()); context.serialize(SEQUENCE_NUMBER_QNAME, null, new Long(notification.getSequenceNumber())); context.serialize(TIMESTAMP_QNAME, null, new Long(notification.getTimeStamp())); context.serialize(MESSAGE_QNAME, null, notification.getMessage()); context.serialize(USER_DATA_QNAME, null, notification.getUserData()); }