Search in sources :

Example 16 with FlightMap

use of bio.terra.stairway.FlightMap in project jade-data-repo by DataBiosphere.

the class IngestPopulateFileStateFromArrayStep method doStep.

@Override
public StepResult doStep(FlightContext context) {
    FlightMap inputParameters = context.getInputParameters();
    BulkLoadArrayRequestModel loadRequest = inputParameters.get(JobMapKeys.REQUEST.getKeyName(), BulkLoadArrayRequestModel.class);
    FlightMap workingMap = context.getWorkingMap();
    UUID loadId = UUID.fromString(workingMap.get(LoadMapKeys.LOAD_ID, String.class));
    loadService.populateFiles(loadId, loadRequest.getLoadArray());
    return StepResult.getStepResultSuccess();
}
Also used : BulkLoadArrayRequestModel(bio.terra.model.BulkLoadArrayRequestModel) FlightMap(bio.terra.stairway.FlightMap) UUID(java.util.UUID)

Example 17 with FlightMap

use of bio.terra.stairway.FlightMap in project jade-data-repo by DataBiosphere.

the class IngestPopulateFileStateFromArrayStep method undoStep.

@Override
public StepResult undoStep(FlightContext context) {
    FlightMap workingMap = context.getWorkingMap();
    UUID loadId = UUID.fromString(workingMap.get(LoadMapKeys.LOAD_ID, String.class));
    loadService.cleanFiles(loadId);
    return StepResult.getStepResultSuccess();
}
Also used : FlightMap(bio.terra.stairway.FlightMap) UUID(java.util.UUID)

Example 18 with FlightMap

use of bio.terra.stairway.FlightMap in project jade-data-repo by DataBiosphere.

the class IngestPopulateFileStateFromFileStep method undoStep.

@Override
public StepResult undoStep(FlightContext context) {
    FlightMap workingMap = context.getWorkingMap();
    UUID loadId = UUID.fromString(workingMap.get(LoadMapKeys.LOAD_ID, String.class));
    loadService.cleanFiles(loadId);
    return StepResult.getStepResultSuccess();
}
Also used : FlightMap(bio.terra.stairway.FlightMap) UUID(java.util.UUID)

Example 19 with FlightMap

use of bio.terra.stairway.FlightMap in project jade-data-repo by DataBiosphere.

the class DeleteFileLookupStep method doStep.

@Override
public StepResult doStep(FlightContext context) throws InterruptedException {
    if (configService.testInsertFault(ConfigEnum.FILE_DELETE_LOCK_CONFLICT_STOP_FAULT)) {
        logger.info("FILE_DELETE_LOCK_CONFLICT_STOP_FAULT");
        while (!configService.testInsertFault(ConfigEnum.FILE_DELETE_LOCK_CONFLICT_CONTINUE_FAULT)) {
            logger.info("Sleeping for CONTINUE FAULT");
            TimeUnit.SECONDS.sleep(5);
        }
        logger.info("FILE_DELETE_LOCK_CONFLICT_CONTINUE_FAULT");
    }
    try {
        // If we are restarting, we may have already retrieved and saved the file,
        // so we check the working map before doing the lookup.
        FlightMap workingMap = context.getWorkingMap();
        FireStoreFile fireStoreFile = workingMap.get(FileMapKeys.FIRESTORE_FILE, FireStoreFile.class);
        if (fireStoreFile == null) {
            fireStoreFile = fileDao.lookupFile(dataset, fileId);
            if (fireStoreFile != null) {
                workingMap.put(FileMapKeys.FIRESTORE_FILE, fireStoreFile);
            }
        }
        // steps know there is no file. If there is a file, check dependencies here.
        if (fireStoreFile != null) {
            if (dependencyDao.fileHasSnapshotReference(dataset, fireStoreFile.getFileId())) {
                throw new FileDependencyException("File is used by at least one snapshot and cannot be deleted");
            }
        }
    } catch (FileSystemAbortTransactionException rex) {
        return new StepResult(StepStatus.STEP_RESULT_FAILURE_RETRY, rex);
    }
    return StepResult.getStepResultSuccess();
}
Also used : FireStoreFile(bio.terra.service.filedata.google.firestore.FireStoreFile) FlightMap(bio.terra.stairway.FlightMap) FileDependencyException(bio.terra.service.filedata.exception.FileDependencyException) FileSystemAbortTransactionException(bio.terra.service.filedata.exception.FileSystemAbortTransactionException) StepResult(bio.terra.stairway.StepResult)

Example 20 with FlightMap

use of bio.terra.stairway.FlightMap in project jade-data-repo by DataBiosphere.

the class DeleteFilePrimaryDataStep method doStep.

@Override
public StepResult doStep(FlightContext context) {
    FlightMap workingMap = context.getWorkingMap();
    FireStoreFile fireStoreFile = workingMap.get(FileMapKeys.FIRESTORE_FILE, FireStoreFile.class);
    if (fireStoreFile != null) {
        GoogleBucketResource bucketResource = locationService.lookupBucket(fireStoreFile.getBucketResourceId());
        gcsPdao.deleteFileByGspath(fireStoreFile.getGspath(), bucketResource);
    }
    return StepResult.getStepResultSuccess();
}
Also used : FireStoreFile(bio.terra.service.filedata.google.firestore.FireStoreFile) GoogleBucketResource(bio.terra.service.resourcemanagement.google.GoogleBucketResource) FlightMap(bio.terra.stairway.FlightMap)

Aggregations

FlightMap (bio.terra.stairway.FlightMap)147 StepResult (bio.terra.stairway.StepResult)38 UUID (java.util.UUID)29 FlightState (bio.terra.stairway.FlightState)20 DatabaseOperationException (bio.terra.stairway.exception.DatabaseOperationException)14 Test (org.junit.jupiter.api.Test)14 Dataset (bio.terra.service.dataset.Dataset)9 IOException (java.io.IOException)9 IamRole (bio.terra.service.iam.IamRole)8 AuthenticatedUserRequest (bio.terra.workspace.service.iam.AuthenticatedUserRequest)8 HashMap (java.util.HashMap)8 DuplicateFlightIdException (bio.terra.stairway.exception.DuplicateFlightIdException)7 CloningInstructions (bio.terra.workspace.service.resource.model.CloningInstructions)7 FlightDebugInfo (bio.terra.stairway.FlightDebugInfo)6 BaseConnectedTest (bio.terra.workspace.common.BaseConnectedTest)6 FileSystemAbortTransactionException (bio.terra.service.filedata.exception.FileSystemAbortTransactionException)5 Snapshot (bio.terra.service.snapshot.Snapshot)5 FlightNotFoundException (bio.terra.stairway.exception.FlightNotFoundException)5 StairwayExecutionException (bio.terra.stairway.exception.StairwayExecutionException)5 BaseUnitTest (bio.terra.workspace.common.BaseUnitTest)5