Пример #1
0
  public void run() {
    try {
      Thread ct = Thread.currentThread();
      Thread.sleep(shift);

      while (monitor != null && monitor.equals(ct)) {
        long executiontime = System.currentTimeMillis();

        OnMemoryTupleSet ts = new OnMemoryTupleSet(schema);
        Tuple t = new Tuple(schema.size());
        t.setTimestamp(table[0], executiontime);
        t.setLong(0, executiontime);
        t.setString(1, command);
        t.setString(2, getCommandOutput());
        ts.appendTuple(t);
        ts.beforeFirst();

        deliverTupleSet(executiontime, table[0], ts);

        Thread.sleep(interval);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Пример #2
0
  public static LogEntry process(
      long executiontime, ExecutionPlan plan, OperatorGroup op, QueueManager qm, CacheManager cm)
      throws StreamSpinnerException {
    ANDNode[] node = op.getANDNodes();

    ORNode inputn = node[0].getInputORNodes()[0];
    Queue inputq = qm.getQueue(plan, op.getMasterSet(), inputn);

    Queue[] outputq = new Queue[node.length];
    for (int i = 0; i < node.length; i++) {
      ORNode outputn = node[i].getOutputORNode();
      outputq[i] = qm.getQueue(plan, node[i].getMasterSet(), outputn);
      if (outputq[i] == null)
        throw new StreamSpinnerException("no input queue for " + outputn.toString());
    }

    TupleSet ts = getDeltaTupleSet(executiontime, plan, op, inputn, inputq, cm);

    LogEntry le = null;
    if (op.isCacheConsumer() == true) le = consumeCacheData(executiontime, plan, op, qm, cm);
    else le = new LogEntry(executiontime, op);

    if (ts.first() == false) return le;

    FunctionParameter fp = node[0].getFunctionParameter();
    Schema origschema = ts.getSchema();

    int[] indexes = new int[fp.getArguments().size()];
    for (int i = 0; i < indexes.length; i++)
      indexes[i] = origschema.getIndex(fp.getArguments().getString(i));

    Function f = Function.getInstance(fp, origschema);
    Schema newschema = origschema.append(fp.toString(), f.getReturnType());

    OnMemoryTupleSet result = new OnMemoryTupleSet(newschema);
    do {
      Tuple t = ts.getTuple();
      Object[] values = new Object[indexes.length];
      for (int i = 0; i < values.length; i++) values[i] = t.getObject(indexes[i]);
      Object returnvalue = f.invoke(values);
      Tuple newtuple = t.appendColumn();
      newtuple.setObject(newtuple.size() - 1, returnvalue);
      for (int i = 0; i < node.length; i++) outputq[i].append(newtuple);
      result.append(newtuple);
      le.add(newtuple);
    } while (ts.next());

    ts.close();
    produceCacheData(executiontime, plan, op, cm, result);
    inputq.moveToWindow(op, executiontime);
    return le;
  }