Skip to content

Commit

Permalink
[ISSUE #3107] Style format core (#3108)
Browse files Browse the repository at this point in the history
* improvement: merge upstream/develop

* style: format code style

* style: modify pom.xml

* fix: fix code style
  • Loading branch information
chuntaojun authored Jun 18, 2020
1 parent 961f0d1 commit 9a44b92
Show file tree
Hide file tree
Showing 137 changed files with 9,080 additions and 8,751 deletions.
98 changes: 49 additions & 49 deletions consistency/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,12 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<parent>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-all</artifactId>
<version>1.3.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<artifactId>nacos-consistency</artifactId>
<packaging>jar</packaging>

<name>nacos-consistency ${project.version}</name>
<url>http://nacos.io</url>

<build>
<extensions>
<extension>
Expand All @@ -41,40 +29,36 @@
</extension>
</extensions>
<plugins>
<!-- Grpc coding plug-in-->
<!-- <plugin>-->
<!-- <groupId>org.xolstice.maven.plugins</groupId>-->
<!-- <artifactId>protobuf-maven-plugin</artifactId>-->
<!-- <version>0.5.0</version>-->
<!-- <configuration>-->
<!-- <protocArtifact>com.google.protobuf:protoc:${protobuf-java.version}:exe:${os.detected.classifier}</protocArtifact>-->
<!-- <pluginId>grpc-java</pluginId>-->
<!-- <pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc-java.version}:exe:${os.detected.classifier}</pluginArtifact>-->
<!-- </configuration>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <goals>-->
<!-- <goal>compile</goal>-->
<!-- <goal>compile-custom</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-compiler-plugin</artifactId>-->
<!-- <configuration>-->
<!-- <source>8</source>-->
<!-- <target>8</target>-->
<!-- </configuration>-->
<!-- </plugin>-->
<!-- Grpc coding plug-in-->
<!-- <plugin>-->
<!-- <groupId>org.xolstice.maven.plugins</groupId>-->
<!-- <artifactId>protobuf-maven-plugin</artifactId>-->
<!-- <version>0.5.0</version>-->
<!-- <configuration>-->
<!-- <protocArtifact>com.google.protobuf:protoc:${protobuf-java.version}:exe:${os.detected.classifier}</protocArtifact>-->
<!-- <pluginId>grpc-java</pluginId>-->
<!-- <pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc-java.version}:exe:${os.detected.classifier}</pluginArtifact>-->
<!-- </configuration>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <goals>-->
<!-- <goal>compile</goal>-->
<!-- <goal>compile-custom</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-compiler-plugin</artifactId>-->
<!-- <configuration>-->
<!-- <source>8</source>-->
<!-- <target>8</target>-->
<!-- </configuration>-->
<!-- </plugin>-->
</plugins>
</build>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>


<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
Expand All @@ -93,5 +77,21 @@
<artifactId>protobuf-java</artifactId>
</dependency>
</dependencies>
<modelVersion>4.0.0</modelVersion>

<name>nacos-consistency ${project.version}</name>
<packaging>jar</packaging>
<parent>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-all</artifactId>
<relativePath>../pom.xml</relativePath>
<version>1.3.0</version>
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<url>http://nacos.io</url>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,20 @@
import java.util.Map;

/**
* Operation and maintenance command interface.
*
* @author <a href="mailto:[email protected]">liaochuntao</a>
*/
public interface CommandOperations {

/**
* Operation and maintenance interface operation entry
*
* @param commands commands
* @return execute success
*/
default RestResult<String> execute(Map<String, String> commands) {
return RestResultUtils.success();
}

/**
* Operation and maintenance interface operation entry.
*
* @param commands commands
* @return execute success
*/
default RestResult<String> execute(Map<String, String> commands) {
return RestResultUtils.success();
}
}
57 changes: 27 additions & 30 deletions consistency/src/main/java/com/alibaba/nacos/consistency/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,83 +17,80 @@
package com.alibaba.nacos.consistency;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Set;

