Skip to content

test voltdb's zk #165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "hadoop-hdfs-project/commons-pool2"]
path = hadoop-hdfs-project/commons-pool2
url = https://github.com/DSL-UMD/commons-pool2
5 changes: 5 additions & 0 deletions hadoop-hdfs-project/hadoop-hdfs-nnproxy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.13</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package org.apache.hadoop.hdfs.nnproxy.server;

import java.util.Date;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.Watcher.Event.KeeperState;
import org.apache.zookeeper.ZooDefs.Ids;
import org.apache.zookeeper.ZooKeeper;

public class ZkConnect {
private ZooKeeper zk;
private CountDownLatch connSignal = new CountDownLatch(0);

// host should be 127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002
public ZooKeeper connect(String host) throws Exception {
zk =
new ZooKeeper(
host,
3000,
new Watcher() {
public void process(WatchedEvent event) {
if (event.getState() == KeeperState.SyncConnected) {
connSignal.countDown();
}
}
});
connSignal.await();
return zk;
}

public void close() throws InterruptedException {
zk.close();
}

public void createNode(String path, byte[] data) throws Exception {
zk.create(path, data, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
}

public void updateNode(String path, byte[] data) throws Exception {
zk.setData(path, data, zk.exists(path, true).getVersion());
}

public void deleteNode(String path) throws Exception {
zk.delete(path, zk.exists(path, true).getVersion());
}

public static void main(String args[]) throws Exception {
ZkConnect connector = new ZkConnect();
ZooKeeper zk = connector.connect("localhost:7181");
String newNode = "/deepakDate" + new Date();
connector.createNode(newNode, new Date().toString().getBytes());
List<String> zNodes = zk.getChildren("/", true);
for (String zNode : zNodes) {
System.out.println("ChildrenNode " + zNode);
}
byte[] data = zk.getData(newNode, true, zk.exists(newNode, true));
System.out.println("GetData before setting");
for (byte dataPoint : data) {
System.out.print((char) dataPoint);
}

System.out.println("GetData after setting");
connector.updateNode(newNode, "Modified data".getBytes());
data = zk.getData(newNode, true, zk.exists(newNode, true));
for (byte dataPoint : data) {
System.out.print((char) dataPoint);
}
connector.deleteNode(newNode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ public long getPreferredBlockSize(String filename) throws IOException, Unresolve
@Override
public boolean setSafeMode(HdfsConstants.SafeModeAction action, boolean isChecked)
throws IOException {
if (action.equals(HdfsConstants.SafeModeAction.SAFEMODE_GET)) {
if (action.equals(HdfsConstants.SafeModeAction.SAFEMODE_GET)
|| action.equals(HdfsConstants.SafeModeAction.SAFEMODE_LEAVE)) {
// FIXME: properly handle
return false;
}
Expand Down
12 changes: 6 additions & 6 deletions voltdb/docker/start-volt.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
set -xe

docker run --name=volt1 --hostname=volt1 -d -p 8080:8080 -p 21212:21212 \
gangliao/voltdb:9.0 /root/voltdb-ent/deploy.py 3 1 volt1
docker run --name=volt1 --hostname=volt1 -d -p 8080:8080 -p 7181:7181 -p 21212:21212 \
gangliao/voltdb:9.1 /root/voltdb-ent/deploy.py 3 1 volt1

LEADERIP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' volt1)

docker run --name=volt2 --hostname=volt2 -d -p 8081:8080 \
gangliao/voltdb:9.0 /root/voltdb-ent/deploy.py 3 1 $LEADERIP
docker run --name=volt2 --hostname=volt2 -d -p 7182:7181 -p 21213:21212 \
gangliao/voltdb:9.1 /root/voltdb-ent/deploy.py 3 1 $LEADERIP

docker run --name=volt3 --hostname=volt3 -d -p 8082:8080 \
gangliao/voltdb:9.0 /root/voltdb-ent/deploy.py 3 1 $LEADERIP
docker run --name=volt3 --hostname=volt3 -d -p 7183:7181 -p 21214:21212 \
gangliao/voltdb:9.1 /root/voltdb-ent/deploy.py 3 1 $LEADERIP
40 changes: 40 additions & 0 deletions voltdb/zookeepercli/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## Zookeeper in VoltDB

Simple, lightweight, dependable CLI for ZooKeeper

### Build zookeepercli

zookeepercli is a non-interactive command line client for ZooKeeper.

```bash
$ go get github.com/let-us-go/zkcli
$ go install github.com/let-us-go/zkcli
```

### zookeepercli commands

```bash
$ zkcli -help

get <path>
ls <path>
create <path> [<data>]
set <path> [<data>]
delete <path>
connect <host:port>
addauth <scheme> <auth>
close

Usage of zkcli:
-p string
Password
-s string
Servers (default "127.0.0.1:2181")
-u string
Username
-version
Show version info
```