Example usage for java.rmi UnmarshalException getMessage

List of usage examples for java.rmi UnmarshalException getMessage

Introduction

In this page you can find the example usage for java.rmi UnmarshalException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message, including the message from the cause, if any, of this exception.

Usage

From source file:net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator.java

/**
 * Gets called once per {@link #asynchronousReplicationInterval}.
 * <p/>//w w  w.java 2  s. c  o m
 * Sends accumulated messages in bulk to each peer. i.e. if ther are 100 messages and 1 peer,
 * 1 RMI invocation results, not 100. Also, if a peer is unavailable this is discovered in only 1 try.
 * <p/>
 * Makes a copy of the queue so as not to hold up the enqueue operations.
 * <p/>
 * Any exceptions are caught so that the replication thread does not die, and because errors are expected,
 * due to peers becoming unavailable.
 * <p/>
 * This method issues warnings for problems that can be fixed with configuration changes.
 */
private void flushReplicationQueue() {
    List replicationQueueCopy;
    synchronized (replicationQueue) {
        if (replicationQueue.size() == 0) {
            return;
        }

        replicationQueueCopy = new ArrayList(replicationQueue);
        replicationQueue.clear();
    }

    Ehcache cache = ((CacheEventMessage) replicationQueueCopy.get(0)).cache;
    List cachePeers = listRemoteCachePeers(cache);

    List resolvedEventMessages = extractAndResolveEventMessages(replicationQueueCopy);

    for (int j = 0; j < cachePeers.size(); j++) {
        CachePeer cachePeer = (CachePeer) cachePeers.get(j);
        try {
            cachePeer.send(resolvedEventMessages);
        } catch (UnmarshalException e) {
            String message = e.getMessage();
            if (message.indexOf("Read time out") != 0) {
                LOG.warn("Unable to send message to remote peer due to socket read timeout. Consider increasing"
                        + " the socketTimeoutMillis setting in the cacheManagerPeerListenerFactory. "
                        + "Message was: " + e.getMessage());
            } else {
                LOG.debug("Unable to send message to remote peer.  Message was: " + e.getMessage());
            }
        } catch (Throwable t) {
            LOG.warn("Unable to send message to remote peer.  Message was: " + t.getMessage(), t);
        }
    }
    if (LOG.isWarnEnabled()) {
        int eventMessagesNotResolved = replicationQueueCopy.size() - resolvedEventMessages.size();
        if (eventMessagesNotResolved > 0) {
            LOG.warn(eventMessagesNotResolved + " messages were discarded on replicate due to reclamation of "
                    + "SoftReferences by the VM. Consider increasing the maximum heap size and/or setting the "
                    + "starting heap size to a higher value.");
        }

    }
}

From source file:net.sf.ehcache.distribution.jgroups.JGroupsCacheReplicator.java

/**
 * Gets called once per {@link #asynchronousReplicationInterval}. <p/>
 * Sends accumulated messages in bulk to each peer. i.e. if ther are 100
 * messages and 1 peer, 1 RMI invocation results, not 100. Also, if a peer
 * is unavailable this is discovered in only 1 try. <p/> Makes a copy of the
 * queue so as not to hold up the enqueue operations. <p/> Any exceptions
 * are caught so that the replication thread does not die, and because
 * errors are expected, due to peers becoming unavailable. <p/> This method
 * issues warnings for problems that can be fixed with configuration
 * changes.//from  www  .  j  a  va2 s  . c  o  m
 */
private void flushReplicationQueue() {
    List resolvedEventMessages;
    Ehcache cache;
    synchronized (replicationQueue) {
        if (replicationQueue.size() == 0) {
            return;
        }
        resolvedEventMessages = extractAndResolveEventMessages(replicationQueue);
        cache = ((JGroupEventMessage) replicationQueue.get(0)).getCache();
        replicationQueue.clear();
    }

    List cachePeers = listRemoteCachePeers(cache);

    for (int j = 0; j < cachePeers.size(); j++) {
        CachePeer cachePeer = (CachePeer) cachePeers.get(j);
        try {
            cachePeer.send(resolvedEventMessages);
        } catch (UnmarshalException e) {
            String message = e.getMessage();
            if (message.indexOf("Read time out") != 0) {
                LOG.warn("Unable to send message to remote peer due to socket read timeout. Consider increasing"
                        + " the socketTimeoutMillis setting in the cacheManagerPeerListenerFactory. "
                        + "Message was: " + e.getMessage());
            } else {
                LOG.debug("Unable to send message to remote peer.  Message was: " + e.getMessage());
            }
        } catch (Throwable t) {
            LOG.warn("Unable to send message to remote peer.  Message was: " + t.getMessage(), t);
        }
    }

}

From source file:com.googlecode.jmxtrans.model.Query.java

public Iterable<Result> fetchResults(MBeanServerConnection mbeanServer, ObjectName queryName)
        throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
    MBeanInfo info = mbeanServer.getMBeanInfo(queryName);
    ObjectInstance oi = mbeanServer.getObjectInstance(queryName);

    List<String> attributes;
    if (attr.isEmpty()) {
        attributes = new ArrayList<>();
        for (MBeanAttributeInfo attrInfo : info.getAttributes()) {
            attributes.add(attrInfo.getName());
        }//from  ww  w.  j ava 2  s. c  o m
    } else {
        attributes = attr;
    }

    try {
        if (!attributes.isEmpty()) {
            logger.debug("Executing queryName [{}] from query [{}]", queryName.getCanonicalName(), this);

            AttributeList al = mbeanServer.getAttributes(queryName,
                    attributes.toArray(new String[attributes.size()]));

            return new JmxResultProcessor(this, oi, al.asList(), info.getClassName(), queryName.getDomain())
                    .getResults();
        }
    } catch (UnmarshalException ue) {
        if ((ue.getCause() != null) && (ue.getCause() instanceof ClassNotFoundException)) {
            logger.debug("Bad unmarshall, continuing. This is probably ok and due to something like this: "
                    + "http://ehcache.org/xref/net/sf/ehcache/distribution/RMICacheManagerPeerListener.html#52",
                    ue.getMessage());
        } else {
            throw ue;
        }
    }
    return ImmutableList.of();
}