Search in sources :

Example 1 with DataInstanceId

use of es.bsc.compss.types.data.DataInstanceId 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 DataInstanceId

use of es.bsc.compss.types.data.DataInstanceId in project compss by bsc-wdc.

the class TaskAnalyser method processTask.

/**
 * Process the dependencies of a new task @currentTask
 *
 * @param currentTask
 */
public void processTask(Task currentTask) {
    TaskDescription params = currentTask.getTaskDescription();
    LOGGER.info("New " + (params.getType() == TaskType.METHOD ? "method" : "service") + " task(" + params.getName() + "), ID = " + currentTask.getId());
    if (drawGraph) {
        addNewTask(currentTask);
    }
    // Update task count
    Integer methodId = params.getId();
    Integer actualCount = currentTaskCount.get(methodId);
    if (actualCount == null) {
        actualCount = 0;
    }
    currentTaskCount.put(methodId, actualCount + 1);
    // Update app id task count
    Long appId = currentTask.getAppId();
    Integer taskCount = appIdToTaskCount.get(appId);
    if (taskCount == null) {
        taskCount = 0;
    }
    taskCount++;
    appIdToTaskCount.put(appId, taskCount);
    Integer totalTaskCount = appIdToTotalTaskCount.get(appId);
    if (totalTaskCount == null) {
        totalTaskCount = 0;
    }
    totalTaskCount++;
    appIdToTotalTaskCount.put(appId, totalTaskCount);
    // Check scheduling enforcing data
    int constrainingParam = -1;
    if (params.getType() == TaskType.SERVICE && params.hasTargetObject()) {
        if (params.hasReturnValue()) {
            constrainingParam = params.getParameters().length - 2;
        } else {
            constrainingParam = params.getParameters().length - 1;
        }
    }
    Parameter[] parameters = params.getParameters();
    for (int paramIdx = 0; paramIdx < parameters.length; paramIdx++) {
        Parameter p = parameters[paramIdx];
        if (DEBUG) {
            LOGGER.debug("* Parameter : " + p);
        }
        // Conversion: direction -> access mode
        AccessMode am = AccessMode.R;
        switch(p.getDirection()) {
            case IN:
                am = AccessMode.R;
                break;
            case OUT:
                am = AccessMode.W;
                break;
            case INOUT:
                am = AccessMode.RW;
                break;
        }
        // Inform the Data Manager about the new accesses
        DataAccessId daId;
        switch(p.getType()) {
            case FILE_T:
                FileParameter fp = (FileParameter) p;
                daId = DIP.registerFileAccess(am, fp.getLocation());
                break;
            case PSCO_T:
                ObjectParameter pscop = (ObjectParameter) p;
                // Check if its PSCO class and persisted to infer its type
                pscop.setType(DataType.PSCO_T);
                daId = DIP.registerObjectAccess(am, pscop.getValue(), pscop.getCode());
                break;
            case EXTERNAL_OBJECT_T:
                ExternalObjectParameter externalPSCOparam = (ExternalObjectParameter) p;
                // Check if its PSCO class and persisted to infer its type
                externalPSCOparam.setType(DataType.EXTERNAL_OBJECT_T);
                daId = DIP.registerExternalObjectAccess(am, externalPSCOparam.getId(), externalPSCOparam.getCode());
                break;
            case OBJECT_T:
                ObjectParameter op = (ObjectParameter) p;
                // Check if its PSCO class and persisted to infer its type
                if (op.getValue() instanceof StubItf && ((StubItf) op.getValue()).getID() != null) {
                    op.setType(DataType.PSCO_T);
                }
                daId = DIP.registerObjectAccess(am, op.getValue(), op.getCode());
                break;
            default:
                /*
                     * Basic types (including String). The only possible access mode is R (already checked by the API)
                     */
                continue;
        }
        // Add dependencies to the graph and register output values for future dependencies
        DependencyParameter dp = (DependencyParameter) p;
        dp.setDataAccessId(daId);
        switch(am) {
            case R:
                checkDependencyForRead(currentTask, dp);
                if (paramIdx == constrainingParam) {
                    DataAccessId.RAccessId raId = (DataAccessId.RAccessId) dp.getDataAccessId();
                    DataInstanceId dependingDataId = raId.getReadDataInstance();
                    if (dependingDataId != null) {
                        if (dependingDataId.getVersionId() > 1) {
                            currentTask.setEnforcingTask(writers.get(dependingDataId.getDataId()));
                        }
                    }
                }
                break;
            case RW:
                checkDependencyForRead(currentTask, dp);
                if (paramIdx == constrainingParam) {
                    DataAccessId.RWAccessId raId = (DataAccessId.RWAccessId) dp.getDataAccessId();
                    DataInstanceId dependingDataId = raId.getReadDataInstance();
                    if (dependingDataId != null) {
                        if (dependingDataId.getVersionId() > 1) {
                            currentTask.setEnforcingTask(writers.get(dependingDataId.getDataId()));
                        }
                    }
                }
                registerOutputValues(currentTask, dp);
                break;
            case W:
                registerOutputValues(currentTask, dp);
                break;
        }
    }
}
Also used : DependencyParameter(es.bsc.compss.types.parameter.DependencyParameter) RWAccessId(es.bsc.compss.types.data.DataAccessId.RWAccessId) DataInstanceId(es.bsc.compss.types.data.DataInstanceId) TaskDescription(es.bsc.compss.types.TaskDescription) ExternalObjectParameter(es.bsc.compss.types.parameter.ExternalObjectParameter) RWAccessId(es.bsc.compss.types.data.DataAccessId.RWAccessId) ExternalObjectParameter(es.bsc.compss.types.parameter.ExternalObjectParameter) ObjectParameter(es.bsc.compss.types.parameter.ObjectParameter) StubItf(storage.StubItf) ExternalObjectParameter(es.bsc.compss.types.parameter.ExternalObjectParameter) ObjectParameter(es.bsc.compss.types.parameter.ObjectParameter) FileParameter(es.bsc.compss.types.parameter.FileParameter) Parameter(es.bsc.compss.types.parameter.Parameter) DependencyParameter(es.bsc.compss.types.parameter.DependencyParameter) FileParameter(es.bsc.compss.types.parameter.FileParameter) DataAccessId(es.bsc.compss.types.data.DataAccessId)

