Search in sources :

Example 1 with CasLocation

use of org.platformlayer.cas.CasLocation in project platformlayer by platformlayer.

the class OpsCasObjectBase method copyTo.

@Override
public void copyTo(CasTarget destTarget, File destPath, CasStore stagingStore) throws OpsException {
    CasLocation srcLocation = getLocation();
    CasLocation destLocation = destTarget.getLocation();
    int distance = srcLocation.estimateDistance(destLocation);
    log.info("Estimated distance from " + srcLocation + " to " + destLocation + " => " + distance);
    if (distance == 0) {
        log.info("Distance was zero; copying directly");
        this.copyTo0(OpsCasTarget.getTarget(destTarget), destPath);
        return;
    }
    if (stagingStore != null) {
        log.info("Staging object " + this + " to " + stagingStore);
        FilesystemCasObject staged = ((FilesystemCasStore) stagingStore).copyToStaging(this);
        staged.copyTo(destTarget, destPath, null);
    } else {
        log.info("Copying object from " + this + " to " + destTarget);
        this.copyTo0(OpsCasTarget.getTarget(destTarget), destPath);
    }
}
Also used : FilesystemCasStore(org.platformlayer.ops.cas.filesystem.FilesystemCasStore) FilesystemCasObject(org.platformlayer.ops.cas.filesystem.FilesystemCasObject) CasLocation(org.platformlayer.cas.CasLocation)

Example 2 with CasLocation

use of org.platformlayer.cas.CasLocation 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);
    }
}
Also used : OpsException(org.platformlayer.ops.OpsException) CasPickClosestStore(org.platformlayer.cas.CasPickClosestStore) CasLocation(org.platformlayer.cas.CasLocation) JenkinsCasStore(org.platformlayer.ops.cas.jenkins.JenkinsCasStore) CasStore(org.platformlayer.cas.CasStore) FilesystemCasStore(org.platformlayer.ops.cas.filesystem.FilesystemCasStore) URISyntaxException(java.net.URISyntaxException) OpsException(org.platformlayer.ops.OpsException)

Aggregations

CasLocation (org.platformlayer.cas.CasLocation)2 FilesystemCasStore (org.platformlayer.ops.cas.filesystem.FilesystemCasStore)2 URISyntaxException (java.net.URISyntaxException)1 CasPickClosestStore (org.platformlayer.cas.CasPickClosestStore)1 CasStore (org.platformlayer.cas.CasStore)1 OpsException (org.platformlayer.ops.OpsException)1 FilesystemCasObject (org.platformlayer.ops.cas.filesystem.FilesystemCasObject)1 JenkinsCasStore (org.platformlayer.ops.cas.jenkins.JenkinsCasStore)1