use of co.cask.cdap.data2.dataset2.lib.table.MDSKey in project cdap by caskdata.
the class DefaultOwnerStore method createRowKey.
private static byte[] createRowKey(NamespacedEntityId targetId) {
String targetType = EntityIdKeyHelper.getTargetType(targetId);
MDSKey.Builder builder = new MDSKey.Builder();
builder.add(OWNER_PREFIX);
builder.add(targetType);
EntityIdKeyHelper.addTargetIdToKey(builder, targetId);
MDSKey build = builder.build();
return build.getKey();
}
use of co.cask.cdap.data2.dataset2.lib.table.MDSKey in project cdap by caskdata.
the class AppMetadataStore method getCompletedRun.
private RunRecordMeta getCompletedRun(ProgramId programId, final String runid) {
MDSKey completedKey = getProgramKeyBuilder(TYPE_RUN_RECORD_COMPLETED, programId).build();
RunRecordMeta runRecordMeta = getCompletedRun(completedKey, runid);
if (runRecordMeta == null && programId.getVersion().equals(ApplicationId.DEFAULT_VERSION)) {
completedKey = getVersionLessProgramKeyBuilder(TYPE_RUN_RECORD_COMPLETED, programId).build();
return getCompletedRun(completedKey, runid);
}
return runRecordMeta;
}
use of co.cask.cdap.data2.dataset2.lib.table.MDSKey in project cdap by caskdata.
the class AppMetadataStore method getCompletedRun.
private RunRecordMeta getCompletedRun(MDSKey completedKey, final String runid) {
// Get start time from RunId
long programStartSecs = RunIds.getTime(RunIds.fromString(runid), TimeUnit.SECONDS);
if (programStartSecs > -1) {
// If start time is found, run a get
MDSKey key = new MDSKey.Builder(completedKey).add(getInvertedTsKeyPart(programStartSecs)).add(runid).build();
return get(key, RunRecordMeta.class);
} else {
// If start time is not found, scan the table (backwards compatibility when run ids were random UUIDs)
MDSKey startKey = new MDSKey.Builder(completedKey).add(getInvertedTsScanKeyPart(Long.MAX_VALUE)).build();
MDSKey stopKey = new MDSKey.Builder(completedKey).add(getInvertedTsScanKeyPart(0)).build();
List<RunRecordMeta> runRecords = list(// Should have only one record for this runid
startKey, // Should have only one record for this runid
stopKey, // Should have only one record for this runid
RunRecordMeta.class, // Should have only one record for this runid
1, new Predicate<RunRecordMeta>() {
@Override
public boolean apply(RunRecordMeta input) {
return input.getPid().equals(runid);
}
});
return Iterables.getFirst(runRecords, null);
}
}
use of co.cask.cdap.data2.dataset2.lib.table.MDSKey in project cdap by caskdata.
the class AppMetadataStore method getUnfinishedRun.
/**
* @return run records for runs that do not have start time in mds key for the run record.
*/
private RunRecordMeta getUnfinishedRun(ProgramId programId, String recordType, String runid) {
MDSKey runningKey = getProgramKeyBuilder(recordType, programId).add(runid).build();
RunRecordMeta runRecordMeta = get(runningKey, RunRecordMeta.class);
if (runRecordMeta == null && programId.getVersion().equals(ApplicationId.DEFAULT_VERSION)) {
runningKey = getVersionLessProgramKeyBuilder(recordType, programId).add(runid).build();
return get(runningKey, RunRecordMeta.class);
}
return runRecordMeta;
}
use of co.cask.cdap.data2.dataset2.lib.table.MDSKey in project cdap by caskdata.
the class OrderedPair method getSecond.
public Set<SECOND> getSecond(Set<MDSKey> mdsKeys) {
Set<SECOND> secondSet = Sets.newHashSetWithExpectedSize(mdsKeys.size());
for (MDSKey mdsKey : mdsKeys) {
MDSKey.Splitter splitter = mdsKey.split();
// prefix
splitter.skipString();
keyMaker1.skipKey(splitter);
secondSet.add(this.keyMaker2.getElement(splitter));
}
return secondSet;
}
Aggregations