Examples of MigrationResult


Examples of eu.planets_project.pp.plato.services.action.MigrationResult

                    try {
                        for (File f : directory.listFiles()) {
                            log.debug("testing " + config.getUrl() + " with file "
                                    + f.getName());
                            byte[] data = FileUtils.getBytesFromFile(f);
                            MigrationResult r = engine.migrate(data, "minimee/"+ config.getUrl(), "");
                            if (!r.isSuccessful()) {
                                log.warn(r.getReport());
                                initResults.put(config.getUrl(), "FAILED: "
                                        + r.getReport());
                            } else {
                                initResults.put(config.getUrl(), "SUCCESS");
                            }
                        }
                    } catch (Exception e) {
View Full Code Here

Examples of eu.planets_project.pp.plato.services.action.MigrationResult

        StringBuffer runDescription = new StringBuffer();

        if (action instanceof IMigrationAction) {
            DigitalObject migrationResultObject;
            DigitalObject experimentResultObject;
            MigrationResult migrationResult = null;
            IMigrationAction migrationAction = (IMigrationAction) action;
            //                int nextIndex = experimentStatus.getNextSampleIndex();
            SampleObject record = experimentStatus.getNextSample(); //null;
            //                if (nextIndex >= 0 && nextIndex < selectedPlan.getSampleRecordsDefinition().getRecords().size()) {
            //                    record = selectedPlan.getSampleRecordsDefinition().getRecords().get(nextIndex);
            //                }
            //experimentStatus.getNextSample();
            while (record != null) {
                if (record.isDataExistent()) {

                    // objectTomigrate is only being read, needs to be merged to lazily get the data out
                    SampleObject objectToMigrate = em.merge(record);

                    try {
                        // ACTION HAPPENS HERE:
                        migrationResult =  migrationAction.migrate(pad, objectToMigrate);
                    } catch (NullPointerException npe) {
                        log.error("Caught nullpointer exception when running a migration tool. ### WRONG CONFIGURATION? ###",npe);
                    } catch (Throwable t) {
                        log.error("Caught unchecked exception when running a migration tool: "+t.getMessage(),t);
                        //throw new PlatoServiceException("Could not run service "+a.getName()+" on object "+record.getShortName(),t);
                    }

                    if (migrationResult != null) {

                        if (migrationResult.isSuccessful() && migrationResult.getMigratedObject() != null) {
                           
                            experimentResultObject = a.getExperiment().getResults().get(record);
                            migrationResultObject = migrationResult.getMigratedObject();
                            experimentResultObject.setContentType(migrationResultObject.getContentType());
                            experimentResultObject.getFormatInfo().assignValues(migrationResultObject.getFormatInfo());

                            int size = saveTempFile(experimentResultObject,migrationResultObject);
                            experimentResultObject.getData().setSize(size);
View Full Code Here

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

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

        }
    }

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

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

     * 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

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

    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

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

     * @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

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

        cm.init();
    }

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

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

    }

    @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

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

        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
TOP
Copyright © 2018 www.massapi.com. 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.