Search in sources :

Example 1 with ClusterMetaData

use of org.apache.openejb.client.ClusterMetaData in project tomee by apache.

the class ClusterRequestHandler method processRequest.

@Override
public ClusterResponse processRequest(final ObjectInputStream in, final ProtocolMetaData metaData) throws Exception {
    final ClusterRequest req = new ClusterRequest();
    req.setMetaData(metaData);
    final ClusterResponse res = new ClusterResponse();
    res.setMetaData(metaData);
    try {
        req.readExternal(in);
    } catch (IOException e) {
        res.setFailure(e);
        return res;
    } catch (ClassNotFoundException e) {
        res.setFailure(new IOException().initCause(e));
        return res;
    }
    final ClusterMetaData currentClusterMetaData = data.current();
    if (req.getClusterMetaDataVersion() < currentClusterMetaData.getVersion()) {
        if (logger.isDebugEnabled()) {
            final URI[] locations = currentClusterMetaData.getLocations();
            if (locations.length < 10) {
                logger.debug("Sending client updated cluster locations: [" + Join.join(", ", locations) + "]");
            } else {
                logger.debug("Sending client updated cluster locations: " + locations.length + " locations total");
            }
        }
        res.setUpdatedMetaData(currentClusterMetaData);
    } else {
        res.setCurrent();
    }
    return res;
}
Also used : ClusterMetaData(org.apache.openejb.client.ClusterMetaData) ClusterRequest(org.apache.openejb.client.ClusterRequest) ClusterResponse(org.apache.openejb.client.ClusterResponse) IOException(java.io.IOException) URI(java.net.URI)

Aggregations

IOException (java.io.IOException)1 URI (java.net.URI)1 ClusterMetaData (org.apache.openejb.client.ClusterMetaData)1 ClusterRequest (org.apache.openejb.client.ClusterRequest)1 ClusterResponse (org.apache.openejb.client.ClusterResponse)1