javax.management.remote.JMXConnectionNotification#FAILED源码实例Demo

下面列出了javax.management.remote.JMXConnectionNotification#FAILED 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jdk1.8-source-analysis   文件: RMIConnector.java
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;
                }
            }
        }
    }
}
 
源代码2 项目: jdk1.8-source-analysis   文件: RMIConnector.java
@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;
}
 
源代码3 项目: dragonwell8_jdk   文件: RMIConnector.java
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;
                }
            }
        }
    }
}
 
源代码4 项目: dragonwell8_jdk   文件: RMIConnector.java
@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;
}
 
源代码5 项目: hottub   文件: RMIConnector.java
@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;
}
 
源代码6 项目: TencentKona-8   文件: RMIConnector.java
@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;
}
 
源代码7 项目: jdk8u_jdk   文件: RMIConnector.java
@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;
}
 
源代码8 项目: jdk8u60   文件: RMIConnector.java
@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;
}
 
源代码9 项目: JDKSourceCode1.8   文件: RMIConnector.java
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;
                }
            }
        }
    }
}
 
源代码10 项目: jdk8u_jdk   文件: RMIConnector.java
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;
                }
            }
        }
    }
}
 
源代码11 项目: jdk8u-jdk   文件: RMIConnector.java
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;
                }
            }
        }
    }
}
 
源代码12 项目: openjdk-jdk8u   文件: RMIConnector.java
@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;
}
 
源代码13 项目: openjdk-jdk8u-backup   文件: RMIConnector.java
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;
                }
            }
        }
    }
}
 
源代码14 项目: openjdk-8   文件: RMIConnector.java
@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;
}
 
源代码15 项目: openjdk-jdk9   文件: RMIConnector.java
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;
                }
            }
        }
    }
}
 
源代码16 项目: jdk8u-dev-jdk   文件: RMIConnector.java
@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;
}
 
源代码17 项目: jdk8u-jdk   文件: RMIConnector.java
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;
                }
            }
        }
    }
}
 
源代码18 项目: jdk8u-jdk   文件: RMIConnector.java
@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;
}
 
源代码19 项目: Java8CN   文件: RMIConnector.java
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;
                }
            }
        }
    }
}
 
源代码20 项目: Java8CN   文件: RMIConnector.java
@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;
}