use of org.iq80.leveldb.DBException in project hadoop by apache.
the class NMLeveldbStateStoreService method removeApplication.
@Override
public void removeApplication(ApplicationId appId) throws IOException {
if (LOG.isDebugEnabled()) {
LOG.debug("removeApplication: appId=" + appId);
}
try {
WriteBatch batch = db.createWriteBatch();
try {
String key = APPLICATIONS_KEY_PREFIX + appId;
batch.delete(bytes(key));
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 removeApplication.
@Override
public synchronized void removeApplication(ApplicationId removeAppId) throws IOException {
String appKey = getApplicationNodeKey(removeAppId);
LOG.info("Removing state for app " + removeAppId);
try {
db.delete(bytes(appKey));
} catch (DBException e) {
throw new IOException(e);
}
}
use of org.iq80.leveldb.DBException in project hadoop by apache.
the class LeveldbRMStateStore method removeApplicationStateInternal.
@Override
protected void removeApplicationStateInternal(ApplicationStateData appState) throws IOException {
ApplicationId appId = appState.getApplicationSubmissionContext().getApplicationId();
String appKey = getApplicationNodeKey(appId);
try {
WriteBatch batch = db.createWriteBatch();
try {
batch.delete(bytes(appKey));
for (ApplicationAttemptId attemptId : appState.attempts.keySet()) {
String attemptKey = getApplicationAttemptNodeKey(appKey, attemptId);
batch.delete(bytes(attemptKey));
}
if (LOG.isDebugEnabled()) {
LOG.debug("Removing state for app " + appId + " and " + appState.attempts.size() + " attempts" + " at " + appKey);
}
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 loadRMApps.
private void loadRMApps(RMState state) throws IOException {
int numApps = 0;
int numAppAttempts = 0;
LeveldbIterator iter = null;
try {
iter = new LeveldbIterator(db);
iter.seek(bytes(RM_APP_KEY_PREFIX));
while (iter.hasNext()) {
Entry<byte[], byte[]> entry = iter.next();
String key = asString(entry.getKey());
if (!key.startsWith(RM_APP_KEY_PREFIX)) {
break;
}
String appIdStr = key.substring(RM_APP_ROOT.length() + 1);
if (appIdStr.contains(SEPARATOR)) {
LOG.warn("Skipping extraneous data " + key);
continue;
}
numAppAttempts += loadRMApp(state, iter, appIdStr, entry.getValue());
++numApps;
}
} catch (DBException e) {
throw new IOException(e);
} finally {
if (iter != null) {
iter.close();
}
}
LOG.info("Recovered " + numApps + " applications and " + numAppAttempts + " application attempts");
}
use of org.iq80.leveldb.DBException in project hadoop by apache.
the class LeveldbRMStateStore method getAndIncrementEpoch.
@Override
public synchronized long getAndIncrementEpoch() throws Exception {
long currentEpoch = 0;
byte[] dbKeyBytes = bytes(EPOCH_NODE);
try {
byte[] data = db.get(dbKeyBytes);
if (data != null) {
currentEpoch = EpochProto.parseFrom(data).getEpoch();
}
EpochProto proto = Epoch.newInstance(currentEpoch + 1).getProto();
db.put(dbKeyBytes, proto.toByteArray());
} catch (DBException e) {
throw new IOException(e);
}
return currentEpoch;
}
Aggregations