Package eu.scape_project.planning.model.beans

Examples of eu.scape_project.planning.model.beans.MigrationResult


        long start = System.nanoTime();
        String settings = "";
        if (action.isExecute()) {
            settings = action.getParamByName("settings");
        }
        MigrationResult result = service.migrate(digitalObject.getData().getData(), action.getUrl(), settings);
        setResultName(result, digitalObject);

        long duration = (System.nanoTime() - start) / (1000000);
        service.addExperience(result.getFeedbackKey(), action.getUrl(), new Measurement("roundtripTimeMS", new Double(
            duration)));
        return result;
    }
View Full Code Here


        }
    }

    @Override
    public boolean perform(Alternative alternative, SampleObject sampleObject) throws PlatoException {
        MigrationResult result = migrate(alternative, sampleObject);
        return result.isSuccessful();
    }
View Full Code Here

     * and collects their results.
     * Forwarding is done sequentially, one AFTER the other.
     */
    public MigrationResult migrate(byte[] data, String toolID, String params) {
       
        MigrationResult result = new MigrationResult();
        StringBuffer report = new StringBuffer();
       
        for (IMigrationEngine engine: engines) {
            // execute tool on all migration engines (ideally in parallel)
            report.append("migrating with engine "+engine.getName()+":\n");
            MigrationResult r = engine.migrate(data, toolID, params);
            report.append(r.getReport()).append("\n------------------- ------------\n");

            // get all performance data and put them together in the order the engines are defined
            for (Measure measure : engine.getMeasures()) {
                result.getMeasurements().put(measure.getUri(),r.getMeasurements().get(measure.getUri()));
            }
            for (Measurement m : r.getMeasurements().values()) {
                if (m.getMeasureId().contains(":normalised")) {
                    result.getMeasurements().put(m.getMeasureId(),m);
                }
            }// TODO define proper models and IDs for these measurements
           
           
            // Let's be nice for now - we can still get more defensive later on
            // and check consistency, i.e. identity of the produced byte arrays, etc.
            if (r.isSuccessful()) {
                result.setMigratedObject(r.getMigratedObject());
                result.setTargetFormat(r.getTargetFormat());
                result.setSuccessful(true);
            }
        }
        normaliseMeasurements(result, toolID);
        result.setReport(report.toString());
View Full Code Here

    public MigrationResult migrate(byte[] data, String toolID, String params) {
        ToolConfig config = getToolConfig(toolID);
        ToolRegistry reg = ToolRegistry.getInstance();

        IMigrationEngine engine = reg.getAllEngines().get(config.getEngine());
        MigrationResult r= engine.migrate(data, toolID, params);

        /* evaluate result */
        evaluate(config, data, r);
       
        long key = System.nanoTime();
        r.setFeedbackKey(key);
        reg.addTimePad(key);
        return r;
    }
View Full Code Here

     * @see IMigrationEngine#migrate(byte[], String, String)
     * This measures <b>elapsed time</b> and relative file size only.
     */
    public MigrationResult migrate(byte[] data, String toolID, String params) {
       
        MigrationResult result = new MigrationResult();
        String key = "minimee/";
        String toolIdentifier = toolID.substring(toolID.indexOf(key)
                + key.length());
        ToolConfig config = ToolRegistry.getInstance().getToolConfig(toolIdentifier);
        migrate(data, config, params, result);
       
        normaliseMeasurements(result, toolIdentifier);
        result.getMeasurements().put("input:filesize",new Measurement("input:filesize",data.length));
        return result;
    }
View Full Code Here

        cm.init();
    }

    @Override
    public boolean perform(Alternative alternative, SampleObject sampleObject) throws PlatoException {
        MigrationResult result = migrate(alternative, sampleObject);
        return result.isSuccessful();
    }
