Java Code Examples for javax.management.remote.JMXConnectionNotification#FAILED

The following examples show how to use javax.management.remote.JMXConnectionNotification#FAILED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RMIConnector.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected NotificationResult fetchNotifs(long clientSequenceNumber,
        int maxNotifications,
        long timeout)
        throws IOException, ClassNotFoundException {

    boolean retried = false;
    while (true) { // used for a successful re-connection
                   // or a transient network problem
        try {
            return connection.fetchNotifications(clientSequenceNumber,
                    maxNotifications,
                    timeout); // return normally
        } catch (IOException ioe) {
            // Examine the chain of exceptions to determine whether this
            // is a deserialization issue. If so - we propagate the
            // appropriate exception to the caller, who will then
            // proceed with fetching notifications one by one
            rethrowDeserializationException(ioe);

            try {
                communicatorAdmin.gotIOException(ioe);
                // reconnection OK, back to "while" to do again
            } catch (IOException ee) {
                boolean toClose = false;

                synchronized (this) {
                    if (terminated) {
                        // the connection is closed.
                        throw ioe;
                    } else if (retried) {
                        toClose = true;
                    }
                }

                if (toClose) {
                    // JDK-8049303
                    // We received an IOException - but the communicatorAdmin
                    // did not close the connection - possibly because
                    // the original exception was raised by a transient network
                    // problem?
                    // We already know that this exception is not due to a deserialization
                    // issue as we already took care of that before involving the
                    // communicatorAdmin. Moreover - we already made one retry attempt
                    // at fetching the same batch of notifications - and the
                    // problem persisted.
                    // Since trying again doesn't seem to solve the issue, we will now
                    // close the connection. Doing otherwise might cause the
                    // NotifFetcher thread to die silently.
                    final Notification failedNotif =
                            new JMXConnectionNotification(
                            JMXConnectionNotification.FAILED,
                            this,
                            connectionId,
                            clientNotifSeqNo++,
                            "Failed to communicate with the server: " + ioe.toString(),
                            ioe);

                    sendNotification(failedNotif);

                    try {
                        close(true);
                    } catch (Exception e) {
                        // OK.
                        // We are closing
                    }
                    throw ioe; // the connection is closed here.
                } else {
                    // JDK-8049303 possible transient network problem,
                    // let's try one more time
                    retried = true;
                }
            }
        }
    }
}
 
Example 2
Source File: RMIConnector.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
@Override
public void gotIOException(IOException ioe) throws IOException {
    if (ioe instanceof NoSuchObjectException) {
        // need to restart
        super.gotIOException(ioe);

        return;
    }

    // check if the connection is broken
    try {
        connection.getDefaultDomain(null);
    } catch (IOException ioexc) {
        boolean toClose = false;

        synchronized(this) {
            if (!terminated) {
                terminated = true;

                toClose = true;
            }
        }

        if (toClose) {
            // we should close the connection,
            // but send a failed notif at first
            final Notification failedNotif =
                    new JMXConnectionNotification(
                    JMXConnectionNotification.FAILED,
                    this,
                    connectionId,
                    clientNotifSeqNo++,
                    "Failed to communicate with the server: "+ioe.toString(),
                    ioe);

            sendNotification(failedNotif);

            try {
                close(true);
            } catch (Exception e) {
                // OK.
                // We are closing
            }
        }
    }

    // forward the exception
    if (ioe instanceof ServerException) {
        /* Need to unwrap the exception.
           Some user-thrown exception at server side will be wrapped by
           rmi into a ServerException.
           For example, a RMIConnnectorServer will wrap a
           ClassNotFoundException into a UnmarshalException, and rmi
           will throw a ServerException at client side which wraps this
           UnmarshalException.
           No failed notif here.
         */
        Throwable tt = ((ServerException)ioe).detail;

        if (tt instanceof IOException) {
            throw (IOException)tt;
        } else if (tt instanceof RuntimeException) {
            throw (RuntimeException)tt;
        }
    }

    throw ioe;
}
 
