当前位置: 首页>>代码示例>>Java>>正文


Java JMXConnectionNotification类代码示例

本文整理汇总了Java中javax.management.remote.JMXConnectionNotification的典型用法代码示例。如果您正苦于以下问题:Java JMXConnectionNotification类的具体用法?Java JMXConnectionNotification怎么用?Java JMXConnectionNotification使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JMXConnectionNotification类属于javax.management.remote包,在下文中一共展示了JMXConnectionNotification类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleNotification

import javax.management.remote.JMXConnectionNotification; //导入依赖的package包/类
/**
 * 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();
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:26,代码来源:AgentImpl.java

示例2: close

import javax.management.remote.JMXConnectionNotification; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:23,代码来源:ClientConnection.java

示例3: handleNotification

import javax.management.remote.JMXConnectionNotification; //导入依赖的package包/类
/**
 * 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();
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:28,代码来源:AgentImpl.java

示例4: handleNotification

import javax.management.remote.JMXConnectionNotification; //导入依赖的package包/类
@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.");
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:JMXConsumer.java

示例5: handleNotification

import javax.management.remote.JMXConnectionNotification; //导入依赖的package包/类
@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();
    }
}
 
开发者ID:IBMStreams,项目名称:streamsx.jmxclients,代码行数:40,代码来源:JmxConnectionPool.java

示例6: fireConnectionStateChanged

import javax.management.remote.JMXConnectionNotification; //导入依赖的package包/类
private void fireConnectionStateChanged(JMXConnectionNotification notification) {

        if (_EventListeners != null) {

            JmxConnectionEvent event = new JmxConnectionEvent(this, notification);
            for (IJmxConnectionEventListener listener : _EventListeners) {
                listener.connectionStateChanged(event);
            }
        }
    }
 
开发者ID:baloise,项目名称:eZooKeeper,代码行数:11,代码来源:JmxConnection.java

示例7: lostNotifs

import javax.management.remote.JMXConnectionNotification; //导入依赖的package包/类
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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:RMIConnector.java

示例8: doStart

import javax.management.remote.JMXConnectionNotification; //导入依赖的package包/类
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);

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:35,代码来源:RMIConnector.java

示例9: isNotificationEnabled

import javax.management.remote.JMXConnectionNotification; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:17,代码来源:AgentImpl.java

示例10: handleNotification

import javax.management.remote.JMXConnectionNotification; //导入依赖的package包/类
@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());
      }
    }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:15,代码来源:JmxOperationInvoker.java

示例11: handleNotification

import javax.management.remote.JMXConnectionNotification; //导入依赖的package包/类
@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();
    }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:11,代码来源:JMXShiroAuthenticator.java

示例12: connect

import javax.management.remote.JMXConnectionNotification; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:34,代码来源:ClientConnection.java

示例13: handleNotification

import javax.management.remote.JMXConnectionNotification; //导入依赖的package包/类
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
                    }
                }
            }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:28,代码来源:NotifReconnectDeadlockTest.java

示例14: handleNotification

import javax.management.remote.JMXConnectionNotification; //导入依赖的package包/类
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();
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:34,代码来源:MissingClassTest.java

示例15: handle

import javax.management.remote.JMXConnectionNotification; //导入依赖的package包/类
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();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:34,代码来源:MissingClassTest.java


注:本文中的javax.management.remote.JMXConnectionNotification类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。