Java 类javax.management.remote.JMXConnectionNotification 实例源码

项目:monarch    文件:AgentImpl.java   
/**
 * If the handback object passed is an AgentImpl, updates the JMX client count
 *
 * @param notification JMXConnectionNotification for change in client connection status
 * @param handback An opaque object which helps the listener to associate information regarding
 *        the MBean emitter. This object is passed to the MBean during the addListener call and
 *        resent, without modification, to the listener. The MBean object should not use or modify
 *        the object. (NOTE: copied from javax.management.NotificationListener)
 */
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "BC_UNCONFIRMED_CAST",
    justification = "Only JMXConnectionNotification instances are used.")
public void handleNotification(Notification notification, Object handback) {
  if (handback instanceof AgentImpl) {
    AgentImpl agent = (AgentImpl) handback;

    JMXConnectionNotification jmxNotifn = (JMXConnectionNotification) notification;

    if (logger.isDebugEnabled()) {
      logger.debug("Connection notification for connection id : '{}'",
          jmxNotifn.getConnectionId());
    }

    agent.updateRmiClientsCount();
  }
}
项目:OperatieBRP    文件:ClientConnection.java   
/**
 * Close the connection.
 * @throws IOException if an I/O error occurs when closing the connection
 */
void close() throws IOException {
    LOGGER.log(Level.FINE, "Sending logoff");
    try {
        handleRequest(new RequestLogoff());
    } catch (final IOException e) {
        LOGGER.log(Level.WARNING, "Unexpected exception when logging off", e);
    }

    LOGGER.log(Level.FINE, "Stopping client listener");
    clientListener.stop();

    IOUtils.closeSilently(socket);
    LOGGER.log(Level.FINE, "Closed");
    if (connectionId != null) {
        // Only send closed notification when we could connect succesfully
        connector.sendConnectionNotification(JMXConnectionNotification.CLOSED, connectionId);
    }
}
项目:gemfirexd-oss    文件:AgentImpl.java   
/**
 * If the handback object passed is an AgentImpl, updates the JMX client count
 *
 * @param notification
 *          JMXConnectionNotification for change in client connection status
 * @param handback
 *          An opaque object which helps the listener to associate information
 *          regarding the MBean emitter. This object is passed to the MBean
 *          during the addListener call and resent, without modification, to
 *          the listener. The MBean object should not use or modify the
 *          object. (NOTE: copied from javax.management.NotificationListener)
 */
@SuppressFBWarnings(value="BC_UNCONFIRMED_CAST", justification="Only JMXConnectionNotification instances are used.") 
public void handleNotification(Notification notification, Object handback) {
  if (handback instanceof AgentImpl) {
    AgentImpl agent = (AgentImpl) handback;

    JMXConnectionNotification jmxNotifn =
      (JMXConnectionNotification) notification;

    LogWriterI18n logWriter = agent.getLogWriterI18n();
    logWriter.fine("Connection notification for connection id : '" +
                              jmxNotifn.getConnectionId() + "'");

    agent.updateRmiClientsCount();
  }
}
项目:Camel    文件:JMXConsumer.java   
@Override
public void handleNotification(Notification notification, Object handback) {
    JMXConnectionNotification connectionNotification = (JMXConnectionNotification)notification;
    // only reset the connection if the notification is for the connection from this endpoint
    if (!connectionNotification.getConnectionId().equals(mConnectionId)) {
        return;
    }
    if (connectionNotification.getType().equals(JMXConnectionNotification.NOTIFS_LOST) 
                || connectionNotification.getType().equals(JMXConnectionNotification.CLOSED) 
                || connectionNotification.getType().equals(JMXConnectionNotification.FAILED)) {
        LOG.warn("Lost JMX connection for : {}", URISupport.sanitizeUri(mJmxEndpoint.getEndpointUri()));
        if (mJmxEndpoint.getReconnectOnConnectionFailure()) {
            scheduleReconnect();
        } else {
            LOG.warn("The JMX consumer will not be reconnected.  Use 'reconnectOnConnectionFailure' to "
                    + "enable reconnections.");
        }
    }
}
项目:gemfirexd-oss    文件:AgentImpl.java   
/**
 * If the handback object passed is an AgentImpl, updates the JMX client count
 *
 * @param notification
 *          JMXConnectionNotification for change in client connection status
 * @param handback
 *          An opaque object which helps the listener to associate information
 *          regarding the MBean emitter. This object is passed to the MBean
 *          during the addListener call and resent, without modification, to
 *          the listener. The MBean object should not use or modify the
 *          object. (NOTE: copied from javax.management.NotificationListener)
 */
