Search in sources :

Example 6 with DBException

use of com.yahoo.ycsb.DBException in project YCSB by brianfrankcooper.

the class HBaseClient method cleanup.

/**
   * Cleanup any state for this DB.
   * Called once per DB instance; there is one DB instance per client thread.
   */
public void cleanup() throws DBException {
    // Get the measurements instance as this is the only client that should
    // count clean up time like an update since autoflush is off.
    Measurements measurements = Measurements.getMeasurements();
    try {
        long st = System.nanoTime();
        if (hTable != null) {
            hTable.flushCommits();
        }
        synchronized (THREAD_COUNT) {
            int threadCount = THREAD_COUNT.decrementAndGet();
            if (threadCount <= 0 && hConn != null) {
                hConn.close();
            }
        }
        long en = System.nanoTime();
        measurements.measure("UPDATE", (int) ((en - st) / 1000));
    } catch (IOException e) {
        throw new DBException(e);
    }
}
Also used : DBException(com.yahoo.ycsb.DBException) Measurements(com.yahoo.ycsb.measurements.Measurements) IOException(java.io.IOException)

Example 7 with DBException

use of com.yahoo.ycsb.DBException in project YCSB by brianfrankcooper.

the class HBaseClient10 method cleanup.

/**
   * Cleanup any state for this DB. Called once per DB instance; there is one DB
   * instance per client thread.
   */
@Override
public void cleanup() throws DBException {
    // Get the measurements instance as this is the only client that should
    // count clean up time like an update if client-side buffering is
    // enabled.
    Measurements measurements = Measurements.getMeasurements();
    try {
        long st = System.nanoTime();
        if (bufferedMutator != null) {
            bufferedMutator.close();
        }
        if (currentTable != null) {
            currentTable.close();
        }
        long en = System.nanoTime();
        final String type = clientSideBuffering ? "UPDATE" : "CLEANUP";
        measurements.measure(type, (int) ((en - st) / 1000));
        threadCount.decrementAndGet();
        if (threadCount.get() <= 0) {
            // Means we are done so ok to shut down the Connection.
            synchronized (CONNECTION_LOCK) {
                if (connection != null) {
                    connection.close();
                    connection = null;
                }
            }
        }
    } catch (IOException e) {
        throw new DBException(e);
    }
}
Also used : DBException(com.yahoo.ycsb.DBException) Measurements(com.yahoo.ycsb.measurements.Measurements) IOException(java.io.IOException)

Example 8 with DBException

use of com.yahoo.ycsb.DBException in project YCSB by brianfrankcooper.

the class AzureClient method init.

@Override
public void init() throws DBException {
    Properties props = getProperties();
    String protocol = props.getProperty(PROTOCOL, PROTOCOL_DEFAULT);
    if (protocol != "https" && protocol != "http") {
        throw new DBException("Protocol must be 'http' or 'https'!\n");
    }
    String table = props.getProperty(TABLE, TABLE_DEFAULT);
    partitionKey = props.getProperty(PARTITIONKEY, PARTITIONKEY_DEFAULT);
    batchSize = Integer.parseInt(props.getProperty(BATCHSIZE, BATCHSIZE_DEFAULT));
    if (batchSize < 1 || batchSize > BATCHSIZE_UPPERBOUND) {
        throw new DBException(String.format("Batchsize must be between 1 and %d!\n", BATCHSIZE_UPPERBOUND));
    }
    String account = props.getProperty(ACCOUNT);
    String key = props.getProperty(KEY);
    String tableEndPoint = props.getProperty(TABLE_ENDPOINT);
    String storageConnectionString = getStorageConnectionString(protocol, account, key, tableEndPoint);
    try {
        storageAccount = CloudStorageAccount.parse(storageConnectionString);
    } catch (Exception e) {
        throw new DBException("Could not connect to the account.\n", e);
    }
    tableClient = storageAccount.createCloudTableClient();
    try {
        cloudTable = tableClient.getTableReference(table);
        cloudTable.createIfNotExists();
    } catch (Exception e) {
        throw new DBException("Could not connect to the table.\n", e);
    }
}
Also used : DBException(com.yahoo.ycsb.DBException) Properties(java.util.Properties) DBException(com.yahoo.ycsb.DBException)

Example 9 with DBException

use of com.yahoo.ycsb.DBException in project YCSB by brianfrankcooper.

the class AccumuloClient method init.

