下面列出了javax.management.remote.JMXConnectionNotification#FAILED 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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;
}
}
}
}
}
@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;
}
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;
}
}
}
}
}
@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;
}
@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;
}
@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;
}
@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;
}
@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;
}
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;
}
}
}
}
}
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;
}
}
}
}
}
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;
}
}
}
}
}
@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;
}
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;
}
}
}
}
}
@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;
}
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;
}
}
}
}
}
@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;
}
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;
}
}
}
}
}
@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;
}
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;
}
}
}
}
}
@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;
}