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

Fix typo,Add @Override,Remove  prefix "I" #8

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -15,11 +15,11 @@
*/
package com.alibaba.nacos.api.config;

import java.lang.reflect.Constructor;
import java.util.Properties;

import com.alibaba.nacos.api.PropertyKeyConst;
import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.client.config.NacosConfigService;

/**
* Config Factory
Expand All @@ -39,20 +39,13 @@ public class ConfigFactory {
* Exception
*/
public static ConfigService createConfigService(Properties properties) throws NacosException {
try {
Class<?> driverImplClass = Class.forName("com.alibaba.nacos.client.config.NacosConfigService");
Constructor constructor = driverImplClass.getConstructor(Properties.class);
ConfigService vendorImpl = (ConfigService) constructor.newInstance(properties);
return vendorImpl;
} catch (Throwable e) {
throw new NacosException(-400, e.getMessage());
}
return new NacosConfigService(properties);
}

/**
* Create Config
*
* @param ServerAddr
* @param serverAddr
* serverlist
* @return Config
* @throws NacosException
Expand All @@ -61,14 +54,7 @@ public static ConfigService createConfigService(Properties properties) throws Na
public static ConfigService createConfigService(String serverAddr) throws NacosException {
Properties properties = new Properties();
properties.put(PropertyKeyConst.SERVER_ADDR, serverAddr);
try {
Class<?> driverImplClass = Class.forName("com.alibaba.nacos.client.config.NacosConfigService");
Constructor constructor = driverImplClass.getConstructor(Properties.class);
ConfigService vendorImpl = (ConfigService) constructor.newInstance(properties);
return vendorImpl;
} catch (Throwable e) {
throw new NacosException(-400, e.getMessage());
}
return new NacosConfigService(properties);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,5 @@ public interface ConfigService {
* listener
*/
public void removeListener(String dataId, String group, Listener listener);

