Package org.rssowl.core.internal.persist.migration

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


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

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

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

Related Classes of org.rssowl.core.internal.persist.migration.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.