Search in sources :

Example 1 with DBException

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);
    }
}
Also used : DBException(site.ycsb.DBException) CrailConfiguration(org.apache.crail.conf.CrailConfiguration) DBException(site.ycsb.DBException)

Example 2 with DBException

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());
        }
    }
}
Also used : DBException(site.ycsb.DBException) Properties(java.util.Properties) URI(java.net.URI) DBException(site.ycsb.DBException)

Example 3 with DBException

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;
}
Also used : DBException(site.ycsb.DBException) StringByteIterator(site.ycsb.StringByteIterator) JsonObject(com.couchbase.client.java.document.json.JsonObject) JsonObject(com.couchbase.client.java.document.json.JsonObject)

Example 4 with DBException

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);
    }
}
Also used : DBException(site.ycsb.DBException) DBException(site.ycsb.DBException)

Example 5 with DBException

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);
        }
    }
}
Also used : DBException(site.ycsb.DBException) IOException(java.io.IOException)

Aggregations

DBException (site.ycsb.DBException)41 Properties (java.util.Properties)20 IOException (java.io.IOException)12 ArrayList (java.util.ArrayList)4 TimeoutException (com.stumbleupon.async.TimeoutException)3 ColumnInfo (com.toshiba.mwcloud.gs.ColumnInfo)2 AerospikeException (com.aerospike.client.AerospikeException)1 ClientPolicy (com.aerospike.client.policy.ClientPolicy)1 MongoClientConfiguration (com.allanbank.mongodb.MongoClientConfiguration)1 MongoDbUri (com.allanbank.mongodb.MongoDbUri)1 ClientConfiguration (com.amazonaws.ClientConfiguration)1 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)1 SSECustomerKey (com.amazonaws.services.s3.model.SSECustomerKey)1 ArangoDB (com.arangodb.ArangoDB)1 ArangoDBException (com.arangodb.ArangoDBException)1 Protocol (com.arangodb.Protocol)1 ConsistencyLevel (com.azure.cosmos.ConsistencyLevel)1 CosmosClientBuilder (com.azure.cosmos.CosmosClientBuilder)1 CosmosException (com.azure.cosmos.CosmosException)1 DirectConnectionConfig (com.azure.cosmos.DirectConnectionConfig)1