Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes #5351

Merged
merged 31 commits into from
Nov 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e5c50fc
Polish apache/dubbo#5306 : [Migration] Upgrade the @since tags in Jav…
mercyblitz Nov 12, 2019
b1fe4f6
Polish apache/dubbo#5306 : [Migration] Upgrade the @since tags in Jav…
mercyblitz Nov 12, 2019
6176bf0
Polish apache/dubbo#5309 : [ISSURE] The beans of Dubbo's Config can't…
mercyblitz Nov 12, 2019
d4c8956
Polish apache/dubbo#5312 : Resolve the demos' issues of zookeeper and…
mercyblitz Nov 12, 2019
4278dc1
Merge remote-tracking branch 'upstream/master' into cloud-native-2.7.5
mercyblitz Nov 12, 2019
3734800
Polish apache/dubbo#5313 : [Migration] migrate the code in common mod…
mercyblitz Nov 12, 2019
5d74025
Polish apache/dubbo#5316 : [Refactor] Replace @EnableDubboConfigBindi…
mercyblitz Nov 13, 2019
2f56570
Polish apache/dubbo#5317 : [Refactor] Refactor ReferenceAnnotationBea…
mercyblitz Nov 13, 2019
5afb058
Polish apache/dubbo#5321 : Remove BeanFactoryUtils
mercyblitz Nov 13, 2019
92af95e
Polish apache/dubbo#5321 : Remove AnnotatedBeanDefinitionRegistryUtils
mercyblitz Nov 13, 2019
2bbabf6
Polish apache/dubbo#5321 : Remove AnnotationUtils
mercyblitz Nov 13, 2019
8596072
Polish apache/dubbo#5321 : Remove ClassUtils
mercyblitz Nov 13, 2019
256ee6e
Polish apache/dubbo#5321 : Remove BeanRegistrar
mercyblitz Nov 13, 2019
96276f4
Polish apache/dubbo#5321 : Remove ObjectUtils
mercyblitz Nov 13, 2019
ed0f920
Polish apache/dubbo#5321 : Remove PropertySourcesUtils
mercyblitz Nov 13, 2019
0da7e27
Merge remote-tracking branch 'upstream/master' into cloud-native-2.7.5
mercyblitz Nov 14, 2019
e97abee
Sync commit
mercyblitz Nov 14, 2019
14c116d
Polish apache/dubbo#5325 : [Migration] To migrate dubbo-metadata-api …
mercyblitz Nov 14, 2019
b1eb630
Polish apache/dubbo#5326 : [Migration] To migrate dubbo-metadata-proc…
mercyblitz Nov 14, 2019
4c72e2c
Sync
mercyblitz Nov 14, 2019
2827278
Polish apache/dubbo#5329 : [Feature] To add the default metadata into…
mercyblitz Nov 14, 2019
8f39074
Merge remote-tracking branch 'upstream/master' into cloud-native-2.7.5
mercyblitz Nov 14, 2019
348e31d
Merge remote-tracking branch 'upstream/master' into cloud-native-2.7.5
mercyblitz Nov 15, 2019
60ba484
Merge remote-tracking branch 'upstream/master' into cloud-native-2.7.5
mercyblitz Nov 15, 2019
b669ec0
Merge remote-tracking branch 'upstream/master' into cloud-native-2.7.5
mercyblitz Nov 18, 2019
2eeee77
Polish apache/dubbo#5339 : [Refactor] Refactor the DynamicConfigurati…
mercyblitz Nov 18, 2019
5cffbc2
Polish bugfix
mercyblitz Nov 19, 2019
95c2068
Fixes test cases
mercyblitz Nov 19, 2019
a29555c
Merge remote-tracking branch 'upstream/master' into cloud-native-2.7.5
mercyblitz Nov 19, 2019
721d25a
Merge remote-tracking branch 'upstream/master' into cloud-native-2.7.5
mercyblitz Nov 19, 2019
ad9ec1f
Merge remote-tracking branch 'upstream/master' into cloud-native-2.7.5
mercyblitz Nov 19, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ public class DynamicConfigurationFactoryTest {
public void testDefaultExtension() {
DynamicConfigurationFactory factory = getExtensionLoader(DynamicConfigurationFactory.class).getDefaultExtension();
assertEquals(NopDynamicConfigurationFactory.class, factory.getClass());
assertEquals(factory, getExtensionLoader(DynamicConfigurationFactory.class).getExtension("nop"));
assertEquals(NopDynamicConfigurationFactory.class, getExtensionLoader(DynamicConfigurationFactory.class).getExtension("nop").getClass());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
*/
package org.apache.dubbo.common.config.configcenter.file;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.config.configcenter.DynamicConfigurationFactory;
import org.apache.dubbo.common.config.configcenter.nop.NopDynamicConfiguration;

import org.junit.jupiter.api.Test;

Expand All @@ -33,9 +31,6 @@ public class FileSystemDynamicConfigurationFactoryTest {

@Test
public void testGetFactory() {
DynamicConfigurationFactory factory = DynamicConfigurationFactory.getDynamicConfigurationFactory("not-exists");
assertEquals(factory, DynamicConfigurationFactory.getDynamicConfigurationFactory("nop"));
assertEquals(factory.getDynamicConfiguration(URL.valueOf("dummy")), factory.getDynamicConfiguration(URL.valueOf("dummy")));
assertEquals(NopDynamicConfiguration.class, factory.getDynamicConfiguration(URL.valueOf("dummy")).getClass());
assertEquals(FileSystemDynamicConfigurationFactory.class, DynamicConfigurationFactory.getDynamicConfigurationFactory("file").getClass());
}
}
Original file line number Diff line number Diff line change
@@ -1,150 +1,150 @@
///*
// * 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.file;
//
//import org.apache.dubbo.common.URL;
//
//import org.apache.commons.io.FileUtils;
//import org.junit.jupiter.api.AfterEach;
//import org.junit.jupiter.api.BeforeEach;
//import org.junit.jupiter.api.Test;
//
//import java.io.File;
//import java.util.concurrent.ThreadPoolExecutor;
//import java.util.concurrent.atomic.AtomicBoolean;
//
//import static org.apache.commons.io.FileUtils.deleteQuietly;
//import static org.apache.dubbo.common.URL.valueOf;
//import static org.apache.dubbo.common.config.configcenter.DynamicConfiguration.DEFAULT_GROUP;
//import static org.apache.dubbo.common.config.configcenter.file.FileSystemDynamicConfiguration.CONFIG_CENTER_DIR_PARAM_NAME;
//import static org.junit.jupiter.api.Assertions.assertEquals;
//import static org.junit.jupiter.api.Assertions.assertNotNull;
//import static org.junit.jupiter.api.Assertions.assertNull;
//import static org.junit.jupiter.api.Assertions.assertTrue;
//
///**
// * {@link FileSystemDynamicConfiguration} Test
// */
//public class FileSystemDynamicConfigurationTest {
//
// private FileSystemDynamicConfiguration configuration;
//
// private static final String KEY = "abc-def-ghi";
//
// private static final String CONTENT = "Hello,World";
//
// @BeforeEach
// public void init() {
// File rootDirectory = new File(getClassPath(), "config-center");
// rootDirectory.mkdirs();
// URL url = valueOf("dubbo://127.0.0.1:20880").addParameter(CONFIG_CENTER_DIR_PARAM_NAME, rootDirectory.getAbsolutePath());
// configuration = new FileSystemDynamicConfiguration(url);
// deleteQuietly(configuration.getRootDirectory());
// }
//
// @AfterEach
// public void destroy() throws Exception {
// configuration.close();
// }
//
// private String getClassPath() {
// return getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
// }
//
// @Test
// public void testInit() {
//
// assertEquals(new File(getClassPath(), "config-center"), configuration.getRootDirectory());
// assertEquals("UTF-8", configuration.getEncoding());
// assertEquals(ThreadPoolExecutor.class, configuration.getWorkersThreadPool().getClass());
// assertEquals(1, (configuration.getWorkersThreadPool()).getCorePoolSize());
// assertEquals(1, (configuration.getWorkersThreadPool()).getMaximumPoolSize());
// assertNotNull(configuration.getWatchEventsLoopThreadPool());
// assertEquals(1, (configuration.getWatchEventsLoopThreadPool()).getCorePoolSize());
// assertEquals(1, (configuration.getWatchEventsLoopThreadPool()).getMaximumPoolSize());
//
// if (configuration.isBasedPoolingWatchService()) {
// assertEquals(2, configuration.getDelay());
// } else {
// assertNull(configuration.getDelay());
// }
// }
//
// @Test
// public void testPublishAndGetConfig() {
// assertTrue(configuration.publishConfig(KEY, CONTENT));
// assertTrue(configuration.publishConfig(KEY, CONTENT));
// assertTrue(configuration.publishConfig(KEY, CONTENT));
// assertEquals(CONTENT, configuration.getConfig(KEY, DEFAULT_GROUP));
// }
//
// @Test
// public void testAddAndRemoveListener() throws InterruptedException {
//
// configuration.publishConfig(KEY, "A");
//
// AtomicBoolean processedEvent = new AtomicBoolean();
//
// configuration.addListener(KEY, event -> {
//
// processedEvent.set(true);
// assertEquals(KEY, event.getKey());
// System.out.printf("[%s] " + event + "\n", Thread.currentThread().getName());
// });
//
//
// configuration.publishConfig(KEY, "B");
// while (!processedEvent.get()) {
// Thread.sleep(1 * 1000L);
// }
//
// processedEvent.set(false);
// configuration.publishConfig(KEY, "C");
// while (!processedEvent.get()) {
// Thread.sleep(1 * 1000L);
// }
//
// processedEvent.set(false);
// configuration.publishConfig(KEY, "D");
// while (!processedEvent.get()) {
// Thread.sleep(1 * 1000L);
// }
//
// configuration.addListener("test", "test", event -> {
// processedEvent.set(true);
// assertEquals("test", event.getKey());
// System.out.printf("[%s] " + event + "\n", Thread.currentThread().getName());
// });
// processedEvent.set(false);
// configuration.publishConfig("test", "test", "TEST");
// while (!processedEvent.get()) {
// Thread.sleep(1 * 1000L);
// }
//
// configuration.publishConfig("test", "test", "TEST");
// configuration.publishConfig("test", "test", "TEST");
// configuration.publishConfig("test", "test", "TEST");
//
//
// processedEvent.set(false);
// File keyFile = configuration.configFile(KEY, DEFAULT_GROUP);
// FileUtils.deleteQuietly(keyFile);
// while (!processedEvent.get()) {
// Thread.sleep(1 * 1000L);
// }
// }
//}
/*
* 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.file;

import org.apache.dubbo.common.URL;

import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.io.File;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.atomic.AtomicBoolean;

import static org.apache.commons.io.FileUtils.deleteQuietly;
import static org.apache.dubbo.common.URL.valueOf;
import static org.apache.dubbo.common.config.configcenter.DynamicConfiguration.DEFAULT_GROUP;
import static org.apache.dubbo.common.config.configcenter.file.FileSystemDynamicConfiguration.CONFIG_CENTER_DIR_PARAM_NAME;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* {@link FileSystemDynamicConfiguration} Test
*/
public class FileSystemDynamicConfigurationTest {

private FileSystemDynamicConfiguration configuration;

private static final String KEY = "abc-def-ghi";

private static final String CONTENT = "Hello,World";

@BeforeEach
public void init() {
File rootDirectory = new File(getClassPath(), "config-center");
rootDirectory.mkdirs();
URL url = valueOf("dubbo://127.0.0.1:20880").addParameter(CONFIG_CENTER_DIR_PARAM_NAME, rootDirectory.getAbsolutePath());
configuration = new FileSystemDynamicConfiguration(url);
deleteQuietly(configuration.getRootDirectory());
}

@AfterEach
public void destroy() throws Exception {
configuration.close();
}

private String getClassPath() {
return getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
}

@Test
public void testInit() {

assertEquals(new File(getClassPath(), "config-center"), configuration.getRootDirectory());
assertEquals("UTF-8", configuration.getEncoding());
assertEquals(ThreadPoolExecutor.class, configuration.getWorkersThreadPool().getClass());
assertEquals(1, (configuration.getWorkersThreadPool()).getCorePoolSize());
assertEquals(1, (configuration.getWorkersThreadPool()).getMaximumPoolSize());
assertNotNull(configuration.getWatchEventsLoopThreadPool());
assertEquals(1, (configuration.getWatchEventsLoopThreadPool()).getCorePoolSize());
assertEquals(1, (configuration.getWatchEventsLoopThreadPool()).getMaximumPoolSize());

if (configuration.isBasedPoolingWatchService()) {
assertEquals(2, configuration.getDelay());
} else {
assertNull(configuration.getDelay());
}
}

@Test
public void testPublishAndGetConfig() {
assertTrue(configuration.publishConfig(KEY, CONTENT));
assertTrue(configuration.publishConfig(KEY, CONTENT));
assertTrue(configuration.publishConfig(KEY, CONTENT));
assertEquals(CONTENT, configuration.getConfig(KEY, DEFAULT_GROUP));
}

@Test
public void testAddAndRemoveListener() throws InterruptedException {

configuration.publishConfig(KEY, "A");

AtomicBoolean processedEvent = new AtomicBoolean();

configuration.addListener(KEY, event -> {

processedEvent.set(true);
assertEquals(KEY, event.getKey());
System.out.printf("[%s] " + event + "\n", Thread.currentThread().getName());
});


configuration.publishConfig(KEY, "B");
while (!processedEvent.get()) {
Thread.sleep(1 * 1000L);
}

processedEvent.set(false);
configuration.publishConfig(KEY, "C");
while (!processedEvent.get()) {
Thread.sleep(1 * 1000L);
}

processedEvent.set(false);
configuration.publishConfig(KEY, "D");
while (!processedEvent.get()) {
Thread.sleep(1 * 1000L);
}

configuration.addListener("test", "test", event -> {
processedEvent.set(true);
assertEquals("test", event.getKey());
System.out.printf("[%s] " + event + "\n", Thread.currentThread().getName());
});
processedEvent.set(false);
configuration.publishConfig("test", "test", "TEST");
while (!processedEvent.get()) {
Thread.sleep(1 * 1000L);
}

configuration.publishConfig("test", "test", "TEST");
configuration.publishConfig("test", "test", "TEST");
configuration.publishConfig("test", "test", "TEST");


processedEvent.set(false);
File keyFile = configuration.configFile(KEY, DEFAULT_GROUP);
FileUtils.deleteQuietly(keyFile);
while (!processedEvent.get()) {
Thread.sleep(1 * 1000L);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

import java.util.EmptyStackException;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

public class StackTest {
@Test
Expand Down
15 changes: 15 additions & 0 deletions dubbo-config/dubbo-config-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,5 +186,20 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-configcenter-nacos</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-configcenter-consul</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>


</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static void main(String[] args) {
DubboBootstrap.getInstance()
.application(applicationConfig)
// Zookeeper in service registry type
.registry("nacos", builder -> builder.address("nacos://127.0.0.1:8848?registry-type=service"))
.registry("nacos", builder -> builder.address("nacos://127.0.0.1:8848?registry-type=service").useAsConfigCenter(true))
// Nacos
// .registry("nacos", builder -> builder.address("nacos://127.0.0.1:8848?registry.type=service"))
// .registry(RegistryBuilder.newBuilder().address("etcd3://127.0.0.1:2379?registry.type=service").build())
Expand Down
Loading