Search in sources :

Example 26 with DBException

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

the class GoogleDatastoreClient method init.

/**
   * Initialize any state for this DB. Called once per DB instance; there is
   * one DB instance per client thread.
   */
@Override
public void init() throws DBException {
    String debug = getProperties().getProperty("googledatastore.debug", null);
    if (null != debug && "true".equalsIgnoreCase(debug)) {
        logger.setLevel(Level.DEBUG);
    }
    // We need the following 3 essential properties to initialize datastore:
    //
    // - DatasetId,
    // - Path to private key file,
    // - Service account email address.
    String datasetId = getProperties().getProperty("googledatastore.datasetId", null);
    if (datasetId == null) {
        throw new DBException("Required property \"datasetId\" missing.");
    }
    String privateKeyFile = getProperties().getProperty("googledatastore.privateKeyFile", null);
    if (privateKeyFile == null) {
        throw new DBException("Required property \"privateKeyFile\" missing.");
    }
    String serviceAccountEmail = getProperties().getProperty("googledatastore.serviceAccountEmail", null);
    if (serviceAccountEmail == null) {
        throw new DBException("Required property \"serviceAccountEmail\" missing.");
    }
    // Below are properties related to benchmarking.
    String readConsistencyConfig = getProperties().getProperty("googledatastore.readConsistency", null);
    if (readConsistencyConfig != null) {
        try {
            this.readConsistency = ReadConsistency.valueOf(readConsistencyConfig.trim().toUpperCase());
        } catch (IllegalArgumentException e) {
            throw new DBException("Invalid read consistency specified: " + readConsistencyConfig + ". Expecting STRONG or EVENTUAL.");
        }
    }
    //
    // Entity Grouping Mode (googledatastore.entitygroupingmode), see
    // documentation in conf/googledatastore.properties.
    //
    String entityGroupingConfig = getProperties().getProperty("googledatastore.entityGroupingMode", null);
    if (entityGroupingConfig != null) {
        try {
            this.entityGroupingMode = EntityGroupingMode.valueOf(entityGroupingConfig.trim().toUpperCase());
        } catch (IllegalArgumentException e) {
            throw new DBException("Invalid entity grouping mode specified: " + entityGroupingConfig + ". Expecting ONE_ENTITY_PER_GROUP or " + "MULTI_ENTITY_PER_GROUP.");
        }
    }
    this.rootEntityName = getProperties().getProperty("googledatastore.rootEntityName", "YCSB_ROOT_ENTITY");
    try {
        // Setup the connection to Google Cloud Datastore with the credentials
        // obtained from the configure.
        DatastoreOptions.Builder options = new DatastoreOptions.Builder();
        Credential credential = DatastoreHelper.getServiceAccountCredential(serviceAccountEmail, privateKeyFile);
        logger.info("Using JWT Service Account credential.");
        logger.info("DatasetID: " + datasetId + ", Service Account Email: " + serviceAccountEmail + ", Private Key File Path: " + privateKeyFile);
        datastore = DatastoreFactory.get().create(options.credential(credential).projectId(datasetId).build());
    } catch (GeneralSecurityException exception) {
        throw new DBException("Security error connecting to the datastore: " + exception.getMessage(), exception);
    } catch (IOException exception) {
        throw new DBException("I/O error connecting to the datastore: " + exception.getMessage(), exception);
    }
    logger.info("Datastore client instance created: " + datastore.toString());
}
Also used : DBException(com.yahoo.ycsb.DBException) Credential(com.google.api.client.auth.oauth2.Credential) GeneralSecurityException(java.security.GeneralSecurityException) DatastoreOptions(com.google.datastore.v1.client.DatastoreOptions) IOException(java.io.IOException)

Example 27 with DBException

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

the class HBaseClient method init.

/**
   * Initialize any state for this DB.
   * Called once per DB instance; there is one DB instance per client thread.
   */
public void init() throws DBException {
    if ((getProperties().getProperty("debug") != null) && (getProperties().getProperty("debug").compareTo("true") == 0)) {
        debug = true;
    }
    if (getProperties().containsKey("clientbuffering")) {
        clientSideBuffering = Boolean.parseBoolean(getProperties().getProperty("clientbuffering"));
    }
    if (getProperties().containsKey("writebuffersize")) {
        writeBufferSize = Long.parseLong(getProperties().getProperty("writebuffersize"));
    }
    if ("false".equals(getProperties().getProperty("hbase.usepagefilter", "true"))) {
        usePageFilter = false;
    }
    if ("kerberos".equalsIgnoreCase(CONFIG.get("hbase.security.authentication"))) {
        CONFIG.set("hadoop.security.authentication", "Kerberos");
        UserGroupInformation.setConfiguration(CONFIG);
    }
    if ((getProperties().getProperty("principal") != null) && (getProperties().getProperty("keytab") != null)) {
        try {
            UserGroupInformation.loginUserFromKeytab(getProperties().getProperty("principal"), getProperties().getProperty("keytab"));
        } catch (IOException e) {
            System.err.println("Keytab file is not readable or not found");
            throw new DBException(e);
        }
    }
    try {
        THREAD_COUNT.getAndIncrement();
        synchronized (THREAD_COUNT) {
            if (hConn == null) {
                hConn = HConnectionManager.createConnection(CONFIG);
            }
        }
    } catch (IOException e) {
        System.err.println("Connection to HBase was not successful");
        throw new DBException(e);
    }
    columnFamily = getProperties().getProperty("columnfamily");
    if (columnFamily == null) {
        System.err.println("Error, must specify a columnfamily for HBase tableName");
        throw new DBException("No columnfamily specified");
    }
    columnFamilyBytes = Bytes.toBytes(columnFamily);
    // Terminate right now if tableName does not exist, since the client
    // will not propagate this error upstream once the workload
    // starts.
    String table = getProperties().getProperty(TABLENAME_PROPERTY, TABLENAME_PROPERTY_DEFAULT);
    try {
        HTableInterface ht = hConn.getTable(table);
        ht.getTableDescriptor();
    } catch (IOException e) {
        throw new DBException(e);
    }
}
Also used : DBException(com.yahoo.ycsb.DBException) IOException(java.io.IOException)

