List of usage examples for javax.management Notification Notification
public Notification(String type, Object source, long sequenceNumber, long timeStamp)
From source file:no.uis.service.ws.studinfosolr.impl.StudinfoSolrServiceImpl.java
private void sendNotification(long seqNo, Throwable error, Object... args) { if (this.jmxPublisher == null) { return;// w ww.j a v a 2 s .c om } StringBuilder sb = new StringBuilder(); for (Object arg : args) { if (sb.length() > 0) { sb.append(", "); } sb.append(arg); } final String msg = sb.toString(); Notification notification = new Notification("SolrUpdate", this, seqNo, msg); if (error != null) { notification.setUserData(errorToString(error)); LOG.error(msg, error); } else { LOG.info(msg); } this.jmxPublisher.sendNotification(notification); }
From source file:org.helios.netty.jmx.MetricCollector.java
/** * Executes the collection// ww w.j a v a 2 s .c o m * {@inheritDoc} * @see java.lang.Runnable#run() */ public void run() { try { updateMetricNames(); long channelCount = SharedChannelGroup.getInstance().size(); //log.info("\n\tChanne,l Count:" + channelCount); submitMetric("netty.channels.count", channelCount); Notification notif = new Notification(MetricProvider.METRIC_NOTIFICATION, OBJECT_NAME, tick.incrementAndGet(), System.currentTimeMillis()); final JSONObject json = new JSONObject(); final JSONObject envelope = new JSONObject(); envelope.put("metrics", json); notif.setUserData(json); pushRemoteMetrics(json); json.put("ts", System.currentTimeMillis()); json.put("heap", processMemoryUsage(memMxBean.getHeapMemoryUsage())); json.put("non-heap", processMemoryUsage(memMxBean.getNonHeapMemoryUsage())); json.put("thread-states*", new JSONObject(getThreadStates())); if (haveNioMXBean) { json.put("direct-nio", new JSONObject(getNio())); } sendNotification(notif); SharedChannelGroup.getInstance().write(envelope); } catch (Exception e) { e.printStackTrace(System.err); } finally { scheduler.schedule(this, period, TimeUnit.MILLISECONDS); } }
From source file:org.helios.netty.jmx.MetricCollector.java
/** * Collects metric names from participating metric providers * @throws JSONException thrown on any json exception *//*ww w .j a v a 2 s. co m*/ protected void updateMetricNames() throws JSONException { Notification notif = new Notification(MetricProvider.METRIC_NAME_NOTIFICATION, OBJECT_NAME, tick.incrementAndGet(), System.currentTimeMillis()); final Set<String> names = new HashSet<String>(); final Set<String> newNames = new HashSet<String>(); notif.setUserData(names); sendNotification(notif); for (String s : names) { if (metricNames.add(s)) { newNames.add(s); } } if (!newNames.isEmpty()) { JSONObject envelope = new JSONObject(); envelope.put("metric-names", new JSONArray(newNames)); SharedChannelGroup.getInstance().write(envelope); } }
From source file:org.apache.geode.admin.jmx.internal.CacheServerJmxImpl.java
/** * Implementation handles client membership changes. * //ww w . j ava2 s .co m * @param clientId id of the client for whom membership change happened * @param eventType membership change type; one of {@link ClientMembershipMessage#JOINED}, * {@link ClientMembershipMessage#LEFT}, {@link ClientMembershipMessage#CRASHED} */ public void handleClientMembership(String clientId, int eventType) { String notifType = null; List<ManagedResource> cleanedUp = null; if (eventType == ClientMembershipMessage.LEFT) { notifType = NOTIF_CLIENT_LEFT; cleanedUp = cleanupBridgeClientResources(clientId); } else if (eventType == ClientMembershipMessage.CRASHED) { notifType = NOTIF_CLIENT_CRASHED; cleanedUp = cleanupBridgeClientResources(clientId); } else if (eventType == ClientMembershipMessage.JOINED) { notifType = NOTIF_CLIENT_JOINED; } if (cleanedUp != null) { for (ManagedResource resource : cleanedUp) { MBeanUtil.unregisterMBean(resource); } } Helper.sendNotification(this, new Notification(notifType, this.modelMBean, Helper.getNextNotificationSequenceNumber(), clientId)); }
From source file:org.apache.geode.admin.jmx.internal.CacheServerJmxImpl.java
/** * Implementation handles creation of cache by extracting the details from the given event object * and sending the {@link SystemMemberJmx#NOTIF_CACHE_CREATED} notification to the connected JMX * Clients./*from ww w.j a v a 2s . com*/ * * @param event event object corresponding to the creation of the cache */ public void handleCacheCreate(SystemMemberCacheEvent event) { Helper.sendNotification(this, new Notification(NOTIF_CACHE_CREATED, this.modelMBean, Helper.getNextNotificationSequenceNumber(), Helper.getCacheEventDetails(event))); }
From source file:org.apache.geode.admin.jmx.internal.CacheServerJmxImpl.java
/** * Implementation handles closure of cache by extracting the details from the given event object * and sending the {@link SystemMemberJmx#NOTIF_CACHE_CLOSED} notification to the connected JMX * Clients./*from w w w. ja va 2 s .c o m*/ * * @param event event object corresponding to the closure of the cache */ public void handleCacheClose(SystemMemberCacheEvent event) { Helper.sendNotification(this, new Notification(NOTIF_CACHE_CLOSED, this.modelMBean, Helper.getNextNotificationSequenceNumber(), Helper.getCacheEventDetails(event))); }
From source file:org.apache.geode.admin.jmx.internal.CacheServerJmxImpl.java
/** * Implementation handles creation of region by extracting the details from the given event object * and sending the {@link SystemMemberJmx#NOTIF_REGION_CREATED} notification to the connected JMX * Clients. Region Path is set as User Data in Notification. * /*from www .java 2s. c om*/ * @param event event object corresponding to the creation of a region */ public void handleRegionCreate(SystemMemberRegionEvent event) { Notification notification = new Notification(NOTIF_REGION_CREATED, this.modelMBean, Helper.getNextNotificationSequenceNumber(), Helper.getRegionEventDetails(event)); notification.setUserData(event.getRegionPath()); Helper.sendNotification(this, notification); }
From source file:org.apache.geode.admin.jmx.internal.CacheServerJmxImpl.java
/** * Implementation should handle loss of region by extracting the details from the given event * object and sending the {@link SystemMemberJmx#NOTIF_REGION_LOST} notification to the connected * JMX Clients. Region Path is set as User Data in Notification. Additionally, it also clears the * ManagedResources created for the region that is lost. * /*from w ww .j a v a 2 s. c o m*/ * @param event event object corresponding to the loss of a region */ public void handleRegionLoss(SystemMemberRegionEvent event) { SystemMemberCacheJmxImpl cacheResource = this.managedSystemMemberCache; if (cacheResource != null) { ManagedResource cleanedUp = cacheResource.cleanupRegionResources(event.getRegionPath()); if (cleanedUp != null) { MBeanUtil.unregisterMBean(cleanedUp); } } Notification notification = new Notification(NOTIF_REGION_LOST, this.modelMBean, Helper.getNextNotificationSequenceNumber(), Helper.getRegionEventDetails(event)); notification.setUserData(event.getRegionPath()); Helper.sendNotification(this, notification); }
From source file:com.cyberway.issue.crawler.admin.CrawlJob.java
public void crawlStarted(String message) { if (this.mbeanName != null) { // Can be null around job startup. sendNotification(/*from w w w . j a v a2 s . c o m*/ new Notification("crawlStarted", this.mbeanName, getNotificationsSequenceNumber(), message)); } }
From source file:com.cyberway.issue.crawler.admin.CrawlJob.java
public void crawlEnding(String sExitMessage) { setRunning(false);/*from ww w . ja va2 s .com*/ setStatus(sExitMessage); setReadOnly(); if (this.mbeanName != null) { sendNotification(new Notification("crawlEnding", this.mbeanName, getNotificationsSequenceNumber(), sExitMessage)); } }