@Override public String toString() { return "HystrixCommandCompletionStream(" + commandKey.name() + ")"; } }
@Override public String toString() { return "HystrixCommandStartStream(" + commandKey.name() + ")"; } }
private RequestCacheKey(HystrixCommandKey commandKey, HystrixConcurrencyStrategy concurrencyStrategy) { type = 1; if (commandKey == null) { this.key = null; } else { this.key = commandKey.name(); } this.concurrencyStrategy = concurrencyStrategy; }
private ExecutionSignature(HystrixCommandKey commandKey, ExecutionResult.EventCounts eventCounts, String cacheKey, int cachedCount, HystrixCollapserKey collapserKey, int collapserBatchSize) { this.commandName = commandKey.name(); this.eventCounts = eventCounts; this.cacheKey = cacheKey; this.cachedCount = cachedCount; this.collapserKey = collapserKey; this.collapserBatchSize = collapserBatchSize; }
/** * Get the {@link HystrixCommandMetrics} instance for a given {@link HystrixCommandKey} or null if one does not exist. * * @param key * {@link HystrixCommandKey} of {@link HystrixCommand} instance requesting the {@link HystrixCommandMetrics} * @return {@link HystrixCommandMetrics} */ public static HystrixCommandMetrics getInstance(HystrixCommandKey key) { return metrics.get(key.name()); }
/** * Get the {@link HystrixCircuitBreaker} instance for a given {@link HystrixCommandKey} or null if none exists. * * @param key * {@link HystrixCommandKey} of {@link HystrixCommand} instance requesting the {@link HystrixCircuitBreaker} * @return {@link HystrixCircuitBreaker} for {@link HystrixCommandKey} */ public static HystrixCircuitBreaker getInstance(HystrixCommandKey key) { return circuitBreakersByCommand.get(key.name()); }
public static void removeByKey(HystrixCommandKey key) { streams.remove(key.name()); }
public static RollingCommandUserLatencyDistributionStream getInstance(HystrixCommandKey commandKey, int numBuckets, int bucketSizeInMs) { RollingCommandUserLatencyDistributionStream initialStream = streams.get(commandKey.name()); if (initialStream != null) { return initialStream; } else { synchronized (RollingCommandUserLatencyDistributionStream.class) { RollingCommandUserLatencyDistributionStream existingStream = streams.get(commandKey.name()); if (existingStream == null) { RollingCommandUserLatencyDistributionStream newStream = new RollingCommandUserLatencyDistributionStream(commandKey, numBuckets, bucketSizeInMs); streams.putIfAbsent(commandKey.name(), newStream); return newStream; } else { return existingStream; } } } }
public static HystrixCommandStartStream getInstance(HystrixCommandKey commandKey) { HystrixCommandStartStream initialStream = streams.get(commandKey.name()); if (initialStream != null) { return initialStream; } else { synchronized (HystrixCommandStartStream.class) { HystrixCommandStartStream existingStream = streams.get(commandKey.name()); if (existingStream == null) { HystrixCommandStartStream newStream = new HystrixCommandStartStream(commandKey); streams.putIfAbsent(commandKey.name(), newStream); return newStream; } else { return existingStream; } } } }
public HystrixCodaHaleMetricsPublisherCommand(String metricsRootNode, HystrixCommandKey commandKey, HystrixCommandGroupKey commandGroupKey, HystrixCommandMetrics metrics, HystrixCircuitBreaker circuitBreaker, HystrixCommandProperties properties, MetricRegistry metricRegistry) { this.metricsRootNode = metricsRootNode; this.key = commandKey; this.commandGroupKey = commandGroupKey; this.metrics = metrics; this.circuitBreaker = circuitBreaker; this.properties = properties; this.metricRegistry = metricRegistry; this.metricGroup = commandGroupKey.name(); this.metricType = key.name(); }
/** * {@inheritDoc} */ @Override public String getActionName() { if (hystrixCommand != null && hystrixCommand instanceof HystrixInvokableInfo) { HystrixInvokableInfo info = (HystrixInvokableInfo) hystrixCommand; return info.getCommandKey().name(); } return ""; }
protected String getLogMessagePrefix() { return getCommandKey().name(); }
private static HystrixCommandKey initCommandKey(final HystrixCommandKey fromConstructor, Class<?> clazz) { if (fromConstructor == null || fromConstructor.name().trim().equals("")) { final String keyName = getDefaultNameFromClass(clazz); return HystrixCommandKey.Factory.asKey(keyName); } else { return fromConstructor; } }
/** * {@inheritDoc} */ @Override protected Object run() throws Exception { LOGGER.debug("execute command: {}", getCommandKey().name()); return process(new Action() { @Override Object execute() { return getCommandAction().execute(getExecutionType()); } }); }
@Nullable @Override public String apply(@Nullable HystrixInvokableInfo<?> input) { return input.getCommandKey().name(); } });
@SuppressWarnings("unused") private static HystrixProperty<String> getProperty(String propertyPrefix, HystrixCommandKey key, String instanceProperty, String builderOverrideValue, String defaultValue) { return forString() .add(propertyPrefix + ".command." + key.name() + "." + instanceProperty, builderOverrideValue) .add(propertyPrefix + ".command.default." + instanceProperty, defaultValue) .build(); }
private static HystrixProperty<Boolean> getProperty(String propertyPrefix, HystrixCommandKey key, String instanceProperty, Boolean builderOverrideValue, Boolean defaultValue) { return forBoolean() .add(propertyPrefix + ".command." + key.name() + "." + instanceProperty, builderOverrideValue) .add(propertyPrefix + ".command.default." + instanceProperty, defaultValue) .build(); }
private static HystrixProperty<Integer> getProperty(String propertyPrefix, HystrixCommandKey key, String instanceProperty, Integer builderOverrideValue, Integer defaultValue) { return forInteger() .add(propertyPrefix + ".command." + key.name() + "." + instanceProperty, builderOverrideValue) .add(propertyPrefix + ".command.default." + instanceProperty, defaultValue) .build(); }
public static HystrixInvokableInfo getHystrixCommandByKey(String key) { HystrixInvokableInfo hystrixCommand = null; Collection<HystrixInvokableInfo<?>> executedCommands = HystrixRequestLog.getCurrentRequest().getAllExecutedCommands(); for (HystrixInvokableInfo command : executedCommands) { if (command.getCommandKey().name().equals(key)) { hystrixCommand = command; break; } } return hystrixCommand; }
@Override protected Boolean run() { assertEquals("SemaphoreIsolatedCommandName", Hystrix.getCurrentThreadExecutingCommand().name()); System.out.println("Semaphore Thread : " + Thread.currentThread().getName()); //should be a single execution on the caller thread (since it's busy here) assertEquals(1, Hystrix.getCommandCount()); return Hystrix.getCurrentThreadExecutingCommand() != null; }