@Override public void applyMigration() { final long start = System.currentTimeMillis(); try { if (curator.checkExists().forPath(PENDING_TASKS_ROOT) == null) { return; } } catch (Exception e) { throw Throwables.propagate(e); } try { for (String pendingTaskId : curator.getChildren().forPath(PENDING_TASKS_ROOT)) { SingularityPendingTaskId newPendingTaskId = createFrom(pendingTaskId, start); if (!newPendingTaskId.toString().equals(pendingTaskId)) { LOG.info("Migrating {} to {}", pendingTaskId, newPendingTaskId); Optional<String> cmdLineArgs = getCmdLineArgs(pendingTaskId); taskManager.savePendingTask( new SingularityPendingTaskBuilder() .setPendingTaskId(newPendingTaskId) .setCmdLineArgsList(cmdLineArgs.isPresent() ? Optional.of(Collections.singletonList(cmdLineArgs.get())) : Optional.<List<String>> absent()) .build()); curator.delete().forPath(ZKPaths.makePath(PENDING_TASKS_ROOT, pendingTaskId)); } } } catch (Exception e) { throw Throwables.propagate(e); } }
@Override public void applyMigration() { final long start = System.currentTimeMillis(); try { if (curator.checkExists().forPath(PENDING_TASKS_ROOT) == null) { return; } } catch (Exception e) { throw Throwables.propagate(e); } try { for (String pendingTaskId : curator.getChildren().forPath(PENDING_TASKS_ROOT)) { SingularityPendingTaskId newPendingTaskId = createFrom(pendingTaskId, start); if (!newPendingTaskId.toString().equals(pendingTaskId)) { LOG.info("Migrating {} to {}", pendingTaskId, newPendingTaskId); Optional<String> cmdLineArgs = getCmdLineArgs(pendingTaskId); taskManager.savePendingTask( new SingularityPendingTaskBuilder() .setPendingTaskId(newPendingTaskId) .setCmdLineArgsList(cmdLineArgs.isPresent() ? Optional.of(Collections.singletonList(cmdLineArgs.get())) : Optional.<List<String>> absent()) .build()); curator.delete().forPath(ZKPaths.makePath(PENDING_TASKS_ROOT, pendingTaskId)); } } } catch (Exception e) { throw Throwables.propagate(e); } }