* Re-check code style for nacos-config module. * Re-check code style for other module. * Open checkstyle plugin check during build
This commit is contained in:
parent
5d65653740
commit
95f3bfb587
@ -27,7 +27,6 @@ import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Properties;
|
||||
import java.util.Scanner;
|
||||
|
||||
|
@ -18,8 +18,8 @@ package com.alibaba.nacos.config.server.filter;
|
||||
|
||||
import com.alibaba.nacos.common.utils.ExceptionUtil;
|
||||
import com.alibaba.nacos.config.server.constant.Constants;
|
||||
import com.alibaba.nacos.config.server.model.event.RaftDBErrorEvent;
|
||||
import com.alibaba.nacos.config.server.model.event.RaftDBErrorRecoverEvent;
|
||||
import com.alibaba.nacos.config.server.model.event.RaftDbErrorEvent;
|
||||
import com.alibaba.nacos.config.server.model.event.RaftDbErrorRecoverEvent;
|
||||
import com.alibaba.nacos.consistency.cp.CPProtocol;
|
||||
import com.alibaba.nacos.consistency.cp.MetadataKey;
|
||||
import com.alibaba.nacos.core.cluster.Member;
|
||||
@ -125,18 +125,18 @@ public class CurcuitFilter implements Filter {
|
||||
public void onEvent(Event event) {
|
||||
// @JustForTest
|
||||
// This event only happens in the case of unit tests
|
||||
if (event instanceof RaftDBErrorRecoverEvent) {
|
||||
if (event instanceof RaftDbErrorRecoverEvent) {
|
||||
isDowngrading = false;
|
||||
return;
|
||||
}
|
||||
if (event instanceof RaftDBErrorEvent) {
|
||||
if (event instanceof RaftDbErrorEvent) {
|
||||
isDowngrading = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canNotify(Event event) {
|
||||
return (event instanceof RaftDBErrorEvent) || (event instanceof RaftDBErrorRecoverEvent);
|
||||
return (event instanceof RaftDbErrorEvent) || (event instanceof RaftDbErrorRecoverEvent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -20,22 +20,21 @@ package com.alibaba.nacos.config.server.model;
|
||||
* SameConfigPolicy.
|
||||
*
|
||||
* @author klw
|
||||
* @date 2019/5/21 10:55
|
||||
*/
|
||||
public enum SameConfigPolicy {
|
||||
|
||||
/**
|
||||
* @Description: abort import on duplicate
|
||||
* Abort import on duplicate.
|
||||
*/
|
||||
ABORT,
|
||||
|
||||
/**
|
||||
* @Description: skipping on duplicate
|
||||
* Skipping on duplicate.
|
||||
*/
|
||||
SKIP,
|
||||
|
||||
/**
|
||||
* @Description: overwrite on duplicate
|
||||
* Overwrite on duplicate.
|
||||
*/
|
||||
OVERWRITE
|
||||
|
||||
|
@ -23,17 +23,16 @@ import com.alibaba.nacos.core.notify.SlowEvent;
|
||||
*
|
||||
* @author <a href="mailto:liaochunyhm@live.com">liaochuntao</a>
|
||||
*/
|
||||
@SuppressWarnings("PMD.ClassNamingShouldBeCamelRule")
|
||||
public class RaftDBErrorEvent implements SlowEvent {
|
||||
public class RaftDbErrorEvent implements SlowEvent {
|
||||
|
||||
private static final long serialVersionUID = 101591819161802336L;
|
||||
|
||||
private Throwable ex;
|
||||
|
||||
public RaftDBErrorEvent() {
|
||||
public RaftDbErrorEvent() {
|
||||
}
|
||||
|
||||
public RaftDBErrorEvent(Throwable ex) {
|
||||
public RaftDbErrorEvent(Throwable ex) {
|
||||
this.ex = ex;
|
||||
}
|
||||
|
@ -24,8 +24,7 @@ import com.alibaba.nacos.core.notify.Event;
|
||||
*
|
||||
* @author <a href="mailto:liaochuntao@live.com">liaochuntao</a>
|
||||
*/
|
||||
@SuppressWarnings("PMD.ClassNamingShouldBeCamelRule")
|
||||
@JustForTest
|
||||
public class RaftDBErrorRecoverEvent implements Event {
|
||||
public class RaftDbErrorRecoverEvent implements Event {
|
||||
|
||||
}
|
@ -22,6 +22,8 @@ import com.alibaba.nacos.config.server.service.ConfigCacheService;
|
||||
import static com.alibaba.nacos.config.server.utils.LogUtil.MEMORY_LOG;
|
||||
|
||||
/**
|
||||
* Print memory task.
|
||||
*
|
||||
* @author zongtanghu
|
||||
*/
|
||||
public class PrintMemoryTask implements Runnable {
|
||||
|
@ -66,9 +66,9 @@ public interface DataSourceService {
|
||||
/**
|
||||
* Get current db url.
|
||||
*
|
||||
* @return
|
||||
* @return database url
|
||||
*/
|
||||
String getCurrentDBUrl();
|
||||
String getCurrentDbUrl();
|
||||
|
||||
/**
|
||||
* Get heath information.
|
||||
|
@ -117,13 +117,13 @@ public class ExternalDataSourceProperties {
|
||||
return dataSources;
|
||||
}
|
||||
|
||||
interface Callback<DataSource> {
|
||||
interface Callback<D> {
|
||||
|
||||
/**
|
||||
* Perform custom logic.
|
||||
*
|
||||
* @param dataSource dataSource.
|
||||
* @param datasource dataSource.
|
||||
*/
|
||||
void accept(DataSource dataSource);
|
||||
void accept(D datasource);
|
||||
}
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ public class ExternalDataSourceServiceImpl implements DataSourceService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrentDBUrl() {
|
||||
public String getCurrentDbUrl() {
|
||||
DataSource ds = this.jt.getDataSource();
|
||||
if (ds == null) {
|
||||
return StringUtils.EMPTY;
|
||||
|
@ -186,7 +186,7 @@ public class LocalDataSourceServiceImpl implements DataSourceService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrentDBUrl() {
|
||||
public String getCurrentDbUrl() {
|
||||
return "jdbc:derby:" + ApplicationUtils.getNacosHome() + File.separator + derbyBaseDir + ";create=true";
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,6 @@ public class DumpTask extends AbstractTask {
|
||||
|
||||
final String tag;
|
||||
|
||||
|
||||
public String getGroupKey() {
|
||||
return groupKey;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ import com.alibaba.nacos.config.server.constant.Constants;
|
||||
import com.alibaba.nacos.config.server.exception.NJdbcException;
|
||||
import com.alibaba.nacos.config.server.model.event.ConfigDumpEvent;
|
||||
import com.alibaba.nacos.config.server.model.event.DerbyLoadEvent;
|
||||
import com.alibaba.nacos.config.server.model.event.RaftDBErrorEvent;
|
||||
import com.alibaba.nacos.config.server.model.event.RaftDbErrorEvent;
|
||||
import com.alibaba.nacos.config.server.service.datasource.DynamicDataSource;
|
||||
import com.alibaba.nacos.config.server.service.datasource.LocalDataSourceServiceImpl;
|
||||
import com.alibaba.nacos.config.server.service.dump.DumpConfigHandler;
|
||||
@ -186,19 +186,19 @@ public class DistributedDatabaseOperateImpl extends LogProcessor4CP implements B
|
||||
this.transactionTemplate = dataSourceService.getTransactionTemplate();
|
||||
|
||||
// Registers a Derby Raft state machine failure event for node degradation processing
|
||||
NotifyCenter.registerToSharePublisher(RaftDBErrorEvent.class);
|
||||
NotifyCenter.registerToSharePublisher(RaftDbErrorEvent.class);
|
||||
// Register the snapshot load event
|
||||
NotifyCenter.registerToSharePublisher(DerbyLoadEvent.class);
|
||||
|
||||
NotifyCenter.registerSubscribe(new Subscribe<RaftDBErrorEvent>() {
|
||||
NotifyCenter.registerSubscribe(new Subscribe<RaftDbErrorEvent>() {
|
||||
@Override
|
||||
public void onEvent(RaftDBErrorEvent event) {
|
||||
public void onEvent(RaftDbErrorEvent event) {
|
||||
dataSourceService.setHealthStatus("DOWN");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Event> subscribeType() {
|
||||
return RaftDBErrorEvent.class;
|
||||
return RaftDbErrorEvent.class;
|
||||
}
|
||||
});
|
||||
|
||||
@ -549,7 +549,7 @@ public class DistributedDatabaseOperateImpl extends LogProcessor4CP implements B
|
||||
@Override
|
||||
public void onError(Throwable throwable) {
|
||||
// Trigger reversion strategy
|
||||
NotifyCenter.publishEvent(new RaftDBErrorEvent(throwable));
|
||||
NotifyCenter.publishEvent(new RaftDbErrorEvent(throwable));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -174,7 +174,7 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
|
||||
|
||||
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
|
||||
public String getCurrentDBUrl() {
|
||||
return this.dataSourceService.getCurrentDBUrl();
|
||||
return this.dataSourceService.getCurrentDbUrl();
|
||||
}
|
||||
|
||||
public DatabaseOperate getDatabaseOperate() {
|
||||
|
@ -166,7 +166,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
|
||||
|
||||
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
|
||||
public String getCurrentDBUrl() {
|
||||
return this.dataSourceService.getCurrentDBUrl();
|
||||
return this.dataSourceService.getCurrentDbUrl();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.example;
|
||||
|
||||
import java.util.Properties;
|
||||
@ -22,7 +23,7 @@ import com.alibaba.nacos.api.naming.NamingFactory;
|
||||
import com.alibaba.nacos.api.naming.NamingService;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
* Hello world.
|
||||
*
|
||||
* @author xxc
|
||||
*/
|
||||
|
@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.example;
|
||||
|
||||
import java.util.Properties;
|
||||
@ -24,7 +25,7 @@ import com.alibaba.nacos.api.config.listener.Listener;
|
||||
import com.alibaba.nacos.api.exception.NacosException;
|
||||
|
||||
/**
|
||||
* Config service example
|
||||
* Config service example.
|
||||
*
|
||||
* @author Nacos
|
||||
*/
|
||||
|
@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.nacos.example;
|
||||
|
||||
import java.util.Properties;
|
||||
@ -25,6 +26,8 @@ import com.alibaba.nacos.api.naming.listener.EventListener;
|
||||
import com.alibaba.nacos.api.naming.listener.NamingEvent;
|
||||
|
||||
/**
|
||||
* Nacos naming example.
|
||||
*
|
||||
* @author nkorange
|
||||
*/
|
||||
public class NamingExample {
|
||||
@ -50,8 +53,8 @@ public class NamingExample {
|
||||
naming.subscribe("nacos.test.3", new EventListener() {
|
||||
@Override
|
||||
public void onEvent(Event event) {
|
||||
System.out.println(((NamingEvent)event).getServiceName());
|
||||
System.out.println(((NamingEvent)event).getInstances());
|
||||
System.out.println(((NamingEvent) event).getServiceName());
|
||||
System.out.println(((NamingEvent) event).getInstances());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright 1999-2018 Alibaba Group Holding Ltd.
|
||||
*
|
||||
* Licensed 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 com.alibaba.nacos.example;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
public class AppTest
|
||||
extends TestCase {
|
||||
/**
|
||||
* Create the test case
|
||||
*
|
||||
* @param testName name of the test case
|
||||
*/
|
||||
public AppTest(String testName) {
|
||||
super(testName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the suite of tests being tested
|
||||
*/
|
||||
public static Test suite() {
|
||||
return new TestSuite(AppTest.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rigourous Test :-)
|
||||
*/
|
||||
public void testApp() {
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
@ -16,7 +16,6 @@
|
||||
|
||||
package com.alibaba.nacos.istio.mcp;
|
||||
|
||||
|
||||
/**
|
||||
* The collection types supported by Nacos.
|
||||
*
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
<module name="Checker">
|
||||
<property name="charset" value="UTF-8"/>
|
||||
<property name="severity" value="warning"/>
|
||||
<property name="severity" value="error"/>
|
||||
<property name="fileExtensions" value="java, properties, xml"/>
|
||||
|
||||
<module name="FileTabCharacter">
|
||||
@ -94,7 +94,7 @@
|
||||
<property name="minLineCount" value="2"/>
|
||||
<property name="allowedAnnotations"
|
||||
value="Override, Test, Before, After, BeforeClass, AfterClass, Parameterized, Parameters, Bean"/>
|
||||
<property name="ignoreMethodNamesRegex" value="^set[A-Z].*|^get[A-Z].*"/>
|
||||
<property name="ignoreMethodNamesRegex" value="^set[A-Z].*|^get[A-Z].*|main"/>
|
||||
<property name="tokens" value="METHOD_DEF, ANNOTATION_FIELD_DEF"/>
|
||||
</module>
|
||||
<module name="SingleLineJavadoc">
|
||||
|
@ -20,8 +20,8 @@ import com.alibaba.nacos.api.config.listener.AbstractListener;
|
||||
import com.alibaba.nacos.common.http.param.Header;
|
||||
import com.alibaba.nacos.common.http.param.Query;
|
||||
import com.alibaba.nacos.common.model.RestResult;
|
||||
import com.alibaba.nacos.config.server.model.event.RaftDBErrorEvent;
|
||||
import com.alibaba.nacos.config.server.model.event.RaftDBErrorRecoverEvent;
|
||||
import com.alibaba.nacos.config.server.model.event.RaftDbErrorEvent;
|
||||
import com.alibaba.nacos.config.server.model.event.RaftDbErrorRecoverEvent;
|
||||
import com.alibaba.nacos.config.server.service.repository.embedded.EmbeddedStoragePersistServiceImpl;
|
||||
import com.alibaba.nacos.config.server.service.repository.PersistService;
|
||||
import com.alibaba.nacos.consistency.cp.CPProtocol;
|
||||
@ -296,21 +296,21 @@ public class ConfigDerbyRaft_DITCase
|
||||
"this.is.raft_cluster=lessspring_7");
|
||||
Assert.assertTrue(result);
|
||||
|
||||
NotifyCenter.registerToPublisher(RaftDBErrorRecoverEvent.class, 8);
|
||||
NotifyCenter.registerToPublisher(RaftDbErrorRecoverEvent.class, 8);
|
||||
|
||||
CountDownLatch latch1 = new CountDownLatch(1);
|
||||
NotifyCenter.registerSubscribe(new Subscribe<RaftDBErrorEvent>() {
|
||||
NotifyCenter.registerSubscribe(new Subscribe<RaftDbErrorEvent>() {
|
||||
@Override
|
||||
public void onEvent(RaftDBErrorEvent event) {
|
||||
public void onEvent(RaftDbErrorEvent event) {
|
||||
latch1.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Event> subscribeType() {
|
||||
return RaftDBErrorEvent.class;
|
||||
return RaftDbErrorEvent.class;
|
||||
}
|
||||
});
|
||||
NotifyCenter.publishEvent(new RaftDBErrorEvent());
|
||||
NotifyCenter.publishEvent(new RaftDbErrorEvent());
|
||||
latch1.await(10_000L, TimeUnit.MILLISECONDS);
|
||||
|
||||
result = iconfig7.publishConfig("raft_test_raft_error", "cluster_test_1",
|
||||
@ -318,19 +318,19 @@ public class ConfigDerbyRaft_DITCase
|
||||
Assert.assertFalse(result);
|
||||
|
||||
CountDownLatch latch2 = new CountDownLatch(1);
|
||||
NotifyCenter.registerSubscribe(new Subscribe<RaftDBErrorRecoverEvent>() {
|
||||
NotifyCenter.registerSubscribe(new Subscribe<RaftDbErrorRecoverEvent>() {
|
||||
|
||||
@Override
|
||||
public void onEvent(RaftDBErrorRecoverEvent event) {
|
||||
public void onEvent(RaftDbErrorRecoverEvent event) {
|
||||
latch2.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Event> subscribeType() {
|
||||
return RaftDBErrorRecoverEvent.class;
|
||||
return RaftDbErrorRecoverEvent.class;
|
||||
}
|
||||
});
|
||||
NotifyCenter.publishEvent(new RaftDBErrorRecoverEvent());
|
||||
NotifyCenter.publishEvent(new RaftDbErrorRecoverEvent());
|
||||
latch2.await(10_000L, TimeUnit.MILLISECONDS);
|
||||
|
||||
result = iconfig7.publishConfig("raft_test_raft_error", "cluster_test_1",
|
||||
@ -411,4 +411,4 @@ public class ConfigDerbyRaft_DITCase
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ import com.alibaba.nacos.api.naming.NamingService;
|
||||
import com.alibaba.nacos.common.http.HttpClientManager;
|
||||
import com.alibaba.nacos.common.http.NSyncHttpClient;
|
||||
import com.alibaba.nacos.core.utils.DiskUtils;
|
||||
import com.alibaba.nacos.config.server.model.event.RaftDBErrorEvent;
|
||||
import com.alibaba.nacos.config.server.model.event.RaftDbErrorEvent;
|
||||
import com.alibaba.nacos.config.server.service.repository.embedded.DistributedDatabaseOperateImpl;
|
||||
import com.alibaba.nacos.consistency.cp.CPProtocol;
|
||||
import com.alibaba.nacos.consistency.cp.MetadataKey;
|
||||
@ -84,15 +84,15 @@ public class BaseClusterTest extends HttpClient4Test {
|
||||
clusterInfo = "nacos.member.list=" + ip + ":8847," + ip
|
||||
+ ":8848," + ip + ":8849";
|
||||
|
||||
NotifyCenter.registerSubscribe(new Subscribe<RaftDBErrorEvent>() {
|
||||
NotifyCenter.registerSubscribe(new Subscribe<RaftDbErrorEvent>() {
|
||||
@Override
|
||||
public void onEvent(RaftDBErrorEvent event) {
|
||||
public void onEvent(RaftDbErrorEvent event) {
|
||||
System.out.print(event.getEx());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Event> subscribeType() {
|
||||
return RaftDBErrorEvent.class;
|
||||
return RaftDbErrorEvent.class;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user