Example 3
Source File: RMIConnector.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
protected NotificationResult fetchNotifs(long clientSequenceNumber,
        int maxNotifications,
        long timeout)
        throws IOException, ClassNotFoundException {

    boolean retried = false;
    while (true) { // used for a successful re-connection
                   // or a transient network problem
        try {
            return connection.fetchNotifications(clientSequenceNumber,
                    maxNotifications,
                    timeout); // return normally
        } catch (IOException ioe) {
            // Examine the chain of exceptions to determine whether this
            // is a deserialization issue. If so - we propagate the
            // appropriate exception to the caller, who will then
            // proceed with fetching notifications one by one
            rethrowDeserializationException(ioe);

            try {
                communicatorAdmin.gotIOException(ioe);
                // reconnection OK, back to "while" to do again
            } catch (IOException ee) {
                boolean toClose = false;

                synchronized (this) {
                    if (terminated) {
                        // the connection is closed.
                        throw ioe;
                    } else if (retried) {
                        toClose = true;
                    }
                }

                if (toClose) {
                    // JDK-8049303
                    // We received an IOException - but the communicatorAdmin
                    // did not close the connection - possibly because
                    // the original exception was raised by a transient network
                    // problem?
                    // We already know that this exception is not due to a deserialization
                    // issue as we already took care of that before involving the
                    // communicatorAdmin. Moreover - we already made one retry attempt
                    // at fetching the same batch of notifications - and the
                    // problem persisted.
                    // Since trying again doesn't seem to solve the issue, we will now
                    // close the connection. Doing otherwise might cause the
                    // NotifFetcher thread to die silently.
                    final Notification failedNotif =
                            new JMXConnectionNotification(
                            JMXConnectionNotification.FAILED,
                            this,
                            connectionId,
                            clientNotifSeqNo++,
                            "Failed to communicate with the server: " + ioe.toString(),
                            ioe);

                    sendNotification(failedNotif);

                    try {
                        close(true);
                    } catch (Exception e) {
                        // OK.
                        // We are closing
                    }
                    throw ioe; // the connection is closed here.
                } else {
                    // JDK-8049303 possible transient network problem,
                    // let's try one more time
                    retried = true;
                }
            }
        }
    }
}
 
Example 4
Source File: RMIConnector.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void gotIOException(IOException ioe) throws IOException {
    if (ioe instanceof NoSuchObjectException) {
        // need to restart
        super.gotIOException(ioe);

        return;
    }

    // check if the connection is broken
    try {
        connection.getDefaultDomain(null);
    } catch (IOException ioexc) {
        boolean toClose = false;

        synchronized(this) {
            if (!terminated) {
                terminated = true;

                toClose = true;
            }
        }

        if (toClose) {
            // we should close the connection,
            // but send a failed notif at first
            final Notification failedNotif =
                    new JMXConnectionNotification(
                    JMXConnectionNotification.FAILED,
                    this,
                    connectionId,
                    clientNotifSeqNo++,
                    "Failed to communicate with the server: "+ioe.toString(),
                    ioe);

            sendNotification(failedNotif);

            try {
                close(true);
            } catch (Exception e) {
                // OK.
                // We are closing
            }
        }
    }

    // forward the exception
    if (ioe instanceof ServerException) {
        /* Need to unwrap the exception.
           Some user-thrown exception at server side will be wrapped by
           rmi into a ServerException.
           For example, a RMIConnnectorServer will wrap a
           ClassNotFoundException into a UnmarshalException, and rmi
           will throw a ServerException at client side which wraps this
           UnmarshalException.
           No failed notif here.
         */
        Throwable tt = ((ServerException)ioe).detail;

        if (tt instanceof IOException) {
            throw (IOException)tt;
        } else if (tt instanceof RuntimeException) {
            throw (RuntimeException)tt;
        }
    }

    throw ioe;
}
 
Example 5
Source File: RMIConnector.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected NotificationResult fetchNotifs(long clientSequenceNumber,
        int maxNotifications,
        long timeout)
        throws IOException, ClassNotFoundException {

    boolean retried = false;
    while (true) { // used for a successful re-connection
                   // or a transient network problem
        try {
            return connection.fetchNotifications(clientSequenceNumber,
                    maxNotifications,
                    timeout); // return normally
        } catch (IOException ioe) {
            // Examine the chain of exceptions to determine whether this
            // is a deserialization issue. If so - we propagate the
            // appropriate exception to the caller, who will then
            // proceed with fetching notifications one by one
            rethrowDeserializationException(ioe);

            try {
                communicatorAdmin.gotIOException(ioe);
                // reconnection OK, back to "while" to do again
            } catch (IOException ee) {
                boolean toClose = false;

                synchronized (this) {
                    if (terminated) {
                        // the connection is closed.
                        throw ioe;
                    } else if (retried) {
                        toClose = true;
                    }
                }

                if (toClose) {
                    // JDK-8049303
                    // We received an IOException - but the communicatorAdmin
                    // did not close the connection - possibly because
                    // the original exception was raised by a transient network
                    // problem?
                    // We already know that this exception is not due to a deserialization
                    // issue as we already took care of that before involving the
                    // communicatorAdmin. Moreover - we already made one retry attempt
                    // at fetching the same batch of notifications - and the
                    // problem persisted.
                    // Since trying again doesn't seem to solve the issue, we will now
                    // close the connection. Doing otherwise might cause the
                    // NotifFetcher thread to die silently.
                    final Notification failedNotif =
                            new JMXConnectionNotification(
                            JMXConnectionNotification.FAILED,
                            this,
                            connectionId,
                            clientNotifSeqNo++,
                            "Failed to communicate with the server: " + ioe.toString(),
                            ioe);

                    sendNotification(failedNotif);

                    try {
                        close(true);
                    } catch (Exception e) {
                        // OK.
                        // We are closing
                    }
                    throw ioe; // the connection is closed here.
                } else {
                    // JDK-8049303 possible transient network problem,
                    // let's try one more time
                    retried = true;
                }
            }
        }
    }
}
 
