use of org.iq80.leveldb.DBException in project hadoop by apache.
the class NMLeveldbStateStoreService method storeContainer.
@Override
public void storeContainer(ContainerId containerId, int containerVersion, StartContainerRequest startRequest) throws IOException {
String idStr = containerId.toString();
if (LOG.isDebugEnabled()) {
LOG.debug("storeContainer: containerId= " + idStr + ", startRequest= " + startRequest);
}
String keyRequest = CONTAINERS_KEY_PREFIX + idStr + CONTAINER_REQUEST_KEY_SUFFIX;
String keyVersion = getContainerVersionKey(idStr);
try {
WriteBatch batch = db.createWriteBatch();
try {
batch.put(bytes(keyRequest), ((StartContainerRequestPBImpl) startRequest).getProto().toByteArray());
if (containerVersion != 0) {
batch.put(bytes(keyVersion), bytes(Integer.toString(containerVersion)));
}
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 NMLeveldbStateStoreService method loadLogDeleterState.
@Override
public RecoveredLogDeleterState loadLogDeleterState() throws IOException {
RecoveredLogDeleterState state = new RecoveredLogDeleterState();
state.logDeleterMap = new HashMap<ApplicationId, LogDeleterProto>();
LeveldbIterator iter = null;
try {
iter = new LeveldbIterator(db);
iter.seek(bytes(LOG_DELETER_KEY_PREFIX));
final int logDeleterKeyPrefixLength = LOG_DELETER_KEY_PREFIX.length();
while (iter.hasNext()) {
Entry<byte[], byte[]> entry = iter.next();
String fullKey = asString(entry.getKey());
if (!fullKey.startsWith(LOG_DELETER_KEY_PREFIX)) {
break;
}
String appIdStr = fullKey.substring(logDeleterKeyPrefixLength);
ApplicationId appId = null;
try {
appId = ApplicationId.fromString(appIdStr);
} catch (IllegalArgumentException e) {
LOG.warn("Skipping unknown log deleter key " + fullKey);
continue;
}
LogDeleterProto proto = LogDeleterProto.parseFrom(entry.getValue());
state.logDeleterMap.put(appId, proto);
}
} catch (DBException e) {
throw new IOException(e);
} finally {
if (iter != null) {
iter.close();
}
}
return state;
}
use of org.iq80.leveldb.DBException in project hadoop by apache.
the class NMLeveldbStateStoreService method removeLocalizedResource.
@Override
public void removeLocalizedResource(String user, ApplicationId appId, Path localPath) throws IOException {
String localPathStr = localPath.toString();
String startedKey = getResourceStartedKey(user, appId, localPathStr);
String completedKey = getResourceCompletedKey(user, appId, localPathStr);
if (LOG.isDebugEnabled()) {
LOG.debug("Removing local resource at " + localPathStr);
}
try {
WriteBatch batch = db.createWriteBatch();
try {
batch.delete(bytes(startedKey));
batch.delete(bytes(completedKey));
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 loadRMDTSecretManagerTokens.
private int loadRMDTSecretManagerTokens(RMState state) throws IOException {
int numTokens = 0;
LeveldbIterator iter = null;
try {
iter = new LeveldbIterator(db);
iter.seek(bytes(RM_DT_TOKEN_KEY_PREFIX));
while (iter.hasNext()) {
Entry<byte[], byte[]> entry = iter.next();
String key = asString(entry.getKey());
if (!key.startsWith(RM_DT_TOKEN_KEY_PREFIX)) {
break;
}
RMDelegationTokenIdentifierData tokenData = loadDelegationToken(entry.getValue());
RMDelegationTokenIdentifier tokenId = tokenData.getTokenIdentifier();
long renewDate = tokenData.getRenewDate();
state.rmSecretManagerState.delegationTokenState.put(tokenId, renewDate);
++numTokens;
if (LOG.isDebugEnabled()) {
LOG.debug("Loaded RM delegation token from " + key + ": tokenId=" + tokenId + ", renewDate=" + renewDate);
}
}
} 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 LeveldbRMStateStore method loadRMAppAttemptState.
@VisibleForTesting
ApplicationAttemptStateData loadRMAppAttemptState(ApplicationAttemptId attemptId) throws IOException {
String attemptKey = getApplicationAttemptNodeKey(attemptId);
byte[] data = null;
try {
data = db.get(bytes(attemptKey));
} catch (DBException e) {
throw new IOException(e);
}
if (data == null) {
return null;
}
return createAttemptState(attemptId.toString(), data);
}
Aggregations