-
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.
[crail] Added support for Apache Crail (Incubating) (#1266)
* Adding support for Apache Crail (crail.apache.org) * Adding Crail benchmark source and README * Cleaning white space * Fixing CrailClient::read - Thanks @PepperJo * Moving classes to Crail specific package * Use a Logging framework instead of System.out * 1) Make binding respect configuration of table name 2) Add new benchmark parameter 'crail.enumeratekeys'
- Loading branch information
1 parent
266d19b
commit 1b6e858
Showing
8 changed files
with
337 additions
and
2 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
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,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 | ||
|
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,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
175
crail/src/main/java/com/yahoo/ycsb/db/crail/CrailClient.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,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
21
crail/src/main/java/com/yahoo/ycsb/db/crail/package-info.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,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; |
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