All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.castled.warehouses.S3BasedDataPoller Maven / Gradle / Ivy

package io.castled.warehouses;

import com.google.common.collect.Lists;
import io.castled.commons.models.FileStorageNamespace;
import io.castled.filestorage.CastledS3Client;
import io.castled.utils.FileUtils;
import io.castled.warehouses.models.WarehousePollContext;

public abstract class S3BasedDataPoller implements WarehouseDataPoller {


    public void cleanupPipelineRunResources(WarehousePollContext warehousePollContext) {
        CastledS3Client castledS3Client = getS3Client(warehousePollContext.getWarehouseConfig(),
                warehousePollContext.getDataEncryptionKey());
        castledS3Client.deleteDirectory(getS3UnloadDirectory(warehousePollContext.getPipelineUUID(),
                warehousePollContext.getPipelineRunId()));
        FileUtils.deleteDirectory(getPipelineRunUnloadDirectory(warehousePollContext.getPipelineUUID(),
                warehousePollContext.getPipelineRunId()));
    }


    public String getS3UnloadDirectory(String pipelineUUID, Long pipelineRunId) {
        return CastledS3Client.constructObjectKey
                (Lists.newArrayList(FileStorageNamespace.PIPELINE_UNLOADS.getNamespace(), pipelineUUID, String.valueOf(pipelineRunId)));
    }

    public abstract CastledS3Client getS3Client(WarehouseConfig warehouseConfig, String encryptionKey);

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy