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());
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations