use of site.ycsb.DBException in project YCSB by brianfrankcooper.
the class CrailClient method init.
@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);
}
}
use of site.ycsb.DBException in project YCSB by brianfrankcooper.
the class CouchbaseClient method init.
@Override
public void init() throws DBException {
Properties props = getProperties();
String url = props.getProperty(URL_PROPERTY, "http://127.0.0.1:8091/pools");
String bucket = props.getProperty(BUCKET_PROPERTY, "default");
String password = props.getProperty(PASSWORD_PROPERTY, "");
checkFutures = props.getProperty(CHECKF_PROPERTY, "true").equals("true");
useJson = props.getProperty(JSON_PROPERTY, "true").equals("true");
persistTo = parsePersistTo(props.getProperty(PERSIST_PROPERTY, "0"));
replicateTo = parseReplicateTo(props.getProperty(REPLICATE_PROPERTY, "0"));
designDoc = getProperties().getProperty(DESIGN_DOC_PROPERTY);
viewName = getProperties().getProperty(VIEW_PROPERTY);
stale = Stale.valueOf(getProperties().getProperty(STALE_PROPERTY, STALE_PROPERTY_DEFAULT).toUpperCase());
Double scanproportion = Double.valueOf(props.getProperty(SCAN_PROPERTY, SCAN_PROPERTY_DEFAULT));
Properties systemProperties = System.getProperties();
systemProperties.put("net.spy.log.LoggerImpl", "net.spy.memcached.compat.log.SLF4JLogger");
System.setProperties(systemProperties);
try {
client = new com.couchbase.client.CouchbaseClient(Arrays.asList(new URI(url)), bucket, password);
} catch (Exception e) {
throw new DBException("Could not create CouchbaseClient object.", e);
}
if (scanproportion > 0) {
try {
view = client.getView(designDoc, viewName);
} catch (Exception e) {
throw new DBException(String.format("%s=%s and %s=%s provided, unable to connect to view.", DESIGN_DOC_PROPERTY, designDoc, VIEW_PROPERTY, viewName), e.getCause());
}
}
}
use of site.ycsb.DBException in project YCSB by brianfrankcooper.
the class BackoffSelectStrategy method readN1ql.
/**
* Performs the {@link #read(String, String, Set, Map)} operation via N1QL ("SELECT").
*
* If this option should be used, the "-p couchbase.kv=false" property must be set.
*
* @param docId the document ID
* @param fields the fields to be loaded
* @param result the result map where the doc needs to be converted into
* @return The result of the operation.
*/
private Status readN1ql(final String docId, Set<String> fields, final Map<String, ByteIterator> result) throws Exception {
String readQuery = "SELECT " + joinFields(fields) + " FROM `" + bucketName + "` USE KEYS [$1]";
N1qlQueryResult queryResult = bucket.query(N1qlQuery.parameterized(readQuery, JsonArray.from(docId), N1qlParams.build().adhoc(adhoc).maxParallelism(maxParallelism)));
if (!queryResult.parseSuccess() || !queryResult.finalSuccess()) {
throw new DBException("Error while parsing N1QL Result. Query: " + readQuery + ", Errors: " + queryResult.errors());
}
N1qlQueryRow row;
try {
row = queryResult.rows().next();
} catch (NoSuchElementException ex) {
return Status.NOT_FOUND;
}
JsonObject content = row.value();
if (fields == null) {
// n1ql result set scoped under *.bucketName
content = content.getObject(bucketName);
fields = content.getNames();
}
for (String field : fields) {
Object value = content.get(field);
result.put(field, new StringByteIterator(value != null ? value.toString() : ""));
}
return Status.OK;
}
use of site.ycsb.DBException in project YCSB by brianfrankcooper.
the class CrailClient method cleanup.
@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);
}
}
use of site.ycsb.DBException in project YCSB by brianfrankcooper.
the class ElasticsearchRestClient method cleanup.
@Override
public void cleanup() throws DBException {
if (restClient != null) {
try {
restClient.close();
restClient = null;
} catch (final IOException e) {
throw new DBException(e);
}
}
}
Aggregations