Search in sources :

Example 1 with RunIds

use of co.cask.cdap.common.app.RunIds in project cdap by caskdata.

the class AppMetadataStore method getRunsForRunIds.

private Map<ProgramRunId, RunRecordMeta> getRunsForRunIds(final Set<ProgramRunId> runIds, String recordType, int limit) {
    Set<MDSKey> keySet = new HashSet<>();
    boolean includeVersionLessKeys = !upgradeComplete.get();
    for (ProgramRunId programRunId : runIds) {
        keySet.add(getProgramKeyBuilder(recordType, programRunId.getParent()).build());
        if (includeVersionLessKeys && programRunId.getVersion().equals(ApplicationId.DEFAULT_VERSION)) {
            keySet.add(getVersionLessProgramKeyBuilder(recordType, programRunId.getParent()).build());
        }
    }
    Predicate<KeyValue<RunRecordMeta>> combinedFilter = input -> {
        ProgramId programId = getProgramID(input.getKey());
        RunRecordMeta meta = input.getValue();
        ProgramRunId programRunId = programId.run(meta.getPid());
        return runIds.contains(programRunId);
    };
    Map<MDSKey, RunRecordMeta> returnMap = listKV(keySet, RunRecordMeta.class, limit, combinedFilter);
    return getProgramRunIdMap(returnMap);
}
Also used : Arrays(java.util.Arrays) CConfiguration(co.cask.cdap.common.conf.CConfiguration) ProgramOptionConstants(co.cask.cdap.internal.app.runtime.ProgramOptionConstants) LoggerFactory(org.slf4j.LoggerFactory) MDSKey(co.cask.cdap.data2.dataset2.lib.table.MDSKey) TopicMessageIdStore(co.cask.cdap.internal.app.runtime.messaging.TopicMessageIdStore) RunIds(co.cask.cdap.common.app.RunIds) GsonBuilder(com.google.gson.GsonBuilder) ProgramType(co.cask.cdap.proto.ProgramType) Gson(com.google.gson.Gson) Map(java.util.Map) ApplicationSpecification(co.cask.cdap.api.app.ApplicationSpecification) RunId(org.apache.twill.api.RunId) ProgramId(co.cask.cdap.proto.id.ProgramId) BasicThrowable(co.cask.cdap.proto.BasicThrowable) ImmutableMap(com.google.common.collect.ImmutableMap) Predicate(java.util.function.Predicate) MetadataStoreDataset(co.cask.cdap.data2.dataset2.lib.table.MetadataStoreDataset) Set(java.util.Set) ProjectInfo(co.cask.cdap.common.utils.ProjectInfo) WorkflowToken(co.cask.cdap.api.workflow.WorkflowToken) Ticker(com.google.common.base.Ticker) BasicWorkflowToken(co.cask.cdap.internal.app.runtime.workflow.BasicWorkflowToken) NamespaceMeta(co.cask.cdap.proto.NamespaceMeta) List(java.util.List) Type(java.lang.reflect.Type) StreamSpecification(co.cask.cdap.api.data.stream.StreamSpecification) NamespaceId(co.cask.cdap.proto.id.NamespaceId) Iterables(com.google.common.collect.Iterables) ProgramRunClusterStatus(co.cask.cdap.proto.ProgramRunClusterStatus) ProgramController(co.cask.cdap.app.runtime.ProgramController) Stopwatch(com.google.common.base.Stopwatch) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) TypeToken(com.google.common.reflect.TypeToken) Function(java.util.function.Function) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) Table(co.cask.cdap.api.dataset.table.Table) ProgramRunStatus(co.cask.cdap.proto.ProgramRunStatus) Nullable(javax.annotation.Nullable) WorkflowNodeStateDetail(co.cask.cdap.proto.WorkflowNodeStateDetail) ProgramRunCluster(co.cask.cdap.proto.ProgramRunCluster) Logger(org.slf4j.Logger) Bytes(co.cask.cdap.api.common.Bytes) ApplicationId(co.cask.cdap.proto.id.ApplicationId) TxConstants(org.apache.tephra.TxConstants) BufferUnderflowException(java.nio.BufferUnderflowException) TimeUnit(java.util.concurrent.TimeUnit) ApplicationSpecificationAdapter(co.cask.cdap.internal.app.ApplicationSpecificationAdapter) Preconditions(com.google.common.base.Preconditions) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Collections(java.util.Collections) ProgramRunId(co.cask.cdap.proto.id.ProgramRunId) MDSKey(co.cask.cdap.data2.dataset2.lib.table.MDSKey) ProgramRunId(co.cask.cdap.proto.id.ProgramRunId) ProgramId(co.cask.cdap.proto.id.ProgramId) HashSet(java.util.HashSet)

Aggregations

ApplicationSpecification (co.cask.cdap.api.app.ApplicationSpecification)1 Bytes (co.cask.cdap.api.common.Bytes)1 StreamSpecification (co.cask.cdap.api.data.stream.StreamSpecification)1 Table (co.cask.cdap.api.dataset.table.Table)1 WorkflowToken (co.cask.cdap.api.workflow.WorkflowToken)1 ProgramController (co.cask.cdap.app.runtime.ProgramController)1 RunIds (co.cask.cdap.common.app.RunIds)1 CConfiguration (co.cask.cdap.common.conf.CConfiguration)1 ProjectInfo (co.cask.cdap.common.utils.ProjectInfo)1 MDSKey (co.cask.cdap.data2.dataset2.lib.table.MDSKey)1 MetadataStoreDataset (co.cask.cdap.data2.dataset2.lib.table.MetadataStoreDataset)1 ApplicationSpecificationAdapter (co.cask.cdap.internal.app.ApplicationSpecificationAdapter)1 ProgramOptionConstants (co.cask.cdap.internal.app.runtime.ProgramOptionConstants)1 TopicMessageIdStore (co.cask.cdap.internal.app.runtime.messaging.TopicMessageIdStore)1 BasicWorkflowToken (co.cask.cdap.internal.app.runtime.workflow.BasicWorkflowToken)1 BasicThrowable (co.cask.cdap.proto.BasicThrowable)1 NamespaceMeta (co.cask.cdap.proto.NamespaceMeta)1 ProgramRunCluster (co.cask.cdap.proto.ProgramRunCluster)1 ProgramRunClusterStatus (co.cask.cdap.proto.ProgramRunClusterStatus)1 ProgramRunStatus (co.cask.cdap.proto.ProgramRunStatus)1