@SuppressFBWarnings(value="BC_UNCONFIRMED_CAST", justification="Only JMXConnectionNotification instances are used.") 
public void handleNotification(Notification notification, Object handback) {
  if (handback instanceof AgentImpl) {
    AgentImpl agent = (AgentImpl) handback;

    JMXConnectionNotification jmxNotifn =
      (JMXConnectionNotification) notification;

    LogWriterI18n logWriter = agent.getLogWriterI18n();
    logWriter.fine("Connection notification for connection id : '" +
                              jmxNotifn.getConnectionId() + "'");

    agent.updateRmiClientsCount();
  }
}
项目:streamsx.jmxclients    文件:JmxConnectionPool.java   
@Override
public void handleNotification(Notification notification,
        Object handback) {
    JMXConnectionNotification connectionNotification = (JMXConnectionNotification) notification;
    // Should handle connectionID in the future to be specific
    // Be aware!! JMX failures log SEVERE messages that are not
    // coming from us
    LOGGER.trace("*** JMX Connection Notification: "
            + connectionNotification);
    LOGGER.trace("*** notification.getConnectionId(): "
            + connectionNotification.getConnectionId());
    LOGGER.trace("*** this.notificationId: " + mConnectionId);

    // Only reset connection if the notification is for the
    // connection at this endpoint
    if (!connectionNotification.getConnectionId().equals(
            mConnectionId)) {
        return;
    }

    String notificationType = connectionNotification.getType();

    if (notificationType
            .equals(JMXConnectionNotification.NOTIFS_LOST)
            || notificationType
                    .equals(JMXConnectionNotification.CLOSED)
            || notificationType
                    .equals(JMXConnectionNotification.FAILED)) {
        LOGGER.warn("*** Lost JMX Connection, scheduling reconnect and removing connection listener ...");
        // Remove connectionListener becuase often FAILED is follwed
        // by CLOSED and was causing multiple reconnects which stomp
        // on each other
        removeNotificationListener();

        notifyBeanSourceInterrupted(mStreamsBeanSource);
        // Could test to ensure we want to try and reconnect
        scheduleReconnect();
    }
}
项目:eZooKeeper    文件:JmxConnection.java   
private void fireConnectionStateChanged(JMXConnectionNotification notification) {

        if (_EventListeners != null) {

            JmxConnectionEvent event = new JmxConnectionEvent(this, notification);
            for (IJmxConnectionEventListener listener : _EventListeners) {
                listener.connectionStateChanged(event);
            }
        }
    }
项目:OpenJSharp    文件:RMIConnector.java   
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);
}
项目:OpenJSharp    文件:RMIConnector.java   
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);

}
项目:monarch    文件:AgentImpl.java   
/**
 * 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;
}
项目:monarch    文件:JmxOperationInvoker.java   
@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());
      }
    }
  }
}
项目:monarch    文件:JMXShiroAuthenticator.java   
@Override
public void handleNotification(Notification notification, Object handback) {
  if (notification instanceof JMXConnectionNotification) {
    JMXConnectionNotification cxNotification = (JMXConnectionNotification) notification;
    String type = cxNotification.getType();
    if (JMXConnectionNotification.CLOSED.equals(type)) {
      this.securityService.logout();
    }
  }
}
项目:OperatieBRP    文件:ClientConnection.java   
/**
 * Connect the connection to the server.
 * @throws IOException if an I/O error occurs when connecting
 */
void connect() throws IOException {
    LOGGER.log(Level.FINE, "Connecting to {0}:{1,number,#####} ...",
            new Object[]{serviceUrl.getHost(), serviceUrl.getPort()});
    socket = socketFactory.createSocket(serviceUrl);
    socket.setSoTimeout(0);

    // The socket InputStream and OutputStream are not closed directly. They
    // are shutdown and closed via method calls on the socket itself.
    output = new MessageOutputStream(socket.getOutputStream());

    LOGGER.log(Level.FINE, "Starting receiver");
    clientListener = new ClientListener(new MessageInputStream(socket.getInputStream()), requestTimeout);
    clientListenerThread = new Thread(clientListener, "jmx-client-receiver");
    clientListenerThread.start();

    LOGGER.log(Level.FINE, "Sending logon request");
    final RequestLogon logon = new RequestLogon(credentials);

    LOGGER.log(Level.FINE, "Handling logon response");
    final Response logonResponse = handleRequest(logon);
    if (logonResponse.getException() != null) {
        LOGGER.log(Level.FINE, "Logon failed");
        throw new IOException("Could not logon", logonResponse.getException());
    }
    connectionId = (String) logonResponse.getResult();

    LOGGER.log(Level.FINE, "Connected; connectionId = {0}", connectionId);
    connector.sendConnectionNotification(JMXConnectionNotification.OPENED, connectionId);
}
项目:jdk8u-jdk    文件:RMIConnector.java   
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);
}
项目:jdk8u-jdk    文件:RMIConnector.java   
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);

}
项目:jdk8u-jdk    文件:NotifReconnectDeadlockTest.java   
public void handleNotification(Notification n, Object hb) {

                // treat the client notif to know the end
                if (n instanceof JMXConnectionNotification) {
                    if (!JMXConnectionNotification.NOTIFS_LOST.equals(n.getType())) {

                        clientState = n.getType();
                        System.out.println(
                           ">>> The client state has been changed to: "+clientState);

                        synchronized(lock) {
                            lock.notifyAll();
                        }
                    }

                    return;
                }

                System.out.println(">>> Do sleep to make reconnection.");
                synchronized(lock) {
                    try {
                        lock.wait(listenerSleep);
                    } catch (Exception e) {
                        // OK
                    }
                }
            }
