当前位置: 首页>>代码示例>>Java>>正文


Java IMonitoringMetric类代码示例

本文整理汇总了Java中eu.atos.sla.monitoring.IMonitoringMetric的典型用法代码示例。如果您正苦于以下问题:Java IMonitoringMetric类的具体用法?Java IMonitoringMetric怎么用?Java IMonitoringMetric使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IMonitoringMetric类属于eu.atos.sla.monitoring包,在下文中一共展示了IMonitoringMetric类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: receiveMetrics

import eu.atos.sla.monitoring.IMonitoringMetric; //导入依赖的package包/类
@POST
@Path("{agreementId}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.TEXT_PLAIN)
public Response receiveMetrics(
		@PathParam("agreementId") String agreementId, 
		final MonitoringMetric metric) {

	if (System.getenv(ENFORCEMENT_TEST) == null) {
		return buildResponse(HttpStatus.NOT_FOUND, 
				"Verify server is running with " + ENFORCEMENT_TEST + " env var");
	}
	logger.debug("receiveMetrics(agreementId={} data={}", agreementId, metric.toString());
	IAgreement agreement = agreementDao.getByAgreementId(agreementId);
	
	if (agreement == null) {
		return buildResponse(HttpStatus.NOT_FOUND, "agreement " + agreementId + " not found");
	}
	SimpleMetricsReceiverData data = new SimpleMetricsReceiverData(
			metric.getMetricKey(), 
			new SimpleMetricsReceiverData.SimpleMetricValue(metric.getMetricValue(), metric.getDate()));
	
	Map<IGuaranteeTerm, List<IMonitoringMetric>> metricsMap = translator.translate(agreement, data);
	enforcementService.doEnforcement(agreement, metricsMap);
	return buildResponse(HttpStatus.ACCEPTED, "Metrics received");
}
 
开发者ID:Atos-FiwareOps,项目名称:sla-framework,代码行数:27,代码来源:MetricsReceiverRest.java

示例2: getBreaches

import eu.atos.sla.monitoring.IMonitoringMetric; //导入依赖的package包/类
@Override
public Iterable<IMonitoringMetric> getBreaches(IAgreement agreement, String kpiName,
		Collection<IMonitoringMetric> metrics, String constraint) {

	if (kpiName == null) {
		throw new NullPointerException("kpiName is null");
	}
	/*
	 * TODO rsosa: This could be cached in some way.
	 */
	SimpleConstraintParser.SimpleConstraintElements elems = parse(constraint);
	Operator operator = elems.getOperator();
	double[] threshold = elems.getRightArray();
	
	if (kpiName.startsWith("avg")) {
		return new SimpleAverageValidatorIter(
				metrics, operator, threshold, MIN_SAMPLES).iterable();
	}
	else {
		return new SimpleValidatorIter(metrics, operator, threshold).iterable();
	}
}
 
开发者ID:Atos-FiwareOps,项目名称:sla-framework,代码行数:23,代码来源:SimpleConstraintEvaluator.java

示例3: evaluate

import eu.atos.sla.monitoring.IMonitoringMetric; //导入依赖的package包/类
/**
 * Evaluate if the metrics fulfill the agreement's service levels.
 * @param agreement Agreement to evaluate.
 * @param metricsMap Contains the list of metrics to check for each guarantee term. 
 * @return list of violations and compensations detected.
 */
public Map<IGuaranteeTerm, GuaranteeTermEvaluationResult> evaluate(IAgreement agreement,
		Map<IGuaranteeTerm, List<IMonitoringMetric>> metricsMap) {

	checkInitialized(false);
	
	Map<IGuaranteeTerm,GuaranteeTermEvaluationResult> result = 
			new HashMap<IGuaranteeTerm,GuaranteeTermEvaluationResult>();
	
	Date now = new Date();
	for (IGuaranteeTerm term : metricsMap.keySet()) {

		List<IMonitoringMetric> metrics = metricsMap.get(term);
		if (metrics.size() > 0) {
			GuaranteeTermEvaluationResult aux = termEval.evaluate(agreement, term, metrics, now);
			result.put(term, aux);
		}
	}

	return result;
}
 
开发者ID:Atos-FiwareOps,项目名称:sla-framework,代码行数:27,代码来源:AgreementEvaluator.java

示例4: evaluate

import eu.atos.sla.monitoring.IMonitoringMetric; //导入依赖的package包/类
/**
 * Evaluate violations and penalties for a given guarantee term and a list of metrics.
 * 
 * @param agreement that contains the term to evaluate
 * @param term guarantee term to evaluate
 * @param metrics list of metrics to evaluated if fulfill the service level of the term.
 * @param now the evaluation period ends at <code>now</code>.
 */
public GuaranteeTermEvaluationResult evaluate(
		IAgreement agreement, IGuaranteeTerm term, List<IMonitoringMetric> metrics, Date now) {

	/*
	 * throws NullPointerException if not property initialized 
	 */
	checkInitialized();
				
	logger.debug("evaluate(agreement={}, term={}, now={})", 
			agreement.getAgreementId(), term.getKpiName(), now);

	final List<IViolation> violations = serviceLevelEval.evaluate(agreement, term, metrics, now);
	logger.debug("Found " + violations.size() + " violations");
	final List<? extends ICompensation> compensations = businessEval.evaluate(agreement, term, violations, now);
	logger.debug("Found " + compensations.size() + " compensations");
	
	GuaranteeTermEvaluationResult result = new GuaranteeTermEvaluationResult(violations, compensations); 
	
	return result;
}
 
开发者ID:Atos-FiwareOps,项目名称:sla-framework,代码行数:29,代码来源:GuaranteeTermEvaluator.java

示例5: enforce

import eu.atos.sla.monitoring.IMonitoringMetric; //导入依赖的package包/类
/**
 * Enforce an agreement that was last enforced at <code>since</code>. The enforcement process must retrieve
 * the metrics since that date and validate them, raising violations if applicable.
 * 
 * This method is intended to be used when the metric data has to be pulled from the Monitoring.
 * 
 * @param agreement Agreement to enforce.
 * @param since Last time the agreement was enforced.
 * @param isLastExecution the enforcement job has been stopped and it will be the last execution
 */
public void enforce(IAgreement agreement, Date since, boolean isLastExecution) {
	logger.debug("enforce(agreement={},since={})", agreement.getAgreementId(), since);
	
	final Date now = new Date();
	
	checkInitialized(true);

	Map<IGuaranteeTerm, IMetricsRetrieverV2.RetrievalItem> retrievalItems = buildRetrievalItems(agreement, since, now, isLastExecution);

	Map<IGuaranteeTerm, List<IMonitoringMetric>> metricsMap;
	if (retriever instanceof IMetricsRetrieverV2) {
		metricsMap = getMetrics((IMetricsRetrieverV2)retriever, agreement, retrievalItems);
	}
	else {
		metricsMap = getMetrics(retriever, agreement, retrievalItems);
	}
	enforce(agreement, metricsMap);
}
 
开发者ID:Atos-FiwareOps,项目名称:sla-framework,代码行数:29,代码来源:AgreementEnforcement.java

示例6: getMetrics

import eu.atos.sla.monitoring.IMonitoringMetric; //导入依赖的package包/类
private Map<IGuaranteeTerm, List<IMonitoringMetric>> getMetrics(
		IMetricsRetriever retriever, 
		IAgreement agreement, 
		Map<IGuaranteeTerm, IMetricsRetrieverV2.RetrievalItem> retrievalItems) {
	logger.debug("getMetrics");
	
	Map<IGuaranteeTerm, List<IMonitoringMetric>> result = new HashMap<IGuaranteeTerm, List<IMonitoringMetric>>();
	for (IGuaranteeTerm term : agreement.getGuaranteeTerms()) {
		IMetricsRetrieverV2.RetrievalItem item = retrievalItems.get(term);
		if (item!=null){
			List<IMonitoringMetric> metrics = retriever.getMetrics(
					agreement.getAgreementId(), 
					term.getServiceScope(), 
					item.getVariable(),
					item.getBegin(), 
					item.getEnd(),
					maxRetrievedResults);
			
			result.put(term, metrics);
		}
	}
	return result;
}
 
开发者ID:Atos-FiwareOps,项目名称:sla-framework,代码行数:24,代码来源:AgreementEnforcement.java

示例7: enforceReceivedMetrics

import eu.atos.sla.monitoring.IMonitoringMetric; //导入依赖的package包/类
public void enforceReceivedMetrics(
		IAgreement agreement, String guaranteeTermName, List<IMonitoringMetric> metrics) {
	
	logger.debug(
			"enforceReceivedMetrics(agreement=" + agreement.getAgreementId() + ", gt=" + guaranteeTermName + ")");
	Map<IGuaranteeTerm, List<IMonitoringMetric>> metricsMap = 
			new HashMap<IGuaranteeTerm, List<IMonitoringMetric>>();

	for (IGuaranteeTerm gt : agreement.getGuaranteeTerms()) {
		if (guaranteeTermName.equals(gt.getName())) {
			metricsMap.put(gt, metrics);
		}
		else {
			metricsMap.put(gt, Collections.<IMonitoringMetric>emptyList());
		}
	}
	agreementEnforcement.enforce(agreement, metricsMap);
}
 
开发者ID:Atos-FiwareOps,项目名称:sla-framework,代码行数:19,代码来源:EnforcementService.java

示例8: checkMetrics

import eu.atos.sla.monitoring.IMonitoringMetric; //导入依赖的package包/类
public void checkMetrics(Iterable<IMonitoringMetric> iterable, String expectedKey,
		double[] expectedValues, long[] expectedTimes) {
	
	int i = 0;
	for (IMonitoringMetric m : iterable) {
		
		if (m == null) {
			continue;
		}
		assertEquals("metric", m.getMetricKey());
		assertEquals(expectedValues[i], Double.parseDouble(m.getMetricValue()), 0);
		assertEquals(new Date(expectedTimes[i]), m.getDate());
		
		i++;
	}
	
}
 
开发者ID:Atos-FiwareOps,项目名称:sla-framework,代码行数:18,代码来源:SimpleValidatorsIterTest.java

示例9: testSimpleValidatorIter

import eu.atos.sla.monitoring.IMonitoringMetric; //导入依赖的package包/类
@Test
public void testSimpleValidatorIter() {

	Collection<IMonitoringMetric> metrics = generateMetricsCollection(new double[] {
			1, 0, -1, 0, 2, 0, -2, 0, 3, 0, -3, 0
	});
	
	SimpleValidatorIter it = new SimpleValidatorIter(metrics, Operator.GE, new double[] {0});
	
	Iterable<IMonitoringMetric> iterable = it.iterable();
	
	/*
	 * These are the times and values that breaches should have
	 */
	long[] times = new long[] { 2, 6, 10 };
	double[] values = new double[] { -1, -2, -3 };
	
	checkMetrics(iterable, "metric", values, times);
}
 
开发者ID:Atos-FiwareOps,项目名称:sla-framework,代码行数:20,代码来源:SimpleValidatorsIterTest.java

示例10: testSimpleValidatorAverageIter

import eu.atos.sla.monitoring.IMonitoringMetric; //导入依赖的package包/类
@Test
public void testSimpleValidatorAverageIter() {
	
	Collection<IMonitoringMetric> metrics = generateMetricsCollection(new double[] {
			1, 0, -1, 0, 2, 0, -2, 0, 3, 0, -3, 0
	});
	
	SimpleAverageValidatorIter it = new SimpleAverageValidatorIter(metrics, Operator.GT, new double[] {0}, 10);
	
	Iterable<IMonitoringMetric> iterable = it.iterable();
	
	/*
	 * These are the times and values that breaches should have
	 */
	long[] times = new long[] { 11 };
	double[] values = new double[] { 0.0 };
	
	checkMetrics(iterable, "metric", values, times);
}
 
开发者ID:Atos-FiwareOps,项目名称:sla-framework,代码行数:20,代码来源:SimpleValidatorsIterTest.java

示例11: getBreachesByTimeRange

import eu.atos.sla.monitoring.IMonitoringMetric; //导入依赖的package包/类
@Override
public List<IBreach> getBreachesByTimeRange(IAgreement agreement, String kpiName,
		Date begin, Date end) {

	if (metrics == null) {
		return Collections.<IBreach>emptyList();
	}
	
	List<IBreach> result = new ArrayList<IBreach>();
	for (IMonitoringMetric metric : metrics) {
		Date metricDate = metric.getDate();
		String metricValue = metric.getMetricValue();
		if (begin.before(metricDate) && end.after(metricDate) && isBreach(metric)) {
			result.add(newBreach(kpiName, metricValue, metricDate));
		}
	}
	
	return result;
}
 
开发者ID:Atos-FiwareOps,项目名称:sla-framework,代码行数:20,代码来源:DummyBreachRepository.java

示例12: setUpWithPolicies

import eu.atos.sla.monitoring.IMonitoringMetric; //导入依赖的package包/类
/**
 * Common setup for tests with policies (after setUp has run)
 */
private List<IMonitoringMetric> setUpWithPolicies() {
	/*
	 * values is the temporal series of metrics (one per second)
	 * t is the last measure
	 */
	values = new String[] { "102", "99", "99", "99", "101", "100", "99", "99" };
	TestMetricsGenerator metricsGenerator = new TestMetricsGenerator(now, values);
	allMetrics = metricsGenerator.getMetrics(kpiName);
	
	int splitIndex = allMetrics.size() - 3;
	List<IMonitoringMetric> newMetrics = allMetrics.subList(splitIndex, allMetrics.size());
	List<IMonitoringMetric> oldMetrics = allMetrics.subList(0, splitIndex);
	
	breachRepository = new DummyBreachRepository(constraint, oldMetrics);
	evaluator.setBreachRepository(breachRepository);
	
	return newMetrics;
}
 
开发者ID:Atos-FiwareOps,项目名称:sla-framework,代码行数:22,代码来源:PoliciedServiceLevelEvaluatorTest.java

示例13: testEvaluateWithoutPolicy

import eu.atos.sla.monitoring.IMonitoringMetric; //导入依赖的package包/类
@Test
	public void testEvaluateWithoutPolicy() {

		System.out.println("---testEvaluateWithoutPolicy()---");
		String kpiName = "UPTIME";
		values = new String[] { "99", "100", "98", "101" };
		TestMetricsGenerator metricsGenerator = new TestMetricsGenerator(now, values);
		List<IMonitoringMetric> metrics = metricsGenerator.getMetrics(kpiName);
		
		breachRepository = new DummyBreachRepository(constraint);
		evaluator.setBreachRepository(breachRepository);
		evaluator.evaluate(contract, term, metrics, now);
		
		
//		Date lastExecution = new Date(now.getTime() - (values.length + 1) * 1000);
//		IAgreementChecker.ResultItem result = policyChecker.calculateViolations(
//				contract, term, policy.getVariable(), policy, constraint, lastExecution, now);
		
		List<IViolation> violations = evaluator.evaluate(contract, term, metrics, now);
		
		assertEquals(2, violations.size());
		assertViolations(violations, metrics.get(1), metrics.get(3));
		//assertEquals(dates[1], result.getViolations().get(0).getDatetime());
		//assertEquals(dates[3], result.getViolations().get(1).getDatetime());
	}
 
开发者ID:Atos-FiwareOps,项目名称:sla-framework,代码行数:26,代码来源:PoliciedServiceLevelEvaluatorTest.java

示例14: testGetViolationsWithPolicy1

import eu.atos.sla.monitoring.IMonitoringMetric; //导入依赖的package包/类
@Test
public void testGetViolationsWithPolicy1() {
	IPolicy policy;
	System.out.println("---testEvaluateWithPolicy1()---");

	/*
	 * Only t - 2 is breach 
	 */
	List<IMonitoringMetric> metrics = setUpWithPolicies();

	policy = newPolicy("LATENCY", 2, new Date(3000));
	term.setPolicies(Arrays.asList(new IPolicy[] { policy }));

	List<IViolation> violations = evaluator.evaluate(contract, term, metrics, now);

	assertEquals(0, violations.size());
}
 
开发者ID:Atos-FiwareOps,项目名称:sla-framework,代码行数:18,代码来源:PoliciedServiceLevelEvaluatorTest.java

示例15: testGetViolationsWithPolicy2

import eu.atos.sla.monitoring.IMonitoringMetric; //导入依赖的package包/类
@Test
public void testGetViolationsWithPolicy2() {
	IPolicy policy;

	System.out.println("---testEvaluateWithPolicy2()---");
	/*
	 * t-2, t-3 are breaches -> 1 violation
	 */
	List<IMonitoringMetric> metrics = setUpWithPolicies();

	policy = newPolicy("LATENCY", 2, new Date(5000));
	term.setPolicies(Arrays.asList(new IPolicy[] { policy }));

	List<IViolation> violations = evaluator.evaluate(contract, term, metrics, now);

	assertEquals(1, violations.size());
	assertViolations(violations, allMetrics.get(4), allMetrics.get(5));
	
}
 
开发者ID:Atos-FiwareOps,项目名称:sla-framework,代码行数:20,代码来源:PoliciedServiceLevelEvaluatorTest.java


注:本文中的eu.atos.sla.monitoring.IMonitoringMetric类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。