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
/**
 * 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 Project: cassandra-reaper   File: JmxProxyImpl.java    License: 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 3
Source Project: cassandra-reaper   File: JmxProxyImpl.java    License: 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 4
/**
 * 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
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}
 
Example 6
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}
 
Example 7
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}
 
Example 8
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}
 
Example 9
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}
 
Example 10
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}
 
Example 11
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}
 
Example 12
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}
 
Example 13
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}
 
Example 14
/**
 * 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 15
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}
 
Example 16
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}
 
Example 17
/**
 * 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 18
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}
 
Example 19
private static String notificationString(Notification n) {
    return n.getClass().getName() + "/" + n.getType() + " \"" +
        n.getMessage() + "\" <" + n.getUserData() + ">";
}