@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(); } } } }
/** * 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) */ @Override @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(); } } }
public void handleNotification(Notification notification, Object o) { if (notification instanceof JMXConnectionNotification) { JMXConnectionNotification cxNotification = (JMXConnectionNotification) notification; String type = cxNotification.getType(); String connectionId = cxNotification.getConnectionId(); if (JMXConnectionNotification.OPENED.equals(type)) { LoginContext context = threadContext.get(); threadContext.set(null); contextMap.put(connectionId, context); } else { LoginContext context = contextMap.remove(connectionId); if (context != null) { try { context.logout(); } catch (LoginException e) { //nothing we can do here... } } } } } }
@Override protected void lostNotifs(final String message, final long number) { final String notifType = JMXConnectionNotification.NOTIFS_LOST; final JMXConnectionNotification n = new JMXConnectionNotification(notifType, intermediary, intermediary.connection.getConnectionId(), intermediary.lostNotifCounter++, message, new Long(number)); intermediary.client.sendNotification(n); } }
public JMXConnectionNotification(String type, Object source, String connectionId, long sequenceNumber, String message, Object userData) { super(type, source, sequenceNumber, System.currentTimeMillis(), message); this.connectionId = connectionId; setUserData(userData); }
public void handleNotification(Notification notification, Object o) { if (notification instanceof JMXConnectionNotification) { JMXConnectionNotification cxNotification = (JMXConnectionNotification) notification; String type = cxNotification.getType(); String connectionId = cxNotification.getConnectionId(); if (JMXConnectionNotification.OPENED.equals(type)) { LoginContext context = threadContext.get(); threadContext.set(null); contextMap.put(connectionId, context); } else { LoginContext context = contextMap.remove(connectionId); if (context != null) { try { context.logout(); } catch (LoginException e) { //nothing we can do here... } } } } } }
public void close() throws IOException { fireNotification(new JMXConnectionNotification(JMXConnectionNotification.CLOSED, this, getConnectionId(), notificatioCounter.getAndIncrement(), "FastJMX SynchronousConnectorAdapter CLOSED.", null)); delegate.close(); }
@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()); } } } }
@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."); } } } }
protected void connectionOpened(String connectionId, String message, Object userData) { if(connectionId == null) { // per spec throw new NullPointerException("Connection id is null."); } synchronized(connectionIds) { connectionIds.add(connectionId); } JMXConnectionNotification notification = new JMXConnectionNotification(JMXConnectionNotification.OPENED, this, connectionId, getNextSequenceNumber(), message, userData); sendNotification(notification); }
@Override public void handleNotification(Notification notification, Object handback) { final String connectionId = ((JMXConnectionNotification) notification).getConnectionId(); removeConnectionIdFromCache(connectionId); }
@Override public boolean isNotificationEnabled(final Notification notification) { boolean enabled = false; if (notification instanceof JMXConnectionNotification) { final JMXConnectionNotification jmxcn = (JMXConnectionNotification) notification; enabled = jmxcn.getType().equals(JMXConnectionNotification.CLOSED); } return enabled; } }
/** * Called by a ClientIntermediary to reconnect the transport because the server has been closed after its timeout. * @return . * @throws IOException . */ ClientSynchroMessageConnection reconnect() throws IOException { synchronized (lock) { if (state != CONNECTED) throw new IOException("The connector is not at the connection state."); } sendNotification(new JMXConnectionNotification(JMXConnectionNotification.FAILED, this, connectionId, clientNotifID++, "The client has got connection exception.", null)); connection.connect(env); connectionId = connection.getConnectionId(); sendNotification(new JMXConnectionNotification(JMXConnectionNotification.OPENED, this, connectionId, clientNotifID++, "The client has succesfully reconnected to the server.", null)); return connection; }
@Override public final void handleNotification(final Notification notification, final Object handback) { final String notificationType = notification.getType(); if (notificationType.equals(JMXConnectionNotification.OPENED)) { LOG.info("New JMX remote connection initialized. Connection ID: " + (notification instanceof JMXConnectionNotification ? ((JMXConnectionNotification) notification).getConnectionId() : "unknown")); // NOCS } else if (notificationType.equals(JMXConnectionNotification.CLOSED)) { LOG.info("JMX remote connection closed. Connection ID: " + (notification instanceof JMXConnectionNotification ? ((JMXConnectionNotification) notification).getConnectionId() : "unknown")); // NOCS } else { // unknown message LOG.info(notificationType + ": " + notification.getMessage() + " (ID: " + (notification instanceof JMXConnectionNotification ? ((JMXConnectionNotification) notification).getConnectionId() : "unknown") + ")"); // NOCS } } }
@Override public boolean isNotificationEnabled(final Notification notification) { boolean enabled = false; if (notification instanceof JMXConnectionNotification) { final JMXConnectionNotification jmxcn = (JMXConnectionNotification) notification; enabled = jmxcn.getType().equals(JMXConnectionNotification.CLOSED); } return enabled; } }
@Override public synchronized void close() throws IOException { if (connected) { connector.close(); connectionBroadcaster.sendNotification(new JMXConnectionNotification( JMXConnectionNotification.CLOSED, this, connectionId, connectionNotificationSequence++, "Connection closed", null)); connected = false; } }
@Override public final void handleNotification(final Notification notification, final Object handback) { if (LOGGER.isInfoEnabled()) { final String notificationType = notification.getType(); final String connectionID; if (notification instanceof JMXConnectionNotification) { connectionID = ((JMXConnectionNotification) notification).getConnectionId(); } else { connectionID = "unknown"; } if (notificationType.equals(JMXConnectionNotification.OPENED)) { LOGGER.info("New JMX remote connection initialized. Connection ID: " + connectionID); } else if (notificationType.equals(JMXConnectionNotification.CLOSED)) { LOGGER.info("JMX remote connection closed. Connection ID: " + connectionID); } else { // unknown message LOGGER.info(notificationType + ": " + notification.getMessage() + " (ID: " + connectionID + ")"); } } } }
@Override public boolean isNotificationEnabled(final Notification notification) { boolean enabled = false; if (notification instanceof JMXConnectionNotification) { final JMXConnectionNotification jmxcn = (JMXConnectionNotification) notification; enabled = jmxcn.getType().equals(JMXConnectionNotification.CLOSED); } return enabled; } }
public void connect(Map<String, ?> env) throws IOException { try { delegate.connect(env); // Force setting the MBeanServerConnection prior to invoking the callbacks. This avoids a potential race. manager.setMBeanServerConnection(delegate.getMBeanServerConnection()); fireNotification(new JMXConnectionNotification(JMXConnectionNotification.OPENED, this, getConnectionId(), notificatioCounter.getAndIncrement(), "FastJMX SynchronousConnectorAdapter OPENED.", null)); } catch (IOException ioe) { throw ioe; } catch (Exception e) { // Hack hack hackity hack hack hack // This is a workaround for: https://issues.jboss.org/browse/REMJMX-90 throw new IOException(e); } }
/** * 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(); } } }