use of co.cask.cdap.internal.app.runtime.schedule.store.ProgramScheduleStoreDataset in project cdap by caskdata.
the class CoreSchedulerService method migrateSchedules.
private void migrateSchedules(final NamespaceQueryAdmin namespaceQueryAdmin, final Store appMetaStore) throws Exception {
List<NamespaceMeta> namespaceMetas = namespaceQueryAdmin.list();
boolean migrateComplete = execute(new StoreTxRunnable<Boolean, RuntimeException>() {
@Override
public Boolean run(ProgramScheduleStoreDataset store) {
return store.isMigrationComplete();
}
}, RuntimeException.class);
if (migrateComplete) {
// no need to migrate if migration is complete
return;
}
String completedNamespace = null;
for (NamespaceMeta namespaceMeta : namespaceMetas) {
final NamespaceId namespaceId = namespaceMeta.getNamespaceId();
// the current namespace lexicographically, then the current namespace is already migrated. Skip this namespace.
if (completedNamespace != null && completedNamespace.compareTo(namespaceId.toString()) > 0) {
continue;
}
completedNamespace = execute(new StoreTxRunnable<String, RuntimeException>() {
@Override
public String run(ProgramScheduleStoreDataset store) {
return store.migrateFromAppMetadataStore(namespaceId, appMetaStore);
}
}, RuntimeException.class);
}
// Set migration complete after migrating all namespaces
execute(new StoreTxRunnable<Void, RuntimeException>() {
@Override
public Void run(ProgramScheduleStoreDataset store) {
store.setMigrationComplete();
return null;
}
}, RuntimeException.class);
}
Aggregations