public void run() {
        if (operation == Operation.getStreamID) {
            result = getSession().getStreamID();
        }
        else if (operation == Operation.getServerName) {
            result = getSession().getServerName();
        }
        else if (operation == Operation.getCreationDate) {
            result = getSession().getCreationDate();
        }
        else if (operation == Operation.getLastActiveDate) {
            result = getSession().getLastActiveDate();
        }
        else if (operation == Operation.getNumClientPackets) {
            result = getSession().getNumClientPackets();
        }
        else if (operation == Operation.getNumServerPackets) {
            result = getSession().getNumServerPackets();
        }
        else if (operation == Operation.getTLSProtocolName) {
            result = getSession().getTLSProtocolName();
        }
        else if (operation == Operation.getCipherSuiteName) {
            result = getSession().getCipherSuiteName();
        }
        else if (operation == Operation.getPeerCertificates) {
            result = getSession().getPeerCertificates();
        }
        else if (operation == Operation.getSoftwareVersion) {
            result = getSession().getSoftwareVersion();
        }
        else if (operation == Operation.close) {
            // Run in another thread so we avoid blocking calls (in hazelcast) 
            final Session session = getSession();
            if (session != null) {
                final Future<?> future = TaskEngine.getInstance().submit( () -> {
                    try {
                        if (session instanceof LocalSession) {
                            // OF-2311: If closed by another cluster node, chances are that the session needs to be closed forcibly.
                            // Chances of the session being resumed are neglectable, while retaining the session in a detached state
                            // causes problems (eg: IQBindHandler could have re-issued the resource to a replacement session).
                            ((LocalSession) session).getStreamManager().formalClose();
                        }
                        session.close();
                    } catch (Exception e) {
                        Log.info("An exception was logged while closing session: {}", session, e);
                    }
                });
                // Wait until the close operation is done or timeout is met
                try {
                    future.get(15, TimeUnit.SECONDS);
                }
                catch (Exception e) {
                    Log.info("An exception was logged while executing RemoteSessionTask to close session: {}", session, e);
                }
            }
        }
        else if (operation == Operation.isClosed) {
            result = getSession().isClosed();
        }
        else if (operation == Operation.isDetached) {
            result = getSession().isDetached();
        }
        else if (operation == Operation.isEncrypted) {
            result = getSession().isEncrypted();
        }
        else if (operation == Operation.getHostAddress) {
            try {
                if (getSession().isDetached()) {
                    Log.debug("Unable to get host-address of detached session: {}", getSession());
                } else {
                    result = getSession().getHostAddress();
                }
            } catch (UnknownHostException e) {
                Log.error("Error getting address of session: {}", getSession(), e);
            }
        }
        else if (operation == Operation.getHostName) {
            try {
                if (getSession().isDetached()) {
                    Log.debug("Unable to get hostname of detached session: {}", getSession());
                } else {
                    result = getSession().getHostName();
                }
            } catch (UnknownHostException e) {
                Log.error("Error getting address of session: {}", getSession(), e);
            }
        }
        else if (operation == Operation.validate) {
            result = getSession().validate();
        }
        else if (operation == Operation.removeDetached) {
            final Session session = getSession();
            if (session instanceof LocalSession) {
                Log.debug("Terminating local session as instructed by another cluster node: {}", session);

                final Future<?> future = TaskEngine.getInstance().submit( () -> {
                    try {
                        SessionManager.getInstance().terminateDetached((LocalSession) session);
                    } catch (Exception e) {
                        Log.info("An exception was logged while closing session: {}", session, e);
                    }
                });
                // Wait until the close operation is done or timeout is met
                try {
                    future.get(15, TimeUnit.SECONDS);
                }
                catch (Exception e) {
                    Log.info("An exception was logged while executing RemoteSessionTask to close session: {}", session, e);
                }
            }
        }
    }
Operations to be executed in a remote session hosted in a remote cluster node.

@author Gaston Dombiak
xmppserver/src/main/java/org/jivesoftware/openfire/session/RemoteSessionTask.java