@Override
public void init() throws DBException {
    colFam = new Text(getProperties().getProperty("accumulo.columnFamily"));
    inst = new ZooKeeperInstance(getProperties().getProperty("accumulo.instanceName"), getProperties().getProperty("accumulo.zooKeepers"));
    try {
        String principal = getProperties().getProperty("accumulo.username");
        AuthenticationToken token = new PasswordToken(getProperties().getProperty("accumulo.password"));
        connector = inst.getConnector(principal, token);
    } catch (AccumuloException e) {
        throw new DBException(e);
    } catch (AccumuloSecurityException e) {
        throw new DBException(e);
    }
    if (!(getProperties().getProperty("accumulo.pcFlag", "none").equals("none"))) {
        System.err.println("Sorry, the ZK based producer/consumer implementation has been removed. " + "Please see YCSB issue #416 for work on adding a general solution to coordinated work.");
    }
}
Also used : AccumuloException(org.apache.accumulo.core.client.AccumuloException) DBException(com.yahoo.ycsb.DBException) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) AuthenticationToken(org.apache.accumulo.core.client.security.tokens.AuthenticationToken) Text(org.apache.hadoop.io.Text) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance)

Example 10 with DBException

use of com.yahoo.ycsb.DBException in project YCSB by brianfrankcooper.

the class AsyncMongoDbClient method init.

/**
   * Initialize any state for this DB. Called once per DB instance; there is one
   * DB instance per client thread.
   */
@Override
public final void init() throws DBException {
    final int count = INIT_COUNT.incrementAndGet();
    synchronized (AsyncMongoDbClient.class) {
        final Properties props = getProperties();
        if (mongoClient != null) {
            database = mongoClient.getDatabase(databaseName);
            // the connections occupied.
            if (count > mongoClient.getConfig().getMaxConnectionCount()) {
                mongoClient.getConfig().setLockType(LockType.MUTEX);
            }
            return;
        }
        // Set insert batchsize, default 1 - to be YCSB-original equivalent
        batchSize = Integer.parseInt(props.getProperty("mongodb.batchsize", "1"));
        // Set is inserts are done as upserts. Defaults to false.
        useUpsert = Boolean.parseBoolean(props.getProperty("mongodb.upsert", "false"));
        // Just use the standard connection format URL
        // http://docs.mongodb.org/manual/reference/connection-string/
        // to configure the client.
        String url = props.getProperty("mongodb.url", "mongodb://localhost:27017/ycsb?w=1");
        if (!url.startsWith("mongodb://")) {
            System.err.println("ERROR: Invalid URL: '" + url + "'. Must be of the form " + "'mongodb://<host1>:<port1>,<host2>:<port2>/database?" + "options'. See " + "http://docs.mongodb.org/manual/reference/connection-string/.");
            System.exit(1);
        }
        MongoDbUri uri = new MongoDbUri(url);
        try {
            databaseName = uri.getDatabase();
            if ((databaseName == null) || databaseName.isEmpty()) {
                // Default database is "ycsb" if database is not
                // specified in URL
                databaseName = "ycsb";
            }
            mongoClient = MongoFactory.createClient(uri);
            MongoClientConfiguration config = mongoClient.getConfig();
            if (!url.toLowerCase().contains("locktype=")) {
                // assumed...
                config.setLockType(LockType.LOW_LATENCY_SPIN);
            }
            readPreference = config.getDefaultReadPreference();
            writeConcern = config.getDefaultDurability();
            database = mongoClient.getDatabase(databaseName);
            System.out.println("mongo connection created with " + url);
        } catch (final Exception e1) {
            System.err.println("Could not initialize MongoDB connection pool for Loader: " + e1.toString());
            e1.printStackTrace();
            return;
        }
    }
}
Also used : MongoDbUri(com.allanbank.mongodb.MongoDbUri) Properties(java.util.Properties) MongoClientConfiguration(com.allanbank.mongodb.MongoClientConfiguration) DBException(com.yahoo.ycsb.DBException)

Aggregations

DBException (com.yahoo.ycsb.DBException)32 Properties (java.util.Properties)15 IOException (java.io.IOException)10 TimeoutException (com.stumbleupon.async.TimeoutException)2 Measurements (com.yahoo.ycsb.measurements.Measurements)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 ArangoConfigure (com.arangodb.ArangoConfigure)1 ArangoDBException (com.arangodb.ArangoDBException)1 ArangoDriver (com.arangodb.ArangoDriver)1 ArangoException (com.arangodb.ArangoException)1 ArangoHost (com.arangodb.ArangoHost)1 MapBuilder (com.arangodb.util.MapBuilder)1 VPackBuilder (com.arangodb.velocypack.VPackBuilder)1 Rados (com.ceph.rados.Rados)1