Example 6
Source File: RMIConnector.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void gotIOException(IOException ioe) throws IOException {
    if (ioe instanceof NoSuchObjectException) {
        // need to restart
        super.gotIOException(ioe);

        return;
    }

    // check if the connection is broken
    try {
        connection.getDefaultDomain(null);
    } catch (IOException ioexc) {
        boolean toClose = false;

        synchronized(this) {
            if (!terminated) {
                terminated = true;

                toClose = true;
            }
        }

        if (toClose) {
            // we should close the connection,
            // but send a failed notif at first
            final Notification failedNotif =
                    new JMXConnectionNotification(
                    JMXConnectionNotification.FAILED,
                    this,
                    connectionId,
                    clientNotifSeqNo++,
                    "Failed to communicate with the server: "+ioe.toString(),
                    ioe);

            sendNotification(failedNotif);

            try {
                close(true);
            } catch (Exception e) {
                // OK.
                // We are closing
            }
        }
    }

    // forward the exception
    if (ioe instanceof ServerException) {
        /* Need to unwrap the exception.
           Some user-thrown exception at server side will be wrapped by
           rmi into a ServerException.
           For example, a RMIConnnectorServer will wrap a
           ClassNotFoundException into a UnmarshalException, and rmi
           will throw a ServerException at client side which wraps this
           UnmarshalException.
           No failed notif here.
         */
        Throwable tt = ((ServerException)ioe).detail;

        if (tt instanceof IOException) {
            throw (IOException)tt;
        } else if (tt instanceof RuntimeException) {
            throw (RuntimeException)tt;
        }
    }

    throw ioe;
}
 
Example 7
Source File: RMIConnector.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
protected NotificationResult fetchNotifs(long clientSequenceNumber,
        int maxNotifications,
        long timeout)
        throws IOException, ClassNotFoundException {

    boolean retried = false;
    while (true) { // used for a successful re-connection
                   // or a transient network problem
        try {
            return connection.fetchNotifications(clientSequenceNumber,
                    maxNotifications,
                    timeout); // return normally
        } catch (IOException ioe) {
            // Examine the chain of exceptions to determine whether this
            // is a deserialization issue. If so - we propagate the
            // appropriate exception to the caller, who will then
            // proceed with fetching notifications one by one
            rethrowDeserializationException(ioe);

            try {
                communicatorAdmin.gotIOException(ioe);
                // reconnection OK, back to "while" to do again
            } catch (IOException ee) {
                boolean toClose = false;

                synchronized (this) {
                    if (terminated) {
                        // the connection is closed.
                        throw ioe;
                    } else if (retried) {
                        toClose = true;
                    }
                }

                if (toClose) {
                    // JDK-8049303
                    // We received an IOException - but the communicatorAdmin
                    // did not close the connection - possibly because
                    // the original exception was raised by a transient network
                    // problem?
                    // We already know that this exception is not due to a deserialization
                    // issue as we already took care of that before involving the
                    // communicatorAdmin. Moreover - we already made one retry attempt
                    // at fetching the same batch of notifications - and the
                    // problem persisted.
                    // Since trying again doesn't seem to solve the issue, we will now
                    // close the connection. Doing otherwise might cause the
                    // NotifFetcher thread to die silently.
                    final Notification failedNotif =
                            new JMXConnectionNotification(
                            JMXConnectionNotification.FAILED,
                            this,
                            connectionId,
                            clientNotifSeqNo++,
                            "Failed to communicate with the server: " + ioe.toString(),
                            ioe);

                    sendNotification(failedNotif);

                    try {
                        close(true);
                    } catch (Exception e) {
                        // OK.
                        // We are closing
                    }
                    throw ioe; // the connection is closed here.
                } else {
                    // JDK-8049303 possible transient network problem,
                    // let's try one more time
                    retried = true;
                }
            }
        }
    }
}
 
