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


Java HystrixCommandMetrics.getInstance方法代码示例

本文整理汇总了Java中com.netflix.hystrix.HystrixCommandMetrics.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java HystrixCommandMetrics.getInstance方法的具体用法?Java HystrixCommandMetrics.getInstance怎么用?Java HystrixCommandMetrics.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.netflix.hystrix.HystrixCommandMetrics的用法示例。


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

示例1: HystrixKafkaCircuitBreaker

import com.netflix.hystrix.HystrixCommandMetrics; //导入方法依赖的package包/类
public HystrixKafkaCircuitBreaker(final String brokerId) {
    commandKey = HystrixCommandKey.Factory.asKey(brokerId);
    commandProperties = HystrixPropertiesFactory.getCommandProperties(commandKey, null);
    threadPoolKey = HystrixThreadPoolKey.Factory.asKey(brokerId);
    hystrixCommandMetrics = HystrixCommandMetrics.getInstance(
            commandKey,
            HYSTRIX_CMD_GROUP_KEY,
            threadPoolKey,
            commandProperties);
    circuitBreaker = HystrixCircuitBreaker.Factory.getInstance(
            commandKey,
            HYSTRIX_CMD_GROUP_KEY,
            commandProperties,
            hystrixCommandMetrics);
    concurrentExecutionCount = new AtomicInteger();
}
 
开发者ID:zalando,项目名称:nakadi,代码行数:17,代码来源:HystrixKafkaCircuitBreaker.java

示例2: printMetrics

import com.netflix.hystrix.HystrixCommandMetrics; //导入方法依赖的package包/类
private void printMetrics() {
    HystrixCommandMetrics metrics =
            HystrixCommandMetrics.
                    getInstance(HystrixCommandKey.Factory.asKey(this.getClass().getSimpleName()));
    StringBuilder m = new StringBuilder();
    if (metrics != null) {
        HystrixCommandMetrics.HealthCounts health = metrics.getHealthCounts();
        m.append("Requests: ").append(health.getTotalRequests()).append(" ");
        m.append("Errors: ").append(health.getErrorCount()).append(" (").
                append(health.getErrorPercentage()).append("%)   ");
        m.append("Mean: ").append(metrics.getExecutionTimePercentile(50)).append(" ");
        m.append("75th: ").append(metrics.getExecutionTimePercentile(75)).append(" ");
        m.append("90th: ").append(metrics.getExecutionTimePercentile(90)).append(" ");
        m.append("99th: ").append(metrics.getExecutionTimePercentile(99)).append(" ");
    }
    System.out.println(m);
}
 
开发者ID:wso2,项目名称:msf4j,代码行数:18,代码来源:CircuitBreakerCommand.java

示例3: getHystrixTotalTimeMean

