Search in sources :

Example 26 with DBException

use of org.iq80.leveldb.DBException in project hadoop by apache.

the class ShuffleHandler method removeJobShuffleInfo.

private void removeJobShuffleInfo(JobID jobId) throws IOException {
    String jobIdStr = jobId.toString();
    secretManager.removeTokenForJob(jobIdStr);
    userRsrc.remove(jobIdStr);
    if (stateDb != null) {
        try {
            stateDb.delete(bytes(jobIdStr));
        } catch (DBException e) {
            throw new IOException("Unable to remove " + jobId + " from state store", e);
        }
    }
}
Also used : DBException(org.iq80.leveldb.DBException) JniDBFactory.asString(org.fusesource.leveldbjni.JniDBFactory.asString) ByteString(com.google.protobuf.ByteString) IOException(java.io.IOException)

Example 27 with DBException

use of org.iq80.leveldb.DBException in project hadoop by apache.

the class HistoryServerLeveldbStateStoreService method storeToken.

@Override
public void storeToken(MRDelegationTokenIdentifier tokenId, Long renewDate) throws IOException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Storing token " + tokenId.getSequenceNumber());
    }
    ByteArrayOutputStream memStream = new ByteArrayOutputStream();
    DataOutputStream dataStream = new DataOutputStream(memStream);
    try {
        tokenId.write(dataStream);
        dataStream.writeLong(renewDate);
        dataStream.close();
        dataStream = null;
    } finally {
        IOUtils.cleanup(LOG, dataStream);
    }
    String dbKey = getTokenDatabaseKey(tokenId);
    try {
        db.put(bytes(dbKey), memStream.toByteArray());
    } catch (DBException e) {
        throw new IOException(e);
    }
}
Also used : DBException(org.iq80.leveldb.DBException) DataOutputStream(java.io.DataOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) JniDBFactory.asString(org.fusesource.leveldbjni.JniDBFactory.asString) IOException(java.io.IOException)

Example 28 with DBException

use of org.iq80.leveldb.DBException in project hadoop by apache.

the class HistoryServerLeveldbStateStoreService method loadTokenMasterKeys.

private int loadTokenMasterKeys(HistoryServerState state) throws IOException {
    int numKeys = 0;
    LeveldbIterator iter = null;
    try {
        iter = new LeveldbIterator(db);
        iter.seek(bytes(TOKEN_MASTER_KEY_KEY_PREFIX));
        while (iter.hasNext()) {
            Entry<byte[], byte[]> entry = iter.next();
            String key = asString(entry.getKey());
            if (!key.startsWith(TOKEN_MASTER_KEY_KEY_PREFIX)) {
                break;
            }
            if (LOG.isDebugEnabled()) {
                LOG.debug("Loading master key from " + key);
            }
            try {
                loadTokenMasterKey(state, entry.getValue());
            } catch (IOException e) {
                throw new IOException("Error loading token master key from " + key, e);
            }
            ++numKeys;
        }
    } 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) JniDBFactory.asString(org.fusesource.leveldbjni.JniDBFactory.asString) IOException(java.io.IOException)

Example 29 with DBException

use of org.iq80.leveldb.DBException in project hadoop by apache.

the class LeveldbTimelineStateStore method updateToken.

@Override
public void updateToken(TimelineDelegationTokenIdentifier tokenId, Long renewDate) throws IOException {
    try {
        byte[] k = createTokenEntryKey(tokenId.getSequenceNumber());
        if (db.get(k) == null) {
            throw new IOException(tokenId + " doesn't exist");
        }
        byte[] v = buildTokenData(tokenId, renewDate);
        db.put(k, v);
    } catch (DBException e) {
        throw new IOException(e);
    }
}
Also used : DBException(org.iq80.leveldb.DBException) IOException(java.io.IOException)

Example 30 with DBException

use of org.iq80.leveldb.DBException in project hadoop by apache.

the class LeveldbTimelineStateStore method removeTokenMasterKey.

@Override
public void removeTokenMasterKey(DelegationKey key) throws IOException {
    try {
        byte[] k = createTokenMasterKeyEntryKey(key.getKeyId());
        db.delete(k);
    } catch (DBException e) {
        throw new IOException(e);
    }
}
Also used : DBException(org.iq80.leveldb.DBException) 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