public static boolean verifyEmptyCurStateAndExtView(String clusterName,
String resourceName,
Set<String> instanceNames,
String zkAddr)
{
ZkClient zkClient = new ZkClient(zkAddr);
zkClient.setZkSerializer(new ZNRecordSerializer());
try
{
ZKHelixDataAccessor accessor =
new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor(zkClient));
Builder keyBuilder = accessor.keyBuilder();
for (String instanceName : instanceNames)
{
List<String> sessionIds =
accessor.getChildNames(keyBuilder.sessions(instanceName));
for (String sessionId : sessionIds)
{
CurrentState curState =
accessor.getProperty(keyBuilder.currentState(instanceName,
sessionId,
resourceName));
if (curState != null && curState.getRecord().getMapFields().size() != 0)
{
return false;
}
}
ExternalView extView =
accessor.getProperty(keyBuilder.externalView(resourceName));
if (extView != null && extView.getRecord().getMapFields().size() != 0)
{
return false;
}
}
return true;
}
finally
{
zkClient.close();
}
}