public PhastEncoderStageGenerator(MessageSchema schema, Appendable bodyTarget) { super(schema, bodyTarget, generateClassName(schema) + " extends PronghornStage", generateClassName(schema), schema.getClass().getPackage().getName() + ".build"); this.bodyTarget = bodyTarget; generateRunnable = false; }
/** * This method overrides from the super class, where it is called to add instance variables. This method should not * be called from anywhere but the super class. * * @param target the Appendable target from super class * @throws IOException if the target can not be written to */ @Override protected void additionalMembers(Appendable target) throws IOException { target.append("private long[] " + longDictionaryName + ";\n"); target.append("private int[] " + intDictionaryName + ";\n"); target.append("private long[] " + defaultLongDictionaryName + ";\n"); target.append("private int[] " + defaultIntDictionaryName + ";\n"); target.append("private Pipe<RawDataSchema> " + inPipeName + ";\n"); interfaceMembers(target); }
public FuzzDataStageGenerator(MessageSchema schema, Appendable target, boolean generateRunnable, boolean scopeProtected) { super(schema, target, generateClassName(schema)+(generateRunnable ? "" : "Stage"), generateRunnable ? "implements Runnable" : "extends PronghornStage", generateRunnable ? null : "output", scopeProtected ? "protected" : "private", false, schema.getClass().getPackage().getName()+".build"); this.generateRunnable = generateRunnable; }
@Test public void compileTest() throws Exception { FieldReferenceOffsetManager from = TemplateHandler.loadFrom("src/test/resources/template/integrityTest.xml"); MessageSchemaDynamic messageSchema = new MessageSchemaDynamic(from); StringBuilder target = new StringBuilder(); PhastDecoderStageGenerator ew = new PhastDecoderStageGenerator(messageSchema, target, false); try { ew.processSchema(); } catch (IOException e) { System.out.println(target); e.printStackTrace(); fail(); } validateCleanCompile(ew.getPackageName(), ew.getClassName(), target, PhastDecoderStageGenerator.class); StringBuilder target2 = new StringBuilder(); PhastEncoderStageGenerator encoder = new PhastEncoderStageGenerator(messageSchema, target2); try { encoder.processSchema(); } catch (IOException e) { System.out.println(target); e.printStackTrace(); fail(); } validateCleanCompile(encoder.getPackageName(), encoder.getClassName(), target2, PhastEncoderStageGenerator.class); }
@Test public void fuzzGeneratorBuildRunnableTest() { StringBuilder target = new StringBuilder(); FuzzDataStageGenerator ew = new FuzzDataStageGenerator(PipeMonitorSchema.instance, target, true); try { ew.processSchema(); } catch (IOException e) { System.out.println(target); e.printStackTrace(); fail(); } validateCleanCompile(ew.getPackageName(), ew.getClassName(), target); }
@Test public void generateDecoderCompileTest() { StringBuilder target = new StringBuilder(); PhastDecoderStageGenerator ew = new PhastDecoderStageGenerator(PipeMonitorSchema.instance, target, false); try { ew.processSchema(); } catch (IOException e) { //System.out.println(target); e.printStackTrace(); fail(); } validateCleanCompile(ew.getPackageName(), ew.getClassName(), target); }
@Test public void generateEncoderCompileTest() { StringBuilder target = new StringBuilder(); PhastEncoderStageGenerator ew = new PhastEncoderStageGenerator(PipeMonitorSchema.instance, target); try { ew.processSchema(); } catch (IOException e) { // System.out.println(target); e.printStackTrace(); fail(); } validateCleanCompile(ew.getPackageName(), ew.getClassName(), target); }
appendWriteMethodName(target.append(tab), cursor).append("(\n"); for(int f = firstField; f<(firstField+fieldCount); f++) { if (f > firstField) { bodyOfBusinessProcessInternal(target, cursor, firstField, fieldCount);
target.append("Pipe<RawDataSchema> " + inPipeName + ", "); Appendables.appendClass(target, Pipe.class, schema.getClass()).append(" ").append(pipeVarName); additionalArgs(target); target.append(") {\n"); target.append(tab + defaultIntDictionaryName + " = FROM.newIntDefaultsDictionary();\n"); target.append(tab + defaultLongDictionaryName + " = FROM.newLongDefaultsDictionary();\n"); interfaceSetup(target); target.append("}\n\n");
@Test public void fuzzGeneratorUsageTestPipeMonitor() { StringBuilder target = new StringBuilder(); FuzzDataStageGenerator ew = new FuzzDataStageGenerator(PipeMonitorSchema.instance, target); // //set the field to use for latency ew.setTimeFieldId(1); //use the MS field from the monitor schema to put the time into. int durationMS = 200; runtimeTestingOfFuzzGenerator(target, PipeMonitorSchema.instance, ew, durationMS, 200); }
@Test public void fuzzGeneratorUsageTestSequenceExample() { MessageSchemaDynamic schema = sequenceExampleSchema(); //Fuzz time test, what ranges are the best? StringBuilder target = new StringBuilder(); FuzzDataStageGenerator ew = new FuzzDataStageGenerator(schema, target); ew.setMaxSequenceLengthInBits(9); int durationMS = 100; runtimeTestingOfFuzzGenerator(target, schema, ew, durationMS, 8000); }
public PhastDecoderStageGenerator(MessageSchema schema, Appendable target, boolean generateRunnable, boolean scopeProtected) { super(schema, target, generateClassName(schema) + (generateRunnable ? "" : "Stage"), generateRunnable ? "implements Runnable" : "extends PronghornStage", generateRunnable ? null : "output", scopeProtected ? "protected" : "private", false, schema.getClass().getPackage().getName() + ".build"); this.generateRunnable = generateRunnable; }
/** * This method overrides from the super class, where it is called to add instance variables. This method should not * be called from anywhere but the super class. * * @param target the Appendable target from super class * @throws IOException if the target can not be written to */ @Override protected void additionalMembers(Appendable target) throws IOException { target.append("long[] " + longDictionaryName + ";\n"); target.append("int[] " + intDictionaryName + ";\n"); target.append("long[] " + defLongDictionaryName + ";\n"); target.append("int[] " + defIntDictionaryName + ";\n"); //isntantiate pipe target.append("DataOutputBlobWriter<" + schema.getClass().getSimpleName() + "> " + writerName + ";\n"); //target.append("private Pipe<MessageSchemaDynamic> " + inPipeName + ";\n"); target.append("private Pipe<RawDataSchema> " + outPipeName + ";\n"); interfaceMembers(target); }
/** * This method overrides from the super class, where it is called to add imports. This method should not be called * from anywhere but the super class. * * @param schema the schema from super class * @param target the Appendable target from super class */ @Override protected void additionalImports(MessageSchema schema, Appendable target) { try { target.append("import ").append(schema.getClass().getCanonicalName()).append(";\n"); target.append("import com.ociweb.pronghorn.stage.phast.PhastDecoder;\n"); target.append("import ").append(DataInputBlobReader.class.getCanonicalName()).append(";\n"); target.append("import ").append(PronghornStage.class.getCanonicalName()).append(";\n"); target.append("import java.util.Arrays;\n"); target.append("import com.ociweb.pronghorn.pipe.*;\n"); interfaceImports(target); } catch (IOException e) { throw new RuntimeException(e); } }
/** * This method overrides from the super class, where it is called to add imports. This method should not be called * from anywhere but the super class. * * @param schema the schema from super class * @param target the Appendable target from super class */ @Override protected void additionalImports(MessageSchema schema, Appendable target) { try { target.append("import ").append(schema.getClass().getCanonicalName()).append(";\n"); target.append("import " + PhastEncoder.class.getCanonicalName() + ";\n"); target.append("import " + DataOutputBlobWriter.class.getCanonicalName() + ";\n"); target.append("import com.ociweb.pronghorn.pipe.*;\n"); target.append("import " + PronghornStage.class.getCanonicalName() + ";\n"); interfaceImports(target); target.append("\n"); } catch (IOException e) { throw new RuntimeException(e); } }
@Ignore public void fuzzGeneratorUsageTestRawData() { StringBuilder target = new StringBuilder(); //TODO: Rewrite for ByteVector, DO NOT use ByteBuffer instead use the easier DataOutput object. FuzzDataStageGenerator ew = new FuzzDataStageGenerator(RawDataSchema.instance, target); int durationMS = 300; runtimeTestingOfFuzzGenerator(target, RawDataSchema.instance, ew, durationMS,1000); }
@Test public void fuzzGeneratorBuildTest() { StringBuilder target = new StringBuilder(); FuzzDataStageGenerator ew = new FuzzDataStageGenerator(PipeMonitorSchema.instance, target); try { ew.processSchema(); } catch (IOException e) { System.out.println(target); e.printStackTrace(); fail(); } validateCleanCompile(ew.getPackageName(), ew.getClassName(), target); }
public FuzzDataStageGenerator(MessageSchema schema, Appendable target, String interitance, boolean scopeProtected) { super(schema, target, generateClassName(schema), interitance,null, scopeProtected ? "protected" : "private", false, schema.getClass().getPackage().getName()+".build"); this.generateRunnable = true; }
public PhastDecoderStageGenerator(MessageSchema schema, Appendable target, String interitance, boolean scopeProtected) { super(schema, target, generateClassName(schema), interitance, null, scopeProtected ? "protected" : "private", false, schema.getClass().getPackage().getName() + ".build"); this.generateRunnable = true; }
@Test public void fuzzGeneratorBuildRunnable2Test() { MessageSchemaDynamic schema = sequenceExampleSchema(); StringBuilder target = new StringBuilder(); FuzzDataStageGenerator ew = new FuzzDataStageGenerator(schema, target, true); try { ew.processSchema(); } catch (IOException e) { System.out.println(target); e.printStackTrace(); fail(); } // System.out.println(target); validateCleanCompile(ew.getPackageName(), ew.getClassName(), target); }