Skip to content

Commit

Permalink
#502 Fix PMD
Browse files Browse the repository at this point in the history
  • Loading branch information
nkorange committed Jan 17, 2019
1 parent cc1f664 commit 38e84cf
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 25 deletions.
Expand Up @@ -173,7 +173,6 @@ public void signalPublish(String key, String value) throws Exception {
parameters.put("key", key);

raftProxy.proxyPostLarge(getLeader().ip, API_PUB, params.toJSONString(), parameters);

return;
}

Expand Down Expand Up @@ -818,6 +817,7 @@ public void listen(String key, DataListener listener) {

if (listenerList == null) {
listenerList = new CopyOnWriteArrayList<>();
listeners.put(key, listenerList);
}

Loggers.RAFT.info("add listener: {}", key);
Expand Down
Expand Up @@ -42,7 +42,7 @@ public void proxyGET(String server, String api, Map<String, String> params) thro
}
}

public static void proxyPostLarge(String server, String api, String content, Map<String, String> headers) throws Exception {
public void proxyPostLarge(String server, String api, String content, Map<String, String> headers) throws Exception {
// do proxy
if (!server.contains(UtilsAndCommons.CLUSTER_CONF_IP_SPLITER)) {
server = server + UtilsAndCommons.CLUSTER_CONF_IP_SPLITER + RunningConfig.getServerPort();
Expand Down
Expand Up @@ -174,7 +174,6 @@ public void onChange(String key, String value) throws Exception {
consistencyService.listen(UtilsAndCommons.getDomStoreKey(dom), dom);
Loggers.SRV_LOG.info("[NEW-DOM-RAFT] {}", dom.toJSON());
}

wakeUp(UtilsAndCommons.assembleFullServiceName(dom.getNamespaceId(), dom.getName()));

} catch (Throwable e) {
Expand Down Expand Up @@ -376,7 +375,6 @@ public void addOrReplaceService(VirtualClusterDomain newDom) throws Exception {
public void registerInstance(String namespaceId, String serviceName, IpAddress instance) throws Exception {

VirtualClusterDomain service = getService(namespaceId, serviceName);

boolean serviceUpdated = false;
if (service == null) {
service = new VirtualClusterDomain();
Expand Down Expand Up @@ -411,9 +409,16 @@ public void registerInstance(String namespaceId, String serviceName, IpAddress i
}

if (serviceUpdated) {
Lock lock = addLockIfAbsent(UtilsAndCommons.assembleFullServiceName(namespaceId, serviceName));
Condition condition = addCondtion(UtilsAndCommons.assembleFullServiceName(namespaceId, serviceName));
addOrReplaceService(service);
try {
lock.lock();
condition.await(5000, TimeUnit.MILLISECONDS);
} finally {
lock.unlock();
}
}

addInstance(namespaceId, serviceName, instance);
}

Expand Down
Expand Up @@ -105,21 +105,6 @@ public void run() {
}
}
}
//
// @JSONField(serialize = false)
// public SwitchDomain getSwitchDomain() {
// return SpringContext.getAppContext().getBean(SwitchDomain.class);
// }
//
// @JSONField(serialize = false)
// public DistroMapper getDistroMapper() {
// return SpringContext.getAppContext().getBean(DistroMapper.class);
// }
//
// @JSONField(serialize = false)
// public HealthCheckProcessor getHealthCheckProcessor() {
// return SpringContext.getAppContext().getBean(HealthCheckProcessorDelegate.class);
// }

public Cluster getCluster() {
return cluster;
Expand Down
Expand Up @@ -55,7 +55,7 @@ public class RegisterInstance_ITCase {
public void init() throws Exception {
if (naming == null) {
TimeUnit.SECONDS.sleep(10);
naming = NamingFactory.createNamingService("127.0.0.1" + ":" + 8848);
naming = NamingFactory.createNamingService("127.0.0.1" + ":" + port);
}
}

Expand Down Expand Up @@ -92,16 +92,14 @@ public void deregService() throws NacosException, InterruptedException {
@Test
public void regDomTest() throws Exception {
String serviceName = randomDomainName();

naming.registerInstance(serviceName, TEST_IP_4_DOM_1, TEST_PORT);

System.out.println(serviceName);
naming.registerInstance(serviceName, TEST_IP_4_DOM_1, TEST_PORT);

TimeUnit.SECONDS.sleep(3);

List<Instance> instances = naming.getAllInstances(serviceName);

Assert.assertEquals(instances.size(), 1);
Assert.assertEquals(1, instances.size());
Assert.assertTrue(instances.get(0).getInstanceId().contains(serviceName));
//Assert.assertEquals(instances.get(0).getService().getName(), serviceName);
Assert.assertEquals(instances.get(0).getIp(), TEST_IP_4_DOM_1);
Expand Down

0 comments on commit 38e84cf

Please sign in to comment.