use of oracle.kv.KVStoreConfig 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);
}
}
Aggregations