-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[db voltdb] Add VoltDB client (#1319)
Add binding based on MIT licensed client version for VoltDB
- Loading branch information
1 parent
178e4e5
commit cc165f2
Showing
23 changed files
with
1,988 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,4 @@ output* | |
|
||
# ignore standard Mac OS X files/dirs | ||
.DS_Store | ||
/differentbin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
179
voltdb/src/main/java/com/yahoo/ycsb/db/voltdb/ConnectionHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.