Emitting java.util.Date

16 views
Skip to first unread message

how...@gmail.com

unread,
Dec 17, 2014, 10:31:17 AM12/17/14
to tigon...@googlegroups.com
Howdy,

I'm trying to emit an object with a Date field and I'm getting the following error.

java.lang.IllegalArgumentException: No record field provided for java.util.Date
        at com.google.common.base.Preconditions.checkArgument(Preconditions.java:119) ~[com.google.guava.guava-13.0.1.jar:na]
        at co.cask.tigon.internal.io.Schema.recordOf(Schema.java:229) ~[co.cask.tigon.tigon-api-0.2.1.jar:na]
        at co.cask.tigon.internal.io.ReflectionSchemaGenerator.generateRecord(ReflectionSchemaGenerator.java:73) ~[co.cask.tigon.tigon-api-0.2.1.jar:na]
        at co.cask.tigon.internal.io.AbstractSchemaGenerator.doGenerate(AbstractSchemaGenerator.java:166) ~[co.cask.tigon.tigon-api-0.2.1.jar:na]
        at co.cask.tigon.internal.io.AbstractSchemaGenerator.generate(AbstractSchemaGenerator.java:84) ~[co.cask.tigon.tigon-api-0.2.1.jar:na]
        at co.cask.tigon.internal.io.AbstractSchemaGenerator.generate(AbstractSchemaGenerator.java:78) ~[co.cask.tigon.tigon-api-0.2.1.jar:na]
        at co.cask.tigon.api.flow.FlowletDefinition.generateSchema(FlowletDefinition.java:185) ~[co.cask.tigon.tigon-api-0.2.1.jar:na]
        at co.cask.tigon.api.flow.FlowletDefinition.generateSchema(FlowletDefinition.java:172) ~[co.cask.tigon.tigon-api-0.2.1.jar:na]
        at co.cask.tigon.internal.app.FlowSpecificationAdapter.toJson(FlowSpecificationAdapter.java:95) ~[co.cask.tigon.tigon-flow-0.2.1.jar:na]
        at co.cask.tigon.internal.app.FlowSpecificationAdapter.toJson(FlowSpecificationAdapter.java:84) ~[co.cask.tigon.tigon-flow-0.2.1.jar:na]
        at co.cask.tigon.flow.DeployClient$1.getInput(DeployClient.java:181) ~[co.cask.tigon.tigon-flow-0.2.1.jar:na]
        at co.cask.tigon.flow.DeployClient$1.getInput(DeployClient.java:178) ~[co.cask.tigon.tigon-flow-0.2.1.jar:na]
        at com.google.common.io.ByteStreams.copy(ByteStreams.java:146) ~[com.google.guava.guava-13.0.1.jar:na]
        at co.cask.tigon.flow.DeployClient.createDeploymentJar(DeployClient.java:248) ~[co.cask.tigon.tigon-flow-0.2.1.jar:na]
        at co.cask.tigon.flow.DeployClient.jarForTestBase(DeployClient.java:171) ~[co.cask.tigon.tigon-flow-0.2.1.jar:na]
        at co.cask.tigon.flow.DeployClient.jarForTestBase(DeployClient.java:165) ~[co.cask.tigon.tigon-flow-0.2.1.jar:na]
        at co.cask.tigon.flow.DeployClient.createProgram(DeployClient.java:142) ~[co.cask.tigon.tigon-flow-0.2.1.jar:na]
        at co.cask.tigon.flow.DeployClient.startFlow(DeployClient.java:158) ~[co.cask.tigon.tigon-flow-0.2.1.jar:na]
        at co.cask.tigon.StandaloneMain.startUp(StandaloneMain.java:130) ~[co.cask.tigon.tigon-client-0.2.1.jar:na]
        at co.cask.tigon.StandaloneMain.main(StandaloneMain.java:119) ~[co.cask.tigon.tigon-client-0.2.1.jar:na]

I've paired down the code and can reproduce it with the following:

public class DateFlow implements Flow {
  @Override public FlowSpecification configure() {
    return FlowSpecification.Builder.with()
      .setName("DateFlow")
      .setDescription("A flow that generates and prints a java.util.Date object.")
      .withFlowlets()
      .add("generator", new DFlowlet(), 1)
      .add("printer", new PFlowlet(), 1)
      .connect()
      .from("generator").to("printer")
      .build();
  }

  private class DFlowlet extends AbstractFlowlet {
    OutputEmitter<Date> outputEmitter;

    @Tick(delay = 1L, unit = TimeUnit.SECONDS)
    public void generate() {
      outputEmitter.emit(new Date());
    }
  }
  private class PFlowlet extends AbstractFlowlet {
    @ProcessInput
    public void process(String s) {
      System.out.println(s);
    }
  }
}

Any suggestions for how to work with Date objects?  The object I'm trying to emit is already well defined so I can't change the Date to a long and then convert it back.

how...@gmail.com

unread,
Dec 17, 2014, 11:24:34 AM12/17/14
to tigon...@googlegroups.com, how...@gmail.com
This is using Tigon 0.2.1.

Terence Yim

unread,
Dec 17, 2014, 12:25:45 PM12/17/14
to how...@gmail.com, tigon...@googlegroups.com
Hi,

The Date object is currently not supported as it is not a POJO. You'll have to emit the time stamp that you get from the Date object and reconstruct it back on the receiving flowlet.

Terence

Sent from my iPhone

On Dec 17, 2014, at 8:24 AM, how...@gmail.com wrote:

This is using Tigon 0.2.1.

--
You received this message because you are subscribed to the Google Groups "Tigon User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tigon-user+...@googlegroups.com.
To post to this group, send email to tigon...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tigon-user/89fb0aa9-3aff-42b3-8f60-9162efcb496a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Terence Yim

unread,
Dec 17, 2014, 3:50:53 PM12/17/14
to how...@gmail.com, tigon...@googlegroups.com
Hi,

Sorry that I missed the last part of your message that you cannot convert Date into string and convert it back. I’ve opened a new JIRA to add support for the Date type to the Tigon type system. Please follow it in:


Terence

how...@gmail.com

unread,
Dec 17, 2014, 4:11:24 PM12/17/14
to tigon...@googlegroups.com
Great, thanks!
Reply all
Reply to author
Forward
0 new messages