java类javax.management.remote.JMXConnectionNotification的实例源码

MissingClassTest.java 文件源码 项目:openjdk9 阅读 16 收藏 0 点赞 0 评论 0
public void handleNotification(Notification n, Object h) {
    /* Connectors can handle unserializable notifications in
       one of two ways.  Either they can arrange for the
       client to get a NotSerializableException from its
       fetchNotifications call (RMI connector), or they can
       replace the unserializable notification by a
       JMXConnectionNotification.NOTIFS_LOST (JMXMP
       connector).  The former case is handled by code within
       the connector client which will end up sending a
       NOTIFS_LOST to our LostListener.  The logic here
       handles the latter case by converting it into the
       former.
     */
    if (n instanceof JMXConnectionNotification
        && n.getType().equals(JMXConnectionNotification.NOTIFS_LOST)) {
        lostListener.handleNotification(n, h);
        return;
    }

    synchronized (result) {
        if (!n.getType().equals("interesting")
            || !n.getUserData().equals("known")) {
            System.out.println("TestListener received strange notif: "
                               + notificationString(n));
            result.failed = true;
            result.notifyAll();
        } else {
            result.knownCount++;
            if (result.knownCount == NNOTIFS)
                result.notifyAll();
        }
    }
}
MissingClassTest.java 文件源码 项目:openjdk9 阅读 17 收藏 0 点赞 0 评论 0
private void handle(Notification n, Object h) {
    if (!(n instanceof JMXConnectionNotification)) {
        System.out.println("LostListener received strange notif: " +
                           notificationString(n));
        result.failed = true;
        result.notifyAll();
        return;
    }

    JMXConnectionNotification jn = (JMXConnectionNotification) n;
    if (!jn.getType().equals(jn.NOTIFS_LOST)) {
        System.out.println("Ignoring JMXConnectionNotification: " +
                           notificationString(jn));
        return;
    }
    final String msg = jn.getMessage();
    if ((!msg.startsWith("Dropped ")
         || !msg.endsWith("classes were missing locally"))
        && (!msg.startsWith("Not serializable: "))) {
        System.out.println("Surprising NOTIFS_LOST getMessage: " +
                           msg);
    }
    if (!(jn.getUserData() instanceof Long)) {
        System.out.println("JMXConnectionNotification userData " +
                           "not a Long: " + jn.getUserData());
        result.failed = true;
    } else {
        int lost = ((Long) jn.getUserData()).intValue();
        result.lostCount += lost;
        if (result.lostCount == NNOTIFS*2)
            result.notifyAll();
    }
}
MissingClassTest.java 文件源码 项目:openjdk9 阅读 18 收藏 0 点赞 0 评论 0
public void handleNotification(Notification n, Object o) {
    if (n instanceof JMXConnectionNotification) {
        JMXConnectionNotification jn = (JMXConnectionNotification)n;
        if (JMXConnectionNotification.FAILED.equals(jn.getType())) {
            failed = true;
        }
    }
}
ConnectionTest.java 文件源码 项目:openjdk9 阅读 22 收藏 0 点赞 0 评论 0
private static boolean
    mustBeConnectionNotification(Notification notif,
                                 String requiredConnId,
                                 String requiredType) {

    if (!(notif instanceof JMXConnectionNotification)) {
        System.out.println("Should have been a " +
                           "JMXConnectionNotification: " +
                           notif.getClass());
        return false;
    }

    JMXConnectionNotification cnotif = (JMXConnectionNotification) notif;
    if (!cnotif.getType().equals(requiredType)) {
        System.out.println("Wrong type notif: is \"" + cnotif.getType() +
                           "\", should be \"" + requiredType + "\"");
        return false;
    }

    if (!cnotif.getConnectionId().equals(requiredConnId)) {
        System.out.println("Wrong connection id: is \"" +
                           cnotif.getConnectionId() + "\", should be \"" +
                           requiredConnId);
        return false;
    }

    return true;
}
RMIConnector.java 文件源码 项目:Java8CN 阅读 28 收藏 0 点赞 0 评论 0
protected void lostNotifs(String message, long number) {
    final String notifType = JMXConnectionNotification.NOTIFS_LOST;

    final JMXConnectionNotification n =
        new JMXConnectionNotification(notifType,
                                      RMIConnector.this,
                                      connectionId,
                                      clientNotifCounter++,
                                      message,
                                      Long.valueOf(number));
    sendNotification(n);
}
RMIConnector.java 文件源码 项目:Java8CN 阅读 22 收藏 0 点赞 0 评论 0
protected void doStart() throws IOException {
    // Get RMIServer stub from directory or URL encoding if needed.
    RMIServer stub;
    try {
        stub = (rmiServer!=null)?rmiServer:
            findRMIServer(jmxServiceURL, env);
    } catch (NamingException ne) {
        throw new IOException("Failed to get a RMI stub: "+ne);
    }

    // Connect IIOP Stub if needed.
    stub = connectStub(stub,env);

    // Calling newClient on the RMIServer stub.
    Object credentials = env.get(CREDENTIALS);
    connection = stub.newClient(credentials);

    // notif issues
    final ClientListenerInfo[] old = rmiNotifClient.preReconnection();

    reconnectNotificationListeners(old);

    connectionId = getConnectionId();

    Notification reconnectedNotif =
            new JMXConnectionNotification(JMXConnectionNotification.OPENED,
            this,
            connectionId,
            clientNotifSeqNo++,
            "Reconnected to server",
            null);
    sendNotification(reconnectedNotif);

}
AgentImpl.java 文件源码 项目:gemfirexd-oss 阅读 23 收藏 0 点赞 0 评论 0
/**
 * 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.
 */
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;
}
JmxOperationInvoker.java 文件源码 项目:gemfirexd-oss 阅读 20 收藏 0 点赞 0 评论 0
@Override
public void handleNotification(Notification notification, Object handback) {
  if (JMXConnectionNotification.class.isInstance(notification)) {
    JMXConnectionNotification connNotif = (JMXConnectionNotification)notification;
    if (JMXConnectionNotification.CLOSED.equals(connNotif.getType()) ||
        JMXConnectionNotification.FAILED.equals(connNotif.getType())) {
      this.invoker.isConnected.set(false);
      this.invoker.resetClusterId();
      if (!this.invoker.isSelfDisconnect.get()) {
        Gfsh.getCurrentInstance().notifyDisconnect(this.invoker.toString());
      }
    }
  }
}
RMIConnector.java 文件源码 项目:jdk8u_jdk 阅读 18 收藏 0 点赞 0 评论 0
protected void lostNotifs(String message, long number) {
    final String notifType = JMXConnectionNotification.NOTIFS_LOST;

    final JMXConnectionNotification n =
        new JMXConnectionNotification(notifType,
                                      RMIConnector.this,
                                      connectionId,
                                      clientNotifCounter++,
                                      message,
                                      Long.valueOf(number));
    sendNotification(n);
}
RMIConnector.java 文件源码 项目:jdk8u_jdk 阅读 24 收藏 0 点赞 0 评论 0
protected void doStart() throws IOException {
    // Get RMIServer stub from directory or URL encoding if needed.
    RMIServer stub;
    try {
        stub = (rmiServer!=null)?rmiServer:
            findRMIServer(jmxServiceURL, env);
    } catch (NamingException ne) {
        throw new IOException("Failed to get a RMI stub: "+ne);
    }

    // Connect IIOP Stub if needed.
    stub = connectStub(stub,env);

    // Calling newClient on the RMIServer stub.
    Object credentials = env.get(CREDENTIALS);
    connection = stub.newClient(credentials);

    // notif issues
    final ClientListenerInfo[] old = rmiNotifClient.preReconnection();

    reconnectNotificationListeners(old);

    connectionId = getConnectionId();

    Notification reconnectedNotif =
            new JMXConnectionNotification(JMXConnectionNotification.OPENED,
            this,
            connectionId,
            clientNotifSeqNo++,
            "Reconnected to server",
            null);
    sendNotification(reconnectedNotif);

}


问题


面经


文章

微信
公众号

扫码关注公众号