Example 28 with DBException

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

the class HBaseClient10 method init.

/**
   * Initialize any state for this DB. Called once per DB instance; there is one
   * DB instance per client thread.
   */
@Override
public void init() throws DBException {
    if ("true".equals(getProperties().getProperty("clientbuffering", "false"))) {
        this.clientSideBuffering = true;
    }
    if (getProperties().containsKey("writebuffersize")) {
        writeBufferSize = Long.parseLong(getProperties().getProperty("writebuffersize"));
    }
    if (getProperties().getProperty("durability") != null) {
        this.durability = Durability.valueOf(getProperties().getProperty("durability"));
    }
    if ("kerberos".equalsIgnoreCase(config.get("hbase.security.authentication"))) {
        config.set("hadoop.security.authentication", "Kerberos");
        UserGroupInformation.setConfiguration(config);
    }
    if ((getProperties().getProperty("principal") != null) && (getProperties().getProperty("keytab") != null)) {
        try {
            UserGroupInformation.loginUserFromKeytab(getProperties().getProperty("principal"), getProperties().getProperty("keytab"));
        } catch (IOException e) {
            System.err.println("Keytab file is not readable or not found");
            throw new DBException(e);
        }
    }
    try {
        threadCount.getAndIncrement();
        synchronized (CONNECTION_LOCK) {
            if (connection == null) {
                // Initialize if not set up already.
                connection = ConnectionFactory.createConnection(config);
            }
        }
    } catch (java.io.IOException e) {
        throw new DBException(e);
    }
    if ((getProperties().getProperty("debug") != null) && (getProperties().getProperty("debug").compareTo("true") == 0)) {
        debug = true;
    }
    if ("false".equals(getProperties().getProperty("hbase.usepagefilter", "true"))) {
        usePageFilter = false;
    }
    columnFamily = getProperties().getProperty("columnfamily");
    if (columnFamily == null) {
        System.err.println("Error, must specify a columnfamily for HBase table");
        throw new DBException("No columnfamily specified");
    }
    columnFamilyBytes = Bytes.toBytes(columnFamily);
    // Terminate right now if table does not exist, since the client
    // will not propagate this error upstream once the workload
    // starts.
    String table = getProperties().getProperty(TABLENAME_PROPERTY, TABLENAME_PROPERTY_DEFAULT);
    try {
        final TableName tName = TableName.valueOf(table);
        synchronized (CONNECTION_LOCK) {
            connection.getTable(tName).getTableDescriptor();
        }
    } catch (IOException e) {
        throw new DBException(e);
    }
}
Also used : DBException(com.yahoo.ycsb.DBException) TableName(org.apache.hadoop.hbase.TableName) IOException(java.io.IOException) IOException(java.io.IOException)

Example 29 with DBException

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

the class MemcachedClient method init.

@Override
public void init() throws DBException {
    try {
        client = createMemcachedClient();
        checkOperationStatus = Boolean.parseBoolean(getProperties().getProperty(CHECK_OPERATION_STATUS_PROPERTY, CHECK_OPERATION_STATUS_DEFAULT));
        objectExpirationTime = Integer.parseInt(getProperties().getProperty(OBJECT_EXPIRATION_TIME_PROPERTY, DEFAULT_OBJECT_EXPIRATION_TIME));
        shutdownTimeoutMillis = Integer.parseInt(getProperties().getProperty(SHUTDOWN_TIMEOUT_MILLIS_PROPERTY, DEFAULT_SHUTDOWN_TIMEOUT_MILLIS));
    } catch (Exception e) {
        throw new DBException(e);
    }
}
Also used : DBException(com.yahoo.ycsb.DBException) DBException(com.yahoo.ycsb.DBException) IOException(java.io.IOException)

Example 30 with DBException

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

the class RadosClientTest method setupClass.

@BeforeClass
public static void setupClass() throws DBException {
    radosclient = new RadosClient();
    Properties p = new Properties();
    p.setProperty(POOL_PROPERTY, POOL_TEST);
    try {
        radosclient.setProperties(p);
        radosclient.init();
    } catch (DBException | UnsatisfiedLinkError e) {
        assumeNoException("Ceph cluster is not running. Skipping tests.", e);
    }
}
Also used : DBException(com.yahoo.ycsb.DBException) Properties(java.util.Properties) BeforeClass(org.junit.BeforeClass)

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