Skip to content
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

Added support for Apache Crail (Incubating) #1266

Merged
merged 7 commits into from
Jun 1, 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
1 change: 1 addition & 0 deletions bin/bindings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ cassandra2-cql:com.yahoo.ycsb.db.CassandraCQLClient
cloudspanner:com.yahoo.ycsb.db.cloudspanner.CloudSpannerClient
couchbase:com.yahoo.ycsb.db.CouchbaseClient
couchbase2:com.yahoo.ycsb.db.couchbase2.Couchbase2Client
crail:com.yahoo.ycsb.db.crail.CrailClient
dynamodb:com.yahoo.ycsb.db.DynamoDBClient
elasticsearch:com.yahoo.ycsb.db.ElasticsearchClient
elasticsearch5:com.yahoo.ycsb.db.elasticsearch5.ElasticsearchClient
Expand Down
1 change: 1 addition & 0 deletions bin/ycsb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ DATABASES = {
"cloudspanner" : "com.yahoo.ycsb.db.cloudspanner.CloudSpannerClient",
"couchbase" : "com.yahoo.ycsb.db.CouchbaseClient",
"couchbase2" : "com.yahoo.ycsb.db.couchbase2.Couchbase2Client",
"crail" : "com.yahoo.ycsb.db.crail.CrailClient",
"dynamodb" : "com.yahoo.ycsb.db.DynamoDBClient",
"elasticsearch": "com.yahoo.ycsb.db.ElasticsearchClient",
"elasticsearch5": "com.yahoo.ycsb.db.elasticsearch5.ElasticsearchClient",
Expand Down
65 changes: 65 additions & 0 deletions crail/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<!--
Copyright (c) 2015 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.
-->

## Quick Start

This section describes how to run YCSB on Apache Crail.

### 1. Start Crail

https://incubator-crail.readthedocs.io

### 2. Install Java and Maven

### 3. Set Up YCSB

Git clone YCSB and compile:

git clone https://github.com/brianfrankcooper/YCSB.git
cd YCSB
mvn -pl com.yahoo.ycsb:crail-binding -am clean package

### 4. Provide Crail Connection Parameters

Connction parameters have to be defined in $CRAIL_HOME/conf/crail-site.conf.

* `crail.namenode.address` - The Crail cluster to connect to (default: `crail://namenode:9060`)
* `crail.blocksize` - The block size (bytes) of the Crail cluster (default: `1048576`)
* `crail.buffersize` - The buffer size (bytes) used by the client (default: `crail.blocksize`)
* `crail.cachelimit` - Maximum client side cache (bytes) (default: `1073741824`)
* `crail.cachepath` - Directory where to mmap memory from (no default)
* `crail.storage.types` - Comma separated list of storage tiers (default: `org.apache.crail.storage.tcp.TcpStorageTier`)

The following benchmark parameters are available.

* `crail.enumeratekeys` - Whether to make keys visible for enumeration or not (default: `false`)

Add them to the workload or set them with the shell command, as in:

./bin/ycsb load crail -s -P workloads/workloada -p crail.enumeratekeys=true >outputLoad.txt


### 5. Load Data and Run Tests

Load the data:

./bin/ycsb load crail -s -P workloads/workloada

Run the workload test:

./bin/ycsb run crail -s -P workloads/workloada

65 changes: 65 additions & 0 deletions crail/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2015-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.16.0-SNAPSHOT</version>
<relativePath>../binding-parent</relativePath>
</parent>

<artifactId>crail-binding</artifactId>
<name>Crail DB Binding</name>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>org.apache.crail</groupId>
<artifactId>crail-client</artifactId>
<version>${crail.version}</version>
</dependency>
<dependency>
<groupId>org.apache.crail</groupId>
<artifactId>crail-storage-rdma</artifactId>
<version>${crail.version}</version>
</dependency>
<dependency>
<groupId>org.apache.crail</groupId>
<artifactId>crail-storage-narpc</artifactId>
<version>${crail.version}</version>
</dependency>
<dependency>
<groupId>org.apache.crail</groupId>
<artifactId>crail-rpc-darpc</artifactId>
<version>${crail.version}</version>
</dependency>
<dependency>
<groupId>org.apache.crail</groupId>
<artifactId>crail-rpc-narpc</artifactId>
<version>${crail.version}</version>
</dependency>
<dependency>
<groupId>com.yahoo.ycsb</groupId>
<artifactId>core</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
175 changes: 175 additions & 0 deletions crail/src/main/java/com/yahoo/ycsb/db/crail/CrailClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
/**
* Copyright (c) 2015 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.
*/

package com.yahoo.ycsb.db.crail;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.Vector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.crail.CrailBufferedInputStream;
import org.apache.crail.CrailBufferedOutputStream;
import org.apache.crail.CrailStore;
import org.apache.crail.CrailKeyValue;
import org.apache.crail.CrailLocationClass;
import org.apache.crail.CrailNodeType;
import org.apache.crail.CrailStorageClass;
import org.apache.crail.conf.CrailConfiguration;
import com.yahoo.ycsb.ByteArrayByteIterator;
import com.yahoo.ycsb.ByteIterator;
import com.yahoo.ycsb.DB;
import com.yahoo.ycsb.DBException;
import com.yahoo.ycsb.Status;

/**
* Crail binding for <a href="http://crail.apache.org/">Crail</a>.
*/
public class CrailClient extends DB {
private static final Logger LOG = LoggerFactory.getLogger(CrailClient.class);

private CrailStore client;
private long startTime;
private long endTime;
private String usertable;
private boolean enumerateKeys;

@Override
public void init() throws DBException {
super.init();
try {
CrailConfiguration crailConf = new CrailConfiguration();
this.client = CrailStore.newInstance(crailConf);

usertable = getProperties().getProperty("table", "usertable");
enumerateKeys = Boolean.parseBoolean(getProperties().getProperty("crail.enumeratekeys", "false"));

if (client.lookup(usertable).get() == null) {
client.create(usertable, CrailNodeType.TABLE, CrailStorageClass.DEFAULT,
CrailLocationClass.DEFAULT, true).get().syncDir();
}
this.startTime = System.nanoTime();
} catch(Exception e){
throw new DBException(e);
}
}

@Override
public void cleanup() throws DBException {
try {
this.endTime = System.nanoTime();
long runTime = (endTime - startTime) / 1000000;
client.close();
} catch(Exception e){
throw new DBException(e);
}
}

@Override
public Status read(String table, String key, Set<String> fields, Map<String, ByteIterator> result) {
try {
String path = table + "/" + key;
CrailKeyValue file = client.lookup(path).get().asKeyValue();
CrailBufferedInputStream stream = file.getBufferedInputStream(1024);
while(stream.available() < Integer.BYTES){
assert true;
}
int fieldKeyLength = stream.readInt();
while(stream.available() < fieldKeyLength){
assert true;
}
byte[] fieldKey = new byte[fieldKeyLength];
int res = stream.read(fieldKey);
if (res != fieldKey.length){
stream.close();
return Status.ERROR;
}
while(stream.available() < Integer.BYTES){
assert true;
}
int fieldValueLength = stream.readInt();
while(stream.available() < fieldValueLength){
assert true;
}
byte[] fieldValue = new byte[fieldValueLength];
res = stream.read(fieldValue);
if (res != fieldValue.length){
stream.close();
return Status.ERROR;
}
result.put(new String(fieldKey), new ByteArrayByteIterator(fieldValue));

stream.close();
return Status.OK;
} catch(Exception e){
LOG.error("Error during read, table " + table + ", key " + key + ", exception " + e.getMessage());
return new Status("read error", "reading exception");
}
}

@Override
public Status scan(String table, String startKey, int recordCount, Set<String> fields,
Vector<HashMap<String, ByteIterator>> result) {
return Status.NOT_IMPLEMENTED;
}

@Override
public Status update(String table, String key, Map<String, ByteIterator> values) {
return insert(table, key, values);
}

@Override
public Status insert(String table, String key, Map<String, ByteIterator> values) {
try {
String path = table + "/" + key;
CrailKeyValue file = client.create(path, CrailNodeType.KEYVALUE, CrailStorageClass.DEFAULT,
CrailLocationClass.DEFAULT, enumerateKeys).get().asKeyValue();
CrailBufferedOutputStream stream = file.getBufferedOutputStream(1024);
for (Entry<String, ByteIterator> entry : values.entrySet()){
byte[] fieldKey = entry.getKey().getBytes();
int fieldKeyLength = fieldKey.length;
byte[] fieldValue = entry.getValue().toArray();
int fieldValueLength = fieldValue.length;
stream.writeInt(fieldKeyLength);
stream.write(fieldKey);
stream.writeInt(fieldValueLength);
stream.write(fieldValue);
}
file.syncDir();
stream.close();
} catch(Exception e){
LOG.error("Error during insert, table " + table + ", key " + key + ", exception " + e.getMessage());
return Status.ERROR;
}
return Status.OK;
}

@Override
public Status delete(String table, String key) {
try {
String path = table + "/" + key;
client.delete(path, false).get().syncDir();
} catch(Exception e){
LOG.error("Error during delete, table " + table + ", key " + key + ", exception " + e.getMessage());
return Status.ERROR;
}
return Status.OK;
}
}
21 changes: 21 additions & 0 deletions crail/src/main/java/com/yahoo/ycsb/db/crail/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Copyright (c) 2015 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 binding for <a href="http://www.crail.io/">Crail</a>.
*/
package com.yahoo.ycsb.db.crail;
5 changes: 5 additions & 0 deletions distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ LICENSE file.
<dependency>
<groupId>com.yahoo.ycsb</groupId>
<artifactId>couchbase2-binding</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.yahoo.ycsb</groupId>
<artifactId>crail-binding</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
Expand Down
6 changes: 4 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ LICENSE file.
<cassandra.cql.version>3.0.0</cassandra.cql.version>
<cloudspanner.version>0.36.0-beta</cloudspanner.version>
<couchbase.version>1.4.10</couchbase.version>
<couchbase2.version>2.3.1</couchbase2.version>
<couchbase2.version>2.3.1</couchbase2.version>
<crail.version>1.1-incubating</crail.version>
<elasticsearch5-version>5.5.1</elasticsearch5-version>
<foundationdb.version>5.2.5</foundationdb.version>
<geode.version>1.2.0</geode.version>
Expand Down Expand Up @@ -126,7 +127,8 @@ LICENSE file.
<module>cassandra</module>
<module>cloudspanner</module>
<module>couchbase</module>
<module>couchbase2</module>
<module>couchbase2</module>
<module>crail</module>
<module>dynamodb</module>
<module>elasticsearch</module>
<module>elasticsearch5</module>
Expand Down