@Test(dependsOnMethods = { "testGetDatasetState" }) public void testGetStoreNames() throws IOException { List<String> storeNames = this.zkJobStateStore.getStoreNames(Predicates.alwaysTrue()); Collections.sort(storeNames); Assert.assertTrue(storeNames.size() == 2); Assert.assertEquals(storeNames.get(0), TEST_JOB_NAME); Assert.assertEquals(storeNames.get(1), TEST_JOB_NAME2); storeNames = this.zkDatasetStateStore.getStoreNames(Predicates.alwaysTrue()); Collections.sort(storeNames); Assert.assertTrue(storeNames.size() == 2); Assert.assertEquals(storeNames.get(0), TEST_JOB_NAME); Assert.assertEquals(storeNames.get(1), TEST_JOB_NAME2); }
@Override public void run(String[] args) throws Exception { CliObjectFactory<Command> factory = new ConstructorAndPublicMethodsCliObjectFactory<>(Command.class); Command command = factory.buildObject(args, 1, true, args[0]); FileSystem fs = FileSystem.get(new Configuration()); FSDataInputStream inputStream = fs.open(command.path); Config config = ConfigFactory.parseReader(new InputStreamReader(inputStream, Charset.defaultCharset())); Preconditions.checkNotNull(config.getObject(SOURCE_KEY)); Preconditions.checkNotNull(config.getObject(DESTINATION_KEY)); DatasetStateStore dstDatasetStateStore = DatasetStateStore.buildDatasetStateStore(config.getConfig(DESTINATION_KEY)); DatasetStateStore srcDatasetStateStore = DatasetStateStore.buildDatasetStateStore(config.getConfig(SOURCE_KEY)); Map<String, JobState.DatasetState> map; // if migrating state for all jobs then list the store names (job names) and copy the current jst files if (ConfigUtils.getBoolean(config, MIGRATE_ALL_JOBS, Boolean.valueOf(DEFAULT_MIGRATE_ALL_JOBS))) { List<String> jobNames = srcDatasetStateStore.getStoreNames(Predicates.alwaysTrue()); for (String jobName : jobNames) { migrateStateForJob(srcDatasetStateStore, dstDatasetStateStore, jobName, command.deleteSourceStateStore); } } else { Preconditions.checkNotNull(config.getString(JOB_NAME_KEY)); migrateStateForJob(srcDatasetStateStore, dstDatasetStateStore, config.getString(JOB_NAME_KEY), command.deleteSourceStateStore); } }
@Test(dependsOnMethods = { "testGetDatasetState" }) public void testGetStoreNames() throws IOException { List<String> storeNames = this.dbJobStateStore.getStoreNames(Predicates.alwaysTrue()); Collections.sort(storeNames); Assert.assertTrue(storeNames.size() == 3); Assert.assertEquals(storeNames.get(0), TEST_JOB_NAME); Assert.assertEquals(storeNames.get(1), TEST_JOB_NAME2); Assert.assertEquals(storeNames.get(2), TEST_JOB_NAME_LOWER); storeNames = this.dbDatasetStateStore.getStoreNames(Predicates.alwaysTrue()); Collections.sort(storeNames); Assert.assertTrue(storeNames.size() == 2); Assert.assertEquals(storeNames.get(0), TEST_JOB_NAME); Assert.assertEquals(storeNames.get(1), TEST_JOB_NAME2); }
@Override public void run(String[] args) throws Exception { CliObjectFactory<Command> factory = new ConstructorAndPublicMethodsCliObjectFactory<>(Command.class); Command command = factory.buildObject(args, 1, true, args[0]); FileSystem fs = FileSystem.get(new Configuration()); FSDataInputStream inputStream = fs.open(command.path); Config config = ConfigFactory.parseReader(new InputStreamReader(inputStream, Charset.defaultCharset())); Preconditions.checkNotNull(config.getObject(SOURCE_KEY)); Preconditions.checkNotNull(config.getObject(DESTINATION_KEY)); DatasetStateStore dstDatasetStateStore = DatasetStateStore.buildDatasetStateStore(config.getConfig(DESTINATION_KEY)); DatasetStateStore srcDatasetStateStore = DatasetStateStore.buildDatasetStateStore(config.getConfig(SOURCE_KEY)); Map<String, JobState.DatasetState> map; // if migrating state for all jobs then list the store names (job names) and copy the current jst files if (ConfigUtils.getBoolean(config, MIGRATE_ALL_JOBS, Boolean.valueOf(DEFAULT_MIGRATE_ALL_JOBS))) { List<String> jobNames = srcDatasetStateStore.getStoreNames(Predicates.alwaysTrue()); for (String jobName : jobNames) { migrateStateForJob(srcDatasetStateStore, dstDatasetStateStore, jobName, command.deleteSourceStateStore); } } else { Preconditions.checkNotNull(config.getString(JOB_NAME_KEY)); migrateStateForJob(srcDatasetStateStore, dstDatasetStateStore, config.getString(JOB_NAME_KEY), command.deleteSourceStateStore); } }