public static boolean verifyFileBasedClusterStates(String instanceName, String expectedFile,
String curFile)
{
boolean ret = true;
ClusterView expectedView = ClusterViewSerializer.deserialize(new File(expectedFile));
ClusterView curView = ClusterViewSerializer.deserialize(new File(curFile));
// ideal_state for instance with the given instanceName
Map<String, String> idealStates = new HashMap<String, String>();
for (ZNRecord idealStateItem : expectedView.getPropertyList(PropertyType.IDEALSTATES))
{
Map<String, Map<String, String>> allIdealStates = idealStateItem.getMapFields();
for (Map.Entry<String, Map<String, String>> entry : allIdealStates.entrySet())
{
if (entry.getValue().containsKey(instanceName))
{
String state = entry.getValue().get(instanceName);
idealStates.put(entry.getKey(), state);
}
}
}
ClusterView.MemberInstance memberInstance = curView.getMemberInstance(instanceName, false);
List<ZNRecord> curStateList = memberInstance.getInstanceProperty(PropertyType.CURRENTSTATES);
if (curStateList == null && idealStates.size() > 0)
{
LOG.info("current state is null");