/**
* server health info
*
* @return whether health
*/
public String getServerStatus();

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* @author Nacos
*
*/
public interface IConfigContext {
public interface ConfigContext {
/**
* get context by key
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
* @author Nacos
*
*/
public interface IConfigFilter {
public interface ConfigFilter {
/**
* Init Fuction
*
* @param filterConfig
* Filter Config
*/
void init(IFilterConfig filterConfig);
void init(FilterConfig filterConfig);

/**
* do filter
Expand All @@ -44,7 +44,7 @@ public interface IConfigFilter {
* @throws NacosException
* exception
*/
void doFilter(IConfigRequest request, IConfigResponse response, IConfigFilterChain filterChain)
void doFilter(ConfigRequest request, ConfigResponse response, ConfigFilterChain filterChain)
throws NacosException;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* @author Nacos
*
*/
public interface IConfigFilterChain {
public interface ConfigFilterChain {
/**
* Filter aciton
*
Expand All @@ -34,6 +34,6 @@ public interface IConfigFilterChain {
* @throws NacosException
* NacosException
*/
public void doFilter(IConfigRequest request, IConfigResponse response) throws NacosException;
public void doFilter(ConfigRequest request, ConfigResponse response) throws NacosException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* @author Nacos
*
*/
public interface IConfigRequest {
public interface ConfigRequest {
/**
* get param
*
Expand All @@ -36,6 +36,6 @@ public interface IConfigRequest {
*
* @return
*/
public IConfigContext getConfigContext();
public ConfigContext getConfigContext();

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* @author Nacos
*
*/
public interface IConfigResponse {
public interface ConfigResponse {
/**
* get param
*
Expand All @@ -36,6 +36,6 @@ public interface IConfigResponse {
*
* @return configContext
*/
public IConfigContext getConfigContext();
public ConfigContext getConfigContext();

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @author Nacos
*
*/
public interface IFilterConfig {
public interface FilterConfig {

/**
* get filter name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public abstract class AbstractListener implements Listener {
/**
* use default Executor
*/
@Override
public Executor getExecutor() {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.nacos.client;
package com.alibaba.nacos.api.naming;

import org.junit.Test;
import java.util.Properties;

import com.alibaba.nacos.client.naming.NacosNamingService;

/**
* @author dungu.zpf
*/
public class NamingTest {

@Test
public void testServiceList() {

}
public class NamingFactory {

public static NamingService createNamingService(String serverList) {
return new NacosNamingService(serverList);
}

public static NamingService createNamingService(Properties properties) {
return new NacosNamingService(properties);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
*/
package com.alibaba.nacos.api.naming;

import java.util.List;

import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.listener.EventListener;
import com.alibaba.nacos.api.naming.pojo.Instance;
import com.alibaba.nacos.api.naming.pojo.ListView;
import com.alibaba.nacos.api.naming.pojo.ServiceInfo;

import java.util.List;

/**
* @author dungu.zpf
Expand Down Expand Up @@ -74,7 +72,7 @@ public interface NamingService {
* @param serviceName name of service
* @param ip instance ip
* @param port instance port
* @param clusterName instance cluster name
* @param clusterName instance cluster name
* @throws NacosException
*/
void deregisterInstance(String serviceName, String ip, int port, String clusterName) throws NacosException;
Expand Down Expand Up @@ -175,29 +173,4 @@ public interface NamingService {
* @throws NacosException
*/
void unsubscribe(String serviceName, List<String> clusters, EventListener listener) throws NacosException;

/**
* Get all service names from server
*
* @param pageNo page index
* @param pageSize page size
* @return list of service names
* @throws NacosException
*/
ListView<String> getServicesOfServer(int pageNo, int pageSize) throws NacosException;

/**
* Get all subscribed services of current client
*
* @return subscribed services
* @throws NacosException
*/
List<ServiceInfo> getSubscribeServices() throws NacosException;

/**
* Get server health status
*
* @return is server healthy
*/
String getServerStatus();
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package com.alibaba.nacos.api.naming.pojo;

import com.alibaba.nacos.client.naming.utils.StringUtils;

import java.util.Objects;

/**
Expand All @@ -35,8 +37,8 @@ public void setType(String type) {
public static class Http extends AbstractHealthChecker {
public static final String TYPE = "HTTP";

private String path = "";
private String headers = "";
private String path = StringUtils.EMPTY;
private String headers = StringUtils.EMPTY;

private int expectedResponseCode = 200;

Expand Down Expand Up @@ -81,14 +83,14 @@ public boolean equals(Object obj) {

Http other = (Http) obj;

if (!strEquals(type, other.getType())) {
if (!StringUtils.equals(type, other.getType())) {
return false;
}

if (!strEquals(path, other.getPath())) {
if (!StringUtils.equals(path, other.getPath())) {
return false;
}
if (!strEquals(headers, other.getHeaders())) {
if (!StringUtils.equals(headers, other.getHeaders())) {
return false;
}
return expectedResponseCode == other.getExpectedResponseCode();
Expand Down Expand Up @@ -162,20 +164,16 @@ public boolean equals(Object obj) {

Mysql other = (Mysql) obj;

if (!strEquals(user, other.getUser())) {
if (!StringUtils.equals(user, other.getUser())) {
return false;
}

if (!strEquals(pwd, other.getPwd())) {
if (!StringUtils.equals(pwd, other.getPwd())) {
return false;
}

return strEquals(cmd, other.getCmd());
return StringUtils.equals(cmd, other.getCmd());

}
}

private static boolean strEquals(String str1, String str2) {
return str1 == null ? str2 == null : str1.equals(str2);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package com.alibaba.nacos.api.naming.pojo;

import com.alibaba.nacos.client.naming.utils.StringUtils;

import java.util.HashMap;
import java.util.Map;

Expand All @@ -31,7 +33,7 @@ public class Cluster {
/**
* Name of cluster
*/
private String name = "";
private String name = StringUtils.EMPTY;

/**
* Health check config of this cluster
Expand All @@ -54,7 +56,7 @@ public class Cluster {
private boolean useIPPort4Check = true;


private Map<String, String> metadata = new HashMap<String, String>();
private Map<String, String> metadata = new HashMap<>();

public Cluster() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.nacos.api.common.Constants;
import com.alibaba.nacos.client.naming.utils.StringUtils;

import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -68,7 +68,7 @@ public class Instance {
/**
* User extended attributes
*/
private Map<String, String> metadata = new HashMap<String, String>();
private Map<String, String> metadata = new HashMap<>();

public String getInstanceId() {
return instanceId;
Expand All @@ -78,14 +78,6 @@ public void setInstanceId(String instanceId) {
this.instanceId = instanceId;
}

public String serviceName() {
String[] infos = instanceId.split(Constants.NAMING_INSTANCE_ID_SPLITTER);
if (infos.length < Constants.NAMING_INSTANCE_ID_SEG_COUNT) {
return null;
}
return infos[Constants.NAMING_INSTANCE_ID_SEG_COUNT - 1];
}

public String getIp() {
return ip;
}
Expand Down Expand Up @@ -163,16 +155,12 @@ public boolean equals(Object obj) {

Instance host = (Instance) obj;

return strEquals(toString(), host.toString());
return StringUtils.equals(toString(), host.toString());
}

@Override
public int hashCode() {
return toString().hashCode();
}

private static boolean strEquals(String str1, String str2) {
return str1 == null ? str2 == null : str1.equals(str2);
}

}
Loading