import com.netflix.hystrix.HystrixCommandMetrics; //导入方法依赖的package包/类
@ManagedAttribute
public int getHystrixTotalTimeMean() {
    HystrixCommandMetrics metrics = HystrixCommandMetrics.getInstance(commandKey);
    if (metrics != null) {
        return metrics.getTotalTimeMean();
    }
    return 0;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:HystrixProcessor.java

示例4: getHystrixExecutionTimeMean

import com.netflix.hystrix.HystrixCommandMetrics; //导入方法依赖的package包/类
@ManagedAttribute
public int getHystrixExecutionTimeMean() {
    HystrixCommandMetrics metrics = HystrixCommandMetrics.getInstance(commandKey);
    if (metrics != null) {
        return metrics.getExecutionTimeMean();
    }
    return 0;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:HystrixProcessor.java

示例5: getHystrixCurrentConcurrentExecutionCount

import com.netflix.hystrix.HystrixCommandMetrics; //导入方法依赖的package包/类
@ManagedAttribute
public int getHystrixCurrentConcurrentExecutionCount() {
    HystrixCommandMetrics metrics = HystrixCommandMetrics.getInstance(commandKey);
    if (metrics != null) {
        return metrics.getCurrentConcurrentExecutionCount();
    }
    return 0;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:HystrixProcessor.java

示例6: getHystrixTotalRequests

import com.netflix.hystrix.HystrixCommandMetrics; //导入方法依赖的package包/类
@ManagedAttribute
public long getHystrixTotalRequests() {
    HystrixCommandMetrics metrics = HystrixCommandMetrics.getInstance(commandKey);
    if (metrics != null) {
        return metrics.getHealthCounts().getTotalRequests();
    }
    return 0;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:HystrixProcessor.java

示例7: getHystrixErrorCount

import com.netflix.hystrix.HystrixCommandMetrics; //导入方法依赖的package包/类
@ManagedAttribute
public long getHystrixErrorCount() {
    HystrixCommandMetrics metrics = HystrixCommandMetrics.getInstance(commandKey);
    if (metrics != null) {
        return metrics.getHealthCounts().getErrorCount();
    }
    return 0;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:HystrixProcessor.java

示例8: getHystrixErrorPercentage

import com.netflix.hystrix.HystrixCommandMetrics; //导入方法依赖的package包/类
@ManagedAttribute
public int getHystrixErrorPercentage() {
    HystrixCommandMetrics metrics = HystrixCommandMetrics.getInstance(commandKey);
    if (metrics != null) {
        return metrics.getHealthCounts().getErrorPercentage();
    }
    return 0;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:HystrixProcessor.java

示例9: something

import com.netflix.hystrix.HystrixCommandMetrics; //导入方法依赖的package包/类
@Scheduled(fixedRate = 1000)
public void something() {
    final HystrixCommandMetrics metrics = HystrixCommandMetrics.getInstance(HystrixCommandKey.Factory.asKey("request"));

    if (metrics != null) { // metrics will be null until command is first used
        LOGGER.info("command [{}]: execTime [{}] errors [{}]/[{}]", metrics.getCommandKey().name(),
                metrics.getExecutionTimeMean(),
                metrics.getHealthCounts().getErrorCount(),
                metrics.getHealthCounts().getTotalRequests());
    }
}
 
开发者ID:ericdahl,项目名称:hello-hystrix,代码行数:12,代码来源:MetricLogger.java

示例10: getEventCountForCommand

import com.netflix.hystrix.HystrixCommandMetrics; //导入方法依赖的package包/类
private int getEventCountForCommand(HystrixRollingNumberEvent hystrixRollingNumberEvent) {
	HystrixFaultToleranceFactory faultTolerance = (HystrixFaultToleranceFactory) AstrixApplicationContext.class.cast(this.context).getInstance(BeanFaultToleranceFactorySpi.class);
	HystrixCommandKey commandKey = faultTolerance.getCommandKey(AstrixBeanKey.create(Ping.class));
	HystrixCommandMetrics metrics = HystrixCommandMetrics.getInstance(commandKey);
	int currentConcurrentExecutionCount = (int) metrics.getCumulativeCount(hystrixRollingNumberEvent);
	return currentConcurrentExecutionCount;
}
 
开发者ID:AvanzaBank,项目名称:astrix,代码行数:8,代码来源:HystrixCommandFacadeTest.java

示例11: getEventCountForCommand

import com.netflix.hystrix.HystrixCommandMetrics; //导入方法依赖的package包/类
private int getEventCountForCommand(HystrixRollingNumberEvent hystrixRollingNumberEvent, HystrixCommandKey commandKey) {
	HystrixCommandMetrics metrics = HystrixCommandMetrics.getInstance(commandKey);
	if (metrics == null) {
		return 0;
	}
	int currentConcurrentExecutionCount = (int) metrics.getCumulativeCount(hystrixRollingNumberEvent);
	return currentConcurrentExecutionCount;
}
 
开发者ID:AvanzaBank,项目名称:astrix,代码行数:9,代码来源:HystrixFaulttoleranceIntegrationTest.java

示例12: should_gather_json_metrics

import com.netflix.hystrix.HystrixCommandMetrics; //导入方法依赖的package包/类
@Test
public void should_gather_json_metrics() throws Exception {
	HystrixCommandKey hystrixCommandKey = HystrixCommandKey.Factory.asKey("commandKey");
	HystrixCommandMetrics.getInstance(hystrixCommandKey,
			HystrixCommandGroupKey.Factory.asKey("commandGroupKey"),
			new HystrixPropertiesCommandDefault(hystrixCommandKey, HystrixCommandProperties.defaultSetter()));

	this.hystrixStreamTask.setApplicationContext(this.context);
	this.hystrixStreamTask.gatherMetrics();

	assertThat(this.hystrixStreamTask.jsonMetrics.isEmpty(), is(false));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:13,代码来源:HystrixStreamTaskTests.java

示例13: doCheck

import com.netflix.hystrix.HystrixCommandMetrics; //导入方法依赖的package包/类
@Override
public HealthCheckResult doCheck()
{
   //
   // Lookup the command group using the provided key. These may be null if
   // no ApiCommands have been created and executed so no need to panic.
   //

   try
   {
      HystrixCommandKey cmdKey = HystrixCommandKey.Factory.asKey(key);

      if (cmdKey == null)
      {
         return new HealthCheckResult(Status.HEALTHY);
      }

      HystrixCommandMetrics metrics = HystrixCommandMetrics.getInstance(cmdKey);

      if (metrics == null)
      {
         return new HealthCheckResult(Status.HEALTHY);
      }

      //
      // As this point we should have viable metrics.
      //

      int windowSize = metrics.getProperties().metricsRollingStatisticalWindowInMilliseconds().get() / 1000;

      long failCount = metrics.getRollingCount(HystrixRollingNumberEvent.FAILURE);

      if (failCount >= minNumFailures)
      {
         return new HealthCheckResult(Status.UNHEALTHY, "Command has " + failCount + " failures in last " + windowSize + " seconds");
      }
      else
      {
         return new HealthCheckResult(Status.HEALTHY);
      }
   }
   catch (Exception e)
   {
      return new HealthCheckResult(Status.UNKNOWN, "Could not get Hystrix metrics for command key " + key + ": " + e.getMessage());
   }
}
 
开发者ID:HomeAdvisor,项目名称:Robusto,代码行数:47,代码来源:HystrixHealthCheck.java


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