Example 8
Source File: RMIConnector.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void gotIOException(IOException ioe) throws IOException {
    if (ioe instanceof NoSuchObjectException) {
        // need to restart
        super.gotIOException(ioe);

        return;
    }

    // check if the connection is broken
    try {
        connection.getDefaultDomain(null);
    } catch (IOException ioexc) {
        boolean toClose = false;

        synchronized(this) {
            if (!terminated) {
                terminated = true;

                toClose = true;
            }
        }

        if (toClose) {
            // we should close the connection,
            // but send a failed notif at first
            final Notification failedNotif =
                    new JMXConnectionNotification(
                    JMXConnectionNotification.FAILED,
                    this,
                    connectionId,
                    clientNotifSeqNo++,
                    "Failed to communicate with the server: "+ioe.toString(),
                    ioe);

            sendNotification(failedNotif);

            try {
                close(true);
            } catch (Exception e) {
                // OK.
                // We are closing
            }
        }
    }

    // forward the exception
    if (ioe instanceof ServerException) {
        /* Need to unwrap the exception.
           Some user-thrown exception at server side will be wrapped by
           rmi into a ServerException.
           For example, a RMIConnnectorServer will wrap a
           ClassNotFoundException into a UnmarshalException, and rmi
           will throw a ServerException at client side which wraps this
           UnmarshalException.
           No failed notif here.
         */
        Throwable tt = ((ServerException)ioe).detail;

        if (tt instanceof IOException) {
            throw (IOException)tt;
        } else if (tt instanceof RuntimeException) {
            throw (RuntimeException)tt;
        }
    }

    throw ioe;
}
 
Example 9
Source File: RMIConnector.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
protected NotificationResult fetchNotifs(long clientSequenceNumber,
        int maxNotifications,
        long timeout)
        throws IOException, ClassNotFoundException {

    boolean retried = false;
    while (true) { // used for a successful re-connection
                   // or a transient network problem
        try {
            return connection.fetchNotifications(clientSequenceNumber,
                    maxNotifications,
                    timeout); // return normally
        } catch (IOException ioe) {
            // Examine the chain of exceptions to determine whether this
            // is a deserialization issue. If so - we propagate the
            // appropriate exception to the caller, who will then
            // proceed with fetching notifications one by one
            rethrowDeserializationException(ioe);

            try {
                communicatorAdmin.gotIOException(ioe);
                // reconnection OK, back to "while" to do again
            } catch (IOException ee) {
                boolean toClose = false;

                synchronized (this) {
                    if (terminated) {
                        // the connection is closed.
                        throw ioe;
                    } else if (retried) {
                        toClose = true;
                    }
                }

                if (toClose) {
                    // JDK-8049303
                    // We received an IOException - but the communicatorAdmin
                    // did not close the connection - possibly because
                    // the original exception was raised by a transient network
                    // problem?
                    // We already know that this exception is not due to a deserialization
                    // issue as we already took care of that before involving the
                    // communicatorAdmin. Moreover - we already made one retry attempt
                    // at fetching the same batch of notifications - and the
                    // problem persisted.
                    // Since trying again doesn't seem to solve the issue, we will now
                    // close the connection. Doing otherwise might cause the
                    // NotifFetcher thread to die silently.
                    final Notification failedNotif =
                            new JMXConnectionNotification(
                            JMXConnectionNotification.FAILED,
                            this,
                            connectionId,
                            clientNotifSeqNo++,
                            "Failed to communicate with the server: " + ioe.toString(),
                            ioe);

                    sendNotification(failedNotif);

                    try {
                        close(true);
                    } catch (Exception e) {
                        // OK.
                        // We are closing
                    }
                    throw ioe; // the connection is closed here.
                } else {
                    // JDK-8049303 possible transient network problem,
                    // let's try one more time
                    retried = true;
                }
            }
        }
    }
}
 
Example 10
Source File: RMIConnector.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void gotIOException(IOException ioe) throws IOException {
    if (ioe instanceof NoSuchObjectException) {
        // need to restart
        super.gotIOException(ioe);

        return;
    }

    // check if the connection is broken
    try {
        connection.getDefaultDomain(null);
    } catch (IOException ioexc) {
        boolean toClose = false;

        synchronized(this) {
            if (!terminated) {
                terminated = true;

                toClose = true;
            }
        }

        if (toClose) {
            // we should close the connection,
            // but send a failed notif at first
            final Notification failedNotif =
                    new JMXConnectionNotification(
                    JMXConnectionNotification.FAILED,
                    this,
                    connectionId,
                    clientNotifSeqNo++,
                    "Failed to communicate with the server: "+ioe.toString(),
                    ioe);

            sendNotification(failedNotif);

            try {
                close(true);
            } catch (Exception e) {
                // OK.
                // We are closing
            }
        }
    }

    // forward the exception
    if (ioe instanceof ServerException) {
        /* Need to unwrap the exception.
           Some user-thrown exception at server side will be wrapped by
           rmi into a ServerException.
           For example, a RMIConnnectorServer will wrap a
           ClassNotFoundException into a UnmarshalException, and rmi
           will throw a ServerException at client side which wraps this
           UnmarshalException.
           No failed notif here.
         */
        Throwable tt = ((ServerException)ioe).detail;

        if (tt instanceof IOException) {
            throw (IOException)tt;
        } else if (tt instanceof RuntimeException) {
            throw (RuntimeException)tt;
        }
    }

    throw ioe;
}
 