Example 3 with DataInstanceId

use of es.bsc.compss.types.data.DataInstanceId in project compss by bsc-wdc.

the class TaskAnalyser method checkResultFileTransfer.

/**
 * Checks if a finished task is the last writer of its file parameters and, eventually, order the necessary
 * transfers
 *
 * @param t
 */
private void checkResultFileTransfer(Task t) {
    LinkedList<DataInstanceId> fileIds = new LinkedList<>();
    for (Parameter p : t.getTaskDescription().getParameters()) {
        switch(p.getType()) {
            case FILE_T:
                FileParameter fp = (FileParameter) p;
                switch(fp.getDirection()) {
                    case IN:
                        break;
                    case INOUT:
                        DataInstanceId dId = ((RWAccessId) fp.getDataAccessId()).getWrittenDataInstance();
                        if (writers.get(dId.getDataId()) == t) {
                            fileIds.add(dId);
                        }
                        break;
                    case OUT:
                        dId = ((WAccessId) fp.getDataAccessId()).getWrittenDataInstance();
                        if (writers.get(dId.getDataId()) == t) {
                            fileIds.add(dId);
                        }
                        break;
                }
                break;
            default:
                break;
        }
    }
    // Order the transfer of the result files
    final int numFT = fileIds.size();
    if (numFT > 0) {
        // List<ResultFile> resFiles = new ArrayList<ResultFile>(numFT);
        for (DataInstanceId fileId : fileIds) {
            try {
                int id = fileId.getDataId();
                DIP.blockDataAndGetResultFile(id, new ResultListener(new Semaphore(0)));
                DIP.unblockDataId(id);
            } catch (Exception e) {
                LOGGER.error("Exception ordering trasnfer when task ends", e);
            }
        }
    }
}
Also used : DataInstanceId(es.bsc.compss.types.data.DataInstanceId) ResultListener(es.bsc.compss.types.data.operation.ResultListener) RWAccessId(es.bsc.compss.types.data.DataAccessId.RWAccessId) ExternalObjectParameter(es.bsc.compss.types.parameter.ExternalObjectParameter) ObjectParameter(es.bsc.compss.types.parameter.ObjectParameter) FileParameter(es.bsc.compss.types.parameter.FileParameter) Parameter(es.bsc.compss.types.parameter.Parameter) DependencyParameter(es.bsc.compss.types.parameter.DependencyParameter) FileParameter(es.bsc.compss.types.parameter.FileParameter) Semaphore(java.util.concurrent.Semaphore) LinkedList(java.util.LinkedList)

Example 4 with DataInstanceId

use of es.bsc.compss.types.data.DataInstanceId in project compss by bsc-wdc.

the class IsObjectHereRequest method process.

@Override
public void process(AccessProcessor ap, TaskAnalyser ta, DataInfoProvider dip, TaskDispatcher td) {
    DataInstanceId dId = dip.getLastDataAccess(code);
    response = dip.isHere(dId);
    sem.release();
}
Also used : DataInstanceId(es.bsc.compss.types.data.DataInstanceId)

Example 5 with DataInstanceId

use of es.bsc.compss.types.data.DataInstanceId 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

DataInstanceId (es.bsc.compss.types.data.DataInstanceId)10 DataAccessId (es.bsc.compss.types.data.DataAccessId)6 RWAccessId (es.bsc.compss.types.data.DataAccessId.RWAccessId)6 DependencyParameter (es.bsc.compss.types.parameter.DependencyParameter)5 Parameter (es.bsc.compss.types.parameter.Parameter)4 SimpleURI (es.bsc.compss.types.uri.SimpleURI)4 RAccessId (es.bsc.compss.types.data.DataAccessId.RAccessId)3 DataLocation (es.bsc.compss.types.data.location.DataLocation)3 TaskDescription (es.bsc.compss.types.TaskDescription)2 AccessParams (es.bsc.compss.types.data.AccessParams)2 FileAccessParams (es.bsc.compss.types.data.AccessParams.FileAccessParams)2 WAccessId (es.bsc.compss.types.data.DataAccessId.WAccessId)2 ExternalObjectParameter (es.bsc.compss.types.parameter.ExternalObjectParameter)2 FileParameter (es.bsc.compss.types.parameter.FileParameter)2 ObjectParameter (es.bsc.compss.types.parameter.ObjectParameter)2 CannotLoadException (es.bsc.compss.exceptions.CannotLoadException)1 BlockedActionException (es.bsc.compss.scheduler.exceptions.BlockedActionException)1 FailedActionException (es.bsc.compss.scheduler.exceptions.FailedActionException)1 UnassignedActionException (es.bsc.compss.scheduler.exceptions.UnassignedActionException)1 LogicalData (es.bsc.compss.types.data.LogicalData)1