@Override
public void process(ClusterEvent event) throws Exception {
HelixManager helixManager = event.getAttribute("helixmanager");
HelixDataAccessor accessor = helixManager.getHelixDataAccessor();
PropertyKey.Builder keyBuilder = accessor.keyBuilder();
ControllerContextProvider contextProvider =
event.getAttribute(AttributeName.CONTEXT_PROVIDER.toString());
// remove marked contexts
Set<ContextId> removedContexts = contextProvider.getRemovedContexts();
List<String> removedPaths = Lists.newLinkedList();
for (ContextId contextId : removedContexts) {
removedPaths.add(keyBuilder.controllerContext(contextId.stringify()).getPath());
}
if (removedPaths.size() > 0) {
accessor.getBaseDataAccessor().remove(removedPaths, 0);
}
// persist pending contexts
Map<ContextId, ControllerContext> pendingContexts = contextProvider.getPendingContexts();
List<PropertyKey> keys = Lists.newArrayList();
List<ControllerContextHolder> properties = Lists.newArrayList();
for (ContextId contextId : pendingContexts.keySet()) {
ControllerContextHolder holder = new ControllerContextHolder(pendingContexts.get(contextId));
if (holder != null) {