Tabnine Logo
Notification.getType
Code IndexAdd Tabnine to your IDE (free)

How to use
getType
method
in
javax.management.Notification

Best Java code snippets using javax.management.Notification.getType (Showing top 20 results out of 1,359)

origin: apache/geode

 /**
  * Invoked before sending the specified notification to the listener. Returns whether the given
  * notification is to be sent to the listener.
  *
  * @param notification The notification to be sent.
  * @return true if the notification has to be sent to the listener, false otherwise.
  */
 @Override
 public boolean isNotificationEnabled(Notification notification) {
  boolean isThisNotificationEnabled = false;
  if (notification.getType().equals(JMXConnectionNotification.OPENED)
    || notification.getType().equals(JMXConnectionNotification.CLOSED)
    || notification.getType().equals(JMXConnectionNotification.FAILED)) {
   isThisNotificationEnabled = true;
  }
  return isThisNotificationEnabled;
 }
}
origin: log4j/log4j

public
void handleNotification(Notification notification, Object handback) {
 cat.debug("Received notification: "+notification.getType());
 registerAppenderMBean((Appender) notification.getUserData() );
}
origin: apache/hive

public void start() {
 // unsupported if null
 if (tenuredGenPool == null) {
  return;
 }
 MemoryMXBean mxBean = ManagementFactory.getMemoryMXBean();
 NotificationEmitter emitter = (NotificationEmitter) mxBean;
 notificationListener = (n, hb) -> {
  if (n.getType().equals(
   MemoryNotificationInfo.MEMORY_COLLECTION_THRESHOLD_EXCEEDED)) {
   long maxMemory = tenuredGenPool.getUsage().getMax();
   long usedMemory = tenuredGenPool.getUsage().getUsed();
   for (Listener listener : listeners) {
    listener.memoryUsageAboveThreshold(usedMemory, maxMemory);
   }
  }
 };
 emitter.addNotificationListener(notificationListener, null, null);
}
origin: groovy/groovy-core

  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;
  }
}
origin: h2oai/h2o-2

 /**
  * Callback routine called by JVM after full gc run. Has two functions:
  * 1) sets the amount of memory to be cleaned from the cache by the Cleaner
  * 2) sets the CAN_ALLOC flag to false if memory level is critical
  *
  * The callback happens in a system thread, and hence not through the usual
  * water.Boot loader - and so any touched classes are in the wrong class
  * loader and you end up with new classes with uninitialized global vars.
  * Limit to touching global vars in the Boot class.
  */
 public void handleNotification(Notification notification, Object handback) {
  String notifType = notification.getType();
  if( notifType.equals(MemoryNotificationInfo.MEMORY_COLLECTION_THRESHOLD_EXCEEDED)) {
   // Memory used after this FullGC
   Boot.TIME_AT_LAST_GC = System.currentTimeMillis();
   Boot.HEAP_USED_AT_LAST_GC = _allMemBean.getHeapMemoryUsage().getUsed();
   MEM_LOW_CRITICAL = Boot.HEAP_USED_AT_LAST_GC > (MEM_MAX - (MEM_MAX >> 2));
   if(Boot.HEAP_USED_AT_LAST_GC > (MEM_MAX - (MEM_MAX >> 1))) { // emergency measure - really low on memory, stop allocations right now!
    setMemLow();
   } else // enable new allocations (even if cleaner is still running, we have enough RAM)
    setMemGood();
   Boot.kick_store_cleaner();
  }
 }
}
origin: apache/geode

 /**
  * Sends the given notification.
  *
  * @param notif notification to send
  *
  * @throws NullPointerException if resource or ModelMBean for resource is null
  */
 /* default */static void sendNotification(ManagedResource resource, Notification notif) {
  try {
   if (MBeanUtil.isRegistered(resource.getObjectName())) {
    resource.getModelMBean().sendNotification(notif);
    if (logger.isDebugEnabled()) {
     logger.debug("Sent '{}' notification", notif.getType());
    }
   }
  } catch (RuntimeOperationsException e) {
   logger
     .info(String.format("Failed to send %s notification for %s",
       new Object[] {"'" + notif.getType() + "'", "'" + notif.getMessage() + "'"}),
       e);
  } catch (MBeanException e) {
   logger
     .info(String.format("Failed to send %s notification for %s",
       new Object[] {"'" + notif.getType() + "'", "'" + notif.getMessage() + "'"}),
       e);
  }
 }
}
origin: apache/geode

public void handleNotification(Notification notification, Object handback) {
 Object notifSource = notification.getSource();
 if (AdminDistributedSystemJmxImpl.NOTIF_MEMBER_JOINED.equals(notification.getType())) {
  ObjectName source = (ObjectName) notifSource;
 notification = new Notification(notification.getType(), notifSource,
   notificationSequenceNumber.addAndGet(1L), notification.getTimeStamp(),
   notification.getMessage());
origin: btraceio/btrace

boolean entered = BTraceRuntime.enter(BTraceRuntime.this);
try {
  String notifType = notif.getType();
  if (notifType.equals(MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED)) {
    CompositeData cd = (CompositeData) notif.getUserData();
origin: apache/geode

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())) {
origin: apache/geode

if (typeStatResourceStats.equals(notification.getType())
  && getMBeanName().equals(notification.getUserData())
  && !adminDSJmx.isRmiClientCountZero()) {
origin: Graylog2/graylog2-server

  @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);
        }
      }
    }
  }
};
origin: cloudfoundry/uaa