Example 11
Source File: RMIConnector.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
protected NotificationResult fetchNotifs(long clientSequenceNumber,
        int maxNotifications,
        long timeout)
        throws IOException, ClassNotFoundException {

    boolean retried = false;
    while (true) { // used for a successful re-connection
                   // or a transient network problem
        try {
            return connection.fetchNotifications(clientSequenceNumber,
                    maxNotifications,
                    timeout); // return normally
        } catch (IOException ioe) {
            // Examine the chain of exceptions to determine whether this
            // is a deserialization issue. If so - we propagate the
            // appropriate exception to the caller, who will then
            // proceed with fetching notifications one by one
            rethrowDeserializationException(ioe);

            try {
                communicatorAdmin.gotIOException(ioe);
                // reconnection OK, back to "while" to do again
            } catch (IOException ee) {
                boolean toClose = false;

                synchronized (this) {
                    if (terminated) {
                        // the connection is closed.
                        throw ioe;
                    } else if (retried) {
                        toClose = true;
                    }
                }

                if (toClose) {
                    // JDK-8049303
                    // We received an IOException - but the communicatorAdmin
                    // did not close the connection - possibly because
                    // the original exception was raised by a transient network
                    // problem?
                    // We already know that this exception is not due to a deserialization
                    // issue as we already took care of that before involving the
                    // communicatorAdmin. Moreover - we already made one retry attempt
                    // at fetching the same batch of notifications - and the
                    // problem persisted.
                    // Since trying again doesn't seem to solve the issue, we will now
                    // close the connection. Doing otherwise might cause the
                    // NotifFetcher thread to die silently.
                    final Notification failedNotif =
                            new JMXConnectionNotification(
                            JMXConnectionNotification.FAILED,
                            this,
                            connectionId,
                            clientNotifSeqNo++,
                            "Failed to communicate with the server: " + ioe.toString(),
                            ioe);

                    sendNotification(failedNotif);

                    try {
                        close(true);
                    } catch (Exception e) {
                        // OK.
                        // We are closing
                    }
                    throw ioe; // the connection is closed here.
                } else {
                    // JDK-8049303 possible transient network problem,
                    // let's try one more time
                    retried = true;
                }
            }
        }
    }
}
 
Example 12
Source File: RMIConnector.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
protected NotificationResult fetchNotifs(long clientSequenceNumber,
        int maxNotifications,
        long timeout)
        throws IOException, ClassNotFoundException {

    boolean retried = false;
    while (true) { // used for a successful re-connection
                   // or a transient network problem
        try {
            return connection.fetchNotifications(clientSequenceNumber,
                    maxNotifications,
                    timeout); // return normally
        } catch (IOException ioe) {
            // Examine the chain of exceptions to determine whether this
            // is a deserialization issue. If so - we propagate the
            // appropriate exception to the caller, who will then
            // proceed with fetching notifications one by one
            rethrowDeserializationException(ioe);

            try {
                communicatorAdmin.gotIOException(ioe);
                // reconnection OK, back to "while" to do again
            } catch (IOException ee) {
                boolean toClose = false;

                synchronized (this) {
                    if (terminated) {
                        // the connection is closed.
                        throw ioe;
                    } else if (retried) {
                        toClose = true;
                    }
                }

                if (toClose) {
                    // JDK-8049303
                    // We received an IOException - but the communicatorAdmin
                    // did not close the connection - possibly because
                    // the original exception was raised by a transient network
                    // problem?
                    // We already know that this exception is not due to a deserialization
                    // issue as we already took care of that before involving the
                    // communicatorAdmin. Moreover - we already made one retry attempt
                    // at fetching the same batch of notifications - and the
                    // problem persisted.
                    // Since trying again doesn't seem to solve the issue, we will now
                    // close the connection. Doing otherwise might cause the
                    // NotifFetcher thread to die silently.
                    final Notification failedNotif =
                            new JMXConnectionNotification(
                            JMXConnectionNotification.FAILED,
                            this,
                            connectionId,
                            clientNotifSeqNo++,
                            "Failed to communicate with the server: " + ioe.toString(),
                            ioe);

                    sendNotification(failedNotif);

                    try {
                        close(true);
                    } catch (Exception e) {
                        // OK.
                        // We are closing
                    }
                    throw ioe; // the connection is closed here.
                } else {
                    // JDK-8049303 possible transient network problem,
                    // let's try one more time
                    retried = true;
                }
            }
        }
    }
}
 
