use of site.ycsb.DBException in project YCSB by brianfrankcooper.
the class AccumuloClient method cleanup.
@Override
public void cleanup() throws DBException {
try {
Iterator<BatchWriter> iterator = writers.values().iterator();
while (iterator.hasNext()) {
BatchWriter writer = iterator.next();
writer.close();
iterator.remove();
}
} catch (MutationsRejectedException e) {
throw new DBException(e);
}
}
use of site.ycsb.DBException in project YCSB by brianfrankcooper.
the class BackoffSelectStrategy method init.
@Override
public void init() throws DBException {
Properties props = getProperties();
host = props.getProperty("couchbase.host", "127.0.0.1");
bucketName = props.getProperty("couchbase.bucket", "default");
String bucketPassword = props.getProperty("couchbase.password", "");
upsert = props.getProperty("couchbase.upsert", "false").equals("true");
persistTo = parsePersistTo(props.getProperty("couchbase.persistTo", "0"));
replicateTo = parseReplicateTo(props.getProperty("couchbase.replicateTo", "0"));
syncMutResponse = props.getProperty("couchbase.syncMutationResponse", "true").equals("true");
adhoc = props.getProperty("couchbase.adhoc", "false").equals("true");
kv = props.getProperty("couchbase.kv", "true").equals("true");
maxParallelism = Integer.parseInt(props.getProperty("couchbase.maxParallelism", "1"));
kvEndpoints = Integer.parseInt(props.getProperty("couchbase.kvEndpoints", "1"));
queryEndpoints = Integer.parseInt(props.getProperty("couchbase.queryEndpoints", "1"));
epoll = props.getProperty("couchbase.epoll", "false").equals("true");
boost = Integer.parseInt(props.getProperty("couchbase.boost", "3"));
networkMetricsInterval = Integer.parseInt(props.getProperty("couchbase.networkMetricsInterval", "0"));
runtimeMetricsInterval = Integer.parseInt(props.getProperty("couchbase.runtimeMetricsInterval", "0"));
documentExpiry = Integer.parseInt(props.getProperty("couchbase.documentExpiry", "0"));
scanAllQuery = "SELECT RAW meta().id FROM `" + bucketName + "` WHERE meta().id >= '$1' ORDER BY meta().id LIMIT $2";
try {
synchronized (INIT_COORDINATOR) {
if (env == null) {
LatencyMetricsCollectorConfig latencyConfig = networkMetricsInterval <= 0 ? DefaultLatencyMetricsCollectorConfig.disabled() : DefaultLatencyMetricsCollectorConfig.builder().emitFrequency(networkMetricsInterval).emitFrequencyUnit(TimeUnit.SECONDS).build();
MetricsCollectorConfig runtimeConfig = runtimeMetricsInterval <= 0 ? DefaultMetricsCollectorConfig.disabled() : DefaultMetricsCollectorConfig.create(runtimeMetricsInterval, TimeUnit.SECONDS);
DefaultCouchbaseEnvironment.Builder builder = DefaultCouchbaseEnvironment.builder().queryEndpoints(queryEndpoints).callbacksOnIoPool(true).runtimeMetricsCollectorConfig(runtimeConfig).networkLatencyMetricsCollectorConfig(latencyConfig).socketConnectTimeout(// 10 secs socket connect timeout
10000).connectTimeout(// 30 secs overall bucket open timeout
30000).kvTimeout(// 10 instead of 2.5s for KV ops
10000).kvEndpoints(kvEndpoints);
// Tune boosting and epoll based on settings
SelectStrategyFactory factory = boost > 0 ? new BackoffSelectStrategyFactory() : DefaultSelectStrategyFactory.INSTANCE;
int poolSize = boost > 0 ? boost : Integer.parseInt(System.getProperty("com.couchbase.ioPoolSize", Integer.toString(DefaultCoreEnvironment.IO_POOL_SIZE)));
ThreadFactory threadFactory = new DefaultThreadFactory("cb-io", true);
EventLoopGroup group = epoll ? new EpollEventLoopGroup(poolSize, threadFactory, factory) : new NioEventLoopGroup(poolSize, threadFactory, SelectorProvider.provider(), factory);
builder.ioPool(group, new IoPoolShutdownHook(group));
env = builder.build();
logParams();
}
}
cluster = CouchbaseCluster.create(env, host);
bucket = cluster.openBucket(bucketName, bucketPassword);
kvTimeout = env.kvTimeout();
} catch (Exception ex) {
throw new DBException("Could not connect to Couchbase Bucket.", ex);
}
if (!kv && !syncMutResponse) {
throw new DBException("Not waiting for N1QL responses on mutations not yet implemented.");
}
}
use of site.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);
}
String skipIndexString = getProperties().getProperty("googledatastore.skipIndex", null);
if (null != skipIndexString && "false".equalsIgnoreCase(skipIndexString)) {
skipIndex = false;
}
// 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);
String serviceAccountEmail = getProperties().getProperty("googledatastore.serviceAccountEmail", null);
// 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 = GoogleCredential.getApplicationDefault();
if (serviceAccountEmail != null && privateKeyFile != null) {
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);
} else {
logger.info("Using default gcloud credential.");
logger.info("DatasetID: " + datasetId + ", Service Account Email: " + ((GoogleCredential) credential).getServiceAccountId());
}
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 site.ycsb.DBException in project YCSB by brianfrankcooper.
the class GridDBClient method init.
public void init() throws DBException {
LOGGER.info("GridDBClient");
final Properties props = getProperties();
notificationAddress = props.getProperty("notificationAddress");
notificationPort = props.getProperty("notificationPort");
notificationMember = props.getProperty("notificationMember");
clusterName = props.getProperty("clusterName");
userName = props.getProperty("userName");
password = props.getProperty("password");
containerPrefix = props.getProperty("table", "usertable") + "@";
String fieldcount = props.getProperty("fieldcount");
String fieldlength = props.getProperty("fieldlength");
LOGGER.info("notificationAddress=" + notificationAddress + " notificationPort=" + notificationPort + " notificationMember=" + notificationMember);
LOGGER.info("clusterName=" + clusterName + " userName=" + userName);
LOGGER.info("fieldcount=" + fieldcount + " fieldlength=" + fieldlength);
final Properties gridstoreProp = new Properties();
if (clusterName == null || userName == null || password == null) {
LOGGER.severe("[ERROR] clusterName or userName or password argument not specified");
throw new DBException();
}
if (fieldcount == null || fieldlength == null) {
LOGGER.severe("[ERROR] fieldcount or fieldlength argument not specified");
throw new DBException();
} else {
if (!fieldcount.equals(String.valueOf(FIELD_NUM)) || !fieldlength.equals("100")) {
LOGGER.severe("[ERROR] Invalid argment: fieldcount or fieldlength");
throw new DBException();
}
}
if (notificationAddress != null) {
if (notificationPort == null) {
LOGGER.severe("[ERROR] notificationPort argument not specified");
throw new DBException();
}
// (A)multicast method
gridstoreProp.setProperty("notificationAddress", notificationAddress);
gridstoreProp.setProperty("notificationPort", notificationPort);
} else if (notificationMember != null) {
// (B)fixed list method
gridstoreProp.setProperty("notificationMember", notificationMember);
} else {
LOGGER.severe("[ERROR] notificationAddress and notificationMember argument not specified");
throw new DBException();
}
gridstoreProp.setProperty("clusterName", clusterName);
gridstoreProp.setProperty("user", userName);
gridstoreProp.setProperty("password", password);
gridstoreProp.setProperty("containerCacheSize", String.valueOf(DEFAULT_CACHE_CONTAINER_NUM));
List<ColumnInfo> columnInfoList = new ArrayList<ColumnInfo>();
ColumnInfo keyInfo = new ColumnInfo("key", SCHEMA_TYPE);
columnInfoList.add(keyInfo);
for (int i = 0; i < FIELD_NUM; i++) {
String columnName = String.format(VALUE_COLUMN_NAME_PREFIX + "%d", i);
ColumnInfo info = new ColumnInfo(columnName, SCHEMA_TYPE);
columnInfoList.add(info);
}
containerInfo = new ContainerInfo(null, ContainerType.COLLECTION, columnInfoList, true);
try {
GridStoreFactory.getInstance().setProperties(gridstoreProp);
store = GridStoreFactory.getInstance().getGridStore(gridstoreProp);
PartitionController controller = store.getPartitionController();
numContainer = controller.getPartitionCount();
for (int k = 0; k < numContainer; k++) {
String name = containerPrefix + k;
store.putContainer(name, containerInfo, false);
}
} catch (GSException e) {
LOGGER.severe("Exception: " + e.getMessage());
throw new DBException();
}
LOGGER.info("numContainer=" + numContainer + " containerCasheSize=" + String.valueOf(DEFAULT_CACHE_CONTAINER_NUM));
}
use of site.ycsb.DBException in project YCSB by brianfrankcooper.
the class GoogleBigtableClient method init.
@Override
public void init() throws DBException {
Properties props = getProperties();
// Defaults the user can override if needed
if (getProperties().containsKey(ASYNC_MUTATOR_MAX_MEMORY)) {
CONFIG.set(BigtableOptionsFactory.BIGTABLE_BUFFERED_MUTATOR_MAX_MEMORY_KEY, getProperties().getProperty(ASYNC_MUTATOR_MAX_MEMORY));
}
if (getProperties().containsKey(ASYNC_MAX_INFLIGHT_RPCS)) {
CONFIG.set(BigtableOptionsFactory.BIGTABLE_BULK_MAX_ROW_KEY_COUNT, getProperties().getProperty(ASYNC_MAX_INFLIGHT_RPCS));
}
// make it easy on ourselves by copying all CLI properties into the config object.
final Iterator<Entry<Object, Object>> it = props.entrySet().iterator();
while (it.hasNext()) {
Entry<Object, Object> entry = it.next();
CONFIG.set((String) entry.getKey(), (String) entry.getValue());
}
clientSideBuffering = getProperties().getProperty(CLIENT_SIDE_BUFFERING, "false").equals("true");
System.err.println("Running Google Bigtable with Proto API" + (clientSideBuffering ? " and client side buffering." : "."));
synchronized (CONFIG) {
++threadCount;
if (session == null) {
try {
options = BigtableOptionsFactory.fromConfiguration(CONFIG);
session = new BigtableSession(options);
// important to instantiate the first client here, otherwise the
// other threads may receive an NPE from the options when they try
// to read the cluster name.
client = session.getDataClient();
} catch (IOException e) {
throw new DBException("Error loading options from config: ", e);
}
} else {
client = session.getDataClient();
}
}
if ((getProperties().getProperty("debug") != null) && (getProperties().getProperty("debug").compareTo("true") == 0)) {
debug = true;
}
final String columnFamily = getProperties().getProperty("columnfamily");
if (columnFamily == null) {
System.err.println("Error, must specify a columnfamily for Bigtable table");
throw new DBException("No columnfamily specified");
}
columnFamilyBytes = Bytes.toBytes(columnFamily);
}
Aggregations