Coder Social home page Coder Social logo

polarismesh / polaris-java Goto Github PK

View Code? Open in Web Editor NEW
128.0 4.0 80.0 2.7 MB

Lightweight Java SDK used as Proxyless Service Governance

License: Other

Java 99.96% Dockerfile 0.04%
service-register service-discover request-route load-balance circuit-break rate-limit health-check authenticate traffic-control fault-tolerance

polaris-java's People

Contributors

1182640071 avatar andrewshan avatar chuntaojun avatar davionchen avatar dependabot[bot] avatar dinstone avatar doubleluxu avatar fabian4 avatar finefuture avatar gongzhijian avatar houseme avatar huyuanxin avatar lepdou avatar li-xiao-shuang avatar melodyl-xyz avatar misselvexu avatar movebean avatar ranchowang avatar samshan08 avatar shanyouyu-sean avatar shedfreewu avatar shichaoyuan avatar shuiqingliu avatar skyebefreeman avatar suninsky avatar veterancj avatar wallezhang avatar wenxuan70 avatar willemgavin avatar xiaohongxiedaima avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

polaris-java's Issues

路由规则的isolate标记不生效

consumer标签配置如下:
image

provider(2个)标签配置如下:
image
image

路由规则配置如下:
image
预期应当实例分组1不接收任何请求。
实际的请求情况实例分组1还是正常按权重的比例分到了对应的请求
image

实际请求状况-全部转发至provider1:

need to support global ratelimiting

What is the feature you want to add?
global rateliming, all instances share one max amount

Why do you want to add this feature?
to protect the database or backend store in logical layer

How to implement this feature?

Additional context
Add any other context or screenshots about the feature request here.

Java SDK使用自定义OutlierDetector插件进行探测结果无法更新到InMemoryRegistry

Describe the bug

Java Sdk 使用自定义OutlierDetector插件进行探测结果无法更新到InMemoryRegistry

To Reproduce

1、SDK内部线程池周期性执行InstancesDetectTask,默认情况下serviceKey列表为空。

@Override
    public void run() {
        Set<ServiceKey> services = extensions.getLocalRegistry().getServices();
        for (ServiceKey serviceKey : services) {
            try {
                doInstanceDetectForService(serviceKey);
            } catch (PolarisException e) {
                LOG.error("fail to do instance detect for {}, e:{}", serviceKey, e);
            }
        }
    }

2、选择某个Service,先getOneInstance,再updateServiceCallResult。此时serviceKey不为空,进入doInstanceDetectForService流程
3、探测的结果通过下列语句写入到InMemoryRegistry

 if (MapUtils.isNotEmpty(aliveResults)) {
            ServiceUpdateRequest updateRequest = buildInstanceUpdateResult(serviceKey, aliveResults);
            LOG.info("update cache for outlier detect, value is {}", updateRequest);
            extensions.getLocalRegistry().updateInstances(updateRequest);

        }

但是发现
在buildInstanceUpdateResult时,探测结果,以key =PROPERTY_OUTLIER_DETECTOR_STATUS 保存到properites中。

     properties.put(PROPERTY_OUTLIER_DETECTOR_STATUS,
                    new OutlierDetectionStatus(entry.getValue().getDetectType(), OutlierDetectionStatus.Status.HEALTHY,
                            entry.getValue().getLastDetectTime().getTime()));

但是在更新InMemoryRegistry.updateInstances时,却没有匹配不上

  for (Map.Entry<String, Object> entry : properties.entrySet()) {
                switch (entry.getKey()) {
                    case InstanceProperty.PROPERTY_CIRCUIT_BREAKER_STATUS:
                        onCircuitBreakStatus(entry.getValue(), instanceLocalValue, instance);
                        break;
                    case InstanceProperty.PROPERTY_DETECT_RESULT:
                        instanceLocalValue.setDetectResult((DetectResult) entry.getValue());
                        break;
                    default:
                        break;
                }
            }

4、导致InstancesDetectTask重复探测。

Expected behavior

理论上连续探测多次成功的探测后,就不应该再次发起。

Environment

  • Version: [Java SDK v1.2.0]

Additional context

  outlierDetection:

    enable: true
    checkPeriod: 10000
    when: on_recover

disable polaris.discover and polaris.healthcheck by default

What is the feature you want to add?
by default config, user can directly use the localhost server to do everthing, no need to register any system services

Why do you want to add this feature?
standalone version has no system services

How to implement this feature?
change the sameAsDefault as true by default

Additional context
Add any other context or screenshots about the feature request here.

polaris-java对外接口抛异常的行为优化

北极星当前接口抛出来的异常是RumtimeException,用户程序如果不进行catch的话,会导致接口失败。传递到上层线程就会失败。
因此,接口行为建议修改如下:

  1. 不是所有错误码都跑异常,只有出现SDK内部错误的情况,SDK出现没法运行的情况,才抛异常。
  2. reponse增加一个Code字段,给出对应的返回码

需要抛异常的情况:

  • 插件初始化失败:PLUGIN_ERROR
  • 配置错误,SDK初始化失败:INVALID_CONFIG
  • SDK已经销毁,状态错误:INVALID_STATE

a risk on the exposure of the internal server ips

Describe the bug
the DefaultInternalConfigProvider has written a list of internal server ips to default config file, it may cause a security exposure of the internal assest

To Reproduce
Steps to reproduce the behavior.

Expected behavior
A clear and concise description of what you expected to happen.

Environment

  • Version: [e.g. v1.0.0]
  • OS: [e.g. CentOS8]

Additional context
Add any other context about the problem here.

支持获取service列表功能

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior.

Expected behavior
A clear and concise description of what you expected to happen.

Environment

  • Version: [e.g. v1.0.0]
  • OS: [e.g. CentOS8]

Additional context
Add any other context about the problem here.

Upgrade third-party libs because current version brings in jars with CVEs

What is the feature you want to add?

Upgrade third-party libs because current version brings in jars with CVEs .
eg:

  • jackson-databind
  • netty
  • snakeyaml
  • log4j
  • httpclient

Why do you want to add this feature?

Upgrade the version of the dependency package specified in the section .

How to implement this feature?

none .

Additional context

eg:

  • Provides transitive vulnerable dependency com.fasterxml.jackson.core:jackson-databind:2.9.9 Deserialization of Untrusted Data vulnerability pending CVSS allocation .
  • Provides transitive vulnerable dependency org.apache.httpcomponents:httpclient:4.5.5 Improper Input Validation vulnerability pending CVSS allocation .

Support configuration center

What is the feature you want to add?
Let's polaris support configuration center.

Why do you want to add this feature?
Polaris server had supportted dynamic configuration, so sdk should support it.

How to implement this feature?
Create an new module for configuration

Additional context
Add any other context or screenshots about the feature request here.

No response information when rate limit

Describe the bug
wecom-temp-61488613964a3756bd314ac49d67b7f6

To Reproduce
Steps to reproduce the behavior.

Expected behavior
A clear and concise description of what you expected to happen.

Environment

  • Version: [e.g. v1.0.0]
  • OS: [e.g. CentOS8]

Additional context
Add any other context about the problem here.

polaris-quickstart-examples should split into 2 module as provider and consumer

What is the feature you want to add?
split into 2 module as provider and consumer
and make consumer accept http request and redirect to provider

Why do you want to add this feature?
for docker deploy, you can observe the response as web server other than one way job

How to implement this feature?
use jdk8 feature to do http server

Additional context
Add any other context or screenshots about the feature request here.

Support multi-discovery server.

What is the feature you want to add?

Let the polaris-java support multiple discovery server.

Why do you want to add this feature?

When using another discovery server and what to change to polaris, can use this feature to realize smooth migration.

How to implement this feature?

Create an composite server connector to get remote service infomation.

Additional context
No.

DiscoverRequest 需要增加 revision 信息以便实现 NO_CHANGE 逻辑

当前 Java SDK 的 DiscoverRequest 没有设置 revision,每次请求都会拉取全量的数据。

public void sendRequest(ServiceUpdateTask serviceUpdateTask) {
    ServiceEventKey serviceEventKey = serviceUpdateTask.getServiceEventKey();
    ServiceProto.Service.Builder builder = ServiceProto.Service.newBuilder();
    builder.setName(StringValue.newBuilder().setValue(serviceEventKey.getServiceKey().getService()).build());
    builder.setNamespace(StringValue.newBuilder().setValue(serviceEventKey.getServiceKey().getNamespace()).build());

    RequestProto.DiscoverRequest.Builder req = RequestProto.DiscoverRequest.newBuilder();
    req.setType(GrpcUtil.buildDiscoverRequestType(serviceEventKey.getEventType())); // switch
    req.setService(builder);
    if (serviceUpdateTask.getTaskType() == Type.FIRST) {
        LOG.info("[ServerConnector]send request(id={}) to {} for service {}", reqId, connection.getConnID(),
                serviceEventKey);
    } else {
        LOG.debug("[ServerConnector]send request(id={}) to {} for service {}", reqId, connection.getConnID(),
                serviceEventKey);
    }
    discoverClient.onNext(req.build());
}

对比 Golang SDK 传递了 revision,这样控制面就能判断是否需要返回全量数据。

