Search in sources :

Example 1 with SimpleURI

use of es.bsc.compss.types.uri.SimpleURI in project compss by bsc-wdc.

the class ScoresTest method testResourceScores.

@SuppressWarnings("unchecked")
@Test
public void testResourceScores() throws BlockedActionException, UnassignedActionException, Exception {
    drs1.clear();
    FakeAllocatableAction action1 = new FakeAllocatableAction(fao, 1, 0, CoreManager.getCoreImplementations(0));
    DataInstanceId d1v1 = new DataInstanceId(1, 1);
    Comm.registerData(d1v1.getRenaming());
    DataInstanceId d2v2 = new DataInstanceId(2, 2);
    Comm.registerData(d2v2.getRenaming());
    DependencyParameter dpD1V1 = new DependencyParameter(DataType.FILE_T, Direction.IN, Stream.UNSPECIFIED, Constants.PREFIX_EMTPY);
    dpD1V1.setDataAccessId(new RAccessId(1, 1));
    DependencyParameter dpD2V2 = new DependencyParameter(DataType.FILE_T, Direction.IN, Stream.UNSPECIFIED, Constants.PREFIX_EMTPY);
    dpD2V2.setDataAccessId(new RAccessId(2, 2));
    TaskDescription params = new TaskDescription("task", false, Constants.SINGLE_NODE, false, false, false, false, new Parameter[] { dpD1V1, dpD2V2 });
    FullGraphScore<FakeProfile, FakeResourceDescription, FakeImplementation> actionScore = (FullGraphScore<FakeProfile, FakeResourceDescription, FakeImplementation>) ds.generateActionScore(action1);
    FullGraphScore<FakeProfile, FakeResourceDescription, FakeImplementation> score1 = (FullGraphScore<FakeProfile, FakeResourceDescription, FakeImplementation>) drs1.generateResourceScore(action1, params, actionScore);
    Verifiers.verifyScore(score1, 0, 2 * FullGraphResourceScheduler.DATA_TRANSFER_DELAY, 0, 0, 2 * FullGraphResourceScheduler.DATA_TRANSFER_DELAY);
    Comm.registerLocation(d1v1.getRenaming(), DataLocation.createLocation(drs1.getResource(), new SimpleURI("/home/test/a")));
    score1 = (FullGraphScore<FakeProfile, FakeResourceDescription, FakeImplementation>) drs1.generateResourceScore(action1, params, actionScore);
    Verifiers.verifyScore(score1, 0, 1 * FullGraphResourceScheduler.DATA_TRANSFER_DELAY, 0, 0, 1 * FullGraphResourceScheduler.DATA_TRANSFER_DELAY);
    Comm.registerLocation(d2v2.getRenaming(), DataLocation.createLocation(drs1.getResource(), new SimpleURI("/home/test/b")));
    score1 = (FullGraphScore<FakeProfile, FakeResourceDescription, FakeImplementation>) drs1.generateResourceScore(action1, params, actionScore);
    Verifiers.verifyScore(score1, 0, 0 * FullGraphResourceScheduler.DATA_TRANSFER_DELAY, 0, 0, 0 * FullGraphResourceScheduler.DATA_TRANSFER_DELAY);
    Comm.removeData(d1v1.getRenaming());
    Comm.removeData(d2v2.getRenaming());
}
Also used : FakeProfile(es.bsc.es.bsc.compss.scheduler.types.fake.FakeProfile) DataInstanceId(es.bsc.compss.types.data.DataInstanceId) FakeImplementation(es.bsc.es.bsc.compss.scheduler.types.fake.FakeImplementation) FullGraphScore(es.bsc.es.bsc.compss.scheduler.types.FullGraphScore) RAccessId(es.bsc.compss.types.data.DataAccessId.RAccessId) TaskDescription(es.bsc.compss.types.TaskDescription) FakeResourceDescription(es.bsc.es.bsc.compss.scheduler.types.fake.FakeResourceDescription) FakeAllocatableAction(es.bsc.es.bsc.compss.scheduler.types.fake.FakeAllocatableAction) SimpleURI(es.bsc.compss.types.uri.SimpleURI) DependencyParameter(es.bsc.compss.types.parameter.DependencyParameter) Test(org.junit.Test)

Example 2 with SimpleURI

use of es.bsc.compss.types.uri.SimpleURI in project compss by bsc-wdc.

the class Comm method registerValue.

