long count = 0;
//now for every role history entry, write out its record
Collection<NodeInstance> instances = history.cloneNodemap().values();
for (NodeInstance instance : instances) {
for (int role = 0; role < roles; role++) {
NodeEntry nodeEntry = instance.get(role);
if (nodeEntry != null) {
NodeEntryRecord ner = build(nodeEntry, role, instance.hostname);
record = new RoleHistoryRecord(ner);
writer.write(record, encoder);