/** {@inheritDoc} */
    @Override
    public TestValue process(MutableEntry<TestKey, TestValue> e, Object... args) {
      TestValue old = e.getValue();

      if (val != null) e.setValue(new TestValue(val));

      return old;
    }
 @Override
 public Object process(MutableEntry<Integer, Long> entry, Object... arguments) {
   if (delayMs > 0) {
     sleepMillis(delayMs);
   }
   long newValue = entry.getValue() + increment;
   entry.setValue(newValue);
   return null;
 }
    /** {@inheritDoc} */
    @Override
    public BinaryObjectException process(
        MutableEntry<PortableMetadataKey, BinaryMetadata> entry, Object... args) {
      try {
        BinaryMetadata oldMeta = entry.getValue();

        BinaryMetadata mergedMeta = PortableUtils.mergeMetadata(oldMeta, newMeta);

        if (mergedMeta != oldMeta) entry.setValue(mergedMeta);

        return null;
      } catch (BinaryObjectException e) {
        return e;
      }
    }
    @Override
    public Void process(MutableEntry<Integer, String> entry, Object... arguments)
        throws EntryProcessorException {

      entry.setValue("Foo");
      return null;
    }
示例#5
0
  @Override
  public Integer process(MutableEntry<String, Integer> mutableEntry, Object... objects)
      throws EntryProcessorException {
    try {
      String finalScript = "function run(value, log) {" + script + "}";

      engine.eval(finalScript);
      Double outputValue =
          (Double)
              ((Invocable) engine)
                  .invokeFunction("run", new Object[] {mutableEntry.getValue(), log});
      int newValue = outputValue.intValue();
      mutableEntry.setValue(newValue);
      return newValue;

    } catch (Exception e) {
      throw new EntryProcessorException("Error executing script", e);
    }
  }