Example 13
Source File: RMIConnector.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
protected NotificationResult fetchNotifs(long clientSequenceNumber,
        int maxNotifications,
        long timeout)
        throws IOException, ClassNotFoundException {

    boolean retried = false;
    while (true) { // used for a successful re-connection
                   // or a transient network problem
        try {
            return connection.fetchNotifications(clientSequenceNumber,
                    maxNotifications,
                    timeout); // return normally
        } catch (IOException ioe) {
            // Examine the chain of exceptions to determine whether this
            // is a deserialization issue. If so - we propagate the
            // appropriate exception to the caller, who will then
            // proceed with fetching notifications one by one
            rethrowDeserializationException(ioe);

            try {
                communicatorAdmin.gotIOException(ioe);
                // reconnection OK, back to "while" to do again
            } catch (IOException ee) {
                boolean toClose = false;

                synchronized (this) {
                    if (terminated) {
                        // the connection is closed.
                        throw ioe;
                    } else if (retried) {
                        toClose = true;
                    }
                }

                if (toClose) {
                    // JDK-8049303
                    // We received an IOException - but the communicatorAdmin
                    // did not close the connection - possibly because
                    // the original exception was raised by a transient network
                    // problem?
                    // We already know that this exception is not due to a deserialization
                    // issue as we already took care of that before involving the
                    // communicatorAdmin. Moreover - we already made one retry attempt
                    // at fetching the same batch of notifications - and the
                    // problem persisted.
                    // Since trying again doesn't seem to solve the issue, we will now
                    // close the connection. Doing otherwise might cause the
                    // NotifFetcher thread to die silently.
                    final Notification failedNotif =
                            new JMXConnectionNotification(
                            JMXConnectionNotification.FAILED,
                            this,
                            connectionId,
                            clientNotifSeqNo++,
                            "Failed to communicate with the server: " + ioe.toString(),
                            ioe);

                    sendNotification(failedNotif);

                    try {
                        close(true);
                    } catch (Exception e) {
                        // OK.
                        // We are closing
                    }
                    throw ioe; // the connection is closed here.
                } else {
                    // JDK-8049303 possible transient network problem,
                    // let's try one more time
                    retried = true;
                }
            }
        }
    }
}
 
Example 14
Source File: RMIConnector.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void gotIOException(IOException ioe) throws IOException {
    if (ioe instanceof NoSuchObjectException) {
        // need to restart
        super.gotIOException(ioe);

        return;
    }

    // check if the connection is broken
    try {
        connection.getDefaultDomain(null);
    } catch (IOException ioexc) {
        boolean toClose = false;

        synchronized(this) {
            if (!terminated) {
                terminated = true;

                toClose = true;
            }
        }

        if (toClose) {
            // we should close the connection,
            // but send a failed notif at first
            final Notification failedNotif =
                    new JMXConnectionNotification(
                    JMXConnectionNotification.FAILED,
                    this,
                    connectionId,
                    clientNotifSeqNo++,
                    "Failed to communicate with the server: "+ioe.toString(),
                    ioe);

            sendNotification(failedNotif);

            try {
                close(true);
            } catch (Exception e) {
                // OK.
                // We are closing
            }
        }
    }

    // forward the exception
    if (ioe instanceof ServerException) {
        /* Need to unwrap the exception.
           Some user-thrown exception at server side will be wrapped by
           rmi into a ServerException.
           For example, a RMIConnnectorServer will wrap a
           ClassNotFoundException into a UnmarshalException, and rmi
           will throw a ServerException at client side which wraps this
           UnmarshalException.
           No failed notif here.
         */
        Throwable tt = ((ServerException)ioe).detail;

        if (tt instanceof IOException) {
            throw (IOException)tt;
        } else if (tt instanceof RuntimeException) {
            throw (RuntimeException)tt;
        }
    }

    throw ioe;
}
 
Example 15
Source File: RMIConnector.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void gotIOException(IOException ioe) throws IOException {
    if (ioe instanceof NoSuchObjectException) {
        // need to restart
        super.gotIOException(ioe);

        return;
    }

    // check if the connection is broken
    try {
        connection.getDefaultDomain(null);
    } catch (IOException ioexc) {
        boolean toClose = false;

        synchronized(this) {
            if (!terminated) {
                terminated = true;

                toClose = true;
            }
        }

        if (toClose) {
            // we should close the connection,
            // but send a failed notif at first
            final Notification failedNotif =
                    new JMXConnectionNotification(
                    JMXConnectionNotification.FAILED,
                    this,
                    connectionId,
                    clientNotifSeqNo++,
                    "Failed to communicate with the server: "+ioe.toString(),
                    ioe);

            sendNotification(failedNotif);

            try {
                close(true);
            } catch (Exception e) {
                // OK.
                // We are closing
            }
        }
    }

    // forward the exception
    if (ioe instanceof ServerException) {
        /* Need to unwrap the exception.
           Some user-thrown exception at server side will be wrapped by
           rmi into a ServerException.
           For example, a RMIConnnectorServer will wrap a
           ClassNotFoundException into a UnmarshalException, and rmi
           will throw a ServerException at client side which wraps this
           UnmarshalException.
           No failed notif here.
         */
        Throwable tt = ((ServerException)ioe).detail;

        if (tt instanceof IOException) {
            throw (IOException)tt;
        } else if (tt instanceof RuntimeException) {
            throw (RuntimeException)tt;
        }
    }

    throw ioe;
}
 
