Skip to content

Commit

Permalink
Dubbo cloud native (#4896)
Browse files Browse the repository at this point in the history
* Polish #4542 : [Enhancement] Adapt the Java standard Event/Listener mechanism

* Polish #4541 : [Feature] Add local File System DynamicConfigurationFactory‘s extension

* Polish #4541 : Bugfix

* Polish #4541 : Optimization

* Polish #4541 : Add the compatibility for PollingWatchService on the some platforms

* Polish #4541 : Add delay publish without ThreadPoolExecutor

* Polish #4541 : Refactor the extension name

* Polish #4541 : Add remove ops

* Polish #4541 : Add testable constructor

* Polish #4541 : Add getConfigGroups method

* Polish #4610 : [Refactor] Refactor the bootstrap module

* Polish #4541 : Fix the nulling URL issue

* Polish #4622 : [Refactor] Refactor ConfigManager

* Polish #4622 : [Refactor] Refactor ConfigManager

* Polish #4622 : Support multiple configcenters

* Polish #4671 : ServiceNameMapping will not map the group, version and protocol

* update referenceCount log (#4683)

Add comments to support multiple shared connections

* Polish /#4687 : Remove the duplicated test code in dubbo-config-spring (#4688)

* #4685  修改代码if判断false问题 if (hasException == false)修改成if (!hasException) (#4695)

* Fixed Service annotation method parameters are not in effect (#4598)

* keep demo simple, and switch to use zookeeper as registry center (#4705)

* keep demo simple, and switch to use zookeeper as registry center

* remove comment

* @reference auto-wires the instance of generic interface #4594 (#4677)

* try to shorten maven output to make travis build pass (#4710)

* use CountDownLatch to check zk registry if establish connection (#4589)

* Minor change

* Rename the extension name of WritableMetadataService

* Polish #4759 : [Refactor] Change the signature of methods of MetadataService #4759

* Merge remote-tracking branch 'upstream/master' into dubbo-cloud-native

# Conflicts:
#	dubbo-all/pom.xml
#	dubbo-bom/pom.xml
#	dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java
#	dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ApplicationConfig.java
#	dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ConfigCenterConfig.java
#	dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java
#	dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/RegistryConfig.java
#	dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java
#	dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ReferenceConfigTest.java
#	dubbo-configcenter/dubbo-configcenter-api/src/main/java/org/apache/dubbo/configcenter/DynamicConfiguration.java
#	dubbo-configcenter/dubbo-configcenter-api/src/test/java/org/apache/dubbo/configcenter/mock/MockDynamicConfiguration.java
#	dubbo-configcenter/dubbo-configcenter-consul/src/main/java/org/apache/dubbo/configcenter/consul/ConsulDynamicConfiguration.java
#	dubbo-configcenter/dubbo-configcenter-etcd/src/test/java/org/apache/dubbo/configcenter/support/etcd/EtcdDynamicConfigurationTest.java
#	dubbo-configcenter/dubbo-configcenter-nacos/src/main/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfiguration.java
#	dubbo-configcenter/dubbo-configcenter-nacos/src/test/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfigurationTest.java
#	dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfiguration.java
#	dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/definition/model/MethodDefinition.java
#	dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/identifier/MetadataIdentifier.java
#	dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/support/AbstractMetadataReport.java
#	dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/report/identifier/MetadataIdentifierTest.java
#	dubbo-metadata/dubbo-metadata-definition-protobuf/src/main/java/org/apache/dubbo/metadata/definition/protobuf/ProtobufTypeBuilder.java
#	dubbo-metadata/dubbo-metadata-definition-protobuf/src/test/java/org/apache/dubbo/metadata/definition/protobuf/ProtobufTypeBuilderTest.java
#	dubbo-metadata/pom.xml
#	dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/AbstractConfiguratorListener.java
#	dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistry.java
#	dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistryFactory.java
#	dubbo-rpc/dubbo-rpc-xml/src/main/java/org/apache/dubbo/xml/rpc/protocol/xmlrpc/XmlRpcProtocol.java

* Polish #3984 : Add the implementation of Page<ServiceInstance> getInstances(String serviceName, int offset, int pageSize, boolean healthyOnly)

* Code merge

* Fix the cases

* Merge remote-tracking branch 'upstream/cloud-native' into dubbo-cloud-native

# Conflicts:
#	dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceProviderBootstrap.java
#	dubbo-metadata/dubbo-metadata-definition-protobuf/pom.xml
#	dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/ServiceOrientedRegistryTest.java
#	dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulServiceDiscoveryFactory.java
#	dubbo-registry/dubbo-registry-etcd3/src/main/java/org/apache/dubbo/registry/etcd/EtcdServiceDiscovery.java

* Refactor ConfigManager

* Refactor ConfigManager

* Resolve the issues on ConfigManager

* Refactor and add test-cases for ConfigManager

* Polish #4774 : [Feature] Dubbo Cloud Native - To Support in Spring

* Polish #4808 : [Feature] Add the registered/unregistered event mechanism ShutdownHook

* Polish #4807 : [Feature] Add the callback mechanism ShutdownHook #4807

* Polish #4813 : [Feature] add Prioritized implementation for ServiceInstanceCustomizer

* Polish #4815 : [Feature] Add the ServiceLoader for Dubbo's services or components

* Polish #4815 : [Feature] Add the ServiceLoader for Dubbo's services or components

* Polish #4813 : [Feature] add Prioritized implementation for ServiceInstanceCustomizer

* Polish #4807 : Add sort implementation

* Refactor

* Refactor

* Polish #4845 : [Feature] Enhance the Event-Publishing feature to original ServiceDiscovery

* Merge remote-tracking branch 'upstream/cloud-native' into dubbo-cloud-native

# Conflicts:
#	dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/DefaultServiceDiscoveryFactory.java
#	dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistry.java

* Merge remote-tracking branch 'upstream/cloud-native' into dubbo-cloud-native

# Conflicts:
#	dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/DefaultServiceDiscoveryFactory.java
#	dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistry.java

* Polish #4854 : [Feature] MetadataService supports the Dubbo protocol under auto-increased port

* Polish #4857 : [Enhancement] Sync the Metadata storage type into ApplicationConfig

* Polish #4868 : [Enhancement] Refactor ConfigChangeEvent

* Polish #4868 : [Enhancement] Refactor ConfigChangeEvent

* Polish #4873 : [Feature] Add a conditional EventListener into Event Module

* Polish #4875 : [Feature] Refactor ServiceInstancesChangedListener
  • Loading branch information
mercyblitz authored Aug 20, 2019
1 parent 21e75e0 commit df61fb1
Show file tree
Hide file tree
Showing 37 changed files with 709 additions and 199 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.dubbo.bootstrap;

import org.apache.dubbo.bootstrap.rest.UserService;
import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.config.context.ConfigManager;

Expand All @@ -33,13 +32,14 @@ public static void main(String[] args) throws Exception {
.application("dubbo-consumer-demo")
.protocol(builder -> builder.port(20887).name("dubbo"))
// Zookeeper
.registry("zookeeper", builder -> builder.address("zookeeper://127.0.0.1:2181?registry.type=service&subscribed.services=dubbo-provider-demo"))
// .registry("zookeeper", builder -> builder.address("zookeeper://127.0.0.1:2181?registry.type=service&subscribed.services=dubbo-provider-demo"))
.registry("file",builder-> builder.address("file://1111?registry.type=service&subscribed.services=dubbo-provider-demo"))
// .metadataReport(new MetadataReportConfig("zookeeper://127.0.0.1:2181"))
// Nacos
// .registry("nacos", builder -> builder.address("nacos://127.0.0.1:8848?registry.type=service&subscribed.services=dubbo-provider-demo"))
// .registry("consul", builder -> builder.address("consul://127.0.0.1:8500?registry.type=service&subscribed.services=dubbo-provider-demo").group("namespace1"))
.reference("echo", builder -> builder.interfaceClass(EchoService.class).protocol("dubbo"))
.reference("user", builder -> builder.interfaceClass(UserService.class).protocol("rest"))
// .reference("user", builder -> builder.interfaceClass(UserService.class).protocol("rest"))
.onlyRegisterProvider(true)
.start()
.await();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.bootstrap;

/**
* TODO
*/
public class DubboServiceProviderMinimumBootstrap {

public static void main(String[] args) {
new DubboBootstrap()
.application("dubbo-provider-demo")
// .registry(builder -> builder.address("zookeeper://127.0.0.1:2181?registry.type=service"))
.registry(builder -> builder.address("file://?registry.type=service"))
.protocol(builder -> builder.port(-1).name("dubbo"))
.service(builder -> builder.interfaceClass(EchoService.class).ref(new EchoServiceImpl()))
.start()
.await();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package org.apache.dubbo.rpc.cluster.router.condition.config;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.config.configcenter.ConfigChangeEvent;
import org.apache.dubbo.common.config.configcenter.ConfigChangeType;
import org.apache.dubbo.common.config.configcenter.ConfigChangedEvent;
import org.apache.dubbo.common.config.configcenter.ConfigurationListener;
import org.apache.dubbo.common.config.configcenter.DynamicConfiguration;
import org.apache.dubbo.common.logger.Logger;
Expand Down Expand Up @@ -56,22 +56,22 @@ public ListenableRouter(URL url, String ruleKey) {
}

@Override
public synchronized void process(ConfigChangeEvent event) {
public synchronized void process(ConfigChangedEvent event) {
if (logger.isInfoEnabled()) {
logger.info("Notification of condition rule, change type is: " + event.getChangeType() +
", raw rule is:\n " + event.getValue());
", raw rule is:\n " + event.getContent());
}

if (event.getChangeType().equals(ConfigChangeType.DELETED)) {
routerRule = null;
conditionRouters = Collections.emptyList();
} else {
try {
routerRule = ConditionRuleParser.parse(event.getValue());
routerRule = ConditionRuleParser.parse(event.getContent());
generateConditions(routerRule);
} catch (Exception e) {
logger.error("Failed to parse the raw condition rule and it will not take effect, please check " +
"if the condition rule matches with the template, the raw rule is:\n " + event.getValue(), e);
"if the condition rule matches with the template, the raw rule is:\n " + event.getContent(), e);
}
}
}
Expand Down Expand Up @@ -121,7 +121,7 @@ private synchronized void init(String ruleKey) {
ruleRepository.addListener(routerKey, this);
String rule = ruleRepository.getRule(routerKey, DynamicConfiguration.DEFAULT_GROUP);
if (StringUtils.isNotEmpty(rule)) {
this.process(new ConfigChangeEvent(routerKey, rule));
this.process(new ConfigChangedEvent(routerKey, DynamicConfiguration.DEFAULT_GROUP, rule));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package org.apache.dubbo.rpc.cluster.router.tag;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.config.configcenter.ConfigChangeEvent;
import org.apache.dubbo.common.config.configcenter.ConfigChangeType;
import org.apache.dubbo.common.config.configcenter.ConfigChangedEvent;
import org.apache.dubbo.common.config.configcenter.ConfigurationListener;
import org.apache.dubbo.common.config.configcenter.DynamicConfiguration;
import org.apache.dubbo.common.constants.CommonConstants;
Expand Down Expand Up @@ -61,17 +61,17 @@ public TagRouter(URL url) {
}

@Override
public synchronized void process(ConfigChangeEvent event) {
public synchronized void process(ConfigChangedEvent event) {
if (logger.isDebugEnabled()) {
logger.debug("Notification of tag rule, change type is: " + event.getChangeType() + ", raw rule is:\n " +
event.getValue());
event.getContent());
}

try {
if (event.getChangeType().equals(ConfigChangeType.DELETED)) {
this.tagRouterRule = null;
} else {
this.tagRouterRule = TagRuleParser.parse(event.getValue());
this.tagRouterRule = TagRuleParser.parse(event.getContent());
}
} catch (Exception e) {
logger.error("Failed to parse the raw tag router rule and it will not take effect, please check if the " +
Expand Down Expand Up @@ -251,7 +251,7 @@ public <T> void notify(List<Invoker<T>> invokers) {
application = providerApplication;
String rawRule = ruleRepository.getRule(key, DynamicConfiguration.DEFAULT_GROUP);
if (StringUtils.isNotEmpty(rawRule)) {
this.process(new ConfigChangeEvent(key, rawRule));
this.process(new ConfigChangedEvent(key, DynamicConfiguration.DEFAULT_GROUP, rawRule));
}
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.common.config.configcenter;

import java.util.EventObject;
import java.util.Objects;

/**
* An event raised when the config changed, immutable.
*
* @see ConfigChangeType
*/
public class ConfigChangedEvent extends EventObject {

private final String key;

private final String group;

private final String content;

private final ConfigChangeType changeType;

public ConfigChangedEvent(String key, String group, String content) {
this(key, group, content, ConfigChangeType.MODIFIED);
}

public ConfigChangedEvent(String key, String group, String content, ConfigChangeType changeType) {
super(key + "=" + content);
this.key = key;
this.group = group;
this.content = content;
this.changeType = changeType;
}

public String getKey() {
return key;
}

public String getGroup() {
return group;
}

public String getContent() {
return content;
}

public ConfigChangeType getChangeType() {
return changeType;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof ConfigChangedEvent)) return false;
ConfigChangedEvent that = (ConfigChangedEvent) o;
return Objects.equals(getKey(), that.getKey()) &&
Objects.equals(group, that.group) &&
Objects.equals(getContent(), that.getContent()) &&
getChangeType() == that.getChangeType();
}

@Override
public int hashCode() {
return Objects.hash(getKey(), group, getContent(), getChangeType());
}

@Override
public String toString() {
return "ConfigChangedEvent{" +
"key='" + key + '\'' +
", group='" + group + '\'' +
", content='" + content + '\'' +
", changeType=" + changeType +
"} " + super.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ public interface ConfigurationListener extends EventListener {
*
* @param event config change event
*/
void process(ConfigChangeEvent event);
void process(ConfigChangedEvent event);
}
Loading

0 comments on commit df61fb1

Please sign in to comment.