Skip to content

Commit de7bad2

Browse files
committed
Merge remote-tracking branch 'origin/master' into ZOOKEEPER-3188
2 parents da98a8d + dec6ac7 commit de7bad2

635 files changed

Lines changed: 23591 additions & 24819 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

checkstyleSuppressions.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,13 @@
2323
<suppress checks=".*" files=".+[\\/]generated-sources[\\/].+\.java" />
2424
<suppress checks=".*" files=".+[\\/]generated-test-sources[\\/].+\.java" />
2525
<suppress checks="LineLength" files=".+[\\/]jute[\\/].+\.java"/>
26+
27+
<!-- TODO ZOOKEEPER-3508 -->
28+
<suppress checks="LineLength" files=".+[\\/]zookeeper-server[\\/].+\.java"/>
29+
30+
<!-- TODO ZOOKEEPER-3507 -->
31+
<suppress checks=".*Name.*" files=".+[\\/]zookeeper-server[\\/].+\.java"/>
32+
33+
<!-- TODO ZOOKEEPER-3469 -->
34+
<suppress checks="Javadoc.+" files=".+[\\/]zookeeper-server[\\/].+\.java"/>
2635
</suppressions>

zookeeper-it/src/test/java/org/apache/zookeeper/test/system/GenerateLoad.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public class GenerateLoad {
7070
volatile static long currentInterval;
7171

7272
static long lastChange;
73-
73+
7474
static PrintStream sf;
7575
static PrintStream tf;
7676
static {
@@ -86,7 +86,8 @@ public class GenerateLoad {
8686
synchronized static void add(long time, int count, Socket s) {
8787
long interval = time / INTERVAL;
8888
if (currentInterval == 0 || currentInterval > interval) {
89-
System.out.println("Dropping " + count + " for " + new Date(time)
89+
System.out.println(
90+
"Dropping " + count + " for " + new Date(time)
9091
+ " " + currentInterval + ">" + interval);
9192
return;
9293
}
@@ -269,7 +270,7 @@ synchronized static void sendChange(int percentage) {
269270
static public class GeneratorInstance implements Instance {
270271

271272
byte bytes[];
272-
273+
273274
int percentage = -1;
274275

275276
int errors;
@@ -287,7 +288,7 @@ static public class GeneratorInstance implements Instance {
287288
int wlatency;
288289

289290
int outstanding;
290-
291+
291292
volatile boolean alive;
292293

293294
class ZooKeeperThread extends Thread implements Watcher, DataCallback,
@@ -556,7 +557,7 @@ synchronized public boolean waitConnected(long timeout)
556557

557558
private static boolean leaderOnly;
558559
private static boolean leaderServes;
559-
560+
560561
private static String []processOptions(String args[]) {
561562
ArrayList<String> newArgs = new ArrayList<String>();
562563
for(String a: args) {
@@ -571,7 +572,7 @@ synchronized public boolean waitConnected(long timeout)
571572
}
572573
return newArgs.toArray(new String[0]);
573574
}
574-
575+
575576
/**
576577
* @param args
577578
* @throws InterruptedException

zookeeper-it/src/test/java/org/apache/zookeeper/test/system/InstanceContainer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ public void processResult(int rc, String path, Object ctx, List<String> children
242242
Instance i = instances.remove(child);
243243
if (i == null) {
244244
// Start up a new instance
245-
byte data[] = null;
245+
byte[] data = null;
246246
String myNode = assignmentsNode + '/' + child;
247247
while(true) {
248248
try {

zookeeper-it/src/test/java/org/apache/zookeeper/test/system/InstanceManager.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
* * ready: this znode indicates that the InstanceManager is running
4848
* * available: the children of this znode are ephemeral nodes representing
4949
* running InstanceContainers
50-
* * assignments: there will be a child under this znode for each available
50+
* * assignments: there will be a child under this znode for each available
5151
* InstanceContainer. those znodes will have a child for each
5252
* assigned instance
5353
* * reports: there will be a child under this znode for each instance that is
@@ -114,21 +114,21 @@ private void setupNodes(ZooKeeper zk) throws KeeperException,
114114
InterruptedException {
115115
try {
116116
zk.create(prefixNode, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
117-
} catch(NodeExistsException e) { /* this is ok */ }
117+
} catch(NodeExistsException e) { /* this is ok */ }
118118
try {
119119
zk.create(assignmentsNode, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
120-
} catch(NodeExistsException e) { /* this is ok */ }
121-
try {
120+
} catch(NodeExistsException e) { /* this is ok */ }
121+
try {
122122
zk.create(statusNode, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
123-
} catch(NodeExistsException e) { /* this is ok */ }
124-
try {
123+
} catch(NodeExistsException e) { /* this is ok */ }
124+
try {
125125
zk.create(reportsNode, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
126-
} catch(NodeExistsException e) { /* this is ok */ }
126+
} catch(NodeExistsException e) { /* this is ok */ }
127127
try {
128128
zk.create(readyNode, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
129-
} catch(NodeExistsException e) { /* this is ok */ }
129+
} catch(NodeExistsException e) { /* this is ok */ }
130130
}
131-
131+
132132
synchronized public void processResult(int rc, String path, Object ctx,
133133
List<String> children) {
134134
if (rc != KeeperException.Code.OK.intValue()) {
@@ -159,7 +159,7 @@ synchronized public void processResult(int rc, String path, Object ctx,
159159
}
160160
assignments = newAssignments;
161161
}
162-
162+
163163
public void process(WatchedEvent event) {
164164
if (event.getPath().equals(statusNode)) {
165165
zk.getChildren(statusNode, this, this, null);
@@ -224,7 +224,7 @@ synchronized public String assignInstance(String name, Class<? extends Instance>
224224
}
225225
throw lastException;
226226
}
227-
227+
228228
public void reconfigureInstance(String name, String params) throws NoAssignmentException, InterruptedException, KeeperException {
229229
if (LOG.isDebugEnabled()) {
230230
LOG.debug("Reconfiguring " + name + " with " + params);
@@ -246,7 +246,7 @@ public void reconfigureInstance(String name, String params) throws NoAssignmentE
246246
throw lastException;
247247
}
248248
}
249-
249+
250250
private void doDelete(String path) throws InterruptedException, KeeperException {
251251
KeeperException lastException = null;
252252
for(int i = 0; i < maxTries; i++) {
@@ -270,11 +270,11 @@ synchronized public void removeInstance(String name) throws InterruptedException
270270
doDelete(assignmentsNode + '/' + assigned.container + '/' + name);
271271
doDelete(reportsNode + '/' + name);
272272
}
273-
273+
274274
synchronized boolean isAlive(String name) {
275275
return instanceToAssignment.get(name) != null;
276276
}
277-
277+
278278
public void resetStatus(String name) throws InterruptedException, KeeperException {
279279
KeeperException lastException = null;
280280
for(int i = 0; i < maxTries; i++) {
@@ -295,7 +295,7 @@ public void resetStatus(String name) throws InterruptedException, KeeperExceptio
295295

296296
public String getStatus(String name, long timeout) throws KeeperException, InterruptedException {
297297
Stat stat = new Stat();
298-
byte data[] = null;
298+
byte[] data = null;
299299
long endTime = Time.currentElapsedTime() + timeout;
300300
KeeperException lastException = null;
301301
for(int i = 0; i < maxTries && endTime > Time.currentElapsedTime(); i++) {

zookeeper-it/src/test/java/org/apache/zookeeper/test/system/SimpleClient.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import org.apache.zookeeper.data.Stat;
3030

3131
/**
32-
* The client that gets spawned for the SimpleSysTest
32+
* The client that gets spawned for the SimpleSysTest
3333
*
3434
*/
3535
public class SimpleClient implements Instance, Watcher, AsyncCallback.DataCallback, StringCallback, StatCallback {
@@ -38,15 +38,15 @@ public class SimpleClient implements Instance, Watcher, AsyncCallback.DataCallba
3838
ZooKeeper zk;
3939
transient int index;
4040
transient String myPath;
41-
byte data[];
41+
byte[] data;
4242
boolean createdEphemeral;
4343
public void configure(String params) {
4444
String parts[] = params.split(" ");
4545
hostPort = parts[1];
4646
this.index = Integer.parseInt(parts[0]);
4747
myPath = "/simpleCase/" + index;
4848
}
49-
49+
5050
public void start() {
5151
try {
5252
zk = new ZooKeeper(hostPort, 15000, this);
@@ -58,7 +58,7 @@ public void start() {
5858
e.printStackTrace();
5959
}
6060
}
61-
61+
6262
public void stop() {
6363
try {
6464
if (zk != null) {
@@ -73,7 +73,7 @@ public void process(WatchedEvent event) {
7373
zk.getData("/simpleCase", true, this, null);
7474
}
7575
}
76-
76+
7777
public void processResult(int rc, String path, Object ctx, byte[] data,
7878
Stat stat) {
7979
if (rc != 0) {
@@ -91,9 +91,9 @@ public void processResult(int rc, String path, Object ctx, byte[] data,
9191
} else {
9292
zk.setData(myPath, data, -1, this, null);
9393
}
94-
}
94+
}
9595
}
96-
96+
9797
public void processResult(int rc, String path, Object ctx, String name) {
9898
if (rc != 0) {
9999
zk.create(myPath, data, Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL, this, null);
@@ -108,7 +108,7 @@ public void processResult(int rc, String path, Object ctx, Stat stat) {
108108
public String toString() {
109109
return SimpleClient.class.getName() + "[" + index + "] using " + hostPort;
110110
}
111-
111+
112112
Reporter r;
113113
public void setReporter(Reporter r) {
114114
this.r = r;

zookeeper-it/src/test/java/org/apache/zookeeper/test/system/SimpleSysTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class SimpleSysTest extends BaseSysTest implements Watcher {
4545
int maxTries = 10;
4646
boolean connected;
4747
final private static Logger LOG = LoggerFactory.getLogger(SimpleSysTest.class);
48-
48+
4949
synchronized private boolean waitForConnect(ZooKeeper zk, long timeout) throws InterruptedException {
5050
connected = (zk.getState() == States.CONNECTED);
5151
long end = Time.currentElapsedTime() + timeout;
@@ -55,15 +55,15 @@ synchronized private boolean waitForConnect(ZooKeeper zk, long timeout) throws I
5555
}
5656
return connected;
5757
}
58-
58+
5959
/**
6060
* This test checks the following:
6161
* 1) All clients connect successfully
6262
* 2) Half of the servers die (assuming odd number) and a write succeeds
6363
* 3) All servers are restarted and cluster stays alive
6464
* 4) Clients see a change by the server
6565
* 5) Clients' ephemeral nodes are cleaned up
66-
*
66+
*
6767
* @throws Exception
6868
*/
6969
@Test
@@ -77,7 +77,7 @@ public void testSimpleCase() throws Exception {
7777
waitForConnect(zk, 10000);
7878
zk.create("/simpleCase", "orig".getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
7979
startClients();
80-
80+
8181
// Check that all clients connect properly
8282
for(int i = 0; i < getClientCount(); i++) {
8383
for(int j = 0; j < maxTries; j++) {
@@ -92,7 +92,7 @@ public void testSimpleCase() throws Exception {
9292
}
9393
}
9494
}
95-
95+
9696
// Kill half the servers, make a change, restart the dead
9797
// servers, and then bounce the other servers one by one
9898
for(int i = 0; i < getServerCount(); i++) {
@@ -120,11 +120,11 @@ public void testSimpleCase() throws Exception {
120120
} catch(ConnectionLossException e) {
121121
Assert.assertTrue("Servers didn't bounce", waitForConnect(zk, 15000));
122122
}
123-
123+
124124
// check that the change has propagated to everyone
125125
for(int i = 0; i < getClientCount(); i++) {
126126
for(int j = 0; j < maxTries; j++) {
127-
byte data[] = zk.getData("/simpleCase/" + i, false, stat);
127+
byte[] data = zk.getData("/simpleCase/" + i, false, stat);
128128
if (new String(data).equals("new")) {
129129
break;
130130
}
@@ -134,10 +134,10 @@ public void testSimpleCase() throws Exception {
134134
Thread.sleep(1000);
135135
}
136136
}
137-
137+
138138
// send out the kill signal
139139
zk.setData("/simpleCase", "die".getBytes(), -1);
140-
140+
141141
// watch for everyone to die
142142
for(int i = 0; i < getClientCount(); i++) {
143143
try {
@@ -152,7 +152,7 @@ public void testSimpleCase() throws Exception {
152152
// Great this is what we were hoping for!
153153
}
154154
}
155-
155+
156156
stopClients();
157157
stopServers();
158158
}

0 commit comments

Comments
 (0)