@Override public void setVersion( final String pluginName, final int version ) { migrationInfoSerialization.setVersion( pluginName, version ); versionCache.invalidate( pluginName ); }
@Override public void resetToVersion( final String pluginName, final int version ) { Preconditions.checkNotNull( pluginName, "pluginName cannot be null" ); final MigrationPlugin plugin = migrationPlugins.get( pluginName ); Preconditions.checkArgument( plugin != null, "Plugin " + pluginName + " could not be found" ); final int highestAllowed = plugin.getMaxVersion(); Preconditions.checkArgument( version <= highestAllowed, "You cannot set a version higher than the max of " + highestAllowed + " for plugin " + pluginName ); Preconditions.checkArgument( version >= 0, "You must specify a version of 0 or greater" ); migrationInfoSerialization.setVersion( pluginName, version ); migrationInfoCache.invalidateAll(); }
@After public void reSetMigrationVersion() { migrationInfoSerialization.setVersion(GraphMigrationPlugin.PLUGIN_NAME, existingVersion ); }
@After public void reSetMigrationVersion() { migrationInfoSerialization.setVersion(CollectionMigrationPlugin.PLUGIN_NAME, existingVersion ); } }
@After public void reSetMigrationVersion() { migrationInfoSerialization.setVersion( CollectionMigrationPlugin.PLUGIN_NAME, existingVersion ); }
@After public void reSetMigrationVersion() { migrationInfoSerialization.setVersion(CollectionMigrationPlugin.PLUGIN_NAME, existingVersion ); }
@After public void reSetMigrationVersion() { migrationInfoSerialization.setVersion( GraphMigrationPlugin.PLUGIN_NAME, existingVersion ); }
@After public void reSetMigrationVersion() { migrationInfoSerialization.setVersion(CollectionMigrationPlugin.PLUGIN_NAME, existingVersion ); }
migrationInfoSerialization.setVersion( getName(), newSystemVersion );
/** * Happy path of version reset */ @Test public void testResetToVersion() { final String name = "plugin1"; final int version = 10; //linked hash set is intentional here. For iteration order we can boostrap to come second so we can //verify it was actually run first final Set<MigrationPlugin> plugins = new LinkedHashSet<>(); MigrationPlugin plugin1 = mock( MigrationPlugin.class ); when( plugin1.getPhase() ).thenReturn( PluginPhase.MIGRATE ); when( plugin1.getName() ).thenReturn( name ); when( plugin1.getMaxVersion() ).thenReturn( version ); plugins.add( plugin1 ); final MigrationInfoSerialization migrationInfoSerialization = mock( MigrationInfoSerialization.class ); final MigrationInfoCache migrationInfoCache = mock(MigrationInfoCache.class); DataMigrationManagerImpl migrationManager = new DataMigrationManagerImpl( plugins, migrationInfoSerialization, migrationInfoCache ); migrationManager.resetToVersion( name, 0 ); verify( migrationInfoSerialization ).setVersion( name, 0 ); migrationManager.resetToVersion( name, version ); verify( migrationInfoSerialization ).setVersion( name, version ); }
/** * We need to run our migration to ensure that we are on the current version, and everything still functions * correctly */ @Before public void setMigrationVersion() { existingVersion = migrationInfoSerialization.getVersion( CollectionMigrationPlugin.PLUGIN_NAME); //set our new version, so that is will run through the new code migrationInfoSerialization.setVersion( CollectionMigrationPlugin.PLUGIN_NAME, v2Impl.getImplementationVersion() ); }
/** * We need to run our migration to ensure that we are on the current version, and everything still functions * correctly */ @Before public void setMigrationVersion() { existingVersion = migrationInfoSerialization.getVersion( GraphMigrationPlugin.PLUGIN_NAME ); //set our version equal to the new version so it only delegates to the new version migrationInfoSerialization .setVersion( GraphMigrationPlugin.PLUGIN_NAME, edgeMetadataSerializationV2.getImplementationVersion() ); }
/** * We need to run our migration to ensure that we are on the current version, and everything still functions * correctly */ @Before public void setMigrationVersion() { existingVersion = migrationInfoSerialization.getVersion( CollectionMigrationPlugin.PLUGIN_NAME); //set our migration version to be v1 migrationInfoSerialization.setVersion( CollectionMigrationPlugin.PLUGIN_NAME, v1Impl.getImplementationVersion() ); }
@Override public void run( ProgressObserver observer ) { final int version = migrationInfoSerialization.getVersion( getName() ); if ( version == getMaxVersion() ) { if (logger.isDebugEnabled()) { logger.debug("Skipping Migration Plugin: {}", getName()); } return; } observer.start(); AtomicInteger count = new AtomicInteger(); //get old app infos to migrate final Observable<Entity> oldAppInfos = getOldAppInfos(); oldAppInfos.doOnNext( oldAppInfoEntity -> { migrateAppInfo( oldAppInfoEntity, observer ); count.incrementAndGet(); } ) //we want a doOnError to catch something going wrong, otherwise we'll mark as complete .doOnError( error -> { logger.error( "Unable to migrate applications, an error occurred. Please try again", error ); observer.failed( getMaxVersion(), "Unable to migrate applications", error ); } ) //if we complete successfully, set the version and notify the observer .doOnCompleted( () -> { migrationInfoSerialization.setVersion( getName(), getMaxVersion() ); observer.complete(); } ).subscribe();//let this run through since it handles errors }
/** * We need to run our migration to ensure that we are on the current version, and everything still functions * correctly */ @Before public void setMigrationVersion() { existingVersion = migrationInfoSerialization.getVersion( CollectionMigrationPlugin.PLUGIN_NAME); //set our migration version to be v1 migrationInfoSerialization.setVersion( CollectionMigrationPlugin.PLUGIN_NAME, mvccEntitySerializationStrategyV1.getImplementationVersion() ); }
/** * We need to run our migration to ensure that we are on the current version, and everything still functions * correctly */ @Before public void setMigrationVersion() { existingVersion = migrationInfoSerialization.getVersion( GraphMigrationPlugin.PLUGIN_NAME); //set our version to 0 so it uses both impls of the proxy migrationInfoSerialization.setVersion(GraphMigrationPlugin.PLUGIN_NAME, edgeMetadataSerializationV1.getImplementationVersion() ); }
/** * We need to run our migration to ensure that we are on the current version, and everything still functions * correctly */ @Before public void setMigrationVersion() { existingVersion = migrationInfoSerialization.getVersion( CollectionMigrationPlugin.PLUGIN_NAME); //set our migration version to be v1 migrationInfoSerialization.setVersion( CollectionMigrationPlugin.PLUGIN_NAME, v1Impl.getImplementationVersion() ); }
}) .doOnCompleted(() -> { migrationInfoSerialization.setVersion(getName(), getMaxVersion()); observer.complete(); })
migrationInfoSerialization.setVersion(migrationModule, savedVersion );