// 转换为服务发现的请求对象
func (s *serviceUpdateTask) toDiscoverRequest() *namingpb.DiscoverRequest {
        var request = &namingpb.DiscoverRequest{
                Type: pb.GetProtoRequestType(s.Type),
                Service: &namingpb.Service{
                        Name:      &wrappers.StringValue{Value: s.Service},
                        Namespace: &wrappers.StringValue{Value: s.Namespace},
                        Revision:  &wrappers.StringValue{Value: s.handler.GetRevision()},
                        Business:  &wrappers.StringValue{Value: s.handler.GetBusiness()},
                },
                // 网格请求
                MeshConfig: s.handler.GetMeshConfig(),
                Mesh: &namingpb.Mesh{
                        Id: &wrappers.StringValue{Value: s.Service},
                },
        }
        if log.GetBaseLogger().IsLevelEnabled(log.DebugLog) {
                reqJson, _ := (&jsonpb.Marshaler{}).MarshalToString(request)
                log.GetBaseLogger().Debugf(
                        "discover request to send is %s", reqJson)
        }
        return request
}

对于polaris-java的shade包,建议把grpc依赖也进行shade

What is the feature you want to add?

或者polaris-java的shade包,把所有的三方依赖全部做shade

Why do you want to add this feature?

How to implement this feature?

Additional context
Add any other context or screenshots about the feature request here.

对插件配置的对象进行缓存

What is the feature you want to add?
在获取插件配置的时候,代码参考这里:com.tencent.polaris.factory.config.plugin.PluginConfigImpl#getPluginConfig
目前只对配置的属性值进行了缓存,每次都会通过mapper反序列化一个新的对象,是不是可以考虑把反序列化之后的对象缓存呢?

Why do you want to add this feature?

How to implement this feature?

Additional context
Add any other context or screenshots about the feature request here.

规范化日志打印,北极星日志单独打印polaris.log

当前北极星日志依赖用户的log配置,一般出现2种情况:

  1. 和用户日志混淆在一起,影响用户定位问题
  2. 没有打印日志,导致北极星自身问题不好定位

期望可以单独一份配置,自动嵌入到用户当前的日志框架中

关于「推空保护开关」的 应用场景 和 粒度 问题

Q1:什么情况下需要关闭「推空保护开关」?

「推空保护」的主要场景在于,当注册中心故障或异常推送 provider 空列表时,consumer端不做更新,维持调用ip列表。

简单想了下,如果是 服务真的下线,开不开都是调用不到,那和注册中心异常两种场景下保持「推空保护」都没什么问题。

想了解下什么场景下需要关闭这个开关?

Q2:为什么开关配置在consumer维度?

看了下读取的是consumer配置。

image

这样如果想单独配置某个provider维度的 推空保护关闭 就做不到了。

是不是配置在provider角度更合适?

Q3:推空保护 是否需要作用于其他配置?

除了服务发现需要推空保护外,其他服务治理配置、路由信息是否需要推空保护?

服务下线 和 推空保护 两个场景不冲突,但是 其他配置信息为空 和 推空保护 似乎有些冲突。

应该如何设计比较好?

Maybe need upgrade io.netty version

What is the feature you want to add?

netty版本为4.1.75,北极星sdk依赖的netty版本为4.1.51,导致高版本的 netty在HpackDecoder处理grpc的header头调用GrpcHttp2ResponseHeaders的contains方法,而这个方法GrpcHttp2ResponseHeaders是直接抛出异常的,从而导致处理响应时抛出错误无法正常继续下面的流程

Why do you want to add this feature?

How to implement this feature?

Additional context
Add any other context or screenshots about the feature request here.

优化日志,当实例变更时,打印新推送的实例列表

What is the feature you want to add?

如下日志显示,没有打印最新的实例信息,不利于排查问题

2022-06-27 15:00:51.671 INFO [grpc-default-executor-7576:codec.CommonHandler] resource ServiceEventKey{serviceKey=ServiceKey{namespace='prod', service=''}, eventType=INSTANCE} has updated, compare status CacheChanged, old revision is 9324c417870f06517e1cb9a45fd9fb2e692fd78b, old loadedFromFile is false, new revision is 0b7ad8cc02f16bb4b40d22590b0b67560a3d40e8
2022-06-27 15:00:51.671 INFO [grpc-default-executor-7576:memory.CacheObject] OnServiceUpdate: cache ServiceEventKey{serviceKey=ServiceKey{namespace='prod', service=''}, eventType=INSTANCE} is pending to update
2022-06-27 15:00:51.671 INFO [grpc-default-executor-7576:memory.CacheObject] CacheObject: value for ServiceEventKey{serviceKey=ServiceKey{namespace='prod', service=''}, eventType=INSTANCE} is updated, revision 0b7ad8cc02f16bb4b40d22590b0b67560a3d40e8
2022-06-27 15:00:51.671 INFO [polaris-inmemory-2:memory.MessagePersistHandler] start to save service ServiceEventKey{serviceKey=ServiceKey{namespace='prod', service=''}, eventType=INSTANCE}
2022-06-27 15:00:51.672 INFO [polaris-inmemory-2:memory.MessagePersistHandler] end to save service ServiceEventKey{serviceKey=ServiceKey{namespace='prod', service=''}, eventType=INSTANCE} to /data/app/./polaris/backup/svc#prod#xl#instance.yaml

