Creating graphs programatically

Hi

I’m struggling to find examples of how to create graphs dynamically, as opposed to using the xml graphs. For instance, I have a simple graph - a delimited reader (NIO) and a delimited writer (NIO) with a simple transform in between. Using the xml configuration it works perfectly, however, this is not an option for what I need to do. So trying to do it programmatically like this:

Phase phase = new Phase(0);
phase.init();
phase.setGraph(graph);

phase.addEdge(inputEdge);
phase.addEdge(outputEdge);

phase.addNode(inputNode);
phase.addNode(outputNode);
phase.addNode(transform);

inputNode.addOutputPort(0, inputEdge);
transform.addInputPort(0,inputEdge);
transform.addOutputPort(0,outputEdge);
outputNode.addInputPort(0, outputEdge);

graph.addPhase(phase);
graph.init();
graph.run();

(assume the nodes and edges are defined correctly, and the input file url refers to a trivial 2 line file - as I say, it all works perfectly when using an xml graph modelled on the samples)

Running this, however, causes all kinds of errors. With older versions, eg 1.1.6, nothing happens. With more recent versions I get BufferUNDERflow exceptions. Changing the readers and writers to non-NIO instances, gives my BufferOVERflow errors.

Am I building my graph incorrectly, or is there a bug? I can provide source files and input files if necessary.

Hi Chris.
Please, try call static method Defaults.init() before you run graph.