use of org.apache.bookkeeper.conf.AbstractConfiguration in project bookkeeper by apache.
the class EtcdMetadataDriverBase method initialize.
/**
* Initialize metadata driver with provided configuration and <tt>statsLogger</tt>.
*
* @param conf configuration to initialize metadata driver
* @param statsLogger stats logger
* @throws MetadataException
*/
protected void initialize(AbstractConfiguration<?> conf, StatsLogger statsLogger) throws MetadataException {
this.conf = conf;
this.statsLogger = statsLogger;
final String metadataServiceUriStr;
try {
metadataServiceUriStr = conf.getMetadataServiceUri();
} catch (ConfigurationException ce) {
log.error("Failed to retrieve metadata service uri from configuration", ce);
throw new MetadataException(Code.INVALID_METADATA_SERVICE_URI, ce);
}
ServiceURI serviceURI = ServiceURI.create(metadataServiceUriStr);
this.keyPrefix = serviceURI.getServicePath();
List<String> etcdEndpoints = Lists.newArrayList(serviceURI.getServiceHosts()).stream().map(host -> String.format("http://%s", host)).collect(Collectors.toList());
log.info("Initializing etcd metadata driver : etcd endpoints = {}, key scope = {}", etcdEndpoints, keyPrefix);
synchronized (this) {
this.client = Client.builder().endpoints(etcdEndpoints.toArray(new String[etcdEndpoints.size()])).build();
}
this.layoutManager = new EtcdLayoutManager(client, keyPrefix);
}
Aggregations