{
for (LiveInstance instance : liveInstances)
{
String instanceName = instance.getId();
String clientSessionId = instance.getSessionId();
HelixManager manager = changeContext.getManager();
// _instanceCurrentStateChangeSubscriptionSessionIds contains all the sessionIds
// that we've added a currentState listener
if (!_instanceCurrentStateChangeSubscriptionSessionIds.contains(clientSessionId))
{
try
{
manager.addCurrentStateChangeListener(this, instanceName, clientSessionId);
_instanceCurrentStateChangeSubscriptionSessionIds.add(clientSessionId);
logger.info("Observing client session id: " + clientSessionId);
}
catch (Exception e)
{
logger.error("Exception adding current state and message listener for instance:"
+ instanceName,
e);
}
}
// _instanceSubscriptionNames contains all the instanceNames that we've added a
// message listener
if (!_instanceSubscriptionNames.contains(instanceName))
{
try
{
logger.info("Adding message listener for " + instanceName);
manager.addMessageListener(this, instanceName);
_instanceSubscriptionNames.add(instanceName);
}
catch (Exception e)
{
logger.error("Exception adding message listener for instance:" + instanceName,