Search in sources :

Example 11 with StorageException

use of storage.StorageException in project compss by bsc-wdc.

the class Internal method testNewVersionAndConsolidate.

private static void testNewVersionAndConsolidate() throws StorageException {
    Person original = new Person("Original", 0, 0);
    original.makePersistent("Original");
    Stack<String> personStack = new Stack<>();
    personStack.push("Original");
    System.out.println("[LOG][PSCO_NEW_VERSION_CONSOLIDATE] Id 0: Original");
    for (int i = 1; i <= 10; ++i) {
        original.setAge(i);
        original.setName("person_" + i);
        String oldId = original.getID();
        String newId = StorageItf.newVersion(oldId, true, "none");
        original = (Person) StorageItf.getByID(newId);
        System.out.println("[LOG][PSCO_NEW_VERSION_CONSOLIDATE] Id " + i + ": " + newId);
        personStack.push(newId);
    }
    StorageItf.consolidateVersion(personStack.pop());
    boolean success = true;
    while (!personStack.isEmpty() && success) {
        String currentId = personStack.pop();
        try {
            StorageItf.getByID(currentId);
            System.out.println("[LOG][PSCO_NEW_VERSION_CONSOLIDATE] Error, id " + currentId + " is still in Redis!");
            success = false;
        } catch (StorageException e) {
            System.out.println("[LOG][PSCO_NEW_VERSION_CONSOLIDATE] Ok, id " + currentId + " is no longer in Redis!");
        }
    }
    System.out.println("[LOG][PSCO_NEW_VERSION_CONSOLIDATE]: " + (success ? "OK" : "ERROR"));
}
Also used : Person(model.Person) StorageException(storage.StorageException) Stack(java.util.Stack)

Example 12 with StorageException

use of storage.StorageException in project compss by bsc-wdc.

the class DataInfoProvider method blockDataAndGetResultFile.

/**
 * Blocks dataId and retrieves its result file
 *
 * @param dataId
 * @param listener
 * @return
 */
public ResultFile blockDataAndGetResultFile(int dataId, ResultListener listener) {
    DataInstanceId lastVersion;
    FileInfo fileInfo = (FileInfo) idToData.get(dataId);
    if (fileInfo != null && !fileInfo.isCurrentVersionToDelete()) {
        // If current version is to delete do not
        // transfer
        String[] splitPath = fileInfo.getOriginalLocation().getPath().split(File.separator);
        String origName = splitPath[splitPath.length - 1];
        if (origName.startsWith("compss-serialized-obj_")) {
            // Do not transfer objects serialized by the bindings
            if (DEBUG) {
                LOGGER.debug("Discarding file " + origName + " as a result");
            }
            return null;
        }
        fileInfo.blockDeletions();
        lastVersion = fileInfo.getCurrentDataVersion().getDataInstanceId();
        ResultFile rf = new ResultFile(lastVersion, fileInfo.getOriginalLocation());
        DataInstanceId fId = rf.getFileInstanceId();
        String renaming = fId.getRenaming();
        // Look for the last available version
        while (renaming != null && !Comm.existsData(renaming)) {
            renaming = DataInstanceId.previousVersionRenaming(renaming);
        }
        if (renaming == null) {
            LOGGER.error(RES_FILE_TRANSFER_ERR + ": Cannot transfer file " + fId.getRenaming() + " nor any of its previous versions");
            return null;
        }
        // Check if data is a PSCO and must be consolidated
        for (DataLocation loc : Comm.getData(renaming).getLocations()) {
            if (loc instanceof PersistentLocation) {
                String pscoId = ((PersistentLocation) loc).getId();
                if (Tracer.isActivated()) {
                    Tracer.emitEvent(Tracer.Event.STORAGE_CONSOLIDATE.getId(), Tracer.Event.STORAGE_CONSOLIDATE.getType());
                }
                try {
                    StorageItf.consolidateVersion(pscoId);
                } catch (StorageException e) {
                    LOGGER.error("Cannot consolidate PSCO " + pscoId, e);
                } finally {
                    if (Tracer.isActivated()) {
                        Tracer.emitEvent(Tracer.EVENT_END, Tracer.Event.STORAGE_CONSOLIDATE.getType());
                    }
                }
                LOGGER.debug("Returned because persistent object");
                return rf;
            }
        }
        // If no PSCO location is found, perform normal getData
        listener.addOperation();
        Comm.getAppHost().getData(renaming, rf.getOriginalLocation(), new FileTransferable(), listener);
        return rf;
    } else if (fileInfo != null && fileInfo.isCurrentVersionToDelete()) {
        if (DEBUG) {
            String[] splitPath = fileInfo.getOriginalLocation().getPath().split(File.separator);
            String origName = splitPath[splitPath.length - 1];
            LOGGER.debug("Trying to delete file " + origName);
        }
        if (fileInfo.delete()) {
        // idToData.remove(dataId);
        }
    }
    return null;
}
Also used : FileTransferable(es.bsc.compss.types.data.operation.FileTransferable) PersistentLocation(es.bsc.compss.types.data.location.PersistentLocation) DataLocation(es.bsc.compss.types.data.location.DataLocation) StorageException(storage.StorageException)

Aggregations

StorageException (storage.StorageException)12 IOException (java.io.IOException)3 LinkedList (java.util.LinkedList)3 JobExecutionException (es.bsc.compss.nio.exceptions.JobExecutionException)2 SerializedObjectException (es.bsc.compss.nio.exceptions.SerializedObjectException)2 DataLocation (es.bsc.compss.types.data.location.DataLocation)2 PersistentLocation (es.bsc.compss.types.data.location.PersistentLocation)2 Resource (es.bsc.compss.types.resources.Resource)2 MultiURI (es.bsc.compss.types.uri.MultiURI)2 CommException (es.bsc.comm.exceptions.CommException)1 NIONode (es.bsc.comm.nio.NIONode)1 CannotLoadException (es.bsc.compss.exceptions.CannotLoadException)1 NIOMessageHandler (es.bsc.compss.nio.NIOMessageHandler)1 CommandShutdownACK (es.bsc.compss.nio.commands.CommandShutdownACK)1 InitializationException (es.bsc.compss.nio.worker.exceptions.InitializationException)1 InvalidMapException (es.bsc.compss.nio.worker.exceptions.InvalidMapException)1 LogicalData (es.bsc.compss.types.data.LogicalData)1 FileTransferable (es.bsc.compss.types.data.operation.FileTransferable)1 MasterResource (es.bsc.compss.types.resources.MasterResource)1 SimpleURI (es.bsc.compss.types.uri.SimpleURI)1