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"));
}
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;
}
Aggregations