org.apache.dubbo.common.extension.ExtensionLoader Java Examples

The following examples show how to use org.apache.dubbo.common.extension.ExtensionLoader. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ITTracingFilter_Consumer.java    From brave with Apache License 2.0 6 votes vote down vote up
/** Shows if you aren't using RpcTracing, the old "dubbo.error_code" works */
@Test public void setError_onUnimplemented_legacy() {
  ((TracingFilter) ExtensionLoader.getExtensionLoader(Filter.class)
      .getExtension("tracing")).isInit = false;

  ((TracingFilter) ExtensionLoader.getExtensionLoader(Filter.class)
      .getExtension("tracing"))
      .setTracing(tracing);

  assertThatThrownBy(() -> wrongClient.get().sayHello("jorge"))
      .isInstanceOf(RpcException.class);

  MutableSpan span =
      testSpanHandler.takeRemoteSpanWithErrorMessage(CLIENT, ".*Not found exported service.*");
  assertThat(span.tags())
      .containsEntry("dubbo.error_code", "1");
}
 
Example #2
Source File: ITTracingFilter.java    From brave with Apache License 2.0 5 votes vote down vote up
/** Call this after updating {@link #tracing} */
TracingFilter init() {
  TracingFilter filter = (TracingFilter) ExtensionLoader.getExtensionLoader(Filter.class)
    .getExtension("tracing");
  filter.setTracing(tracing);
  return filter;
}
 
Example #3
Source File: DubboHealthIndicator.java    From dubbo-spring-boot-project with Apache License 2.0 2 votes vote down vote up
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {

    ExtensionLoader<StatusChecker> extensionLoader = getExtensionLoader(StatusChecker.class);

    Map<String, String> statusCheckerNamesMap = resolveStatusCheckerNamesMap();

    boolean hasError = false;

    boolean hasUnknown = false;

    // Up first
    builder.up();

    for (Map.Entry<String, String> entry : statusCheckerNamesMap.entrySet()) {

        String statusCheckerName = entry.getKey();

        String source = entry.getValue();

        StatusChecker checker = extensionLoader.getExtension(statusCheckerName);

        org.apache.dubbo.common.status.Status status = checker.check();

        org.apache.dubbo.common.status.Status.Level level = status.getLevel();

        if (!hasError && level.equals(org.apache.dubbo.common.status.Status.Level.ERROR)) {
            hasError = true;
            builder.down();
        }

        if (!hasError && !hasUnknown && level.equals(org.apache.dubbo.common.status.Status.Level.UNKNOWN)) {
            hasUnknown = true;
            builder.unknown();
        }

        Map<String, Object> detail = new LinkedHashMap<>();

        detail.put("source", source);
        detail.put("status", status);

        builder.withDetail(statusCheckerName, detail);

    }


}