* ledger fragments are stored on. Check if any of the ledger fragments
* for the current ledger are stored on the input dead bookie.
*/
final DigestType digestType = getLedgerDigestType(lId);
final byte[] passwd = getLedgerPasswd(lId);
bkc.asyncOpenLedgerNoRecovery(lId, digestType, passwd, new OpenCallback() {
@Override
public void openComplete(int rc, final LedgerHandle lh, Object ctx) {
if (rc != Code.OK.intValue()) {
LOG.error("BK error opening ledger: " + lId, BKException.create(rc));
ledgerIterCb.processResult(rc, null, null);
return;
}
LedgerMetadata lm = lh.getLedgerMetadata();
if (!lm.isClosed() &&
lm.getEnsembles().size() > 0) {
Long lastKey = lm.getEnsembles().lastKey();
ArrayList<InetSocketAddress> lastEnsemble = lm.getEnsembles().get(lastKey);
// the original write has not removed faulty bookie from
// current ledger ensemble. to avoid data loss issue in
// the case of concurrent updates to the ensemble composition,
// the recovery tool should first close the ledger
if (lastEnsemble.contains(bookieSrc)) {
// close opened non recovery ledger handle
try {
lh.close();
} catch (Exception ie) {
LOG.warn("Error closing non recovery ledger handle for ledger " + lId, ie);
}
bkc.asyncOpenLedger(lId, digestType, passwd, new OpenCallback() {
@Override
public void openComplete(int newrc, final LedgerHandle newlh, Object newctx) {
if (newrc != Code.OK.intValue()) {
LOG.error("BK error close ledger: " + lId, BKException.create(newrc));
ledgerIterCb.processResult(newrc, null, null);