Github user hsaputra commented on a diff in the pull request:
https://github.com/apache/incubator-twill/pull/52#discussion_r34505505
--- Diff:
twill-core/src/main/java/org/apache/twill/internal/AbstractTwillController.java
---
@@ -109,6 +121,75 @@ public final ServiceDiscovered discoverService(String
serviceName) {
return sendMessage(SystemMessages.setInstances(runnable, newCount),
newCount);
}
+ @Override
+ public final ListenableFuture<String> restartAllInstances(String
runnableName) {
+ Command updateStateCommand =
Command.Builder.of(Constants.RESTART_ALL_RUNNABLE_INSTANCES).
+ build();
+ Message message =
SystemMessages.updateRunnableInstances(updateStateCommand, runnableName);
+ return sendMessage(message, updateStateCommand.getCommand());
+ }
+
+ @Override
+ public final ListenableFuture<Set<String>> restartInstances(Map<String,
+ ? extends Set<Integer>> runnableToInstanceIds) {
+ Map<String, String> runnableToStringInstanceIds =
+ Maps.transformEntries(runnableToInstanceIds, new
Maps.EntryTransformer<String, Set<Integer>, String>() {
+ @Override
+ public String transformEntry(String runnableName, Set<Integer>
instanceIds) {
+ validateInstanceIds(runnableName, instanceIds);
+ return GSON.toJson(instanceIds, new TypeToken<Set<Integer>>()
{}.getType());
+ }
+ });
+
+ Command updateStateCommand =
Command.Builder.of(Constants.RESTART_RUNNABLES_INSTANCES)
+ .addOptions(runnableToStringInstanceIds)
+ .build();
+ Message message =
SystemMessages.updateRunnablesInstances(updateStateCommand);
+
+ return sendMessage(message, runnableToInstanceIds.keySet());
+ }
+
+ @Override
+ public ListenableFuture<String> restartInstances(String runnable, int
instanceId, int... moreInstanceIds) {
+ Set<Integer> instanceIds = Sets.newLinkedHashSet();
+ instanceIds.add(instanceId);
+ for (int id : moreInstanceIds) {
+ instanceIds.add(id);
+ }
+
+ validateInstanceIds(runnable, instanceIds);
--- End diff --
Sounds good to me. Let me know if you have other comments. for a full pass.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---