下面列出了org.apache.commons.lang.time.DateUtils#MILLIS_PER_MINUTE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) {
String site = config.getString("dataSourceConfig.site");
String topic = config.getString("dataSourceConfig.topic");
this.baseMetricDimension = new HashMap<>();
this.baseMetricDimension.put("site", site);
this.baseMetricDimension.put("topic", topic);
registry = new MetricRegistry();
this.granularity = DEFAULT_METRIC_GRANULARITY;
if (config.hasPath("dataSourceConfig.kafkaDistributionDataIntervalMin")) {
this.granularity = config.getInt("dataSourceConfig.kafkaDistributionDataIntervalMin") * DateUtils.MILLIS_PER_MINUTE;
}
String host = config.getString(EagleConfigConstants.EAGLE_PROPS + "." + EagleConfigConstants.EAGLE_SERVICE + "." + EagleConfigConstants.HOST);
int port = config.getInt(EagleConfigConstants.EAGLE_PROPS + "." + EagleConfigConstants.EAGLE_SERVICE + "." + EagleConfigConstants.PORT);
String username = config.getString(EagleConfigConstants.EAGLE_PROPS + "." + EagleConfigConstants.EAGLE_SERVICE + "." + EagleConfigConstants.USERNAME);
String password = config.getString(EagleConfigConstants.EAGLE_PROPS + "." + EagleConfigConstants.EAGLE_SERVICE + "." + EagleConfigConstants.PASSWORD);
listener = new EagleServiceReporterMetricListener(host, port, username, password);
}
public void startCompleteStatusCheckerThread() {
while(true) {
List<Object> list;
try {
list = fetcher.getResource(ResourceType.JOB_LIST, JobState.COMPLETED.name());
if (list == null) {
LOG.warn("Current Completed Job List is Empty");
continue;
}
@SuppressWarnings("unchecked")
List<AppInfo> apps = (List<AppInfo>)list.get(0);
Set<JobContext> completedJobSet = new HashSet<JobContext>();
for (AppInfo app : apps) {
//Only fetch MapReduce job
if (!YarnApplicationType.MAPREDUCE.name().equals(app.getApplicationType())
|| !jobFilter.accept(app.getUser())) {
continue;
}
if (System.currentTimeMillis() - app.getFinishedTime() < controlConfig.completedJobOutofDateTimeInMin * DateUtils.MILLIS_PER_MINUTE) {
completedJobSet.add(new JobContext(JobUtils.getJobIDByAppID(app.getId()),app.getUser(), System.currentTimeMillis()));
}
}
if (controlConfig.jobConfigEnabled) {
addIntoProcessingQueueAndList(completedJobSet, queueOfConfig, ResourceType.JOB_CONFIGURATION);
}
if (controlConfig.jobInfoEnabled) {
addIntoProcessingQueueAndList(completedJobSet, queueOfCompleteJobInfo, ResourceType.JOB_COMPLETE_INFO);
}
Thread.sleep(20 * 1000);
} catch (Throwable t) {
LOG.error("Got a throwable in fetching job completed list :", t);
}
}
}
public AlertDeduplicationStatus checkDedup(EntityTagsUniq key){
long current = key.timestamp;
if(!entites.containsKey(key)){
entites.put(key, current);
return AlertDeduplicationStatus.NEW;
}
long last = entites.get(key);
if(current - last >= dedupIntervalMin * DateUtils.MILLIS_PER_MINUTE){
entites.put(key, current);
return AlertDeduplicationStatus.DUPLICATED;
}
return AlertDeduplicationStatus.IGNORED;
}
public EagleMetric(long latestUserTimeClock, String metricName, double value) {
this(latestUserTimeClock, metricName, value, 5 * DateUtils.MILLIS_PER_MINUTE);
}