Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into ZOOKEEPER-3188
Browse files Browse the repository at this point in the history
  • Loading branch information
symat committed Aug 23, 2019
2 parents da98a8d + dec6ac7 commit de7bad2
Show file tree
Hide file tree
Showing 635 changed files with 23,591 additions and 24,819 deletions.
9 changes: 9 additions & 0 deletions checkstyleSuppressions.xml
Expand Up @@ -23,4 +23,13 @@
<suppress checks=".*" files=".+[\\/]generated-sources[\\/].+\.java" />
<suppress checks=".*" files=".+[\\/]generated-test-sources[\\/].+\.java" />
<suppress checks="LineLength" files=".+[\\/]jute[\\/].+\.java"/>

<!-- TODO ZOOKEEPER-3508 -->
<suppress checks="LineLength" files=".+[\\/]zookeeper-server[\\/].+\.java"/>

<!-- TODO ZOOKEEPER-3507 -->
<suppress checks=".*Name.*" files=".+[\\/]zookeeper-server[\\/].+\.java"/>

<!-- TODO ZOOKEEPER-3469 -->
<suppress checks="Javadoc.+" files=".+[\\/]zookeeper-server[\\/].+\.java"/>
</suppressions>
Expand Up @@ -70,7 +70,7 @@ public class GenerateLoad {
volatile static long currentInterval;

static long lastChange;

static PrintStream sf;
static PrintStream tf;
static {
Expand All @@ -86,7 +86,8 @@ public class GenerateLoad {
synchronized static void add(long time, int count, Socket s) {
long interval = time / INTERVAL;
if (currentInterval == 0 || currentInterval > interval) {
System.out.println("Dropping " + count + " for " + new Date(time)
System.out.println(
"Dropping " + count + " for " + new Date(time)
+ " " + currentInterval + ">" + interval);
return;
}
Expand Down Expand Up @@ -269,7 +270,7 @@ synchronized static void sendChange(int percentage) {
static public class GeneratorInstance implements Instance {

byte bytes[];

int percentage = -1;

int errors;
Expand All @@ -287,7 +288,7 @@ static public class GeneratorInstance implements Instance {
int wlatency;

int outstanding;

volatile boolean alive;

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

private static boolean leaderOnly;
private static boolean leaderServes;

private static String []processOptions(String args[]) {
ArrayList<String> newArgs = new ArrayList<String>();
for(String a: args) {
Expand All @@ -571,7 +572,7 @@ synchronized public boolean waitConnected(long timeout)
}
return newArgs.toArray(new String[0]);
}

/**
* @param args
* @throws InterruptedException
Expand Down
Expand Up @@ -242,7 +242,7 @@ public void processResult(int rc, String path, Object ctx, List<String> children
Instance i = instances.remove(child);
if (i == null) {
// Start up a new instance
byte data[] = null;
byte[] data = null;
String myNode = assignmentsNode + '/' + child;
while(true) {
try {
Expand Down
Expand Up @@ -47,7 +47,7 @@
* * ready: this znode indicates that the InstanceManager is running
* * available: the children of this znode are ephemeral nodes representing
* running InstanceContainers
* * assignments: there will be a child under this znode for each available
* * assignments: there will be a child under this znode for each available
* InstanceContainer. those znodes will have a child for each
* assigned instance
* * reports: there will be a child under this znode for each instance that is
Expand Down Expand Up @@ -114,21 +114,21 @@ private void setupNodes(ZooKeeper zk) throws KeeperException,
InterruptedException {
try {
zk.create(prefixNode, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
} catch(NodeExistsException e) { /* this is ok */ }
} catch(NodeExistsException e) { /* this is ok */ }
try {
zk.create(assignmentsNode, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
} catch(NodeExistsException e) { /* this is ok */ }
try {
} catch(NodeExistsException e) { /* this is ok */ }
try {
zk.create(statusNode, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
} catch(NodeExistsException e) { /* this is ok */ }
try {
} catch(NodeExistsException e) { /* this is ok */ }
try {
zk.create(reportsNode, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
} catch(NodeExistsException e) { /* this is ok */ }
} catch(NodeExistsException e) { /* this is ok */ }
try {
zk.create(readyNode, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
} catch(NodeExistsException e) { /* this is ok */ }
} catch(NodeExistsException e) { /* this is ok */ }
}

synchronized public void processResult(int rc, String path, Object ctx,
List<String> children) {
if (rc != KeeperException.Code.OK.intValue()) {
Expand Down Expand Up @@ -159,7 +159,7 @@ synchronized public void processResult(int rc, String path, Object ctx,
}
assignments = newAssignments;
}

public void process(WatchedEvent event) {
if (event.getPath().equals(statusNode)) {
zk.getChildren(statusNode, this, this, null);
Expand Down Expand Up @@ -224,7 +224,7 @@ synchronized public String assignInstance(String name, Class<? extends Instance>
}
throw lastException;
}

public void reconfigureInstance(String name, String params) throws NoAssignmentException, InterruptedException, KeeperException {
if (LOG.isDebugEnabled()) {
LOG.debug("Reconfiguring " + name + " with " + params);
Expand All @@ -246,7 +246,7 @@ public void reconfigureInstance(String name, String params) throws NoAssignmentE
throw lastException;
}
}

private void doDelete(String path) throws InterruptedException, KeeperException {
KeeperException lastException = null;
for(int i = 0; i < maxTries; i++) {
Expand All @@ -270,11 +270,11 @@ synchronized public void removeInstance(String name) throws InterruptedException
doDelete(assignmentsNode + '/' + assigned.container + '/' + name);
doDelete(reportsNode + '/' + name);
}

synchronized boolean isAlive(String name) {
return instanceToAssignment.get(name) != null;
}

public void resetStatus(String name) throws InterruptedException, KeeperException {
KeeperException lastException = null;
for(int i = 0; i < maxTries; i++) {
Expand All @@ -295,7 +295,7 @@ public void resetStatus(String name) throws InterruptedException, KeeperExceptio

public String getStatus(String name, long timeout) throws KeeperException, InterruptedException {
Stat stat = new Stat();
byte data[] = null;
byte[] data = null;
long endTime = Time.currentElapsedTime() + timeout;
KeeperException lastException = null;
for(int i = 0; i < maxTries && endTime > Time.currentElapsedTime(); i++) {
Expand Down
Expand Up @@ -29,7 +29,7 @@
import org.apache.zookeeper.data.Stat;

/**
* The client that gets spawned for the SimpleSysTest
* The client that gets spawned for the SimpleSysTest
*
*/
public class SimpleClient implements Instance, Watcher, AsyncCallback.DataCallback, StringCallback, StatCallback {
Expand All @@ -38,15 +38,15 @@ public class SimpleClient implements Instance, Watcher, AsyncCallback.DataCallba
ZooKeeper zk;
transient int index;
transient String myPath;
byte data[];
byte[] data;
boolean createdEphemeral;
public void configure(String params) {
String parts[] = params.split(" ");
hostPort = parts[1];
this.index = Integer.parseInt(parts[0]);
myPath = "/simpleCase/" + index;
}

public void start() {
try {
zk = new ZooKeeper(hostPort, 15000, this);
Expand All @@ -58,7 +58,7 @@ public void start() {
e.printStackTrace();
}
}

public void stop() {
try {
if (zk != null) {
Expand All @@ -73,7 +73,7 @@ public void process(WatchedEvent event) {
zk.getData("/simpleCase", true, this, null);
}
}

public void processResult(int rc, String path, Object ctx, byte[] data,
Stat stat) {
if (rc != 0) {
Expand All @@ -91,9 +91,9 @@ public void processResult(int rc, String path, Object ctx, byte[] data,
} else {
zk.setData(myPath, data, -1, this, null);
}
}
}
}

public void processResult(int rc, String path, Object ctx, String name) {
if (rc != 0) {
zk.create(myPath, data, Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL, this, null);
Expand All @@ -108,7 +108,7 @@ public void processResult(int rc, String path, Object ctx, Stat stat) {
public String toString() {
return SimpleClient.class.getName() + "[" + index + "] using " + hostPort;
}

Reporter r;
public void setReporter(Reporter r) {
this.r = r;
Expand Down
Expand Up @@ -45,7 +45,7 @@ public class SimpleSysTest extends BaseSysTest implements Watcher {
int maxTries = 10;
boolean connected;
final private static Logger LOG = LoggerFactory.getLogger(SimpleSysTest.class);

synchronized private boolean waitForConnect(ZooKeeper zk, long timeout) throws InterruptedException {
connected = (zk.getState() == States.CONNECTED);
long end = Time.currentElapsedTime() + timeout;
Expand All @@ -55,15 +55,15 @@ synchronized private boolean waitForConnect(ZooKeeper zk, long timeout) throws I
}
return connected;
}

/**
* This test checks the following:
* 1) All clients connect successfully
* 2) Half of the servers die (assuming odd number) and a write succeeds
* 3) All servers are restarted and cluster stays alive
* 4) Clients see a change by the server
* 5) Clients' ephemeral nodes are cleaned up
*
*
* @throws Exception
*/
@Test
Expand All @@ -77,7 +77,7 @@ public void testSimpleCase() throws Exception {
waitForConnect(zk, 10000);
zk.create("/simpleCase", "orig".getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
startClients();

// Check that all clients connect properly
for(int i = 0; i < getClientCount(); i++) {
for(int j = 0; j < maxTries; j++) {
Expand All @@ -92,7 +92,7 @@ public void testSimpleCase() throws Exception {
}
}
}

// Kill half the servers, make a change, restart the dead
// servers, and then bounce the other servers one by one
for(int i = 0; i < getServerCount(); i++) {
Expand Down Expand Up @@ -120,11 +120,11 @@ public void testSimpleCase() throws Exception {
} catch(ConnectionLossException e) {
Assert.assertTrue("Servers didn't bounce", waitForConnect(zk, 15000));
}

// check that the change has propagated to everyone
for(int i = 0; i < getClientCount(); i++) {
for(int j = 0; j < maxTries; j++) {
byte data[] = zk.getData("/simpleCase/" + i, false, stat);
byte[] data = zk.getData("/simpleCase/" + i, false, stat);
if (new String(data).equals("new")) {
break;
}
Expand All @@ -134,10 +134,10 @@ public void testSimpleCase() throws Exception {
Thread.sleep(1000);
}
}

// send out the kill signal
zk.setData("/simpleCase", "die".getBytes(), -1);

// watch for everyone to die
for(int i = 0; i < getClientCount(); i++) {
try {
Expand All @@ -152,7 +152,7 @@ public void testSimpleCase() throws Exception {
// Great this is what we were hoping for!
}
}

stopClients();
stopServers();
}
Expand Down

0 comments on commit de7bad2

Please sign in to comment.