Java Code Examples for javax.management.Notification#getMessage()

The following examples show how to use javax.management.Notification#getMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JMXAdminDistributedSystem.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Translate the given JMX <code>Notification</code> into an
 * <code>Membership</code> that is delivered to the
 * <code>SystemMembershipListener</code>.
 */
public void handleNotification(Notification notification,
                               Object handback) {

  final String memberId = notification.getMessage();
  SystemMembershipEvent event = new SystemMembershipEvent() {
      public String getMemberId() {
        return memberId;
      }
      public DistributedMember getDistributedMember() {
        return null;
      }
    };

  String type = notification.getType();
  if (AdminDistributedSystemJmxImpl.NOTIF_MEMBER_JOINED.equals(type)) {
    this.listener.memberJoined(event);

  } else if (AdminDistributedSystemJmxImpl.NOTIF_MEMBER_LEFT.equals(type)) {
    this.listener.memberLeft(event);

  } else if (AdminDistributedSystemJmxImpl.NOTIF_MEMBER_CRASHED.equals(type)) {
    this.listener.memberCrashed(event);
  }
}
 
Example 2
Source File: JmxProxyImpl.java    From cassandra-reaper with Apache License 2.0 6 votes vote down vote up
/**
 * Handles notifications from the new repair API (repairAsync)
 */
private void processNewApiNotification(Notification notification) {
  Map<String, Integer> data = (Map<String, Integer>) notification.getUserData();
  try {
    // get the repair sequence number
    int repairNo = Integer.parseInt(((String) notification.getSource()).split(":")[1]);
    // get the progress status
    ProgressEventType progress = ProgressEventType.values()[data.get("type")];
    // this is some text message like "Starting repair...", "Finished repair...", etc.
    String message = notification.getMessage();
    // let the handler process the even
    if (repairStatusHandlers.containsKey(repairNo)) {
      LOG.debug("Handling notification {} with repair handler {}", notification, repairStatusHandlers.get(repairNo));

      repairStatusHandlers
          .get(repairNo)
          .handle(repairNo, Optional.empty(), Optional.of(progress), message, this);
    }
  } catch (NumberFormatException e) {
    LOG.error("Error while processing JMX notification", e);
  }
}
 
Example 3
Source File: JmxProxyImpl.java    From cassandra-reaper with Apache License 2.0 6 votes vote down vote up
/**
 * Handles notifications from the old repair API (forceRepairAsync)
 */
private void processOldApiNotification(Notification notification) {
  try {
    int[] data = (int[]) notification.getUserData();
    // get the repair sequence number
    int repairNo = data[0];
    // get the repair status
    ActiveRepairService.Status status = ActiveRepairService.Status.values()[data[1]];
    // this is some text message like "Starting repair...", "Finished repair...", etc.
    String message = notification.getMessage();
    // let the handler process the even
    if (repairStatusHandlers.containsKey(repairNo)) {
      LOG.debug("Handling notification {} with repair handler {}", notification, repairStatusHandlers.get(repairNo));

      repairStatusHandlers
          .get(repairNo)
          .handle(repairNo, Optional.of(status), Optional.empty(), message, this);
    }
  } catch (RuntimeException e) {
    LOG.error("Error while processing JMX notification", e);
  }
}
 
Example 4
Source File: JMXAdminDistributedSystem.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Translate the given JMX <code>Notification</code> into an
 * <code>Membership</code> that is delivered to the
 * <code>SystemMembershipListener</code>.
 */
public void handleNotification(Notification notification,
                               Object handback) {

  final String memberId = notification.getMessage();
  SystemMembershipEvent event = new SystemMembershipEvent() {
      public String getMemberId() {
        return memberId;
      }
      public DistributedMember getDistributedMember() {
        return null;
      }
    };

  String type = notification.getType();
  if (AdminDistributedSystemJmxImpl.NOTIF_MEMBER_JOINED.equals(type)) {
    this.listener.memberJoined(event);

  } else if (AdminDistributedSystemJmxImpl.NOTIF_MEMBER_LEFT.equals(type)) {
    this.listener.memberLeft(event);

  } else if (AdminDistributedSystemJmxImpl.NOTIF_MEMBER_CRASHED.equals(type)) {
    this.listener.memberCrashed(event);
  }
}
 
