Search in sources :

Example 21 with DBException

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

the class HypertableClient 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 ((getProperties().getProperty("debug") != null) && (getProperties().getProperty("debug").equals("true"))) {
        debug = true;
    }
    try {
        connection = ThriftClient.create("localhost", THRIFTBROKER_PORT);
        if (!connection.namespace_exists(NAMESPACE)) {
            connection.namespace_create(NAMESPACE);
        }
        ns = connection.open_namespace(NAMESPACE);
    } catch (ClientException e) {
        throw new DBException("Could not open namespace", e);
    } catch (TException e) {
        throw new DBException("Could not open namespace", e);
    }
    columnFamily = getProperties().getProperty("columnfamily");
    if (columnFamily == null) {
        System.err.println("Error, must specify a " + "columnfamily for Hypertable table");
        throw new DBException("No columnfamily specified");
    }
}
Also used : TException(org.apache.thrift.TException) DBException(com.yahoo.ycsb.DBException) ClientException(org.hypertable.thriftgen.ClientException)

Example 22 with DBException

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

the class JdbcDBClientTest method setupWithBatch.

public static void setupWithBatch(int batchSize, boolean autoCommit) {
    try {
        jdbcConnection = DriverManager.getConnection(TEST_DB_URL);
        jdbcDBClient = new JdbcDBClient();
        Properties p = new Properties();
        p.setProperty(JdbcDBClient.CONNECTION_URL, TEST_DB_URL);
        p.setProperty(JdbcDBClient.DRIVER_CLASS, TEST_DB_DRIVER);
        p.setProperty(JdbcDBClient.CONNECTION_USER, TEST_DB_USER);
        p.setProperty(JdbcDBClient.DB_BATCH_SIZE, Integer.toString(batchSize));
        p.setProperty(JdbcDBClient.JDBC_BATCH_UPDATES, "true");
        p.setProperty(JdbcDBClient.JDBC_AUTO_COMMIT, Boolean.toString(autoCommit));
        jdbcDBClient.setProperties(p);
        jdbcDBClient.init();
    } catch (SQLException e) {
        e.printStackTrace();
        fail("Could not create local Database");
    } catch (DBException e) {
        e.printStackTrace();
        fail("Could not create JdbcDBClient instance");
    }
}
Also used : DBException(com.yahoo.ycsb.DBException) Properties(java.util.Properties)

Example 23 with DBException

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

the class KuduYCSBClient method initClient.

private static synchronized void initClient(String tableName, Properties prop) throws DBException {
    if (client != null) {
        return;
    }
    String masterAddresses = prop.getProperty(MASTER_ADDRESSES_OPT);
    if (masterAddresses == null) {
        masterAddresses = "localhost:7051";
    }
    int numTablets = getIntFromProp(prop, PRE_SPLIT_NUM_TABLETS_OPT, 4);
    if (numTablets > MAX_TABLETS) {
        throw new DBException(String.format("Specified number of tablets (%s) must be equal or below %s", numTablets, MAX_TABLETS));
    }
    int numReplicas = getIntFromProp(prop, TABLE_NUM_REPLICAS, 3);
    int blockSize = getIntFromProp(prop, BLOCK_SIZE_OPT, BLOCK_SIZE_DEFAULT);
    client = new KuduClient.KuduClientBuilder(masterAddresses).defaultSocketReadTimeoutMs(DEFAULT_SLEEP).defaultOperationTimeoutMs(DEFAULT_SLEEP).defaultAdminOperationTimeoutMs(DEFAULT_SLEEP).build();
    LOG.debug("Connecting to the masters at {}", masterAddresses);
    int fieldCount = getIntFromProp(prop, CoreWorkload.FIELD_COUNT_PROPERTY, Integer.parseInt(CoreWorkload.FIELD_COUNT_PROPERTY_DEFAULT));
    List<ColumnSchema> columns = new ArrayList<>(fieldCount + 1);
    ColumnSchema keyColumn = new ColumnSchema.ColumnSchemaBuilder(KEY, STRING).key(true).desiredBlockSize(blockSize).build();
    columns.add(keyColumn);
    COLUMN_NAMES.add(KEY);
    for (int i = 0; i < fieldCount; i++) {
        String name = "field" + i;
        COLUMN_NAMES.add(name);
        columns.add(new ColumnSchema.ColumnSchemaBuilder(name, STRING).desiredBlockSize(blockSize).build());
    }
    schema = new Schema(columns);
    CreateTableOptions builder = new CreateTableOptions();
    builder.setRangePartitionColumns(new ArrayList<String>());
    List<String> hashPartitionColumns = new ArrayList<>();
    hashPartitionColumns.add(KEY);
    builder.addHashPartitions(hashPartitionColumns, numTablets);
    builder.setNumReplicas(numReplicas);
    try {
        client.createTable(tableName, schema, builder);
    } catch (Exception e) {
        if (!e.getMessage().contains("already exists")) {
            throw new DBException("Couldn't create the table", e);
        }
    }
}
Also used : DBException(com.yahoo.ycsb.DBException) Schema(org.apache.kudu.Schema) ColumnSchema(org.apache.kudu.ColumnSchema) ArrayList(java.util.ArrayList) ColumnSchema(org.apache.kudu.ColumnSchema) DBException(com.yahoo.ycsb.DBException) TimeoutException(com.stumbleupon.async.TimeoutException)

