[ISSUE#8485] (module-client) replace the type specification in this constructor call with the diamond operator ("<>") (#8498)
This commit is contained in:
parent
e66a1903f3
commit
ce41075de6
@ -67,8 +67,8 @@ public class HttpLoginProcessor implements LoginProcessor {
|
||||
url = server + contextPath + LOGIN_URL;
|
||||
}
|
||||
|
||||
Map<String, String> params = new HashMap<String, String>(2);
|
||||
Map<String, String> bodyMap = new HashMap<String, String>(2);
|
||||
Map<String, String> params = new HashMap<>(2);
|
||||
Map<String, String> bodyMap = new HashMap<>(2);
|
||||
params.put(PropertyKeyConst.USERNAME, properties.getProperty(PropertyKeyConst.USERNAME, StringUtils.EMPTY));
|
||||
bodyMap.put(PropertyKeyConst.PASSWORD, properties.getProperty(PropertyKeyConst.PASSWORD, StringUtils.EMPTY));
|
||||
try {
|
||||
|
@ -31,7 +31,7 @@ public final class CredentialService implements SpasCredentialLoader {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.logger(CredentialService.class);
|
||||
|
||||
private static final ConcurrentHashMap<String, CredentialService> INSTANCES = new ConcurrentHashMap<String, CredentialService>();
|
||||
private static final ConcurrentHashMap<String, CredentialService> INSTANCES = new ConcurrentHashMap<>();
|
||||
|
||||
private final String appName;
|
||||
|
||||
|
@ -45,7 +45,7 @@ public class SpasAdapter {
|
||||
private static final String SHA_ENCRYPT = "HmacSHA1";
|
||||
|
||||
public static Map<String, String> getSignHeaders(String resource, String secretKey) {
|
||||
Map<String, String> header = new HashMap<String, String>(2);
|
||||
Map<String, String> header = new HashMap<>(2);
|
||||
String timeStamp = String.valueOf(System.currentTimeMillis());
|
||||
header.put(TIMESTAMP_HEADER, timeStamp);
|
||||
if (secretKey != null) {
|
||||
|
@ -28,7 +28,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class ConfigContext implements IConfigContext {
|
||||
|
||||
private final Map<String, Object> param = new HashMap<String, Object>();
|
||||
private final Map<String, Object> param = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public Object getParameter(String key) {
|
||||
|
@ -36,7 +36,7 @@ import static com.alibaba.nacos.client.config.common.ConfigConstants.TYPE;
|
||||
*/
|
||||
public class ConfigRequest implements IConfigRequest {
|
||||
|
||||
private final Map<String, Object> param = new HashMap<String, Object>();
|
||||
private final Map<String, Object> param = new HashMap<>();
|
||||
|
||||
private final IConfigContext configContext = new ConfigContext();
|
||||
|
||||
|
@ -36,7 +36,7 @@ import static com.alibaba.nacos.client.config.common.ConfigConstants.TENANT;
|
||||
*/
|
||||
public class ConfigResponse implements IConfigResponse {
|
||||
|
||||
private final Map<String, Object> param = new HashMap<String, Object>();
|
||||
private final Map<String, Object> param = new HashMap<>();
|
||||
|
||||
private final IConfigContext configContext = new ConfigContext();
|
||||
|
||||
|
@ -42,7 +42,7 @@ public abstract class AbstractConfigChangeParser implements ConfigChangeParser {
|
||||
}
|
||||
|
||||
protected Map<String, ConfigChangeItem> filterChangeData(Map oldMap, Map newMap) {
|
||||
Map<String, ConfigChangeItem> result = new HashMap<String, ConfigChangeItem>(16);
|
||||
Map<String, ConfigChangeItem> result = new HashMap<>(16);
|
||||
for (Map.Entry<String, Object> e : (Iterable<Map.Entry<String, Object>>) oldMap.entrySet()) {
|
||||
ConfigChangeItem cci;
|
||||
if (newMap.containsKey(e.getKey())) {
|
||||
|
@ -202,7 +202,7 @@ public class CacheData {
|
||||
* Returns the iterator on the listener list, read-only. It is guaranteed not to return NULL.
|
||||
*/
|
||||
public List<Listener> getListeners() {
|
||||
List<Listener> result = new ArrayList<Listener>();
|
||||
List<Listener> result = new ArrayList<>();
|
||||
for (ManagerListenerWrap wrap : listeners) {
|
||||
result.add(wrap.listener);
|
||||
}
|
||||
|
@ -521,7 +521,7 @@ public class ClientWorker implements Closeable {
|
||||
|
||||
public class ConfigRpcTransportClient extends ConfigTransportClient {
|
||||
|
||||
private final BlockingQueue<Object> listenExecutebell = new ArrayBlockingQueue<Object>(1);
|
||||
private final BlockingQueue<Object> listenExecutebell = new ArrayBlockingQueue<>(1);
|
||||
|
||||
private Object bellItem = new Object();
|
||||
|
||||
@ -575,7 +575,7 @@ public class ClientWorker implements Closeable {
|
||||
|
||||
private Map<String, String> getLabels() {
|
||||
|
||||
Map<String, String> labels = new HashMap<String, String>(2, 1);
|
||||
Map<String, String> labels = new HashMap<>(2, 1);
|
||||
labels.put(RemoteConstants.LABEL_SOURCE, RemoteConstants.LABEL_SOURCE_SDK);
|
||||
labels.put(RemoteConstants.LABEL_MODULE, RemoteConstants.LABEL_MODULE_CONFIG);
|
||||
labels.put(Constants.APPNAME, AppNameUtils.getAppName());
|
||||
@ -714,8 +714,8 @@ public class ClientWorker implements Closeable {
|
||||
@Override
|
||||
public void executeConfigListen() {
|
||||
|
||||
Map<String, List<CacheData>> listenCachesMap = new HashMap<String, List<CacheData>>(16);
|
||||
Map<String, List<CacheData>> removeListenCachesMap = new HashMap<String, List<CacheData>>(16);
|
||||
Map<String, List<CacheData>> listenCachesMap = new HashMap<>(16);
|
||||
Map<String, List<CacheData>> removeListenCachesMap = new HashMap<>(16);
|
||||
long now = System.currentTimeMillis();
|
||||
boolean needAllSync = now - lastAllSyncTime >= ALL_SYNC_INTERNAL;
|
||||
for (CacheData cache : cacheMap.get().values()) {
|
||||
@ -778,7 +778,7 @@ public class ClientWorker implements Closeable {
|
||||
rpcClient, configChangeListenRequest);
|
||||
if (configChangeBatchListenResponse != null && configChangeBatchListenResponse.isSuccess()) {
|
||||
|
||||
Set<String> changeKeys = new HashSet<String>();
|
||||
Set<String> changeKeys = new HashSet<>();
|
||||
//handle changed keys,notify listener
|
||||
if (!CollectionUtils.isEmpty(configChangeBatchListenResponse.getChangedConfigs())) {
|
||||
hasChangedKeys = true;
|
||||
|
@ -40,7 +40,7 @@ public class ConfigChangeHandler {
|
||||
}
|
||||
|
||||
private ConfigChangeHandler() {
|
||||
this.parserList = new LinkedList<ConfigChangeParser>();
|
||||
this.parserList = new LinkedList<>();
|
||||
|
||||
Collection<ConfigChangeParser> loader = NacosServiceLoader.load(ConfigChangeParser.class);
|
||||
Iterator<ConfigChangeParser> itr = loader.iterator();
|
||||
|
@ -104,7 +104,7 @@ public abstract class ConfigTransportClient {
|
||||
* @return headers.
|
||||
*/
|
||||
protected Map<String, String> getCommonHeader() {
|
||||
Map<String, String> headers = new HashMap<String, String>(16);
|
||||
Map<String, String> headers = new HashMap<>(16);
|
||||
|
||||
String ts = String.valueOf(System.currentTimeMillis());
|
||||
String token = MD5Utils.md5Hex(ts + ParamUtil.getAppKey(), Constants.ENCODE);
|
||||
|
@ -77,7 +77,7 @@ public class YmlChangeParser extends AbstractConfigChangeParser {
|
||||
}
|
||||
|
||||
private Map<String, Object> getFlattenedMap(Map<String, Object> source) {
|
||||
Map<String, Object> result = new LinkedHashMap<String, Object>(128);
|
||||
Map<String, Object> result = new LinkedHashMap<>(128);
|
||||
buildFlattenedMap(result, source, null);
|
||||
return result;
|
||||
}
|
||||
|
@ -186,23 +186,23 @@ public class NacosNamingService implements NamingService {
|
||||
|
||||
@Override
|
||||
public List<Instance> getAllInstances(String serviceName) throws NacosException {
|
||||
return getAllInstances(serviceName, new ArrayList<String>());
|
||||
return getAllInstances(serviceName, new ArrayList<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Instance> getAllInstances(String serviceName, String groupName) throws NacosException {
|
||||
return getAllInstances(serviceName, groupName, new ArrayList<String>());
|
||||
return getAllInstances(serviceName, groupName, new ArrayList<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Instance> getAllInstances(String serviceName, boolean subscribe) throws NacosException {
|
||||
return getAllInstances(serviceName, new ArrayList<String>(), subscribe);
|
||||
return getAllInstances(serviceName, new ArrayList<>(), subscribe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Instance> getAllInstances(String serviceName, String groupName, boolean subscribe)
|
||||
throws NacosException {
|
||||
return getAllInstances(serviceName, groupName, new ArrayList<String>(), subscribe);
|
||||
return getAllInstances(serviceName, groupName, new ArrayList<>(), subscribe);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -237,14 +237,14 @@ public class NacosNamingService implements NamingService {
|
||||
}
|
||||
List<Instance> list;
|
||||
if (serviceInfo == null || CollectionUtils.isEmpty(list = serviceInfo.getHosts())) {
|
||||
return new ArrayList<Instance>();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Instance> selectInstances(String serviceName, boolean healthy) throws NacosException {
|
||||
return selectInstances(serviceName, new ArrayList<String>(), healthy);
|
||||
return selectInstances(serviceName, new ArrayList<>(), healthy);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -255,13 +255,13 @@ public class NacosNamingService implements NamingService {
|
||||
@Override
|
||||
public List<Instance> selectInstances(String serviceName, boolean healthy, boolean subscribe)
|
||||
throws NacosException {
|
||||
return selectInstances(serviceName, new ArrayList<String>(), healthy, subscribe);
|
||||
return selectInstances(serviceName, new ArrayList<>(), healthy, subscribe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Instance> selectInstances(String serviceName, String groupName, boolean healthy, boolean subscribe)
|
||||
throws NacosException {
|
||||
return selectInstances(serviceName, groupName, new ArrayList<String>(), healthy, subscribe);
|
||||
return selectInstances(serviceName, groupName, new ArrayList<>(), healthy, subscribe);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -302,7 +302,7 @@ public class NacosNamingService implements NamingService {
|
||||
private List<Instance> selectInstances(ServiceInfo serviceInfo, boolean healthy) {
|
||||
List<Instance> list;
|
||||
if (serviceInfo == null || CollectionUtils.isEmpty(list = serviceInfo.getHosts())) {
|
||||
return new ArrayList<Instance>();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
Iterator<Instance> iterator = list.iterator();
|
||||
@ -318,7 +318,7 @@ public class NacosNamingService implements NamingService {
|
||||
|
||||
@Override
|
||||
public Instance selectOneHealthyInstance(String serviceName) throws NacosException {
|
||||
return selectOneHealthyInstance(serviceName, new ArrayList<String>());
|
||||
return selectOneHealthyInstance(serviceName, new ArrayList<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -328,13 +328,13 @@ public class NacosNamingService implements NamingService {
|
||||
|
||||
@Override
|
||||
public Instance selectOneHealthyInstance(String serviceName, boolean subscribe) throws NacosException {
|
||||
return selectOneHealthyInstance(serviceName, new ArrayList<String>(), subscribe);
|
||||
return selectOneHealthyInstance(serviceName, new ArrayList<>(), subscribe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instance selectOneHealthyInstance(String serviceName, String groupName, boolean subscribe)
|
||||
throws NacosException {
|
||||
return selectOneHealthyInstance(serviceName, groupName, new ArrayList<String>(), subscribe);
|
||||
return selectOneHealthyInstance(serviceName, groupName, new ArrayList<>(), subscribe);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -373,12 +373,12 @@ public class NacosNamingService implements NamingService {
|
||||
|
||||
@Override
|
||||
public void subscribe(String serviceName, EventListener listener) throws NacosException {
|
||||
subscribe(serviceName, new ArrayList<String>(), listener);
|
||||
subscribe(serviceName, new ArrayList<>(), listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subscribe(String serviceName, String groupName, EventListener listener) throws NacosException {
|
||||
subscribe(serviceName, groupName, new ArrayList<String>(), listener);
|
||||
subscribe(serviceName, groupName, new ArrayList<>(), listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -399,12 +399,12 @@ public class NacosNamingService implements NamingService {
|
||||
|
||||
@Override
|
||||
public void unsubscribe(String serviceName, EventListener listener) throws NacosException {
|
||||
unsubscribe(serviceName, new ArrayList<String>(), listener);
|
||||
unsubscribe(serviceName, new ArrayList<>(), listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsubscribe(String serviceName, String groupName, EventListener listener) throws NacosException {
|
||||
unsubscribe(serviceName, groupName, new ArrayList<String>(), listener);
|
||||
unsubscribe(serviceName, groupName, new ArrayList<>(), listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,9 +59,9 @@ public class FailoverReactor implements Closeable {
|
||||
|
||||
private static final String FAILOVER_MODE_PARAM = "failover-mode";
|
||||
|
||||
private Map<String, ServiceInfo> serviceMap = new ConcurrentHashMap<String, ServiceInfo>();
|
||||
private Map<String, ServiceInfo> serviceMap = new ConcurrentHashMap<>();
|
||||
|
||||
private final Map<String, String> switchParams = new ConcurrentHashMap<String, String>();
|
||||
private final Map<String, String> switchParams = new ConcurrentHashMap<>();
|
||||
|
||||
private static final long DAY_PERIOD_MINUTES = 24 * 60;
|
||||
|
||||
@ -184,7 +184,7 @@ public class FailoverReactor implements Closeable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Map<String, ServiceInfo> domMap = new HashMap<String, ServiceInfo>(16);
|
||||
Map<String, ServiceInfo> domMap = new HashMap<>(16);
|
||||
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
|
@ -56,7 +56,7 @@ public class BeatReactor implements Closeable {
|
||||
|
||||
private boolean lightBeatEnabled = false;
|
||||
|
||||
public final Map<String, BeatInfo> dom2Beat = new ConcurrentHashMap<String, BeatInfo>();
|
||||
public final Map<String, BeatInfo> dom2Beat = new ConcurrentHashMap<>();
|
||||
|
||||
public BeatReactor(NamingHttpClientProxy serverProxy) {
|
||||
this(serverProxy, null);
|
||||
|
@ -90,7 +90,7 @@ public class DiskCache {
|
||||
* @return service infos
|
||||
*/
|
||||
public static Map<String, ServiceInfo> read(String cacheDir) {
|
||||
Map<String, ServiceInfo> domMap = new HashMap<String, ServiceInfo>(16);
|
||||
Map<String, ServiceInfo> domMap = new HashMap<>(16);
|
||||
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
@ -109,7 +109,7 @@ public class DiskCache {
|
||||
if (!(fileName.endsWith(Constants.SERVICE_INFO_SPLITER + "meta") || fileName
|
||||
.endsWith(Constants.SERVICE_INFO_SPLITER + "special-url"))) {
|
||||
ServiceInfo dom = new ServiceInfo(fileName);
|
||||
List<Instance> ips = new ArrayList<Instance>();
|
||||
List<Instance> ips = new ArrayList<>();
|
||||
dom.setHosts(ips);
|
||||
|
||||
ServiceInfo newFormat = null;
|
||||
|
@ -191,20 +191,20 @@ public class ServiceInfoHolder implements Closeable {
|
||||
return false;
|
||||
}
|
||||
boolean changed = false;
|
||||
Map<String, Instance> oldHostMap = new HashMap<String, Instance>(oldService.getHosts().size());
|
||||
Map<String, Instance> oldHostMap = new HashMap<>(oldService.getHosts().size());
|
||||
for (Instance host : oldService.getHosts()) {
|
||||
oldHostMap.put(host.toInetAddr(), host);
|
||||
}
|
||||
Map<String, Instance> newHostMap = new HashMap<String, Instance>(newService.getHosts().size());
|
||||
Map<String, Instance> newHostMap = new HashMap<>(newService.getHosts().size());
|
||||
for (Instance host : newService.getHosts()) {
|
||||
newHostMap.put(host.toInetAddr(), host);
|
||||
}
|
||||
|
||||
Set<Instance> modHosts = new HashSet<Instance>();
|
||||
Set<Instance> newHosts = new HashSet<Instance>();
|
||||
Set<Instance> remvHosts = new HashSet<Instance>();
|
||||
Set<Instance> modHosts = new HashSet<>();
|
||||
Set<Instance> newHosts = new HashSet<>();
|
||||
Set<Instance> remvHosts = new HashSet<>();
|
||||
|
||||
List<Map.Entry<String, Instance>> newServiceHosts = new ArrayList<Map.Entry<String, Instance>>(
|
||||
List<Map.Entry<String, Instance>> newServiceHosts = new ArrayList<>(
|
||||
newHostMap.entrySet());
|
||||
for (Map.Entry<String, Instance> entry : newServiceHosts) {
|
||||
Instance host = entry.getValue();
|
||||
|
@ -83,14 +83,14 @@ public class Balancer {
|
||||
return null;
|
||||
}
|
||||
NAMING_LOGGER.debug("new Chooser");
|
||||
List<Pair<Instance>> hostsWithWeight = new ArrayList<Pair<Instance>>();
|
||||
List<Pair<Instance>> hostsWithWeight = new ArrayList<>();
|
||||
for (Instance host : hosts) {
|
||||
if (host.isHealthy()) {
|
||||
hostsWithWeight.add(new Pair<Instance>(host, host.getWeight()));
|
||||
}
|
||||
}
|
||||
NAMING_LOGGER.debug("for (Host host : hosts)");
|
||||
Chooser<String, Instance> vipChooser = new Chooser<String, Instance>("www.taobao.com");
|
||||
Chooser<String, Instance> vipChooser = new Chooser<>("www.taobao.com");
|
||||
vipChooser.refresh(hostsWithWeight);
|
||||
NAMING_LOGGER.debug("vipChooser.refresh");
|
||||
return vipChooser.randomWithWeight();
|
||||
|
@ -125,7 +125,7 @@ public class ServerListManager implements ServerListFactory, Closeable {
|
||||
"Error while requesting: " + urlString + "'. Server returned: " + restResult.getCode());
|
||||
}
|
||||
String content = restResult.getData();
|
||||
List<String> list = new ArrayList<String>();
|
||||
List<String> list = new ArrayList<>();
|
||||
for (String line : IoUtils.readLines(new StringReader(content))) {
|
||||
if (!line.trim().isEmpty()) {
|
||||
list.add(line.trim());
|
||||
|
@ -51,7 +51,7 @@ public class ServiceInfoUpdateService implements Closeable {
|
||||
|
||||
private static final int DEFAULT_UPDATE_CACHE_TIME_MULTIPLE = 6;
|
||||
|
||||
private final Map<String, ScheduledFuture<?>> futureMap = new HashMap<String, ScheduledFuture<?>>();
|
||||
private final Map<String, ScheduledFuture<?>> futureMap = new HashMap<>();
|
||||
|
||||
private final ServiceInfoHolder serviceInfoHolder;
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class InstancesChangeNotifier extends Subscriber<InstancesChangeEvent> {
|
||||
|
||||
private final String eventScope;
|
||||
|
||||
private final Map<String, ConcurrentHashSet<EventListener>> listenerMap = new ConcurrentHashMap<String, ConcurrentHashSet<EventListener>>();
|
||||
private final Map<String, ConcurrentHashSet<EventListener>> listenerMap = new ConcurrentHashMap<>();
|
||||
|
||||
private final Object lock = new Object();
|
||||
|
||||
@ -71,7 +71,7 @@ public class InstancesChangeNotifier extends Subscriber<InstancesChangeEvent> {
|
||||
synchronized (lock) {
|
||||
eventListeners = listenerMap.get(key);
|
||||
if (eventListeners == null) {
|
||||
eventListeners = new ConcurrentHashSet<EventListener>();
|
||||
eventListeners = new ConcurrentHashSet<>();
|
||||
listenerMap.put(key, eventListeners);
|
||||
}
|
||||
}
|
||||
@ -114,7 +114,7 @@ public class InstancesChangeNotifier extends Subscriber<InstancesChangeEvent> {
|
||||
}
|
||||
|
||||
public List<ServiceInfo> getSubscribeServices() {
|
||||
List<ServiceInfo> serviceInfos = new ArrayList<ServiceInfo>();
|
||||
List<ServiceInfo> serviceInfos = new ArrayList<>();
|
||||
for (String key : listenerMap.keySet()) {
|
||||
serviceInfos.add(ServiceInfo.fromKey(key));
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ public class NamingGrpcClientProxy extends AbstractNamingClientProxy {
|
||||
this.namespaceId = namespaceId;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.requestTimeout = Long.parseLong(properties.getProperty(CommonParams.NAMING_REQUEST_TIMEOUT, "-1"));
|
||||
Map<String, String> labels = new HashMap<String, String>();
|
||||
Map<String, String> labels = new HashMap<>();
|
||||
labels.put(RemoteConstants.LABEL_SOURCE, RemoteConstants.LABEL_SOURCE_SDK);
|
||||
labels.put(RemoteConstants.LABEL_MODULE, RemoteConstants.LABEL_MODULE_NAMING);
|
||||
this.rpcClient = RpcClientFactory.createClient(uuid, ConnectionType.GRPC, labels);
|
||||
@ -199,7 +199,7 @@ public class NamingGrpcClientProxy extends AbstractNamingClientProxy {
|
||||
}
|
||||
}
|
||||
ServiceListResponse response = requestToServer(request, ServiceListResponse.class);
|
||||
ListView<String> result = new ListView<String>();
|
||||
ListView<String> result = new ListView<>();
|
||||
result.setCount(response.getCount());
|
||||
result.setData(response.getServiceNames());
|
||||
return result;
|
||||
|
@ -150,7 +150,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy {
|
||||
BeatInfo beatInfo = beatReactor.buildBeatInfo(groupedServiceName, instance);
|
||||
beatReactor.addBeatInfo(groupedServiceName, beatInfo);
|
||||
}
|
||||
final Map<String, String> params = new HashMap<String, String>(32);
|
||||
final Map<String, String> params = new HashMap<>(32);
|
||||
params.put(CommonParams.NAMESPACE_ID, namespaceId);
|
||||
params.put(CommonParams.SERVICE_NAME, groupedServiceName);
|
||||
params.put(CommonParams.GROUP_NAME, groupName);
|
||||
@ -176,7 +176,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy {
|
||||
beatReactor.removeBeatInfo(NamingUtils.getGroupedName(serviceName, groupName), instance.getIp(),
|
||||
instance.getPort());
|
||||
}
|
||||
final Map<String, String> params = new HashMap<String, String>(16);
|
||||
final Map<String, String> params = new HashMap<>(16);
|
||||
params.put(CommonParams.NAMESPACE_ID, namespaceId);
|
||||
params.put(CommonParams.SERVICE_NAME, NamingUtils.getGroupedName(serviceName, groupName));
|
||||
params.put(CommonParams.CLUSTER_NAME, instance.getClusterName());
|
||||
@ -192,7 +192,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy {
|
||||
NAMING_LOGGER
|
||||
.info("[UPDATE-SERVICE] {} update service {} with instance: {}", namespaceId, serviceName, instance);
|
||||
|
||||
final Map<String, String> params = new HashMap<String, String>(32);
|
||||
final Map<String, String> params = new HashMap<>(32);
|
||||
params.put(CommonParams.NAMESPACE_ID, namespaceId);
|
||||
params.put(CommonParams.SERVICE_NAME, serviceName);
|
||||
params.put(CommonParams.GROUP_NAME, groupName);
|
||||
@ -210,7 +210,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy {
|
||||
@Override
|
||||
public ServiceInfo queryInstancesOfService(String serviceName, String groupName, String clusters, int udpPort,
|
||||
boolean healthyOnly) throws NacosException {
|
||||
final Map<String, String> params = new HashMap<String, String>(16);
|
||||
final Map<String, String> params = new HashMap<>(16);
|
||||
params.put(CommonParams.NAMESPACE_ID, namespaceId);
|
||||
params.put(CommonParams.SERVICE_NAME, NamingUtils.getGroupedName(serviceName, groupName));
|
||||
params.put(CLUSTERS_PARAM, clusters);
|
||||
@ -228,7 +228,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy {
|
||||
public Service queryService(String serviceName, String groupName) throws NacosException {
|
||||
NAMING_LOGGER.info("[QUERY-SERVICE] {} query service : {}, {}", namespaceId, serviceName, groupName);
|
||||
|
||||
final Map<String, String> params = new HashMap<String, String>(16);
|
||||
final Map<String, String> params = new HashMap<>(16);
|
||||
params.put(CommonParams.NAMESPACE_ID, namespaceId);
|
||||
params.put(CommonParams.SERVICE_NAME, serviceName);
|
||||
params.put(CommonParams.GROUP_NAME, groupName);
|
||||
@ -242,7 +242,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy {
|
||||
|
||||
NAMING_LOGGER.info("[CREATE-SERVICE] {} creating service : {}", namespaceId, service);
|
||||
|
||||
final Map<String, String> params = new HashMap<String, String>(16);
|
||||
final Map<String, String> params = new HashMap<>(16);
|
||||
params.put(CommonParams.NAMESPACE_ID, namespaceId);
|
||||
params.put(CommonParams.SERVICE_NAME, service.getName());
|
||||
params.put(CommonParams.GROUP_NAME, service.getGroupName());
|
||||
@ -259,7 +259,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy {
|
||||
NAMING_LOGGER.info("[DELETE-SERVICE] {} deleting service : {} with groupName : {}", namespaceId, serviceName,
|
||||
groupName);
|
||||
|
||||
final Map<String, String> params = new HashMap<String, String>(16);
|
||||
final Map<String, String> params = new HashMap<>(16);
|
||||
params.put(CommonParams.NAMESPACE_ID, namespaceId);
|
||||
params.put(CommonParams.SERVICE_NAME, serviceName);
|
||||
params.put(CommonParams.GROUP_NAME, groupName);
|
||||
@ -272,7 +272,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy {
|
||||
public void updateService(Service service, AbstractSelector selector) throws NacosException {
|
||||
NAMING_LOGGER.info("[UPDATE-SERVICE] {} updating service : {}", namespaceId, service);
|
||||
|
||||
final Map<String, String> params = new HashMap<String, String>(16);
|
||||
final Map<String, String> params = new HashMap<>(16);
|
||||
params.put(CommonParams.NAMESPACE_ID, namespaceId);
|
||||
params.put(CommonParams.SERVICE_NAME, service.getName());
|
||||
params.put(CommonParams.GROUP_NAME, service.getGroupName());
|
||||
@ -296,8 +296,8 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy {
|
||||
if (NAMING_LOGGER.isDebugEnabled()) {
|
||||
NAMING_LOGGER.debug("[BEAT] {} sending beat to server: {}", namespaceId, beatInfo.toString());
|
||||
}
|
||||
Map<String, String> params = new HashMap<String, String>(16);
|
||||
Map<String, String> bodyMap = new HashMap<String, String>(2);
|
||||
Map<String, String> params = new HashMap<>(16);
|
||||
Map<String, String> bodyMap = new HashMap<>(2);
|
||||
if (!lightBeatEnabled) {
|
||||
bodyMap.put("beat", JacksonUtils.toJson(beatInfo));
|
||||
}
|
||||
@ -314,7 +314,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy {
|
||||
public boolean serverHealthy() {
|
||||
|
||||
try {
|
||||
String result = reqApi(UtilAndComs.nacosUrlBase + "/operator/metrics", new HashMap<String, String>(8),
|
||||
String result = reqApi(UtilAndComs.nacosUrlBase + "/operator/metrics", new HashMap<>(8),
|
||||
HttpMethod.GET);
|
||||
JsonNode json = JacksonUtils.toObj(result);
|
||||
String serverStatus = json.get("status").asText();
|
||||
@ -328,7 +328,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy {
|
||||
public ListView<String> getServiceList(int pageNo, int pageSize, String groupName, AbstractSelector selector)
|
||||
throws NacosException {
|
||||
|
||||
Map<String, String> params = new HashMap<String, String>(16);
|
||||
Map<String, String> params = new HashMap<>(16);
|
||||
params.put("pageNo", String.valueOf(pageNo));
|
||||
params.put("pageSize", String.valueOf(pageSize));
|
||||
params.put(CommonParams.NAMESPACE_ID, namespaceId);
|
||||
@ -350,7 +350,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy {
|
||||
String result = reqApi(UtilAndComs.nacosUrlBase + "/service/list", params, HttpMethod.GET);
|
||||
|
||||
JsonNode json = JacksonUtils.toObj(result);
|
||||
ListView<String> listView = new ListView<String>();
|
||||
ListView<String> listView = new ListView<>();
|
||||
listView.setCount(json.get("count").asInt());
|
||||
listView.setData(JacksonUtils.toObj(json.get("doms").toString(), new TypeReference<List<String>>() {
|
||||
}));
|
||||
|
@ -80,7 +80,7 @@ public class Chooser<K, T> {
|
||||
}
|
||||
|
||||
public Chooser(K uniqueKey, List<Pair<T>> pairs) {
|
||||
Ref<T> ref = new Ref<T>(pairs);
|
||||
Ref<T> ref = new Ref<>(pairs);
|
||||
ref.refresh();
|
||||
this.uniqueKey = uniqueKey;
|
||||
this.ref = ref;
|
||||
@ -100,7 +100,7 @@ public class Chooser<K, T> {
|
||||
* @param itemsWithWeight items with weight
|
||||
*/
|
||||
public void refresh(List<Pair<T>> itemsWithWeight) {
|
||||
Ref<T> newRef = new Ref<T>(itemsWithWeight);
|
||||
Ref<T> newRef = new Ref<>(itemsWithWeight);
|
||||
newRef.refresh();
|
||||
newRef.poller = this.ref.poller.refresh(newRef.items);
|
||||
this.ref = newRef;
|
||||
@ -108,11 +108,11 @@ public class Chooser<K, T> {
|
||||
|
||||
public class Ref<T> {
|
||||
|
||||
private List<Pair<T>> itemsWithWeight = new ArrayList<Pair<T>>();
|
||||
private List<Pair<T>> itemsWithWeight = new ArrayList<>();
|
||||
|
||||
private final List<T> items = new ArrayList<T>();
|
||||
private final List<T> items = new ArrayList<>();
|
||||
|
||||
private Poller<T> poller = new GenericPoller<T>(items);
|
||||
private Poller<T> poller = new GenericPoller<>(items);
|
||||
|
||||
private double[] weights;
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class GenericPoller<T> implements Poller<T> {
|
||||
|
||||
private final AtomicInteger index = new AtomicInteger(0);
|
||||
|
||||
private List<T> items = new ArrayList<T>();
|
||||
private List<T> items = new ArrayList<>();
|
||||
|
||||
public GenericPoller(List<T> items) {
|
||||
this.items = items;
|
||||
@ -42,6 +42,6 @@ public class GenericPoller<T> implements Poller<T> {
|
||||
|
||||
@Override
|
||||
public Poller<T> refresh(List<T> items) {
|
||||
return new GenericPoller<T>(items);
|
||||
return new GenericPoller<>(items);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user