/** * Determine if the task executed successfully in a prior attempt by checkitn the task state store for the success * marker. * @param taskId task id to check * @return whether the task was processed successfully in a prior attempt */ private boolean taskSuccessfulInPriorAttempt(String taskId) { if (this.taskStateStoreOptional.isPresent()) { StateStore<TaskState> taskStateStore = this.taskStateStoreOptional.get(); // Delete the task state file for the task if it already exists. // This usually happens if the task is retried upon failure. try { if (taskStateStore.exists(jobId, taskId + TASK_STATE_STORE_SUCCESS_MARKER_SUFFIX)) { log.info("Skipping task {} that successfully executed in a prior attempt.", taskId); // skip tasks that executed successfully in a previous attempt return true; } } catch (IOException e) { // if an error while looking up the task state store then treat like it was not processed return false; } } return false; }
@Nullable private State getOrCreate (String storeName, String jobName) throws IOException { if (this.stateStore.exists(storeName, jobName)) { return this.stateStore.get(storeName, jobName, jobName); } return new State(); }
@Test(dependsOnMethods = { "testPut" }) public void testCreateAlias() throws IOException { this.stateStore.createAlias("testStore", "testTable", "testTable1"); Assert.assertTrue(this.stateStore.exists("testStore", "testTable1")); }
@Test public void testBackwardsCompat() throws IOException { // Tests with a state store that was saved before the WritableShim changes Config bwConfig = ConfigFactory.load(config); URL path = getClass().getResource("/backwardsCompatTestStore"); Assert.assertNotNull(path); bwConfig = bwConfig.withValue(ConfigurationKeys.STATE_STORE_ROOT_DIR_KEY, ConfigValueFactory.fromAnyRef(path.toString())); StateStore<State> bwStateStore = stateStoreFactory.createStateStore(bwConfig, State.class); Assert.assertTrue(bwStateStore.exists("testStore", "testTable")); List<State> states = bwStateStore.getAll("testStore", "testTable"); Assert.assertEquals(states.size(), 3); Assert.assertEquals(states.get(0).getProp("k1"), "v1"); Assert.assertEquals(states.get(1).getProp("k2"), "v2"); Assert.assertEquals(states.get(2).getProp("k3"), "v3"); }
@Test public void testPut() throws IOException { List<State> states = Lists.newArrayList(); State state1 = new State(); state1.setId("s1"); state1.setProp("k1", "v1"); states.add(state1); State state2 = new State(); state2.setId("s2"); state2.setProp("k2", "v2"); states.add(state2); State state3 = new State(); state3.setId("s3"); state3.setProp("k3", "v3"); states.add(state3); Assert.assertFalse(this.stateStore.exists("testStore", "testTable")); this.stateStore.putAll("testStore", "testTable", states); Assert.assertTrue(this.stateStore.exists("testStore", "testTable")); // for testing of getStoreNames this.stateStore.putAll("testStore2", "testTable", states); }
if (taskStateStore.exists(jobId, taskId + AbstractJobLauncher.TASK_STATE_STORE_TABLE_SUFFIX)) { taskStateStore.delete(jobId, taskId + AbstractJobLauncher.TASK_STATE_STORE_TABLE_SUFFIX);
/** * Determine if the task executed successfully in a prior attempt by checkitn the task state store for the success * marker. * @param taskId task id to check * @return whether the task was processed successfully in a prior attempt */ private boolean taskSuccessfulInPriorAttempt(String taskId) { if (this.taskStateStoreOptional.isPresent()) { StateStore<TaskState> taskStateStore = this.taskStateStoreOptional.get(); // Delete the task state file for the task if it already exists. // This usually happens if the task is retried upon failure. try { if (taskStateStore.exists(jobId, taskId + TASK_STATE_STORE_SUCCESS_MARKER_SUFFIX)) { log.info("Skipping task {} that successfully executed in a prior attempt.", taskId); // skip tasks that executed successfully in a previous attempt return true; } } catch (IOException e) { // if an error while looking up the task state store then treat like it was not processed return false; } } return false; }
if (taskStateStore.exists(jobId, taskId + AbstractJobLauncher.TASK_STATE_STORE_TABLE_SUFFIX)) { taskStateStore.delete(jobId, taskId + AbstractJobLauncher.TASK_STATE_STORE_TABLE_SUFFIX);