Example 24 with DBException

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

the class NoSqlDbClient method init.

@Override
public void init() throws DBException {
    Properties properties = getProperties();
    /* Mandatory properties */
    String storeName = properties.getProperty("storeName", "kvstore");
    String[] helperHosts = properties.getProperty("helperHost", "localhost:5000").split(",");
    KVStoreConfig config = new KVStoreConfig(storeName, helperHosts);
    /* Optional properties */
    String p;
    p = properties.getProperty("consistency");
    if (p != null) {
        if (p.equalsIgnoreCase("ABSOLUTE")) {
            config.setConsistency(Consistency.ABSOLUTE);
        } else if (p.equalsIgnoreCase("NONE_REQUIRED")) {
            config.setConsistency(Consistency.NONE_REQUIRED);
        } else {
            throw new DBException("Illegal value in consistency property");
        }
    }
    p = properties.getProperty("durability");
    if (p != null) {
        if (p.equalsIgnoreCase("COMMIT_NO_SYNC")) {
            config.setDurability(Durability.COMMIT_NO_SYNC);
        } else if (p.equalsIgnoreCase("COMMIT_SYNC")) {
            config.setDurability(Durability.COMMIT_SYNC);
        } else if (p.equalsIgnoreCase("COMMIT_WRITE_NO_SYNC")) {
            config.setDurability(Durability.COMMIT_WRITE_NO_SYNC);
        } else {
            throw new DBException("Illegal value in durability property");
        }
    }
    int maxActiveRequests = getPropertyInt(properties, "requestLimit.maxActiveRequests", RequestLimitConfig.DEFAULT_MAX_ACTIVE_REQUESTS);
    int requestThresholdPercent = getPropertyInt(properties, "requestLimit.requestThresholdPercent", RequestLimitConfig.DEFAULT_REQUEST_THRESHOLD_PERCENT);
    int nodeLimitPercent = getPropertyInt(properties, "requestLimit.nodeLimitPercent", RequestLimitConfig.DEFAULT_NODE_LIMIT_PERCENT);
    RequestLimitConfig requestLimitConfig;
    /*
     * It is said that the constructor could throw NodeRequestLimitException in
     * Javadoc, the exception is not provided
     */
    // try {
    requestLimitConfig = new RequestLimitConfig(maxActiveRequests, requestThresholdPercent, nodeLimitPercent);
    // } catch (NodeRequestLimitException e) {
    // throw new DBException(e);
    // }
    config.setRequestLimit(requestLimitConfig);
    p = properties.getProperty("requestTimeout");
    if (p != null) {
        long timeout = 1;
        try {
            timeout = Long.parseLong(p);
        } catch (NumberFormatException e) {
            throw new DBException("Illegal number format in requestTimeout property");
        }
        try {
            // TODO Support other TimeUnit
            config.setRequestTimeout(timeout, TimeUnit.SECONDS);
        } catch (IllegalArgumentException e) {
            throw new DBException(e);
        }
    }
    try {
        store = KVStoreFactory.getStore(config);
    } catch (FaultException e) {
        throw new DBException(e);
    }
}
Also used : KVStoreConfig(oracle.kv.KVStoreConfig) DBException(com.yahoo.ycsb.DBException) RequestLimitConfig(oracle.kv.RequestLimitConfig) FaultException(oracle.kv.FaultException) Properties(java.util.Properties)

Example 25 with DBException

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

the class NoSqlDbClient method getPropertyInt.

private int getPropertyInt(Properties properties, String key, int defaultValue) throws DBException {
    String p = properties.getProperty(key);
    int i = defaultValue;
    if (p != null) {
        try {
            i = Integer.parseInt(p);
        } catch (NumberFormatException e) {
            throw new DBException("Illegal number format in " + key + " property");
        }
    }
    return i;
}
Also used : 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