> On Dec. 12, 2013, 11:08 p.m., Bill Farner wrote: > > src/main/java/com/twitter/aurora/scheduler/http/Maintenance.java, line 68 > > <https://reviews.apache.org/r/16220/diff/3/?file=396978#file396978line68> > > > > While N is not _huge_ here, there is redundant work in multiple calls > > to getHostAttributes(). I suspect it wouldn't be hard to rework so that's > > only fetched once. > > Zameer Manji wrote: > I don't think it is worth it here. If you disagree I can encapsulate all > of the logic into a stateful private class that does not make multiple calls.
The class doesn't have to be stateful, you just need to store the result of getHostAttributes() in the calling method: Multimap<MaintenanceMode, String> hostsByMode = Multimaps.index(storeProvider.getAttributeStore().getHostAttributes(), GET_MODE); Map<MaintenanceMode, Object> hosts = Maps.newHashMap(); hosts.put(DRAINING, getDrainingTasks(storeProvider, hostsByMode.get(DRAINING)); hosts.put(DRAINED, ImmutableSet.copyOf(hostsByMode.get(DRAINED))); hosts.put(SCHEDULED, ImmutableSet.copyOf(hostsByMode.get(SCHEDULED))); - Bill ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/16220/#review30294 ----------------------------------------------------------- On Dec. 13, 2013, 12:02 a.m., Zameer Manji wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/16220/ > ----------------------------------------------------------- > > (Updated Dec. 13, 2013, 12:02 a.m.) > > > Review request for Aurora, Kevin Sweeney and Bill Farner. > > > Bugs: AURORA-9 > https://issues.apache.org/jira/browse/AURORA-9 > > > Repository: aurora > > > Description > ------- > > Improve the /maintenance endpoint to print out hosts affected by SCHEDULED > and DRAINED states. > > > Diffs > ----- > > src/main/java/com/twitter/aurora/scheduler/http/Maintenance.java > 30afce37d6c108a5a8c1c3c8a8094030ad12ce72 > src/main/java/com/twitter/aurora/scheduler/state/MaintenanceController.java > fb12d38858b260d1d9ce318d3022cd93413a3e68 > > src/test/java/com/twitter/aurora/scheduler/state/MaintenanceControllerImplTest.java > 8acb716c733ec9d3cc3b1ec74c85f958082ae139 > > Diff: https://reviews.apache.org/r/16220/diff/ > > > Testing > ------- > > ./gradlew clean build > > > Thanks, > > Zameer Manji > >