Example 16
Source File: RMIConnector.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void gotIOException(IOException ioe) throws IOException {
    if (ioe instanceof NoSuchObjectException) {
        // need to restart
        super.gotIOException(ioe);

        return;
    }

    // check if the connection is broken
    try {
        connection.getDefaultDomain(null);
    } catch (IOException ioexc) {
        boolean toClose = false;

        synchronized(this) {
            if (!terminated) {
                terminated = true;

                toClose = true;
            }
        }

        if (toClose) {
            // we should close the connection,
            // but send a failed notif at first
            final Notification failedNotif =
                    new JMXConnectionNotification(
                    JMXConnectionNotification.FAILED,
                    this,
                    connectionId,
                    clientNotifSeqNo++,
                    "Failed to communicate with the server: "+ioe.toString(),
                    ioe);

            sendNotification(failedNotif);

            try {
                close(true);
            } catch (Exception e) {
                // OK.
                // We are closing
            }
        }
    }

    // forward the exception
    if (ioe instanceof ServerException) {
        /* Need to unwrap the exception.
           Some user-thrown exception at server side will be wrapped by
           rmi into a ServerException.
           For example, a RMIConnnectorServer will wrap a
           ClassNotFoundException into a UnmarshalException, and rmi
           will throw a ServerException at client side which wraps this
           UnmarshalException.
           No failed notif here.
         */
        Throwable tt = ((ServerException)ioe).detail;

        if (tt instanceof IOException) {
            throw (IOException)tt;
        } else if (tt instanceof RuntimeException) {
            throw (RuntimeException)tt;
        }
    }

    throw ioe;
}
 
Example 17
Source File: RMIConnector.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void gotIOException(IOException ioe) throws IOException {
    if (ioe instanceof NoSuchObjectException) {
        // need to restart
        super.gotIOException(ioe);

        return;
    }

    // check if the connection is broken
    try {
        connection.getDefaultDomain(null);
    } catch (IOException ioexc) {
        boolean toClose = false;

        synchronized(this) {
            if (!terminated) {
                terminated = true;

                toClose = true;
            }
        }

        if (toClose) {
            // we should close the connection,
            // but send a failed notif at first
            final Notification failedNotif =
                    new JMXConnectionNotification(
                    JMXConnectionNotification.FAILED,
                    this,
                    connectionId,
                    clientNotifSeqNo++,
                    "Failed to communicate with the server: "+ioe.toString(),
                    ioe);

            sendNotification(failedNotif);

            try {
                close(true);
            } catch (Exception e) {
                // OK.
                // We are closing
            }
        }
    }

    // forward the exception
    if (ioe instanceof ServerException) {
        /* Need to unwrap the exception.
           Some user-thrown exception at server side will be wrapped by
           rmi into a ServerException.
           For example, a RMIConnnectorServer will wrap a
           ClassNotFoundException into a UnmarshalException, and rmi
           will throw a ServerException at client side which wraps this
           UnmarshalException.
           No failed notif here.
         */
        Throwable tt = ((ServerException)ioe).detail;

        if (tt instanceof IOException) {
            throw (IOException)tt;
        } else if (tt instanceof RuntimeException) {
            throw (RuntimeException)tt;
        }
    }

    throw ioe;
}
 
