in asynchbase/src/main/java/site/ycsb/db/AsyncHBaseClient.java [97:177]
public void init() throws DBException {
if (getProperties().getProperty(CLIENT_SIDE_BUFFERING_PROPERTY, "false")
.toLowerCase().equals("true")) {
clientSideBuffering = true;
}
if (getProperties().getProperty(DURABILITY_PROPERTY, "true")
.toLowerCase().equals("false")) {
durability = false;
}
final String columnFamily = getProperties().getProperty(COLUMN_FAMILY_PROPERTY);
if (columnFamily == null || columnFamily.isEmpty()) {
System.err.println("Error, must specify a columnfamily for HBase table");
throw new DBException("No columnfamily specified");
}
columnFamilyBytes = columnFamily.getBytes();
if ((getProperties().getProperty("debug") != null)
&& (getProperties().getProperty("debug").compareTo("true") == 0)) {
debug = true;
}
joinTimeout = Integer.parseInt(getProperties().getProperty(
JOIN_TIMEOUT_PROPERTY, JOIN_TIMEOUT_PROPERTY_DEFAULT));
final boolean prefetchMeta = getProperties()
.getProperty(PREFETCH_META_PROPERTY, "false")
.toLowerCase().equals("true") ? true : false;
try {
synchronized (MUTEX) {
++threadCount;
if (client == null) {
final String configPath = getProperties().getProperty(CONFIG_PROPERTY);
final Config config;
if (configPath == null || configPath.isEmpty()) {
config = new Config();
final Iterator<Entry<Object, Object>> iterator = getProperties()
.entrySet().iterator();
while (iterator.hasNext()) {
final Entry<Object, Object> property = iterator.next();
config.overrideConfig((String)property.getKey(),
(String)property.getValue());
}
} else {
config = new Config(configPath);
}
client = new HBaseClient(config);
// 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 {
client.ensureTableExists(table).join(joinTimeout);
} catch (InterruptedException e1) {
Thread.currentThread().interrupt();
} catch (Exception e) {
throw new DBException(e);
}
if (prefetchMeta) {
try {
if (debug) {
System.out.println("Starting meta prefetch for table " + table);
}
client.prefetchMeta(table).join(joinTimeout);
if (debug) {
System.out.println("Completed meta prefetch for table " + table);
}
} catch (InterruptedException e) {
System.err.println("Interrupted during prefetch");
Thread.currentThread().interrupt();
} catch (Exception e) {
throw new DBException("Failed prefetch", e);
}
}
}
}
} catch (IOException e) {
throw new DBException("Failed instantiation of client", e);
}
}