}
public void processRequest(ObjectInputStream in, ObjectOutputStream out) throws IOException {
ClusterRequest req = new ClusterRequest();
ClusterResponse res = new ClusterResponse();
try {
req.readExternal(in);
} catch (IOException e) {
res.setFailure(e);
sendErrorResponse("Cannot read ClusterRequest", e, res, out);
throw e;
} catch (ClassNotFoundException e) {
res.setFailure(e);
sendErrorResponse("Cannot read ClusterRequest", e, res, out);
throw (IOException) new IOException().initCause(e);
}
ClusterMetaData currentClusterMetaData = data.current();
if (req.getClusterMetaDataVersion() < currentClusterMetaData.getVersion()){
if (logger.isDebugEnabled()) {
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();
}
try {
res.writeExternal(out);
} catch (IOException e) {
logger.error("Failed to write to ClusterResponse", e);
throw e;
}
}