* @throws IOException
* raised when a fatal error occurred.
*/
@Override
public NamespaceNotification getNamespaceNotification() throws IOException {
FSEditLogOp op = null;
NamespaceNotification notification = null;
// Keep looping until we reach an operation that can be
// considered a notification.
while (true) {
try {
// if the stream is null, we need to setup next stream
// if we cannot than this is a fatal failure
refreshInputStream();
// get current position in the stream
currentEditLogInputStreamPosition = currentEditLogInputStream
.getPosition();
// try reading a transaction
op = currentEditLogInputStream.readOp();
InjectionHandler.processEventIO(InjectionEvent.SERVERLOGREADER_READOP);
if (LOG.isDebugEnabled()) {
LOG.info("inputStream.readOP() returned " + op);
}
} catch (Exception e) {
// possibly ChecksumException
LOG.warn("inputStream.readOp() failed", e);
// try reopening current log segment
tryReloadingEditLog();
continue;
}
// for each successful read, we update state
if (op == null) {
// we can sleep to wait for new transactions
sleep(500);
// nothing in the edit log now
core.getMetrics().reachedEditLogEnd.inc();
checkProgress();
continue;
}
if (ServerLogReaderUtil.shouldSkipOp(mostRecentlyReadTransactionTxId, op)){
updateState(op, false);
continue;
}
// update internal state, and check for progress
updateState(op, true);
if (LOG.isDebugEnabled()) {
LOG.debug("Read operation: " + op + " with txId="
+ (op == null ? "null" : op.getTransactionId()));
}
// Test if it can be considered a notification
notification = ServerLogReaderUtil.createNotification(op);
if (notification != null) {