tries = 40;
}
// Trying recovery
boolean recovered = false;
FSDataOutputStream out = null;
while (!recovered && tries-- > 0) {
try {
out = fs.append(file1);
LOG.info("Successfully opened for appends");
recovered = true;
} catch (IOException e) {
if (!e.getMessage().contains("being recovered") &&
!e.getMessage().contains("being created")) {
throw e;
}
LOG.info("Failed open for append, waiting on lease recovery");
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
// ignore it and try again
}
}
}
if (out != null) {
out.close();
}
if (!recovered) {
throw new RuntimeException("Recovery failed");
}
}