Example 5
Source File: JMXAdminDistributedSystem.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Translate the given JMX <code>Notification</code> into an
 * <code>Alert</code> that is delivered to the
 * <code>AlertListener</code>.
 */
public void handleNotification(Notification notification,
                               Object handback) {
  String type = notification.getType();
  if (!AdminDistributedSystemJmxImpl.NOTIF_ALERT.equals(type)) {
    return;
  }

  String message = notification.getMessage();
  final com.gemstone.gemfire.internal.admin.Alert alert0 =
    com.gemstone.gemfire.internal.admin.remote.RemoteAlert.fromString(message);
  Alert alert = new Alert() {
      public AlertLevel getLevel() {
        return AlertLevel.forSeverity(alert0.getLevel());
      }

      public SystemMember getSystemMember() {
        String s = "Not implemented yet";
        throw new UnsupportedOperationException(s);
      }

      public String getConnectionName() {
        return alert0.getConnectionName();
      }

      public String getSourceId() {
        return alert0.getSourceId();
      }

      public String getMessage() {
        return alert0.getMessage();
      }

      public Date getDate() {
        return alert0.getDate();
      }

   public String toString() {
return "Test JMXAdminDistributedSystem Alert date: " + getDate() + " message: \"" + getMessage()
    + "\" source id: \"" + getSourceId() + "\" connection name: " + getConnectionName()  
    + " alert level: " + getLevel();
   }


    };
  this.listener.alert(alert);
}
 
Example 6
Source File: MissingClassTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}
 
Example 7
Source File: MissingClassTest.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}
 
Example 8
Source File: JMXAdminDistributedSystem.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Translate the given JMX <code>Notification</code> into an
 * <code>Alert</code> that is delivered to the
 * <code>AlertListener</code>.
 */
public void handleNotification(Notification notification,
                               Object handback) {
  String type = notification.getType();
  if (!AdminDistributedSystemJmxImpl.NOTIF_ALERT.equals(type)) {
    return;
  }

  String message = notification.getMessage();
  final com.gemstone.gemfire.internal.admin.Alert alert0 =
    com.gemstone.gemfire.internal.admin.remote.RemoteAlert.fromString(message);
  Alert alert = new Alert() {
      public AlertLevel getLevel() {
        return AlertLevel.forSeverity(alert0.getLevel());
      }

      public SystemMember getSystemMember() {
        String s = "Not implemented yet";
        throw new UnsupportedOperationException(s);
      }

      public String getConnectionName() {
        return alert0.getConnectionName();
      }

      public String getSourceId() {
        return alert0.getSourceId();
      }

      public String getMessage() {
        return alert0.getMessage();
      }

      public Date getDate() {
        return alert0.getDate();
      }

   public String toString() {
return "Test JMXAdminDistributedSystem Alert date: " + getDate() + " message: \"" + getMessage()
    + "\" source id: \"" + getSourceId() + "\" connection name: " + getConnectionName()  
    + " alert level: " + getLevel();
   }


    };
  this.listener.alert(alert);
}
 
Example 9
Source File: MissingClassTest.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}
 
Example 10
Source File: MissingClassTest.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}
 
Example 11
Source File: MissingClassTest.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}
 
Example 12
Source File: MissingClassTest.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}
 
Example 13
Source File: MissingClassTest.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}
 
Example 14
Source File: MissingClassTest.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}
 
Example 15
Source File: MissingClassTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}
 
Example 16
Source File: MissingClassTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}
 
Example 17
Source File: MissingClassTest.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}
 
Example 18
Source File: MissingClassTest.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}
 
Example 19
Source File: MissingClassTest.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}