use of org.iq80.leveldb.DBException in project hadoop by apache.
the class LeveldbRMStateStore method loadRMDTSecretManagerKeys.
private int loadRMDTSecretManagerKeys(RMState state) throws IOException {
int numKeys = 0;
LeveldbIterator iter = null;
try {
iter = new LeveldbIterator(db);
iter.seek(bytes(RM_DT_MASTER_KEY_KEY_PREFIX));
while (iter.hasNext()) {
Entry<byte[], byte[]> entry = iter.next();
String key = asString(entry.getKey());
if (!key.startsWith(RM_DT_MASTER_KEY_KEY_PREFIX)) {
break;
}
DelegationKey masterKey = loadDelegationKey(entry.getValue());
state.rmSecretManagerState.masterKeyState.add(masterKey);
++numKeys;
if (LOG.isDebugEnabled()) {
LOG.debug("Loaded RM delegation key from " + key + ": keyId=" + masterKey.getKeyId() + ", expirationDate=" + masterKey.getExpiryDate());
}
}
} catch (DBException e) {
throw new IOException(e);
} finally {
if (iter != null) {
iter.close();
}
}
return numKeys;
}
use of org.iq80.leveldb.DBException in project hadoop by apache.
the class LeveldbRMStateStore method loadRMAppState.
@VisibleForTesting
ApplicationStateData loadRMAppState(ApplicationId appId) throws IOException {
String appKey = getApplicationNodeKey(appId);
byte[] data = null;
try {
data = db.get(bytes(appKey));
} catch (DBException e) {
throw new IOException(e);
}
if (data == null) {
return null;
}
return createApplicationState(appId.toString(), data);
}
use of org.iq80.leveldb.DBException in project hadoop by apache.
the class LeveldbRMStateStore method storeReservationState.
@Override
protected void storeReservationState(ReservationAllocationStateProto reservationAllocation, String planName, String reservationIdName) throws Exception {
try {
WriteBatch batch = db.createWriteBatch();
try {
String key = getReservationNodeKey(planName, reservationIdName);
if (LOG.isDebugEnabled()) {
LOG.debug("Storing state for reservation " + reservationIdName + " plan " + planName + " at " + key);
}
batch.put(bytes(key), reservationAllocation.toByteArray());
db.write(batch);
} finally {
batch.close();
}
} catch (DBException e) {
throw new IOException(e);
}
}
use of org.iq80.leveldb.DBException in project hadoop by apache.
the class LeveldbRMStateStore method removeReservationState.
@Override
protected void removeReservationState(String planName, String reservationIdName) throws Exception {
try {
WriteBatch batch = db.createWriteBatch();
try {
String reservationKey = getReservationNodeKey(planName, reservationIdName);
batch.delete(bytes(reservationKey));
if (LOG.isDebugEnabled()) {
LOG.debug("Removing state for reservation " + reservationIdName + " plan " + planName + " at " + reservationKey);
}
db.write(batch);
} finally {
batch.close();
}
} catch (DBException e) {
throw new IOException(e);
}
}
use of org.iq80.leveldb.DBException in project hadoop by apache.
the class LeveldbRMStateStore method loadAMRMTokenSecretManagerState.
private void loadAMRMTokenSecretManagerState(RMState rmState) throws IOException {
try {
byte[] data = db.get(bytes(AMRMTOKEN_SECRET_MANAGER_ROOT));
if (data != null) {
AMRMTokenSecretManagerStatePBImpl stateData = new AMRMTokenSecretManagerStatePBImpl(AMRMTokenSecretManagerStateProto.parseFrom(data));
rmState.amrmTokenSecretManagerState = AMRMTokenSecretManagerState.newInstance(stateData.getCurrentMasterKey(), stateData.getNextMasterKey());
}
} catch (DBException e) {
throw new IOException(e);
}
}
Aggregations