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


Java HystrixCommandMetrics类代码示例

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


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

示例1: checkNotifierIsCalledOnceForEveryCommand

import com.netflix.hystrix.HystrixCommandMetrics; //导入依赖的package包/类
@Test
public void checkNotifierIsCalledOnceForEveryCommand() {
    mocks.forEach(m -> doAnswer(a -> {
        HystrixCommandMetrics metrics = a.getArgument(0);
        log.info("initialize for command {} and group {}", metrics.getCommandKey().name(), metrics.getCommandGroup().name());
                return null;
            }).when(m).initialize(any())
    );

    HystrixPlugins.getInstance().registerMetricsPublisher(notifier);

    for (int i = 0; i < 3; i++) {
        Command.from(GROUP_KEY, COMMAND_1, SUCCESS, 50).observe();
    }

    for (int i = 0; i < 5; i++) {
        Command.from(GROUP_KEY, COMMAND_2, FAILURE, 60).observe();
    }

    mocks.forEach(m -> {
        verify(m, times(1)).initialize(withKey(COMMAND_1));
        verify(m, times(1)).initialize(withKey(COMMAND_2));
        verifyNoMoreInteractions(m);
    });
}
 
开发者ID:ringcentral,项目名称:hystrix-addons,代码行数:26,代码来源:HystrixMetricsInitializationNotifierTest.java

示例2: printHystrixCommandMetrics

import com.netflix.hystrix.HystrixCommandMetrics; //导入依赖的package包/类
public void printHystrixCommandMetrics() {
    for (HystrixCommandMetrics metrics : HystrixCommandMetrics.getInstances()) {
        boolean isCircuitOpen = HystrixCircuitBreaker.Factory.getInstance(metrics.getCommandKey()).isOpen();

        LOGGER.info("group:{}, commandKey:{}, CircuitOpen:{}, Mean:{}, 95%:{}, 99%:{}, 99.5%:{}, {}",
                metrics.getCommandGroup().name(),
                metrics.getCommandKey().name(),
                isCircuitOpen,
                metrics.getExecutionTimeMean(),
                metrics.getExecutionTimePercentile(95.0),
                metrics.getExecutionTimePercentile(99.5),
                metrics.getExecutionTimePercentile(99.5),
                metrics.getHealthCounts()
        );
    }
}
 
开发者ID:Nike-Inc,项目名称:cerberus-management-service,代码行数:17,代码来源:HystrixMetricsLogger.java

示例3: commandStats

import com.netflix.hystrix.HystrixCommandMetrics; //导入依赖的package包/类
@RequestMapping(value = "/commands", method = RequestMethod.GET)
public List<HystrixCommandStats> commandStats() {
    return HystrixCommandMetrics.getInstances().stream().map((m) -> {
        final HystrixCommandStats s = new HystrixCommandStats();
        s.currentConcurrentExecutionCount = m.getCurrentConcurrentExecutionCount();
        s.commandGroup = m.getCommandGroup().name();
        s.commandKey = m.getCommandKey().name();
        s.executionTimeMean = m.getExecutionTimeMean();
        s.errorCount = m.getHealthCounts().getErrorCount();
        s.totalCount = m.getHealthCounts().getTotalRequests();
        s.errorPercentage = m.getHealthCounts().getErrorPercentage();
        s.totalTimeMean = m.getTotalTimeMean();

        return s;
    }).collect(Collectors.toList());
}
 
开发者ID:nielsutrecht,项目名称:example-loadbalancer,代码行数:17,代码来源:StatusController.java

示例4: 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

示例5: printMetrics

