use of oracle.kv.FaultException in project YCSB by brianfrankcooper.
the class NoSqlDbClient method update.
@Override
public Status update(String table, String key, HashMap<String, ByteIterator> values) {
for (Map.Entry<String, ByteIterator> entry : values.entrySet()) {
Key kvKey = createKey(table, key, entry.getKey());
Value kvValue = Value.createValue(entry.getValue().toArray());
try {
store.put(kvKey, kvValue);
} catch (FaultException e) {
System.err.println(e);
return Status.ERROR;
}
}
return Status.OK;
}
use of oracle.kv.FaultException 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);
}
}
use of oracle.kv.FaultException in project YCSB by brianfrankcooper.
the class NoSqlDbClient method read.
@Override
public Status read(String table, String key, Set<String> fields, HashMap<String, ByteIterator> result) {
Key kvKey = createKey(table, key);
SortedMap<Key, ValueVersion> kvResult;
try {
kvResult = store.multiGet(kvKey, null, null);
} catch (FaultException e) {
System.err.println(e);
return Status.ERROR;
}
for (Map.Entry<Key, ValueVersion> entry : kvResult.entrySet()) {
/* If fields is null, read all fields */
String field = getFieldFromKey(entry.getKey());
if (fields != null && !fields.contains(field)) {
continue;
}
result.put(field, new ByteArrayByteIterator(entry.getValue().getValue().getValue()));
}
return Status.OK;
}
Aggregations