Skip to content

Commit

Permalink
No anonymous inner classes in classes extending MachineLifecycleEffec…
Browse files Browse the repository at this point in the history
…torTasks
  • Loading branch information
Sam Corbett committed Jul 29, 2015
1 parent f012c9c commit fcb1af0
Show file tree
Hide file tree
Showing 3 changed files with 233 additions and 150 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected Collection<Integer> getRequiredOpenPorts(Entity entity) {
value = maybeValue.isPresent() ? maybeValue.get() : null;
}

Maybe<PortRange> maybePortRange = TypeCoercions.tryCoerce(value, new TypeToken<PortRange>() {});
Maybe<PortRange> maybePortRange = TypeCoercions.tryCoerce(value, TypeToken.of(PortRange.class));

if (maybePortRange.isPresentAndNonNull()) {
PortRange p = maybePortRange.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,30 @@ public void restart(ConfigBag parameters) {
return;
}

DynamicTasks.queue("pre-restart", new Runnable() { public void run() {
preRestartCustom();
}});
DynamicTasks.queue("pre-restart", new PreRestartTask());

log.debug("restart of "+entity()+" appears to have driver and hostname - doing driver-level restart");
entity().getDriver().restart();

restartChildren(parameters);

DynamicTasks.queue("post-restart", new Runnable() { public void run() {
DynamicTasks.queue("post-restart", new PostRestartTask());
}

private class PreRestartTask implements Runnable {
@Override
public void run() {
preRestartCustom();
}
}

private class PostRestartTask implements Runnable {
@Override
public void run() {
postStartCustom();
postRestartCustom();
ServiceStateLogic.setExpectedState(entity(), Lifecycle.RUNNING);
}});
}
}

@Override
Expand Down Expand Up @@ -233,7 +243,7 @@ protected String stopProcessesAtMachine() {

if (childException!=null)
throw new IllegalStateException(result+"; but error stopping child: "+childException, childException);

return result;
}

Expand Down
Loading

0 comments on commit fcb1af0

Please sign in to comment.