View Full Code Here

    }

    @Override
    public MigrationResult migrate(Alternative alternative, DigitalObject digitalObject) throws PlatoException {
        DigitalObject workflow = alternative.getExperiment().getWorkflow();
        MigrationResult result = new MigrationResult();
        result.setSourceFormat(digitalObject.getFormatInfo());
        result.setSuccessful(false);

        // Prepare executor
        SSHTavernaExecutor tavernaExecutor = new SSHTavernaExecutor();
        tavernaExecutor.init();
        SSHTavernaExecutor.ByteArraySourceFile workflowFile = tavernaExecutor.new ByteArraySourceFile(
            FileUtils.makeFilename(workflow.getFullname()), workflow.getData().getData());
        tavernaExecutor.setWorkflow(workflowFile);

        // Input
        HashMap<String, Object> inputData = new HashMap<String, Object>();
        SSHTavernaExecutor.ByteArraySourceFile sourceFile = tavernaExecutor.new ByteArraySourceFile(
            FileUtils.makeFilename(digitalObject.getFullname()), digitalObject.getData().getData());
        inputData.put("source", sourceFile);
        tavernaExecutor.setInputData(inputData);

        // Outputs
        tavernaExecutor.setOutputPorts(null);
        HashMap<String, SSHInMemoryTempFile> requestedFiles = new HashMap<String, SSHInMemoryTempFile>(1);
        SSHInMemoryTempFile tempFile = new SSHInMemoryTempFile();
        requestedFiles.put("target", tempFile);
        tavernaExecutor.setOutputFiles(requestedFiles);

        // Execute
        try {
            tavernaExecutor.execute();
            result.setReport(tavernaExecutor.getOutputDoc());

            // Migrated file
            Map<String, ?> outputFiles = tavernaExecutor.getOutputFiles();

            DigitalObject migrated = new DigitalObject();
            for (Entry<String, ?> entry : outputFiles.entrySet()) {
                SSHInMemoryTempFile resultFile = (SSHInMemoryTempFile) entry.getValue();
                migrated.getData().setData(resultFile.getData());
                migrated.setFullname(alternative.getAction().getShortname() + " - " + digitalObject.getFullname());
            }
            result.setMigratedObject(migrated);
            result.setTargetFormat(migrated.getFormatInfo());
            result.setSuccessful(migrated.isDataExistent());

            // Measures
            Map<String, ?> outputData = tavernaExecutor.getOutputData();
            Map<String, Measurement> measurements = new HashMap<String, Measurement>();
            for (Entry<String, ?> outputEntry : outputData.entrySet()) {
                Measurement measurement = createMeasurement(outputEntry.getKey(), outputEntry.getValue());
                if (measurement != null) {
                    measurements.put(measurement.getMeasureId(), measurement);
                }
            }
            result.setMeasurements(measurements);
        } catch (IOException e) {
            throw new PlatoException("Error communicating with the server.", e);
        } catch (TavernaExecutorException e) {
            throw new PlatoException("Error executing taverna workflow", e);
        }
View Full Code Here

        if (action instanceof IMigrationAction) {
            IMigrationAction migrationAction = (IMigrationAction) action;
            SampleObject record = experimentStatus.getNextSample();
            while (record != null) {
                if (record.isDataExistent()) {
                    MigrationResult migrationResult = null;

                    try {
                        DigitalObject workflow = a.getExperiment().getWorkflow();
                        if (workflow != null) {
                            byte[] workflowData = byteStreamManager.load(workflow.getPid());
                            workflow.getData().setData(workflowData);
                        }
                        DigitalObject objectToMigrate = digitalObjectManager.getCopyOfDataFilledDigitalObject(record);
                        migrationResult = migrationAction.migrate(a, objectToMigrate);
                    } catch (StorageException e) {
                        log.error("Failed to load sample object", e);
                    } catch (NullPointerException e) {
                        log.error(
                            "Caught nullpointer exception when running a migration tool. ### WRONG CONFIGURATION? ###",
                            e);
                    } catch (Throwable t) {
                        log.error("Caught unchecked exception when running a migration tool: " + t.getMessage(), t);
                    }

                    // Set detailed info before moving data to storage
                    extractDetailedInfos(a, record, migrationResult);

                    if (migrationResult != null) {
                        try {
                            if (migrationResult.isSuccessful()) {
                                DigitalObject experimentResultObject = a.getExperiment().getResults().get(record);
                                experimentResultObject.assignValues(migrationResult.getMigratedObject());
                                digitalObjectManager.moveDataToStorage(experimentResultObject);

                                addCriteria(a, record, migrationResult);
                            }
                        } catch (StorageException e) {
                            log.error("Could not store migration result", e);
                            migrationResult.setSuccessful(false);
                            migrationResult.setReport("Migration failed - could not store result.");
                        }
                    }
                }
                record = experimentStatus.getNextSample();
            }
View Full Code Here

public class SSHTavernaMigrationActionService implements IMigrationAction {
    private static Logger log = LoggerFactory.getLogger(SSHTavernaMigrationActionService.class);

    @Override
    public boolean perform(Alternative alternative, SampleObject sampleObject) throws PlatoException {
        MigrationResult result = migrate(alternative, sampleObject);
        return result.isSuccessful();
    }
View Full Code Here

        PreservationActionDefinition action = alternative.getAction();

        SSHTavernaExecutor tavernaExecutor = new SSHTavernaExecutor();
        tavernaExecutor.init();

        MigrationResult result = new MigrationResult();

        HashMap<String, Object> inputData = new HashMap<String, Object>();

        WorkflowDescription workflowDescription = MyExperimentRESTClient.getWorkflow(action.getDescriptor());
        workflowDescription.readMetadata();
        if (!workflowDescription.getProfile().equals("http://purl.org/DP/components#MigrationAction")) {
            result.setSuccessful(false);
            result.setReport("The workflow " + action.getUrl() + " is no MigrationAction.");
            return result;
        }

        List<Port> inputPorts = workflowDescription.getInputPorts();

        for (Port p : inputPorts) {
            if (ComponentConstants.VALUE_SOURCE_OBJECT.equals(p.getValue())) {
                inputData.put(p.getName(),
                    tavernaExecutor.new ByteArraySourceFile(FileUtils.makeFilename(digitalObject.getFullname()),
                        digitalObject.getData().getData()));
            } else if (ComponentConstants.VALUE_PARAMETER.equals(p.getValue()) || p.getValue() == null) {
                String value = action.getParamByName(p.getName());
                if (value == null) {
                    value = "";
                }
                inputData.put(p.getName(), value);
            } else {
                result.setSuccessful(false);
                result.setReport("The workflow " + action.getUrl() + " has unsupported port " + p.getName()
                    + " that accepts " + p.getValue());
                return result;
            }
        }
        tavernaExecutor.setInputData(inputData);

        // Workflow
        tavernaExecutor.setWorkflow(action.getUrl());

        // Output ports to receive
        List<Port> outputPorts = workflowDescription.getOutputPorts();
        Set<String> outputPortNames = new HashSet<String>(outputPorts.size());
        String targetPathPort = null;
        for (Port p : outputPorts) {
            outputPortNames.add(p.getName());

            if (ComponentConstants.VALUE_TARGET_OBJECT.equals(p.getValue())) {
                targetPathPort = p.getName();
            }
        }
        tavernaExecutor.setOutputPorts(outputPortNames);

        // Output files
        if (targetPathPort == null) {
            result.setSuccessful(false);
            result.setReport("The workflow " + action.getUrl() + " has not target port.");
            return result;
        }
        HashMap<String, SSHInMemoryTempFile> requestedFiles = new HashMap<String, SSHInMemoryTempFile>(1);
        SSHInMemoryTempFile tempFile = new SSHInMemoryTempFile();
        requestedFiles.put(targetPathPort, tempFile);
        tavernaExecutor.setOutputFiles(requestedFiles);

        // Execute
        try {
            tavernaExecutor.execute();
        } catch (IOException e) {
            result.setSuccessful(false);
            result.setReport("Error connecting to execution server");
            log.error("Error connecting to execution server", e);
            return result;
        } catch (TavernaExecutorException e) {
            result.setSuccessful(false);
            result.setReport("Error executing taverna workflow");
            log.error("Error executing taverna workflow", e);
            return result;
        }

        result.setSuccessful(true);
        result.setReport(tavernaExecutor.getOutputDoc());

        Map<String, ?> outputFiles = tavernaExecutor.getOutputFiles();

        DigitalObject u = new DigitalObject();
        for (Entry<String, ?> entry : outputFiles.entrySet()) {
            SSHInMemoryTempFile resultFile = (SSHInMemoryTempFile) entry.getValue();
            u.getData().setData(resultFile.getData());
            u.setFullname(action.getShortname() + " - " + digitalObject.getFullname());
        }
        FormatInfo tFormat = new FormatInfo();
        result.setTargetFormat(tFormat);
        result.setMigratedObject(u);

        return result;
    }
View Full Code Here

TOP

Related Classes of eu.scape_project.planning.model.beans.MigrationResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.