use of org.apache.hadoop.yarn.server.utils.LeveldbIterator in project hadoop by apache.
the class LeveldbTimelineStateStore method loadTokenMasterKeys.
private int loadTokenMasterKeys(TimelineServiceState state) throws IOException {
byte[] base = KeyBuilder.newInstance().add(TOKEN_MASTER_KEY_ENTRY_PREFIX).getBytesForLookup();
int numKeys = 0;
LeveldbIterator iterator = null;
try {
for (iterator = new LeveldbIterator(db), iterator.seek(base); iterator.hasNext(); iterator.next()) {
byte[] k = iterator.peekNext().getKey();
if (!prefixMatches(base, base.length, k)) {
break;
}
byte[] v = iterator.peekNext().getValue();
loadTokenMasterKeyData(state, v);
++numKeys;
}
} finally {
IOUtils.cleanup(LOG, iterator);
}
return numKeys;
}
use of org.apache.hadoop.yarn.server.utils.LeveldbIterator in project hadoop by apache.
the class NMLeveldbStateStoreService method loadApplicationsState.
@Override
public RecoveredApplicationsState loadApplicationsState() throws IOException {
RecoveredApplicationsState state = new RecoveredApplicationsState();
state.applications = new ArrayList<ContainerManagerApplicationProto>();
String keyPrefix = APPLICATIONS_KEY_PREFIX;
LeveldbIterator iter = null;
try {
iter = new LeveldbIterator(db);
iter.seek(bytes(keyPrefix));
while (iter.hasNext()) {
Entry<byte[], byte[]> entry = iter.next();
String key = asString(entry.getKey());
if (!key.startsWith(keyPrefix)) {
break;
}
state.applications.add(ContainerManagerApplicationProto.parseFrom(entry.getValue()));
}
} catch (DBException e) {
throw new IOException(e);
} finally {
if (iter != null) {
iter.close();
}
}
cleanupDeprecatedFinishedApps();
return state;
}
use of org.apache.hadoop.yarn.server.utils.LeveldbIterator 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.apache.hadoop.yarn.server.utils.LeveldbIterator in project hadoop by apache.
the class LeveldbRMStateStore method getNumEntriesInDatabase.
@VisibleForTesting
int getNumEntriesInDatabase() throws IOException {
int numEntries = 0;
LeveldbIterator iter = null;
try {
iter = new LeveldbIterator(db);
iter.seekToFirst();
while (iter.hasNext()) {
Entry<byte[], byte[]> entry = iter.next();
LOG.info("entry: " + asString(entry.getKey()));
++numEntries;
}
} catch (DBException e) {
throw new IOException(e);
} finally {
if (iter != null) {
iter.close();
}
}
return numEntries;
}
use of org.apache.hadoop.yarn.server.utils.LeveldbIterator 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;
}
Aggregations