Search in sources :

Example 1 with CasStore

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

the class CasStoreHelper method getCasStoreMap.

public CasStoreMap getCasStoreMap(OpsTarget target) throws OpsException {
    // TODO: Reintroduce (some) caching?
    // if (this.casStores == null) {
    CasStoreMap casStores = new CasStoreMap();
    FilesystemCasStore filesystemCasStore = new FilesystemCasStore(new CasStoreInfo(false), new OpsCasTarget(target));
    casStores.addPrimary(filesystemCasStore);
    // TODO: Don't hard-code
    casStores.addSecondary(buildJenkins("http://192.168.131.14:8080/"));
    for (ProviderOf<CasStoreProvider> casStoreProvider : providers.listItemsProviding(CasStoreProvider.class)) {
        CasStore casStore = casStoreProvider.get().getCasStore();
        casStores.addSecondary(casStore);
        if (casStore.getOptions().isStaging()) {
            // Use this as a staging store i.e. we can upload files to here instead of to the VM
            casStores.addStagingStore(casStore);
        }
    }
    // }
    return casStores;
}
Also used : CasStoreMap(org.platformlayer.cas.CasStoreMap) CasStoreInfo(org.platformlayer.cas.CasStoreInfo) FilesystemCasStore(org.platformlayer.ops.cas.filesystem.FilesystemCasStore) JenkinsCasStore(org.platformlayer.ops.cas.jenkins.JenkinsCasStore) CasStore(org.platformlayer.cas.CasStore) FilesystemCasStore(org.platformlayer.ops.cas.filesystem.FilesystemCasStore)

Example 2 with CasStore

use of org.platformlayer.cas.CasStore 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

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