http://git-wip-us.apache.org/repos/asf/ambari/blob/42112e28/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/sink/KafkaSinkProvider.java ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/sink/KafkaSinkProvider.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/sink/KafkaSinkProvider.java deleted file mode 100644 index 3b34b55..0000000 --- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/sink/KafkaSinkProvider.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.sink; - -import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.TimelineMetricConfiguration.KAFKA_ACKS; -import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.TimelineMetricConfiguration.KAFKA_BATCH_SIZE; -import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.TimelineMetricConfiguration.KAFKA_BUFFER_MEM; -import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.TimelineMetricConfiguration.KAFKA_LINGER_MS; -import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.TimelineMetricConfiguration.KAFKA_RETRIES; -import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.TimelineMetricConfiguration.KAFKA_SERVERS; -import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.TimelineMetricConfiguration.KAFKA_SINK_TIMEOUT_SECONDS; -import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.TimelineMetricConfiguration.TIMELINE_METRICS_CACHE_COMMIT_INTERVAL; - -import java.util.Collection; -import java.util.Properties; -import java.util.concurrent.Future; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.hadoop.metrics2.sink.timeline.TimelineMetrics; -import org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.TimelineMetricConfiguration; -import org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.source.InternalSourceProvider.SOURCE_NAME; -import org.apache.kafka.clients.producer.KafkaProducer; -import org.apache.kafka.clients.producer.Producer; -import org.apache.kafka.clients.producer.ProducerConfig; -import org.apache.kafka.clients.producer.ProducerRecord; -import org.apache.kafka.clients.producer.RecordMetadata; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -/* - This will be used by the single Metrics committer thread. Hence it is - important to make this non-blocking export. - */ -public class KafkaSinkProvider implements ExternalSinkProvider { - private static String TOPIC_NAME = "ambari-metrics-topic"; - private static final Log LOG = LogFactory.getLog(KafkaSinkProvider.class); - - private Producer producer; - private int TIMEOUT_SECONDS = 10; - private int FLUSH_SECONDS = 3; - - ObjectMapper objectMapper = new ObjectMapper(); - - public KafkaSinkProvider() { - TimelineMetricConfiguration configuration = TimelineMetricConfiguration.getInstance(); - - Properties configProperties = new Properties(); - try { - configProperties.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, configuration.getMetricsConf().getTrimmed(KAFKA_SERVERS)); - configProperties.put(ProducerConfig.ACKS_CONFIG, configuration.getMetricsConf().getTrimmed(KAFKA_ACKS, "all")); - // Avoid duplicates - No transactional semantics - configProperties.put(ProducerConfig.RETRIES_CONFIG, configuration.getMetricsConf().getInt(KAFKA_RETRIES, 0)); - configProperties.put(ProducerConfig.BATCH_SIZE_CONFIG, configuration.getMetricsConf().getInt(KAFKA_BATCH_SIZE, 128)); - configProperties.put(ProducerConfig.LINGER_MS_CONFIG, configuration.getMetricsConf().getInt(KAFKA_LINGER_MS, 1)); - configProperties.put(ProducerConfig.BUFFER_MEMORY_CONFIG, configuration.getMetricsConf().getLong(KAFKA_BUFFER_MEM, 33554432)); // 32 MB - FLUSH_SECONDS = configuration.getMetricsConf().getInt(TIMELINE_METRICS_CACHE_COMMIT_INTERVAL, 3); - TIMEOUT_SECONDS = configuration.getMetricsConf().getInt(KAFKA_SINK_TIMEOUT_SECONDS, 10); - } catch (Exception e) { - LOG.error("Configuration error!", e); - throw new ExceptionInInitializerError(e); - } - configProperties.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG,"org.apache.kafka.common.serialization.ByteArraySerializer"); - configProperties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,"org.apache.kafka.connect.json.JsonSerializer"); - - - - producer = new KafkaProducer(configProperties); - } - - @Override - public ExternalMetricsSink getExternalMetricsSink(SOURCE_NAME sourceName) { - switch (sourceName) { - case RAW_METRICS: - return new KafkaRawMetricsSink(); - default: - throw new UnsupportedOperationException("Provider does not support " + - "the expected source " + sourceName); - } - } - - class KafkaRawMetricsSink implements ExternalMetricsSink { - - @Override - public int getSinkTimeOutSeconds() { - return TIMEOUT_SECONDS; - } - - @Override - public int getFlushSeconds() { - return FLUSH_SECONDS; - } - - @Override - public void sinkMetricData(Collection<TimelineMetrics> metrics) { - JsonNode jsonNode = objectMapper.valueToTree(metrics); - ProducerRecord<String, JsonNode> rec = new ProducerRecord<String, JsonNode>(TOPIC_NAME, jsonNode); - Future<RecordMetadata> f = producer.send(rec); - } - } - -}
http://git-wip-us.apache.org/repos/asf/ambari/blob/42112e28/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/DefaultInternalMetricsSourceProvider.java ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/DefaultInternalMetricsSourceProvider.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/DefaultInternalMetricsSourceProvider.java deleted file mode 100644 index c6b071f..0000000 --- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/DefaultInternalMetricsSourceProvider.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.source; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.sink.ExternalMetricsSink; - -public class DefaultInternalMetricsSourceProvider implements InternalSourceProvider { - private static final Log LOG = LogFactory.getLog(DefaultInternalMetricsSourceProvider.class); - - // TODO: Implement read based sources for higher order data - @Override - public InternalMetricsSource getInternalMetricsSource(SOURCE_NAME sourceName, int sinkIntervalSeconds, ExternalMetricsSink sink) { - if (sink == null) { - LOG.warn("No external sink configured for source " + sourceName); - return null; - } - - switch (sourceName) { - case RAW_METRICS: - return new RawMetricsSource(sinkIntervalSeconds, sink); - default: - throw new UnsupportedOperationException("Unimplemented source type " + sourceName); - } - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/42112e28/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/InternalMetricsSource.java ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/InternalMetricsSource.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/InternalMetricsSource.java deleted file mode 100644 index a6e1092..0000000 --- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/InternalMetricsSource.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.source; - -import java.util.Collection; - -import org.apache.hadoop.metrics2.sink.timeline.TimelineMetrics; - -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -public interface InternalMetricsSource { - /** - * Write metrics to external sink. - * Allows pre-processing and caching capabilities to the consumer. - */ - void publishTimelineMetrics(Collection<TimelineMetrics> metrics); -} http://git-wip-us.apache.org/repos/asf/ambari/blob/42112e28/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/InternalSourceProvider.java ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/InternalSourceProvider.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/InternalSourceProvider.java deleted file mode 100644 index 9d8ca36..0000000 --- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/InternalSourceProvider.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.source; - -import org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.sink.ExternalMetricsSink; - -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -public interface InternalSourceProvider { - - enum SOURCE_NAME { - RAW_METRICS, - MINUTE_HOST_AGGREAGATE_METRICS, - HOURLY_HOST_AGGREAGATE_METRICS, - DAILY_HOST_AGGREAGATE_METRICS, - MINUTE_CLUSTER_AGGREAGATE_METRICS, - HOURLY_CLUSTER_AGGREAGATE_METRICS, - DAILY_CLUSTER_AGGREAGATE_METRICS, - } - - /** - * Provide Source for metrics data. - * @return {@link InternalMetricsSource} - */ - InternalMetricsSource getInternalMetricsSource(SOURCE_NAME sourceName, int sinkIntervalSeconds, ExternalMetricsSink sink); -} http://git-wip-us.apache.org/repos/asf/ambari/blob/42112e28/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/RawMetricsSource.java ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/RawMetricsSource.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/RawMetricsSource.java deleted file mode 100644 index 6475536..0000000 --- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/RawMetricsSource.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.source; - -import java.util.Collection; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.hadoop.metrics2.sink.timeline.TimelineMetrics; -import org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.sink.ExternalMetricsSink; -import org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.source.cache.InternalMetricsCache; -import org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.source.cache.InternalMetricsCacheProvider; - -public class RawMetricsSource implements InternalMetricsSource { - private static final Log LOG = LogFactory.getLog(RawMetricsSource.class); - private final int internalCacheInterval; - private final ExternalMetricsSink rawMetricsSink; - private final ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor(); - private final InternalMetricsCache cache; - static final String RAW_METRICS_CACHE = "RAW_METRICS_CACHE_INSTANCE"; - - public RawMetricsSource(int internalCacheInterval, ExternalMetricsSink rawMetricsSink) { - this.internalCacheInterval = internalCacheInterval; - this.rawMetricsSink = rawMetricsSink; - this.cache = InternalMetricsCacheProvider.getInstance().getCacheInstance(RAW_METRICS_CACHE); - if (rawMetricsSink.getFlushSeconds() > internalCacheInterval) { - initializeFixedRateScheduler(); - } - } - - @Override - public void publishTimelineMetrics(Collection<TimelineMetrics> metrics) { - // TODO: Adjust default flush to reasonable defaults > 3 seconds - if (rawMetricsSink.getFlushSeconds() > internalCacheInterval) { - // Need to cache only if external sink cannot keep up and thereby has - // different flush interval as compared to HBase flush - cache.putAll(metrics); // Scheduler initialized already for flush - } else { - submitDataWithTimeout(metrics); - } - } - - private void initializeFixedRateScheduler() { - executorService.scheduleAtFixedRate(() -> rawMetricsSink.sinkMetricData(cache.evictAll()), - rawMetricsSink.getFlushSeconds(), rawMetricsSink.getFlushSeconds(), TimeUnit.SECONDS); - } - - private void submitDataWithTimeout(final Collection<TimelineMetrics> metrics) { - Future f = executorService.submit(() -> { - rawMetricsSink.sinkMetricData(metrics); - return null; - }); - try { - f.get(rawMetricsSink.getSinkTimeOutSeconds(), TimeUnit.SECONDS); - } catch (InterruptedException e) { - LOG.warn("Raw metrics sink interrupted."); - } catch (ExecutionException e) { - LOG.warn("Exception on sinking metrics", e); - } catch (TimeoutException e) { - LOG.warn("Timeout exception on sinking metrics", e); - } - } - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/42112e28/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/cache/InternalMetricCacheKey.java ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/cache/InternalMetricCacheKey.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/cache/InternalMetricCacheKey.java deleted file mode 100644 index 28d457d..0000000 --- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/cache/InternalMetricCacheKey.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.source.cache; - -public class InternalMetricCacheKey { - private String metricName; - private String appId; - private String instanceId; - private String hostname; - private long startTime; // Useful for debugging - - public InternalMetricCacheKey(String metricName, String appId, String instanceId, String hostname, long startTime) { - this.metricName = metricName; - this.appId = appId; - this.instanceId = instanceId; - this.hostname = hostname; - this.startTime = startTime; - } - - public String getMetricName() { - return metricName; - } - - public void setMetricName(String metricName) { - this.metricName = metricName; - } - - public String getAppId() { - return appId; - } - - public void setAppId(String appId) { - this.appId = appId; - } - - public String getInstanceId() { - return instanceId; - } - - public void setInstanceId(String instanceId) { - this.instanceId = instanceId; - } - - public String getHostname() { - return hostname; - } - - public void setHostname(String hostname) { - this.hostname = hostname; - } - - public long getStartTime() { - return startTime; - } - - public void setStartTime(long startTime) { - this.startTime = startTime; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - InternalMetricCacheKey that = (InternalMetricCacheKey) o; - - if (!getMetricName().equals(that.getMetricName())) return false; - if (!getAppId().equals(that.getAppId())) return false; - if (getInstanceId() != null ? !getInstanceId().equals(that.getInstanceId()) : that.getInstanceId() != null) - return false; - return getHostname() != null ? getHostname().equals(that.getHostname()) : that.getHostname() == null; - - } - - @Override - public int hashCode() { - int result = getMetricName().hashCode(); - result = 31 * result + getAppId().hashCode(); - result = 31 * result + (getInstanceId() != null ? getInstanceId().hashCode() : 0); - result = 31 * result + (getHostname() != null ? getHostname().hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "InternalMetricCacheKey{" + - "metricName='" + metricName + '\'' + - ", appId='" + appId + '\'' + - ", instanceId='" + instanceId + '\'' + - ", hostname='" + hostname + '\'' + - ", startTime=" + startTime + - '}'; - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/42112e28/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/cache/InternalMetricCacheValue.java ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/cache/InternalMetricCacheValue.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/cache/InternalMetricCacheValue.java deleted file mode 100644 index a4dabe7..0000000 --- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/cache/InternalMetricCacheValue.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.source.cache; - -import java.util.Map; -import java.util.TreeMap; - -public class InternalMetricCacheValue { - private TreeMap<Long, Double> metricValues = new TreeMap<Long, Double>(); - - public TreeMap<Long, Double> getMetricValues() { - return metricValues; - } - - public void setMetricValues(TreeMap<Long, Double> metricValues) { - this.metricValues = metricValues; - } - - public void addMetricValues(Map<Long, Double> metricValues) { - this.metricValues.putAll(metricValues); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/42112e28/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/cache/InternalMetricsCache.java ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/cache/InternalMetricsCache.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/cache/InternalMetricsCache.java deleted file mode 100644 index e5522c7..0000000 --- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/cache/InternalMetricsCache.java +++ /dev/null @@ -1,229 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.source.cache; - -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.hadoop.metrics2.sink.timeline.TimelineMetric; -import org.apache.hadoop.metrics2.sink.timeline.TimelineMetrics; - -import net.sf.ehcache.Cache; -import net.sf.ehcache.CacheException; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Ehcache; -import net.sf.ehcache.Element; -import net.sf.ehcache.config.CacheConfiguration; -import net.sf.ehcache.config.PersistenceConfiguration; -import net.sf.ehcache.config.SizeOfPolicyConfiguration; -import net.sf.ehcache.event.CacheEventListener; -import net.sf.ehcache.store.MemoryStoreEvictionPolicy; - -public class InternalMetricsCache { - private static final Log LOG = LogFactory.getLog(InternalMetricsCache.class); - private final String instanceName; - private final String maxHeapPercent; - private volatile boolean isCacheInitialized = false; - private Cache cache; - static final String TIMELINE_METRIC_CACHE_MANAGER_NAME = "internalMetricsCacheManager"; - private final Lock lock = new ReentrantLock(); - private static final int LOCK_TIMEOUT_SECONDS = 2; - - public InternalMetricsCache(String instanceName, String maxHeapPercent) { - this.instanceName = instanceName; - this.maxHeapPercent = maxHeapPercent; - initialize(); - } - - private void initialize() { - // Check in case of contention to avoid ObjectExistsException - if (isCacheInitialized) { - throw new RuntimeException("Cannot initialize internal cache twice"); - } - - System.setProperty("net.sf.ehcache.skipUpdateCheck", "true"); - System.setProperty("net.sf.ehcache.sizeofengine." + TIMELINE_METRIC_CACHE_MANAGER_NAME, - "org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.source.cache.InternalMetricsCacheSizeOfEngine"); - - net.sf.ehcache.config.Configuration managerConfig = - new net.sf.ehcache.config.Configuration(); - managerConfig.setName(TIMELINE_METRIC_CACHE_MANAGER_NAME); - - // Set max heap available to the cache manager - managerConfig.setMaxBytesLocalHeap(maxHeapPercent); - - //Create a singleton CacheManager using defaults - CacheManager manager = CacheManager.create(managerConfig); - - LOG.info("Creating Metrics Cache with maxHeapPercent => " + maxHeapPercent); - - // Create a Cache specifying its configuration. - CacheConfiguration cacheConfiguration = new CacheConfiguration() - .name(instanceName) - .memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LRU) - .sizeOfPolicy(new SizeOfPolicyConfiguration() // Set sizeOf policy to continue on max depth reached - avoid OOM - .maxDepth(10000) - .maxDepthExceededBehavior(SizeOfPolicyConfiguration.MaxDepthExceededBehavior.CONTINUE)) - .eternal(true) // infinite time until eviction - .persistence(new PersistenceConfiguration() - .strategy(PersistenceConfiguration.Strategy.NONE.name())); - - cache = new Cache(cacheConfiguration); - cache.getCacheEventNotificationService().registerListener(new InternalCacheEvictionListener()); - - LOG.info("Registering internal metrics cache with provider: name = " + - cache.getName() + ", guid: " + cache.getGuid()); - - manager.addCache(cache); - - isCacheInitialized = true; - } - - public InternalMetricCacheValue getInternalMetricCacheValue(InternalMetricCacheKey key) { - Element ele = cache.get(key); - if (ele != null) { - return (InternalMetricCacheValue) ele.getObjectValue(); - } - return null; - } - - public Collection<TimelineMetrics> evictAll() { - TimelineMetrics metrics = new TimelineMetrics(); - try { - if (lock.tryLock(LOCK_TIMEOUT_SECONDS, TimeUnit.SECONDS)) { - try{ - List keys = cache.getKeys(); - for (Object obj : keys) { - TimelineMetric metric = new TimelineMetric(); - InternalMetricCacheKey key = (InternalMetricCacheKey) obj; - metric.setMetricName(key.getMetricName()); - metric.setAppId(key.getAppId()); - metric.setInstanceId(key.getInstanceId()); - metric.setHostName(key.getHostname()); - metric.setStartTime(key.getStartTime()); - Element ele = cache.get(key); - metric.setMetricValues(((InternalMetricCacheValue) ele.getObjectValue()).getMetricValues()); - metrics.getMetrics().add(metric); - } - cache.removeAll(); - } finally { - lock.unlock(); - } - } else { - LOG.warn("evictAll: Unable to acquire lock on the cache instance. " + - "Giving up after " + LOCK_TIMEOUT_SECONDS + " seconds."); - } - } catch (InterruptedException e) { - LOG.warn("Interrupted while waiting to acquire lock"); - } - - return Collections.singletonList(metrics); - } - - public void putAll(Collection<TimelineMetrics> metrics) { - try { - if (lock.tryLock(LOCK_TIMEOUT_SECONDS, TimeUnit.SECONDS)) { - try { - if (metrics != null) { - for (TimelineMetrics timelineMetrics : metrics) { - for (TimelineMetric timelineMetric : timelineMetrics.getMetrics()) { - InternalMetricCacheKey key = new InternalMetricCacheKey( - timelineMetric.getMetricName(), - timelineMetric.getAppId(), - timelineMetric.getInstanceId(), - timelineMetric.getHostName(), - timelineMetric.getStartTime() - ); - - Element ele = cache.get(key); - if (ele != null) { - InternalMetricCacheValue value = (InternalMetricCacheValue) ele.getObjectValue(); - value.addMetricValues(timelineMetric.getMetricValues()); - } else { - InternalMetricCacheValue value = new InternalMetricCacheValue(); - value.setMetricValues(timelineMetric.getMetricValues()); - cache.put(new Element(key, value)); - } - } - } - } - } finally { - lock.unlock(); - } - } else { - LOG.warn("putAll: Unable to acquire lock on the cache instance. " + - "Giving up after " + LOCK_TIMEOUT_SECONDS + " seconds."); - } - } catch (InterruptedException e) { - LOG.warn("Interrupted while waiting to acquire lock"); - } - } - - class InternalCacheEvictionListener implements CacheEventListener { - - @Override - public void notifyElementRemoved(Ehcache cache, Element element) throws CacheException { - // expected - } - - @Override - public void notifyElementPut(Ehcache cache, Element element) throws CacheException { - // do nothing - } - - @Override - public void notifyElementUpdated(Ehcache cache, Element element) throws CacheException { - // do nothing - } - - @Override - public void notifyElementExpired(Ehcache cache, Element element) { - // do nothing - } - - @Override - public void notifyElementEvicted(Ehcache cache, Element element) { - // Bad - Remote endpoint cannot keep up resulting in flooding - InternalMetricCacheKey key = (InternalMetricCacheKey) element.getObjectKey(); - LOG.warn("Evicting element from internal metrics cache, metric => " + key - .getMetricName() + ", startTime = " + new Date(key.getStartTime())); - } - - @Override - public void notifyRemoveAll(Ehcache cache) { - // expected - } - - @Override - public Object clone() throws CloneNotSupportedException { - return null; - } - - @Override - public void dispose() { - // do nothing - } - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/42112e28/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/cache/InternalMetricsCacheProvider.java ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/cache/InternalMetricsCacheProvider.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/cache/InternalMetricsCacheProvider.java deleted file mode 100644 index 3e0dc1b..0000000 --- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/cache/InternalMetricsCacheProvider.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.source.cache; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.TimelineMetricConfiguration; - -public class InternalMetricsCacheProvider { - private Map<String, InternalMetricsCache> metricsCacheMap = new ConcurrentHashMap<>(); - private static final InternalMetricsCacheProvider instance = new InternalMetricsCacheProvider(); - - private InternalMetricsCacheProvider() { - } - - public static InternalMetricsCacheProvider getInstance() { - return instance; - } - - public InternalMetricsCache getCacheInstance(String instanceName) { - if (metricsCacheMap.containsKey(instanceName)) { - return metricsCacheMap.get(instanceName); - } else { - TimelineMetricConfiguration conf = TimelineMetricConfiguration.getInstance(); - InternalMetricsCache cache = new InternalMetricsCache(instanceName, - conf.getInternalCacheHeapPercent(instanceName)); - - metricsCacheMap.put(instanceName, cache); - return cache; - } - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/42112e28/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/cache/InternalMetricsCacheSizeOfEngine.java ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/cache/InternalMetricsCacheSizeOfEngine.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/cache/InternalMetricsCacheSizeOfEngine.java deleted file mode 100644 index e36c981..0000000 --- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/source/cache/InternalMetricsCacheSizeOfEngine.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.source.cache; - -import org.apache.hadoop.metrics2.sink.timeline.cache.TimelineMetricsEhCacheSizeOfEngine; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class InternalMetricsCacheSizeOfEngine extends TimelineMetricsEhCacheSizeOfEngine { - private final static Logger LOG = LoggerFactory.getLogger(InternalMetricsCacheSizeOfEngine.class); - - public InternalMetricsCacheSizeOfEngine() { - // Invoke default constructor in base class - } - - @Override - protected long getSizeOfEntry(Object key, Object value) { - try { - LOG.debug("BEGIN - Sizeof, key: {}, value: {}", key, value); - long size = 0; - if (key instanceof InternalMetricCacheKey) { - InternalMetricCacheKey metricCacheKey = (InternalMetricCacheKey) key; - size += reflectionSizeOf.sizeOf(metricCacheKey.getMetricName()); - size += reflectionSizeOf.sizeOf(metricCacheKey.getAppId()); - size += reflectionSizeOf.sizeOf(metricCacheKey.getInstanceId()); // null safe - size += reflectionSizeOf.sizeOf(metricCacheKey.getHostname()); - } - if (value instanceof InternalMetricCacheValue) { - size += getValueMapSize(((InternalMetricCacheValue) value).getMetricValues()); - } - // Mark size as not being exact - return size; - } finally { - LOG.debug("END - Sizeof, key: {}", key); - } - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/42112e28/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/uuid/HashBasedUuidGenStrategy.java ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/uuid/HashBasedUuidGenStrategy.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/uuid/HashBasedUuidGenStrategy.java deleted file mode 100644 index 3acf656..0000000 --- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/uuid/HashBasedUuidGenStrategy.java +++ /dev/null @@ -1,206 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.uuid; - -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.apache.commons.lang.ArrayUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.aggregators.TimelineClusterMetric; - -public class HashBasedUuidGenStrategy implements MetricUuidGenStrategy { - - /** - * Computes the UUID for a timelineClusterMetric. - * @param timelineClusterMetric - * @param maxLength - * @return byte array of length 'maxlength' - */ - @Override - public byte[] computeUuid(TimelineClusterMetric timelineClusterMetric, int maxLength) { - - int metricNameUuidLength = 12; - String metricName = timelineClusterMetric.getMetricName(); - - //Compute the individual splits. - String[] splits = getIndidivualSplits(metricName); - - /* - Compute the ascii sum of every split in the metric name. (asciiSum += (int) splits[s].charAt(i)) - For the last split, use weighted sum instead of ascii sum. (asciiSum += ((i+1) * (int) splits[s].charAt(i))) - These weighted sums are 'appended' to get the unique ID for metric name. - */ - StringBuilder splitSums = new StringBuilder(); - if (splits.length > 0) { - for (int s = 0; s < splits.length; s++) { - int asciiSum = 0; - if ( s < splits.length -1) { - for (int i = 0; i < splits[s].length(); i++) { - asciiSum += (int) splits[s].charAt(i); // Get Ascii Sum. - } - } else { - for (int i = 0; i < splits[s].length(); i++) { - asciiSum += ((i+1) * (int) splits[s].charAt(i)); //weighted sum for last split. - } - } - splitSums.append(asciiSum); //Append the sum to the array of sums. - } - } - - //Compute a unique metric seed for the stemmed metric name - String stemmedMetric = stem(metricName); - long metricSeed = 100123456789L; - for (int i = 0; i < stemmedMetric.length(); i++) { - metricSeed += stemmedMetric.charAt(i); - } - - //Reverse the computed seed to get a metric UUID portion which is used optionally. - byte[] metricUuidPortion = StringUtils.reverse(String.valueOf(metricSeed)).getBytes(); - String splitSumString = splitSums.toString(); - int splitLength = splitSumString.length(); - - //If splitSums length > required metric UUID length, use only the required length suffix substring of the splitSums as metric UUID. - if (splitLength > metricNameUuidLength) { - metricUuidPortion = ArrayUtils.subarray(splitSumString.getBytes(), splitLength - metricNameUuidLength, splitLength); - } else { - //If splitSums is not enough for required metric UUID length, pad with the metric uuid portion. - int pad = metricNameUuidLength - splitLength; - metricUuidPortion = ArrayUtils.addAll(splitSumString.getBytes(), ArrayUtils.subarray(metricUuidPortion, 0, pad)); - } - - /* - For appId and instanceId the logic is similar. Use a seed integer to start with and compute ascii sum. - Based on required length, use a suffix of the computed uuid. - */ - String appId = timelineClusterMetric.getAppId(); - int appidSeed = 11; - for (int i = 0; i < appId.length(); i++) { - appidSeed += appId.charAt(i); - } - String appIdSeedStr = String.valueOf(appidSeed); - byte[] appUuidPortion = ArrayUtils.subarray(appIdSeedStr.getBytes(), appIdSeedStr.length() - 2, appIdSeedStr.length()); - - String instanceId = timelineClusterMetric.getInstanceId(); - ByteBuffer buffer = ByteBuffer.allocate(4); - byte[] instanceUuidPortion = new byte[2]; - if (StringUtils.isNotEmpty(instanceId)) { - int instanceIdSeed = 1489; - for (int i = 0; i < appId.length(); i++) { - instanceIdSeed += appId.charAt(i); - } - buffer.putInt(instanceIdSeed); - ArrayUtils.subarray(buffer.array(), 2, 4); - } - - // Concatenate all UUIDs together (metric uuid + appId uuid + instanceId uuid) - return ArrayUtils.addAll(ArrayUtils.addAll(metricUuidPortion, appUuidPortion), instanceUuidPortion); - } - - /** - * Splits the metric name into individual tokens. - * For example, - * kafka.server.ReplicaManager.LeaderCount -> [kafka, server, ReplicaManager, LeaderCount] - * default.General.api_drop_table_15min_rate -> [default, General, api, drop, table, 15min, rate] - * @param metricName - * @return - */ - private String[] getIndidivualSplits(String metricName) { - List<String> tokens = new ArrayList<>(); - String[] splits = new String[0]; - if (metricName.contains("\\.")) { - splits = metricName.split("\\."); - for (String split : splits) { - if (split.contains("_")) { - tokens.addAll(Arrays.asList(split.split("_"))); - } else { - tokens.add(split); - } - } - } - - if (splits.length <= 1) { - splits = metricName.split("\\_"); - return splits; - } - - if (splits.length <= 1) { - splits = metricName.split("\\="); - return splits; - } - - return tokens.toArray(new String[tokens.size()]); - } - - /** - * Stem the metric name. Remove a set of usual suspects characters. - * @param metricName - * @return - */ - private String stem(String metricName) { - String metric = metricName.toLowerCase(); - String regex = "[\\.\\_\\%\\-\\=]"; - String trimmedMetric = StringUtils.removePattern(metric, regex); - return trimmedMetric; - } - - - /** - * Computes the UUID of a string. (hostname) - * Uses the ascii sum of the String. Numbers in the String are treated as actual numerical values rather than ascii values. - * @param value - * @param maxLength - * @return byte array of length 'maxlength' - */ - @Override - public byte[] computeUuid(String value, int maxLength) { - - if (StringUtils.isEmpty(value)) { - return null; - } - int len = value.length(); - int numericValue = 0; - int seed = 1489; - for (int i = 0; i < len; i++) { - int ascii = value.charAt(i); - if (48 <= ascii && ascii <= 57) { - numericValue += numericValue * 10 + (ascii - 48); - } else { - if (numericValue > 0) { - seed += numericValue; - numericValue = 0; - } - seed+= value.charAt(i); - } - } - - if (numericValue != 0) { - seed+=numericValue; - } - - String seedStr = String.valueOf(seed); - if (seedStr.length() < maxLength) { - return null; - } else { - return seedStr.substring(seedStr.length() - maxLength, seedStr.length()).getBytes(); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/42112e28/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/uuid/MetricUuidGenStrategy.java ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/uuid/MetricUuidGenStrategy.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/uuid/MetricUuidGenStrategy.java deleted file mode 100644 index b6a1890..0000000 --- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/uuid/MetricUuidGenStrategy.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.uuid; - -import org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.aggregators.TimelineClusterMetric; - -public interface MetricUuidGenStrategy { - - /** - * Compute UUID for a given value - * @param timelineMetric instance - * @param maxLength - * @return - */ -// byte[] computeUuid(TimelineMetric timelineMetric, int maxLength); - - /** - * Compute UUID for a given value - * @param value - * @param maxLength - * @return - */ - byte[] computeUuid(TimelineClusterMetric timelineClusterMetric, int maxLength); - - /** - * Compute UUID for a given value - * @param value - * @param maxLength - * @return - */ - byte[] computeUuid(String value, int maxLength); - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/42112e28/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/uuid/RandomUuidGenStrategy.java ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/uuid/RandomUuidGenStrategy.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/uuid/RandomUuidGenStrategy.java deleted file mode 100644 index 1443067..0000000 --- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/uuid/RandomUuidGenStrategy.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.uuid; - -import java.security.SecureRandom; - -import org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.aggregators.TimelineClusterMetric; - -import com.google.common.primitives.Longs; - -public class RandomUuidGenStrategy implements MetricUuidGenStrategy { - private static SecureRandom randomGenerator; - - public RandomUuidGenStrategy() { - randomGenerator = new SecureRandom( - Longs.toByteArray(System.currentTimeMillis())); - } - - @Override - public byte[] computeUuid(TimelineClusterMetric timelineClusterMetric, int maxLength) { - final byte[] bytes = new byte[maxLength]; - randomGenerator.nextBytes(bytes); - return bytes; - } - -// @Override -// public byte[] computeUuid(TimelineMetric timelineMetric, int maxLength) { -// return new byte[10]; -// } - - @Override - public byte[] computeUuid(String value, int maxLength) { - final byte[] bytes = new byte[maxLength]; - randomGenerator.nextBytes(bytes); - return bytes; - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/42112e28/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/records/ApplicationAttemptFinishData.java ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/records/ApplicationAttemptFinishData.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/records/ApplicationAttemptFinishData.java deleted file mode 100644 index 7ba51af..0000000 --- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/records/ApplicationAttemptFinishData.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.yarn.server.applicationhistoryservice.records; - -import org.apache.hadoop.classification.InterfaceAudience.Public; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; -import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; -import org.apache.hadoop.yarn.api.records.YarnApplicationAttemptState; -import org.apache.hadoop.yarn.util.Records; - -/** - * The class contains the fields that can be determined when - * <code>RMAppAttempt</code> finishes, and that need to be stored persistently. - */ -@Public -@Unstable -public abstract class ApplicationAttemptFinishData { - - @Public - @Unstable - public static ApplicationAttemptFinishData newInstance( - ApplicationAttemptId appAttemptId, String diagnosticsInfo, - String trackingURL, FinalApplicationStatus finalApplicationStatus, - YarnApplicationAttemptState yarnApplicationAttemptState) { - ApplicationAttemptFinishData appAttemptFD = - Records.newRecord(ApplicationAttemptFinishData.class); - appAttemptFD.setApplicationAttemptId(appAttemptId); - appAttemptFD.setDiagnosticsInfo(diagnosticsInfo); - appAttemptFD.setTrackingURL(trackingURL); - appAttemptFD.setFinalApplicationStatus(finalApplicationStatus); - appAttemptFD.setYarnApplicationAttemptState(yarnApplicationAttemptState); - return appAttemptFD; - } - - @Public - @Unstable - public abstract ApplicationAttemptId getApplicationAttemptId(); - - @Public - @Unstable - public abstract void setApplicationAttemptId( - ApplicationAttemptId applicationAttemptId); - - @Public - @Unstable - public abstract String getTrackingURL(); - - @Public - @Unstable - public abstract void setTrackingURL(String trackingURL); - - @Public - @Unstable - public abstract String getDiagnosticsInfo(); - - @Public - @Unstable - public abstract void setDiagnosticsInfo(String diagnosticsInfo); - - @Public - @Unstable - public abstract FinalApplicationStatus getFinalApplicationStatus(); - - @Public - @Unstable - public abstract void setFinalApplicationStatus( - FinalApplicationStatus finalApplicationStatus); - - @Public - @Unstable - public abstract YarnApplicationAttemptState getYarnApplicationAttemptState(); - - @Public - @Unstable - public abstract void setYarnApplicationAttemptState( - YarnApplicationAttemptState yarnApplicationAttemptState); - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/42112e28/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/records/ApplicationAttemptHistoryData.java ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/records/ApplicationAttemptHistoryData.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/records/ApplicationAttemptHistoryData.java deleted file mode 100644 index b759ab1..0000000 --- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/records/ApplicationAttemptHistoryData.java +++ /dev/null @@ -1,171 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.yarn.server.applicationhistoryservice.records; - -import org.apache.hadoop.classification.InterfaceAudience.Public; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; -import org.apache.hadoop.yarn.api.records.ContainerId; -import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; -import org.apache.hadoop.yarn.api.records.YarnApplicationAttemptState; - -/** - * The class contains all the fields that are stored persistently for - * <code>RMAppAttempt</code>. - */ -@Public -@Unstable -public class ApplicationAttemptHistoryData { - - private ApplicationAttemptId applicationAttemptId; - - private String host; - - private int rpcPort; - - private String trackingURL; - - private String diagnosticsInfo; - - private FinalApplicationStatus finalApplicationStatus; - - private ContainerId masterContainerId; - - private YarnApplicationAttemptState yarnApplicationAttemptState; - - @Public - @Unstable - public static ApplicationAttemptHistoryData newInstance( - ApplicationAttemptId appAttemptId, String host, int rpcPort, - ContainerId masterContainerId, String diagnosticsInfo, - String trackingURL, FinalApplicationStatus finalApplicationStatus, - YarnApplicationAttemptState yarnApplicationAttemptState) { - ApplicationAttemptHistoryData appAttemptHD = - new ApplicationAttemptHistoryData(); - appAttemptHD.setApplicationAttemptId(appAttemptId); - appAttemptHD.setHost(host); - appAttemptHD.setRPCPort(rpcPort); - appAttemptHD.setMasterContainerId(masterContainerId); - appAttemptHD.setDiagnosticsInfo(diagnosticsInfo); - appAttemptHD.setTrackingURL(trackingURL); - appAttemptHD.setFinalApplicationStatus(finalApplicationStatus); - appAttemptHD.setYarnApplicationAttemptState(yarnApplicationAttemptState); - return appAttemptHD; - } - - @Public - @Unstable - public ApplicationAttemptId getApplicationAttemptId() { - return applicationAttemptId; - } - - @Public - @Unstable - public void - setApplicationAttemptId(ApplicationAttemptId applicationAttemptId) { - this.applicationAttemptId = applicationAttemptId; - } - - @Public - @Unstable - public String getHost() { - return host; - } - - @Public - @Unstable - public void setHost(String host) { - this.host = host; - } - - @Public - @Unstable - public int getRPCPort() { - return rpcPort; - } - - @Public - @Unstable - public void setRPCPort(int rpcPort) { - this.rpcPort = rpcPort; - } - - @Public - @Unstable - public String getTrackingURL() { - return trackingURL; - } - - @Public - @Unstable - public void setTrackingURL(String trackingURL) { - this.trackingURL = trackingURL; - } - - @Public - @Unstable - public String getDiagnosticsInfo() { - return diagnosticsInfo; - } - - @Public - @Unstable - public void setDiagnosticsInfo(String diagnosticsInfo) { - this.diagnosticsInfo = diagnosticsInfo; - } - - @Public - @Unstable - public FinalApplicationStatus getFinalApplicationStatus() { - return finalApplicationStatus; - } - - @Public - @Unstable - public void setFinalApplicationStatus( - FinalApplicationStatus finalApplicationStatus) { - this.finalApplicationStatus = finalApplicationStatus; - } - - @Public - @Unstable - public ContainerId getMasterContainerId() { - return masterContainerId; - } - - @Public - @Unstable - public void setMasterContainerId(ContainerId masterContainerId) { - this.masterContainerId = masterContainerId; - } - - @Public - @Unstable - public YarnApplicationAttemptState getYarnApplicationAttemptState() { - return yarnApplicationAttemptState; - } - - @Public - @Unstable - public void setYarnApplicationAttemptState( - YarnApplicationAttemptState yarnApplicationAttemptState) { - this.yarnApplicationAttemptState = yarnApplicationAttemptState; - } - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/42112e28/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/records/ApplicationAttemptStartData.java ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/records/ApplicationAttemptStartData.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/records/ApplicationAttemptStartData.java deleted file mode 100644 index 7ca43fa..0000000 --- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/records/ApplicationAttemptStartData.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.yarn.server.applicationhistoryservice.records; - -import org.apache.hadoop.classification.InterfaceAudience.Public; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; -import org.apache.hadoop.yarn.api.records.ContainerId; -import org.apache.hadoop.yarn.util.Records; - -/** - * The class contains the fields that can be determined when - * <code>RMAppAttempt</code> starts, and that need to be stored persistently. - */ -@Public -@Unstable -public abstract class ApplicationAttemptStartData { - - @Public - @Unstable - public static ApplicationAttemptStartData newInstance( - ApplicationAttemptId appAttemptId, String host, int rpcPort, - ContainerId masterContainerId) { - ApplicationAttemptStartData appAttemptSD = - Records.newRecord(ApplicationAttemptStartData.class); - appAttemptSD.setApplicationAttemptId(appAttemptId); - appAttemptSD.setHost(host); - appAttemptSD.setRPCPort(rpcPort); - appAttemptSD.setMasterContainerId(masterContainerId); - return appAttemptSD; - } - - @Public - @Unstable - public abstract ApplicationAttemptId getApplicationAttemptId(); - - @Public - @Unstable - public abstract void setApplicationAttemptId( - ApplicationAttemptId applicationAttemptId); - - @Public - @Unstable - public abstract String getHost(); - - @Public - @Unstable - public abstract void setHost(String host); - - @Public - @Unstable - public abstract int getRPCPort(); - - @Public - @Unstable - public abstract void setRPCPort(int rpcPort); - - @Public - @Unstable - public abstract ContainerId getMasterContainerId(); - - @Public - @Unstable - public abstract void setMasterContainerId(ContainerId masterContainerId); - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/42112e28/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/records/ApplicationFinishData.java ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/records/ApplicationFinishData.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/records/ApplicationFinishData.java deleted file mode 100644 index 997fa6c..0000000 --- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/records/ApplicationFinishData.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.yarn.server.applicationhistoryservice.records; - -import org.apache.hadoop.classification.InterfaceAudience.Public; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.ApplicationId; -import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; -import org.apache.hadoop.yarn.api.records.YarnApplicationState; -import org.apache.hadoop.yarn.util.Records; - -/** - * The class contains the fields that can be determined when <code>RMApp</code> - * finishes, and that need to be stored persistently. - */ -@Public -@Unstable -public abstract class ApplicationFinishData { - - @Public - @Unstable - public static ApplicationFinishData newInstance(ApplicationId applicationId, - long finishTime, String diagnosticsInfo, - FinalApplicationStatus finalApplicationStatus, - YarnApplicationState yarnApplicationState) { - ApplicationFinishData appFD = - Records.newRecord(ApplicationFinishData.class); - appFD.setApplicationId(applicationId); - appFD.setFinishTime(finishTime); - appFD.setDiagnosticsInfo(diagnosticsInfo); - appFD.setFinalApplicationStatus(finalApplicationStatus); - appFD.setYarnApplicationState(yarnApplicationState); - return appFD; - } - - @Public - @Unstable - public abstract ApplicationId getApplicationId(); - - @Public - @Unstable - public abstract void setApplicationId(ApplicationId applicationId); - - @Public - @Unstable - public abstract long getFinishTime(); - - @Public - @Unstable - public abstract void setFinishTime(long finishTime); - - @Public - @Unstable - public abstract String getDiagnosticsInfo(); - - @Public - @Unstable - public abstract void setDiagnosticsInfo(String diagnosticsInfo); - - @Public - @Unstable - public abstract FinalApplicationStatus getFinalApplicationStatus(); - - @Public - @Unstable - public abstract void setFinalApplicationStatus( - FinalApplicationStatus finalApplicationStatus); - - @Public - @Unstable - public abstract YarnApplicationState getYarnApplicationState(); - - @Public - @Unstable - public abstract void setYarnApplicationState( - YarnApplicationState yarnApplicationState); - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/42112e28/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/records/ApplicationHistoryData.java ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/records/ApplicationHistoryData.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/records/ApplicationHistoryData.java deleted file mode 100644 index b7d16f3..0000000 --- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/records/ApplicationHistoryData.java +++ /dev/null @@ -1,213 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.yarn.server.applicationhistoryservice.records; - -import org.apache.hadoop.classification.InterfaceAudience.Public; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.ApplicationId; -import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; -import org.apache.hadoop.yarn.api.records.YarnApplicationState; - -/** - * The class contains all the fields that are stored persistently for - * <code>RMApp</code>. - */ -@Public -@Unstable -public class ApplicationHistoryData { - - private ApplicationId applicationId; - - private String applicationName; - - private String applicationType; - - private String user; - - private String queue; - - private long submitTime; - - private long startTime; - - private long finishTime; - - private String diagnosticsInfo; - - private FinalApplicationStatus finalApplicationStatus; - - private YarnApplicationState yarnApplicationState; - - @Public - @Unstable - public static ApplicationHistoryData newInstance(ApplicationId applicationId, - String applicationName, String applicationType, String queue, - String user, long submitTime, long startTime, long finishTime, - String diagnosticsInfo, FinalApplicationStatus finalApplicationStatus, - YarnApplicationState yarnApplicationState) { - ApplicationHistoryData appHD = new ApplicationHistoryData(); - appHD.setApplicationId(applicationId); - appHD.setApplicationName(applicationName); - appHD.setApplicationType(applicationType); - appHD.setQueue(queue); - appHD.setUser(user); - appHD.setSubmitTime(submitTime); - appHD.setStartTime(startTime); - appHD.setFinishTime(finishTime); - appHD.setDiagnosticsInfo(diagnosticsInfo); - appHD.setFinalApplicationStatus(finalApplicationStatus); - appHD.setYarnApplicationState(yarnApplicationState); - return appHD; - } - - @Public - @Unstable - public ApplicationId getApplicationId() { - return applicationId; - } - - @Public - @Unstable - public void setApplicationId(ApplicationId applicationId) { - this.applicationId = applicationId; - } - - @Public - @Unstable - public String getApplicationName() { - return applicationName; - } - - @Public - @Unstable - public void setApplicationName(String applicationName) { - this.applicationName = applicationName; - } - - @Public - @Unstable - public String getApplicationType() { - return applicationType; - } - - @Public - @Unstable - public void setApplicationType(String applicationType) { - this.applicationType = applicationType; - } - - @Public - @Unstable - public String getUser() { - return user; - } - - @Public - @Unstable - public void setUser(String user) { - this.user = user; - } - - @Public - @Unstable - public String getQueue() { - return queue; - } - - @Public - @Unstable - public void setQueue(String queue) { - this.queue = queue; - } - - @Public - @Unstable - public long getSubmitTime() { - return submitTime; - } - - @Public - @Unstable - public void setSubmitTime(long submitTime) { - this.submitTime = submitTime; - } - - @Public - @Unstable - public long getStartTime() { - return startTime; - } - - @Public - @Unstable - public void setStartTime(long startTime) { - this.startTime = startTime; - } - - @Public - @Unstable - public long getFinishTime() { - return finishTime; - } - - @Public - @Unstable - public void setFinishTime(long finishTime) { - this.finishTime = finishTime; - } - - @Public - @Unstable - public String getDiagnosticsInfo() { - return diagnosticsInfo; - } - - @Public - @Unstable - public void setDiagnosticsInfo(String diagnosticsInfo) { - this.diagnosticsInfo = diagnosticsInfo; - } - - @Public - @Unstable - public FinalApplicationStatus getFinalApplicationStatus() { - return finalApplicationStatus; - } - - @Public - @Unstable - public void setFinalApplicationStatus( - FinalApplicationStatus finalApplicationStatus) { - this.finalApplicationStatus = finalApplicationStatus; - } - - @Public - @Unstable - public YarnApplicationState getYarnApplicationState() { - return this.yarnApplicationState; - } - - @Public - @Unstable - public void - setYarnApplicationState(YarnApplicationState yarnApplicationState) { - this.yarnApplicationState = yarnApplicationState; - } - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/42112e28/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/records/ApplicationStartData.java ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/records/ApplicationStartData.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/records/ApplicationStartData.java deleted file mode 100644 index 6bc1323..0000000 --- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/records/ApplicationStartData.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.yarn.server.applicationhistoryservice.records; - -import org.apache.hadoop.classification.InterfaceAudience.Public; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.ApplicationId; -import org.apache.hadoop.yarn.util.Records; - -/** - * The class contains the fields that can be determined when <code>RMApp</code> - * starts, and that need to be stored persistently. - */ -@Public -@Unstable -public abstract class ApplicationStartData { - - @Public - @Unstable - public static ApplicationStartData newInstance(ApplicationId applicationId, - String applicationName, String applicationType, String queue, - String user, long submitTime, long startTime) { - ApplicationStartData appSD = Records.newRecord(ApplicationStartData.class); - appSD.setApplicationId(applicationId); - appSD.setApplicationName(applicationName); - appSD.setApplicationType(applicationType); - appSD.setQueue(queue); - appSD.setUser(user); - appSD.setSubmitTime(submitTime); - appSD.setStartTime(startTime); - return appSD; - } - - @Public - @Unstable - public abstract ApplicationId getApplicationId(); - - @Public - @Unstable - public abstract void setApplicationId(ApplicationId applicationId); - - @Public - @Unstable - public abstract String getApplicationName(); - - @Public - @Unstable - public abstract void setApplicationName(String applicationName); - - @Public - @Unstable - public abstract String getApplicationType(); - - @Public - @Unstable - public abstract void setApplicationType(String applicationType); - - @Public - @Unstable - public abstract String getUser(); - - @Public - @Unstable - public abstract void setUser(String user); - - @Public - @Unstable - public abstract String getQueue(); - - @Public - @Unstable - public abstract void setQueue(String queue); - - @Public - @Unstable - public abstract long getSubmitTime(); - - @Public - @Unstable - public abstract void setSubmitTime(long submitTime); - - @Public - @Unstable - public abstract long getStartTime(); - - @Public - @Unstable - public abstract void setStartTime(long startTime); - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/42112e28/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/records/ContainerFinishData.java ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/records/ContainerFinishData.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/records/ContainerFinishData.java deleted file mode 100644 index 5eb9ddb..0000000 --- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/records/ContainerFinishData.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.yarn.server.applicationhistoryservice.records; - -import org.apache.hadoop.classification.InterfaceAudience.Public; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.ContainerId; -import org.apache.hadoop.yarn.api.records.ContainerState; -import org.apache.hadoop.yarn.util.Records; - -/** - * The class contains the fields that can be determined when - * <code>RMContainer</code> finishes, and that need to be stored persistently. - */ -@Public -@Unstable -public abstract class ContainerFinishData { - - @Public - @Unstable - public static ContainerFinishData newInstance(ContainerId containerId, - long finishTime, String diagnosticsInfo, int containerExitCode, - ContainerState containerState) { - ContainerFinishData containerFD = - Records.newRecord(ContainerFinishData.class); - containerFD.setContainerId(containerId); - containerFD.setFinishTime(finishTime); - containerFD.setDiagnosticsInfo(diagnosticsInfo); - containerFD.setContainerExitStatus(containerExitCode); - containerFD.setContainerState(containerState); - return containerFD; - } - - @Public - @Unstable - public abstract ContainerId getContainerId(); - - @Public - @Unstable - public abstract void setContainerId(ContainerId containerId); - - @Public - @Unstable - public abstract long getFinishTime(); - - @Public - @Unstable - public abstract void setFinishTime(long finishTime); - - @Public - @Unstable - public abstract String getDiagnosticsInfo(); - - @Public - @Unstable - public abstract void setDiagnosticsInfo(String diagnosticsInfo); - - @Public - @Unstable - public abstract int getContainerExitStatus(); - - @Public - @Unstable - public abstract void setContainerExitStatus(int containerExitStatus); - - @Public - @Unstable - public abstract ContainerState getContainerState(); - - @Public - @Unstable - public abstract void setContainerState(ContainerState containerState); - -}