import com.netflix.hystrix.HystrixCommandMetrics; //导入依赖的package包/类
private static void printMetrics() {
   for (HystrixCommandMetrics metric : HystrixCommandMetrics.getInstances()) {
      System.out.println("Metric: " + metric.getCommandGroup().name());
      System.out.println("execution-time-mean: " + metric.getExecutionTimeMean());
      System.out.println("total-time-mean: " + metric.getTotalTimeMean());
      System.out.println("total-count: " + metric.getHealthCounts().getTotalRequests());
      System.out.println("error-count: " + metric.getHealthCounts().getErrorCount());
      System.out.println("error-%: " + metric.getHealthCounts().getErrorPercentage());
   }

   for (HystrixThreadPoolMetrics metrics : HystrixThreadPoolMetrics.getInstances()) {
      System.out.println("cumulative-count-threads-executed: " + metrics.getCumulativeCountThreadsExecuted());
      System.out.println("current-active-count: " + metrics.getCurrentActiveCount());
      System.out.println("current-completed-task-count: " + metrics.getCurrentCompletedTaskCount());
      System.out.println("current-core-pool-size: " + metrics.getCurrentCorePoolSize());
      System.out.println("current-largest-pool-size: " + metrics.getCurrentLargestPoolSize());
      System.out.println("current-max-pool-size: " + metrics.getCurrentMaximumPoolSize());
      System.out.println("current-pool-size: " + metrics.getCurrentPoolSize());
      System.out.println("current-queue-size: " + metrics.getCurrentQueueSize());
      System.out.println("current-task-count: " + metrics.getCurrentTaskCount());
      System.out.println("rolling-count-threads-executed: " + metrics.getRollingCountThreadsExecuted());
      System.out.println("rolling-max-active-threads: " + metrics.getRollingMaxActiveThreads());
   }
}
 
开发者ID:eivindw,项目名称:akka-hystrix,代码行数:25,代码来源:TestApp.java

示例6: 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

示例7: doHealthCheck

import com.netflix.hystrix.HystrixCommandMetrics; //导入依赖的package包/类
@Override
protected void doHealthCheck(Builder builder) throws Exception {
	List<String> openCircuitBreakers = new ArrayList<>();

	// Collect all open circuit breakers from Hystrix
	for (HystrixCommandMetrics metrics : HystrixCommandMetrics.getInstances()) {
		HystrixCircuitBreaker circuitBreaker = HystrixCircuitBreaker.Factory
				.getInstance(metrics.getCommandKey());
		if (circuitBreaker != null && circuitBreaker.isOpen()) {
			openCircuitBreakers.add(metrics.getCommandGroup().name() + "::"
					+ metrics.getCommandKey().name());
		}
	}

	// If there is at least one open circuit report OUT_OF_SERVICE adding the command
	// group
	// and key name
	if (!openCircuitBreakers.isEmpty()) {
		builder.status(CIRCUIT_OPEN).withDetail("openCircuitBreakers",
				openCircuitBreakers);
	}
	else {
		builder.up();
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:26,代码来源:HystrixHealthIndicator.java

示例8: call

import com.netflix.hystrix.HystrixCommandMetrics; //导入依赖的package包/类
@Override
public String call() {
  List<TpsAndLatencyData> tpsAndLatencyData = HystrixCommandMetrics.getInstances()
      .stream()
      .map(instance -> new TpsAndLatencyData(instance.getRollingCount(HystrixEventType.SUCCESS),
          instance.getRollingCount(HystrixEventType.FAILURE), instance.getExecutionTimeMean(),
          instance.getProperties().metricsRollingStatisticalWindowInMilliseconds().get()))
      .collect(Collectors.toList());
  return calculateTpsAndLatency(tpsAndLatencyData);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:11,代码来源:MetricsServoRegistry.java

示例9: initialize

import com.netflix.hystrix.HystrixCommandMetrics; //导入依赖的package包/类
@Override
public void initialize(HystrixCommandMetrics metrics) {
    if (filter.test(metrics)) {
        final HystrixCommandKey key = metrics.getCommandKey();
        log.debug("Aggregate stream for command {}", key.name());
        streams.onNext(HystrixCommandCompletionStream.getInstance(key).observe());
    }
}
 
开发者ID:ringcentral,项目名称:hystrix-addons,代码行数:9,代码来源:AggregatedHystrixCommandCompletionStream.java

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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