Skip to content

Commit

Permalink
[db voltdb] Add VoltDB client (#1319)
Browse files Browse the repository at this point in the history
Add binding based on MIT licensed client version for VoltDB
  • Loading branch information
srmadscience authored and busbey committed Sep 17, 2019
1 parent 178e4e5 commit cc165f2
Show file tree
Hide file tree
Showing 23 changed files with 1,988 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ output*

# ignore standard Mac OS X files/dirs
.DS_Store
/differentbin/
1 change: 1 addition & 0 deletions bin/bindings.properties
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,4 @@ solr:com.yahoo.ycsb.db.solr.SolrClient
solr6:com.yahoo.ycsb.db.solr6.SolrClient
tarantool:com.yahoo.ycsb.db.TarantoolClient
tablestore:com.yahoo.ycsb.db.tablestore.TableStoreClient
voltdb:com.yahoo.ycsb.db.voltdb.VoltClient4
Empty file modified bin/ycsb.bat
100644 → 100755
Empty file.
6 changes: 6 additions & 0 deletions distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,12 @@ LICENSE file.
<version>${project.version}</version>
</dependency>
-->
<dependency>
<groupId>com.yahoo.ycsb</groupId>
<artifactId>voltdb-binding</artifactId>
<version>${project.version}</version>
</dependency>

</dependencies>
<build>
<plugins>
Expand Down
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ LICENSE file.
<thrift.version>0.8.0</thrift.version>
<voldemort.version>0.81</voldemort.version>
<tablestore.version>4.8.0</tablestore.version>
<voltdb.version>9.1.1</voltdb.version>
</properties>

<modules>
Expand Down Expand Up @@ -168,6 +169,7 @@ LICENSE file.
<module>tarantool</module>
<module>tablestore</module>
<!--<module>voldemort</module>-->
<module>voltdb</module>
</modules>

<build>
Expand Down
86 changes: 86 additions & 0 deletions voltdb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<!--
Copyright (c) 2010 Yahoo! Inc., 2012 - 2019 YCSB contributors.
All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you
may not use this file except in compliance with the License. You
may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied. See the License for the specific language governing
permissions and limitations under the License. See accompanying
LICENSE file.
-->
# YCSB for VoltDB

![VoltDB Logo](https://www.voltdb.com/wp-content/uploads/2016/10/VoltDB-logo-320x132.jpg?ycsb=true "VoltDB")

## README

This README describes how to run YCSB on VoltDB.

Here at VoltDB we use 4 machines for testing - 1 client and a 3 node cluster.

### 1. Install Java on all the machines involved.

VoltDB uses Java. Either [Oracle Java](https://www.oracle.com/technetwork/java/javase/downloads/index.html) or [OpenJDK](https://openjdk.java.net/) will work.


### 3. Install and configure VoltDB

If you don't already have a copy of VoltDB you should [download](https://www.voltdb.com/try-voltdb/) and install it.
Make sure you know the hostnames/ip addresses of all the nodes in the cluster and that [port 21212](https://docs.voltdb.com/AdminGuide/HostConfigPortOpts.php) is open for your client.

A representative VoltDB cluster would have 3 nodes and a '[K factor](https://docs.voltdb.com/UsingVoltDB/KSafeEnable.php)' of 1. This configuration allows work to continue if a server dies.

Note: If you contact us we can give you access to AWS Cloudformation scripts and a matching AMI to create a cluster for you.

### 4. Install YCSB

Download the [latest YCSB](https://github.com/brianfrankcooper/YCSB/releases/latest) file. Follow the instructions.

### 5. Configure VoltDB parameters

Create a file called (for example) voltdb.properties:

recordcount=10000000
operationcount=10000000
voltdb.servers=localhost
threadcount=1
maxexecutiontime=300

Other possible entries would be:

- `voltdb.user`
- Username. Only needed if username/passwords enabled.
- `voltdb.password`
- Password. Only needed if username/passwords enabled.
- `voltdb.ratelimit`
- Maximum number of transactions allowed per second per 50 threads - e.g. 'voltdb.ratelimit=70000'. Note that as you increase the workload you eventually get to a point where throwing more and more transactions at a given configuration is counterproductive. For the three node configuration we mentioned above 70000 would be a good starting point for this value.
- `voltdb.scanall`
- When set to 'yes' uses a single query to return data for 'Scan' operations ('workload e') instead of a separate query per partition. The later is much more scalable but generates more network traffic.

### 6. Run YCSB

See: [Running a Workload](https://github.com/brianfrankcooper/YCSB/wiki/Running-a-Workload)

Make sure you keep an eye on the voltdb GUI. If you installed VoltDB on the same computer you are running YCSB on it will be at:

http://localhost:8080/

First load the data:

bin/ycsb.sh load voltdb -P workloads/workloada -P voltdb.properties

Then run the different workloads - 'a' through 'e':

bin/ycsb.sh run voltdb -P workloads/workloada -P voltdb.properties
bin/ycsb.sh run voltdb -P workloads/workloadb -P voltdb.properties
bin/ycsb.sh run voltdb -P workloads/workloadc -P voltdb.properties
bin/ycsb.sh run voltdb -P workloads/workloadd -P voltdb.properties
bin/ycsb.sh run voltdb -P workloads/workloade -P voltdb.properties

74 changes: 74 additions & 0 deletions voltdb/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (c) 2012 - 2016 YCSB contributors. All rights reserved. Licensed
under the Apache License, Version 2.0 (the "License"); you may not use this
file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
applicable law or agreed to in writing, software distributed under the License
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License. See accompanying
LICENSE file. -->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.yahoo.ycsb</groupId>
<artifactId>binding-parent</artifactId>
<version>0.17.0-SNAPSHOT</version>
<relativePath>../binding-parent</relativePath>
</parent>

<artifactId>voltdb-binding</artifactId>
<name>VoltDB Binding</name>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.yahoo.ycsb</groupId>
<artifactId>core</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.28</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.voltdb/voltdbclient -->
<dependency>
<groupId>org.voltdb</groupId>
<artifactId>voltdbclient</artifactId>
<version>9.1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.voltdb/voltdb -->
<dependency>
<groupId>org.voltdb</groupId>
<artifactId>voltdb</artifactId>
<version>9.1.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

179 changes: 179 additions & 0 deletions voltdb/src/main/java/com/yahoo/ycsb/db/voltdb/ConnectionHelper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
/**
* Copyright (c) 2015-2019 YCSB contributors. All rights reserved.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You
* may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License. See accompanying
* LICENSE file.
*/

/*
* VoltDB Connection Utility.
*/
package com.yahoo.ycsb.db.voltdb;

import java.io.IOException;
import java.net.Socket;
import java.util.concurrent.CountDownLatch;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.voltdb.client.Client;
import org.voltdb.client.ClientConfig;
import org.voltdb.client.ClientFactory;

/**
* Help class to create VoltDB connections for YCSB benchmark.
*/
public final class ConnectionHelper {

/**
* Default port for VoltDB.
*/
private static final int VOLTDB_DEFAULT_PORT = 21212;

/**
* hidden constructor.
*/
private ConnectionHelper() {

}

/**
* Creates a factory used to connect to a VoltDB instance. (Note that if a
* corresponding connection exists, all parameters other than 'servers' are
* ignored)
*
* @param servers The comma separated list of VoltDB servers in
* hostname[:port] format that the instance will use.
* @param user The username for the connection
* @param password The password for the specified user
* @param ratelimit A limit on the number of transactions per second for the
* VoltDB instance
* @return The existing factory if a corresponding connection has already been
* created; the newly created one otherwise.
* @throws IOException Throws if a connection is already open with a
* different server string.
* @throws InterruptedException
*/
public static Client createConnection(String servers, String user, String password,
int ratelimit) throws IOException, InterruptedException {

ClientConfig config = new ClientConfig(user, password);
config.setMaxTransactionsPerSecond(ratelimit);
Client client = ClientFactory.createClient(config);

// Note that in VoltDB there is a distinction between creating an instance of a client
// and actually connecting to the DB...
connect(client, servers);

return client;
}


/**
* Connect to a single server with retry. Limited exponential backoff. No
* timeout. This will run until the process is killed if it's not able to
* connect.
*
* @param server hostname:port or just hostname (hostname can be ip).
*/
private static void connectToOneServerWithRetry(final Client client, String server) {

Logger logger = LoggerFactory.getLogger(ConnectionHelper.class);

int sleep = 1000;
while (true) {
try {
client.createConnection(server);
break;
} catch (Exception e) {
logger.error("Connection failed - retrying in %d second(s).\n", sleep / 1000);
try {
Thread.sleep(sleep);
} catch (java.lang.InterruptedException e2) {
logger.error(e2.getMessage());
}
if (sleep < 8000) {
sleep += sleep;
}
}
}

logger.info("Connected to VoltDB node at:" + server);
}

/**
* See if DB servers are present on the network.
*
* @return true or false
*/
public static boolean checkDBServers(String servernames) {

String[] serverNamesArray = servernames.split(",");

boolean dbThere = false;

Socket socket = null;
try {
// Connect
socket = new Socket(serverNamesArray[0], VOLTDB_DEFAULT_PORT);
dbThere = true;
} catch (IOException connectFailed) {
dbThere = false;
} finally {
if (socket != null) {
try {
socket.close();
} catch (IOException ignore) {
// Ignore.
}
}
socket = null;
}

return dbThere;

}

/**
* Connect to a set of servers in parallel. Each will retry until connection.
* This call will block until all have connected.
*
* @param servers A comma separated list of servers using the hostname:port
* syntax (where :port is optional).
* @throws InterruptedException if anything bad happens with the threads.
*/
private static void connect(final Client client, String servers) throws InterruptedException {

Logger logger = LoggerFactory.getLogger(ConnectionHelper.class);

logger.info("Connecting to VoltDB...");

String[] serverArray = servers.split(",");
final CountDownLatch connections = new CountDownLatch(serverArray.length);

// use a new thread to connect to each server
for (final String server : serverArray) {
new Thread(new Runnable() {
@Override
public void run() {
connectToOneServerWithRetry(client, server);
connections.countDown();
}
}).start();
}
// block until all have connected
connections.await();
}


}
Loading

0 comments on commit cc165f2

Please sign in to comment.