use of org.platformlayer.cas.CasPickClosestStore in project platformlayer by platformlayer.
the class CasStoreHelper method copyObject.
public void copyObject(CasStoreMap casStoreMap, CasStoreObject src, OpsCasTarget opsCasTarget, File remoteFilePath, boolean useStagingStore) throws OpsException {
log.info("Copying object from " + src + " to " + opsCasTarget);
try {
CasLocation targetLocation = opsCasTarget.getLocation();
CasStore stagingStore = null;
if (useStagingStore) {
// Find the nearest staging store
CasPickClosestStore pickClosest = new CasPickClosestStore(targetLocation);
stagingStore = pickClosest.choose(casStoreMap.getStagingStores());
}
if (stagingStore != null) {
if (stagingStore.equals(src.getStore())) {
log.info("Already on closest staging server");
stagingStore = null;
}
}
src.copyTo(opsCasTarget, remoteFilePath, stagingStore);
} catch (Exception e) {
throw new OpsException("Error copying file to remote CAS", e);
}
}
Aggregations