private static final Logger LOG =
Logger.getLogger(ClusterDataCache.class.getName());
public boolean refresh(HelixDataAccessor accessor)
{
Builder keyBuilder = accessor.keyBuilder();
_idealStateMap = accessor.getChildValuesMap(keyBuilder.idealStates());
_liveInstanceMap = accessor.getChildValuesMap(keyBuilder.liveInstances());
for (LiveInstance instance : _liveInstanceMap.values())
{
LOG.trace("live instance: " + instance.getInstanceName() + " "
+ instance.getSessionId());
}
_stateModelDefMap = accessor.getChildValuesMap(keyBuilder.stateModelDefs());
_instanceConfigMap = accessor.getChildValuesMap(keyBuilder.instanceConfigs());
_constraintMap =
accessor.getChildValuesMap(keyBuilder.constraints());
Map<String, Map<String, Message>> msgMap =
new HashMap<String, Map<String, Message>>();
for (String instanceName : _liveInstanceMap.keySet())
{
Map<String, Message> map =
accessor.getChildValuesMap(keyBuilder.messages(instanceName));
msgMap.put(instanceName, map);
}
_messageMap = Collections.unmodifiableMap(msgMap);
Map<String, Map<String, Map<String, CurrentState>>> allCurStateMap =
new HashMap<String, Map<String, Map<String, CurrentState>>>();
for (String instanceName : _liveInstanceMap.keySet())
{
LiveInstance liveInstance = _liveInstanceMap.get(instanceName);
String sessionId = liveInstance.getSessionId();
if (!allCurStateMap.containsKey(instanceName))
{
allCurStateMap.put(instanceName, new HashMap<String, Map<String, CurrentState>>());
}
Map<String, Map<String, CurrentState>> curStateMap =
allCurStateMap.get(instanceName);
Map<String, CurrentState> map =
accessor.getChildValuesMap(keyBuilder.currentStates(instanceName, sessionId));
curStateMap.put(sessionId, map);
}
for (String instance : allCurStateMap.keySet())
{