/**
 * Registers a new value @value for the data with id @dataId dataId must exist
 *
 * @param dataId
 * @param value
 * @return
 */
public static synchronized LogicalData registerValue(String dataId, Object value) {
    LOGGER.debug("Register value " + value + " for data " + dataId);
    String targetPath = Protocol.OBJECT_URI.getSchema() + dataId;
    DataLocation location = null;
    try {
        SimpleURI uri = new SimpleURI(targetPath);
        location = DataLocation.createLocation(appHost, uri);
    } catch (IOException e) {
        ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + targetPath, e);
    }
    LogicalData logicalData = data.get(dataId);
    logicalData.addLocation(location);
    logicalData.setValue(value);
    // Register PSCO Location if needed it's PSCO and it's persisted
    if (value instanceof StubItf) {
        String id = ((StubItf) value).getID();
        if (id != null) {
            Comm.registerPSCO(dataId, id);
        }
    }
    return logicalData;
}
Also used : LogicalData(es.bsc.compss.types.data.LogicalData) SimpleURI(es.bsc.compss.types.uri.SimpleURI) StubItf(storage.StubItf) DataLocation(es.bsc.compss.types.data.location.DataLocation) IOException(java.io.IOException)

Example 3 with SimpleURI

use of es.bsc.compss.types.uri.SimpleURI in project compss by bsc-wdc.

the class Comm method registerPSCO.

/**
 * Registers a new PSCO id @id for the data with id @dataId dataId must exist
 *
 * @param dataId
 * @param id
 * @return
 */
public static synchronized LogicalData registerPSCO(String dataId, String id) {
    String targetPath = Protocol.PERSISTENT_URI.getSchema() + id;
    DataLocation location = null;
    try {
        SimpleURI uri = new SimpleURI(targetPath);
        location = DataLocation.createLocation(appHost, uri);
    } catch (IOException ioe) {
        ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + targetPath, ioe);
    }
    LogicalData logicalData = data.get(dataId);
    logicalData.addLocation(location);
    return logicalData;
}
Also used : LogicalData(es.bsc.compss.types.data.LogicalData) SimpleURI(es.bsc.compss.types.uri.SimpleURI) DataLocation(es.bsc.compss.types.data.location.DataLocation) IOException(java.io.IOException)

Example 4 with SimpleURI

use of es.bsc.compss.types.uri.SimpleURI in project compss by bsc-wdc.

the class COMPSsRuntimeImpl method createLocation.

private DataLocation createLocation(String fileName) throws IOException {
    // Check if fileName contains schema
    SimpleURI uri = new SimpleURI(fileName);
    if (uri.getSchema().isEmpty()) {
        // Add default File scheme and wrap local paths
        String canonicalPath = new File(fileName).getCanonicalPath();
        uri = new SimpleURI(Protocol.FILE_URI.getSchema() + canonicalPath);
    }
    // Check host
    Resource host = Comm.getAppHost();
    String hostName = uri.getHost();
    if (hostName != null && !hostName.isEmpty()) {
        host = Resource.getResource(hostName);
        if (host == null) {
            ErrorManager.error("Host " + hostName + " not found when creating data location.");
        }
    }
    // Create location
    return DataLocation.createLocation(host, uri);
}
Also used : SimpleURI(es.bsc.compss.types.uri.SimpleURI) Resource(es.bsc.compss.types.resources.Resource) File(java.io.File)

Example 5 with SimpleURI

use of es.bsc.compss.types.uri.SimpleURI in project compss by bsc-wdc.

the class TransferOpenFileRequest method process.

