本文整理汇总了Java中com.netflix.hystrix.HystrixEventType类的典型用法代码示例。如果您正苦于以下问题:Java HystrixEventType类的具体用法?Java HystrixEventType怎么用?Java HystrixEventType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HystrixEventType类属于com.netflix.hystrix包,在下文中一共展示了HystrixEventType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: commandWithFallbackViaNetworkTest
import com.netflix.hystrix.HystrixEventType; //导入依赖的package包/类
private static void commandWithFallbackViaNetworkTest() {
HystrixRequestContext context = HystrixRequestContext.initializeContext();
try {
log.info(new CommandWithFallbackViaNetwork(1).execute());
HystrixInvokableInfo<?> command1 = HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().toArray(new HystrixInvokableInfo<?>[2])[0];
log.info(command1.getCommandKey().name());
log.info(""+command1.getExecutionEvents().contains(HystrixEventType.FAILURE));
HystrixInvokableInfo<?> command2 = HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().toArray(new HystrixInvokableInfo<?>[2])[1];
log.info(command2.getCommandKey().name());
log.info(""+command2.getExecutionEvents().contains(HystrixEventType.FAILURE));
} finally {
context.shutdown();
}
}
开发者ID:ggj2010,项目名称:javabase,代码行数:17,代码来源:QuickStart.java
示例2: BEC
import com.netflix.hystrix.HystrixEventType; //导入依赖的package包/类
@Ignore("This test interferes with other tests using the BEC (they probably use the same HystrixRequestLog)")
@Test
public void whenSending100Queries_TheyAreSentInBatch() {
List<Observable<QueryResponse>> all = new ArrayList<>();
// Increasing the max delay so eveyrthing goes in a single batch
try (BatchExecutorClient loader = loader(MAX_DELAY * 100)) {
int n = 100;
generate(this::query).limit(n).forEach(q ->
all.add(loader.add(q, keyspace, true))
);
int completed = allObservable(all).toBlocking().first().size();
assertEquals(n, completed);
assertEquals(1, HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().size());
HystrixCommand<?> command = HystrixRequestLog.getCurrentRequest()
.getAllExecutedCommands()
.toArray(new HystrixCommand<?>[1])[0];
// assert the command is the one we're expecting
assertEquals("CommandQueries", command.getCommandKey().name());
// confirm that it was a COLLAPSED command execution
assertTrue(command.getExecutionEvents().contains(HystrixEventType.COLLAPSED));
// and that it was successful
assertTrue(command.getExecutionEvents().contains(HystrixEventType.SUCCESS));
}
}
开发者ID:graknlabs,项目名称:grakn,代码行数:27,代码来源:BatchExecutorClientIT.java
示例3: logEvent
import com.netflix.hystrix.HystrixEventType; //导入依赖的package包/类
private void logEvent(HystrixEventType eventType) {
switch (eventType) {
case FAILURE:
log.info(String.format("Aborted command execution: cause=%s astrixBean=%s hystrixCommandKey=%s", eventType, beanKey, hystrixCommandKey.name()));
break;
case SEMAPHORE_REJECTED:
logSemaphoreRejectedRequest(eventType);
break;
case THREAD_POOL_REJECTED:
logThreadPoolRejectedRequest(eventType);
break;
case TIMEOUT:
logTimeoutRequest(eventType);
break;
case SHORT_CIRCUITED:
log.info(String.format("Aborted command execution: cause=%s astrixBean=%s hystrixCommandKey=%s", eventType, beanKey, hystrixCommandKey.name()));
break;
default:
// Do nothing
}
}
开发者ID:AvanzaBank,项目名称:astrix,代码行数:22,代码来源:FailedServiceInvocationLogger.java
示例4: call
import com.netflix.hystrix.HystrixEventType; //导入依赖的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
示例5: getFallback
import com.netflix.hystrix.HystrixEventType; //导入依赖的package包/类
@Override
protected T getFallback() {
failMeter.mark();
final List<HystrixEventType> events = getExecutionEvents();
if (isFailure(events)) {
final Throwable throwable = getFailedExecutionException();
logger.warn("{}", kvp("command_name", commandName,
"fallback_event", "error",
"time_millis", this.getExecutionTimeInMilliseconds(),
"err", "[" + throwable.getMessage() + "]"
), throwable);
}
if (events.contains(HystrixEventType.TIMEOUT)) {
warn(commandName, HystrixEventType.TIMEOUT.name());
}
if (events.contains(HystrixEventType.SHORT_CIRCUITED)) {
warn(commandName, HystrixEventType.SHORT_CIRCUITED.name());
}
if (events.contains(HystrixEventType.BAD_REQUEST)) {
warn(commandName, HystrixEventType.BAD_REQUEST.name());
}
return fallbackAction.get();
}
开发者ID:dehora,项目名称:outland,代码行数:30,代码来源:RedisCacheCommand.java
示例6: testCollapser
import com.netflix.hystrix.HystrixEventType; //导入依赖的package包/类
/**
* 测试合并请求
* @throws Exception
*/
@Test
public void testCollapser() throws Exception {
HystrixRequestContext context = HystrixRequestContext.initializeContext();
try {
Future<String> f1 = new CommandCollapserGetValueForKey(1).queue();
Future<String> f2 = new CommandCollapserGetValueForKey(2).queue();
Future<String> f3 = new CommandCollapserGetValueForKey(3).queue();
Future<String> f4 = new CommandCollapserGetValueForKey(4).queue();
assertEquals("ValueForKey: 1", f1.get());
assertEquals("ValueForKey: 2", f2.get());
assertEquals("ValueForKey: 3", f3.get());
assertEquals("ValueForKey: 4", f4.get());
// assert that the batch command 'GetValueForKey' was in fact
// executed and that it executed only once
assertEquals(1, HystrixRequestLog.getCurrentRequest().getExecutedCommands().size());
HystrixCommand<?> command = HystrixRequestLog.getCurrentRequest().getExecutedCommands().toArray(new HystrixCommand<?>[1])[0];
// assert the command is the one we're expecting
assertEquals("GetValueForKey", command.getCommandKey().name());
// confirm that it was a COLLAPSED command execution
assertTrue(command.getExecutionEvents().contains(HystrixEventType.COLLAPSED));
// and that it was successful
assertTrue(command.getExecutionEvents().contains(HystrixEventType.SUCCESS));
} finally {
context.shutdown();
}
}
开发者ID:wz12406,项目名称:accumulate,代码行数:33,代码来源:HystrixTest.java
示例7: markCommandExecution
import com.netflix.hystrix.HystrixEventType; //导入依赖的package包/类
@Override
public void markCommandExecution(HystrixCommandKey key, ExecutionIsolationStrategy isolationStrategy, int duration,
List<HystrixEventType> eventsDuringExecution) {
if (MultiConfigId.hasMultiSourceId(key)) {
strategies.get(MultiConfigId.readFrom(key))
.markCommandExecution(MultiConfigId.decode(key), isolationStrategy, duration, eventsDuringExecution);
} else {
defaultStrategy.markCommandExecution(key, isolationStrategy, duration, eventsDuringExecution);
}
}
开发者ID:AvanzaBank,项目名称:astrix,代码行数:11,代码来源:MultiEventNotifierDispatcher.java
示例8: markEvent
import com.netflix.hystrix.HystrixEventType; //导入依赖的package包/类
@Override
public void markEvent(HystrixEventType eventType, HystrixCommandKey key) {
if (MultiConfigId.hasMultiSourceId(key)) {
strategies.get(MultiConfigId.readFrom(key))
.markEvent(eventType, MultiConfigId.decode(key));
} else {
defaultStrategy.markEvent(eventType, key);
}
}
开发者ID:AvanzaBank,项目名称:astrix,代码行数:10,代码来源:MultiEventNotifierDispatcher.java
示例9: markCommandExecution
import com.netflix.hystrix.HystrixEventType; //导入依赖的package包/类
@Override
public void markCommandExecution(HystrixCommandKey key,
ExecutionIsolationStrategy isolationStrategy,
int duration,
List<HystrixEventType> eventsDuringExecution) {
strategymapping.getHystrixStrategies(key)
.getHystrixEventNotifier()
.markCommandExecution(key, isolationStrategy, duration, eventsDuringExecution);
}
开发者ID:AvanzaBank,项目名称:astrix,代码行数:10,代码来源:EventNotifierDispatcher.java
示例10: createNonBeanInvocationCommandLogger
import com.netflix.hystrix.HystrixEventType; //导入依赖的package包/类
private Consumer<HystrixEventType> createNonBeanInvocationCommandLogger(HystrixCommandKey key) {
return eventType -> {
switch (eventType) {
case FAILURE:
case SEMAPHORE_REJECTED:
case THREAD_POOL_REJECTED:
case TIMEOUT:
case SHORT_CIRCUITED:
log.info(String.format("Aborted command execution: cause=%s astrixBean=null hystrixCommandKey=%s", eventType, key.name()));
break;
default:
// Do nothing
}
};
}
开发者ID:AvanzaBank,项目名称:astrix,代码行数:16,代码来源:FailedServiceInvocationLogger.java
示例11: initMetrics
import com.netflix.hystrix.HystrixEventType; //导入依赖的package包/类
private void initMetrics(Ping ping) throws InterruptedException {
// Black hystrix magic here :(
try {
ping.ping("foo");
} catch (Exception e) {
}
HystrixFaultToleranceFactory faultTolerance = (HystrixFaultToleranceFactory) AstrixApplicationContext.class.cast(this.context).getInstance(BeanFaultToleranceFactorySpi.class);
HystrixCommandKey key = faultTolerance.getCommandKey(AstrixBeanKey.create(Ping.class));
HystrixCommandMetrics.getInstance(key).getCumulativeCount(HystrixEventType.SUCCESS);
}
开发者ID:AvanzaBank,项目名称:astrix,代码行数:12,代码来源:HystrixCommandFacadeTest.java
示例12: initMetrics
import com.netflix.hystrix.HystrixEventType; //导入依赖的package包/类
private void initMetrics(Ping ping) throws InterruptedException {
// Black hystrix magic here :(
try {
ping.ping();
} catch (Exception e) {
}
HystrixFaultToleranceFactory faultTolerance = (HystrixFaultToleranceFactory) AstrixApplicationContext.class.cast(this.context).getInstance(BeanFaultToleranceFactorySpi.class);
HystrixCommandKey key = faultTolerance.getCommandKey(AstrixBeanKey.create(Ping.class));
HystrixCommandMetrics.getInstance(key).getCumulativeCount(HystrixEventType.SUCCESS);
}
开发者ID:AvanzaBank,项目名称:astrix,代码行数:12,代码来源:HystrixObservableCommandFacadeTest.java
示例13: initMetrics
import com.netflix.hystrix.HystrixEventType; //导入依赖的package包/类
private void initMetrics(Ping ping, AstrixContext context) {
try {
ping.ping("foo");
} catch (Exception e) {
}
HystrixFaultToleranceFactory faultTolerance = (HystrixFaultToleranceFactory) AstrixApplicationContext.class.cast(context).getInstance(BeanFaultToleranceFactorySpi.class);
HystrixCommandKey key = faultTolerance.getCommandKey(AstrixBeanKey.create(Ping.class));
HystrixCommandMetrics.getInstance(key).getCumulativeCount(HystrixEventType.SUCCESS);
}
开发者ID:AvanzaBank,项目名称:astrix,代码行数:10,代码来源:FaultToleranceMetricsTest.java
示例14: getFallback
import com.netflix.hystrix.HystrixEventType; //导入依赖的package包/类
@Override protected R getFallback() {
failMeter.mark();
final List<HystrixEventType> events = getExecutionEvents();
if (isFailure(events)) {
final Throwable throwable = getFailedExecutionException();
if (throwable instanceof ProvisionedThroughputExceededException) {
// todo: figure out how to handle this via fallbackAction and retries
throughputFailMeter.mark();
logger.error("{}",
kvp("command_name", commandName,
"fallback_event", "ProvisionedThroughputExceededException",
"time_millis", this.getExecutionTimeInMilliseconds(),
"err", "[" + throwable.getMessage() + "]"
),
throwable);
} else {
logger.warn("{}",
kvp("command_name", commandName,
"fallback_event", "error",
"time_millis", this.getExecutionTimeInMilliseconds(),
"err", "[" + throwable.getMessage() + "]"
),
throwable);
}
}
if (events.contains(HystrixEventType.TIMEOUT)) {
warn(commandName, HystrixEventType.TIMEOUT.name());
}
if (events.contains(HystrixEventType.SHORT_CIRCUITED)) {
warn(commandName, HystrixEventType.SHORT_CIRCUITED.name());
}
if (events.contains(HystrixEventType.BAD_REQUEST)) {
warn(commandName, HystrixEventType.BAD_REQUEST.name());
}
return fallbackAction.get();
}
开发者ID:dehora,项目名称:outland,代码行数:45,代码来源:DynamoDbCommand.java
示例15: isFailure
import com.netflix.hystrix.HystrixEventType; //导入依赖的package包/类
private boolean isFailure(List<HystrixEventType> eventTypes) {
return eventTypes.contains(HystrixEventType.EXCEPTION_THROWN)
|| eventTypes.contains(HystrixEventType.FAILURE);
}
开发者ID:dehora,项目名称:outland,代码行数:5,代码来源:DynamoDbCommand.java
示例16: markSuccessfully
import com.netflix.hystrix.HystrixEventType; //导入依赖的package包/类
public void markSuccessfully() {
concurrentExecutionCount.decrementAndGet();
HystrixThreadEventStream.getInstance()
.executionDone(ExecutionResult.from(HystrixEventType.SUCCESS), commandKey, threadPoolKey);
circuitBreaker.markSuccess();
}
开发者ID:zalando,项目名称:nakadi,代码行数:7,代码来源:HystrixKafkaCircuitBreaker.java
示例17: markFailure
import com.netflix.hystrix.HystrixEventType; //导入依赖的package包/类
public void markFailure() {
concurrentExecutionCount.decrementAndGet();
HystrixThreadEventStream.getInstance()
.executionDone(ExecutionResult.from(HystrixEventType.FAILURE), commandKey, threadPoolKey);
}
开发者ID:zalando,项目名称:nakadi,代码行数:6,代码来源:HystrixKafkaCircuitBreaker.java
示例18: markEvent
import com.netflix.hystrix.HystrixEventType; //导入依赖的package包/类
@Override
public void markEvent(HystrixEventType eventType, HystrixCommandKey key) {
strategymapping.getHystrixStrategies(key)
.getHystrixEventNotifier()
.markEvent(eventType, key);
}
开发者ID:AvanzaBank,项目名称:astrix,代码行数:7,代码来源:EventNotifierDispatcher.java
示例19: markEvent
import com.netflix.hystrix.HystrixEventType; //导入依赖的package包/类
@Override
public void markEvent(HystrixEventType eventType, HystrixCommandKey key) {
logEvent(eventType, key);
}
开发者ID:AvanzaBank,项目名称:astrix,代码行数:5,代码来源:FailedServiceInvocationLogger.java
示例20: getBeanInvocationLogger
import com.netflix.hystrix.HystrixEventType; //导入依赖的package包/类
private Optional<Consumer<HystrixEventType>> getBeanInvocationLogger(HystrixCommandKey commandKey) {
return beanMapping.getBeanKey(commandKey)
.map(beanKey -> getOrCreateBeanInvocationLogger(commandKey, beanKey));
}
开发者ID:AvanzaBank,项目名称:astrix,代码行数:5,代码来源:FailedServiceInvocationLogger.java
注:本文中的com.netflix.hystrix.HystrixEventType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论