Class DocumentStoreUtils
java.lang.Object
org.apache.hadoop.yarn.server.timelineservice.documentstore.DocumentStoreUtils
This class consists of all the utils required for reading or writing
documents for a
DocumentStoreVendor.-
Method Summary
Modifier and TypeMethodDescriptionapplyConfigFilter(org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList configsToRetrieve, Map<String, String> configs) static StringconstructFlowActivityDocId(org.apache.hadoop.yarn.server.timelineservice.collector.TimelineCollectorContext collectorContext, long eventTimestamp) Creates a composite key for storingFlowActivityDocument.static StringconstructFlowRunDocId(org.apache.hadoop.yarn.server.timelineservice.collector.TimelineCollectorContext collectorContext) Creates a composite key for storingFlowRunDocument.static StringconstructTimelineEntityDocId(org.apache.hadoop.yarn.server.timelineservice.collector.TimelineCollectorContext collectorContext, String type) Creates a composite key for storingTimelineEntityDocument.static StringconstructTimelineEntityDocId(org.apache.hadoop.yarn.server.timelineservice.collector.TimelineCollectorContext collectorContext, String type, String id) Creates a composite key for storingTimelineEntityDocument.static com.microsoft.azure.cosmosdb.rx.AsyncDocumentClientcreateCosmosDBAsyncClient(org.apache.hadoop.conf.Configuration conf) Creates CosmosDB Async Document Client.static org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntitycreateEntityToBeReturned(TimelineEntityDocument timelineEntityDocument, org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList confsToRetrieve, org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList metricsToRetrieve) Creates the final entity to be returned as the result.static org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntitycreateEntityToBeReturned(TimelineEntityDocument timelineEntityDocument, org.apache.hadoop.yarn.server.timelineservice.reader.TimelineDataToRetrieve dataToRetrieve) Creates the final entity to be returned as the result.static org.apache.hadoop.yarn.api.records.timelineservice.TimelineEventfetchEvent(org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity timelineEntity, String eventType) Retrieves aTimelineEventfromTimelineEntity.events.static StringgetCosmosDBDatabaseName(org.apache.hadoop.conf.Configuration conf) static DocumentStoreVendorgetStoreVendor(org.apache.hadoop.conf.Configuration conf) RetrievesDocumentStoreVendorconfigured.static longgetTopOfTheDayTimestamp(long timeStamp) Returns the timestamp of the day's start (which is midnight 00:00:00 AM) for a given input timestamp.static booleanisNullOrEmpty(String... values) Checks if the string is null or empty.static Set<org.apache.hadoop.yarn.api.records.timelineservice.TimelineMetric>transformMetrics(org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList metricsToRetrieve, Map<String, Set<TimelineMetricSubDoc>> metrics) static voidvalidateCosmosDBConf(org.apache.hadoop.conf.Configuration conf) Checks whether the cosmosdb conf are set properly in yarn-site.xml conf.
-
Method Details
-
validateCosmosDBConf
public static void validateCosmosDBConf(org.apache.hadoop.conf.Configuration conf) throws org.apache.hadoop.yarn.exceptions.YarnException Checks whether the cosmosdb conf are set properly in yarn-site.xml conf.- Parameters:
conf- related to yarn- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- if required config properties are missing
-
getStoreVendor
RetrievesDocumentStoreVendorconfigured.- Parameters:
conf- related to yarn- Returns:
- Returns the
DocumentStoreVendorthat is configured, else usesDocumentStoreVendor.COSMOS_DBas default
-
fetchEvent
public static org.apache.hadoop.yarn.api.records.timelineservice.TimelineEvent fetchEvent(org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity timelineEntity, String eventType) Retrieves aTimelineEventfromTimelineEntity.events.- Parameters:
timelineEntity- from which the set of events are examined.eventType- that has to be checked.- Returns:
TimelineEventif found else null
-
isNullOrEmpty
Checks if the string is null or empty.- Parameters:
values- array of string to be checked- Returns:
- false if any of the string is null or empty else true
-
createCosmosDBAsyncClient
public static com.microsoft.azure.cosmosdb.rx.AsyncDocumentClient createCosmosDBAsyncClient(org.apache.hadoop.conf.Configuration conf) Creates CosmosDB Async Document Client.- Parameters:
conf- to retrieve cosmos db endpoint and key- Returns:
- async document client for CosmosDB
-
getTopOfTheDayTimestamp
public static long getTopOfTheDayTimestamp(long timeStamp) Returns the timestamp of the day's start (which is midnight 00:00:00 AM) for a given input timestamp.- Parameters:
timeStamp- Timestamp.- Returns:
- timestamp of that day's beginning (midnight)
-
constructTimelineEntityDocId
public static String constructTimelineEntityDocId(org.apache.hadoop.yarn.server.timelineservice.collector.TimelineCollectorContext collectorContext, String type) Creates a composite key for storingTimelineEntityDocument.- Parameters:
collectorContext- of the timeline writertype- of the entity- Returns:
- composite key delimited with !
-
constructTimelineEntityDocId
public static String constructTimelineEntityDocId(org.apache.hadoop.yarn.server.timelineservice.collector.TimelineCollectorContext collectorContext, String type, String id) Creates a composite key for storingTimelineEntityDocument.- Parameters:
collectorContext- of the timeline writertype- of the entityid- of the entity- Returns:
- composite key delimited with !
-
constructFlowRunDocId
public static String constructFlowRunDocId(org.apache.hadoop.yarn.server.timelineservice.collector.TimelineCollectorContext collectorContext) Creates a composite key for storingFlowRunDocument.- Parameters:
collectorContext- of the timeline writer- Returns:
- composite key delimited with !
-
constructFlowActivityDocId
public static String constructFlowActivityDocId(org.apache.hadoop.yarn.server.timelineservice.collector.TimelineCollectorContext collectorContext, long eventTimestamp) Creates a composite key for storingFlowActivityDocument.- Parameters:
collectorContext- of the timeline writereventTimestamp- of the timeline entity- Returns:
- composite key delimited with !
-
getCosmosDBDatabaseName
-
createEntityToBeReturned
public static org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity createEntityToBeReturned(TimelineEntityDocument timelineEntityDocument, org.apache.hadoop.yarn.server.timelineservice.reader.TimelineDataToRetrieve dataToRetrieve) Creates the final entity to be returned as the result.- Parameters:
timelineEntityDocument- which has all the information for the entitydataToRetrieve- specifies filters and fields to retrieve- Returns:
TimelineEntityas the result
-
createEntityToBeReturned
public static org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity createEntityToBeReturned(TimelineEntityDocument timelineEntityDocument, org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList confsToRetrieve, org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList metricsToRetrieve) Creates the final entity to be returned as the result.- Parameters:
timelineEntityDocument- which has all the information for the entityconfsToRetrieve- specifies config filters to be appliedmetricsToRetrieve- specifies metric filters to be applied- Returns:
TimelineEntityas the result
-
transformMetrics
public static Set<org.apache.hadoop.yarn.api.records.timelineservice.TimelineMetric> transformMetrics(org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList metricsToRetrieve, Map<String, Set<TimelineMetricSubDoc>> metrics) -
applyConfigFilter
-