Search in sources :

Example 1 with ProgramScheduleStoreDataset

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);
}
Also used : ProgramScheduleStoreDataset(co.cask.cdap.internal.app.runtime.schedule.store.ProgramScheduleStoreDataset) NamespaceMeta(co.cask.cdap.proto.NamespaceMeta) NamespaceId(co.cask.cdap.proto.id.NamespaceId)

Aggregations

ProgramScheduleStoreDataset (co.cask.cdap.internal.app.runtime.schedule.store.ProgramScheduleStoreDataset)1 NamespaceMeta (co.cask.cdap.proto.NamespaceMeta)1 NamespaceId (co.cask.cdap.proto.id.NamespaceId)1