io.github.resilience4j.bulkhead.Bulkhead.getName()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(134)

本文整理了Java中io.github.resilience4j.bulkhead.Bulkhead.getName()方法的一些代码示例,展示了Bulkhead.getName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bulkhead.getName()方法的具体详情如下:
包路径:io.github.resilience4j.bulkhead.Bulkhead
类名称:Bulkhead
方法名:getName

Bulkhead.getName介绍

[英]Returns the name of this bulkhead.
[中]返回此隔板的名称。

代码示例

代码示例来源:origin: resilience4j/resilience4j

@Override
protected Throwable getThrowable() {
  return new BulkheadFullException(String.format("Bulkhead '%s' is full", bulkhead.getName()));
}

代码示例来源:origin: resilience4j/resilience4j

private BulkheadMetrics(String prefix, Iterable<Bulkhead> bulkheads) {
  requireNonNull(prefix);
  requireNonNull(bulkheads);
  bulkheads.forEach(bulkhead -> {
        String name = bulkhead.getName();
    //number of available concurrent calls as an integer
        metricRegistry.register(name(prefix, name, AVAILABLE_CONCURRENT_CALLS),
            (Gauge<Integer>) () -> bulkhead.getMetrics().getAvailableConcurrentCalls());
      }
  );
}

代码示例来源:origin: resilience4j/resilience4j

private Exception bulkheadFullException() {
  return new BulkheadFullException(String.format("Bulkhead '%s' is full", bulkhead.getName()));
}

代码示例来源:origin: resilience4j/resilience4j

public static void isCallPermitted(Bulkhead bulkhead) {
    if(!bulkhead.isCallPermitted()) {
      throw new BulkheadFullException(String.format("Bulkhead '%s' is full", bulkhead.getName()));
    }
  }
}

代码示例来源:origin: resilience4j/resilience4j

@Override
public void onSubscribe(Subscription subscription) {
  if (SubscriptionHelper.setOnce(this, subscription)) {
    if (acquireCallPermit()) {
      childSubscriber.onSubscribe(this);
    } else {
      cancel();
      childSubscriber.onSubscribe(this);
      childSubscriber.onError(new BulkheadFullException(String.format("Bulkhead '%s' is full", bulkhead.getName())));
    }
  }
}

代码示例来源:origin: resilience4j/resilience4j

/**
   * {@inheritDoc}
   */
  @Override
  public List<MetricFamilySamples> collect() {
    final GaugeMetricFamily stats = new GaugeMetricFamily(
        name,
        "Bulkhead Stats",
        asList("name", "param"));

    for (Bulkhead bulkhead : bulkheadsSupplier.get()) {

      final Bulkhead.Metrics metrics = bulkhead.getMetrics();

      stats.addMetric(
          asList(bulkhead.getName(), "available_concurrent_calls"),
          metrics.getAvailableConcurrentCalls());
    }

    return singletonList(stats);
  }
}

代码示例来源:origin: resilience4j/resilience4j

private Object handleOther(MethodInvocation invocation, io.github.resilience4j.bulkhead.Bulkhead bulkhead, RecoveryFunction<?> recoveryFunction) throws Throwable {
    boolean permission = bulkhead.isCallPermitted();

    if (!permission) {
      Throwable t = new BulkheadFullException(String.format("Bulkhead '%s' is full", bulkhead.getName()));
      return recoveryFunction.apply(t);
    }

    try {
      if (Thread.interrupted()) {
        throw new IllegalStateException("Thread was interrupted during permission wait");
      }

      return invocation.proceed();
    } catch (Exception e) {
      return recoveryFunction.apply(e);
    } finally {
      bulkhead.onComplete();
    }
  }
}

代码示例来源:origin: resilience4j/resilience4j

@Test
public void shouldReturnTheCorrectName() {
  assertThat(bulkhead.getName()).isEqualTo("test");
}

代码示例来源:origin: resilience4j/resilience4j

promise.completeExceptionally(new BulkheadFullException(String.format("Bulkhead '%s' is open", bulkhead.getName())));

代码示例来源:origin: resilience4j/resilience4j

Throwable t = new BulkheadFullException(String.format("Bulkhead '%s' is full", bulkhead.getName()));
handleRecovery(down, t);

代码示例来源:origin: resilience4j/resilience4j

@Override
  public void bindTo(MeterRegistry registry) {
    for (Bulkhead bulkhead : bulkheads) {
      final String name = bulkhead.getName();
      Gauge.builder(getName(prefix, name, AVAILABLE_CONCURRENT_CALLS), bulkhead, (cb) -> cb.getMetrics().getAvailableConcurrentCalls())
          .register(registry);
    }
  }
}