@Test
public void happy_path() throws Exception {
  filter.setPerRequestMetrics(true);
  String path = performTwoSimpleRequests();
  Map<String, String> summary = filter.getSummary();
  assertNotNull(summary);
  assertFalse(summary.isEmpty());
  assertEquals(2, summary.size());
  for (String uri : Arrays.asList(path, MetricsUtil.GLOBAL_GROUP)) {
    MetricsQueue totals = readValue(summary.get(filter.getUriGroup(request).getGroup()), MetricsQueue.class);
    assertNotNull("URI:"+uri, totals);
    for (StatusCodeGroup status : Arrays.asList(StatusCodeGroup.SUCCESS, StatusCodeGroup.SERVER_ERROR)) {
      RequestMetricSummary total = totals.getDetailed().get(status);
      assertEquals("URI:"+uri, 1, total.getCount());
    }
  }
  assertNull(MetricsAccessor.getCurrent());
  ArgumentCaptor<Notification> argumentCaptor = ArgumentCaptor.forClass(Notification.class);
  verify(publisher, times(2)).sendNotification(argumentCaptor.capture());
  List<Notification> capturedArg = argumentCaptor.getAllValues();
  assertEquals(2, capturedArg.size());
  assertEquals("/api" , capturedArg.get(0).getType());
}
origin: cloudfoundry/uaa

@Test
public void intolerable_request() throws Exception {
  TimeService slowRequestTimeService = new TimeService() {
    long now = System.currentTimeMillis();
    @Override
    public long getCurrentTimeMillis() {
      now += 5000;
      return now;
    }
  };
  for (TimeService timeService : Arrays.asList(slowRequestTimeService, new TimeServiceImpl())) {
    reset(publisher);
    filter = new UaaMetricsFilter();
    filter.setPerRequestMetrics(true);
    filter.setTimeService(timeService);
    filter.setNotificationPublisher(publisher);
    String path = "/authenticate/test";
    setRequestData(path);
    filter.getUriGroup(request).setLimit(1000);
    filter.doFilterInternal(request, response, chain);
    MetricsQueue metricsQueue = filter.getMetricsQueue(filter.getUriGroup(request).getGroup());
    RequestMetricSummary totals = metricsQueue.getTotals();
    assertEquals(1, totals.getCount());
    assertEquals(timeService == slowRequestTimeService ? 1 : 0, totals.getIntolerableCount());
    ArgumentCaptor<Notification> argumentCaptor = ArgumentCaptor.forClass(Notification.class);
    verify(publisher).sendNotification(argumentCaptor.capture());
    Notification capturedArg = argumentCaptor.getValue();
    assertEquals("/api" , capturedArg.getType());
  }
}
origin: apache/log4j

public
void handleNotification(Notification notification, Object handback) {
 cat.debug("Received notification: "+notification.getType());
 registerAppenderMBean((Appender) notification.getUserData() );
}
origin: hcoles/pitest

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);
}
origin: spring-projects/spring-integration

@Test
public void testPublish() {
  publishChannel.send(new GenericMessage<String>("bar"));
  Message<?> message = publishInChannel.receive(100000);
  assertNotNull(message);
  assertTrue(message.getPayload() instanceof Notification);
  Notification notification = (Notification) message.getPayload();
  assertEquals("bar", notification.getMessage());
  assertEquals("foo", notification.getType());
}
origin: spring-projects/spring-integration

@Test
public void defaultNotificationType() throws Exception {
  assertNull(listener.lastNotification);
  Message<?> message = MessageBuilder.withPayload("test").build();
  channel.send(message);
  assertNotNull(listener.lastNotification);
  Notification notification = listener.lastNotification;
  assertEquals("default.type", notification.getType());
}
origin: spring-projects/spring-integration

@Test
public void simplePublish() {
  MessageHandler handler = context.getBean("testPublisher", MessageHandler.class);
  assertEquals(0, this.listener.notifications.size());
  handler.handleMessage(new GenericMessage<String>("foo"));
  assertEquals(1, this.listener.notifications.size());
  Notification notification = this.listener.notifications.get(0);
  assertEquals(this.publisherObjectName, notification.getSource());
  assertEquals("foo", notification.getMessage());
  assertEquals("test.type", notification.getType());
}
origin: spring-projects/spring-integration

@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());
}
origin: spring-projects/spring-integration

@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);
}
javax.managementNotificationgetType

Popular methods of Notification

  • <init>
  • getUserData
  • setUserData
  • getMessage
  • getSource
  • getTimeStamp
  • getSequenceNumber
  • setSource
  • toString
  • setSequenceNumber
  • getAttachments
  • getClass
  • getAttachments,
  • getClass,
  • getFlag,
  • getIntent,
  • getTitle,
  • setCreatedd_time,
  • setId,
  • setLatestEventInfo,
  • setLink

Popular in Java

  • Making http post requests using okhttp
  • getSupportFragmentManager (FragmentActivity)
  • setRequestProperty (URLConnection)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now