Search in sources :

Example 16 with DBException

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;
}
Also used : DBException(org.iq80.leveldb.DBException) LeveldbIterator(org.apache.hadoop.yarn.server.utils.LeveldbIterator) DelegationKey(org.apache.hadoop.security.token.delegation.DelegationKey) JniDBFactory.asString(org.fusesource.leveldbjni.JniDBFactory.asString) IOException(java.io.IOException)

Example 17 with DBException

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);
}
Also used : DBException(org.iq80.leveldb.DBException) JniDBFactory.asString(org.fusesource.leveldbjni.JniDBFactory.asString) IOException(java.io.IOException) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 18 with DBException

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);
    }
}
Also used : DBException(org.iq80.leveldb.DBException) JniDBFactory.asString(org.fusesource.leveldbjni.JniDBFactory.asString) IOException(java.io.IOException) WriteBatch(org.iq80.leveldb.WriteBatch)

Example 19 with DBException

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);
    }
}
Also used : DBException(org.iq80.leveldb.DBException) JniDBFactory.asString(org.fusesource.leveldbjni.JniDBFactory.asString) IOException(java.io.IOException) WriteBatch(org.iq80.leveldb.WriteBatch)

Example 20 with DBException

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);
    }
}
Also used : DBException(org.iq80.leveldb.DBException) AMRMTokenSecretManagerStatePBImpl(org.apache.hadoop.yarn.server.resourcemanager.recovery.records.impl.pb.AMRMTokenSecretManagerStatePBImpl) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)70 DBException (org.iq80.leveldb.DBException)70 JniDBFactory.asString (org.fusesource.leveldbjni.JniDBFactory.asString)39 LeveldbIterator (org.apache.hadoop.yarn.server.utils.LeveldbIterator)19 WriteBatch (org.iq80.leveldb.WriteBatch)18 Path (org.apache.hadoop.fs.Path)8 ByteString (com.google.protobuf.ByteString)6 File (java.io.File)6 Map (java.util.Map)6 NativeDB (org.fusesource.leveldbjni.internal.NativeDB)6 Options (org.iq80.leveldb.Options)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 DataOutputStream (java.io.DataOutputStream)5 TopicMetadata (co.cask.cdap.messaging.TopicMetadata)4 VisibleForTesting (com.google.common.annotations.VisibleForTesting)4 HashMap (java.util.HashMap)4 TopicNotFoundException (co.cask.cdap.api.messaging.TopicNotFoundException)3 RawMessageTableEntry (co.cask.cdap.messaging.store.RawMessageTableEntry)3 TreeMap (java.util.TreeMap)3 ImmutableMessageTableEntry (co.cask.cdap.messaging.store.ImmutableMessageTableEntry)2