/** Creates a builder for the TopologySpec based on values in a topology properties config. */ public static TopologySpec.Builder builder(URI catalogURI, Properties topologyProps) { String name = topologyProps.getProperty(ConfigurationKeys.TOPOLOGY_NAME_KEY); String group = topologyProps.getProperty(ConfigurationKeys.TOPOLOGY_GROUP_KEY, "default"); try { URI topologyURI = new URI(catalogURI.getScheme(), catalogURI.getAuthority(), "/" + group + "/" + name, null); TopologySpec.Builder builder = new TopologySpec.Builder(topologyURI).withConfigAsProperties(topologyProps); String descr = topologyProps.getProperty(ConfigurationKeys.TOPOLOGY_DESCRIPTION_KEY, null); if (null != descr) { builder = builder.withDescription(descr); } return builder; } catch (URISyntaxException e) { throw new RuntimeException("Unable to create a TopologySpec URI: " + e, e); } }
public URI getDefaultURI() { URI topologyCatalogURI = getTopologyCatalogURI(); Config topologyCfg = getConfig(); String name = topologyCfg.hasPath(ConfigurationKeys.TOPOLOGY_NAME_KEY) ? topologyCfg.getString(ConfigurationKeys.TOPOLOGY_NAME_KEY) : "default"; String group = topologyCfg.hasPath(ConfigurationKeys.TOPOLOGY_GROUP_KEY) ? topologyCfg.getString(ConfigurationKeys.TOPOLOGY_GROUP_KEY) : "default"; try { return new URI(topologyCatalogURI.getScheme(), topologyCatalogURI.getAuthority(), "/" + group + "/" + name, null, null); } catch (URISyntaxException e) { throw new RuntimeException("Unable to create default TopologySpec URI:" + e, e); } }
public Config getConfig() { if (!this.config.isPresent()) { this.config = this.configAsProperties.isPresent() ? Optional.of(ConfigUtils.propertiesToTypedConfig(this.configAsProperties.get(), Optional.<String>absent())) : Optional.of(getDefaultConfig()); } return this.config.get(); }
.withConfig(topologyConfig) .withDescription(description) .withVersion(version) .withSpecExecutorInstanceProducer(specExecutorInstanceProducer); topologySpecs.add(topologySpecBuilder.build());
public static TopologySpec.Builder builder(URI topologySpecUri) { return new TopologySpec.Builder(topologySpecUri); }
public static TopologySpec.Builder builder() { return new TopologySpec.Builder(); }
public static TopologySpec.Builder builder(String topologySpecUri) { return new TopologySpec.Builder(topologySpecUri); }
public String getDescription() { if (! this.description.isPresent()) { this.description = Optional.of(getDefaultDescription()); } return this.description.get(); }
public URI getURI() { if (! this.uri.isPresent()) { this.uri = Optional.of(getDefaultURI()); } return this.uri.get(); }
public URI getTopologyCatalogURI() { if (! this.topologyCatalogURI.isPresent()) { this.topologyCatalogURI = Optional.of(getDefaultTopologyCatalogURI()); } return this.topologyCatalogURI.get(); }
public TopologySpec build() { Preconditions.checkNotNull(this.uri); Preconditions.checkNotNull(this.version); return new TopologySpec(getURI(), getVersion(), getDescription(), getConfig(), getConfigAsProperties(), getSpecExceutorInstanceProducer()); }