use of org.apache.gora.kudu.utils.KuduParameters in project gora by apache.
the class KuduStore method initialize.
@Override
public void initialize(Class<K> keyClass, Class<T> persistentClass, Properties properties) throws GoraException {
try {
super.initialize(keyClass, persistentClass, properties);
KuduMappingBuilder<K, T> builder = new KuduMappingBuilder<>(this);
InputStream mappingStream;
if (properties.containsKey(XML_MAPPING_DEFINITION)) {
if (LOG.isTraceEnabled()) {
LOG.trace("{} = {}", XML_MAPPING_DEFINITION, properties.getProperty(XML_MAPPING_DEFINITION));
}
mappingStream = org.apache.commons.io.IOUtils.toInputStream(properties.getProperty(XML_MAPPING_DEFINITION), (Charset) null);
} else {
mappingStream = getClass().getClassLoader().getResourceAsStream(getConf().get(PARSE_MAPPING_FILE_KEY, DEFAULT_MAPPING_FILE));
}
builder.readMappingFile(mappingStream);
kuduMapping = builder.getKuduMapping();
KuduParameters kuduParameters = KuduParameters.load(properties, getConf());
KuduClient.KuduClientBuilder kuduClientBuilder = new KuduClient.KuduClientBuilder(kuduParameters.getMasterAddresses());
if (kuduParameters.getBossCount() != null) {
kuduClientBuilder.bossCount(kuduParameters.getBossCount());
}
if (kuduParameters.getDefaultAdminOperationTimeoutMs() != null) {
kuduClientBuilder.defaultAdminOperationTimeoutMs(kuduParameters.getDefaultAdminOperationTimeoutMs());
}
if (kuduParameters.getDefaultOperationTimeoutMs() != null) {
kuduClientBuilder.defaultOperationTimeoutMs(kuduParameters.getDefaultOperationTimeoutMs());
}
if (kuduParameters.getDefaultSocketReadTimeoutMs() != null) {
kuduClientBuilder.defaultSocketReadTimeoutMs(kuduParameters.getDefaultSocketReadTimeoutMs());
}
if (kuduParameters.getWorkerCount() != null) {
kuduClientBuilder.workerCount(kuduParameters.getWorkerCount());
}
if (kuduParameters.isClientStatistics() != null && !kuduParameters.isClientStatistics()) {
kuduClientBuilder.disableStatistics();
}
client = kuduClientBuilder.build();
session = client.newSession();
if (kuduParameters.getFlushMode() != null) {
session.setFlushMode(SessionConfiguration.FlushMode.valueOf(kuduParameters.getFlushMode()));
}
if (kuduParameters.getFlushInterval() != null) {
session.setFlushInterval(kuduParameters.getFlushInterval());
}
LOG.info("Kudu store was successfully initialized");
if (!schemaExists()) {
createSchema();
} else {
table = client.openTable(kuduMapping.getTableName());
}
} catch (Exception ex) {
throw new GoraException(ex);
}
}
use of org.apache.gora.kudu.utils.KuduParameters in project gora by apache.
the class KuduStoreMetadataAnalyzer method initialize.
@Override
public void initialize() throws GoraException {
Properties createProps = DataStoreFactory.createProps();
KuduParameters kuduParameters = KuduParameters.load(createProps, getConf());
KuduClient.KuduClientBuilder kuduClientBuilder = new KuduClient.KuduClientBuilder(kuduParameters.getMasterAddresses());
if (kuduParameters.getBossCount() != null) {
kuduClientBuilder.bossCount(kuduParameters.getBossCount());
}
if (kuduParameters.getDefaultAdminOperationTimeoutMs() != null) {
kuduClientBuilder.defaultAdminOperationTimeoutMs(kuduParameters.getDefaultAdminOperationTimeoutMs());
}
if (kuduParameters.getDefaultOperationTimeoutMs() != null) {
kuduClientBuilder.defaultOperationTimeoutMs(kuduParameters.getDefaultOperationTimeoutMs());
}
if (kuduParameters.getDefaultSocketReadTimeoutMs() != null) {
kuduClientBuilder.defaultSocketReadTimeoutMs(kuduParameters.getDefaultSocketReadTimeoutMs());
}
if (kuduParameters.getWorkerCount() != null) {
kuduClientBuilder.workerCount(kuduParameters.getWorkerCount());
}
if (kuduParameters.isClientStatistics() != null && !kuduParameters.isClientStatistics()) {
kuduClientBuilder.disableStatistics();
}
client = kuduClientBuilder.build();
}
Aggregations