@Override protected void setupObservers(FluoConfiguration fc) { List<org.apache.fluo.api.config.ObserverSpecification> observers = new ArrayList<>(); observers.add( new org.apache.fluo.api.config.ObserverSpecification(ConfigurableObserver.class.getName(), newMap("observedCol", "fam1:col1:" + NotificationType.STRONG, "outputCQ", "col2"))); observers.add( new org.apache.fluo.api.config.ObserverSpecification(ConfigurableObserver.class.getName(), newMap("observedCol", "fam1:col2:" + NotificationType.STRONG, "outputCQ", "col3", "setWeakNotification", "true"))); observers.add( new org.apache.fluo.api.config.ObserverSpecification(ConfigurableObserver.class.getName(), newMap("observedCol", "fam1:col3:" + NotificationType.WEAK, "outputCQ", "col4"))); fc.addObservers(observers); }
@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 ObserversV1(Environment env, Map<Column, org.apache.fluo.api.config.ObserverSpecification> strongObservers, Map<Column, org.apache.fluo.api.config.ObserverSpecification> weakObservers) { this.env = env; this.strongObservers = strongObservers; this.weakObservers = weakObservers; this.aliases = new HashMap<>(); for (Entry<Column, org.apache.fluo.api.config.ObserverSpecification> e : Iterables .concat(strongObservers.entrySet(), weakObservers.entrySet())) { org.apache.fluo.api.config.ObserverSpecification observerConfig = e.getValue(); try { String alias = Class.forName(observerConfig.getClassName()).asSubclass(Observer.class).getSimpleName(); aliases.put(e.getKey(), alias); } catch (ClassNotFoundException e1) { throw new RuntimeException(e1); } } }
public ObserversV1(Environment env, Map<Column, org.apache.fluo.api.config.ObserverSpecification> strongObservers, Map<Column, org.apache.fluo.api.config.ObserverSpecification> weakObservers) { this.env = env; this.strongObservers = strongObservers; this.weakObservers = weakObservers; this.aliases = new HashMap<>(); for (Entry<Column, org.apache.fluo.api.config.ObserverSpecification> e : Iterables .concat(strongObservers.entrySet(), weakObservers.entrySet())) { org.apache.fluo.api.config.ObserverSpecification observerConfig = e.getValue(); try { String alias = Class.forName(observerConfig.getClassName()).asSubclass(Observer.class).getSimpleName(); aliases.put(e.getKey(), alias); } catch (ClassNotFoundException e1) { throw new RuntimeException(e1); } } }
/** * Add info about the Kafka queue/topic to receive the export. */ @Override protected void preFluoInitHook() throws Exception { // Setup the observers that will be used by the Fluo PCJ Application. final List<ObserverSpecification> observers = new ArrayList<>(); observers.add(new ObserverSpecification(TripleObserver.class.getName())); observers.add(new ObserverSpecification(BatchObserver.class.getName())); observers.add(new ObserverSpecification(StatementPatternObserver.class.getName())); observers.add(new ObserverSpecification(JoinObserver.class.getName())); observers.add(new ObserverSpecification(FilterObserver.class.getName())); observers.add(new ObserverSpecification(AggregationObserver.class.getName())); observers.add(new ObserverSpecification(ProjectionObserver.class.getName())); observers.add(new ObserverSpecification(ConstructQueryResultObserver.class.getName())); // Configure the export observer to export new PCJ results to the mini // accumulo cluster. final HashMap<String, String> exportParams = new HashMap<>(); final KafkaBindingSetExporterParameters kafkaParams = new KafkaBindingSetExporterParameters(exportParams); kafkaParams.setUseKafkaBindingSetExporter(true); kafkaParams.setKafkaBootStrapServers(BROKERHOST + ":" + BROKERPORT); final KafkaSubGraphExporterParameters kafkaConstructParams = new KafkaSubGraphExporterParameters(exportParams); kafkaConstructParams.setUseKafkaSubgraphExporter(true); final ObserverSpecification exportObserverConfig = new ObserverSpecification(QueryResultObserver.class.getName(), exportParams); observers.add(exportObserverConfig); // Add the observers to the Fluo Configuration. super.getFluoConfiguration().addObservers(observers); }
@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); }
/** * Add info about the Kafka queue/topic to receive the export. */ @Override protected void preFluoInitHook() throws Exception { // Setup the observers that will be used by the Fluo PCJ Application. final List<ObserverSpecification> observers = new ArrayList<>(); observers.add(new ObserverSpecification(TripleObserver.class.getName())); observers.add(new ObserverSpecification(BatchObserver.class.getName())); observers.add(new ObserverSpecification(StatementPatternObserver.class.getName())); observers.add(new ObserverSpecification(JoinObserver.class.getName())); observers.add(new ObserverSpecification(FilterObserver.class.getName())); observers.add(new ObserverSpecification(AggregationObserver.class.getName())); observers.add(new ObserverSpecification(ProjectionObserver.class.getName())); observers.add(new ObserverSpecification(ConstructQueryResultObserver.class.getName())); // Configure the export observer to export new PCJ results to the mini // accumulo cluster. final HashMap<String, String> exportParams = new HashMap<>(); final KafkaBindingSetExporterParameters kafkaParams = new KafkaBindingSetExporterParameters(exportParams); kafkaParams.setUseKafkaBindingSetExporter(true); kafkaParams.setKafkaBootStrapServers(BROKERHOST + ":" + BROKERPORT); final KafkaSubGraphExporterParameters kafkaConstructParams = new KafkaSubGraphExporterParameters(exportParams); kafkaConstructParams.setUseKafkaSubgraphExporter(true); final ObserverSpecification exportObserverConfig = new ObserverSpecification(QueryResultObserver.class.getName(), exportParams); observers.add(exportObserverConfig); // Add the observers to the Fluo Configuration. super.getFluoConfiguration().addObservers(observers); }
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 Map<Column, org.apache.fluo.api.config.ObserverSpecification> readObservers( DataInputStream dis) throws IOException { ImmutableMap.Builder<Column, org.apache.fluo.api.config.ObserverSpecification> omapBuilder = new ImmutableMap.Builder<>(); int num = WritableUtils.readVInt(dis); for (int i = 0; i < num; i++) { Column col = ColumnUtil.readColumn(dis); String clazz = dis.readUTF(); Map<String, String> params = new HashMap<>(); int numParams = WritableUtils.readVInt(dis); for (int j = 0; j < numParams; j++) { String k = dis.readUTF(); String v = dis.readUTF(); params.put(k, v); } org.apache.fluo.api.config.ObserverSpecification ospec = new org.apache.fluo.api.config.ObserverSpecification(clazz, params); omapBuilder.put(col, ospec); } return omapBuilder.build(); }
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()); } } }
ObserverSpecification observerSpecification = new ObserverSpecification(className, params); configList.add(observerSpecification);
try { observer = Class.forName(observerConfig.getClassName()).asSubclass(Observer.class).newInstance(); observer.init(new ObserverContext(env, observerConfig.getConfiguration())); } catch (RuntimeException e) { throw e; "Mismatch between configured column and class column " + observerConfig.getClassName() + " " + col + " " + observer.getObservedColumn().getColumn());
private static Map<Column, org.apache.fluo.api.config.ObserverSpecification> readObservers( DataInputStream dis) throws IOException { ImmutableMap.Builder<Column, org.apache.fluo.api.config.ObserverSpecification> omapBuilder = new ImmutableMap.Builder<>(); int num = WritableUtils.readVInt(dis); for (int i = 0; i < num; i++) { Column col = ColumnUtil.readColumn(dis); String clazz = dis.readUTF(); Map<String, String> params = new HashMap<>(); int numParams = WritableUtils.readVInt(dis); for (int j = 0; j < numParams; j++) { String k = dis.readUTF(); String v = dis.readUTF(); params.put(k, v); } org.apache.fluo.api.config.ObserverSpecification ospec = new org.apache.fluo.api.config.ObserverSpecification(clazz, params); omapBuilder.put(col, ospec); } return omapBuilder.build(); }
try { observer = Class.forName(observerConfig.getClassName()).asSubclass(Observer.class).newInstance(); observer.init(new ObserverContext(env, observerConfig.getConfiguration())); } catch (RuntimeException e) { throw e; "Mismatch between configured column and class column " + observerConfig.getClassName() + " " + col + " " + observer.getObservedColumn().getColumn());
/** * Call this method before initializing Fluo. * * @param fluoConfig The configuration that will be used to initialize fluo. * @deprecated since 1.1.0 use {@link #configure(String)} and * {@link #registerObserver(ObserverProvider.Registry, org.apache.fluo.recipes.core.export.function.Exporter)} * instead. */ @Deprecated public static void configure(FluoConfiguration fluoConfig, Options opts) { SimpleConfiguration appConfig = fluoConfig.getAppConfiguration(); opts.save(appConfig); fluoConfig.addObserver( new org.apache.fluo.api.config.ObserverSpecification(ExportObserver.class.getName(), Collections.singletonMap("queueId", opts.fluentCfg.queueId))); }
Observer observer; try { observer = Class.forName(ospec.getClassName()).asSubclass(Observer.class).newInstance(); } catch (ClassNotFoundException e1) { throw new FluoException("Observer class '" + ospec.getClassName() + "' was not " + "found. Check for class name misspellings or failure to include " + "the observer jar.", e1); } catch (InstantiationException | IllegalAccessException e2) { throw new FluoException( "Observer class '" + ospec.getClassName() + "' could not be created.", e2); SimpleConfiguration oc = ospec.getConfiguration(); logger.info("Setting up observer {} using params {}.", observer.getClass().getSimpleName(), oc.toMap()); observer.init(new ObserverContext(config.getAppConfiguration(), oc)); } catch (Exception e) { throw new FluoException("Observer '" + ospec.getClassName() + "' could not be initialized", e);
@Override protected void preFluoInitHook() throws Exception { // Setup the observers that will be used by the Fluo PCJ Application. final List<ObserverSpecification> observers = new ArrayList<>(); observers.add(new ObserverSpecification(BatchObserver.class.getName())); observers.add(new ObserverSpecification(TripleObserver.class.getName())); observers.add(new ObserverSpecification(StatementPatternObserver.class.getName())); observers.add(new ObserverSpecification(JoinObserver.class.getName())); observers.add(new ObserverSpecification(FilterObserver.class.getName())); observers.add(new ObserverSpecification(AggregationObserver.class.getName())); observers.add(new ObserverSpecification(PeriodicQueryObserver.class.getName())); observers.add(new ObserverSpecification(ProjectionObserver.class.getName())); // Configure the export observer to export new PCJ results to the mini accumulo cluster. final HashMap<String, String> exportParams = new HashMap<>(); final RyaExportParameters ryaParams = new RyaExportParameters(exportParams); ryaParams.setUseRyaBindingSetExporter(true); ryaParams.setUsePeriodicBindingSetExporter(true); ryaParams.setRyaInstanceName(getRyaInstanceName()); ryaParams.setAccumuloInstanceName(super.getMiniAccumuloCluster().getInstanceName()); ryaParams.setZookeeperServers(super.getMiniAccumuloCluster().getZooKeepers()); ryaParams.setExporterUsername(getUsername()); ryaParams.setExporterPassword(getPassword()); final ObserverSpecification exportObserverConfig = new ObserverSpecification(QueryResultObserver.class.getName(), exportParams); observers.add(exportObserverConfig); // Add the observers to the Fluo Configuration. super.getFluoConfiguration().addObservers(observers); }
Observer observer; try { observer = Class.forName(ospec.getClassName()).asSubclass(Observer.class).newInstance(); } catch (ClassNotFoundException e1) { throw new FluoException("Observer class '" + ospec.getClassName() + "' was not " + "found. Check for class name misspellings or failure to include " + "the observer jar.", e1); } catch (InstantiationException | IllegalAccessException e2) { throw new FluoException( "Observer class '" + ospec.getClassName() + "' could not be created.", e2); SimpleConfiguration oc = ospec.getConfiguration(); logger.info("Setting up observer {} using params {}.", observer.getClass().getSimpleName(), oc.toMap()); observer.init(new ObserverContext(config.getAppConfiguration(), oc)); } catch (Exception e) { throw new FluoException("Observer '" + ospec.getClassName() + "' could not be initialized", e);
ObserverSpecification observerSpecification = new ObserverSpecification(className, params); configList.add(observerSpecification);
@Override protected void preFluoInitHook() throws Exception { // Setup the observers that will be used by the Fluo PCJ Application. final List<ObserverSpecification> observers = new ArrayList<>(); observers.add(new ObserverSpecification(BatchObserver.class.getName())); observers.add(new ObserverSpecification(TripleObserver.class.getName())); observers.add(new ObserverSpecification(StatementPatternObserver.class.getName())); observers.add(new ObserverSpecification(JoinObserver.class.getName())); observers.add(new ObserverSpecification(FilterObserver.class.getName())); observers.add(new ObserverSpecification(AggregationObserver.class.getName())); observers.add(new ObserverSpecification(PeriodicQueryObserver.class.getName())); observers.add(new ObserverSpecification(ProjectionObserver.class.getName())); // Configure the export observer to export new PCJ results to the mini accumulo cluster. final HashMap<String, String> exportParams = new HashMap<>(); final RyaExportParameters ryaParams = new RyaExportParameters(exportParams); ryaParams.setUseRyaBindingSetExporter(true); ryaParams.setUsePeriodicBindingSetExporter(true); ryaParams.setRyaInstanceName(getRyaInstanceName()); ryaParams.setAccumuloInstanceName(super.getMiniAccumuloCluster().getInstanceName()); ryaParams.setZookeeperServers(super.getMiniAccumuloCluster().getZooKeepers()); ryaParams.setExporterUsername(getUsername()); ryaParams.setExporterPassword(getPassword()); final ObserverSpecification exportObserverConfig = new ObserverSpecification(QueryResultObserver.class.getName(), exportParams); observers.add(exportObserverConfig); // Add the observers to the Fluo Configuration. super.getFluoConfiguration().addObservers(observers); }