use of org.iq80.leveldb.DBException in project hadoop by apache.
the class HistoryServerLeveldbStateStoreService method dbStoreVersion.
void dbStoreVersion(Version state) throws IOException {
String key = DB_SCHEMA_VERSION_KEY;
byte[] data = ((VersionPBImpl) state).getProto().toByteArray();
try {
db.put(bytes(key), data);
} catch (DBException e) {
throw new IOException(e);
}
}
use of org.iq80.leveldb.DBException in project hadoop by apache.
the class HistoryServerLeveldbStateStoreService method storeTokenMasterKey.
@Override
public void storeTokenMasterKey(DelegationKey masterKey) throws IOException {
if (LOG.isDebugEnabled()) {
LOG.debug("Storing master key " + masterKey.getKeyId());
}
ByteArrayOutputStream memStream = new ByteArrayOutputStream();
DataOutputStream dataStream = new DataOutputStream(memStream);
try {
masterKey.write(dataStream);
dataStream.close();
dataStream = null;
} finally {
IOUtils.cleanup(LOG, dataStream);
}
String dbKey = getTokenMasterKeyDatabaseKey(masterKey);
try {
db.put(bytes(dbKey), memStream.toByteArray());
} catch (DBException e) {
throw new IOException(e);
}
}
use of org.iq80.leveldb.DBException in project hadoop by apache.
the class HistoryServerLeveldbStateStoreService method loadTokens.
private int loadTokens(HistoryServerState state) throws IOException {
int numTokens = 0;
LeveldbIterator iter = null;
try {
iter = new LeveldbIterator(db);
iter.seek(bytes(TOKEN_STATE_KEY_PREFIX));
while (iter.hasNext()) {
Entry<byte[], byte[]> entry = iter.next();
String key = asString(entry.getKey());
if (!key.startsWith(TOKEN_STATE_KEY_PREFIX)) {
break;
}
if (LOG.isDebugEnabled()) {
LOG.debug("Loading token from " + key);
}
try {
loadToken(state, entry.getValue());
} catch (IOException e) {
throw new IOException("Error loading token state from " + key, e);
}
++numTokens;
}
} catch (DBException e) {
throw new IOException(e);
} finally {
if (iter != null) {
iter.close();
}
}
return numTokens;
}
use of org.iq80.leveldb.DBException in project hadoop by apache.
the class ShuffleHandler method recoverState.
private void recoverState(Configuration conf) throws IOException {
Path recoveryRoot = getRecoveryPath();
if (recoveryRoot != null) {
startStore(recoveryRoot);
Pattern jobPattern = Pattern.compile(JobID.JOBID_REGEX);
LeveldbIterator iter = null;
try {
iter = new LeveldbIterator(stateDb);
iter.seek(bytes(JobID.JOB));
while (iter.hasNext()) {
Map.Entry<byte[], byte[]> entry = iter.next();
String key = asString(entry.getKey());
if (!jobPattern.matcher(key).matches()) {
break;
}
recoverJobShuffleInfo(key, entry.getValue());
}
} catch (DBException e) {
throw new IOException("Database error during recovery", e);
} finally {
if (iter != null) {
iter.close();
}
}
}
}
use of org.iq80.leveldb.DBException in project tez by apache.
the class ShuffleHandler method storeSchemaVersion.
private void storeSchemaVersion(Version version) throws IOException {
String key = STATE_DB_SCHEMA_VERSION_KEY;
byte[] data = ((VersionPBImpl) version).getProto().toByteArray();
try {
stateDb.put(bytes(key), data);
} catch (DBException e) {
throw new IOException(e.getMessage(), e);
}
}
Aggregations