Examples of MigrationResult


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

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

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

        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

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);
        // provide a nice name for the resulting object
        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

                    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 org.rssowl.core.internal.persist.migration.MigrationResult

    checkDirPermissions();

    /* Create Configuration and check for Migration */
    Configuration config = createConfiguration(false);
    int workspaceVersion = getWorkspaceFormatVersion();
    MigrationResult migrationResult = new MigrationResult(false, false, false);

    SubMonitor subMonitor = null;
    try {

      /* Log previously failing Online Backup */
      try {
        if (getOnlineBackupMarkerFile().exists()) {
          Activator.safeLogInfo("Detected an Online Backup that did not complete"); //$NON-NLS-1$
          safeDelete(getOnlineBackupMarkerFile());
        }
      } catch (Exception e) {
        /* Ignore */
      }

      /* Log previously failing Reindexing */
      try {
        if (getReindexMarkerFile().exists()) {
          Activator.safeLogInfo("Detected a Search Re-Indexing that did not complete"); //$NON-NLS-1$
          safeDelete(getReindexMarkerFile());
        }
      } catch (Exception e) {
        /* Ignore */
      }

      /* Perform Migration if necessary */
      if (workspaceVersion != getCurrentFormatVersion()) {
        progressMonitor.beginLongOperation(false);
        subMonitor = SubMonitor.convert(progressMonitor, Messages.DBManager_RSSOWL_MIGRATION, 100);

        //TODO Have a better way to allocate the ticks to the child. We need
        //to be able to do it dynamically based on whether a reindex is required or not.
        migrationResult = migrate(workspaceVersion, getCurrentFormatVersion(), subMonitor.newChild(70));
      }

      /* Perform Defrag if necessary */
      if (!defragmentIfNecessary(progressMonitor, subMonitor)) {

        /* Defragment */
        if (migrationResult.isDefragmentDatabase())
          defragment(progressMonitor, subMonitor);

        /*
         * We only run the time-based back-up if a defragment has not taken
         * place because we always back-up during defragment.
         */
        else
          scheduledBackup(progressMonitor);
      }

      /* Open the DB */
      startupStatus = createObjectContainer(config);

      /* Notify Listeners that DB is opened */
      if (startupStatus.isOK())
        fireDatabaseEvent(new DatabaseEvent(fObjectContainer, fLock), true);

      /* Re-Index Search Index if necessary */
      boolean shouldReindex = shouldReindex(migrationResult, startupStatus);
      if (subMonitor == null && shouldReindex) {
        progressMonitor.beginLongOperation(false);
        subMonitor = SubMonitor.convert(progressMonitor, Messages.DBManager_PROGRESS_WAIT, 20);
      }

      IModelSearch modelSearch = InternalOwl.getDefault().getPersistenceService().getModelSearch();
      if (!progressMonitor.isCanceled() && (shouldReindex || migrationResult.isOptimizeIndex())) {
        modelSearch.startup();
        if (shouldReindex && !progressMonitor.isCanceled()) {
          Activator.safeLogInfo("Start: Search Re-Indexing"); //$NON-NLS-1$

          File marker = getReindexMarkerFile();
          try {

            /* Create Marker that Reindexing is Performed */
            if (!marker.exists())
              safeCreate(marker);

            /* Reindex Search Index */
            modelSearch.reindexAll(subMonitor != null ? subMonitor.newChild(20) : new NullProgressMonitor());
          } finally {
            safeDelete(marker);
          }

          if (progressMonitor.isCanceled())
            Activator.safeLogInfo("Cancelled: Search Re-Indexing"); //$NON-NLS-1$
          else
            Activator.safeLogInfo("Finished: Search Re-Indexing"); //$NON-NLS-1$
        }

        /* Optimize Index if Necessary */
        if (migrationResult.isOptimizeIndex() && !progressMonitor.isCanceled())
          modelSearch.optimize();
      }
    } finally {
      if (subMonitor != null) //If we perform the migration, the subMonitor is not null. Otherwise we don't show progress.
        progressMonitor.done();
View Full Code Here

Examples of org.rssowl.core.internal.persist.migration.MigrationResult

    /* Create a copy of the db file to use for the migration */
    File migDbFile = backupService.getTempBackupFile();
    DBHelper.copyFileNIO(dbFile, migDbFile);

    /* Migrate the copy */
    MigrationResult migrationResult = migration.migrate(configFactory, migDbFile.getAbsolutePath(), progressMonitor);

    File dbFormatFile = getDBFormatFile();
    File migFormatFile = new File(dbFormatFile.getAbsolutePath() + ".mig.temp"); //$NON-NLS-1$
    try {
      if (!migFormatFile.exists()) {
View Full Code Here

Examples of org.rssowl.core.internal.persist.migration.MigrationResult

    /* Assert File Permissions */
    checkDirPermissions();

    SubMonitor subMonitor = null;
    MigrationResult migrationResult = new MigrationResult(false, false, false);
    try {

      /* Migration and Defragment only apply to non-emergency situations */
      if (!emergency) {

        /* Check for Migration */
        int workspaceVersion = getWorkspaceFormatVersion();

        /* Log previously failing Online Backup */
        try {
          if (getOnlineBackupMarkerFile().exists()) {
            Activator.safeLogInfo("Detected an Online Backup that did not complete"); //$NON-NLS-1$
            safeDelete(getOnlineBackupMarkerFile());
          }
        } catch (Exception e) {
          /* Ignore */
        }

        /* Log previously failing Reindexing */
        try {
          if (getReindexMarkerFile().exists()) {
            Activator.safeLogInfo("Detected a Search Re-Indexing that did not complete"); //$NON-NLS-1$
            safeDelete(getReindexMarkerFile());
          }
        } catch (Exception e) {
          /* Ignore */
        }

        /* Perform Migration if necessary */
        if (ENABLE_MIGRATION && workspaceVersion != getCurrentFormatVersion()) {
          progressMonitor.beginLongOperation(false);
          subMonitor = SubMonitor.convert(progressMonitor, Messages.DBManager_RSSOWL_MIGRATION, 100);
          migrationResult = migrate(workspaceVersion, getCurrentFormatVersion(), subMonitor.newChild(70));
        }

        /* Perform Defrag if necessary */
        if (!defragmentIfNecessary(progressMonitor, subMonitor)) {

          /* Defragment */
          if (migrationResult.isDefragmentDatabase())
            defragment(false, progressMonitor, subMonitor);

          /*
           * We only run the time-based back-up if a defragment has not taken
           * place because we always back-up during defragment.
           */
          else if (PERFORM_SCHEDULED_BACKUPS)
            scheduledBackup(progressMonitor);
        }
      }

      /* Open the DB */
      Configuration config = createConfiguration(false);
      createObjectContainer(config, forRestore);

      /* Notify Listeners that DB is opened */
      fireDatabaseEvent(new DatabaseEvent(fObjectContainer, fLock), true);

      /*
       * Model Search Reindex or Cleanup only applies to non-emergency
       * situations
       */
      if (!emergency) {

        /* Re-Index Search Index if necessary */
        boolean reindexed = false;
        {
          boolean shouldReindex = shouldReindex(migrationResult);
          if (shouldReindex) {
            progressMonitor.beginLongOperation(false);
            subMonitor = SubMonitor.convert(progressMonitor, Messages.DBManager_PROGRESS_WAIT, 20);
          }

          IModelSearch modelSearch = InternalOwl.getDefault().getPersistenceService().getModelSearch();
          if (!progressMonitor.isCanceled() && (shouldReindex || migrationResult.isOptimizeIndex())) {

            /* Reindex */
            if (shouldReindex && !progressMonitor.isCanceled()) {
              Activator.safeLogInfo("Start: Search Re-Indexing"); //$NON-NLS-1$

View Full Code Here

Examples of org.rssowl.core.internal.persist.migration.MigrationResult

    /* Create a copy of the db file to use for the migration */
    File migDbFile = backupService.getTempBackupFile();
    DBHelper.copyFileNIO(dbFile, migDbFile);

    /* Migrate the copy */
    MigrationResult migrationResult = migration.migrate(configFactory, migDbFile.getAbsolutePath(), progressMonitor);

    File dbFormatFile = getDBFormatFile();
    File migFormatFile = new File(dbFormatFile.getAbsolutePath() + ".mig.temp"); //$NON-NLS-1$
    try {
      if (!migFormatFile.exists()) {
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.