synchronized boolean checkBackupRegistration(
NamenodeRegistration registration) {
Iterator<EditLogOutputStream> it =
getOutputStreamIterator(JournalType.BACKUP);
boolean regAllowed = !it.hasNext();
NamenodeRegistration backupNode = null;
ArrayList<EditLogOutputStream> errorStreams = null;
while(it.hasNext()) {
EditLogBackupOutputStream eStream = (EditLogBackupOutputStream)it.next();
backupNode = eStream.getRegistration();
if(backupNode.getAddress().equals(registration.getAddress()) &&
backupNode.isRole(registration.getRole())) {
regAllowed = true; // same node re-registers
break;
}
if(!eStream.isAlive()) {
if(errorStreams == null)
errorStreams = new ArrayList<EditLogOutputStream>(1);
errorStreams.add(eStream);
regAllowed = true; // previous backup node failed
}
}
assert backupNode == null || backupNode.isRole(NamenodeRole.BACKUP) :
"Not a backup node corresponds to a backup stream";
processIOError(errorStreams, true);
return regAllowed;
}