@Override
public void process(AccessProcessor ap, TaskAnalyser ta, DataInfoProvider dip, TaskDispatcher td) {
    LOGGER.debug("Process TransferOpenFileRequest");
    // Get target information
    String targetName;
    String targetPath;
    if (faId instanceof WAccessId) {
        // Write mode
        WAccessId waId = (WAccessId) faId;
        DataInstanceId targetFile = waId.getWrittenDataInstance();
        targetName = targetFile.getRenaming();
        targetPath = Comm.getAppHost().getTempDirPath() + targetName;
    } else if (faId instanceof RWAccessId) {
        // Read write mode
        RWAccessId rwaId = (RWAccessId) faId;
        targetName = rwaId.getWrittenDataInstance().getRenaming();
        targetPath = Comm.getAppHost().getTempDirPath() + targetName;
    } else {
        // Read only mode
        RAccessId raId = (RAccessId) faId;
        targetName = raId.getReadDataInstance().getRenaming();
        targetPath = Comm.getAppHost().getTempDirPath() + targetName;
    }
    LOGGER.debug("Openning file " + targetName + " at " + targetPath);
    // Create location
    DataLocation targetLocation = null;
    String pscoId = Comm.getData(targetName).getId();
    if (pscoId == null) {
        try {
            SimpleURI targetURI = new SimpleURI(DataLocation.Protocol.FILE_URI.getSchema() + targetPath);
            targetLocation = DataLocation.createLocation(Comm.getAppHost(), targetURI);
        } catch (IOException ioe) {
            ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + targetPath, ioe);
        }
    } else {
        // It is an external object persisted inside the task
        try {
            SimpleURI targetURI = new SimpleURI(DataLocation.Protocol.PERSISTENT_URI.getSchema() + pscoId);
            targetLocation = DataLocation.createLocation(Comm.getAppHost(), targetURI);
        } catch (IOException ioe) {
            ErrorManager.error(DataLocation.ERROR_INVALID_LOCATION + " " + targetPath, ioe);
        }
    }
    // Register target location
    LOGGER.debug("Setting target location to " + targetLocation);
    setLocation(targetLocation);
    // Ask for transfer when required
    if (pscoId != null) {
        LOGGER.debug("External object detected. Auto-release");
        Comm.registerLocation(targetName, targetLocation);
        sem.release();
    } else if (faId instanceof WAccessId) {
        LOGGER.debug("Write only mode. Auto-release");
        Comm.registerLocation(targetName, targetLocation);
        sem.release();
    } else if (faId instanceof RWAccessId) {
        LOGGER.debug("RW mode. Asking for transfer");
        RWAccessId rwaId = (RWAccessId) faId;
        String srcName = rwaId.getReadDataInstance().getRenaming();
        Comm.getAppHost().getData(srcName, targetName, (LogicalData) null, new FileTransferable(), new OneOpWithSemListener(sem));
    } else {
        LOGGER.debug("Read only mode. Asking for transfer");
        RAccessId raId = (RAccessId) faId;
        String srcName = raId.getReadDataInstance().getRenaming();
        Comm.getAppHost().getData(srcName, srcName, new FileTransferable(), new OneOpWithSemListener(sem));
    }
}
Also used : FileTransferable(es.bsc.compss.types.data.operation.FileTransferable) DataInstanceId(es.bsc.compss.types.data.DataInstanceId) RAccessId(es.bsc.compss.types.data.DataAccessId.RAccessId) RWAccessId(es.bsc.compss.types.data.DataAccessId.RWAccessId) SimpleURI(es.bsc.compss.types.uri.SimpleURI) DataLocation(es.bsc.compss.types.data.location.DataLocation) WAccessId(es.bsc.compss.types.data.DataAccessId.WAccessId) RWAccessId(es.bsc.compss.types.data.DataAccessId.RWAccessId) IOException(java.io.IOException) OneOpWithSemListener(es.bsc.compss.types.data.operation.OneOpWithSemListener)

Aggregations

SimpleURI (es.bsc.compss.types.uri.SimpleURI)22 DataLocation (es.bsc.compss.types.data.location.DataLocation)16 IOException (java.io.IOException)9 UnstartedNodeException (es.bsc.compss.exceptions.UnstartedNodeException)6 LogicalData (es.bsc.compss.types.data.LogicalData)6 InitNodeException (es.bsc.compss.exceptions.InitNodeException)5 Semaphore (java.util.concurrent.Semaphore)5 CannotLoadException (es.bsc.compss.exceptions.CannotLoadException)4 COMPSsNode (es.bsc.compss.types.COMPSsNode)4 DataInstanceId (es.bsc.compss.types.data.DataInstanceId)4 File (java.io.File)4 StorageException (storage.StorageException)4 DataAccessId (es.bsc.compss.types.data.DataAccessId)3 RAccessId (es.bsc.compss.types.data.DataAccessId.RAccessId)3 Test (org.junit.Test)3 RWAccessId (es.bsc.compss.types.data.DataAccessId.RWAccessId)2 WAccessId (es.bsc.compss.types.data.DataAccessId.WAccessId)2 TracingCopyListener (es.bsc.compss.types.data.listener.TracingCopyListener)2 OneOpWithSemListener (es.bsc.compss.types.data.operation.OneOpWithSemListener)2 TracingCopyTransferable (es.bsc.compss.types.data.transferable.TracingCopyTransferable)2