/** * @param className The name of a class that implements {@link Observer} * @param observerConfig Per observer configuration that's specific to this observer. For * configuration that's the same across multiple observers, consider using * {@link FluoConfiguration#getAppConfiguration()} */ public ObserverSpecification(String className, SimpleConfiguration observerConfig) { this.className = className; this.configMap = observerConfig.toMap(); }
/** * @param className The name of a class that implements {@link Observer} * @param observerConfig Per observer configuration thats specific to this observer. For * configuration thats the same across multiple observers, consider using * {@link FluoConfiguration#getAppConfiguration()} */ public ObserverSpecification(String className, SimpleConfiguration observerConfig) { this.className = className; this.configMap = observerConfig.toMap(); }
@Override public int hashCode() { return Objects.hashCode(this.toMap().entrySet()); }
@Override public int hashCode() { return Objects.hashCode(this.toMap().entrySet()); }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof SimpleConfiguration) { Map<String, String> th = this.toMap(); Map<String, String> sc = ((SimpleConfiguration) o).toMap(); if (th.size() == sc.size()) { return th.entrySet().equals(sc.entrySet()); } } return false; }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof SimpleConfiguration) { Map<String, String> th = this.toMap(); Map<String, String> sc = ((SimpleConfiguration) o).toMap(); if (th.size() == sc.size()) { return th.entrySet().equals(sc.entrySet()); } } return false; }
@Deprecated private void addObserver(ObserverSpecification oconf, int next) { Map<String, String> params = oconf.getConfiguration().toMap(); StringBuilder paramString = new StringBuilder(); for (java.util.Map.Entry<String, String> pentry : params.entrySet()) { paramString.append(','); paramString.append(pentry.getKey()); paramString.append('='); paramString.append(pentry.getValue()); } setProperty(OBSERVER_PREFIX + "" + next, oconf.getClassName() + paramString); }
@Deprecated private void addObserver(ObserverSpecification oconf, int next) { Map<String, String> params = oconf.getConfiguration().toMap(); StringBuilder paramString = new StringBuilder(); for (java.util.Map.Entry<String, String> pentry : params.entrySet()) { paramString.append(','); paramString.append(pentry.getKey()); paramString.append('='); paramString.append(pentry.getValue()); } setProperty(OBSERVER_PREFIX + "" + next, oconf.getClassName() + paramString); }
public static FluoConfiguration mergeZookeeperConfig(FluoConfiguration config) { SimpleConfiguration zooConfig = getZookeeperConfig(config); FluoConfiguration copy = new FluoConfiguration(config); for (Map.Entry<String, String> entry : zooConfig.toMap().entrySet()) { copy.setProperty(entry.getKey(), entry.getValue()); } return copy; }
public static FluoConfiguration mergeZookeeperConfig(FluoConfiguration config) { SimpleConfiguration zooConfig = getZookeeperConfig(config); FluoConfiguration copy = new FluoConfiguration(config); for (Map.Entry<String, String> entry : zooConfig.toMap().entrySet()) { copy.setProperty(entry.getKey(), entry.getValue()); } return copy; }
/** * @param fallback SimpleConfiguration to join together * @return a new simple configuration that contains all of the current properties from this plus * the properties from fallback that are not present in this. * * @since 1.2.0 */ public SimpleConfiguration orElse(SimpleConfiguration fallback) { SimpleConfiguration copy = new SimpleConfiguration(this); for (Map.Entry<String, String> entry : fallback.toMap().entrySet()) { if (!copy.containsKey(entry.getKey())) { copy.setProperty(entry.getKey(), entry.getValue()); } } return copy; }
private static void serializeObservers(DataOutputStream dos, Map<Column, org.apache.fluo.api.config.ObserverSpecification> colObservers) throws IOException { // TODO use a human readable serialized format like json Set<Entry<Column, org.apache.fluo.api.config.ObserverSpecification>> es = colObservers.entrySet(); WritableUtils.writeVInt(dos, colObservers.size()); for (Entry<Column, org.apache.fluo.api.config.ObserverSpecification> entry : es) { ColumnUtil.writeColumn(entry.getKey(), dos); dos.writeUTF(entry.getValue().getClassName()); Map<String, String> params = entry.getValue().getConfiguration().toMap(); WritableUtils.writeVInt(dos, params.size()); for (Entry<String, String> pentry : params.entrySet()) { dos.writeUTF(pentry.getKey()); dos.writeUTF(pentry.getValue()); } } }
private static void serializeObservers(DataOutputStream dos, Map<Column, org.apache.fluo.api.config.ObserverSpecification> colObservers) throws IOException { // TODO use a human readable serialized format like json Set<Entry<Column, org.apache.fluo.api.config.ObserverSpecification>> es = colObservers.entrySet(); WritableUtils.writeVInt(dos, colObservers.size()); for (Entry<Column, org.apache.fluo.api.config.ObserverSpecification> entry : es) { ColumnUtil.writeColumn(entry.getKey(), dos); dos.writeUTF(entry.getValue().getClassName()); Map<String, String> params = entry.getValue().getConfiguration().toMap(); WritableUtils.writeVInt(dos, params.size()); for (Entry<String, String> pentry : params.entrySet()) { dos.writeUTF(pentry.getKey()); dos.writeUTF(pentry.getValue()); } } }
/** * @param fallback SimpleConfiguration to join together * @return a new simple configuration that contains all of the current properties from this plus * the properties from fallback that are not present in this. * * @since 1.2.0 */ public SimpleConfiguration orElse(SimpleConfiguration fallback) { SimpleConfiguration copy = new SimpleConfiguration(this); for (Map.Entry<String, String> entry : fallback.toMap().entrySet()) { if (!copy.containsKey(entry.getKey())) { copy.setProperty(entry.getKey(), entry.getValue()); } } return copy; }
@Override public Optional<IncrementalResultExporter> build(final Context context) throws IncrementalExporterFactoryException, ConfigurationException { final KafkaBindingSetExporterParameters exportParams = new KafkaBindingSetExporterParameters(context.getObserverConfiguration().toMap()); if (exportParams.getUseKafkaBindingSetExporter()) { log.info("Exporter is enabled."); // Setup Kafka connection final KafkaProducer<String, VisibilityBindingSet> producer = new KafkaProducer<>(exportParams.listAllConfig()); // Create the exporter final IncrementalBindingSetExporter exporter = new KafkaBindingSetExporter(producer); return Optional.of(exporter); } else { return Optional.absent(); } }
@Override public Optional<IncrementalResultExporter> build(final Context context) throws IncrementalExporterFactoryException, ConfigurationException { final KafkaBindingSetExporterParameters exportParams = new KafkaBindingSetExporterParameters(context.getObserverConfiguration().toMap()); if (exportParams.getUseKafkaBindingSetExporter()) { log.info("Exporter is enabled."); // Setup Kafka connection final KafkaProducer<String, VisibilityBindingSet> producer = new KafkaProducer<>(exportParams.listAllConfig()); // Create the exporter final IncrementalBindingSetExporter exporter = new KafkaBindingSetExporter(producer); return Optional.of(exporter); } else { return Optional.absent(); } }
/** * Builds a {@link KafkaRyaSubGraphExporter}. * @param context - {@link Context} object used to pass configuration parameters * @return an Optional consisting of an IncrementalSubGraphExproter if it can be constructed * @throws IncrementalExporterFactoryException * @throws ConfigurationException */ @Override public Optional<IncrementalResultExporter> build(final Context context) throws IncrementalExporterFactoryException, ConfigurationException { final KafkaSubGraphExporterParameters exportParams = new KafkaSubGraphExporterParameters(context.getObserverConfiguration().toMap()); log.info("Exporter is enabled: {}", exportParams.getUseKafkaSubgraphExporter()); if (exportParams.getUseKafkaSubgraphExporter()) { // Setup Kafka connection final KafkaProducer<String, RyaSubGraph> producer = new KafkaProducer<String, RyaSubGraph>(exportParams.listAllConfig()); // Create the exporter final IncrementalRyaSubGraphExporter exporter = new KafkaRyaSubGraphExporter(producer); return Optional.of(exporter); } else { return Optional.absent(); } }
public static void main(String[] args) { CommonOpts opts = CommonOpts.parse("fluo config", args); FluoConfiguration config = CommandUtil.resolveFluoConfig(); config.setApplicationName(opts.getApplicationName()); opts.overrideFluoConfig(config); CommandUtil.verifyAppInitialized(config); try (FluoAdmin admin = FluoFactory.newAdmin(config)) { for (Map.Entry<String, String> entry : admin.getApplicationConfig().toMap().entrySet()) { System.out.println(entry.getKey() + " = " + entry.getValue()); } } } }
@Override public Optional<IncrementalResultExporter> build(Context context) throws IncrementalExporterFactoryException, ConfigurationException { Preconditions.checkNotNull(context); RyaSubGraphExportParameters params = new RyaSubGraphExportParameters(context.getObserverConfiguration().toMap()); if (params.getUseRyaSubGraphExporter()) { try { //Get FluoConfiguration from params FluoConfiguration conf = params.getFluoConfiguration(); FluoClient fluo = FluoFactory.newClient(conf); //Create exporter RyaSubGraphExporter exporter = new RyaSubGraphExporter(fluo); return Optional.of(exporter); } catch (Exception e) { throw new IncrementalExporterFactoryException("Could not initialize the RyaSubGraphExporter", e); } } return Optional.absent(); } }
@Override public Optional<IncrementalResultExporter> build(Context context) throws IncrementalExporterFactoryException, ConfigurationException { Preconditions.checkNotNull(context); RyaSubGraphExportParameters params = new RyaSubGraphExportParameters(context.getObserverConfiguration().toMap()); if (params.getUseRyaSubGraphExporter()) { try { //Get FluoConfiguration from params FluoConfiguration conf = params.getFluoConfiguration(); FluoClient fluo = FluoFactory.newClient(conf); //Create exporter RyaSubGraphExporter exporter = new RyaSubGraphExporter(fluo); return Optional.of(exporter); } catch (Exception e) { throw new IncrementalExporterFactoryException("Could not initialize the RyaSubGraphExporter", e); } } return Optional.absent(); } }