代码示例来源:origin: resilience4j/resilience4j

} else {
  final CompletableFuture promise = new CompletableFuture<>();
  Throwable t = new BulkheadFullException(String.format("Bulkhead '%s' is full", bulkhead.getName()));
  try {
    promise.complete(recoveryFunction.apply(t));

代码示例来源:origin: resilience4j/resilience4j

@Test
public void shouldReturnTheCorrectName() {
  Bulkhead bulkhead = registry.bulkhead("test");
  assertThat(bulkhead).isNotNull();
  assertThat(bulkhead.getName()).isEqualTo("test");
  assertThat(bulkhead.getBulkheadConfig().getMaxConcurrentCalls()).isEqualTo(25);
  assertThat(bulkhead.getMetrics().getAvailableConcurrentCalls()).isEqualTo(25);
}

代码示例来源:origin: resilience4j/resilience4j

chain1.get("stream/events/:name", ctx -> {
  String bulkheadName = ctx.getPathTokens().get("name");
  Bulkhead bulkhead = bulkheadRegistry.getAllBulkheads().find(b -> b.getName().equals(bulkheadName))
      .getOrElseThrow(() -> new IllegalArgumentException(String.format("bulkhead with name %s not found", bulkheadName)));
  Function<BulkheadEvent, String> data = b -> Jackson.getObjectWriter(chain1.getRegistry()).writeValueAsString(BulkheadEventDTO.createEventDTO(b));
  String bulkheadName = ctx.getPathTokens().get("name");
  String eventType = ctx.getPathTokens().get("type");
  Bulkhead bulkhead = bulkheadRegistry.getAllBulkheads().find(b -> b.getName().equals(bulkheadName))
      .getOrElseThrow(() -> new IllegalArgumentException(String.format("bulkhead with name %s not found", bulkheadName)));
  Flux<BulkheadEvent> eventStream = ReactorAdapter.toFlux(bulkhead.getEventPublisher())

代码示例来源:origin: io.github.resilience4j/resilience4j-rxjava2

private Exception bulkheadFullException() {
  return new BulkheadFullException(String.format("Bulkhead '%s' is full", bulkhead.getName()));
}

代码示例来源:origin: io.github.resilience4j/resilience4j-metrics

private BulkheadMetrics(String prefix, Iterable<Bulkhead> bulkheads) {
  requireNonNull(prefix);
  requireNonNull(bulkheads);
  bulkheads.forEach(bulkhead -> {
        String name = bulkhead.getName();
    //number of available concurrent calls as an integer
        metricRegistry.register(name(prefix, name, AVAILABLE_CONCURRENT_CALLS),
            (Gauge<Integer>) () -> bulkhead.getMetrics().getAvailableConcurrentCalls());
      }
  );
}

代码示例来源:origin: io.github.resilience4j/resilience4j-rxjava2

@Override
public void onSubscribe(Subscription subscription) {
  if (SubscriptionHelper.setOnce(this, subscription)) {
    if (acquireCallPermit()) {
      childSubscriber.onSubscribe(this);
    } else {
      cancel();
      childSubscriber.onSubscribe(this);
      childSubscriber.onError(new BulkheadFullException(String.format("Bulkhead '%s' is full", bulkhead.getName())));
    }
  }
}

代码示例来源:origin: io.github.resilience4j/resilience4j-ratpack

private Object handleOther(MethodInvocation invocation, io.github.resilience4j.bulkhead.Bulkhead bulkhead, RecoveryFunction<?> recoveryFunction) throws Throwable {
    boolean permission = bulkhead.isCallPermitted();

    if (!permission) {
      Throwable t = new BulkheadFullException(String.format("Bulkhead '%s' is full", bulkhead.getName()));
      return recoveryFunction.apply(t);
    }

    try {
      if (Thread.interrupted()) {
        throw new IllegalStateException("Thread was interrupted during permission wait");
      }

      return invocation.proceed();
    } catch (Exception e) {
      return recoveryFunction.apply(e);
    } finally {
      bulkhead.onComplete();
    }
  }
}

代码示例来源:origin: io.github.resilience4j/resilience4j-ratpack

Throwable t = new BulkheadFullException(String.format("Bulkhead '%s' is full", bulkhead.getName()));
handleRecovery(down, t);

代码示例来源:origin: io.github.resilience4j/resilience4j-ratpack

chain1.get("stream/events/:name", ctx -> {
  String bulkheadName = ctx.getPathTokens().get("name");
  Bulkhead bulkhead = bulkheadRegistry.getAllBulkheads().find(b -> b.getName().equals(bulkheadName))
      .getOrElseThrow(() -> new IllegalArgumentException(String.format("bulkhead with name %s not found", bulkheadName)));
  Function<BulkheadEvent, String> data = b -> Jackson.getObjectWriter(chain1.getRegistry()).writeValueAsString(BulkheadEventDTO.createEventDTO(b));
  String bulkheadName = ctx.getPathTokens().get("name");
  String eventType = ctx.getPathTokens().get("type");
  Bulkhead bulkhead = bulkheadRegistry.getAllBulkheads().find(b -> b.getName().equals(bulkheadName))
      .getOrElseThrow(() -> new IllegalArgumentException(String.format("bulkhead with name %s not found", bulkheadName)));
  Flux<BulkheadEvent> eventStream = ReactorAdapter.toFlux(bulkhead.getEventPublisher())

相关文章