项目:jdk8u-jdk    文件:MissingClassTest.java   
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();
        }
    }
}
项目:jdk8u-jdk    文件:MissingClassTest.java   
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();
    }
}
项目:jdk8u-jdk    文件:MissingClassTest.java   
public void handleNotification(Notification n, Object o) {
    if (n instanceof JMXConnectionNotification) {
        JMXConnectionNotification jn = (JMXConnectionNotification)n;
        if (JMXConnectionNotification.FAILED.equals(jn.getType())) {
            failed = true;
        }
    }
}
项目:jdk8u-jdk    文件:ConnectionTest.java   
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;
}
项目:openjdk-jdk10    文件:RMIConnector.java   
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);
}
项目:openjdk-jdk10    文件:RMIConnector.java   
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);
    }

    // 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);

}
项目:openjdk-jdk10    文件:NotifReconnectDeadlockTest.java   
public void handleNotification(Notification n, Object hb) {

                // treat the client notif to know the end
                if (n instanceof JMXConnectionNotification) {
                    if (!JMXConnectionNotification.NOTIFS_LOST.equals(n.getType())) {

                        clientState = n.getType();
                        System.out.println(
                           ">>> The client state has been changed to: "+clientState);

                        synchronized(lock) {
                            lock.notifyAll();
                        }
                    }

                    return;
                }

                System.out.println(">>> Do sleep to make reconnection.");
                synchronized(lock) {
                    try {
                        lock.wait(listenerSleep);
                    } catch (Exception e) {
                        // OK
                    }
                }
            }
项目:openjdk-jdk10    文件:MissingClassTest.java   
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();
        }
    }
}
项目:openjdk-jdk10    文件:MissingClassTest.java   
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();
    }
}
项目:openjdk-jdk10    文件:MissingClassTest.java   
public void handleNotification(Notification n, Object o) {
    if (n instanceof JMXConnectionNotification) {
        JMXConnectionNotification jn = (JMXConnectionNotification)n;
        if (JMXConnectionNotification.FAILED.equals(jn.getType())) {
            failed = true;
        }
    }
}
项目:openjdk-jdk10    文件:ConnectionTest.java   
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;
}
项目:openjdk9    文件:RMIConnector.java   
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);
}
项目:openjdk9    文件:RMIConnector.java   
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);
    }

    // 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);

}
项目:openjdk9    文件:NotifReconnectDeadlockTest.java   
public void handleNotification(Notification n, Object hb) {

                // treat the client notif to know the end
                if (n instanceof JMXConnectionNotification) {
                    if (!JMXConnectionNotification.NOTIFS_LOST.equals(n.getType())) {

                        clientState = n.getType();
                        System.out.println(
                           ">>> The client state has been changed to: "+clientState);

                        synchronized(lock) {
                            lock.notifyAll();
                        }
                    }

                    return;
                }

                System.out.println(">>> Do sleep to make reconnection.");
                synchronized(lock) {
                    try {
                        lock.wait(listenerSleep);
                    } catch (Exception e) {
                        // OK
                    }
                }
            }
项目:openjdk9    文件:MissingClassTest.java   
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();
        }
    }
}
项目:openjdk9    文件:MissingClassTest.java   
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();
    }
}
项目:openjdk9    文件:MissingClassTest.java   
public void handleNotification(Notification n, Object o) {
    if (n instanceof JMXConnectionNotification) {
        JMXConnectionNotification jn = (JMXConnectionNotification)n;
        if (JMXConnectionNotification.FAILED.equals(jn.getType())) {
            failed = true;
        }
    }
}
项目:openjdk9    文件:ConnectionTest.java   
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;
}
项目:Java8CN    文件:RMIConnector.java   
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);
}
项目:Java8CN    文件:RMIConnector.java   
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);

}
项目:gemfirexd-oss    文件:AgentImpl.java   
/**
 * 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;
}
项目:gemfirexd-oss    文件:JmxOperationInvoker.java   
@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());
      }
    }
  }
}
项目:jdk8u_jdk    文件:RMIConnector.java   
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);
}
项目:jdk8u_jdk    文件:RMIConnector.java   
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);

}