本文整理汇总了Java中com.netflix.hystrix.HystrixCircuitBreaker类的典型用法代码示例。如果您正苦于以下问题:Java HystrixCircuitBreaker类的具体用法?Java HystrixCircuitBreaker怎么用?Java HystrixCircuitBreaker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HystrixCircuitBreaker类属于com.netflix.hystrix包,在下文中一共展示了HystrixCircuitBreaker类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: printHystrixCommandMetrics
import com.netflix.hystrix.HystrixCircuitBreaker; //导入依赖的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
示例2: HystrixCommandInterceptor
import com.netflix.hystrix.HystrixCircuitBreaker; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Inject
public HystrixCommandInterceptor(@ConfigProperty(name = "MP_Fault_Tolerance_NonFallback_Enabled", defaultValue = "true") Boolean nonFallBackEnable, @ConfigProperty(name = SYNC_CIRCUIT_BREAKER_KEY, defaultValue = "true") Boolean syncCircuitBreakerEnabled, BeanManager beanManager) {
this.nonFallBackEnable = nonFallBackEnable;
this.syncCircuitBreakerEnabled = syncCircuitBreakerEnabled;
this.beanManager = beanManager;
this.extension = beanManager.getExtension(HystrixExtension.class);
this.commandMetadataMap = new ConcurrentHashMap<>();
// WORKAROUND: Hystrix does not allow to use custom HystrixCircuitBreaker impl
// See also https://github.com/Netflix/Hystrix/issues/9
try {
Field field = SecurityActions.getDeclaredField(com.netflix.hystrix.HystrixCircuitBreaker.Factory.class, "circuitBreakersByCommand");
SecurityActions.setAccessible(field);
this.circuitBreakers = (ConcurrentHashMap<String, HystrixCircuitBreaker>) field.get(null);
} catch (Exception e) {
throw new IllegalStateException("Could not obtain reference to com.netflix.hystrix.HystrixCircuitBreaker.Factory.circuitBreakersByCommand");
}
}
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:19,代码来源:HystrixCommandInterceptor.java
示例3: testDefaultHystrixCircuitBreakerUsed
import com.netflix.hystrix.HystrixCircuitBreaker; //导入依赖的package包/类
@Test
public void testDefaultHystrixCircuitBreakerUsed() throws InterruptedException {
// Verify Hystrix config first
DynamicLongProperty intervalInMilliseconds = DynamicPropertyFactory.getInstance()
.getLongProperty("hystrix.command.default.metrics.healthSnapshot.intervalInMilliseconds", 500);
assertEquals(intervalInMilliseconds.get(), 10);
// CLOSED
for (int i = 0; i < ShakyServiceClient.REQUEST_THRESHOLD; i++) {
assertInvocation(false);
}
// Should be OPEN now
HystrixCircuitBreaker breaker = HystrixCircuitBreaker.Factory.getInstance(HystrixCommandKey.Factory.asKey(getCommandKey()));
assertNotNull(breaker);
assertFalse(breaker.getClass().getName().contains("org.wildfly.swarm.microprofile.faulttolerance"));
assertTrue(breaker.isOpen());
assertInvocation(true);
TimeUnit.MILLISECONDS.sleep(ShakyServiceClient.DELAY);
// Should be HALF-OPEN
assertInvocation(false);
// OPEN again
assertInvocation(true);
}
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:24,代码来源:SyncCircuitBreakerDisabledTest.java
示例4: HystrixKafkaCircuitBreaker
import com.netflix.hystrix.HystrixCircuitBreaker; //导入依赖的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: doHealthCheck
import com.netflix.hystrix.HystrixCircuitBreaker; //导入依赖的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
示例6: usingHystrix
import com.netflix.hystrix.HystrixCircuitBreaker; //导入依赖的package包/类
public static Optional<CircuitBreaker> usingHystrix(TenacityPropertyKey id) {
final HystrixCircuitBreaker circuitBreaker = TenacityCommand.getCircuitBreaker(id);
if (circuitBreaker == null) {
return Optional.empty();
}
final HystrixCommandProperties commandProperties = TenacityCommand.getCommandProperties(id);
if (commandProperties.circuitBreakerForceOpen().get()) {
return Optional.of(CircuitBreaker.forcedOpen(id));
} else if (commandProperties.circuitBreakerForceClosed().get()) {
return Optional.of(CircuitBreaker.forcedClosed(id));
} else if (circuitBreaker.allowRequest()) {
return Optional.of(CircuitBreaker.closed(id));
} else {
return Optional.of(CircuitBreaker.open(id));
}
}
开发者ID:yammer,项目名称:tenacity,代码行数:20,代码来源:CircuitBreaker.java
示例7: getSynchronousCircuitBreaker
import com.netflix.hystrix.HystrixCircuitBreaker; //导入依赖的package包/类
private SynchronousCircuitBreaker getSynchronousCircuitBreaker(HystrixCommandKey commandKey, CircuitBreakerConfig config) {
HystrixCircuitBreaker circuitBreaker = circuitBreakers.computeIfAbsent(commandKey.name(), (key) -> new SynchronousCircuitBreaker(config));
if (circuitBreaker instanceof SynchronousCircuitBreaker) {
return (SynchronousCircuitBreaker) circuitBreaker;
}
throw new IllegalStateException("Cached circuit breaker does not extend SynchronousCircuitBreaker");
}
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:8,代码来源:HystrixCommandInterceptor.java
示例8: getMetricsPublisherForCommand
import com.netflix.hystrix.HystrixCircuitBreaker; //导入依赖的package包/类
@Override
public HystrixMetricsPublisherCommand getMetricsPublisherForCommand(HystrixCommandKey commandKey,
HystrixCommandGroupKey commandGroupKey,
HystrixCommandMetrics metrics,
HystrixCircuitBreaker circuitBreaker,
HystrixCommandProperties properties) {
return new HystrixAppmon4jMetricsPublisherCommand(commandKey, commandGroupKey, metrics, circuitBreaker, properties,
corePlugin);
}
开发者ID:ImmobilienScout24,项目名称:appmon4j,代码行数:10,代码来源:HystrixAppmon4jMetricsPublisher.java
示例9: HystrixAppmon4jMetricsPublisherCommand
import com.netflix.hystrix.HystrixCircuitBreaker; //导入依赖的package包/类
public HystrixAppmon4jMetricsPublisherCommand(HystrixCommandKey commandKey, HystrixCommandGroupKey commandGroupKey,
HystrixCommandMetrics metrics, HystrixCircuitBreaker circuitBreaker,
HystrixCommandProperties properties, CorePlugin corePlugin) {
this.key = commandKey;
this.commandGroupKey = commandGroupKey;
this.metrics = metrics;
this.circuitBreaker = circuitBreaker;
this.properties = properties;
this.metricGroup = "HystrixCommand";
this.metricType = key.name();
this.corePlugin = corePlugin;
}
开发者ID:ImmobilienScout24,项目名称:appmon4j,代码行数:13,代码来源:HystrixAppmon4jMetricsPublisherCommand.java
示例10: getMetricsPublisherForCommand
import com.netflix.hystrix.HystrixCircuitBreaker; //导入依赖的package包/类
@Override
public HystrixMetricsPublisherCommand getMetricsPublisherForCommand(HystrixCommandKey commandKey,
HystrixCommandGroupKey commandGroupKey,
HystrixCommandMetrics metrics,
HystrixCircuitBreaker circuitBreaker,
HystrixCommandProperties properties) {
return new HystrixCodahaleMetricsPublisherCommand(commandKey, commandGroupKey, metrics, circuitBreaker, properties,
metricRegistry);
}
开发者ID:ImmobilienScout24,项目名称:hystrix-codahale-metrics-publisher,代码行数:10,代码来源:HystrixCodahaleMetricsPublisher.java
示例11: HystrixCodahaleMetricsPublisherCommand
import com.netflix.hystrix.HystrixCircuitBreaker; //导入依赖的package包/类
public HystrixCodahaleMetricsPublisherCommand(HystrixCommandKey commandKey, HystrixCommandGroupKey commandGroupKey,
HystrixCommandMetrics metrics, HystrixCircuitBreaker circuitBreaker,
HystrixCommandProperties properties, MetricRegistry metricRegistry) {
this.key = commandKey;
this.commandGroupKey = commandGroupKey;
this.metrics = metrics;
this.circuitBreaker = circuitBreaker;
this.properties = properties;
this.metricRegistry = metricRegistry;
this.metricGroup = "HystrixCommand";
this.metricType = key.name();
}
开发者ID:ImmobilienScout24,项目名称:hystrix-codahale-metrics-publisher,代码行数:13,代码来源:HystrixCodahaleMetricsPublisherCommand.java
示例12: getMetricsPublisherForCommand
import com.netflix.hystrix.HystrixCircuitBreaker; //导入依赖的package包/类
@Override
public HystrixMetricsPublisherCommand getMetricsPublisherForCommand(HystrixCommandKey commandKey, HystrixCommandGroupKey commandGroupKey, HystrixCommandMetrics metrics, HystrixCircuitBreaker circuitBreaker, HystrixCommandProperties properties) {
return new MicrometerMetricsPublisherCommand(registry, commandKey, commandGroupKey, metrics, circuitBreaker, properties);
}
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:5,代码来源:MicrometerMetricsPublisher.java
注:本文中的com.netflix.hystrix.HystrixCircuitBreaker类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论