Пример #1
0
  @Override
  public void populateDAG(DAG dag, Configuration conf) {
    int maxValue = 30000;

    RandomEventGenerator rand = dag.addOperator("rand", new RandomEventGenerator());
    rand.setMinvalue(0);
    rand.setMaxvalue(maxValue);

    RoundRobinHashMap<String, Object> rrhm =
        dag.addOperator("rrhm", new RoundRobinHashMap<String, Object>());
    rrhm.setKeys(new String[] {"x", "y"});

    JavaScriptOperator calc = dag.addOperator("picalc", new JavaScriptOperator());
    calc.setPassThru(false);
    calc.put("i", 0);
    calc.put("count", 0);
    calc.addSetupScript(
        "function pi() { if (x*x+y*y <= "
            + maxValue * maxValue
            + ") { i++; } count++; return i / count * 4; }");

    calc.setInvoke("pi");

    dag.addStream("rand_rrhm", rand.integer_data, rrhm.data);
    dag.addStream("rrhm_calc", rrhm.map, calc.inBindings);

    ConsoleOutputOperator console = dag.addOperator("console", new ConsoleOutputOperator());
    dag.addStream("rand_console", calc.result, console.input);
  }
Пример #2
0
  @Override
  public void populateDAG(DAG dag, Configuration conf) {
    String lPhoneRange = conf.get(PHONE_RANGE_PROP, null);
    if (lPhoneRange != null) {
      String[] tokens = lPhoneRange.split("-");
      if (tokens.length != 2) {
        throw new IllegalArgumentException("Invalid range: " + lPhoneRange);
      }
      this.phoneRange = Range.between(Integer.parseInt(tokens[0]), Integer.parseInt(tokens[1]));
    }
    LOG.debug("Phone range {}", this.phoneRange);

    RandomEventGenerator phones = dag.addOperator("Receiver", RandomEventGenerator.class);
    phones.setMinvalue(this.phoneRange.getMinimum());
    phones.setMaxvalue(this.phoneRange.getMaximum());

    PhoneMovementGenerator movementGen =
        dag.addOperator("LocationFinder", PhoneMovementGenerator.class);
    dag.setAttribute(
        movementGen,
        OperatorContext.COUNTERS_AGGREGATOR,
        new BasicCounters.LongAggregator<MutableLong>());

    StatelessThroughputBasedPartitioner<PhoneMovementGenerator> partitioner =
        new StatelessThroughputBasedPartitioner<PhoneMovementGenerator>();
    partitioner.setCooldownMillis(conf.getLong(COOL_DOWN_MILLIS, 45000));
    partitioner.setMaximumEvents(conf.getLong(MAX_THROUGHPUT, 30000));
    partitioner.setMinimumEvents(conf.getLong(MIN_THROUGHPUT, 10000));
    dag.setAttribute(
        movementGen,
        OperatorContext.STATS_LISTENERS,
        Arrays.asList(new StatsListener[] {partitioner}));
    dag.setAttribute(movementGen, OperatorContext.PARTITIONER, partitioner);

    // generate seed numbers
    Random random = new Random();
    int maxPhone = phoneRange.getMaximum() - phoneRange.getMinimum();
    int phonesToDisplay = conf.getInt(TOTAL_SEED_NOS, 10);
    for (int i = phonesToDisplay; i-- > 0; ) {
      int phoneNo = phoneRange.getMinimum() + random.nextInt(maxPhone + 1);
      LOG.info("seed no: " + phoneNo);
      movementGen.phoneRegister.add(phoneNo);
    }
    // done generating data
    LOG.info("Finished generating seed data.");

    String gatewayAddress = dag.getValue(DAG.GATEWAY_CONNECT_ADDRESS);
    URI uri = URI.create("ws://" + gatewayAddress + "/pubsub");
    PubSubWebSocketOutputOperator<Object> wsOut =
        dag.addOperator("LocationResults", new PubSubWebSocketOutputOperator<Object>());
    wsOut.setUri(uri);
    PubSubWebSocketInputOperator<Map<String, String>> wsIn =
        dag.addOperator("QueryLocation", new PubSubWebSocketInputOperator<Map<String, String>>());
    wsIn.setUri(uri);
    // default partitioning: first connected stream to movementGen will be partitioned
    dag.addStream("Phone-Data", phones.integer_data, movementGen.data);
    dag.addStream("Results", movementGen.locationQueryResult, wsOut.input);
    dag.addStream("Query", wsIn.outputPort, movementGen.phoneQuery);
  }