Additional context
Add any other context or screenshots about the feature request here.

flush lots of logs on discovery

Describe the bug
When discover a service, add into the schedule pool, it will flush a log frequently to make others logs hard to find

To Reproduce
discover any of service

Expected behavior
log flush as normal , remove the useless log

Environment

  • Version: [e.g. v1.0.0]
  • OS: [e.g. CentOS8]

Additional context

/**
 * 加入调度队列
 */
public void addUpdateTaskSet() {
    if (taskType.compareAndSet(Type.FIRST, Type.LONG_RUNNING)) {
        targetClusterType.set(ClusterType.SERVICE_DISCOVER_CLUSTER);
        grpcConnector.addLongRunningTask(this);
        LOG.debug("[ServerConnector]task for service {} has been scheduled updated", this);
    }
}

配置模块的日志没有打印到日志文件里

Describe the bug

配置模块的日志没有打印到日志文件里

To Reproduce
Steps to reproduce the behavior.

Expected behavior
A clear and concise description of what you expected to happen.

Environment

  • Version: [e.g. v1.0.0]
  • OS: [e.g. CentOS8]

Additional context
Add any other context about the problem here.

change package to cn.polarismesh

What is the feature you want to add?

Why do you want to add this feature?

How to implement this feature?

Additional context
Add any other context or screenshots about the feature request here.

support default method to build ServiceInstances object

What is the feature you want to add?
spring cloud integrate polaris, need to get service Instances implementation to proceed with ribbon flow

Why do you want to add this feature?

How to implement this feature?

Additional context
Add any other context or screenshots about the feature request here.

服务治理监控支持通过拉模式接入prometheus

当前支持推模式接入pushgateway,再通过pushgateway接入prometheus,但是存在以下问题:

  1. pushgateway的数据,在应用下线时不会自动更新
  2. 需要额外维护一套pushgateway集群,增加了故障点。

希望北极星可以接入原生prometheus拉取模式,当前go sdk已经接入

规则路由匹配失败则全放通

What is the feature you want to add?

Why do you want to add this feature?

How to implement this feature?

Additional context
Add any other context or screenshots about the feature request here.

路由规则无法支持全放通匹配

Describe the bug
用户配置了路由规则,假如没有传入标签,则匹配失败,无法获取实例

To Reproduce
Steps to reproduce the behavior.

Expected behavior
用户可以配置全放通规则

Environment

  • Version: [e.g. v1.0.0]
  • OS: [e.g. CentOS8]

Additional context
Add any other context about the problem here.

support Subscribe and UnSubscribe Service

What is the feature you want to add?

support Subscribe and UnSubscribe Service

Why do you want to add this feature?

support Subscribe and UnSubscribe Service

How to implement this feature?

Additional context
Add any other context or screenshots about the feature request here.

Support service registration and discovery fine-grained switch

What is the feature you want to add?

User can define if registration or discovery enabled.

Why do you want to add this feature?

When using multi-discovery may encounter this situation.

How to implement this feature?

Add switch of registration and discovery.

Additional context

No.

replace org.apache.logging.log4j to ch.qos.logback

Describe the bug

replace org.apache.logging.log4j to ch.qos.logback

To Reproduce
Steps to reproduce the behavior.

Expected behavior
A clear and concise description of what you expected to happen.

Environment

  • Version: [e.g. v1.0.0]
  • OS: [e.g. CentOS8]

Additional context
Add any other context about the problem here.

自定义探测结果 无法更新到instanceLocalValue

Describe the bug
自定义探测结果 无法更新到instanceLocalValue
To Reproduce

image

自定义探测结果返回类型为:OutlierDetectionStatus,但是InstanceLocalValue的方法为setDetectResult(DetectResult result)
类型不一致性,更新失败

Expected behavior
A clear and concise description of what you expected to happen.

Environment

  • Version: [1.2.2-SNAPSHOT]

Additional context
Add any other context about the problem here.

在服务注册前后是否能够提供增强处理

如图,假设我现在需要在Metadata里面添加一个固定的元素,就不需要每个项目都要去在配置文件中配置上下文。
又或者我想自己定义一些注册前执行的业务处理,以及注册后的一些操作。目前查看源码好像没有对应的支持
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.