/**
* Consistent protocol related configuration objects
* Consistent protocol related configuration objects.
*
* {@link LogProcessor} : The consistency protocol provides services for all businesses,
* but each business only cares about the transaction information belonging to that business,
* and the transaction processing between the various services should not block each other. Therefore,
* the LogProcessor is abstracted to implement the parallel processing of transactions of different services.
* Corresponding LogProcessor sub-interface: LogProcessor4AP or LogProcessor4CP, different consistency
* protocols will actively discover the corresponding LogProcessor
* <p>{@link LogProcessor} : The consistency protocol provides services for all businesses, but each business only cares
* about the transaction information belonging to that business, and the transaction processing between the various
* services should not block each other. Therefore, the LogProcessor is abstracted to implement the parallel processing
* of transactions of different services. Corresponding LogProcessor sub-interface: LogProcessor4AP or LogProcessor4CP,
* different consistency protocols will actively discover the corresponding LogProcessor
*
* @author <a href="mailto:[email protected]">liaochuntao</a>
*/
public interface Config<L extends LogProcessor> extends Serializable {

/**
* Set the cluster node information to initialize,like [ip:port, ip:port, ip:port]
* Set the cluster node information to initialize,like [ip:port, ip:port, ip:port].
*
* @param self local node address information, ip:port
* @param members {@link Set<String>}
* @param self local node address information, ip:port
* @param members {@link Set}
*/
void setMembers(String self, Set<String> members);

/**
* members join
* members join.
*
* @param members {@link Set<String>}
* @param members {@link Set}
*/
void addMembers(Set<String> members);

/**
* members leave
* members leave.
*
* @param members {@link Set<String>}
* @param members {@link Set}
*/
void removeMembers(Set<String> members);

/**
* get local node address info
* get local node address info.
*
* @return address
*/
String getSelfMember();

/**
* get the cluster node information
* get the cluster node information.
*
* @return members info, like [ip:port, ip:port, ip:port]
*/
Set<String> getMembers();

/**
* Add configuration content
* Add configuration content.
*
* @param key config key
* @param value config value
*/
void setVal(String key, String value);

/**
* get configuration content by key
* get configuration content by key.
*
* @param key config key
* @return config value
*/
String getVal(String key);

/**
* get configuration content by key, if not found, use default-val
* get configuration content by key, if not found, use default-val.
*
* @param key config key
* @param defaultVal default value
* @return config value
*/
String getValOfDefault(String key, String defaultVal);

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.alibaba.nacos.consistency;


import com.alibaba.nacos.consistency.entity.GetRequest;
import com.alibaba.nacos.consistency.entity.Log;
import com.alibaba.nacos.consistency.entity.Response;
Expand All @@ -26,8 +25,7 @@
import java.util.concurrent.CompletableFuture;

/**
* Has nothing to do with the specific implementation of the consistency protocol
* Initialization sequence: init(Config)
* Has nothing to do with the specific implementation of the consistency protocol Initialization sequence: init(Config).
*
* <ul>
* <li>{@link Config} : Relevant configuration information required by the consistency protocol,
Expand All @@ -40,79 +38,79 @@
* @author <a href="mailto:[email protected]">liaochuntao</a>
*/
public interface ConsistencyProtocol<T extends Config, P extends LogProcessor> extends CommandOperations {

/**
* Consistency protocol initialization: perform initialization operations based on the incoming Config
* 一致性协议初始化,根据 Config 实现类
* Consistency protocol initialization: perform initialization operations based on the incoming.
* Config 一致性协议初始化,根据Config 实现类
*
* @param config {@link Config}
*/
void init(T config);

/**
* Add a log handler
* Add a log handler.
*
* @param processors {@link LogProcessor}
*/
void addLogProcessors(Collection<P> processors);

/**
* Copy of metadata information for this consensus protocol
* Copy of metadata information for this consensus protocol.
* 该一致性协议的元数据信息
*
* @return metaData {@link ProtocolMetaData}
*/
ProtocolMetaData protocolMetaData();

/**
* Obtain data according to the request
* Obtain data according to the request.
*
* @param request request
* @return data {@link Response}
* @throws Exception
* @throws Exception {@link Exception}
*/
Response getData(GetRequest request) throws Exception;

/**
* Get data asynchronously
* Get data asynchronously.
*
* @param request request
* @return data {@link CompletableFuture<Response>}
* @return data {@link CompletableFuture}
*/
CompletableFuture<Response> aGetData(GetRequest request);

/**
* Data operation, returning submission results synchronously
* Data operation, returning submission results synchronously.
* 同步数据提交,在 Datum 中已携带相应的数据操作信息
*
* @param data {@link Log}
* @return submit operation result {@link Response}
* @throws Exception
* @throws Exception {@link Exception}
*/
Response submit(Log data) throws Exception;

/**
* Data submission operation, returning submission results asynchronously
* 异步数据提交,在 Datum 中已携带相应的数据操作信息,返回一个Future,自行操作,提交发生的异常会在CompleteFuture中
* Data submission operation, returning submission results asynchronously.
* 异步数据提交,在 Datum中已携带相应的数据操作信息,返回一个Future,自行操作,提交发生的异常会在CompleteFuture中
*
* @param data {@link Log}
* @return {@link CompletableFuture<Response>} submit result
* @return {@link CompletableFuture} submit result
* @throws Exception when submit throw Exception
*/
CompletableFuture<Response> submitAsync(Log data);

/**
* New member list
* New member list .
* 新的成员节点列表,一致性协议自行处理相应的成员节点是加入还是离开
*
* @param addresses [ip:port, ip:port, ...]
*/
void memberChange(Set<String> addresses);

/**
* Consistency agreement service shut down
* Consistency agreement service shut down .
* 一致性协议服务关闭
*/
void shutdown();

}
Loading

0 comments on commit 9a44b92

Please sign in to comment.