Пример #3
0
  @Override
  public void populateDAG(DAG dag, Configuration conf) {
    int maxValue = 1000;

    RandomEventGenerator rand = dag.addOperator("rand", new RandomEventGenerator());
    rand.setMinvalue(0);
    rand.setMaxvalue(maxValue);
    rand.setTuplesBlast(200);
    CouchBaseOutputOperator couchbaseOutput =
        dag.addOperator("couchbaseOutput", new CouchBaseOutputOperator());
    // couchbaseOutput.getStore().setBucket("default");
    // couchbaseOutput.getStore().setPassword("");
    dag.addStream("ss", rand.integer_data, couchbaseOutput.input).setLocality(locality);
  }
Пример #4
0
  @Override
  public void populateDAG(DAG dag, Configuration conf) {
    String appName = conf.get("appName");
    if (appName == null) {
      appName = "VisualDataDemo";
    }
    dag.setAttribute(DAG.APPLICATION_NAME, appName);
    int maxValue = 30000;

    RandomEventGenerator rand = dag.addOperator("random", new RandomEventGenerator());
    rand.setMinvalue(0);
    rand.setMaxvalue(maxValue);

    DemoValueGenerator demo = dag.addOperator("chartValue", new DemoValueGenerator());
    demo.setRandomIncrement(5);
    demo.setRandomIncrement2(20);

    PiCalculateOperator calc = dag.addOperator("picalc", new PiCalculateOperator());
    calc.setBase(maxValue * maxValue);
    dag.addStream("rand_calc", rand.integer_data, calc.input).setLocality(locality);

    WidgetOutputOperator woo =
        dag.addOperator("widget output operator", new WidgetOutputOperator());
    WidgetOutputOperator wooa =
        dag.addOperator("widget output operator2", new WidgetOutputOperator());

    // wire to simple input gadget
    dag.addStream(
            "ws_pi_data", calc.output, woo.simpleInput.setTopic("app." + appName + ".piValue"))
        .setLocality(locality);

    // wire to time series chart gadget
    dag.addStream(
            "ws_chart_data",
            demo.simpleOutput,
            woo.timeSeriesInput.setTopic("app." + appName + ".chartValue").setMin(0).setMax(100))
        .setLocality(locality);

    // wire to another time series chart gadget
    dag.addStream(
            "ws_chart_data2",
            demo.simpleOutput2,
            wooa.timeSeriesInput.setTopic("app." + appName + ".chartValue2"))
        .setLocality(locality);

    // wire to percentage chart gadget
    dag.addStream(
            "ws_percentage_data",
            demo.percentageOutput,
            woo.percentageInput.setTopic("app." + appName + ".percentage"))
        .setLocality(locality);

    // wire to top N chart gadget
    dag.addStream(
            "ws_topn_data",
            demo.top10Output,
            woo.topNInput.setN(10).setTopic("app." + appName + ".topn"))
        .setLocality(locality);

    // wire to progress bar chart gadget
    dag.addStream(
            "ws_progress_data",
            demo.progressOutput,
            wooa.percentageInput.setTopic("app." + appName + ".progress"))
        .setLocality(locality);

    // wire to piechart gadget
    dag.addStream(
            "ws_piechart_data",
            demo.pieChartOutput,
            wooa.pieChartInput.setTopic("app." + appName + ".piechart"))
        .setLocality(locality);
  }