Skip to content

Commit 87986a6

Browse files
committed
fixes #2380 branch 1.6.x update consul code format
1 parent b119e4a commit 87986a6

File tree

10 files changed

+23
-31
lines changed

10 files changed

+23
-31
lines changed

consul/src/main/java/com/networknt/consul/ConsulConstants.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ public class ConsulConstants {
5757
* Heart beat circle,2/3 of ttl
5858
*/
5959
public static int HEARTBEAT_CIRCLE = (TTL * 1000 * 2) / 3;
60-
60+
6161
/**
6262
* Maximum continuous switch checks, send heart beat is this number is exceeded.
6363
*/
6464
public static int MAX_SWITCHER_CHECK_TIMES = 10;
65-
65+
6666
/**
6767
* Switcher change rate
6868
*/
@@ -83,7 +83,7 @@ public class ConsulConstants {
8383
* consul block, max block time in minute
8484
*/
8585
public static int CONSUL_BLOCK_TIME_MINUTES = 10;
86-
86+
8787
/**
8888
* consul block max block time in second
8989
*/

consul/src/main/java/com/networknt/consul/ConsulHeartbeatManager.java

+6-11
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,20 @@
1616

1717
package com.networknt.consul;
1818

19-
import java.util.concurrent.ArrayBlockingQueue;
20-
import java.util.concurrent.Executors;
21-
import java.util.concurrent.RejectedExecutionException;
22-
import java.util.concurrent.ScheduledExecutorService;
23-
import java.util.concurrent.ThreadPoolExecutor;
24-
import java.util.concurrent.TimeUnit;
25-
2619
import com.networknt.consul.client.ConsulClient;
2720
import com.networknt.utility.ConcurrentHashSet;
2821
import org.slf4j.Logger;
2922
import org.slf4j.LoggerFactory;
3023

24+
import java.util.concurrent.*;
25+
3126
/**
3227
* consul heart beat manager. passing status service id is registered here,
3328
* and this class will set passing status for serviceId(in fact it is corresponding checkId of serviceId),
3429
* then the heart beat process is done.
3530
*
3631
* Switcher is used to enable heart beat or disable heart beat.
37-
*
32+
*
3833
* @author zhanglei
3934
*
4035
*/
@@ -98,7 +93,7 @@ public void run() {
9893
/**
9994
* check heart beat switcher status, if switcher is changed, then change lastHeartBeatSwitcherStatus
10095
* to the latest status.
101-
*
96+
*
10297
* @param switcherStatus
10398
* @return
10499
*/
@@ -131,7 +126,7 @@ public void close() {
131126

132127
/**
133128
* Add consul serviceId,added serviceId will set passing status to keep sending heart beat.
134-
*
129+
*
135130
* @param serviceId service Id
136131
*/
137132
public void addHeartbeatServcieId(String serviceId) {
@@ -140,7 +135,7 @@ public void addHeartbeatServcieId(String serviceId) {
140135

141136
/**
142137
* remove serviceId,corresponding serviceId won't send heart beat
143-
*
138+
*
144139
* @param serviceId service Id
145140
*/
146141
public void removeHeartbeatServiceId(String serviceId) {

consul/src/main/java/com/networknt/consul/ConsulResponse.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ public class ConsulResponse<T> {
2121
* consul return result
2222
*/
2323
private T value;
24-
24+
2525
private Long consulIndex;
26-
26+
2727
private Boolean consulKnownLeader;
28-
28+
2929
private Long consulLastContact;
3030

3131
public T getValue() {
@@ -60,5 +60,4 @@ public void setConsulLastContact(Long consulLastContact) {
6060
this.consulLastContact = consulLastContact;
6161
}
6262

63-
6463
}

consul/src/main/java/com/networknt/consul/ConsulService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class ConsulService {
3737
private Integer port;
3838

3939
private String checkString;
40-
40+
4141
public String getId() {
4242
return id;
4343
}

consul/src/main/java/com/networknt/consul/ConsulUtils.java

-1
Original file line numberDiff line numberDiff line change
@@ -193,5 +193,4 @@ public static int getTimeoutBufferInSecond(String timeoutBuffer) {
193193
}
194194
return w;
195195
}
196-
197196
}

consul/src/main/java/com/networknt/consul/client/ConsulClient.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616

1717
package com.networknt.consul.client;
1818

19-
import java.util.List;
20-
2119
import com.networknt.consul.ConsulResponse;
2220
import com.networknt.consul.ConsulService;
2321

22+
import java.util.List;
23+
2424
public interface ConsulClient {
2525

2626
/**

consul/src/test/java/com/networknt/consul/ConsulClientImplTest.java

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package com.networknt.consul;
1818

1919
import com.networknt.config.Config;
20-
import com.networknt.consul.client.ConsulClientImpl;
2120
import org.junit.Test;
2221

2322
import static org.junit.Assert.assertEquals;

consul/src/test/java/com/networknt/consul/ConsulHeartbeatManagerTest.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@
1616

1717
package com.networknt.consul;
1818

19-
import static org.junit.Assert.assertTrue;
19+
import org.junit.After;
20+
import org.junit.Before;
21+
import org.junit.Test;
2022

2123
import java.util.HashMap;
2224
import java.util.Map;
2325
import java.util.Map.Entry;
2426

25-
import org.junit.After;
26-
import org.junit.Before;
27-
import org.junit.Test;
27+
import static org.junit.Assert.assertTrue;
2828

2929
/**
30-
*
30+
*
3131
* @Description ConsulHeartbeatManagerTest
3232
* @author zhanglei28
3333
*

consul/src/test/java/com/networknt/consul/MockUtils.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616

1717
package com.networknt.consul;
1818

19-
import com.networknt.registry.URLImpl;
20-
import com.networknt.registry.URLParamType;
2119
import com.networknt.registry.URL;
20+
import com.networknt.registry.URLImpl;
2221

2322
import java.util.ArrayList;
2423
import java.util.HashMap;

consul/src/test/resources/config/consul.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ ttlCheck: true
2525
# respectively).
2626
wait: 600s
2727
# Time in seconds between blocking queries with Consul
28-
# Consul blocking queries time should be set via the 'lookupInterval' parameter in consul.yml, instead of 'registrySessionTimeout' in service.yml
28+
# Consul blocking queries time should be set via the 'lookupInterval' parameter in consul.yml, instead of
29+
# 'registrySessionTimeout' in service.yml
2930
lookupInterval: 30

0 commit comments

Comments
 (0)