Example 18
Source File: RMIConnector.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void gotIOException(IOException ioe) throws IOException {
    if (ioe instanceof NoSuchObjectException) {
        // need to restart
        super.gotIOException(ioe);

        return;
    }

    // check if the connection is broken
    try {
        connection.getDefaultDomain(null);
    } catch (IOException ioexc) {
        boolean toClose = false;

        synchronized(this) {
            if (!terminated) {
                terminated = true;

                toClose = true;
            }
        }

        if (toClose) {
            // we should close the connection,
            // but send a failed notif at first
            final Notification failedNotif =
                    new JMXConnectionNotification(
                    JMXConnectionNotification.FAILED,
                    this,
                    connectionId,
                    clientNotifSeqNo++,
                    "Failed to communicate with the server: "+ioe.toString(),
                    ioe);

            sendNotification(failedNotif);

            try {
                close(true);
            } catch (Exception e) {
                // OK.
                // We are closing
            }
        }
    }

    // forward the exception
    if (ioe instanceof ServerException) {
        /* Need to unwrap the exception.
           Some user-thrown exception at server side will be wrapped by
           rmi into a ServerException.
           For example, a RMIConnnectorServer will wrap a
           ClassNotFoundException into a UnmarshalException, and rmi
           will throw a ServerException at client side which wraps this
           UnmarshalException.
           No failed notif here.
         */
        Throwable tt = ((ServerException)ioe).detail;

        if (tt instanceof IOException) {
            throw (IOException)tt;
        } else if (tt instanceof RuntimeException) {
            throw (RuntimeException)tt;
        }
    }

    throw ioe;
}
 
Example 19
Source File: RMIConnector.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
protected NotificationResult fetchNotifs(long clientSequenceNumber,
        int maxNotifications,
        long timeout)
        throws IOException, ClassNotFoundException {

    boolean retried = false;
    while (true) { // used for a successful re-connection
                   // or a transient network problem
        try {
            return connection.fetchNotifications(clientSequenceNumber,
                    maxNotifications,
                    timeout); // return normally
        } catch (IOException ioe) {
            // Examine the chain of exceptions to determine whether this
            // is a deserialization issue. If so - we propagate the
            // appropriate exception to the caller, who will then
            // proceed with fetching notifications one by one
            rethrowDeserializationException(ioe);

            try {
                communicatorAdmin.gotIOException(ioe);
                // reconnection OK, back to "while" to do again
            } catch (IOException ee) {
                boolean toClose = false;

                synchronized (this) {
                    if (terminated) {
                        // the connection is closed.
                        throw ioe;
                    } else if (retried) {
                        toClose = true;
                    }
                }

                if (toClose) {
                    // JDK-8049303
                    // We received an IOException - but the communicatorAdmin
                    // did not close the connection - possibly because
                    // the original exception was raised by a transient network
                    // problem?
                    // We already know that this exception is not due to a deserialization
                    // issue as we already took care of that before involving the
                    // communicatorAdmin. Moreover - we already made one retry attempt
                    // at fetching the same batch of notifications - and the
                    // problem persisted.
                    // Since trying again doesn't seem to solve the issue, we will now
                    // close the connection. Doing otherwise might cause the
                    // NotifFetcher thread to die silently.
                    final Notification failedNotif =
                            new JMXConnectionNotification(
                            JMXConnectionNotification.FAILED,
                            this,
                            connectionId,
                            clientNotifSeqNo++,
                            "Failed to communicate with the server: " + ioe.toString(),
                            ioe);

                    sendNotification(failedNotif);

                    try {
                        close(true);
                    } catch (Exception e) {
                        // OK.
                        // We are closing
                    }
                    throw ioe; // the connection is closed here.
                } else {
                    // JDK-8049303 possible transient network problem,
                    // let's try one more time
                    retried = true;
                }
            }
        }
    }
}
 
Example 20
Source File: RMIConnector.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
@Override
public void gotIOException(IOException ioe) throws IOException {
    if (ioe instanceof NoSuchObjectException) {
        // need to restart
        super.gotIOException(ioe);

        return;
    }

    // check if the connection is broken
    try {
        connection.getDefaultDomain(null);
    } catch (IOException ioexc) {
        boolean toClose = false;

        synchronized(this) {
            if (!terminated) {
                terminated = true;

                toClose = true;
            }
        }

        if (toClose) {
            // we should close the connection,
            // but send a failed notif at first
            final Notification failedNotif =
                    new JMXConnectionNotification(
                    JMXConnectionNotification.FAILED,
                    this,
                    connectionId,
                    clientNotifSeqNo++,
                    "Failed to communicate with the server: "+ioe.toString(),
                    ioe);

            sendNotification(failedNotif);

            try {
                close(true);
            } catch (Exception e) {
                // OK.
                // We are closing
            }
        }
    }

    // forward the exception
    if (ioe instanceof ServerException) {
        /* Need to unwrap the exception.
           Some user-thrown exception at server side will be wrapped by
           rmi into a ServerException.
           For example, a RMIConnnectorServer will wrap a
           ClassNotFoundException into a UnmarshalException, and rmi
           will throw a ServerException at client side which wraps this
           UnmarshalException.
           No failed notif here.
         */
        Throwable tt = ((ServerException)ioe).detail;

        if (tt instanceof IOException) {
            throw (IOException)tt;
        } else if (tt instanceof RuntimeException) {
            throw (RuntimeException)tt;
        }
    }

    throw ioe;
}