repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
IHTSDO/snomed-utilities
src/main/java/org/ihtsdo/util/GlobalUtils.java
// Path: src/main/java/org/ihtsdo/snomed/util/SnomedUtilException.java // public class SnomedUtilException extends Exception { // // private static final long serialVersionUID = 1L; // // public SnomedUtilException(String msg, Throwable t) { // super(msg, t); // } // // public SnomedUtilException(String msg) { // super(msg); // } // }
import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.nio.charset.StandardCharsets; import java.util.List; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import org.apache.commons.io.FileUtils; import org.ihtsdo.snomed.util.SnomedUtilException;
File file = new File(fileName); if (!file.exists()) { if (file.getParentFile() != null) { file.getParentFile().mkdirs(); } file.createNewFile(); } return file; } /** * @return an array of 3 elements containing: The path, the filename, the file extension (if it exists) or empty strings */ public static String[] deconstructFilename(File file) { String[] parts = new String[] {"","",""}; if (file== null) { return parts; } parts[0] = file.getAbsolutePath().substring(0, file.getAbsolutePath().lastIndexOf(File.separator)); if (file.getName().lastIndexOf(".") > 0) { parts[1] = file.getName().substring(0, file.getName().lastIndexOf(".")); parts[2] = file.getName().substring(file.getName().lastIndexOf(".") + 1); } else { parts[1] = file.getName(); } return parts; }
// Path: src/main/java/org/ihtsdo/snomed/util/SnomedUtilException.java // public class SnomedUtilException extends Exception { // // private static final long serialVersionUID = 1L; // // public SnomedUtilException(String msg, Throwable t) { // super(msg, t); // } // // public SnomedUtilException(String msg) { // super(msg); // } // } // Path: src/main/java/org/ihtsdo/util/GlobalUtils.java import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.nio.charset.StandardCharsets; import java.util.List; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import org.apache.commons.io.FileUtils; import org.ihtsdo.snomed.util.SnomedUtilException; File file = new File(fileName); if (!file.exists()) { if (file.getParentFile() != null) { file.getParentFile().mkdirs(); } file.createNewFile(); } return file; } /** * @return an array of 3 elements containing: The path, the filename, the file extension (if it exists) or empty strings */ public static String[] deconstructFilename(File file) { String[] parts = new String[] {"","",""}; if (file== null) { return parts; } parts[0] = file.getAbsolutePath().substring(0, file.getAbsolutePath().lastIndexOf(File.separator)); if (file.getName().lastIndexOf(".") > 0) { parts[1] = file.getName().substring(0, file.getName().lastIndexOf(".")); parts[2] = file.getName().substring(file.getName().lastIndexOf(".") + 1); } else { parts[1] = file.getName(); } return parts; }
public static void createArchive(File dirToZip, String zipFileOrigName) throws SnomedUtilException {
IHTSDO/snomed-utilities
src/main/java/org/ihtsdo/snomed/util/rf2/srsi/Relationship.java
// Path: src/main/java/org/ihtsdo/snomed/util/Type5UuidFactory.java // public class Type5UuidFactory { // // public static final String encoding = "8859_1"; // public static final String SHA_1 = "SHA-1"; // // private final MessageDigest sha1Algorithm; // // public Type5UuidFactory() throws NoSuchAlgorithmException { // sha1Algorithm = MessageDigest.getInstance(SHA_1); // } // // public synchronized UUID get(UUID namespace, String name) throws UnsupportedEncodingException { // // Generate the digest. // sha1Algorithm.reset(); // if (namespace != null) { // sha1Algorithm.update(getRawBytes(namespace)); // } // sha1Algorithm.update(name.getBytes(encoding)); // byte[] sha1digest = sha1Algorithm.digest(); // // sha1digest[6] &= 0x0f; /* clear version */ // sha1digest[6] |= 0x50; /* set to version 5 */ // sha1digest[8] &= 0x3f; /* clear variant */ // sha1digest[8] |= 0x80; /* set to IETF variant */ // // long msb = 0; // long lsb = 0; // for (int i = 0; i < 8; i++) { // msb = (msb << 8) | (sha1digest[i] & 0xff); // } // for (int i = 8; i < 16; i++) { // lsb = (lsb << 8) | (sha1digest[i] & 0xff); // } // // return new UUID(msb, lsb); // } // // public UUID get(String name) throws UnsupportedEncodingException { // return get(null, name); // } // // /** // * This routine adapted from org.safehaus.uuid.UUID, // * which is licensed under Apache 2. // * // * @param uid // * @return // */ // public static byte[] getRawBytes(UUID uid) { // String id = uid.toString(); // if (id.length() != 36) { // throw new NumberFormatException("UUID has to be represented by the standard 36-char representation"); // } // byte[] rawBytes = new byte[16]; // // for (int i = 0, j = 0; i < 36; ++j) { // // Need to bypass hyphens: // switch (i) { // case 8: // case 13: // case 18: // case 23: // if (id.charAt(i) != '-') { // throw new NumberFormatException("UUID has to be represented by the standard 36-char representation"); // } // ++i; // } // char c = id.charAt(i); // // if (c >= '0' && c <= '9') { // rawBytes[j] = (byte) ((c - '0') << 4); // } else if (c >= 'a' && c <= 'f') { // rawBytes[j] = (byte) ((c - 'a' + 10) << 4); // } else if (c >= 'A' && c <= 'F') { // rawBytes[j] = (byte) ((c - 'A' + 10) << 4); // } else { // throw new NumberFormatException("Non-hex character '" + c + "'"); // } // // c = id.charAt(++i); // // if (c >= '0' && c <= '9') { // rawBytes[j] |= (byte) (c - '0'); // } else if (c >= 'a' && c <= 'f') { // rawBytes[j] |= (byte) (c - 'a' + 10); // } else if (c >= 'A' && c <= 'F') { // rawBytes[j] |= (byte) (c - 'A' + 10); // } else { // throw new NumberFormatException("Non-hex character '" + c + "'"); // } // ++i; // } // return rawBytes; // } // // }
import java.util.List; import org.ihtsdo.snomed.util.Type5UuidFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
package org.ihtsdo.snomed.util.rf2.srsi; public class Relationship implements Comparable<Relationship> { private static final Logger LOGGER = LoggerFactory.getLogger(Relationship.class); // id effectiveTime active moduleId sourceId destinationId relationshipGroup typeId characteristicTypeId modifierId public static final Long ISA_ID = new Long(116680003); public static final String CHARACTERISTIC_STATED_SCTID = "900000000000010007"; public static final String FIELD_DELIMITER = "\t"; public static final String LINE_DELIMITER = "\r\n"; public static final String ACTIVE_FLAG = "1"; public static final String INACTIVE_FLAG = "0"; public static final String HEADER_ROW = "id\teffectiveTime\tactive\tmoduleId\tsourceId\tdestinationId\trelationshipGroup\ttypeId\tcharacteristicTypeId\tmodifierId\r\n"; public static enum CHARACTERISTIC { STATED, INFERRED, ADDITIONAL };
// Path: src/main/java/org/ihtsdo/snomed/util/Type5UuidFactory.java // public class Type5UuidFactory { // // public static final String encoding = "8859_1"; // public static final String SHA_1 = "SHA-1"; // // private final MessageDigest sha1Algorithm; // // public Type5UuidFactory() throws NoSuchAlgorithmException { // sha1Algorithm = MessageDigest.getInstance(SHA_1); // } // // public synchronized UUID get(UUID namespace, String name) throws UnsupportedEncodingException { // // Generate the digest. // sha1Algorithm.reset(); // if (namespace != null) { // sha1Algorithm.update(getRawBytes(namespace)); // } // sha1Algorithm.update(name.getBytes(encoding)); // byte[] sha1digest = sha1Algorithm.digest(); // // sha1digest[6] &= 0x0f; /* clear version */ // sha1digest[6] |= 0x50; /* set to version 5 */ // sha1digest[8] &= 0x3f; /* clear variant */ // sha1digest[8] |= 0x80; /* set to IETF variant */ // // long msb = 0; // long lsb = 0; // for (int i = 0; i < 8; i++) { // msb = (msb << 8) | (sha1digest[i] & 0xff); // } // for (int i = 8; i < 16; i++) { // lsb = (lsb << 8) | (sha1digest[i] & 0xff); // } // // return new UUID(msb, lsb); // } // // public UUID get(String name) throws UnsupportedEncodingException { // return get(null, name); // } // // /** // * This routine adapted from org.safehaus.uuid.UUID, // * which is licensed under Apache 2. // * // * @param uid // * @return // */ // public static byte[] getRawBytes(UUID uid) { // String id = uid.toString(); // if (id.length() != 36) { // throw new NumberFormatException("UUID has to be represented by the standard 36-char representation"); // } // byte[] rawBytes = new byte[16]; // // for (int i = 0, j = 0; i < 36; ++j) { // // Need to bypass hyphens: // switch (i) { // case 8: // case 13: // case 18: // case 23: // if (id.charAt(i) != '-') { // throw new NumberFormatException("UUID has to be represented by the standard 36-char representation"); // } // ++i; // } // char c = id.charAt(i); // // if (c >= '0' && c <= '9') { // rawBytes[j] = (byte) ((c - '0') << 4); // } else if (c >= 'a' && c <= 'f') { // rawBytes[j] = (byte) ((c - 'a' + 10) << 4); // } else if (c >= 'A' && c <= 'F') { // rawBytes[j] = (byte) ((c - 'A' + 10) << 4); // } else { // throw new NumberFormatException("Non-hex character '" + c + "'"); // } // // c = id.charAt(++i); // // if (c >= '0' && c <= '9') { // rawBytes[j] |= (byte) (c - '0'); // } else if (c >= 'a' && c <= 'f') { // rawBytes[j] |= (byte) (c - 'a' + 10); // } else if (c >= 'A' && c <= 'F') { // rawBytes[j] |= (byte) (c - 'A' + 10); // } else { // throw new NumberFormatException("Non-hex character '" + c + "'"); // } // ++i; // } // return rawBytes; // } // // } // Path: src/main/java/org/ihtsdo/snomed/util/rf2/srsi/Relationship.java import java.util.List; import org.ihtsdo.snomed.util.Type5UuidFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; package org.ihtsdo.snomed.util.rf2.srsi; public class Relationship implements Comparable<Relationship> { private static final Logger LOGGER = LoggerFactory.getLogger(Relationship.class); // id effectiveTime active moduleId sourceId destinationId relationshipGroup typeId characteristicTypeId modifierId public static final Long ISA_ID = new Long(116680003); public static final String CHARACTERISTIC_STATED_SCTID = "900000000000010007"; public static final String FIELD_DELIMITER = "\t"; public static final String LINE_DELIMITER = "\r\n"; public static final String ACTIVE_FLAG = "1"; public static final String INACTIVE_FLAG = "0"; public static final String HEADER_ROW = "id\teffectiveTime\tactive\tmoduleId\tsourceId\tdestinationId\trelationshipGroup\ttypeId\tcharacteristicTypeId\tmodifierId\r\n"; public static enum CHARACTERISTIC { STATED, INFERRED, ADDITIONAL };
private static Type5UuidFactory type5UuidFactory;
IHTSDO/snomed-utilities
src/main/java/org/ihtsdo/snomed/util/rf2/srsi/RelationshipProcessor.java
// Path: src/main/java/org/ihtsdo/snomed/util/rf2/srsi/Relationship.java // public static enum CHARACTERISTIC { // STATED, INFERRED, ADDITIONAL // };
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; import java.io.Writer; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Scanner; import java.util.TreeSet; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.io.output.NullOutputStream; import org.ihtsdo.snomed.util.rf2.srsi.Relationship.CHARACTERISTIC; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
this.additionalFile = additionalFile; this.outputFile = outputFile; } public static void main(String[] args) throws Exception { if (args.length < 4) { doHelp(); } RelationshipProcessor rp = new RelationshipProcessor(args[0], args[1], args[2], args[3]); // Make sure we have a valid effectiveTime for output, before we start rp.outputEffectiveTime = extractEffectiveTime(args[3]); rp.loadRelationships(); rp.substituteInferredRelationships(); // Are we running in interactive mode? Query memory structures if so if (args.length == 5 && args[4].equals("-i")) { rp.goInteractive(); } } /** * Lookup the concept in both the stated and inferred graphs and output all the relationships (sorted naturally) for each * * @param conceptSCTID * @throws Exception */ private void outputConcept(Long conceptSCTID) throws Exception { // Output all the parents of this concept in the
// Path: src/main/java/org/ihtsdo/snomed/util/rf2/srsi/Relationship.java // public static enum CHARACTERISTIC { // STATED, INFERRED, ADDITIONAL // }; // Path: src/main/java/org/ihtsdo/snomed/util/rf2/srsi/RelationshipProcessor.java import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; import java.io.Writer; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Scanner; import java.util.TreeSet; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.io.output.NullOutputStream; import org.ihtsdo.snomed.util.rf2.srsi.Relationship.CHARACTERISTIC; import org.slf4j.Logger; import org.slf4j.LoggerFactory; this.additionalFile = additionalFile; this.outputFile = outputFile; } public static void main(String[] args) throws Exception { if (args.length < 4) { doHelp(); } RelationshipProcessor rp = new RelationshipProcessor(args[0], args[1], args[2], args[3]); // Make sure we have a valid effectiveTime for output, before we start rp.outputEffectiveTime = extractEffectiveTime(args[3]); rp.loadRelationships(); rp.substituteInferredRelationships(); // Are we running in interactive mode? Query memory structures if so if (args.length == 5 && args[4].equals("-i")) { rp.goInteractive(); } } /** * Lookup the concept in both the stated and inferred graphs and output all the relationships (sorted naturally) for each * * @param conceptSCTID * @throws Exception */ private void outputConcept(Long conceptSCTID) throws Exception { // Output all the parents of this concept in the
Concept conceptInferred = Concept.getConcept(conceptSCTID, CHARACTERISTIC.INFERRED);
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/builder/FlowDefsBuilder.java
// Path: src/main/java/org/calrissian/flowmix/core/model/StreamDef.java // public class StreamDef implements Serializable { // // private String name; // private List<FlowOp> flowOps; // private boolean stdInput; // private boolean stdOutput; // private String[] outputs; // // public StreamDef(String name, List<FlowOp> flowOps, boolean stdInput, boolean stdOutput, String[] outputs) { // this.name = name; // this.flowOps = flowOps; // this.stdInput = stdInput; // this.stdOutput = stdOutput; // this.outputs = outputs; // } // // public String getName() { // return name; // } // // public List<FlowOp> getFlowOps() { // return flowOps; // } // // public boolean isStdInput() { // return stdInput; // } // // public boolean isStdOutput() { // return stdOutput; // } // // public String[] getOutputs() { // return outputs; // } // // @Override // public String toString() { // return "StreamDef{" + // "name='" + name + '\'' + // ", flowOps=" + flowOps + // '}'; // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // StreamDef streamDef = (StreamDef) o; // // if (stdInput != streamDef.stdInput) { // return false; // } // if (stdOutput != streamDef.stdOutput) { // return false; // } // if (flowOps != null ? !flowOps.equals(streamDef.flowOps) : streamDef.flowOps != null) { // return false; // } // if (name != null ? !name.equals(streamDef.name) : streamDef.name != null) { // return false; // } // if (!Arrays.equals(outputs, streamDef.outputs)) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = name != null ? name.hashCode() : 0; // result = 31 * result + (flowOps != null ? flowOps.hashCode() : 0); // result = 31 * result + (stdInput ? 1 : 0); // result = 31 * result + (stdOutput ? 1 : 0); // result = 31 * result + (outputs != null ? Arrays.hashCode(outputs) : 0); // return result; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/JoinOp.java // public class JoinOp implements FlowOp, RequiresPartitioning { // // public static final String JOIN = "join"; // // String leftStream; // String rightStream; // // Policy evictionPolicy; // long evictionThreshold; // // public JoinOp(String leftStream, String rightStream, Policy evictionPolicy, long evictionThreshold) { // this.leftStream = leftStream; // this.rightStream = rightStream; // this.evictionPolicy = evictionPolicy; // this.evictionThreshold = evictionThreshold; // } // // public String getLeftStream() { // return leftStream; // } // // public String getRightStream() { // return rightStream; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // @Override // public String getComponentName() { // return "join"; // } // }
import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import org.calrissian.flowmix.core.model.StreamDef; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.JoinOp;
boolean oneStdOut = false; boolean oneStdIn = false; Map<String, Set<String>> inputs = new HashMap<String, Set<String>>(); for(StreamDef def : getStreamList()) { if(def.isStdInput()) oneStdIn = true; if(def.isStdOutput()) oneStdOut = true; if(def.getOutputs() != null) { for(String output : def.getOutputs()) { Set<String> entry = inputs.get(output); if(entry == null) { entry = new HashSet<String>(); inputs.put(output, entry); } entry.add(def.getName()); } } } if(!oneStdIn) throw new RuntimeException("At least one stream needs to read from std input"); if(!oneStdOut) throw new RuntimeException("At least one stream needs to write to std output"); for(StreamDef def : getStreamList()) {
// Path: src/main/java/org/calrissian/flowmix/core/model/StreamDef.java // public class StreamDef implements Serializable { // // private String name; // private List<FlowOp> flowOps; // private boolean stdInput; // private boolean stdOutput; // private String[] outputs; // // public StreamDef(String name, List<FlowOp> flowOps, boolean stdInput, boolean stdOutput, String[] outputs) { // this.name = name; // this.flowOps = flowOps; // this.stdInput = stdInput; // this.stdOutput = stdOutput; // this.outputs = outputs; // } // // public String getName() { // return name; // } // // public List<FlowOp> getFlowOps() { // return flowOps; // } // // public boolean isStdInput() { // return stdInput; // } // // public boolean isStdOutput() { // return stdOutput; // } // // public String[] getOutputs() { // return outputs; // } // // @Override // public String toString() { // return "StreamDef{" + // "name='" + name + '\'' + // ", flowOps=" + flowOps + // '}'; // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // StreamDef streamDef = (StreamDef) o; // // if (stdInput != streamDef.stdInput) { // return false; // } // if (stdOutput != streamDef.stdOutput) { // return false; // } // if (flowOps != null ? !flowOps.equals(streamDef.flowOps) : streamDef.flowOps != null) { // return false; // } // if (name != null ? !name.equals(streamDef.name) : streamDef.name != null) { // return false; // } // if (!Arrays.equals(outputs, streamDef.outputs)) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = name != null ? name.hashCode() : 0; // result = 31 * result + (flowOps != null ? flowOps.hashCode() : 0); // result = 31 * result + (stdInput ? 1 : 0); // result = 31 * result + (stdOutput ? 1 : 0); // result = 31 * result + (outputs != null ? Arrays.hashCode(outputs) : 0); // return result; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/JoinOp.java // public class JoinOp implements FlowOp, RequiresPartitioning { // // public static final String JOIN = "join"; // // String leftStream; // String rightStream; // // Policy evictionPolicy; // long evictionThreshold; // // public JoinOp(String leftStream, String rightStream, Policy evictionPolicy, long evictionThreshold) { // this.leftStream = leftStream; // this.rightStream = rightStream; // this.evictionPolicy = evictionPolicy; // this.evictionThreshold = evictionThreshold; // } // // public String getLeftStream() { // return leftStream; // } // // public String getRightStream() { // return rightStream; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // @Override // public String getComponentName() { // return "join"; // } // } // Path: src/main/java/org/calrissian/flowmix/api/builder/FlowDefsBuilder.java import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import org.calrissian.flowmix.core.model.StreamDef; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.JoinOp; boolean oneStdOut = false; boolean oneStdIn = false; Map<String, Set<String>> inputs = new HashMap<String, Set<String>>(); for(StreamDef def : getStreamList()) { if(def.isStdInput()) oneStdIn = true; if(def.isStdOutput()) oneStdOut = true; if(def.getOutputs() != null) { for(String output : def.getOutputs()) { Set<String> entry = inputs.get(output); if(entry == null) { entry = new HashSet<String>(); inputs.put(output, entry); } entry.add(def.getName()); } } } if(!oneStdIn) throw new RuntimeException("At least one stream needs to read from std input"); if(!oneStdOut) throw new RuntimeException("At least one stream needs to write to std output"); for(StreamDef def : getStreamList()) {
for(FlowOp op : def.getFlowOps()) {
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/builder/FlowDefsBuilder.java
// Path: src/main/java/org/calrissian/flowmix/core/model/StreamDef.java // public class StreamDef implements Serializable { // // private String name; // private List<FlowOp> flowOps; // private boolean stdInput; // private boolean stdOutput; // private String[] outputs; // // public StreamDef(String name, List<FlowOp> flowOps, boolean stdInput, boolean stdOutput, String[] outputs) { // this.name = name; // this.flowOps = flowOps; // this.stdInput = stdInput; // this.stdOutput = stdOutput; // this.outputs = outputs; // } // // public String getName() { // return name; // } // // public List<FlowOp> getFlowOps() { // return flowOps; // } // // public boolean isStdInput() { // return stdInput; // } // // public boolean isStdOutput() { // return stdOutput; // } // // public String[] getOutputs() { // return outputs; // } // // @Override // public String toString() { // return "StreamDef{" + // "name='" + name + '\'' + // ", flowOps=" + flowOps + // '}'; // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // StreamDef streamDef = (StreamDef) o; // // if (stdInput != streamDef.stdInput) { // return false; // } // if (stdOutput != streamDef.stdOutput) { // return false; // } // if (flowOps != null ? !flowOps.equals(streamDef.flowOps) : streamDef.flowOps != null) { // return false; // } // if (name != null ? !name.equals(streamDef.name) : streamDef.name != null) { // return false; // } // if (!Arrays.equals(outputs, streamDef.outputs)) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = name != null ? name.hashCode() : 0; // result = 31 * result + (flowOps != null ? flowOps.hashCode() : 0); // result = 31 * result + (stdInput ? 1 : 0); // result = 31 * result + (stdOutput ? 1 : 0); // result = 31 * result + (outputs != null ? Arrays.hashCode(outputs) : 0); // return result; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/JoinOp.java // public class JoinOp implements FlowOp, RequiresPartitioning { // // public static final String JOIN = "join"; // // String leftStream; // String rightStream; // // Policy evictionPolicy; // long evictionThreshold; // // public JoinOp(String leftStream, String rightStream, Policy evictionPolicy, long evictionThreshold) { // this.leftStream = leftStream; // this.rightStream = rightStream; // this.evictionPolicy = evictionPolicy; // this.evictionThreshold = evictionThreshold; // } // // public String getLeftStream() { // return leftStream; // } // // public String getRightStream() { // return rightStream; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // @Override // public String getComponentName() { // return "join"; // } // }
import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import org.calrissian.flowmix.core.model.StreamDef; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.JoinOp;
boolean oneStdOut = false; boolean oneStdIn = false; Map<String, Set<String>> inputs = new HashMap<String, Set<String>>(); for(StreamDef def : getStreamList()) { if(def.isStdInput()) oneStdIn = true; if(def.isStdOutput()) oneStdOut = true; if(def.getOutputs() != null) { for(String output : def.getOutputs()) { Set<String> entry = inputs.get(output); if(entry == null) { entry = new HashSet<String>(); inputs.put(output, entry); } entry.add(def.getName()); } } } if(!oneStdIn) throw new RuntimeException("At least one stream needs to read from std input"); if(!oneStdOut) throw new RuntimeException("At least one stream needs to write to std output"); for(StreamDef def : getStreamList()) { for(FlowOp op : def.getFlowOps()) {
// Path: src/main/java/org/calrissian/flowmix/core/model/StreamDef.java // public class StreamDef implements Serializable { // // private String name; // private List<FlowOp> flowOps; // private boolean stdInput; // private boolean stdOutput; // private String[] outputs; // // public StreamDef(String name, List<FlowOp> flowOps, boolean stdInput, boolean stdOutput, String[] outputs) { // this.name = name; // this.flowOps = flowOps; // this.stdInput = stdInput; // this.stdOutput = stdOutput; // this.outputs = outputs; // } // // public String getName() { // return name; // } // // public List<FlowOp> getFlowOps() { // return flowOps; // } // // public boolean isStdInput() { // return stdInput; // } // // public boolean isStdOutput() { // return stdOutput; // } // // public String[] getOutputs() { // return outputs; // } // // @Override // public String toString() { // return "StreamDef{" + // "name='" + name + '\'' + // ", flowOps=" + flowOps + // '}'; // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // StreamDef streamDef = (StreamDef) o; // // if (stdInput != streamDef.stdInput) { // return false; // } // if (stdOutput != streamDef.stdOutput) { // return false; // } // if (flowOps != null ? !flowOps.equals(streamDef.flowOps) : streamDef.flowOps != null) { // return false; // } // if (name != null ? !name.equals(streamDef.name) : streamDef.name != null) { // return false; // } // if (!Arrays.equals(outputs, streamDef.outputs)) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = name != null ? name.hashCode() : 0; // result = 31 * result + (flowOps != null ? flowOps.hashCode() : 0); // result = 31 * result + (stdInput ? 1 : 0); // result = 31 * result + (stdOutput ? 1 : 0); // result = 31 * result + (outputs != null ? Arrays.hashCode(outputs) : 0); // return result; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/JoinOp.java // public class JoinOp implements FlowOp, RequiresPartitioning { // // public static final String JOIN = "join"; // // String leftStream; // String rightStream; // // Policy evictionPolicy; // long evictionThreshold; // // public JoinOp(String leftStream, String rightStream, Policy evictionPolicy, long evictionThreshold) { // this.leftStream = leftStream; // this.rightStream = rightStream; // this.evictionPolicy = evictionPolicy; // this.evictionThreshold = evictionThreshold; // } // // public String getLeftStream() { // return leftStream; // } // // public String getRightStream() { // return rightStream; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // @Override // public String getComponentName() { // return "join"; // } // } // Path: src/main/java/org/calrissian/flowmix/api/builder/FlowDefsBuilder.java import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import org.calrissian.flowmix.core.model.StreamDef; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.JoinOp; boolean oneStdOut = false; boolean oneStdIn = false; Map<String, Set<String>> inputs = new HashMap<String, Set<String>>(); for(StreamDef def : getStreamList()) { if(def.isStdInput()) oneStdIn = true; if(def.isStdOutput()) oneStdOut = true; if(def.getOutputs() != null) { for(String output : def.getOutputs()) { Set<String> entry = inputs.get(output); if(entry == null) { entry = new HashSet<String>(); inputs.put(output, entry); } entry.add(def.getName()); } } } if(!oneStdIn) throw new RuntimeException("At least one stream needs to read from std input"); if(!oneStdOut) throw new RuntimeException("At least one stream needs to write to std output"); for(StreamDef def : getStreamList()) { for(FlowOp op : def.getFlowOps()) {
if(op instanceof JoinOp) {
calrissian/flowmix
src/main/java/org/calrissian/flowmix/core/model/FlowInfo.java
// Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String EVENT = "event"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_ID = "flowId"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_OP_IDX = "flowOpIdx"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String LAST_STREAM = "lastStream"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String PARTITION = "partition"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String STREAM_NAME = "streamName";
import backtype.storm.tuple.Tuple; import org.calrissian.mango.domain.event.Event; import static org.calrissian.flowmix.core.Constants.EVENT; import static org.calrissian.flowmix.core.Constants.FLOW_ID; import static org.calrissian.flowmix.core.Constants.FLOW_OP_IDX; import static org.calrissian.flowmix.core.Constants.LAST_STREAM; import static org.calrissian.flowmix.core.Constants.PARTITION; import static org.calrissian.flowmix.core.Constants.STREAM_NAME;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.model; public class FlowInfo { private String flowId; private Event event; private int idx; private String streamName; private String previousStream; private String partition; public FlowInfo(Tuple tuple) {
// Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String EVENT = "event"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_ID = "flowId"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_OP_IDX = "flowOpIdx"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String LAST_STREAM = "lastStream"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String PARTITION = "partition"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String STREAM_NAME = "streamName"; // Path: src/main/java/org/calrissian/flowmix/core/model/FlowInfo.java import backtype.storm.tuple.Tuple; import org.calrissian.mango.domain.event.Event; import static org.calrissian.flowmix.core.Constants.EVENT; import static org.calrissian.flowmix.core.Constants.FLOW_ID; import static org.calrissian.flowmix.core.Constants.FLOW_OP_IDX; import static org.calrissian.flowmix.core.Constants.LAST_STREAM; import static org.calrissian.flowmix.core.Constants.PARTITION; import static org.calrissian.flowmix.core.Constants.STREAM_NAME; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.model; public class FlowInfo { private String flowId; private Event event; private int idx; private String streamName; private String previousStream; private String partition; public FlowInfo(Tuple tuple) {
flowId = tuple.getStringByField(FLOW_ID);
calrissian/flowmix
src/main/java/org/calrissian/flowmix/core/model/FlowInfo.java
// Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String EVENT = "event"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_ID = "flowId"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_OP_IDX = "flowOpIdx"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String LAST_STREAM = "lastStream"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String PARTITION = "partition"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String STREAM_NAME = "streamName";
import backtype.storm.tuple.Tuple; import org.calrissian.mango.domain.event.Event; import static org.calrissian.flowmix.core.Constants.EVENT; import static org.calrissian.flowmix.core.Constants.FLOW_ID; import static org.calrissian.flowmix.core.Constants.FLOW_OP_IDX; import static org.calrissian.flowmix.core.Constants.LAST_STREAM; import static org.calrissian.flowmix.core.Constants.PARTITION; import static org.calrissian.flowmix.core.Constants.STREAM_NAME;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.model; public class FlowInfo { private String flowId; private Event event; private int idx; private String streamName; private String previousStream; private String partition; public FlowInfo(Tuple tuple) { flowId = tuple.getStringByField(FLOW_ID);
// Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String EVENT = "event"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_ID = "flowId"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_OP_IDX = "flowOpIdx"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String LAST_STREAM = "lastStream"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String PARTITION = "partition"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String STREAM_NAME = "streamName"; // Path: src/main/java/org/calrissian/flowmix/core/model/FlowInfo.java import backtype.storm.tuple.Tuple; import org.calrissian.mango.domain.event.Event; import static org.calrissian.flowmix.core.Constants.EVENT; import static org.calrissian.flowmix.core.Constants.FLOW_ID; import static org.calrissian.flowmix.core.Constants.FLOW_OP_IDX; import static org.calrissian.flowmix.core.Constants.LAST_STREAM; import static org.calrissian.flowmix.core.Constants.PARTITION; import static org.calrissian.flowmix.core.Constants.STREAM_NAME; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.model; public class FlowInfo { private String flowId; private Event event; private int idx; private String streamName; private String previousStream; private String partition; public FlowInfo(Tuple tuple) { flowId = tuple.getStringByField(FLOW_ID);
event = (Event) tuple.getValueByField(EVENT);
calrissian/flowmix
src/main/java/org/calrissian/flowmix/core/model/FlowInfo.java
// Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String EVENT = "event"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_ID = "flowId"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_OP_IDX = "flowOpIdx"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String LAST_STREAM = "lastStream"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String PARTITION = "partition"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String STREAM_NAME = "streamName";
import backtype.storm.tuple.Tuple; import org.calrissian.mango.domain.event.Event; import static org.calrissian.flowmix.core.Constants.EVENT; import static org.calrissian.flowmix.core.Constants.FLOW_ID; import static org.calrissian.flowmix.core.Constants.FLOW_OP_IDX; import static org.calrissian.flowmix.core.Constants.LAST_STREAM; import static org.calrissian.flowmix.core.Constants.PARTITION; import static org.calrissian.flowmix.core.Constants.STREAM_NAME;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.model; public class FlowInfo { private String flowId; private Event event; private int idx; private String streamName; private String previousStream; private String partition; public FlowInfo(Tuple tuple) { flowId = tuple.getStringByField(FLOW_ID); event = (Event) tuple.getValueByField(EVENT);
// Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String EVENT = "event"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_ID = "flowId"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_OP_IDX = "flowOpIdx"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String LAST_STREAM = "lastStream"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String PARTITION = "partition"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String STREAM_NAME = "streamName"; // Path: src/main/java/org/calrissian/flowmix/core/model/FlowInfo.java import backtype.storm.tuple.Tuple; import org.calrissian.mango.domain.event.Event; import static org.calrissian.flowmix.core.Constants.EVENT; import static org.calrissian.flowmix.core.Constants.FLOW_ID; import static org.calrissian.flowmix.core.Constants.FLOW_OP_IDX; import static org.calrissian.flowmix.core.Constants.LAST_STREAM; import static org.calrissian.flowmix.core.Constants.PARTITION; import static org.calrissian.flowmix.core.Constants.STREAM_NAME; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.model; public class FlowInfo { private String flowId; private Event event; private int idx; private String streamName; private String previousStream; private String partition; public FlowInfo(Tuple tuple) { flowId = tuple.getStringByField(FLOW_ID); event = (Event) tuple.getValueByField(EVENT);
idx = tuple.getIntegerByField(FLOW_OP_IDX);
calrissian/flowmix
src/main/java/org/calrissian/flowmix/core/model/FlowInfo.java
// Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String EVENT = "event"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_ID = "flowId"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_OP_IDX = "flowOpIdx"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String LAST_STREAM = "lastStream"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String PARTITION = "partition"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String STREAM_NAME = "streamName";
import backtype.storm.tuple.Tuple; import org.calrissian.mango.domain.event.Event; import static org.calrissian.flowmix.core.Constants.EVENT; import static org.calrissian.flowmix.core.Constants.FLOW_ID; import static org.calrissian.flowmix.core.Constants.FLOW_OP_IDX; import static org.calrissian.flowmix.core.Constants.LAST_STREAM; import static org.calrissian.flowmix.core.Constants.PARTITION; import static org.calrissian.flowmix.core.Constants.STREAM_NAME;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.model; public class FlowInfo { private String flowId; private Event event; private int idx; private String streamName; private String previousStream; private String partition; public FlowInfo(Tuple tuple) { flowId = tuple.getStringByField(FLOW_ID); event = (Event) tuple.getValueByField(EVENT); idx = tuple.getIntegerByField(FLOW_OP_IDX); idx++;
// Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String EVENT = "event"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_ID = "flowId"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_OP_IDX = "flowOpIdx"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String LAST_STREAM = "lastStream"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String PARTITION = "partition"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String STREAM_NAME = "streamName"; // Path: src/main/java/org/calrissian/flowmix/core/model/FlowInfo.java import backtype.storm.tuple.Tuple; import org.calrissian.mango.domain.event.Event; import static org.calrissian.flowmix.core.Constants.EVENT; import static org.calrissian.flowmix.core.Constants.FLOW_ID; import static org.calrissian.flowmix.core.Constants.FLOW_OP_IDX; import static org.calrissian.flowmix.core.Constants.LAST_STREAM; import static org.calrissian.flowmix.core.Constants.PARTITION; import static org.calrissian.flowmix.core.Constants.STREAM_NAME; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.model; public class FlowInfo { private String flowId; private Event event; private int idx; private String streamName; private String previousStream; private String partition; public FlowInfo(Tuple tuple) { flowId = tuple.getStringByField(FLOW_ID); event = (Event) tuple.getValueByField(EVENT); idx = tuple.getIntegerByField(FLOW_OP_IDX); idx++;
streamName = tuple.getStringByField(STREAM_NAME);
calrissian/flowmix
src/main/java/org/calrissian/flowmix/core/model/FlowInfo.java
// Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String EVENT = "event"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_ID = "flowId"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_OP_IDX = "flowOpIdx"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String LAST_STREAM = "lastStream"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String PARTITION = "partition"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String STREAM_NAME = "streamName";
import backtype.storm.tuple.Tuple; import org.calrissian.mango.domain.event.Event; import static org.calrissian.flowmix.core.Constants.EVENT; import static org.calrissian.flowmix.core.Constants.FLOW_ID; import static org.calrissian.flowmix.core.Constants.FLOW_OP_IDX; import static org.calrissian.flowmix.core.Constants.LAST_STREAM; import static org.calrissian.flowmix.core.Constants.PARTITION; import static org.calrissian.flowmix.core.Constants.STREAM_NAME;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.model; public class FlowInfo { private String flowId; private Event event; private int idx; private String streamName; private String previousStream; private String partition; public FlowInfo(Tuple tuple) { flowId = tuple.getStringByField(FLOW_ID); event = (Event) tuple.getValueByField(EVENT); idx = tuple.getIntegerByField(FLOW_OP_IDX); idx++; streamName = tuple.getStringByField(STREAM_NAME);
// Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String EVENT = "event"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_ID = "flowId"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_OP_IDX = "flowOpIdx"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String LAST_STREAM = "lastStream"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String PARTITION = "partition"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String STREAM_NAME = "streamName"; // Path: src/main/java/org/calrissian/flowmix/core/model/FlowInfo.java import backtype.storm.tuple.Tuple; import org.calrissian.mango.domain.event.Event; import static org.calrissian.flowmix.core.Constants.EVENT; import static org.calrissian.flowmix.core.Constants.FLOW_ID; import static org.calrissian.flowmix.core.Constants.FLOW_OP_IDX; import static org.calrissian.flowmix.core.Constants.LAST_STREAM; import static org.calrissian.flowmix.core.Constants.PARTITION; import static org.calrissian.flowmix.core.Constants.STREAM_NAME; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.model; public class FlowInfo { private String flowId; private Event event; private int idx; private String streamName; private String previousStream; private String partition; public FlowInfo(Tuple tuple) { flowId = tuple.getStringByField(FLOW_ID); event = (Event) tuple.getValueByField(EVENT); idx = tuple.getIntegerByField(FLOW_OP_IDX); idx++; streamName = tuple.getStringByField(STREAM_NAME);
previousStream = tuple.getStringByField(LAST_STREAM);
calrissian/flowmix
src/main/java/org/calrissian/flowmix/core/model/FlowInfo.java
// Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String EVENT = "event"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_ID = "flowId"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_OP_IDX = "flowOpIdx"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String LAST_STREAM = "lastStream"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String PARTITION = "partition"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String STREAM_NAME = "streamName";
import backtype.storm.tuple.Tuple; import org.calrissian.mango.domain.event.Event; import static org.calrissian.flowmix.core.Constants.EVENT; import static org.calrissian.flowmix.core.Constants.FLOW_ID; import static org.calrissian.flowmix.core.Constants.FLOW_OP_IDX; import static org.calrissian.flowmix.core.Constants.LAST_STREAM; import static org.calrissian.flowmix.core.Constants.PARTITION; import static org.calrissian.flowmix.core.Constants.STREAM_NAME;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.model; public class FlowInfo { private String flowId; private Event event; private int idx; private String streamName; private String previousStream; private String partition; public FlowInfo(Tuple tuple) { flowId = tuple.getStringByField(FLOW_ID); event = (Event) tuple.getValueByField(EVENT); idx = tuple.getIntegerByField(FLOW_OP_IDX); idx++; streamName = tuple.getStringByField(STREAM_NAME); previousStream = tuple.getStringByField(LAST_STREAM);
// Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String EVENT = "event"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_ID = "flowId"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_OP_IDX = "flowOpIdx"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String LAST_STREAM = "lastStream"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String PARTITION = "partition"; // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String STREAM_NAME = "streamName"; // Path: src/main/java/org/calrissian/flowmix/core/model/FlowInfo.java import backtype.storm.tuple.Tuple; import org.calrissian.mango.domain.event.Event; import static org.calrissian.flowmix.core.Constants.EVENT; import static org.calrissian.flowmix.core.Constants.FLOW_ID; import static org.calrissian.flowmix.core.Constants.FLOW_OP_IDX; import static org.calrissian.flowmix.core.Constants.LAST_STREAM; import static org.calrissian.flowmix.core.Constants.PARTITION; import static org.calrissian.flowmix.core.Constants.STREAM_NAME; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.model; public class FlowInfo { private String flowId; private Event event; private int idx; private String streamName; private String previousStream; private String partition; public FlowInfo(Tuple tuple) { flowId = tuple.getStringByField(FLOW_ID); event = (Event) tuple.getValueByField(EVENT); idx = tuple.getIntegerByField(FLOW_OP_IDX); idx++; streamName = tuple.getStringByField(STREAM_NAME); previousStream = tuple.getStringByField(LAST_STREAM);
if(tuple.contains(PARTITION))
calrissian/flowmix
src/main/java/org/calrissian/flowmix/core/support/window/Window.java
// Path: src/main/java/org/calrissian/flowmix/core/support/deque/LimitingDeque.java // public class LimitingDeque<E> extends LinkedBlockingDeque<E> { // // private long maxSize; // // protected long getMaxSize() { // return maxSize; // } // // public LimitingDeque(long maxSize) { // this.maxSize = maxSize; // } // // @Override // public boolean offerFirst(E e) { // if(size() == maxSize) // removeLast(); // // return super.offerFirst(e); // } // // @Override // public boolean offerLast(E e) { // if(size() == maxSize) // removeFirst(); // // return super.offerLast(e); // } // }
import org.calrissian.flowmix.core.support.deque.LimitingDeque; import org.calrissian.mango.domain.event.Event; import java.util.*; import java.util.concurrent.LinkedBlockingDeque; import static java.lang.System.currentTimeMillis; import static org.apache.commons.lang.StringUtils.join;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.support.window; public class Window { protected String groupedIndex; // a unique key given to the groupBy field/value combinations in the window buffer protected Deque<WindowItem> events; // using standard array list for proof of concept. // Circular buffer needs to be used after concept is proven protected int triggerTicks = 0; /** * A progressive window buffer which automatically evicts by count */ public Window(String groupedIndex, long size) { this(groupedIndex);
// Path: src/main/java/org/calrissian/flowmix/core/support/deque/LimitingDeque.java // public class LimitingDeque<E> extends LinkedBlockingDeque<E> { // // private long maxSize; // // protected long getMaxSize() { // return maxSize; // } // // public LimitingDeque(long maxSize) { // this.maxSize = maxSize; // } // // @Override // public boolean offerFirst(E e) { // if(size() == maxSize) // removeLast(); // // return super.offerFirst(e); // } // // @Override // public boolean offerLast(E e) { // if(size() == maxSize) // removeFirst(); // // return super.offerLast(e); // } // } // Path: src/main/java/org/calrissian/flowmix/core/support/window/Window.java import org.calrissian.flowmix.core.support.deque.LimitingDeque; import org.calrissian.mango.domain.event.Event; import java.util.*; import java.util.concurrent.LinkedBlockingDeque; import static java.lang.System.currentTimeMillis; import static org.apache.commons.lang.StringUtils.join; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.support.window; public class Window { protected String groupedIndex; // a unique key given to the groupBy field/value combinations in the window buffer protected Deque<WindowItem> events; // using standard array list for proof of concept. // Circular buffer needs to be used after concept is proven protected int triggerTicks = 0; /** * A progressive window buffer which automatically evicts by count */ public Window(String groupedIndex, long size) { this(groupedIndex);
events = new LimitingDeque<WindowItem>(size);
calrissian/flowmix
src/main/java/org/calrissian/flowmix/core/model/op/FilterOp.java
// Path: src/main/java/org/calrissian/flowmix/api/Filter.java // public interface Filter extends Serializable { // // boolean accept(Event event); // }
import org.calrissian.flowmix.api.Filter;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.model.op; public class FilterOp implements FlowOp { public static final String FILTER = "filter";
// Path: src/main/java/org/calrissian/flowmix/api/Filter.java // public interface Filter extends Serializable { // // boolean accept(Event event); // } // Path: src/main/java/org/calrissian/flowmix/core/model/op/FilterOp.java import org.calrissian.flowmix.api.Filter; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.model.op; public class FilterOp implements FlowOp { public static final String FILTER = "filter";
Filter filter;
calrissian/flowmix
src/main/java/org/calrissian/flowmix/core/model/op/SwitchOp.java
// Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/RequiresPartitioning.java // public interface RequiresPartitioning { // }
import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.RequiresPartitioning;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.model.op; public class SwitchOp implements FlowOp, RequiresPartitioning { public static final String SWITCH = "stopGate";
// Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/RequiresPartitioning.java // public interface RequiresPartitioning { // } // Path: src/main/java/org/calrissian/flowmix/core/model/op/SwitchOp.java import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.RequiresPartitioning; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.model.op; public class SwitchOp implements FlowOp, RequiresPartitioning { public static final String SWITCH = "stopGate";
private Policy openPolicy;
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/storm/bolt/MockSinkBolt.java
// Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String EVENT = "event";
import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Map; import backtype.storm.task.OutputCollector; import backtype.storm.task.TopologyContext; import backtype.storm.topology.OutputFieldsDeclarer; import backtype.storm.topology.base.BaseRichBolt; import backtype.storm.tuple.Tuple; import org.calrissian.mango.domain.event.Event; import static org.calrissian.flowmix.core.Constants.EVENT;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.storm.bolt; /** * A test tool using static methods to collect output. When wired downstream from a bolt, it will * collect the output from that bolt. It's important that the clear() method is called on this * class after a test is run. */ public class MockSinkBolt extends BaseRichBolt{ private static List<Event> eventsReceived = new LinkedList<Event>(); @Override public void prepare(Map map, TopologyContext topologyContext, OutputCollector outputCollector) { } @Override public void execute(Tuple tuple) {
// Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String EVENT = "event"; // Path: src/main/java/org/calrissian/flowmix/api/storm/bolt/MockSinkBolt.java import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Map; import backtype.storm.task.OutputCollector; import backtype.storm.task.TopologyContext; import backtype.storm.topology.OutputFieldsDeclarer; import backtype.storm.topology.base.BaseRichBolt; import backtype.storm.tuple.Tuple; import org.calrissian.mango.domain.event.Event; import static org.calrissian.flowmix.core.Constants.EVENT; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.storm.bolt; /** * A test tool using static methods to collect output. When wired downstream from a bolt, it will * collect the output from that bolt. It's important that the clear() method is called on this * class after a test is run. */ public class MockSinkBolt extends BaseRichBolt{ private static List<Event> eventsReceived = new LinkedList<Event>(); @Override public void prepare(Map map, TopologyContext topologyContext, OutputCollector outputCollector) { } @Override public void execute(Tuple tuple) {
if(tuple.contains(EVENT)) {
calrissian/flowmix
src/main/java/org/calrissian/flowmix/core/model/StreamDef.java
// Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // }
import java.io.Serializable; import java.util.Arrays; import java.util.List; import org.calrissian.flowmix.core.model.op.FlowOp;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.model; public class StreamDef implements Serializable { private String name;
// Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // Path: src/main/java/org/calrissian/flowmix/core/model/StreamDef.java import java.io.Serializable; import java.util.Arrays; import java.util.List; import org.calrissian.flowmix.core.model.op.FlowOp; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.model; public class StreamDef implements Serializable { private String name;
private List<FlowOp> flowOps;
calrissian/flowmix
src/main/java/org/calrissian/flowmix/core/support/window/AggregatorWindow.java
// Path: src/main/java/org/calrissian/flowmix/api/Aggregator.java // public interface Aggregator extends Serializable { // // public static final String GROUP_BY = "groupBy"; // public static final String GROUP_BY_DELIM = "\u0000"; // // void configure(Map<String, String> configuration); // // void added(WindowItem item); // // void evicted(WindowItem item); // // List<AggregatedEvent> aggregate(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/event/AggregatedEvent.java // public class AggregatedEvent { // // private Event event; // private String previousStream; // // public AggregatedEvent(Event event, String previousStream) { // this.event = event; // this.previousStream = previousStream; // } // // public AggregatedEvent(Event event) { // this.event = event; // } // // public Event getEvent() { // return event; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // AggregatedEvent that = (AggregatedEvent) o; // // if (event != null ? !event.equals(that.event) : that.event != null) return false; // if (previousStream != null ? !previousStream.equals(that.previousStream) : that.previousStream != null) // return false; // // return true; // } // // @Override // public int hashCode() { // int result = event != null ? event.hashCode() : 0; // result = 31 * result + (previousStream != null ? previousStream.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "AggregatedEvent{" + // "event=" + event + // ", previousStream='" + previousStream + '\'' + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/support/deque/AggregatorLimitingDeque.java // public class AggregatorLimitingDeque extends LimitingDeque<WindowItem> { // // Aggregator aggregator; // // public AggregatorLimitingDeque(long maxSize, Aggregator aggregator) { // super(maxSize); // this.aggregator = aggregator; // } // // @Override // public boolean offerLast(WindowItem windowItem) { // if(size() == getMaxSize()) // aggregator.evicted(getFirst()); // // return super.offerLast(windowItem); // } // }
import java.util.Collection; import org.calrissian.flowmix.api.Aggregator; import org.calrissian.flowmix.core.model.event.AggregatedEvent; import org.calrissian.flowmix.core.support.deque.AggregatorLimitingDeque; import org.calrissian.mango.domain.event.Event;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.support.window; public class AggregatorWindow extends Window { private Aggregator aggregator; public AggregatorWindow(Aggregator aggregator, String groupedIndex, long size) {
// Path: src/main/java/org/calrissian/flowmix/api/Aggregator.java // public interface Aggregator extends Serializable { // // public static final String GROUP_BY = "groupBy"; // public static final String GROUP_BY_DELIM = "\u0000"; // // void configure(Map<String, String> configuration); // // void added(WindowItem item); // // void evicted(WindowItem item); // // List<AggregatedEvent> aggregate(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/event/AggregatedEvent.java // public class AggregatedEvent { // // private Event event; // private String previousStream; // // public AggregatedEvent(Event event, String previousStream) { // this.event = event; // this.previousStream = previousStream; // } // // public AggregatedEvent(Event event) { // this.event = event; // } // // public Event getEvent() { // return event; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // AggregatedEvent that = (AggregatedEvent) o; // // if (event != null ? !event.equals(that.event) : that.event != null) return false; // if (previousStream != null ? !previousStream.equals(that.previousStream) : that.previousStream != null) // return false; // // return true; // } // // @Override // public int hashCode() { // int result = event != null ? event.hashCode() : 0; // result = 31 * result + (previousStream != null ? previousStream.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "AggregatedEvent{" + // "event=" + event + // ", previousStream='" + previousStream + '\'' + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/support/deque/AggregatorLimitingDeque.java // public class AggregatorLimitingDeque extends LimitingDeque<WindowItem> { // // Aggregator aggregator; // // public AggregatorLimitingDeque(long maxSize, Aggregator aggregator) { // super(maxSize); // this.aggregator = aggregator; // } // // @Override // public boolean offerLast(WindowItem windowItem) { // if(size() == getMaxSize()) // aggregator.evicted(getFirst()); // // return super.offerLast(windowItem); // } // } // Path: src/main/java/org/calrissian/flowmix/core/support/window/AggregatorWindow.java import java.util.Collection; import org.calrissian.flowmix.api.Aggregator; import org.calrissian.flowmix.core.model.event.AggregatedEvent; import org.calrissian.flowmix.core.support.deque.AggregatorLimitingDeque; import org.calrissian.mango.domain.event.Event; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.support.window; public class AggregatorWindow extends Window { private Aggregator aggregator; public AggregatorWindow(Aggregator aggregator, String groupedIndex, long size) {
events = new AggregatorLimitingDeque(size, aggregator);
calrissian/flowmix
src/main/java/org/calrissian/flowmix/core/support/window/AggregatorWindow.java
// Path: src/main/java/org/calrissian/flowmix/api/Aggregator.java // public interface Aggregator extends Serializable { // // public static final String GROUP_BY = "groupBy"; // public static final String GROUP_BY_DELIM = "\u0000"; // // void configure(Map<String, String> configuration); // // void added(WindowItem item); // // void evicted(WindowItem item); // // List<AggregatedEvent> aggregate(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/event/AggregatedEvent.java // public class AggregatedEvent { // // private Event event; // private String previousStream; // // public AggregatedEvent(Event event, String previousStream) { // this.event = event; // this.previousStream = previousStream; // } // // public AggregatedEvent(Event event) { // this.event = event; // } // // public Event getEvent() { // return event; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // AggregatedEvent that = (AggregatedEvent) o; // // if (event != null ? !event.equals(that.event) : that.event != null) return false; // if (previousStream != null ? !previousStream.equals(that.previousStream) : that.previousStream != null) // return false; // // return true; // } // // @Override // public int hashCode() { // int result = event != null ? event.hashCode() : 0; // result = 31 * result + (previousStream != null ? previousStream.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "AggregatedEvent{" + // "event=" + event + // ", previousStream='" + previousStream + '\'' + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/support/deque/AggregatorLimitingDeque.java // public class AggregatorLimitingDeque extends LimitingDeque<WindowItem> { // // Aggregator aggregator; // // public AggregatorLimitingDeque(long maxSize, Aggregator aggregator) { // super(maxSize); // this.aggregator = aggregator; // } // // @Override // public boolean offerLast(WindowItem windowItem) { // if(size() == getMaxSize()) // aggregator.evicted(getFirst()); // // return super.offerLast(windowItem); // } // }
import java.util.Collection; import org.calrissian.flowmix.api.Aggregator; import org.calrissian.flowmix.core.model.event.AggregatedEvent; import org.calrissian.flowmix.core.support.deque.AggregatorLimitingDeque; import org.calrissian.mango.domain.event.Event;
@Override public WindowItem add(Event event, String previousStream) { WindowItem item = super.add(event, previousStream); aggregator.added(item); return item; } @Override public WindowItem expire() { WindowItem item = super.expire(); aggregator.evicted(item); return item; } @Override public void clear() { while(size() > 0) expire(); } /** * Used for age-based expiration */ public void timeEvict(long thresholdInSeconds) { while(events != null && events.peek() != null && (System.currentTimeMillis() - events.peek().getTimestamp()) >= (thresholdInSeconds * 1000)) { WindowItem item = events.poll(); aggregator.evicted(item); } }
// Path: src/main/java/org/calrissian/flowmix/api/Aggregator.java // public interface Aggregator extends Serializable { // // public static final String GROUP_BY = "groupBy"; // public static final String GROUP_BY_DELIM = "\u0000"; // // void configure(Map<String, String> configuration); // // void added(WindowItem item); // // void evicted(WindowItem item); // // List<AggregatedEvent> aggregate(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/event/AggregatedEvent.java // public class AggregatedEvent { // // private Event event; // private String previousStream; // // public AggregatedEvent(Event event, String previousStream) { // this.event = event; // this.previousStream = previousStream; // } // // public AggregatedEvent(Event event) { // this.event = event; // } // // public Event getEvent() { // return event; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // AggregatedEvent that = (AggregatedEvent) o; // // if (event != null ? !event.equals(that.event) : that.event != null) return false; // if (previousStream != null ? !previousStream.equals(that.previousStream) : that.previousStream != null) // return false; // // return true; // } // // @Override // public int hashCode() { // int result = event != null ? event.hashCode() : 0; // result = 31 * result + (previousStream != null ? previousStream.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "AggregatedEvent{" + // "event=" + event + // ", previousStream='" + previousStream + '\'' + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/support/deque/AggregatorLimitingDeque.java // public class AggregatorLimitingDeque extends LimitingDeque<WindowItem> { // // Aggregator aggregator; // // public AggregatorLimitingDeque(long maxSize, Aggregator aggregator) { // super(maxSize); // this.aggregator = aggregator; // } // // @Override // public boolean offerLast(WindowItem windowItem) { // if(size() == getMaxSize()) // aggregator.evicted(getFirst()); // // return super.offerLast(windowItem); // } // } // Path: src/main/java/org/calrissian/flowmix/core/support/window/AggregatorWindow.java import java.util.Collection; import org.calrissian.flowmix.api.Aggregator; import org.calrissian.flowmix.core.model.event.AggregatedEvent; import org.calrissian.flowmix.core.support.deque.AggregatorLimitingDeque; import org.calrissian.mango.domain.event.Event; @Override public WindowItem add(Event event, String previousStream) { WindowItem item = super.add(event, previousStream); aggregator.added(item); return item; } @Override public WindowItem expire() { WindowItem item = super.expire(); aggregator.evicted(item); return item; } @Override public void clear() { while(size() > 0) expire(); } /** * Used for age-based expiration */ public void timeEvict(long thresholdInSeconds) { while(events != null && events.peek() != null && (System.currentTimeMillis() - events.peek().getTimestamp()) >= (thresholdInSeconds * 1000)) { WindowItem item = events.poll(); aggregator.evicted(item); } }
public Collection<AggregatedEvent> getAggregate() {
calrissian/flowmix
src/main/java/org/calrissian/flowmix/core/model/op/JoinOp.java
// Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/RequiresPartitioning.java // public interface RequiresPartitioning { // }
import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.RequiresPartitioning;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.model.op; public class JoinOp implements FlowOp, RequiresPartitioning { public static final String JOIN = "join"; String leftStream; String rightStream;
// Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/RequiresPartitioning.java // public interface RequiresPartitioning { // } // Path: src/main/java/org/calrissian/flowmix/core/model/op/JoinOp.java import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.RequiresPartitioning; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.model.op; public class JoinOp implements FlowOp, RequiresPartitioning { public static final String JOIN = "join"; String leftStream; String rightStream;
Policy evictionPolicy;
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/aggregator/LongSumAggregator.java
// Path: src/main/java/org/calrissian/flowmix/api/Aggregator.java // public interface Aggregator extends Serializable { // // public static final String GROUP_BY = "groupBy"; // public static final String GROUP_BY_DELIM = "\u0000"; // // void configure(Map<String, String> configuration); // // void added(WindowItem item); // // void evicted(WindowItem item); // // List<AggregatedEvent> aggregate(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/event/AggregatedEvent.java // public class AggregatedEvent { // // private Event event; // private String previousStream; // // public AggregatedEvent(Event event, String previousStream) { // this.event = event; // this.previousStream = previousStream; // } // // public AggregatedEvent(Event event) { // this.event = event; // } // // public Event getEvent() { // return event; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // AggregatedEvent that = (AggregatedEvent) o; // // if (event != null ? !event.equals(that.event) : that.event != null) return false; // if (previousStream != null ? !previousStream.equals(that.previousStream) : that.previousStream != null) // return false; // // return true; // } // // @Override // public int hashCode() { // int result = event != null ? event.hashCode() : 0; // result = 31 * result + (previousStream != null ? previousStream.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "AggregatedEvent{" + // "event=" + event + // ", previousStream='" + previousStream + '\'' + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/support/window/WindowItem.java // public class WindowItem { // Event event; // long timestamp; // String previousStream; // // public WindowItem(Event event, long timestamp, String previousStream) { // this.event = event; // this.timestamp = timestamp; // this.previousStream = previousStream; // } // // public Event getEvent() { // return event; // } // // public long getTimestamp() { // return timestamp; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public String toString() { // return "WindowItem{" + // "event=" + event + // ", timestamp=" + timestamp + // '}'; // } // }
import static java.util.UUID.randomUUID; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.commons.lang.StringUtils; import org.calrissian.flowmix.api.Aggregator; import org.calrissian.flowmix.core.model.event.AggregatedEvent; import org.calrissian.flowmix.core.support.window.WindowItem; import org.calrissian.mango.domain.Tuple; import org.calrissian.mango.domain.event.BaseEvent; import org.calrissian.mango.domain.event.Event; import static java.lang.System.currentTimeMillis;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.aggregator; @Deprecated public class LongSumAggregator implements Aggregator { public static final String SUM_FIELD = "sumField"; public static final String OUTPUT_FIELD = "outputField"; public static final String DEFAULT_OUTPUT_FIELD = "sum"; protected String sumField; protected String outputField = DEFAULT_OUTPUT_FIELD; protected Map<String,Collection<Tuple>> groupedValues; protected String[] groupByFields; protected long sum = 0; @Override public void configure(Map<String, String> configuration) { if(configuration.get(GROUP_BY) != null) groupByFields = StringUtils.splitPreserveAllTokens(configuration.get(GROUP_BY), GROUP_BY_DELIM); if(configuration.get(OUTPUT_FIELD) != null) outputField = configuration.get(OUTPUT_FIELD); if(configuration.get(SUM_FIELD) != null) sumField = configuration.get(SUM_FIELD); else throw new RuntimeException("Sum aggregator needs a field to sum. Property missing: " + SUM_FIELD); } @Override
// Path: src/main/java/org/calrissian/flowmix/api/Aggregator.java // public interface Aggregator extends Serializable { // // public static final String GROUP_BY = "groupBy"; // public static final String GROUP_BY_DELIM = "\u0000"; // // void configure(Map<String, String> configuration); // // void added(WindowItem item); // // void evicted(WindowItem item); // // List<AggregatedEvent> aggregate(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/event/AggregatedEvent.java // public class AggregatedEvent { // // private Event event; // private String previousStream; // // public AggregatedEvent(Event event, String previousStream) { // this.event = event; // this.previousStream = previousStream; // } // // public AggregatedEvent(Event event) { // this.event = event; // } // // public Event getEvent() { // return event; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // AggregatedEvent that = (AggregatedEvent) o; // // if (event != null ? !event.equals(that.event) : that.event != null) return false; // if (previousStream != null ? !previousStream.equals(that.previousStream) : that.previousStream != null) // return false; // // return true; // } // // @Override // public int hashCode() { // int result = event != null ? event.hashCode() : 0; // result = 31 * result + (previousStream != null ? previousStream.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "AggregatedEvent{" + // "event=" + event + // ", previousStream='" + previousStream + '\'' + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/support/window/WindowItem.java // public class WindowItem { // Event event; // long timestamp; // String previousStream; // // public WindowItem(Event event, long timestamp, String previousStream) { // this.event = event; // this.timestamp = timestamp; // this.previousStream = previousStream; // } // // public Event getEvent() { // return event; // } // // public long getTimestamp() { // return timestamp; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public String toString() { // return "WindowItem{" + // "event=" + event + // ", timestamp=" + timestamp + // '}'; // } // } // Path: src/main/java/org/calrissian/flowmix/api/aggregator/LongSumAggregator.java import static java.util.UUID.randomUUID; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.commons.lang.StringUtils; import org.calrissian.flowmix.api.Aggregator; import org.calrissian.flowmix.core.model.event.AggregatedEvent; import org.calrissian.flowmix.core.support.window.WindowItem; import org.calrissian.mango.domain.Tuple; import org.calrissian.mango.domain.event.BaseEvent; import org.calrissian.mango.domain.event.Event; import static java.lang.System.currentTimeMillis; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.aggregator; @Deprecated public class LongSumAggregator implements Aggregator { public static final String SUM_FIELD = "sumField"; public static final String OUTPUT_FIELD = "outputField"; public static final String DEFAULT_OUTPUT_FIELD = "sum"; protected String sumField; protected String outputField = DEFAULT_OUTPUT_FIELD; protected Map<String,Collection<Tuple>> groupedValues; protected String[] groupByFields; protected long sum = 0; @Override public void configure(Map<String, String> configuration) { if(configuration.get(GROUP_BY) != null) groupByFields = StringUtils.splitPreserveAllTokens(configuration.get(GROUP_BY), GROUP_BY_DELIM); if(configuration.get(OUTPUT_FIELD) != null) outputField = configuration.get(OUTPUT_FIELD); if(configuration.get(SUM_FIELD) != null) sumField = configuration.get(SUM_FIELD); else throw new RuntimeException("Sum aggregator needs a field to sum. Property missing: " + SUM_FIELD); } @Override
public void added(WindowItem item) {
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/aggregator/LongSumAggregator.java
// Path: src/main/java/org/calrissian/flowmix/api/Aggregator.java // public interface Aggregator extends Serializable { // // public static final String GROUP_BY = "groupBy"; // public static final String GROUP_BY_DELIM = "\u0000"; // // void configure(Map<String, String> configuration); // // void added(WindowItem item); // // void evicted(WindowItem item); // // List<AggregatedEvent> aggregate(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/event/AggregatedEvent.java // public class AggregatedEvent { // // private Event event; // private String previousStream; // // public AggregatedEvent(Event event, String previousStream) { // this.event = event; // this.previousStream = previousStream; // } // // public AggregatedEvent(Event event) { // this.event = event; // } // // public Event getEvent() { // return event; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // AggregatedEvent that = (AggregatedEvent) o; // // if (event != null ? !event.equals(that.event) : that.event != null) return false; // if (previousStream != null ? !previousStream.equals(that.previousStream) : that.previousStream != null) // return false; // // return true; // } // // @Override // public int hashCode() { // int result = event != null ? event.hashCode() : 0; // result = 31 * result + (previousStream != null ? previousStream.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "AggregatedEvent{" + // "event=" + event + // ", previousStream='" + previousStream + '\'' + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/support/window/WindowItem.java // public class WindowItem { // Event event; // long timestamp; // String previousStream; // // public WindowItem(Event event, long timestamp, String previousStream) { // this.event = event; // this.timestamp = timestamp; // this.previousStream = previousStream; // } // // public Event getEvent() { // return event; // } // // public long getTimestamp() { // return timestamp; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public String toString() { // return "WindowItem{" + // "event=" + event + // ", timestamp=" + timestamp + // '}'; // } // }
import static java.util.UUID.randomUUID; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.commons.lang.StringUtils; import org.calrissian.flowmix.api.Aggregator; import org.calrissian.flowmix.core.model.event.AggregatedEvent; import org.calrissian.flowmix.core.support.window.WindowItem; import org.calrissian.mango.domain.Tuple; import org.calrissian.mango.domain.event.BaseEvent; import org.calrissian.mango.domain.event.Event; import static java.lang.System.currentTimeMillis;
if(configuration.get(OUTPUT_FIELD) != null) outputField = configuration.get(OUTPUT_FIELD); if(configuration.get(SUM_FIELD) != null) sumField = configuration.get(SUM_FIELD); else throw new RuntimeException("Sum aggregator needs a field to sum. Property missing: " + SUM_FIELD); } @Override public void added(WindowItem item) { if(groupedValues == null && groupByFields != null) { groupedValues = new HashMap<String, Collection<Tuple>>(); for(String group : groupByFields) groupedValues.put(group, item.getEvent().getAll(group)); } if(item.getEvent().get(sumField) != null) sum += ((Long)item.getEvent().get(sumField).getValue()); } @Override public void evicted(WindowItem item) { if(item.getEvent().get(sumField) != null) sum -= ((Long)item.getEvent().get(sumField).getValue()); } @Override
// Path: src/main/java/org/calrissian/flowmix/api/Aggregator.java // public interface Aggregator extends Serializable { // // public static final String GROUP_BY = "groupBy"; // public static final String GROUP_BY_DELIM = "\u0000"; // // void configure(Map<String, String> configuration); // // void added(WindowItem item); // // void evicted(WindowItem item); // // List<AggregatedEvent> aggregate(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/event/AggregatedEvent.java // public class AggregatedEvent { // // private Event event; // private String previousStream; // // public AggregatedEvent(Event event, String previousStream) { // this.event = event; // this.previousStream = previousStream; // } // // public AggregatedEvent(Event event) { // this.event = event; // } // // public Event getEvent() { // return event; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // AggregatedEvent that = (AggregatedEvent) o; // // if (event != null ? !event.equals(that.event) : that.event != null) return false; // if (previousStream != null ? !previousStream.equals(that.previousStream) : that.previousStream != null) // return false; // // return true; // } // // @Override // public int hashCode() { // int result = event != null ? event.hashCode() : 0; // result = 31 * result + (previousStream != null ? previousStream.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "AggregatedEvent{" + // "event=" + event + // ", previousStream='" + previousStream + '\'' + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/support/window/WindowItem.java // public class WindowItem { // Event event; // long timestamp; // String previousStream; // // public WindowItem(Event event, long timestamp, String previousStream) { // this.event = event; // this.timestamp = timestamp; // this.previousStream = previousStream; // } // // public Event getEvent() { // return event; // } // // public long getTimestamp() { // return timestamp; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public String toString() { // return "WindowItem{" + // "event=" + event + // ", timestamp=" + timestamp + // '}'; // } // } // Path: src/main/java/org/calrissian/flowmix/api/aggregator/LongSumAggregator.java import static java.util.UUID.randomUUID; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.commons.lang.StringUtils; import org.calrissian.flowmix.api.Aggregator; import org.calrissian.flowmix.core.model.event.AggregatedEvent; import org.calrissian.flowmix.core.support.window.WindowItem; import org.calrissian.mango.domain.Tuple; import org.calrissian.mango.domain.event.BaseEvent; import org.calrissian.mango.domain.event.Event; import static java.lang.System.currentTimeMillis; if(configuration.get(OUTPUT_FIELD) != null) outputField = configuration.get(OUTPUT_FIELD); if(configuration.get(SUM_FIELD) != null) sumField = configuration.get(SUM_FIELD); else throw new RuntimeException("Sum aggregator needs a field to sum. Property missing: " + SUM_FIELD); } @Override public void added(WindowItem item) { if(groupedValues == null && groupByFields != null) { groupedValues = new HashMap<String, Collection<Tuple>>(); for(String group : groupByFields) groupedValues.put(group, item.getEvent().getAll(group)); } if(item.getEvent().get(sumField) != null) sum += ((Long)item.getEvent().get(sumField).getValue()); } @Override public void evicted(WindowItem item) { if(item.getEvent().get(sumField) != null) sum -= ((Long)item.getEvent().get(sumField).getValue()); } @Override
public List<AggregatedEvent> aggregate() {
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/builder/SortBuilder.java
// Path: src/main/java/org/calrissian/flowmix/api/Order.java // public enum Order { // // ASC, DESC // } // // Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/SortOp.java // public class SortOp implements FlowOp, RequiresPartitioning { // // public static final String SORT = "sort"; // // private List<Pair<String, Order>> sortBy; // private boolean clearOnTrigger = false; // this determines whether or or not the dataset is sorted all the time // private Policy evictionPolicy; // private long evictionThreshold; // private Policy triggerPolicy; // private long triggerThreshold; // private boolean progressive; // // public SortOp(List<Pair<String,Order>> sortBy, boolean clearOnTrigger, Policy evictionPolicy, long evictionThreshold, Policy triggerPolicy, long triggerThreshold, boolean progressive) { // this.sortBy = sortBy; // this.clearOnTrigger = clearOnTrigger; // this.evictionPolicy = evictionPolicy; // this.evictionThreshold = evictionThreshold; // this.triggerPolicy = triggerPolicy; // this.triggerThreshold = triggerThreshold; // this.progressive = progressive; // } // // // public boolean isProgressive() { // return progressive; // } // // public List<Pair<String,Order>> getSortBy() { // return sortBy; // } // // public boolean isClearOnTrigger() { // return clearOnTrigger; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // public Policy getTriggerPolicy() { // return triggerPolicy; // } // // public long getTriggerThreshold() { // return triggerThreshold; // } // // // @Override // public boolean equals(Object o) { // // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // SortOp sortOp = (SortOp) o; // // if (clearOnTrigger != sortOp.clearOnTrigger) return false; // if (evictionThreshold != sortOp.evictionThreshold) return false; // if (triggerThreshold != sortOp.triggerThreshold) return false; // if (evictionPolicy != sortOp.evictionPolicy) return false; // if (sortBy != null ? !sortBy.equals(sortOp.sortBy) : sortOp.sortBy != null) return false; // if (triggerPolicy != sortOp.triggerPolicy) return false; // // return true; // } // // @Override // public int hashCode() { // int result = sortBy != null ? sortBy.hashCode() : 0; // result = 31 * result + (clearOnTrigger ? 1 : 0); // result = 31 * result + (evictionPolicy != null ? evictionPolicy.hashCode() : 0); // result = 31 * result + (int) (evictionThreshold ^ (evictionThreshold >>> 32)); // result = 31 * result + (triggerPolicy != null ? triggerPolicy.hashCode() : 0); // result = 31 * result + (int) (triggerThreshold ^ (triggerThreshold >>> 32)); // return result; // } // // @Override // public String toString() { // return "SortOp{" + // "sortBy=" + sortBy + // ", clearOnTrigger=" + clearOnTrigger + // ", evictionPolicy=" + evictionPolicy + // ", evictionThreshold=" + evictionThreshold + // ", triggerPolicy=" + triggerPolicy + // ", triggerThreshold=" + triggerThreshold + // '}'; // } // // @Override // public String getComponentName() { // return SORT; // } // }
import java.util.ArrayList; import java.util.List; import org.calrissian.flowmix.api.Order; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import org.calrissian.flowmix.core.model.op.SortOp; import org.calrissian.mango.domain.Pair; import static java.util.Collections.EMPTY_LIST;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.builder; public class SortBuilder extends AbstractOpBuilder { private List<Pair<String,Order>> sortBy = new ArrayList<Pair<String, Order>>();
// Path: src/main/java/org/calrissian/flowmix/api/Order.java // public enum Order { // // ASC, DESC // } // // Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/SortOp.java // public class SortOp implements FlowOp, RequiresPartitioning { // // public static final String SORT = "sort"; // // private List<Pair<String, Order>> sortBy; // private boolean clearOnTrigger = false; // this determines whether or or not the dataset is sorted all the time // private Policy evictionPolicy; // private long evictionThreshold; // private Policy triggerPolicy; // private long triggerThreshold; // private boolean progressive; // // public SortOp(List<Pair<String,Order>> sortBy, boolean clearOnTrigger, Policy evictionPolicy, long evictionThreshold, Policy triggerPolicy, long triggerThreshold, boolean progressive) { // this.sortBy = sortBy; // this.clearOnTrigger = clearOnTrigger; // this.evictionPolicy = evictionPolicy; // this.evictionThreshold = evictionThreshold; // this.triggerPolicy = triggerPolicy; // this.triggerThreshold = triggerThreshold; // this.progressive = progressive; // } // // // public boolean isProgressive() { // return progressive; // } // // public List<Pair<String,Order>> getSortBy() { // return sortBy; // } // // public boolean isClearOnTrigger() { // return clearOnTrigger; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // public Policy getTriggerPolicy() { // return triggerPolicy; // } // // public long getTriggerThreshold() { // return triggerThreshold; // } // // // @Override // public boolean equals(Object o) { // // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // SortOp sortOp = (SortOp) o; // // if (clearOnTrigger != sortOp.clearOnTrigger) return false; // if (evictionThreshold != sortOp.evictionThreshold) return false; // if (triggerThreshold != sortOp.triggerThreshold) return false; // if (evictionPolicy != sortOp.evictionPolicy) return false; // if (sortBy != null ? !sortBy.equals(sortOp.sortBy) : sortOp.sortBy != null) return false; // if (triggerPolicy != sortOp.triggerPolicy) return false; // // return true; // } // // @Override // public int hashCode() { // int result = sortBy != null ? sortBy.hashCode() : 0; // result = 31 * result + (clearOnTrigger ? 1 : 0); // result = 31 * result + (evictionPolicy != null ? evictionPolicy.hashCode() : 0); // result = 31 * result + (int) (evictionThreshold ^ (evictionThreshold >>> 32)); // result = 31 * result + (triggerPolicy != null ? triggerPolicy.hashCode() : 0); // result = 31 * result + (int) (triggerThreshold ^ (triggerThreshold >>> 32)); // return result; // } // // @Override // public String toString() { // return "SortOp{" + // "sortBy=" + sortBy + // ", clearOnTrigger=" + clearOnTrigger + // ", evictionPolicy=" + evictionPolicy + // ", evictionThreshold=" + evictionThreshold + // ", triggerPolicy=" + triggerPolicy + // ", triggerThreshold=" + triggerThreshold + // '}'; // } // // @Override // public String getComponentName() { // return SORT; // } // } // Path: src/main/java/org/calrissian/flowmix/api/builder/SortBuilder.java import java.util.ArrayList; import java.util.List; import org.calrissian.flowmix.api.Order; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import org.calrissian.flowmix.core.model.op.SortOp; import org.calrissian.mango.domain.Pair; import static java.util.Collections.EMPTY_LIST; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.builder; public class SortBuilder extends AbstractOpBuilder { private List<Pair<String,Order>> sortBy = new ArrayList<Pair<String, Order>>();
private Policy evictionPolicy;
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/builder/SortBuilder.java
// Path: src/main/java/org/calrissian/flowmix/api/Order.java // public enum Order { // // ASC, DESC // } // // Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/SortOp.java // public class SortOp implements FlowOp, RequiresPartitioning { // // public static final String SORT = "sort"; // // private List<Pair<String, Order>> sortBy; // private boolean clearOnTrigger = false; // this determines whether or or not the dataset is sorted all the time // private Policy evictionPolicy; // private long evictionThreshold; // private Policy triggerPolicy; // private long triggerThreshold; // private boolean progressive; // // public SortOp(List<Pair<String,Order>> sortBy, boolean clearOnTrigger, Policy evictionPolicy, long evictionThreshold, Policy triggerPolicy, long triggerThreshold, boolean progressive) { // this.sortBy = sortBy; // this.clearOnTrigger = clearOnTrigger; // this.evictionPolicy = evictionPolicy; // this.evictionThreshold = evictionThreshold; // this.triggerPolicy = triggerPolicy; // this.triggerThreshold = triggerThreshold; // this.progressive = progressive; // } // // // public boolean isProgressive() { // return progressive; // } // // public List<Pair<String,Order>> getSortBy() { // return sortBy; // } // // public boolean isClearOnTrigger() { // return clearOnTrigger; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // public Policy getTriggerPolicy() { // return triggerPolicy; // } // // public long getTriggerThreshold() { // return triggerThreshold; // } // // // @Override // public boolean equals(Object o) { // // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // SortOp sortOp = (SortOp) o; // // if (clearOnTrigger != sortOp.clearOnTrigger) return false; // if (evictionThreshold != sortOp.evictionThreshold) return false; // if (triggerThreshold != sortOp.triggerThreshold) return false; // if (evictionPolicy != sortOp.evictionPolicy) return false; // if (sortBy != null ? !sortBy.equals(sortOp.sortBy) : sortOp.sortBy != null) return false; // if (triggerPolicy != sortOp.triggerPolicy) return false; // // return true; // } // // @Override // public int hashCode() { // int result = sortBy != null ? sortBy.hashCode() : 0; // result = 31 * result + (clearOnTrigger ? 1 : 0); // result = 31 * result + (evictionPolicy != null ? evictionPolicy.hashCode() : 0); // result = 31 * result + (int) (evictionThreshold ^ (evictionThreshold >>> 32)); // result = 31 * result + (triggerPolicy != null ? triggerPolicy.hashCode() : 0); // result = 31 * result + (int) (triggerThreshold ^ (triggerThreshold >>> 32)); // return result; // } // // @Override // public String toString() { // return "SortOp{" + // "sortBy=" + sortBy + // ", clearOnTrigger=" + clearOnTrigger + // ", evictionPolicy=" + evictionPolicy + // ", evictionThreshold=" + evictionThreshold + // ", triggerPolicy=" + triggerPolicy + // ", triggerThreshold=" + triggerThreshold + // '}'; // } // // @Override // public String getComponentName() { // return SORT; // } // }
import java.util.ArrayList; import java.util.List; import org.calrissian.flowmix.api.Order; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import org.calrissian.flowmix.core.model.op.SortOp; import org.calrissian.mango.domain.Pair; import static java.util.Collections.EMPTY_LIST;
public SortBuilder tumbling(Policy policy, long threshold) { clearOnTrigger = true; triggerPolicy = policy; triggerThreshold = threshold; evictionPolicy = null; evictionThreshold = -1; return this; } public SortBuilder topN(int n, Policy triggerPolicy, long triggerThreshold, boolean flushOnTrigger) { evictionPolicy = Policy.COUNT; evictionThreshold = n; this.triggerPolicy = triggerPolicy; this.triggerThreshold = triggerThreshold; this.clearOnTrigger = flushOnTrigger; return this; } @Override public StreamBuilder end() { if(sortBy.size() == 0) throw new RuntimeException("Sort operator needs at least one field name to sort by"); if(clearOnTrigger == false && (evictionPolicy == null || evictionThreshold == -1)) throw new RuntimeException("Sort operator needs an eviction policy and threshold"); if(triggerPolicy == null || triggerThreshold == -1) throw new RuntimeException("Sort operator needs a trigger policy and threshold");
// Path: src/main/java/org/calrissian/flowmix/api/Order.java // public enum Order { // // ASC, DESC // } // // Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/SortOp.java // public class SortOp implements FlowOp, RequiresPartitioning { // // public static final String SORT = "sort"; // // private List<Pair<String, Order>> sortBy; // private boolean clearOnTrigger = false; // this determines whether or or not the dataset is sorted all the time // private Policy evictionPolicy; // private long evictionThreshold; // private Policy triggerPolicy; // private long triggerThreshold; // private boolean progressive; // // public SortOp(List<Pair<String,Order>> sortBy, boolean clearOnTrigger, Policy evictionPolicy, long evictionThreshold, Policy triggerPolicy, long triggerThreshold, boolean progressive) { // this.sortBy = sortBy; // this.clearOnTrigger = clearOnTrigger; // this.evictionPolicy = evictionPolicy; // this.evictionThreshold = evictionThreshold; // this.triggerPolicy = triggerPolicy; // this.triggerThreshold = triggerThreshold; // this.progressive = progressive; // } // // // public boolean isProgressive() { // return progressive; // } // // public List<Pair<String,Order>> getSortBy() { // return sortBy; // } // // public boolean isClearOnTrigger() { // return clearOnTrigger; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // public Policy getTriggerPolicy() { // return triggerPolicy; // } // // public long getTriggerThreshold() { // return triggerThreshold; // } // // // @Override // public boolean equals(Object o) { // // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // SortOp sortOp = (SortOp) o; // // if (clearOnTrigger != sortOp.clearOnTrigger) return false; // if (evictionThreshold != sortOp.evictionThreshold) return false; // if (triggerThreshold != sortOp.triggerThreshold) return false; // if (evictionPolicy != sortOp.evictionPolicy) return false; // if (sortBy != null ? !sortBy.equals(sortOp.sortBy) : sortOp.sortBy != null) return false; // if (triggerPolicy != sortOp.triggerPolicy) return false; // // return true; // } // // @Override // public int hashCode() { // int result = sortBy != null ? sortBy.hashCode() : 0; // result = 31 * result + (clearOnTrigger ? 1 : 0); // result = 31 * result + (evictionPolicy != null ? evictionPolicy.hashCode() : 0); // result = 31 * result + (int) (evictionThreshold ^ (evictionThreshold >>> 32)); // result = 31 * result + (triggerPolicy != null ? triggerPolicy.hashCode() : 0); // result = 31 * result + (int) (triggerThreshold ^ (triggerThreshold >>> 32)); // return result; // } // // @Override // public String toString() { // return "SortOp{" + // "sortBy=" + sortBy + // ", clearOnTrigger=" + clearOnTrigger + // ", evictionPolicy=" + evictionPolicy + // ", evictionThreshold=" + evictionThreshold + // ", triggerPolicy=" + triggerPolicy + // ", triggerThreshold=" + triggerThreshold + // '}'; // } // // @Override // public String getComponentName() { // return SORT; // } // } // Path: src/main/java/org/calrissian/flowmix/api/builder/SortBuilder.java import java.util.ArrayList; import java.util.List; import org.calrissian.flowmix.api.Order; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import org.calrissian.flowmix.core.model.op.SortOp; import org.calrissian.mango.domain.Pair; import static java.util.Collections.EMPTY_LIST; public SortBuilder tumbling(Policy policy, long threshold) { clearOnTrigger = true; triggerPolicy = policy; triggerThreshold = threshold; evictionPolicy = null; evictionThreshold = -1; return this; } public SortBuilder topN(int n, Policy triggerPolicy, long triggerThreshold, boolean flushOnTrigger) { evictionPolicy = Policy.COUNT; evictionThreshold = n; this.triggerPolicy = triggerPolicy; this.triggerThreshold = triggerThreshold; this.clearOnTrigger = flushOnTrigger; return this; } @Override public StreamBuilder end() { if(sortBy.size() == 0) throw new RuntimeException("Sort operator needs at least one field name to sort by"); if(clearOnTrigger == false && (evictionPolicy == null || evictionThreshold == -1)) throw new RuntimeException("Sort operator needs an eviction policy and threshold"); if(triggerPolicy == null || triggerThreshold == -1) throw new RuntimeException("Sort operator needs a trigger policy and threshold");
List<FlowOp> flowOpList = getStreamBuilder().getFlowOpList();
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/builder/SortBuilder.java
// Path: src/main/java/org/calrissian/flowmix/api/Order.java // public enum Order { // // ASC, DESC // } // // Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/SortOp.java // public class SortOp implements FlowOp, RequiresPartitioning { // // public static final String SORT = "sort"; // // private List<Pair<String, Order>> sortBy; // private boolean clearOnTrigger = false; // this determines whether or or not the dataset is sorted all the time // private Policy evictionPolicy; // private long evictionThreshold; // private Policy triggerPolicy; // private long triggerThreshold; // private boolean progressive; // // public SortOp(List<Pair<String,Order>> sortBy, boolean clearOnTrigger, Policy evictionPolicy, long evictionThreshold, Policy triggerPolicy, long triggerThreshold, boolean progressive) { // this.sortBy = sortBy; // this.clearOnTrigger = clearOnTrigger; // this.evictionPolicy = evictionPolicy; // this.evictionThreshold = evictionThreshold; // this.triggerPolicy = triggerPolicy; // this.triggerThreshold = triggerThreshold; // this.progressive = progressive; // } // // // public boolean isProgressive() { // return progressive; // } // // public List<Pair<String,Order>> getSortBy() { // return sortBy; // } // // public boolean isClearOnTrigger() { // return clearOnTrigger; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // public Policy getTriggerPolicy() { // return triggerPolicy; // } // // public long getTriggerThreshold() { // return triggerThreshold; // } // // // @Override // public boolean equals(Object o) { // // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // SortOp sortOp = (SortOp) o; // // if (clearOnTrigger != sortOp.clearOnTrigger) return false; // if (evictionThreshold != sortOp.evictionThreshold) return false; // if (triggerThreshold != sortOp.triggerThreshold) return false; // if (evictionPolicy != sortOp.evictionPolicy) return false; // if (sortBy != null ? !sortBy.equals(sortOp.sortBy) : sortOp.sortBy != null) return false; // if (triggerPolicy != sortOp.triggerPolicy) return false; // // return true; // } // // @Override // public int hashCode() { // int result = sortBy != null ? sortBy.hashCode() : 0; // result = 31 * result + (clearOnTrigger ? 1 : 0); // result = 31 * result + (evictionPolicy != null ? evictionPolicy.hashCode() : 0); // result = 31 * result + (int) (evictionThreshold ^ (evictionThreshold >>> 32)); // result = 31 * result + (triggerPolicy != null ? triggerPolicy.hashCode() : 0); // result = 31 * result + (int) (triggerThreshold ^ (triggerThreshold >>> 32)); // return result; // } // // @Override // public String toString() { // return "SortOp{" + // "sortBy=" + sortBy + // ", clearOnTrigger=" + clearOnTrigger + // ", evictionPolicy=" + evictionPolicy + // ", evictionThreshold=" + evictionThreshold + // ", triggerPolicy=" + triggerPolicy + // ", triggerThreshold=" + triggerThreshold + // '}'; // } // // @Override // public String getComponentName() { // return SORT; // } // }
import java.util.ArrayList; import java.util.List; import org.calrissian.flowmix.api.Order; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import org.calrissian.flowmix.core.model.op.SortOp; import org.calrissian.mango.domain.Pair; import static java.util.Collections.EMPTY_LIST;
triggerPolicy = policy; triggerThreshold = threshold; evictionPolicy = null; evictionThreshold = -1; return this; } public SortBuilder topN(int n, Policy triggerPolicy, long triggerThreshold, boolean flushOnTrigger) { evictionPolicy = Policy.COUNT; evictionThreshold = n; this.triggerPolicy = triggerPolicy; this.triggerThreshold = triggerThreshold; this.clearOnTrigger = flushOnTrigger; return this; } @Override public StreamBuilder end() { if(sortBy.size() == 0) throw new RuntimeException("Sort operator needs at least one field name to sort by"); if(clearOnTrigger == false && (evictionPolicy == null || evictionThreshold == -1)) throw new RuntimeException("Sort operator needs an eviction policy and threshold"); if(triggerPolicy == null || triggerThreshold == -1) throw new RuntimeException("Sort operator needs a trigger policy and threshold"); List<FlowOp> flowOpList = getStreamBuilder().getFlowOpList(); FlowOp op = flowOpList.size() == 0 ? null : flowOpList.get(flowOpList.size()-1);
// Path: src/main/java/org/calrissian/flowmix/api/Order.java // public enum Order { // // ASC, DESC // } // // Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/SortOp.java // public class SortOp implements FlowOp, RequiresPartitioning { // // public static final String SORT = "sort"; // // private List<Pair<String, Order>> sortBy; // private boolean clearOnTrigger = false; // this determines whether or or not the dataset is sorted all the time // private Policy evictionPolicy; // private long evictionThreshold; // private Policy triggerPolicy; // private long triggerThreshold; // private boolean progressive; // // public SortOp(List<Pair<String,Order>> sortBy, boolean clearOnTrigger, Policy evictionPolicy, long evictionThreshold, Policy triggerPolicy, long triggerThreshold, boolean progressive) { // this.sortBy = sortBy; // this.clearOnTrigger = clearOnTrigger; // this.evictionPolicy = evictionPolicy; // this.evictionThreshold = evictionThreshold; // this.triggerPolicy = triggerPolicy; // this.triggerThreshold = triggerThreshold; // this.progressive = progressive; // } // // // public boolean isProgressive() { // return progressive; // } // // public List<Pair<String,Order>> getSortBy() { // return sortBy; // } // // public boolean isClearOnTrigger() { // return clearOnTrigger; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // public Policy getTriggerPolicy() { // return triggerPolicy; // } // // public long getTriggerThreshold() { // return triggerThreshold; // } // // // @Override // public boolean equals(Object o) { // // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // SortOp sortOp = (SortOp) o; // // if (clearOnTrigger != sortOp.clearOnTrigger) return false; // if (evictionThreshold != sortOp.evictionThreshold) return false; // if (triggerThreshold != sortOp.triggerThreshold) return false; // if (evictionPolicy != sortOp.evictionPolicy) return false; // if (sortBy != null ? !sortBy.equals(sortOp.sortBy) : sortOp.sortBy != null) return false; // if (triggerPolicy != sortOp.triggerPolicy) return false; // // return true; // } // // @Override // public int hashCode() { // int result = sortBy != null ? sortBy.hashCode() : 0; // result = 31 * result + (clearOnTrigger ? 1 : 0); // result = 31 * result + (evictionPolicy != null ? evictionPolicy.hashCode() : 0); // result = 31 * result + (int) (evictionThreshold ^ (evictionThreshold >>> 32)); // result = 31 * result + (triggerPolicy != null ? triggerPolicy.hashCode() : 0); // result = 31 * result + (int) (triggerThreshold ^ (triggerThreshold >>> 32)); // return result; // } // // @Override // public String toString() { // return "SortOp{" + // "sortBy=" + sortBy + // ", clearOnTrigger=" + clearOnTrigger + // ", evictionPolicy=" + evictionPolicy + // ", evictionThreshold=" + evictionThreshold + // ", triggerPolicy=" + triggerPolicy + // ", triggerThreshold=" + triggerThreshold + // '}'; // } // // @Override // public String getComponentName() { // return SORT; // } // } // Path: src/main/java/org/calrissian/flowmix/api/builder/SortBuilder.java import java.util.ArrayList; import java.util.List; import org.calrissian.flowmix.api.Order; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import org.calrissian.flowmix.core.model.op.SortOp; import org.calrissian.mango.domain.Pair; import static java.util.Collections.EMPTY_LIST; triggerPolicy = policy; triggerThreshold = threshold; evictionPolicy = null; evictionThreshold = -1; return this; } public SortBuilder topN(int n, Policy triggerPolicy, long triggerThreshold, boolean flushOnTrigger) { evictionPolicy = Policy.COUNT; evictionThreshold = n; this.triggerPolicy = triggerPolicy; this.triggerThreshold = triggerThreshold; this.clearOnTrigger = flushOnTrigger; return this; } @Override public StreamBuilder end() { if(sortBy.size() == 0) throw new RuntimeException("Sort operator needs at least one field name to sort by"); if(clearOnTrigger == false && (evictionPolicy == null || evictionThreshold == -1)) throw new RuntimeException("Sort operator needs an eviction policy and threshold"); if(triggerPolicy == null || triggerThreshold == -1) throw new RuntimeException("Sort operator needs a trigger policy and threshold"); List<FlowOp> flowOpList = getStreamBuilder().getFlowOpList(); FlowOp op = flowOpList.size() == 0 ? null : flowOpList.get(flowOpList.size()-1);
if(op == null || !(op instanceof PartitionOp))
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/builder/SortBuilder.java
// Path: src/main/java/org/calrissian/flowmix/api/Order.java // public enum Order { // // ASC, DESC // } // // Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/SortOp.java // public class SortOp implements FlowOp, RequiresPartitioning { // // public static final String SORT = "sort"; // // private List<Pair<String, Order>> sortBy; // private boolean clearOnTrigger = false; // this determines whether or or not the dataset is sorted all the time // private Policy evictionPolicy; // private long evictionThreshold; // private Policy triggerPolicy; // private long triggerThreshold; // private boolean progressive; // // public SortOp(List<Pair<String,Order>> sortBy, boolean clearOnTrigger, Policy evictionPolicy, long evictionThreshold, Policy triggerPolicy, long triggerThreshold, boolean progressive) { // this.sortBy = sortBy; // this.clearOnTrigger = clearOnTrigger; // this.evictionPolicy = evictionPolicy; // this.evictionThreshold = evictionThreshold; // this.triggerPolicy = triggerPolicy; // this.triggerThreshold = triggerThreshold; // this.progressive = progressive; // } // // // public boolean isProgressive() { // return progressive; // } // // public List<Pair<String,Order>> getSortBy() { // return sortBy; // } // // public boolean isClearOnTrigger() { // return clearOnTrigger; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // public Policy getTriggerPolicy() { // return triggerPolicy; // } // // public long getTriggerThreshold() { // return triggerThreshold; // } // // // @Override // public boolean equals(Object o) { // // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // SortOp sortOp = (SortOp) o; // // if (clearOnTrigger != sortOp.clearOnTrigger) return false; // if (evictionThreshold != sortOp.evictionThreshold) return false; // if (triggerThreshold != sortOp.triggerThreshold) return false; // if (evictionPolicy != sortOp.evictionPolicy) return false; // if (sortBy != null ? !sortBy.equals(sortOp.sortBy) : sortOp.sortBy != null) return false; // if (triggerPolicy != sortOp.triggerPolicy) return false; // // return true; // } // // @Override // public int hashCode() { // int result = sortBy != null ? sortBy.hashCode() : 0; // result = 31 * result + (clearOnTrigger ? 1 : 0); // result = 31 * result + (evictionPolicy != null ? evictionPolicy.hashCode() : 0); // result = 31 * result + (int) (evictionThreshold ^ (evictionThreshold >>> 32)); // result = 31 * result + (triggerPolicy != null ? triggerPolicy.hashCode() : 0); // result = 31 * result + (int) (triggerThreshold ^ (triggerThreshold >>> 32)); // return result; // } // // @Override // public String toString() { // return "SortOp{" + // "sortBy=" + sortBy + // ", clearOnTrigger=" + clearOnTrigger + // ", evictionPolicy=" + evictionPolicy + // ", evictionThreshold=" + evictionThreshold + // ", triggerPolicy=" + triggerPolicy + // ", triggerThreshold=" + triggerThreshold + // '}'; // } // // @Override // public String getComponentName() { // return SORT; // } // }
import java.util.ArrayList; import java.util.List; import org.calrissian.flowmix.api.Order; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import org.calrissian.flowmix.core.model.op.SortOp; import org.calrissian.mango.domain.Pair; import static java.util.Collections.EMPTY_LIST;
evictionThreshold = -1; return this; } public SortBuilder topN(int n, Policy triggerPolicy, long triggerThreshold, boolean flushOnTrigger) { evictionPolicy = Policy.COUNT; evictionThreshold = n; this.triggerPolicy = triggerPolicy; this.triggerThreshold = triggerThreshold; this.clearOnTrigger = flushOnTrigger; return this; } @Override public StreamBuilder end() { if(sortBy.size() == 0) throw new RuntimeException("Sort operator needs at least one field name to sort by"); if(clearOnTrigger == false && (evictionPolicy == null || evictionThreshold == -1)) throw new RuntimeException("Sort operator needs an eviction policy and threshold"); if(triggerPolicy == null || triggerThreshold == -1) throw new RuntimeException("Sort operator needs a trigger policy and threshold"); List<FlowOp> flowOpList = getStreamBuilder().getFlowOpList(); FlowOp op = flowOpList.size() == 0 ? null : flowOpList.get(flowOpList.size()-1); if(op == null || !(op instanceof PartitionOp)) flowOpList.add(new PartitionOp(EMPTY_LIST));
// Path: src/main/java/org/calrissian/flowmix/api/Order.java // public enum Order { // // ASC, DESC // } // // Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/SortOp.java // public class SortOp implements FlowOp, RequiresPartitioning { // // public static final String SORT = "sort"; // // private List<Pair<String, Order>> sortBy; // private boolean clearOnTrigger = false; // this determines whether or or not the dataset is sorted all the time // private Policy evictionPolicy; // private long evictionThreshold; // private Policy triggerPolicy; // private long triggerThreshold; // private boolean progressive; // // public SortOp(List<Pair<String,Order>> sortBy, boolean clearOnTrigger, Policy evictionPolicy, long evictionThreshold, Policy triggerPolicy, long triggerThreshold, boolean progressive) { // this.sortBy = sortBy; // this.clearOnTrigger = clearOnTrigger; // this.evictionPolicy = evictionPolicy; // this.evictionThreshold = evictionThreshold; // this.triggerPolicy = triggerPolicy; // this.triggerThreshold = triggerThreshold; // this.progressive = progressive; // } // // // public boolean isProgressive() { // return progressive; // } // // public List<Pair<String,Order>> getSortBy() { // return sortBy; // } // // public boolean isClearOnTrigger() { // return clearOnTrigger; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // public Policy getTriggerPolicy() { // return triggerPolicy; // } // // public long getTriggerThreshold() { // return triggerThreshold; // } // // // @Override // public boolean equals(Object o) { // // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // SortOp sortOp = (SortOp) o; // // if (clearOnTrigger != sortOp.clearOnTrigger) return false; // if (evictionThreshold != sortOp.evictionThreshold) return false; // if (triggerThreshold != sortOp.triggerThreshold) return false; // if (evictionPolicy != sortOp.evictionPolicy) return false; // if (sortBy != null ? !sortBy.equals(sortOp.sortBy) : sortOp.sortBy != null) return false; // if (triggerPolicy != sortOp.triggerPolicy) return false; // // return true; // } // // @Override // public int hashCode() { // int result = sortBy != null ? sortBy.hashCode() : 0; // result = 31 * result + (clearOnTrigger ? 1 : 0); // result = 31 * result + (evictionPolicy != null ? evictionPolicy.hashCode() : 0); // result = 31 * result + (int) (evictionThreshold ^ (evictionThreshold >>> 32)); // result = 31 * result + (triggerPolicy != null ? triggerPolicy.hashCode() : 0); // result = 31 * result + (int) (triggerThreshold ^ (triggerThreshold >>> 32)); // return result; // } // // @Override // public String toString() { // return "SortOp{" + // "sortBy=" + sortBy + // ", clearOnTrigger=" + clearOnTrigger + // ", evictionPolicy=" + evictionPolicy + // ", evictionThreshold=" + evictionThreshold + // ", triggerPolicy=" + triggerPolicy + // ", triggerThreshold=" + triggerThreshold + // '}'; // } // // @Override // public String getComponentName() { // return SORT; // } // } // Path: src/main/java/org/calrissian/flowmix/api/builder/SortBuilder.java import java.util.ArrayList; import java.util.List; import org.calrissian.flowmix.api.Order; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import org.calrissian.flowmix.core.model.op.SortOp; import org.calrissian.mango.domain.Pair; import static java.util.Collections.EMPTY_LIST; evictionThreshold = -1; return this; } public SortBuilder topN(int n, Policy triggerPolicy, long triggerThreshold, boolean flushOnTrigger) { evictionPolicy = Policy.COUNT; evictionThreshold = n; this.triggerPolicy = triggerPolicy; this.triggerThreshold = triggerThreshold; this.clearOnTrigger = flushOnTrigger; return this; } @Override public StreamBuilder end() { if(sortBy.size() == 0) throw new RuntimeException("Sort operator needs at least one field name to sort by"); if(clearOnTrigger == false && (evictionPolicy == null || evictionThreshold == -1)) throw new RuntimeException("Sort operator needs an eviction policy and threshold"); if(triggerPolicy == null || triggerThreshold == -1) throw new RuntimeException("Sort operator needs a trigger policy and threshold"); List<FlowOp> flowOpList = getStreamBuilder().getFlowOpList(); FlowOp op = flowOpList.size() == 0 ? null : flowOpList.get(flowOpList.size()-1); if(op == null || !(op instanceof PartitionOp)) flowOpList.add(new PartitionOp(EMPTY_LIST));
getStreamBuilder().addFlowOp(new SortOp(sortBy, clearOnTrigger, evictionPolicy, evictionThreshold,
calrissian/flowmix
src/main/java/org/calrissian/flowmix/core/model/op/SplitOp.java
// Path: src/main/java/org/calrissian/flowmix/api/Filter.java // public interface Filter extends Serializable { // // boolean accept(Event event); // }
import org.calrissian.flowmix.api.Filter; import org.calrissian.mango.domain.Pair; import java.util.List;
package org.calrissian.flowmix.core.model.op; public class SplitOp implements FlowOp{ public static final String SPLIT = "split"; // default path should just pass through to the next component in the chain
// Path: src/main/java/org/calrissian/flowmix/api/Filter.java // public interface Filter extends Serializable { // // boolean accept(Event event); // } // Path: src/main/java/org/calrissian/flowmix/core/model/op/SplitOp.java import org.calrissian.flowmix.api.Filter; import org.calrissian.mango.domain.Pair; import java.util.List; package org.calrissian.flowmix.core.model.op; public class SplitOp implements FlowOp{ public static final String SPLIT = "split"; // default path should just pass through to the next component in the chain
private Filter defaultPath;
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/storm/spout/FlowLoaderBaseSpout.java
// Path: src/main/java/org/calrissian/flowmix/api/Flow.java // public class Flow implements Serializable{ // // String id; // String name; // String description; // // Map<String,StreamDef> streams = new HashMap<String, StreamDef>(); // // public String getId() { // return id; // } // // public String getName() { // return name; // } // // public String getDescription() { // return description; // } // // public Collection<StreamDef> getStreams() { // return streams.values(); // } // // public StreamDef getStream(String name) { // return streams.get(name); // } // // public void setId(String id) { // this.id = id; // } // // public void setName(String name) { // this.name = name; // } // // public void setDescription(String description) { // this.description = description; // } // // public void setStreams(List<StreamDef> streams) { // for(StreamDef def : streams) // this.streams.put(def.getName(), def); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Flow flow = (Flow) o; // // if (description != null ? !description.equals(flow.description) : flow.description != null) return false; // if (id != null ? !id.equals(flow.id) : flow.id != null) return false; // if (name != null ? !name.equals(flow.name) : flow.name != null) return false; // if (streams != null ? !streams.equals(flow.streams) : flow.streams != null) return false; // // return true; // } // // @Override // public int hashCode() { // int result = id != null ? id.hashCode() : 0; // result = 31 * result + (name != null ? name.hashCode() : 0); // result = 31 * result + (description != null ? description.hashCode() : 0); // result = 31 * result + (streams != null ? streams.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "Flow{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // ", description='" + description + '\'' + // ", streams=" + streams + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_LOADER_STREAM = "flowLoaderStream";
import java.util.Collection; import backtype.storm.spout.SpoutOutputCollector; import backtype.storm.topology.OutputFieldsDeclarer; import backtype.storm.topology.base.BaseRichSpout; import backtype.storm.tuple.Fields; import backtype.storm.tuple.Values; import org.calrissian.flowmix.api.Flow; import static org.calrissian.flowmix.core.Constants.FLOW_LOADER_STREAM;
package org.calrissian.flowmix.api.storm.spout; public abstract class FlowLoaderBaseSpout extends BaseRichSpout { @Override public void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer) {
// Path: src/main/java/org/calrissian/flowmix/api/Flow.java // public class Flow implements Serializable{ // // String id; // String name; // String description; // // Map<String,StreamDef> streams = new HashMap<String, StreamDef>(); // // public String getId() { // return id; // } // // public String getName() { // return name; // } // // public String getDescription() { // return description; // } // // public Collection<StreamDef> getStreams() { // return streams.values(); // } // // public StreamDef getStream(String name) { // return streams.get(name); // } // // public void setId(String id) { // this.id = id; // } // // public void setName(String name) { // this.name = name; // } // // public void setDescription(String description) { // this.description = description; // } // // public void setStreams(List<StreamDef> streams) { // for(StreamDef def : streams) // this.streams.put(def.getName(), def); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Flow flow = (Flow) o; // // if (description != null ? !description.equals(flow.description) : flow.description != null) return false; // if (id != null ? !id.equals(flow.id) : flow.id != null) return false; // if (name != null ? !name.equals(flow.name) : flow.name != null) return false; // if (streams != null ? !streams.equals(flow.streams) : flow.streams != null) return false; // // return true; // } // // @Override // public int hashCode() { // int result = id != null ? id.hashCode() : 0; // result = 31 * result + (name != null ? name.hashCode() : 0); // result = 31 * result + (description != null ? description.hashCode() : 0); // result = 31 * result + (streams != null ? streams.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "Flow{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // ", description='" + description + '\'' + // ", streams=" + streams + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_LOADER_STREAM = "flowLoaderStream"; // Path: src/main/java/org/calrissian/flowmix/api/storm/spout/FlowLoaderBaseSpout.java import java.util.Collection; import backtype.storm.spout.SpoutOutputCollector; import backtype.storm.topology.OutputFieldsDeclarer; import backtype.storm.topology.base.BaseRichSpout; import backtype.storm.tuple.Fields; import backtype.storm.tuple.Values; import org.calrissian.flowmix.api.Flow; import static org.calrissian.flowmix.core.Constants.FLOW_LOADER_STREAM; package org.calrissian.flowmix.api.storm.spout; public abstract class FlowLoaderBaseSpout extends BaseRichSpout { @Override public void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer) {
outputFieldsDeclarer.declareStream(FLOW_LOADER_STREAM, new Fields("flows"));
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/storm/spout/FlowLoaderBaseSpout.java
// Path: src/main/java/org/calrissian/flowmix/api/Flow.java // public class Flow implements Serializable{ // // String id; // String name; // String description; // // Map<String,StreamDef> streams = new HashMap<String, StreamDef>(); // // public String getId() { // return id; // } // // public String getName() { // return name; // } // // public String getDescription() { // return description; // } // // public Collection<StreamDef> getStreams() { // return streams.values(); // } // // public StreamDef getStream(String name) { // return streams.get(name); // } // // public void setId(String id) { // this.id = id; // } // // public void setName(String name) { // this.name = name; // } // // public void setDescription(String description) { // this.description = description; // } // // public void setStreams(List<StreamDef> streams) { // for(StreamDef def : streams) // this.streams.put(def.getName(), def); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Flow flow = (Flow) o; // // if (description != null ? !description.equals(flow.description) : flow.description != null) return false; // if (id != null ? !id.equals(flow.id) : flow.id != null) return false; // if (name != null ? !name.equals(flow.name) : flow.name != null) return false; // if (streams != null ? !streams.equals(flow.streams) : flow.streams != null) return false; // // return true; // } // // @Override // public int hashCode() { // int result = id != null ? id.hashCode() : 0; // result = 31 * result + (name != null ? name.hashCode() : 0); // result = 31 * result + (description != null ? description.hashCode() : 0); // result = 31 * result + (streams != null ? streams.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "Flow{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // ", description='" + description + '\'' + // ", streams=" + streams + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_LOADER_STREAM = "flowLoaderStream";
import java.util.Collection; import backtype.storm.spout.SpoutOutputCollector; import backtype.storm.topology.OutputFieldsDeclarer; import backtype.storm.topology.base.BaseRichSpout; import backtype.storm.tuple.Fields; import backtype.storm.tuple.Values; import org.calrissian.flowmix.api.Flow; import static org.calrissian.flowmix.core.Constants.FLOW_LOADER_STREAM;
package org.calrissian.flowmix.api.storm.spout; public abstract class FlowLoaderBaseSpout extends BaseRichSpout { @Override public void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer) { outputFieldsDeclarer.declareStream(FLOW_LOADER_STREAM, new Fields("flows")); }
// Path: src/main/java/org/calrissian/flowmix/api/Flow.java // public class Flow implements Serializable{ // // String id; // String name; // String description; // // Map<String,StreamDef> streams = new HashMap<String, StreamDef>(); // // public String getId() { // return id; // } // // public String getName() { // return name; // } // // public String getDescription() { // return description; // } // // public Collection<StreamDef> getStreams() { // return streams.values(); // } // // public StreamDef getStream(String name) { // return streams.get(name); // } // // public void setId(String id) { // this.id = id; // } // // public void setName(String name) { // this.name = name; // } // // public void setDescription(String description) { // this.description = description; // } // // public void setStreams(List<StreamDef> streams) { // for(StreamDef def : streams) // this.streams.put(def.getName(), def); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Flow flow = (Flow) o; // // if (description != null ? !description.equals(flow.description) : flow.description != null) return false; // if (id != null ? !id.equals(flow.id) : flow.id != null) return false; // if (name != null ? !name.equals(flow.name) : flow.name != null) return false; // if (streams != null ? !streams.equals(flow.streams) : flow.streams != null) return false; // // return true; // } // // @Override // public int hashCode() { // int result = id != null ? id.hashCode() : 0; // result = 31 * result + (name != null ? name.hashCode() : 0); // result = 31 * result + (description != null ? description.hashCode() : 0); // result = 31 * result + (streams != null ? streams.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "Flow{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // ", description='" + description + '\'' + // ", streams=" + streams + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_LOADER_STREAM = "flowLoaderStream"; // Path: src/main/java/org/calrissian/flowmix/api/storm/spout/FlowLoaderBaseSpout.java import java.util.Collection; import backtype.storm.spout.SpoutOutputCollector; import backtype.storm.topology.OutputFieldsDeclarer; import backtype.storm.topology.base.BaseRichSpout; import backtype.storm.tuple.Fields; import backtype.storm.tuple.Values; import org.calrissian.flowmix.api.Flow; import static org.calrissian.flowmix.core.Constants.FLOW_LOADER_STREAM; package org.calrissian.flowmix.api.storm.spout; public abstract class FlowLoaderBaseSpout extends BaseRichSpout { @Override public void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer) { outputFieldsDeclarer.declareStream(FLOW_LOADER_STREAM, new Fields("flows")); }
protected void emitFlows(SpoutOutputCollector collector, Collection<Flow> flows) {
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/storm/bolt/FlowLoaderBaseBolt.java
// Path: src/main/java/org/calrissian/flowmix/api/Flow.java // public class Flow implements Serializable{ // // String id; // String name; // String description; // // Map<String,StreamDef> streams = new HashMap<String, StreamDef>(); // // public String getId() { // return id; // } // // public String getName() { // return name; // } // // public String getDescription() { // return description; // } // // public Collection<StreamDef> getStreams() { // return streams.values(); // } // // public StreamDef getStream(String name) { // return streams.get(name); // } // // public void setId(String id) { // this.id = id; // } // // public void setName(String name) { // this.name = name; // } // // public void setDescription(String description) { // this.description = description; // } // // public void setStreams(List<StreamDef> streams) { // for(StreamDef def : streams) // this.streams.put(def.getName(), def); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Flow flow = (Flow) o; // // if (description != null ? !description.equals(flow.description) : flow.description != null) return false; // if (id != null ? !id.equals(flow.id) : flow.id != null) return false; // if (name != null ? !name.equals(flow.name) : flow.name != null) return false; // if (streams != null ? !streams.equals(flow.streams) : flow.streams != null) return false; // // return true; // } // // @Override // public int hashCode() { // int result = id != null ? id.hashCode() : 0; // result = 31 * result + (name != null ? name.hashCode() : 0); // result = 31 * result + (description != null ? description.hashCode() : 0); // result = 31 * result + (streams != null ? streams.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "Flow{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // ", description='" + description + '\'' + // ", streams=" + streams + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_LOADER_STREAM = "flowLoaderStream";
import java.util.Collection; import backtype.storm.spout.SpoutOutputCollector; import backtype.storm.topology.OutputFieldsDeclarer; import backtype.storm.topology.base.BaseRichBolt; import backtype.storm.tuple.Fields; import backtype.storm.tuple.Values; import org.calrissian.flowmix.api.Flow; import static org.calrissian.flowmix.core.Constants.FLOW_LOADER_STREAM;
package org.calrissian.flowmix.api.storm.bolt; public abstract class FlowLoaderBaseBolt extends BaseRichBolt { @Override public void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer) {
// Path: src/main/java/org/calrissian/flowmix/api/Flow.java // public class Flow implements Serializable{ // // String id; // String name; // String description; // // Map<String,StreamDef> streams = new HashMap<String, StreamDef>(); // // public String getId() { // return id; // } // // public String getName() { // return name; // } // // public String getDescription() { // return description; // } // // public Collection<StreamDef> getStreams() { // return streams.values(); // } // // public StreamDef getStream(String name) { // return streams.get(name); // } // // public void setId(String id) { // this.id = id; // } // // public void setName(String name) { // this.name = name; // } // // public void setDescription(String description) { // this.description = description; // } // // public void setStreams(List<StreamDef> streams) { // for(StreamDef def : streams) // this.streams.put(def.getName(), def); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Flow flow = (Flow) o; // // if (description != null ? !description.equals(flow.description) : flow.description != null) return false; // if (id != null ? !id.equals(flow.id) : flow.id != null) return false; // if (name != null ? !name.equals(flow.name) : flow.name != null) return false; // if (streams != null ? !streams.equals(flow.streams) : flow.streams != null) return false; // // return true; // } // // @Override // public int hashCode() { // int result = id != null ? id.hashCode() : 0; // result = 31 * result + (name != null ? name.hashCode() : 0); // result = 31 * result + (description != null ? description.hashCode() : 0); // result = 31 * result + (streams != null ? streams.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "Flow{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // ", description='" + description + '\'' + // ", streams=" + streams + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_LOADER_STREAM = "flowLoaderStream"; // Path: src/main/java/org/calrissian/flowmix/api/storm/bolt/FlowLoaderBaseBolt.java import java.util.Collection; import backtype.storm.spout.SpoutOutputCollector; import backtype.storm.topology.OutputFieldsDeclarer; import backtype.storm.topology.base.BaseRichBolt; import backtype.storm.tuple.Fields; import backtype.storm.tuple.Values; import org.calrissian.flowmix.api.Flow; import static org.calrissian.flowmix.core.Constants.FLOW_LOADER_STREAM; package org.calrissian.flowmix.api.storm.bolt; public abstract class FlowLoaderBaseBolt extends BaseRichBolt { @Override public void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer) {
outputFieldsDeclarer.declareStream(FLOW_LOADER_STREAM, new Fields("flows"));
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/storm/bolt/FlowLoaderBaseBolt.java
// Path: src/main/java/org/calrissian/flowmix/api/Flow.java // public class Flow implements Serializable{ // // String id; // String name; // String description; // // Map<String,StreamDef> streams = new HashMap<String, StreamDef>(); // // public String getId() { // return id; // } // // public String getName() { // return name; // } // // public String getDescription() { // return description; // } // // public Collection<StreamDef> getStreams() { // return streams.values(); // } // // public StreamDef getStream(String name) { // return streams.get(name); // } // // public void setId(String id) { // this.id = id; // } // // public void setName(String name) { // this.name = name; // } // // public void setDescription(String description) { // this.description = description; // } // // public void setStreams(List<StreamDef> streams) { // for(StreamDef def : streams) // this.streams.put(def.getName(), def); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Flow flow = (Flow) o; // // if (description != null ? !description.equals(flow.description) : flow.description != null) return false; // if (id != null ? !id.equals(flow.id) : flow.id != null) return false; // if (name != null ? !name.equals(flow.name) : flow.name != null) return false; // if (streams != null ? !streams.equals(flow.streams) : flow.streams != null) return false; // // return true; // } // // @Override // public int hashCode() { // int result = id != null ? id.hashCode() : 0; // result = 31 * result + (name != null ? name.hashCode() : 0); // result = 31 * result + (description != null ? description.hashCode() : 0); // result = 31 * result + (streams != null ? streams.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "Flow{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // ", description='" + description + '\'' + // ", streams=" + streams + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_LOADER_STREAM = "flowLoaderStream";
import java.util.Collection; import backtype.storm.spout.SpoutOutputCollector; import backtype.storm.topology.OutputFieldsDeclarer; import backtype.storm.topology.base.BaseRichBolt; import backtype.storm.tuple.Fields; import backtype.storm.tuple.Values; import org.calrissian.flowmix.api.Flow; import static org.calrissian.flowmix.core.Constants.FLOW_LOADER_STREAM;
package org.calrissian.flowmix.api.storm.bolt; public abstract class FlowLoaderBaseBolt extends BaseRichBolt { @Override public void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer) { outputFieldsDeclarer.declareStream(FLOW_LOADER_STREAM, new Fields("flows")); }
// Path: src/main/java/org/calrissian/flowmix/api/Flow.java // public class Flow implements Serializable{ // // String id; // String name; // String description; // // Map<String,StreamDef> streams = new HashMap<String, StreamDef>(); // // public String getId() { // return id; // } // // public String getName() { // return name; // } // // public String getDescription() { // return description; // } // // public Collection<StreamDef> getStreams() { // return streams.values(); // } // // public StreamDef getStream(String name) { // return streams.get(name); // } // // public void setId(String id) { // this.id = id; // } // // public void setName(String name) { // this.name = name; // } // // public void setDescription(String description) { // this.description = description; // } // // public void setStreams(List<StreamDef> streams) { // for(StreamDef def : streams) // this.streams.put(def.getName(), def); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Flow flow = (Flow) o; // // if (description != null ? !description.equals(flow.description) : flow.description != null) return false; // if (id != null ? !id.equals(flow.id) : flow.id != null) return false; // if (name != null ? !name.equals(flow.name) : flow.name != null) return false; // if (streams != null ? !streams.equals(flow.streams) : flow.streams != null) return false; // // return true; // } // // @Override // public int hashCode() { // int result = id != null ? id.hashCode() : 0; // result = 31 * result + (name != null ? name.hashCode() : 0); // result = 31 * result + (description != null ? description.hashCode() : 0); // result = 31 * result + (streams != null ? streams.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "Flow{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // ", description='" + description + '\'' + // ", streams=" + streams + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String FLOW_LOADER_STREAM = "flowLoaderStream"; // Path: src/main/java/org/calrissian/flowmix/api/storm/bolt/FlowLoaderBaseBolt.java import java.util.Collection; import backtype.storm.spout.SpoutOutputCollector; import backtype.storm.topology.OutputFieldsDeclarer; import backtype.storm.topology.base.BaseRichBolt; import backtype.storm.tuple.Fields; import backtype.storm.tuple.Values; import org.calrissian.flowmix.api.Flow; import static org.calrissian.flowmix.core.Constants.FLOW_LOADER_STREAM; package org.calrissian.flowmix.api.storm.bolt; public abstract class FlowLoaderBaseBolt extends BaseRichBolt { @Override public void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer) { outputFieldsDeclarer.declareStream(FLOW_LOADER_STREAM, new Fields("flows")); }
protected void emitFlows(SpoutOutputCollector collector, Collection<Flow> flows) {
calrissian/flowmix
src/main/java/org/calrissian/flowmix/core/model/op/AggregateOp.java
// Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/RequiresPartitioning.java // public interface RequiresPartitioning { // } // // Path: src/main/java/org/calrissian/flowmix/api/Aggregator.java // public interface Aggregator extends Serializable { // // public static final String GROUP_BY = "groupBy"; // public static final String GROUP_BY_DELIM = "\u0000"; // // void configure(Map<String, String> configuration); // // void added(WindowItem item); // // void evicted(WindowItem item); // // List<AggregatedEvent> aggregate(); // }
import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.RequiresPartitioning; import org.calrissian.flowmix.api.Aggregator; import java.util.Map;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.model.op; public class AggregateOp implements FlowOp, RequiresPartitioning { public static final String AGGREGATE = "aggregate";
// Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/RequiresPartitioning.java // public interface RequiresPartitioning { // } // // Path: src/main/java/org/calrissian/flowmix/api/Aggregator.java // public interface Aggregator extends Serializable { // // public static final String GROUP_BY = "groupBy"; // public static final String GROUP_BY_DELIM = "\u0000"; // // void configure(Map<String, String> configuration); // // void added(WindowItem item); // // void evicted(WindowItem item); // // List<AggregatedEvent> aggregate(); // } // Path: src/main/java/org/calrissian/flowmix/core/model/op/AggregateOp.java import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.RequiresPartitioning; import org.calrissian.flowmix.api.Aggregator; import java.util.Map; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.model.op; public class AggregateOp implements FlowOp, RequiresPartitioning { public static final String AGGREGATE = "aggregate";
private final Class<? extends Aggregator> aggregatorClass;
calrissian/flowmix
src/main/java/org/calrissian/flowmix/core/model/op/AggregateOp.java
// Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/RequiresPartitioning.java // public interface RequiresPartitioning { // } // // Path: src/main/java/org/calrissian/flowmix/api/Aggregator.java // public interface Aggregator extends Serializable { // // public static final String GROUP_BY = "groupBy"; // public static final String GROUP_BY_DELIM = "\u0000"; // // void configure(Map<String, String> configuration); // // void added(WindowItem item); // // void evicted(WindowItem item); // // List<AggregatedEvent> aggregate(); // }
import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.RequiresPartitioning; import org.calrissian.flowmix.api.Aggregator; import java.util.Map;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.model.op; public class AggregateOp implements FlowOp, RequiresPartitioning { public static final String AGGREGATE = "aggregate"; private final Class<? extends Aggregator> aggregatorClass;
// Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/RequiresPartitioning.java // public interface RequiresPartitioning { // } // // Path: src/main/java/org/calrissian/flowmix/api/Aggregator.java // public interface Aggregator extends Serializable { // // public static final String GROUP_BY = "groupBy"; // public static final String GROUP_BY_DELIM = "\u0000"; // // void configure(Map<String, String> configuration); // // void added(WindowItem item); // // void evicted(WindowItem item); // // List<AggregatedEvent> aggregate(); // } // Path: src/main/java/org/calrissian/flowmix/core/model/op/AggregateOp.java import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.RequiresPartitioning; import org.calrissian.flowmix.api.Aggregator; import java.util.Map; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.model.op; public class AggregateOp implements FlowOp, RequiresPartitioning { public static final String AGGREGATE = "aggregate"; private final Class<? extends Aggregator> aggregatorClass;
private final Policy triggerPolicy;
calrissian/flowmix
src/main/java/org/calrissian/flowmix/core/model/op/EachOp.java
// Path: src/main/java/org/calrissian/flowmix/api/Function.java // public interface Function extends Serializable{ // // List<Event> execute(Event event); // }
import org.calrissian.flowmix.api.Function;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.model.op; public class EachOp implements FlowOp { public static final String EACH = "each";
// Path: src/main/java/org/calrissian/flowmix/api/Function.java // public interface Function extends Serializable{ // // List<Event> execute(Event event); // } // Path: src/main/java/org/calrissian/flowmix/core/model/op/EachOp.java import org.calrissian.flowmix.api.Function; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.model.op; public class EachOp implements FlowOp { public static final String EACH = "each";
Function function;
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/Flow.java
// Path: src/main/java/org/calrissian/flowmix/core/model/StreamDef.java // public class StreamDef implements Serializable { // // private String name; // private List<FlowOp> flowOps; // private boolean stdInput; // private boolean stdOutput; // private String[] outputs; // // public StreamDef(String name, List<FlowOp> flowOps, boolean stdInput, boolean stdOutput, String[] outputs) { // this.name = name; // this.flowOps = flowOps; // this.stdInput = stdInput; // this.stdOutput = stdOutput; // this.outputs = outputs; // } // // public String getName() { // return name; // } // // public List<FlowOp> getFlowOps() { // return flowOps; // } // // public boolean isStdInput() { // return stdInput; // } // // public boolean isStdOutput() { // return stdOutput; // } // // public String[] getOutputs() { // return outputs; // } // // @Override // public String toString() { // return "StreamDef{" + // "name='" + name + '\'' + // ", flowOps=" + flowOps + // '}'; // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // StreamDef streamDef = (StreamDef) o; // // if (stdInput != streamDef.stdInput) { // return false; // } // if (stdOutput != streamDef.stdOutput) { // return false; // } // if (flowOps != null ? !flowOps.equals(streamDef.flowOps) : streamDef.flowOps != null) { // return false; // } // if (name != null ? !name.equals(streamDef.name) : streamDef.name != null) { // return false; // } // if (!Arrays.equals(outputs, streamDef.outputs)) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = name != null ? name.hashCode() : 0; // result = 31 * result + (flowOps != null ? flowOps.hashCode() : 0); // result = 31 * result + (stdInput ? 1 : 0); // result = 31 * result + (stdOutput ? 1 : 0); // result = 31 * result + (outputs != null ? Arrays.hashCode(outputs) : 0); // return result; // } // }
import java.io.Serializable; import java.util.*; import org.calrissian.flowmix.core.model.StreamDef;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api; public class Flow implements Serializable{ String id; String name; String description;
// Path: src/main/java/org/calrissian/flowmix/core/model/StreamDef.java // public class StreamDef implements Serializable { // // private String name; // private List<FlowOp> flowOps; // private boolean stdInput; // private boolean stdOutput; // private String[] outputs; // // public StreamDef(String name, List<FlowOp> flowOps, boolean stdInput, boolean stdOutput, String[] outputs) { // this.name = name; // this.flowOps = flowOps; // this.stdInput = stdInput; // this.stdOutput = stdOutput; // this.outputs = outputs; // } // // public String getName() { // return name; // } // // public List<FlowOp> getFlowOps() { // return flowOps; // } // // public boolean isStdInput() { // return stdInput; // } // // public boolean isStdOutput() { // return stdOutput; // } // // public String[] getOutputs() { // return outputs; // } // // @Override // public String toString() { // return "StreamDef{" + // "name='" + name + '\'' + // ", flowOps=" + flowOps + // '}'; // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // StreamDef streamDef = (StreamDef) o; // // if (stdInput != streamDef.stdInput) { // return false; // } // if (stdOutput != streamDef.stdOutput) { // return false; // } // if (flowOps != null ? !flowOps.equals(streamDef.flowOps) : streamDef.flowOps != null) { // return false; // } // if (name != null ? !name.equals(streamDef.name) : streamDef.name != null) { // return false; // } // if (!Arrays.equals(outputs, streamDef.outputs)) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = name != null ? name.hashCode() : 0; // result = 31 * result + (flowOps != null ? flowOps.hashCode() : 0); // result = 31 * result + (stdInput ? 1 : 0); // result = 31 * result + (stdOutput ? 1 : 0); // result = 31 * result + (outputs != null ? Arrays.hashCode(outputs) : 0); // return result; // } // } // Path: src/main/java/org/calrissian/flowmix/api/Flow.java import java.io.Serializable; import java.util.*; import org.calrissian.flowmix.core.model.StreamDef; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api; public class Flow implements Serializable{ String id; String name; String description;
Map<String,StreamDef> streams = new HashMap<String, StreamDef>();
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/builder/SplitBuilder.java
// Path: src/main/java/org/calrissian/flowmix/api/Filter.java // public interface Filter extends Serializable { // // boolean accept(Event event); // } // // Path: src/main/java/org/calrissian/flowmix/api/filter/NoFilter.java // public class NoFilter implements Filter { // @Override public boolean accept(Event event) { // return true; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/SplitOp.java // public class SplitOp implements FlowOp{ // // public static final String SPLIT = "split"; // // // default path should just pass through to the next component in the chain // private Filter defaultPath; // // // events that path each given filter should go out to the stream with the specified id. // private List<Pair<Filter, String>> paths; // // public SplitOp(Filter defaultPath, List<Pair<Filter,String>> paths) { // this.defaultPath = defaultPath; // this.paths = paths; // } // // public Filter getDefaultPath() { // return defaultPath; // } // // public List<Pair<Filter,String>> getPaths() { // return paths; // } // // @Override public String getComponentName() { // return SPLIT; // } // }
import java.util.ArrayList; import java.util.List; import org.calrissian.flowmix.api.Filter; import org.calrissian.flowmix.api.filter.NoFilter; import org.calrissian.flowmix.core.model.op.SplitOp; import org.calrissian.mango.domain.Pair;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.builder; public class SplitBuilder extends AbstractOpBuilder { private Filter defaultPath; private List<Pair<Filter, String>> paths = new ArrayList<Pair<Filter,String>>(); public SplitBuilder(StreamBuilder flowOpsBuilder) { super(flowOpsBuilder); } public SplitBuilder defaultPath(Filter filter) { this.defaultPath = filter; return this; } public SplitBuilder path(Filter filter, String destinationStream) { this.paths.add(new Pair<Filter,String>(filter, destinationStream)); return this; } public SplitBuilder all(String destinationStream) {
// Path: src/main/java/org/calrissian/flowmix/api/Filter.java // public interface Filter extends Serializable { // // boolean accept(Event event); // } // // Path: src/main/java/org/calrissian/flowmix/api/filter/NoFilter.java // public class NoFilter implements Filter { // @Override public boolean accept(Event event) { // return true; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/SplitOp.java // public class SplitOp implements FlowOp{ // // public static final String SPLIT = "split"; // // // default path should just pass through to the next component in the chain // private Filter defaultPath; // // // events that path each given filter should go out to the stream with the specified id. // private List<Pair<Filter, String>> paths; // // public SplitOp(Filter defaultPath, List<Pair<Filter,String>> paths) { // this.defaultPath = defaultPath; // this.paths = paths; // } // // public Filter getDefaultPath() { // return defaultPath; // } // // public List<Pair<Filter,String>> getPaths() { // return paths; // } // // @Override public String getComponentName() { // return SPLIT; // } // } // Path: src/main/java/org/calrissian/flowmix/api/builder/SplitBuilder.java import java.util.ArrayList; import java.util.List; import org.calrissian.flowmix.api.Filter; import org.calrissian.flowmix.api.filter.NoFilter; import org.calrissian.flowmix.core.model.op.SplitOp; import org.calrissian.mango.domain.Pair; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.builder; public class SplitBuilder extends AbstractOpBuilder { private Filter defaultPath; private List<Pair<Filter, String>> paths = new ArrayList<Pair<Filter,String>>(); public SplitBuilder(StreamBuilder flowOpsBuilder) { super(flowOpsBuilder); } public SplitBuilder defaultPath(Filter filter) { this.defaultPath = filter; return this; } public SplitBuilder path(Filter filter, String destinationStream) { this.paths.add(new Pair<Filter,String>(filter, destinationStream)); return this; } public SplitBuilder all(String destinationStream) {
this.paths.add(new Pair<Filter,String>(new NoFilter(), destinationStream));
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/builder/SplitBuilder.java
// Path: src/main/java/org/calrissian/flowmix/api/Filter.java // public interface Filter extends Serializable { // // boolean accept(Event event); // } // // Path: src/main/java/org/calrissian/flowmix/api/filter/NoFilter.java // public class NoFilter implements Filter { // @Override public boolean accept(Event event) { // return true; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/SplitOp.java // public class SplitOp implements FlowOp{ // // public static final String SPLIT = "split"; // // // default path should just pass through to the next component in the chain // private Filter defaultPath; // // // events that path each given filter should go out to the stream with the specified id. // private List<Pair<Filter, String>> paths; // // public SplitOp(Filter defaultPath, List<Pair<Filter,String>> paths) { // this.defaultPath = defaultPath; // this.paths = paths; // } // // public Filter getDefaultPath() { // return defaultPath; // } // // public List<Pair<Filter,String>> getPaths() { // return paths; // } // // @Override public String getComponentName() { // return SPLIT; // } // }
import java.util.ArrayList; import java.util.List; import org.calrissian.flowmix.api.Filter; import org.calrissian.flowmix.api.filter.NoFilter; import org.calrissian.flowmix.core.model.op.SplitOp; import org.calrissian.mango.domain.Pair;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.builder; public class SplitBuilder extends AbstractOpBuilder { private Filter defaultPath; private List<Pair<Filter, String>> paths = new ArrayList<Pair<Filter,String>>(); public SplitBuilder(StreamBuilder flowOpsBuilder) { super(flowOpsBuilder); } public SplitBuilder defaultPath(Filter filter) { this.defaultPath = filter; return this; } public SplitBuilder path(Filter filter, String destinationStream) { this.paths.add(new Pair<Filter,String>(filter, destinationStream)); return this; } public SplitBuilder all(String destinationStream) { this.paths.add(new Pair<Filter,String>(new NoFilter(), destinationStream)); return this; } @Override public StreamBuilder end() { for(Pair<Filter, String> pair : paths) { if(pair.getOne() == null || pair.getTwo() == null) throw new RuntimeException("Each path in the split operator must have both a non-null filter and destination stream name."); } //TODO: Verify destination stream exists
// Path: src/main/java/org/calrissian/flowmix/api/Filter.java // public interface Filter extends Serializable { // // boolean accept(Event event); // } // // Path: src/main/java/org/calrissian/flowmix/api/filter/NoFilter.java // public class NoFilter implements Filter { // @Override public boolean accept(Event event) { // return true; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/SplitOp.java // public class SplitOp implements FlowOp{ // // public static final String SPLIT = "split"; // // // default path should just pass through to the next component in the chain // private Filter defaultPath; // // // events that path each given filter should go out to the stream with the specified id. // private List<Pair<Filter, String>> paths; // // public SplitOp(Filter defaultPath, List<Pair<Filter,String>> paths) { // this.defaultPath = defaultPath; // this.paths = paths; // } // // public Filter getDefaultPath() { // return defaultPath; // } // // public List<Pair<Filter,String>> getPaths() { // return paths; // } // // @Override public String getComponentName() { // return SPLIT; // } // } // Path: src/main/java/org/calrissian/flowmix/api/builder/SplitBuilder.java import java.util.ArrayList; import java.util.List; import org.calrissian.flowmix.api.Filter; import org.calrissian.flowmix.api.filter.NoFilter; import org.calrissian.flowmix.core.model.op.SplitOp; import org.calrissian.mango.domain.Pair; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.builder; public class SplitBuilder extends AbstractOpBuilder { private Filter defaultPath; private List<Pair<Filter, String>> paths = new ArrayList<Pair<Filter,String>>(); public SplitBuilder(StreamBuilder flowOpsBuilder) { super(flowOpsBuilder); } public SplitBuilder defaultPath(Filter filter) { this.defaultPath = filter; return this; } public SplitBuilder path(Filter filter, String destinationStream) { this.paths.add(new Pair<Filter,String>(filter, destinationStream)); return this; } public SplitBuilder all(String destinationStream) { this.paths.add(new Pair<Filter,String>(new NoFilter(), destinationStream)); return this; } @Override public StreamBuilder end() { for(Pair<Filter, String> pair : paths) { if(pair.getOne() == null || pair.getTwo() == null) throw new RuntimeException("Each path in the split operator must have both a non-null filter and destination stream name."); } //TODO: Verify destination stream exists
getStreamBuilder().addFlowOp(new SplitOp(defaultPath, paths));
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/Aggregator.java
// Path: src/main/java/org/calrissian/flowmix/core/model/event/AggregatedEvent.java // public class AggregatedEvent { // // private Event event; // private String previousStream; // // public AggregatedEvent(Event event, String previousStream) { // this.event = event; // this.previousStream = previousStream; // } // // public AggregatedEvent(Event event) { // this.event = event; // } // // public Event getEvent() { // return event; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // AggregatedEvent that = (AggregatedEvent) o; // // if (event != null ? !event.equals(that.event) : that.event != null) return false; // if (previousStream != null ? !previousStream.equals(that.previousStream) : that.previousStream != null) // return false; // // return true; // } // // @Override // public int hashCode() { // int result = event != null ? event.hashCode() : 0; // result = 31 * result + (previousStream != null ? previousStream.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "AggregatedEvent{" + // "event=" + event + // ", previousStream='" + previousStream + '\'' + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/support/window/WindowItem.java // public class WindowItem { // Event event; // long timestamp; // String previousStream; // // public WindowItem(Event event, long timestamp, String previousStream) { // this.event = event; // this.timestamp = timestamp; // this.previousStream = previousStream; // } // // public Event getEvent() { // return event; // } // // public long getTimestamp() { // return timestamp; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public String toString() { // return "WindowItem{" + // "event=" + event + // ", timestamp=" + timestamp + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/exceptions/FlowmixException.java // public class FlowmixException extends RuntimeException { // // public FlowmixException(String msg, Throwable t) { // super(msg, t); // } // // }
import java.io.Serializable; import java.util.List; import java.util.Map; import org.calrissian.flowmix.core.model.event.AggregatedEvent; import org.calrissian.flowmix.core.support.window.WindowItem; import org.calrissian.flowmix.exceptions.FlowmixException;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api; /** * An aggregator over a progressive/tumbling window allows aggregate values like * sums and averages to be maintained for some window at some point in time * without the whole window being available at any point in time. * * This is very useful for associative algorithms that can be implemented * without the entire dataset being available. Often this is good for reduce * functions that can summarize a dataset without the need to see each * individual point. * * Multiple events can be returned as the aggregate if necessary, this means * multiple aggregates could be maintained inside and emitted separately (i.e. * sum and count and sumsqaure, and average). */ public interface Aggregator extends Serializable { public static final String GROUP_BY = "groupBy"; public static final String GROUP_BY_DELIM = "\u0000"; void configure(Map<String, String> configuration);
// Path: src/main/java/org/calrissian/flowmix/core/model/event/AggregatedEvent.java // public class AggregatedEvent { // // private Event event; // private String previousStream; // // public AggregatedEvent(Event event, String previousStream) { // this.event = event; // this.previousStream = previousStream; // } // // public AggregatedEvent(Event event) { // this.event = event; // } // // public Event getEvent() { // return event; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // AggregatedEvent that = (AggregatedEvent) o; // // if (event != null ? !event.equals(that.event) : that.event != null) return false; // if (previousStream != null ? !previousStream.equals(that.previousStream) : that.previousStream != null) // return false; // // return true; // } // // @Override // public int hashCode() { // int result = event != null ? event.hashCode() : 0; // result = 31 * result + (previousStream != null ? previousStream.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "AggregatedEvent{" + // "event=" + event + // ", previousStream='" + previousStream + '\'' + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/support/window/WindowItem.java // public class WindowItem { // Event event; // long timestamp; // String previousStream; // // public WindowItem(Event event, long timestamp, String previousStream) { // this.event = event; // this.timestamp = timestamp; // this.previousStream = previousStream; // } // // public Event getEvent() { // return event; // } // // public long getTimestamp() { // return timestamp; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public String toString() { // return "WindowItem{" + // "event=" + event + // ", timestamp=" + timestamp + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/exceptions/FlowmixException.java // public class FlowmixException extends RuntimeException { // // public FlowmixException(String msg, Throwable t) { // super(msg, t); // } // // } // Path: src/main/java/org/calrissian/flowmix/api/Aggregator.java import java.io.Serializable; import java.util.List; import java.util.Map; import org.calrissian.flowmix.core.model.event.AggregatedEvent; import org.calrissian.flowmix.core.support.window.WindowItem; import org.calrissian.flowmix.exceptions.FlowmixException; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api; /** * An aggregator over a progressive/tumbling window allows aggregate values like * sums and averages to be maintained for some window at some point in time * without the whole window being available at any point in time. * * This is very useful for associative algorithms that can be implemented * without the entire dataset being available. Often this is good for reduce * functions that can summarize a dataset without the need to see each * individual point. * * Multiple events can be returned as the aggregate if necessary, this means * multiple aggregates could be maintained inside and emitted separately (i.e. * sum and count and sumsqaure, and average). */ public interface Aggregator extends Serializable { public static final String GROUP_BY = "groupBy"; public static final String GROUP_BY_DELIM = "\u0000"; void configure(Map<String, String> configuration);
void added(WindowItem item);
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/Aggregator.java
// Path: src/main/java/org/calrissian/flowmix/core/model/event/AggregatedEvent.java // public class AggregatedEvent { // // private Event event; // private String previousStream; // // public AggregatedEvent(Event event, String previousStream) { // this.event = event; // this.previousStream = previousStream; // } // // public AggregatedEvent(Event event) { // this.event = event; // } // // public Event getEvent() { // return event; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // AggregatedEvent that = (AggregatedEvent) o; // // if (event != null ? !event.equals(that.event) : that.event != null) return false; // if (previousStream != null ? !previousStream.equals(that.previousStream) : that.previousStream != null) // return false; // // return true; // } // // @Override // public int hashCode() { // int result = event != null ? event.hashCode() : 0; // result = 31 * result + (previousStream != null ? previousStream.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "AggregatedEvent{" + // "event=" + event + // ", previousStream='" + previousStream + '\'' + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/support/window/WindowItem.java // public class WindowItem { // Event event; // long timestamp; // String previousStream; // // public WindowItem(Event event, long timestamp, String previousStream) { // this.event = event; // this.timestamp = timestamp; // this.previousStream = previousStream; // } // // public Event getEvent() { // return event; // } // // public long getTimestamp() { // return timestamp; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public String toString() { // return "WindowItem{" + // "event=" + event + // ", timestamp=" + timestamp + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/exceptions/FlowmixException.java // public class FlowmixException extends RuntimeException { // // public FlowmixException(String msg, Throwable t) { // super(msg, t); // } // // }
import java.io.Serializable; import java.util.List; import java.util.Map; import org.calrissian.flowmix.core.model.event.AggregatedEvent; import org.calrissian.flowmix.core.support.window.WindowItem; import org.calrissian.flowmix.exceptions.FlowmixException;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api; /** * An aggregator over a progressive/tumbling window allows aggregate values like * sums and averages to be maintained for some window at some point in time * without the whole window being available at any point in time. * * This is very useful for associative algorithms that can be implemented * without the entire dataset being available. Often this is good for reduce * functions that can summarize a dataset without the need to see each * individual point. * * Multiple events can be returned as the aggregate if necessary, this means * multiple aggregates could be maintained inside and emitted separately (i.e. * sum and count and sumsqaure, and average). */ public interface Aggregator extends Serializable { public static final String GROUP_BY = "groupBy"; public static final String GROUP_BY_DELIM = "\u0000"; void configure(Map<String, String> configuration); void added(WindowItem item); void evicted(WindowItem item);
// Path: src/main/java/org/calrissian/flowmix/core/model/event/AggregatedEvent.java // public class AggregatedEvent { // // private Event event; // private String previousStream; // // public AggregatedEvent(Event event, String previousStream) { // this.event = event; // this.previousStream = previousStream; // } // // public AggregatedEvent(Event event) { // this.event = event; // } // // public Event getEvent() { // return event; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // AggregatedEvent that = (AggregatedEvent) o; // // if (event != null ? !event.equals(that.event) : that.event != null) return false; // if (previousStream != null ? !previousStream.equals(that.previousStream) : that.previousStream != null) // return false; // // return true; // } // // @Override // public int hashCode() { // int result = event != null ? event.hashCode() : 0; // result = 31 * result + (previousStream != null ? previousStream.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "AggregatedEvent{" + // "event=" + event + // ", previousStream='" + previousStream + '\'' + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/support/window/WindowItem.java // public class WindowItem { // Event event; // long timestamp; // String previousStream; // // public WindowItem(Event event, long timestamp, String previousStream) { // this.event = event; // this.timestamp = timestamp; // this.previousStream = previousStream; // } // // public Event getEvent() { // return event; // } // // public long getTimestamp() { // return timestamp; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public String toString() { // return "WindowItem{" + // "event=" + event + // ", timestamp=" + timestamp + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/exceptions/FlowmixException.java // public class FlowmixException extends RuntimeException { // // public FlowmixException(String msg, Throwable t) { // super(msg, t); // } // // } // Path: src/main/java/org/calrissian/flowmix/api/Aggregator.java import java.io.Serializable; import java.util.List; import java.util.Map; import org.calrissian.flowmix.core.model.event.AggregatedEvent; import org.calrissian.flowmix.core.support.window.WindowItem; import org.calrissian.flowmix.exceptions.FlowmixException; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api; /** * An aggregator over a progressive/tumbling window allows aggregate values like * sums and averages to be maintained for some window at some point in time * without the whole window being available at any point in time. * * This is very useful for associative algorithms that can be implemented * without the entire dataset being available. Often this is good for reduce * functions that can summarize a dataset without the need to see each * individual point. * * Multiple events can be returned as the aggregate if necessary, this means * multiple aggregates could be maintained inside and emitted separately (i.e. * sum and count and sumsqaure, and average). */ public interface Aggregator extends Serializable { public static final String GROUP_BY = "groupBy"; public static final String GROUP_BY_DELIM = "\u0000"; void configure(Map<String, String> configuration); void added(WindowItem item); void evicted(WindowItem item);
List<AggregatedEvent> aggregate();
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/builder/AggregateBuilder.java
// Path: src/main/java/org/calrissian/flowmix/api/Aggregator.java // public interface Aggregator extends Serializable { // // public static final String GROUP_BY = "groupBy"; // public static final String GROUP_BY_DELIM = "\u0000"; // // void configure(Map<String, String> configuration); // // void added(WindowItem item); // // void evicted(WindowItem item); // // List<AggregatedEvent> aggregate(); // } // // Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/AggregateOp.java // public class AggregateOp implements FlowOp, RequiresPartitioning { // // public static final String AGGREGATE = "aggregate"; // // private final Class<? extends Aggregator> aggregatorClass; // private final Policy triggerPolicy; // private final Policy evictionPolicy; // private final long triggerThreshold; // private final long evictionThreshold; // private final boolean clearOnTrigger; // // private long windowEvictMillis; // // private Map<String,String> config; // // public AggregateOp(Class<? extends Aggregator> aggregatorClass, Policy triggerPolicy, long triggerThreshold, // Policy evictionPolicy, long evictionThreshold, Map<String,String> config, boolean clearOnTrigger, // long windowEvictMillis) { // this.aggregatorClass = aggregatorClass; // this.triggerPolicy = triggerPolicy; // this.evictionPolicy = evictionPolicy; // this.triggerThreshold = triggerThreshold; // this.evictionThreshold = evictionThreshold; // this.config = config; // this.clearOnTrigger = clearOnTrigger; // this.windowEvictMillis = windowEvictMillis; // } // // public boolean isClearOnTrigger() { // return clearOnTrigger; // } // // public Class<? extends Aggregator> getAggregatorClass() { // return aggregatorClass; // } // // public Policy getTriggerPolicy() { // return triggerPolicy; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public long getTriggerThreshold() { // return triggerThreshold; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // public Map<String, String> getConfig() { // return config; // } // // public long getWindowEvictMillis() { // return windowEvictMillis; // } // // @Override // public String getComponentName() { // return AGGREGATE; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // }
import java.util.HashMap; import java.util.List; import java.util.Map; import org.calrissian.flowmix.api.Aggregator; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.AggregateOp; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import static java.util.Collections.EMPTY_LIST;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.builder; public class AggregateBuilder extends AbstractOpBuilder { private Class<? extends Aggregator> aggregatorClass;
// Path: src/main/java/org/calrissian/flowmix/api/Aggregator.java // public interface Aggregator extends Serializable { // // public static final String GROUP_BY = "groupBy"; // public static final String GROUP_BY_DELIM = "\u0000"; // // void configure(Map<String, String> configuration); // // void added(WindowItem item); // // void evicted(WindowItem item); // // List<AggregatedEvent> aggregate(); // } // // Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/AggregateOp.java // public class AggregateOp implements FlowOp, RequiresPartitioning { // // public static final String AGGREGATE = "aggregate"; // // private final Class<? extends Aggregator> aggregatorClass; // private final Policy triggerPolicy; // private final Policy evictionPolicy; // private final long triggerThreshold; // private final long evictionThreshold; // private final boolean clearOnTrigger; // // private long windowEvictMillis; // // private Map<String,String> config; // // public AggregateOp(Class<? extends Aggregator> aggregatorClass, Policy triggerPolicy, long triggerThreshold, // Policy evictionPolicy, long evictionThreshold, Map<String,String> config, boolean clearOnTrigger, // long windowEvictMillis) { // this.aggregatorClass = aggregatorClass; // this.triggerPolicy = triggerPolicy; // this.evictionPolicy = evictionPolicy; // this.triggerThreshold = triggerThreshold; // this.evictionThreshold = evictionThreshold; // this.config = config; // this.clearOnTrigger = clearOnTrigger; // this.windowEvictMillis = windowEvictMillis; // } // // public boolean isClearOnTrigger() { // return clearOnTrigger; // } // // public Class<? extends Aggregator> getAggregatorClass() { // return aggregatorClass; // } // // public Policy getTriggerPolicy() { // return triggerPolicy; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public long getTriggerThreshold() { // return triggerThreshold; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // public Map<String, String> getConfig() { // return config; // } // // public long getWindowEvictMillis() { // return windowEvictMillis; // } // // @Override // public String getComponentName() { // return AGGREGATE; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // } // Path: src/main/java/org/calrissian/flowmix/api/builder/AggregateBuilder.java import java.util.HashMap; import java.util.List; import java.util.Map; import org.calrissian.flowmix.api.Aggregator; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.AggregateOp; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import static java.util.Collections.EMPTY_LIST; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.builder; public class AggregateBuilder extends AbstractOpBuilder { private Class<? extends Aggregator> aggregatorClass;
private Policy triggerPolicy;
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/builder/AggregateBuilder.java
// Path: src/main/java/org/calrissian/flowmix/api/Aggregator.java // public interface Aggregator extends Serializable { // // public static final String GROUP_BY = "groupBy"; // public static final String GROUP_BY_DELIM = "\u0000"; // // void configure(Map<String, String> configuration); // // void added(WindowItem item); // // void evicted(WindowItem item); // // List<AggregatedEvent> aggregate(); // } // // Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/AggregateOp.java // public class AggregateOp implements FlowOp, RequiresPartitioning { // // public static final String AGGREGATE = "aggregate"; // // private final Class<? extends Aggregator> aggregatorClass; // private final Policy triggerPolicy; // private final Policy evictionPolicy; // private final long triggerThreshold; // private final long evictionThreshold; // private final boolean clearOnTrigger; // // private long windowEvictMillis; // // private Map<String,String> config; // // public AggregateOp(Class<? extends Aggregator> aggregatorClass, Policy triggerPolicy, long triggerThreshold, // Policy evictionPolicy, long evictionThreshold, Map<String,String> config, boolean clearOnTrigger, // long windowEvictMillis) { // this.aggregatorClass = aggregatorClass; // this.triggerPolicy = triggerPolicy; // this.evictionPolicy = evictionPolicy; // this.triggerThreshold = triggerThreshold; // this.evictionThreshold = evictionThreshold; // this.config = config; // this.clearOnTrigger = clearOnTrigger; // this.windowEvictMillis = windowEvictMillis; // } // // public boolean isClearOnTrigger() { // return clearOnTrigger; // } // // public Class<? extends Aggregator> getAggregatorClass() { // return aggregatorClass; // } // // public Policy getTriggerPolicy() { // return triggerPolicy; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public long getTriggerThreshold() { // return triggerThreshold; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // public Map<String, String> getConfig() { // return config; // } // // public long getWindowEvictMillis() { // return windowEvictMillis; // } // // @Override // public String getComponentName() { // return AGGREGATE; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // }
import java.util.HashMap; import java.util.List; import java.util.Map; import org.calrissian.flowmix.api.Aggregator; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.AggregateOp; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import static java.util.Collections.EMPTY_LIST;
} public AggregateBuilder trigger(Policy policy, long threshold) { this.triggerPolicy = policy; this.triggerThreshold = threshold; return this; } public AggregateBuilder evict(Policy policy, long threshold) { this.evictionPolicy = policy; this.evictionThreshold = threshold; return this; } public AggregateBuilder windowEvictMillis(long millis) { this.windowEvictMillis = millis; return this; } public StreamBuilder end() { if(aggregatorClass == null) throw new RuntimeException("Aggregator operator needs an aggregator class"); if(triggerPolicy == null || triggerThreshold == -1) throw new RuntimeException("Aggregator operator needs to have trigger policy and threshold"); if(evictionPolicy == null || evictionThreshold == -1) throw new RuntimeException("Aggregator operator needs to have eviction policy and threshold");
// Path: src/main/java/org/calrissian/flowmix/api/Aggregator.java // public interface Aggregator extends Serializable { // // public static final String GROUP_BY = "groupBy"; // public static final String GROUP_BY_DELIM = "\u0000"; // // void configure(Map<String, String> configuration); // // void added(WindowItem item); // // void evicted(WindowItem item); // // List<AggregatedEvent> aggregate(); // } // // Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/AggregateOp.java // public class AggregateOp implements FlowOp, RequiresPartitioning { // // public static final String AGGREGATE = "aggregate"; // // private final Class<? extends Aggregator> aggregatorClass; // private final Policy triggerPolicy; // private final Policy evictionPolicy; // private final long triggerThreshold; // private final long evictionThreshold; // private final boolean clearOnTrigger; // // private long windowEvictMillis; // // private Map<String,String> config; // // public AggregateOp(Class<? extends Aggregator> aggregatorClass, Policy triggerPolicy, long triggerThreshold, // Policy evictionPolicy, long evictionThreshold, Map<String,String> config, boolean clearOnTrigger, // long windowEvictMillis) { // this.aggregatorClass = aggregatorClass; // this.triggerPolicy = triggerPolicy; // this.evictionPolicy = evictionPolicy; // this.triggerThreshold = triggerThreshold; // this.evictionThreshold = evictionThreshold; // this.config = config; // this.clearOnTrigger = clearOnTrigger; // this.windowEvictMillis = windowEvictMillis; // } // // public boolean isClearOnTrigger() { // return clearOnTrigger; // } // // public Class<? extends Aggregator> getAggregatorClass() { // return aggregatorClass; // } // // public Policy getTriggerPolicy() { // return triggerPolicy; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public long getTriggerThreshold() { // return triggerThreshold; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // public Map<String, String> getConfig() { // return config; // } // // public long getWindowEvictMillis() { // return windowEvictMillis; // } // // @Override // public String getComponentName() { // return AGGREGATE; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // } // Path: src/main/java/org/calrissian/flowmix/api/builder/AggregateBuilder.java import java.util.HashMap; import java.util.List; import java.util.Map; import org.calrissian.flowmix.api.Aggregator; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.AggregateOp; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import static java.util.Collections.EMPTY_LIST; } public AggregateBuilder trigger(Policy policy, long threshold) { this.triggerPolicy = policy; this.triggerThreshold = threshold; return this; } public AggregateBuilder evict(Policy policy, long threshold) { this.evictionPolicy = policy; this.evictionThreshold = threshold; return this; } public AggregateBuilder windowEvictMillis(long millis) { this.windowEvictMillis = millis; return this; } public StreamBuilder end() { if(aggregatorClass == null) throw new RuntimeException("Aggregator operator needs an aggregator class"); if(triggerPolicy == null || triggerThreshold == -1) throw new RuntimeException("Aggregator operator needs to have trigger policy and threshold"); if(evictionPolicy == null || evictionThreshold == -1) throw new RuntimeException("Aggregator operator needs to have eviction policy and threshold");
List<FlowOp> flowOpList = getStreamBuilder().getFlowOpList();
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/builder/AggregateBuilder.java
// Path: src/main/java/org/calrissian/flowmix/api/Aggregator.java // public interface Aggregator extends Serializable { // // public static final String GROUP_BY = "groupBy"; // public static final String GROUP_BY_DELIM = "\u0000"; // // void configure(Map<String, String> configuration); // // void added(WindowItem item); // // void evicted(WindowItem item); // // List<AggregatedEvent> aggregate(); // } // // Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/AggregateOp.java // public class AggregateOp implements FlowOp, RequiresPartitioning { // // public static final String AGGREGATE = "aggregate"; // // private final Class<? extends Aggregator> aggregatorClass; // private final Policy triggerPolicy; // private final Policy evictionPolicy; // private final long triggerThreshold; // private final long evictionThreshold; // private final boolean clearOnTrigger; // // private long windowEvictMillis; // // private Map<String,String> config; // // public AggregateOp(Class<? extends Aggregator> aggregatorClass, Policy triggerPolicy, long triggerThreshold, // Policy evictionPolicy, long evictionThreshold, Map<String,String> config, boolean clearOnTrigger, // long windowEvictMillis) { // this.aggregatorClass = aggregatorClass; // this.triggerPolicy = triggerPolicy; // this.evictionPolicy = evictionPolicy; // this.triggerThreshold = triggerThreshold; // this.evictionThreshold = evictionThreshold; // this.config = config; // this.clearOnTrigger = clearOnTrigger; // this.windowEvictMillis = windowEvictMillis; // } // // public boolean isClearOnTrigger() { // return clearOnTrigger; // } // // public Class<? extends Aggregator> getAggregatorClass() { // return aggregatorClass; // } // // public Policy getTriggerPolicy() { // return triggerPolicy; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public long getTriggerThreshold() { // return triggerThreshold; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // public Map<String, String> getConfig() { // return config; // } // // public long getWindowEvictMillis() { // return windowEvictMillis; // } // // @Override // public String getComponentName() { // return AGGREGATE; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // }
import java.util.HashMap; import java.util.List; import java.util.Map; import org.calrissian.flowmix.api.Aggregator; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.AggregateOp; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import static java.util.Collections.EMPTY_LIST;
public AggregateBuilder trigger(Policy policy, long threshold) { this.triggerPolicy = policy; this.triggerThreshold = threshold; return this; } public AggregateBuilder evict(Policy policy, long threshold) { this.evictionPolicy = policy; this.evictionThreshold = threshold; return this; } public AggregateBuilder windowEvictMillis(long millis) { this.windowEvictMillis = millis; return this; } public StreamBuilder end() { if(aggregatorClass == null) throw new RuntimeException("Aggregator operator needs an aggregator class"); if(triggerPolicy == null || triggerThreshold == -1) throw new RuntimeException("Aggregator operator needs to have trigger policy and threshold"); if(evictionPolicy == null || evictionThreshold == -1) throw new RuntimeException("Aggregator operator needs to have eviction policy and threshold"); List<FlowOp> flowOpList = getStreamBuilder().getFlowOpList(); FlowOp op = flowOpList.size() == 0 ? null : flowOpList.get(flowOpList.size()-1);
// Path: src/main/java/org/calrissian/flowmix/api/Aggregator.java // public interface Aggregator extends Serializable { // // public static final String GROUP_BY = "groupBy"; // public static final String GROUP_BY_DELIM = "\u0000"; // // void configure(Map<String, String> configuration); // // void added(WindowItem item); // // void evicted(WindowItem item); // // List<AggregatedEvent> aggregate(); // } // // Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/AggregateOp.java // public class AggregateOp implements FlowOp, RequiresPartitioning { // // public static final String AGGREGATE = "aggregate"; // // private final Class<? extends Aggregator> aggregatorClass; // private final Policy triggerPolicy; // private final Policy evictionPolicy; // private final long triggerThreshold; // private final long evictionThreshold; // private final boolean clearOnTrigger; // // private long windowEvictMillis; // // private Map<String,String> config; // // public AggregateOp(Class<? extends Aggregator> aggregatorClass, Policy triggerPolicy, long triggerThreshold, // Policy evictionPolicy, long evictionThreshold, Map<String,String> config, boolean clearOnTrigger, // long windowEvictMillis) { // this.aggregatorClass = aggregatorClass; // this.triggerPolicy = triggerPolicy; // this.evictionPolicy = evictionPolicy; // this.triggerThreshold = triggerThreshold; // this.evictionThreshold = evictionThreshold; // this.config = config; // this.clearOnTrigger = clearOnTrigger; // this.windowEvictMillis = windowEvictMillis; // } // // public boolean isClearOnTrigger() { // return clearOnTrigger; // } // // public Class<? extends Aggregator> getAggregatorClass() { // return aggregatorClass; // } // // public Policy getTriggerPolicy() { // return triggerPolicy; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public long getTriggerThreshold() { // return triggerThreshold; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // public Map<String, String> getConfig() { // return config; // } // // public long getWindowEvictMillis() { // return windowEvictMillis; // } // // @Override // public String getComponentName() { // return AGGREGATE; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // } // Path: src/main/java/org/calrissian/flowmix/api/builder/AggregateBuilder.java import java.util.HashMap; import java.util.List; import java.util.Map; import org.calrissian.flowmix.api.Aggregator; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.AggregateOp; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import static java.util.Collections.EMPTY_LIST; public AggregateBuilder trigger(Policy policy, long threshold) { this.triggerPolicy = policy; this.triggerThreshold = threshold; return this; } public AggregateBuilder evict(Policy policy, long threshold) { this.evictionPolicy = policy; this.evictionThreshold = threshold; return this; } public AggregateBuilder windowEvictMillis(long millis) { this.windowEvictMillis = millis; return this; } public StreamBuilder end() { if(aggregatorClass == null) throw new RuntimeException("Aggregator operator needs an aggregator class"); if(triggerPolicy == null || triggerThreshold == -1) throw new RuntimeException("Aggregator operator needs to have trigger policy and threshold"); if(evictionPolicy == null || evictionThreshold == -1) throw new RuntimeException("Aggregator operator needs to have eviction policy and threshold"); List<FlowOp> flowOpList = getStreamBuilder().getFlowOpList(); FlowOp op = flowOpList.size() == 0 ? null : flowOpList.get(flowOpList.size()-1);
if(op == null || !(op instanceof PartitionOp))
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/builder/AggregateBuilder.java
// Path: src/main/java/org/calrissian/flowmix/api/Aggregator.java // public interface Aggregator extends Serializable { // // public static final String GROUP_BY = "groupBy"; // public static final String GROUP_BY_DELIM = "\u0000"; // // void configure(Map<String, String> configuration); // // void added(WindowItem item); // // void evicted(WindowItem item); // // List<AggregatedEvent> aggregate(); // } // // Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/AggregateOp.java // public class AggregateOp implements FlowOp, RequiresPartitioning { // // public static final String AGGREGATE = "aggregate"; // // private final Class<? extends Aggregator> aggregatorClass; // private final Policy triggerPolicy; // private final Policy evictionPolicy; // private final long triggerThreshold; // private final long evictionThreshold; // private final boolean clearOnTrigger; // // private long windowEvictMillis; // // private Map<String,String> config; // // public AggregateOp(Class<? extends Aggregator> aggregatorClass, Policy triggerPolicy, long triggerThreshold, // Policy evictionPolicy, long evictionThreshold, Map<String,String> config, boolean clearOnTrigger, // long windowEvictMillis) { // this.aggregatorClass = aggregatorClass; // this.triggerPolicy = triggerPolicy; // this.evictionPolicy = evictionPolicy; // this.triggerThreshold = triggerThreshold; // this.evictionThreshold = evictionThreshold; // this.config = config; // this.clearOnTrigger = clearOnTrigger; // this.windowEvictMillis = windowEvictMillis; // } // // public boolean isClearOnTrigger() { // return clearOnTrigger; // } // // public Class<? extends Aggregator> getAggregatorClass() { // return aggregatorClass; // } // // public Policy getTriggerPolicy() { // return triggerPolicy; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public long getTriggerThreshold() { // return triggerThreshold; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // public Map<String, String> getConfig() { // return config; // } // // public long getWindowEvictMillis() { // return windowEvictMillis; // } // // @Override // public String getComponentName() { // return AGGREGATE; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // }
import java.util.HashMap; import java.util.List; import java.util.Map; import org.calrissian.flowmix.api.Aggregator; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.AggregateOp; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import static java.util.Collections.EMPTY_LIST;
return this; } public AggregateBuilder evict(Policy policy, long threshold) { this.evictionPolicy = policy; this.evictionThreshold = threshold; return this; } public AggregateBuilder windowEvictMillis(long millis) { this.windowEvictMillis = millis; return this; } public StreamBuilder end() { if(aggregatorClass == null) throw new RuntimeException("Aggregator operator needs an aggregator class"); if(triggerPolicy == null || triggerThreshold == -1) throw new RuntimeException("Aggregator operator needs to have trigger policy and threshold"); if(evictionPolicy == null || evictionThreshold == -1) throw new RuntimeException("Aggregator operator needs to have eviction policy and threshold"); List<FlowOp> flowOpList = getStreamBuilder().getFlowOpList(); FlowOp op = flowOpList.size() == 0 ? null : flowOpList.get(flowOpList.size()-1); if(op == null || !(op instanceof PartitionOp)) flowOpList.add(new PartitionOp(EMPTY_LIST));
// Path: src/main/java/org/calrissian/flowmix/api/Aggregator.java // public interface Aggregator extends Serializable { // // public static final String GROUP_BY = "groupBy"; // public static final String GROUP_BY_DELIM = "\u0000"; // // void configure(Map<String, String> configuration); // // void added(WindowItem item); // // void evicted(WindowItem item); // // List<AggregatedEvent> aggregate(); // } // // Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/AggregateOp.java // public class AggregateOp implements FlowOp, RequiresPartitioning { // // public static final String AGGREGATE = "aggregate"; // // private final Class<? extends Aggregator> aggregatorClass; // private final Policy triggerPolicy; // private final Policy evictionPolicy; // private final long triggerThreshold; // private final long evictionThreshold; // private final boolean clearOnTrigger; // // private long windowEvictMillis; // // private Map<String,String> config; // // public AggregateOp(Class<? extends Aggregator> aggregatorClass, Policy triggerPolicy, long triggerThreshold, // Policy evictionPolicy, long evictionThreshold, Map<String,String> config, boolean clearOnTrigger, // long windowEvictMillis) { // this.aggregatorClass = aggregatorClass; // this.triggerPolicy = triggerPolicy; // this.evictionPolicy = evictionPolicy; // this.triggerThreshold = triggerThreshold; // this.evictionThreshold = evictionThreshold; // this.config = config; // this.clearOnTrigger = clearOnTrigger; // this.windowEvictMillis = windowEvictMillis; // } // // public boolean isClearOnTrigger() { // return clearOnTrigger; // } // // public Class<? extends Aggregator> getAggregatorClass() { // return aggregatorClass; // } // // public Policy getTriggerPolicy() { // return triggerPolicy; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public long getTriggerThreshold() { // return triggerThreshold; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // public Map<String, String> getConfig() { // return config; // } // // public long getWindowEvictMillis() { // return windowEvictMillis; // } // // @Override // public String getComponentName() { // return AGGREGATE; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // } // Path: src/main/java/org/calrissian/flowmix/api/builder/AggregateBuilder.java import java.util.HashMap; import java.util.List; import java.util.Map; import org.calrissian.flowmix.api.Aggregator; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.AggregateOp; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import static java.util.Collections.EMPTY_LIST; return this; } public AggregateBuilder evict(Policy policy, long threshold) { this.evictionPolicy = policy; this.evictionThreshold = threshold; return this; } public AggregateBuilder windowEvictMillis(long millis) { this.windowEvictMillis = millis; return this; } public StreamBuilder end() { if(aggregatorClass == null) throw new RuntimeException("Aggregator operator needs an aggregator class"); if(triggerPolicy == null || triggerThreshold == -1) throw new RuntimeException("Aggregator operator needs to have trigger policy and threshold"); if(evictionPolicy == null || evictionThreshold == -1) throw new RuntimeException("Aggregator operator needs to have eviction policy and threshold"); List<FlowOp> flowOpList = getStreamBuilder().getFlowOpList(); FlowOp op = flowOpList.size() == 0 ? null : flowOpList.get(flowOpList.size()-1); if(op == null || !(op instanceof PartitionOp)) flowOpList.add(new PartitionOp(EMPTY_LIST));
getStreamBuilder().addFlowOp(new AggregateOp(aggregatorClass, triggerPolicy, triggerThreshold, evictionPolicy,
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/builder/SwitchBuilder.java
// Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/SwitchOp.java // public class SwitchOp implements FlowOp, RequiresPartitioning { // // public static final String SWITCH = "stopGate"; // private Policy openPolicy; // private Policy evictionPolicy; // private Policy closePolicy; // // private long openThreshold; // private long evictionThreshold; // private long closeThreshold; // // public SwitchOp(Policy openPolicy, Policy evictionPolicy, Policy closePolicy, long openThreshold, // long evictionThreshold, long closeThreshold) { // this.openPolicy = openPolicy; // this.evictionPolicy = evictionPolicy; // this.closePolicy = closePolicy; // this.openThreshold = openThreshold; // this.evictionThreshold = evictionThreshold; // this.closeThreshold = closeThreshold; // } // // public Policy getOpenPolicy() { // return openPolicy; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public Policy getClosePolicy() { // return closePolicy; // } // // public long getOpenThreshold() { // return openThreshold; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // public long getCloseThreshold() { // return closeThreshold; // } // // @Override // public String getComponentName() { // return SWITCH; // } // }
import java.util.List; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import org.calrissian.flowmix.core.model.op.SwitchOp; import static java.util.Collections.EMPTY_LIST;
public SwitchBuilder open(Policy policy, long threshold) { this.openPolicy = policy; this.openThreshold = threshold; return this; } public SwitchBuilder evict(Policy policy, long threshold) { this.evictionPolicy = policy; this.evictionThreshold = threshold; return this; } public SwitchBuilder close(Policy policy, long openThreshold) { this.closePolicy = policy; this.closeThreshold = openThreshold; return this; } @Override public StreamBuilder end() { if(openPolicy == null || openThreshold == -1) throw new RuntimeException("Stop gate operator must have an activation policy and threshold"); if(evictionPolicy == null || evictionThreshold == -1) throw new RuntimeException("Stop gate operator must have an eviction policy and threshold"); if(closePolicy == null || closeThreshold == -1) throw new RuntimeException("Stop gate operator must have an close policy and threshold");
// Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/SwitchOp.java // public class SwitchOp implements FlowOp, RequiresPartitioning { // // public static final String SWITCH = "stopGate"; // private Policy openPolicy; // private Policy evictionPolicy; // private Policy closePolicy; // // private long openThreshold; // private long evictionThreshold; // private long closeThreshold; // // public SwitchOp(Policy openPolicy, Policy evictionPolicy, Policy closePolicy, long openThreshold, // long evictionThreshold, long closeThreshold) { // this.openPolicy = openPolicy; // this.evictionPolicy = evictionPolicy; // this.closePolicy = closePolicy; // this.openThreshold = openThreshold; // this.evictionThreshold = evictionThreshold; // this.closeThreshold = closeThreshold; // } // // public Policy getOpenPolicy() { // return openPolicy; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public Policy getClosePolicy() { // return closePolicy; // } // // public long getOpenThreshold() { // return openThreshold; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // public long getCloseThreshold() { // return closeThreshold; // } // // @Override // public String getComponentName() { // return SWITCH; // } // } // Path: src/main/java/org/calrissian/flowmix/api/builder/SwitchBuilder.java import java.util.List; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import org.calrissian.flowmix.core.model.op.SwitchOp; import static java.util.Collections.EMPTY_LIST; public SwitchBuilder open(Policy policy, long threshold) { this.openPolicy = policy; this.openThreshold = threshold; return this; } public SwitchBuilder evict(Policy policy, long threshold) { this.evictionPolicy = policy; this.evictionThreshold = threshold; return this; } public SwitchBuilder close(Policy policy, long openThreshold) { this.closePolicy = policy; this.closeThreshold = openThreshold; return this; } @Override public StreamBuilder end() { if(openPolicy == null || openThreshold == -1) throw new RuntimeException("Stop gate operator must have an activation policy and threshold"); if(evictionPolicy == null || evictionThreshold == -1) throw new RuntimeException("Stop gate operator must have an eviction policy and threshold"); if(closePolicy == null || closeThreshold == -1) throw new RuntimeException("Stop gate operator must have an close policy and threshold");
List<FlowOp> flowOpList = getStreamBuilder().getFlowOpList();
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/builder/SwitchBuilder.java
// Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/SwitchOp.java // public class SwitchOp implements FlowOp, RequiresPartitioning { // // public static final String SWITCH = "stopGate"; // private Policy openPolicy; // private Policy evictionPolicy; // private Policy closePolicy; // // private long openThreshold; // private long evictionThreshold; // private long closeThreshold; // // public SwitchOp(Policy openPolicy, Policy evictionPolicy, Policy closePolicy, long openThreshold, // long evictionThreshold, long closeThreshold) { // this.openPolicy = openPolicy; // this.evictionPolicy = evictionPolicy; // this.closePolicy = closePolicy; // this.openThreshold = openThreshold; // this.evictionThreshold = evictionThreshold; // this.closeThreshold = closeThreshold; // } // // public Policy getOpenPolicy() { // return openPolicy; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public Policy getClosePolicy() { // return closePolicy; // } // // public long getOpenThreshold() { // return openThreshold; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // public long getCloseThreshold() { // return closeThreshold; // } // // @Override // public String getComponentName() { // return SWITCH; // } // }
import java.util.List; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import org.calrissian.flowmix.core.model.op.SwitchOp; import static java.util.Collections.EMPTY_LIST;
this.openThreshold = threshold; return this; } public SwitchBuilder evict(Policy policy, long threshold) { this.evictionPolicy = policy; this.evictionThreshold = threshold; return this; } public SwitchBuilder close(Policy policy, long openThreshold) { this.closePolicy = policy; this.closeThreshold = openThreshold; return this; } @Override public StreamBuilder end() { if(openPolicy == null || openThreshold == -1) throw new RuntimeException("Stop gate operator must have an activation policy and threshold"); if(evictionPolicy == null || evictionThreshold == -1) throw new RuntimeException("Stop gate operator must have an eviction policy and threshold"); if(closePolicy == null || closeThreshold == -1) throw new RuntimeException("Stop gate operator must have an close policy and threshold"); List<FlowOp> flowOpList = getStreamBuilder().getFlowOpList(); FlowOp op = flowOpList.size() == 0 ? null : flowOpList.get(flowOpList.size()-1);
// Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/SwitchOp.java // public class SwitchOp implements FlowOp, RequiresPartitioning { // // public static final String SWITCH = "stopGate"; // private Policy openPolicy; // private Policy evictionPolicy; // private Policy closePolicy; // // private long openThreshold; // private long evictionThreshold; // private long closeThreshold; // // public SwitchOp(Policy openPolicy, Policy evictionPolicy, Policy closePolicy, long openThreshold, // long evictionThreshold, long closeThreshold) { // this.openPolicy = openPolicy; // this.evictionPolicy = evictionPolicy; // this.closePolicy = closePolicy; // this.openThreshold = openThreshold; // this.evictionThreshold = evictionThreshold; // this.closeThreshold = closeThreshold; // } // // public Policy getOpenPolicy() { // return openPolicy; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public Policy getClosePolicy() { // return closePolicy; // } // // public long getOpenThreshold() { // return openThreshold; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // public long getCloseThreshold() { // return closeThreshold; // } // // @Override // public String getComponentName() { // return SWITCH; // } // } // Path: src/main/java/org/calrissian/flowmix/api/builder/SwitchBuilder.java import java.util.List; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import org.calrissian.flowmix.core.model.op.SwitchOp; import static java.util.Collections.EMPTY_LIST; this.openThreshold = threshold; return this; } public SwitchBuilder evict(Policy policy, long threshold) { this.evictionPolicy = policy; this.evictionThreshold = threshold; return this; } public SwitchBuilder close(Policy policy, long openThreshold) { this.closePolicy = policy; this.closeThreshold = openThreshold; return this; } @Override public StreamBuilder end() { if(openPolicy == null || openThreshold == -1) throw new RuntimeException("Stop gate operator must have an activation policy and threshold"); if(evictionPolicy == null || evictionThreshold == -1) throw new RuntimeException("Stop gate operator must have an eviction policy and threshold"); if(closePolicy == null || closeThreshold == -1) throw new RuntimeException("Stop gate operator must have an close policy and threshold"); List<FlowOp> flowOpList = getStreamBuilder().getFlowOpList(); FlowOp op = flowOpList.size() == 0 ? null : flowOpList.get(flowOpList.size()-1);
if(op == null || !(op instanceof PartitionOp))
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/builder/SwitchBuilder.java
// Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/SwitchOp.java // public class SwitchOp implements FlowOp, RequiresPartitioning { // // public static final String SWITCH = "stopGate"; // private Policy openPolicy; // private Policy evictionPolicy; // private Policy closePolicy; // // private long openThreshold; // private long evictionThreshold; // private long closeThreshold; // // public SwitchOp(Policy openPolicy, Policy evictionPolicy, Policy closePolicy, long openThreshold, // long evictionThreshold, long closeThreshold) { // this.openPolicy = openPolicy; // this.evictionPolicy = evictionPolicy; // this.closePolicy = closePolicy; // this.openThreshold = openThreshold; // this.evictionThreshold = evictionThreshold; // this.closeThreshold = closeThreshold; // } // // public Policy getOpenPolicy() { // return openPolicy; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public Policy getClosePolicy() { // return closePolicy; // } // // public long getOpenThreshold() { // return openThreshold; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // public long getCloseThreshold() { // return closeThreshold; // } // // @Override // public String getComponentName() { // return SWITCH; // } // }
import java.util.List; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import org.calrissian.flowmix.core.model.op.SwitchOp; import static java.util.Collections.EMPTY_LIST;
public SwitchBuilder evict(Policy policy, long threshold) { this.evictionPolicy = policy; this.evictionThreshold = threshold; return this; } public SwitchBuilder close(Policy policy, long openThreshold) { this.closePolicy = policy; this.closeThreshold = openThreshold; return this; } @Override public StreamBuilder end() { if(openPolicy == null || openThreshold == -1) throw new RuntimeException("Stop gate operator must have an activation policy and threshold"); if(evictionPolicy == null || evictionThreshold == -1) throw new RuntimeException("Stop gate operator must have an eviction policy and threshold"); if(closePolicy == null || closeThreshold == -1) throw new RuntimeException("Stop gate operator must have an close policy and threshold"); List<FlowOp> flowOpList = getStreamBuilder().getFlowOpList(); FlowOp op = flowOpList.size() == 0 ? null : flowOpList.get(flowOpList.size()-1); if(op == null || !(op instanceof PartitionOp)) flowOpList.add(new PartitionOp(EMPTY_LIST));
// Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/SwitchOp.java // public class SwitchOp implements FlowOp, RequiresPartitioning { // // public static final String SWITCH = "stopGate"; // private Policy openPolicy; // private Policy evictionPolicy; // private Policy closePolicy; // // private long openThreshold; // private long evictionThreshold; // private long closeThreshold; // // public SwitchOp(Policy openPolicy, Policy evictionPolicy, Policy closePolicy, long openThreshold, // long evictionThreshold, long closeThreshold) { // this.openPolicy = openPolicy; // this.evictionPolicy = evictionPolicy; // this.closePolicy = closePolicy; // this.openThreshold = openThreshold; // this.evictionThreshold = evictionThreshold; // this.closeThreshold = closeThreshold; // } // // public Policy getOpenPolicy() { // return openPolicy; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public Policy getClosePolicy() { // return closePolicy; // } // // public long getOpenThreshold() { // return openThreshold; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // public long getCloseThreshold() { // return closeThreshold; // } // // @Override // public String getComponentName() { // return SWITCH; // } // } // Path: src/main/java/org/calrissian/flowmix/api/builder/SwitchBuilder.java import java.util.List; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import org.calrissian.flowmix.core.model.op.SwitchOp; import static java.util.Collections.EMPTY_LIST; public SwitchBuilder evict(Policy policy, long threshold) { this.evictionPolicy = policy; this.evictionThreshold = threshold; return this; } public SwitchBuilder close(Policy policy, long openThreshold) { this.closePolicy = policy; this.closeThreshold = openThreshold; return this; } @Override public StreamBuilder end() { if(openPolicy == null || openThreshold == -1) throw new RuntimeException("Stop gate operator must have an activation policy and threshold"); if(evictionPolicy == null || evictionThreshold == -1) throw new RuntimeException("Stop gate operator must have an eviction policy and threshold"); if(closePolicy == null || closeThreshold == -1) throw new RuntimeException("Stop gate operator must have an close policy and threshold"); List<FlowOp> flowOpList = getStreamBuilder().getFlowOpList(); FlowOp op = flowOpList.size() == 0 ? null : flowOpList.get(flowOpList.size()-1); if(op == null || !(op instanceof PartitionOp)) flowOpList.add(new PartitionOp(EMPTY_LIST));
getStreamBuilder().addFlowOp(new SwitchOp(openPolicy, evictionPolicy, closePolicy,
calrissian/flowmix
src/test/java/org/calrissian/flowmix/core/support/UtilsTest.java
// Path: src/main/java/org/calrissian/flowmix/core/support/Utils.java // public static String buildKeyIndexForEvent(Event event, List<String> groupBy) { // StringBuffer stringBuffer = new StringBuffer(); // // if(groupBy == null || groupBy.size() == 0) // return stringBuffer.toString(); // default partition when no groupBy fields are specified. // // for(String groupField : groupBy) { // Collection<Tuple> tuples = event.getAll(groupField); // SortedSet<String> values = new TreeSet<String>(); // // if(tuples == null) { // values.add(""); // } else { // for(Tuple tuple : tuples) // values.add(registry.encode(tuple.getValue())); // } // stringBuffer.append(groupField + join(values, "") + "|"); // } // try { // return stringBuffer.toString(); // } catch (Exception e) { // return null; // } // }
import java.util.Arrays; import java.util.Collections; import org.calrissian.mango.domain.Tuple; import org.calrissian.mango.domain.event.BaseEvent; import org.calrissian.mango.domain.event.Event; import org.junit.Test; import static java.lang.System.currentTimeMillis; import static java.util.Collections.EMPTY_LIST; import static java.util.UUID.randomUUID; import static org.calrissian.flowmix.core.support.Utils.buildKeyIndexForEvent; import static org.junit.Assert.assertEquals;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.support; public class UtilsTest { @Test public void test_buildKeyIndexForEvent_noGroupBy() {
// Path: src/main/java/org/calrissian/flowmix/core/support/Utils.java // public static String buildKeyIndexForEvent(Event event, List<String> groupBy) { // StringBuffer stringBuffer = new StringBuffer(); // // if(groupBy == null || groupBy.size() == 0) // return stringBuffer.toString(); // default partition when no groupBy fields are specified. // // for(String groupField : groupBy) { // Collection<Tuple> tuples = event.getAll(groupField); // SortedSet<String> values = new TreeSet<String>(); // // if(tuples == null) { // values.add(""); // } else { // for(Tuple tuple : tuples) // values.add(registry.encode(tuple.getValue())); // } // stringBuffer.append(groupField + join(values, "") + "|"); // } // try { // return stringBuffer.toString(); // } catch (Exception e) { // return null; // } // } // Path: src/test/java/org/calrissian/flowmix/core/support/UtilsTest.java import java.util.Arrays; import java.util.Collections; import org.calrissian.mango.domain.Tuple; import org.calrissian.mango.domain.event.BaseEvent; import org.calrissian.mango.domain.event.Event; import org.junit.Test; import static java.lang.System.currentTimeMillis; import static java.util.Collections.EMPTY_LIST; import static java.util.UUID.randomUUID; import static org.calrissian.flowmix.core.support.Utils.buildKeyIndexForEvent; import static org.junit.Assert.assertEquals; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.support; public class UtilsTest { @Test public void test_buildKeyIndexForEvent_noGroupBy() {
String hash = buildKeyIndexForEvent("one", buildTestEvent(), EMPTY_LIST);
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/builder/JoinBuilder.java
// Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/JoinOp.java // public class JoinOp implements FlowOp, RequiresPartitioning { // // public static final String JOIN = "join"; // // String leftStream; // String rightStream; // // Policy evictionPolicy; // long evictionThreshold; // // public JoinOp(String leftStream, String rightStream, Policy evictionPolicy, long evictionThreshold) { // this.leftStream = leftStream; // this.rightStream = rightStream; // this.evictionPolicy = evictionPolicy; // this.evictionThreshold = evictionThreshold; // } // // public String getLeftStream() { // return leftStream; // } // // public String getRightStream() { // return rightStream; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // @Override // public String getComponentName() { // return "join"; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // }
import java.util.List; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.JoinOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import static java.util.Collections.EMPTY_LIST;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.builder; public class JoinBuilder extends AbstractOpBuilder{ String lhs; String rhs;
// Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/JoinOp.java // public class JoinOp implements FlowOp, RequiresPartitioning { // // public static final String JOIN = "join"; // // String leftStream; // String rightStream; // // Policy evictionPolicy; // long evictionThreshold; // // public JoinOp(String leftStream, String rightStream, Policy evictionPolicy, long evictionThreshold) { // this.leftStream = leftStream; // this.rightStream = rightStream; // this.evictionPolicy = evictionPolicy; // this.evictionThreshold = evictionThreshold; // } // // public String getLeftStream() { // return leftStream; // } // // public String getRightStream() { // return rightStream; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // @Override // public String getComponentName() { // return "join"; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // } // Path: src/main/java/org/calrissian/flowmix/api/builder/JoinBuilder.java import java.util.List; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.JoinOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import static java.util.Collections.EMPTY_LIST; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.builder; public class JoinBuilder extends AbstractOpBuilder{ String lhs; String rhs;
Policy evictionPolicy;
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/builder/JoinBuilder.java
// Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/JoinOp.java // public class JoinOp implements FlowOp, RequiresPartitioning { // // public static final String JOIN = "join"; // // String leftStream; // String rightStream; // // Policy evictionPolicy; // long evictionThreshold; // // public JoinOp(String leftStream, String rightStream, Policy evictionPolicy, long evictionThreshold) { // this.leftStream = leftStream; // this.rightStream = rightStream; // this.evictionPolicy = evictionPolicy; // this.evictionThreshold = evictionThreshold; // } // // public String getLeftStream() { // return leftStream; // } // // public String getRightStream() { // return rightStream; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // @Override // public String getComponentName() { // return "join"; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // }
import java.util.List; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.JoinOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import static java.util.Collections.EMPTY_LIST;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.builder; public class JoinBuilder extends AbstractOpBuilder{ String lhs; String rhs; Policy evictionPolicy; long evictionThreshold = -1; public JoinBuilder(StreamBuilder streamBuilder, String lhs, String rhs) { super(streamBuilder); this.lhs = lhs; this.rhs = rhs; } public JoinBuilder evict(Policy policy, long threshold) { this.evictionPolicy = policy; this.evictionThreshold = threshold; return this; } @Override public StreamBuilder end() { if(evictionPolicy == null || evictionThreshold == -1) throw new RuntimeException("Eviction policy is required by the join operator"); if(lhs == null || rhs == null) throw new RuntimeException("Left and right side streams required by the join operator");
// Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/JoinOp.java // public class JoinOp implements FlowOp, RequiresPartitioning { // // public static final String JOIN = "join"; // // String leftStream; // String rightStream; // // Policy evictionPolicy; // long evictionThreshold; // // public JoinOp(String leftStream, String rightStream, Policy evictionPolicy, long evictionThreshold) { // this.leftStream = leftStream; // this.rightStream = rightStream; // this.evictionPolicy = evictionPolicy; // this.evictionThreshold = evictionThreshold; // } // // public String getLeftStream() { // return leftStream; // } // // public String getRightStream() { // return rightStream; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // @Override // public String getComponentName() { // return "join"; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // } // Path: src/main/java/org/calrissian/flowmix/api/builder/JoinBuilder.java import java.util.List; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.JoinOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import static java.util.Collections.EMPTY_LIST; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.builder; public class JoinBuilder extends AbstractOpBuilder{ String lhs; String rhs; Policy evictionPolicy; long evictionThreshold = -1; public JoinBuilder(StreamBuilder streamBuilder, String lhs, String rhs) { super(streamBuilder); this.lhs = lhs; this.rhs = rhs; } public JoinBuilder evict(Policy policy, long threshold) { this.evictionPolicy = policy; this.evictionThreshold = threshold; return this; } @Override public StreamBuilder end() { if(evictionPolicy == null || evictionThreshold == -1) throw new RuntimeException("Eviction policy is required by the join operator"); if(lhs == null || rhs == null) throw new RuntimeException("Left and right side streams required by the join operator");
List<FlowOp> flowOpList = getStreamBuilder().getFlowOpList();
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/builder/JoinBuilder.java
// Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/JoinOp.java // public class JoinOp implements FlowOp, RequiresPartitioning { // // public static final String JOIN = "join"; // // String leftStream; // String rightStream; // // Policy evictionPolicy; // long evictionThreshold; // // public JoinOp(String leftStream, String rightStream, Policy evictionPolicy, long evictionThreshold) { // this.leftStream = leftStream; // this.rightStream = rightStream; // this.evictionPolicy = evictionPolicy; // this.evictionThreshold = evictionThreshold; // } // // public String getLeftStream() { // return leftStream; // } // // public String getRightStream() { // return rightStream; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // @Override // public String getComponentName() { // return "join"; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // }
import java.util.List; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.JoinOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import static java.util.Collections.EMPTY_LIST;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.builder; public class JoinBuilder extends AbstractOpBuilder{ String lhs; String rhs; Policy evictionPolicy; long evictionThreshold = -1; public JoinBuilder(StreamBuilder streamBuilder, String lhs, String rhs) { super(streamBuilder); this.lhs = lhs; this.rhs = rhs; } public JoinBuilder evict(Policy policy, long threshold) { this.evictionPolicy = policy; this.evictionThreshold = threshold; return this; } @Override public StreamBuilder end() { if(evictionPolicy == null || evictionThreshold == -1) throw new RuntimeException("Eviction policy is required by the join operator"); if(lhs == null || rhs == null) throw new RuntimeException("Left and right side streams required by the join operator"); List<FlowOp> flowOpList = getStreamBuilder().getFlowOpList(); FlowOp op = flowOpList.size() == 0 ? null : flowOpList.get(flowOpList.size()-1);
// Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/JoinOp.java // public class JoinOp implements FlowOp, RequiresPartitioning { // // public static final String JOIN = "join"; // // String leftStream; // String rightStream; // // Policy evictionPolicy; // long evictionThreshold; // // public JoinOp(String leftStream, String rightStream, Policy evictionPolicy, long evictionThreshold) { // this.leftStream = leftStream; // this.rightStream = rightStream; // this.evictionPolicy = evictionPolicy; // this.evictionThreshold = evictionThreshold; // } // // public String getLeftStream() { // return leftStream; // } // // public String getRightStream() { // return rightStream; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // @Override // public String getComponentName() { // return "join"; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // } // Path: src/main/java/org/calrissian/flowmix/api/builder/JoinBuilder.java import java.util.List; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.JoinOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import static java.util.Collections.EMPTY_LIST; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.builder; public class JoinBuilder extends AbstractOpBuilder{ String lhs; String rhs; Policy evictionPolicy; long evictionThreshold = -1; public JoinBuilder(StreamBuilder streamBuilder, String lhs, String rhs) { super(streamBuilder); this.lhs = lhs; this.rhs = rhs; } public JoinBuilder evict(Policy policy, long threshold) { this.evictionPolicy = policy; this.evictionThreshold = threshold; return this; } @Override public StreamBuilder end() { if(evictionPolicy == null || evictionThreshold == -1) throw new RuntimeException("Eviction policy is required by the join operator"); if(lhs == null || rhs == null) throw new RuntimeException("Left and right side streams required by the join operator"); List<FlowOp> flowOpList = getStreamBuilder().getFlowOpList(); FlowOp op = flowOpList.size() == 0 ? null : flowOpList.get(flowOpList.size()-1);
if(op == null || !(op instanceof PartitionOp))
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/builder/JoinBuilder.java
// Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/JoinOp.java // public class JoinOp implements FlowOp, RequiresPartitioning { // // public static final String JOIN = "join"; // // String leftStream; // String rightStream; // // Policy evictionPolicy; // long evictionThreshold; // // public JoinOp(String leftStream, String rightStream, Policy evictionPolicy, long evictionThreshold) { // this.leftStream = leftStream; // this.rightStream = rightStream; // this.evictionPolicy = evictionPolicy; // this.evictionThreshold = evictionThreshold; // } // // public String getLeftStream() { // return leftStream; // } // // public String getRightStream() { // return rightStream; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // @Override // public String getComponentName() { // return "join"; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // }
import java.util.List; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.JoinOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import static java.util.Collections.EMPTY_LIST;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.builder; public class JoinBuilder extends AbstractOpBuilder{ String lhs; String rhs; Policy evictionPolicy; long evictionThreshold = -1; public JoinBuilder(StreamBuilder streamBuilder, String lhs, String rhs) { super(streamBuilder); this.lhs = lhs; this.rhs = rhs; } public JoinBuilder evict(Policy policy, long threshold) { this.evictionPolicy = policy; this.evictionThreshold = threshold; return this; } @Override public StreamBuilder end() { if(evictionPolicy == null || evictionThreshold == -1) throw new RuntimeException("Eviction policy is required by the join operator"); if(lhs == null || rhs == null) throw new RuntimeException("Left and right side streams required by the join operator"); List<FlowOp> flowOpList = getStreamBuilder().getFlowOpList(); FlowOp op = flowOpList.size() == 0 ? null : flowOpList.get(flowOpList.size()-1); if(op == null || !(op instanceof PartitionOp)) flowOpList.add(new PartitionOp(EMPTY_LIST));
// Path: src/main/java/org/calrissian/flowmix/api/Policy.java // public enum Policy implements Serializable { // // COUNT, TIME, TIME_DELTA_LT // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/JoinOp.java // public class JoinOp implements FlowOp, RequiresPartitioning { // // public static final String JOIN = "join"; // // String leftStream; // String rightStream; // // Policy evictionPolicy; // long evictionThreshold; // // public JoinOp(String leftStream, String rightStream, Policy evictionPolicy, long evictionThreshold) { // this.leftStream = leftStream; // this.rightStream = rightStream; // this.evictionPolicy = evictionPolicy; // this.evictionThreshold = evictionThreshold; // } // // public String getLeftStream() { // return leftStream; // } // // public String getRightStream() { // return rightStream; // } // // public Policy getEvictionPolicy() { // return evictionPolicy; // } // // public long getEvictionThreshold() { // return evictionThreshold; // } // // @Override // public String getComponentName() { // return "join"; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // } // Path: src/main/java/org/calrissian/flowmix/api/builder/JoinBuilder.java import java.util.List; import org.calrissian.flowmix.api.Policy; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.flowmix.core.model.op.JoinOp; import org.calrissian.flowmix.core.model.op.PartitionOp; import static java.util.Collections.EMPTY_LIST; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.builder; public class JoinBuilder extends AbstractOpBuilder{ String lhs; String rhs; Policy evictionPolicy; long evictionThreshold = -1; public JoinBuilder(StreamBuilder streamBuilder, String lhs, String rhs) { super(streamBuilder); this.lhs = lhs; this.rhs = rhs; } public JoinBuilder evict(Policy policy, long threshold) { this.evictionPolicy = policy; this.evictionThreshold = threshold; return this; } @Override public StreamBuilder end() { if(evictionPolicy == null || evictionThreshold == -1) throw new RuntimeException("Eviction policy is required by the join operator"); if(lhs == null || rhs == null) throw new RuntimeException("Left and right side streams required by the join operator"); List<FlowOp> flowOpList = getStreamBuilder().getFlowOpList(); FlowOp op = flowOpList.size() == 0 ? null : flowOpList.get(flowOpList.size()-1); if(op == null || !(op instanceof PartitionOp)) flowOpList.add(new PartitionOp(EMPTY_LIST));
getStreamBuilder().addFlowOp(new JoinOp(lhs, rhs, evictionPolicy, evictionThreshold));
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/builder/EachBuilder.java
// Path: src/main/java/org/calrissian/flowmix/core/model/op/EachOp.java // public class EachOp implements FlowOp { // // public static final String EACH = "each"; // // Function function; // // public EachOp(Function function) { // this.function = function; // } // // public Function getFunction() { // return function; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // EachOp that = (EachOp) o; // // if (function != null ? !function.equals(that.function) : that.function != null) return false; // // return true; // } // // @Override // public int hashCode() { // return function != null ? function.hashCode() : 0; // } // // @Override // public String getComponentName() { // return "each"; // } // } // // Path: src/main/java/org/calrissian/flowmix/api/Function.java // public interface Function extends Serializable{ // // List<Event> execute(Event event); // }
import org.calrissian.flowmix.core.model.op.EachOp; import org.calrissian.flowmix.api.Function;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.builder; public class EachBuilder extends AbstractOpBuilder{ private Function function; public EachBuilder(StreamBuilder flowOpsBuilder) { super(flowOpsBuilder); } public EachBuilder function(Function function) { this.function = function; return this; } @Override public StreamBuilder end() {
// Path: src/main/java/org/calrissian/flowmix/core/model/op/EachOp.java // public class EachOp implements FlowOp { // // public static final String EACH = "each"; // // Function function; // // public EachOp(Function function) { // this.function = function; // } // // public Function getFunction() { // return function; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // EachOp that = (EachOp) o; // // if (function != null ? !function.equals(that.function) : that.function != null) return false; // // return true; // } // // @Override // public int hashCode() { // return function != null ? function.hashCode() : 0; // } // // @Override // public String getComponentName() { // return "each"; // } // } // // Path: src/main/java/org/calrissian/flowmix/api/Function.java // public interface Function extends Serializable{ // // List<Event> execute(Event event); // } // Path: src/main/java/org/calrissian/flowmix/api/builder/EachBuilder.java import org.calrissian.flowmix.core.model.op.EachOp; import org.calrissian.flowmix.api.Function; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.builder; public class EachBuilder extends AbstractOpBuilder{ private Function function; public EachBuilder(StreamBuilder flowOpsBuilder) { super(flowOpsBuilder); } public EachBuilder function(Function function) { this.function = function; return this; } @Override public StreamBuilder end() {
getStreamBuilder().addFlowOp(new EachOp(function));
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/builder/SelectBuilder.java
// Path: src/main/java/org/calrissian/flowmix/core/model/op/SelectOp.java // public class SelectOp implements FlowOp { // // public static final String SELECT = "select"; // List<String> fields; // // public SelectOp(List<String> fields) { // this.fields = fields; // } // @Override // public String getComponentName() { // return SELECT; // } // // public List<String> getFields() { // return fields; // } // }
import java.util.ArrayList; import java.util.List; import org.calrissian.flowmix.core.model.op.SelectOp;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.builder; public class SelectBuilder extends AbstractOpBuilder { private List<String> fieldsList = new ArrayList<String>(); public SelectBuilder(StreamBuilder fob) { super(fob); } public SelectBuilder fields(String... fields) { for(String field : fields) fieldsList.add(field); return this; } public StreamBuilder end() { if(fieldsList == null || fieldsList.size() == 0) throw new RuntimeException("Selector operator needs to select at least 1 field");
// Path: src/main/java/org/calrissian/flowmix/core/model/op/SelectOp.java // public class SelectOp implements FlowOp { // // public static final String SELECT = "select"; // List<String> fields; // // public SelectOp(List<String> fields) { // this.fields = fields; // } // @Override // public String getComponentName() { // return SELECT; // } // // public List<String> getFields() { // return fields; // } // } // Path: src/main/java/org/calrissian/flowmix/api/builder/SelectBuilder.java import java.util.ArrayList; import java.util.List; import org.calrissian.flowmix.core.model.op.SelectOp; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.builder; public class SelectBuilder extends AbstractOpBuilder { private List<String> fieldsList = new ArrayList<String>(); public SelectBuilder(StreamBuilder fob) { super(fob); } public SelectBuilder fields(String... fields) { for(String field : fields) fieldsList.add(field); return this; } public StreamBuilder end() { if(fieldsList == null || fieldsList.size() == 0) throw new RuntimeException("Selector operator needs to select at least 1 field");
getStreamBuilder().addFlowOp(new SelectOp(fieldsList));
calrissian/flowmix
src/main/java/org/calrissian/flowmix/core/support/EventSortByComparator.java
// Path: src/main/java/org/calrissian/flowmix/api/Order.java // public enum Order { // // ASC, DESC // } // // Path: src/main/java/org/calrissian/flowmix/core/support/window/WindowItem.java // public class WindowItem { // Event event; // long timestamp; // String previousStream; // // public WindowItem(Event event, long timestamp, String previousStream) { // this.event = event; // this.timestamp = timestamp; // this.previousStream = previousStream; // } // // public Event getEvent() { // return event; // } // // public long getTimestamp() { // return timestamp; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public String toString() { // return "WindowItem{" + // "event=" + event + // ", timestamp=" + timestamp + // '}'; // } // }
import java.util.Comparator; import java.util.List; import org.apache.commons.collections.comparators.ComparableComparator; import org.calrissian.flowmix.api.Order; import org.calrissian.flowmix.core.support.window.WindowItem; import org.calrissian.mango.domain.Pair; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.support; public class EventSortByComparator implements Comparator<WindowItem> { private static ComparableComparator comparator = new ComparableComparator();
// Path: src/main/java/org/calrissian/flowmix/api/Order.java // public enum Order { // // ASC, DESC // } // // Path: src/main/java/org/calrissian/flowmix/core/support/window/WindowItem.java // public class WindowItem { // Event event; // long timestamp; // String previousStream; // // public WindowItem(Event event, long timestamp, String previousStream) { // this.event = event; // this.timestamp = timestamp; // this.previousStream = previousStream; // } // // public Event getEvent() { // return event; // } // // public long getTimestamp() { // return timestamp; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public String toString() { // return "WindowItem{" + // "event=" + event + // ", timestamp=" + timestamp + // '}'; // } // } // Path: src/main/java/org/calrissian/flowmix/core/support/EventSortByComparator.java import java.util.Comparator; import java.util.List; import org.apache.commons.collections.comparators.ComparableComparator; import org.calrissian.flowmix.api.Order; import org.calrissian.flowmix.core.support.window.WindowItem; import org.calrissian.mango.domain.Pair; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.support; public class EventSortByComparator implements Comparator<WindowItem> { private static ComparableComparator comparator = new ComparableComparator();
private List<Pair<String,Order>> sortBy;
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/builder/PartitionBuilder.java
// Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // }
import java.util.ArrayList; import java.util.List; import org.calrissian.flowmix.core.model.op.PartitionOp;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.builder; public class PartitionBuilder extends AbstractOpBuilder { private List<String> fieldsList = new ArrayList<String>(); public PartitionBuilder(StreamBuilder flowOpsBuilder) { super(flowOpsBuilder); } public PartitionBuilder fields(String... fields) { for(String field : fields) fieldsList.add(field); return this; } public StreamBuilder end() { /** * It's possible that if a partitioner does not have any specified fieldsList, that it uses a default partition. */
// Path: src/main/java/org/calrissian/flowmix/core/model/op/PartitionOp.java // public class PartitionOp implements FlowOp { // // public static final String PARTITION = "partition"; // private List<String> fields; // // public PartitionOp(List<String> fields) { // this.fields = fields; // } // // public List<String> getFields() { // return fields; // } // // @Override // public String getComponentName() { // return PARTITION; // } // // @Override // public String toString() { // return "PartitionOp{" + // "fields=" + fields + // '}'; // } // } // Path: src/main/java/org/calrissian/flowmix/api/builder/PartitionBuilder.java import java.util.ArrayList; import java.util.List; import org.calrissian.flowmix.core.model.op.PartitionOp; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.builder; public class PartitionBuilder extends AbstractOpBuilder { private List<String> fieldsList = new ArrayList<String>(); public PartitionBuilder(StreamBuilder flowOpsBuilder) { super(flowOpsBuilder); } public PartitionBuilder fields(String... fields) { for(String field : fields) fieldsList.add(field); return this; } public StreamBuilder end() { /** * It's possible that if a partitioner does not have any specified fieldsList, that it uses a default partition. */
getStreamBuilder().addFlowOp(new PartitionOp(fieldsList));
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/builder/StreamBuilder.java
// Path: src/main/java/org/calrissian/flowmix/core/model/StreamDef.java // public class StreamDef implements Serializable { // // private String name; // private List<FlowOp> flowOps; // private boolean stdInput; // private boolean stdOutput; // private String[] outputs; // // public StreamDef(String name, List<FlowOp> flowOps, boolean stdInput, boolean stdOutput, String[] outputs) { // this.name = name; // this.flowOps = flowOps; // this.stdInput = stdInput; // this.stdOutput = stdOutput; // this.outputs = outputs; // } // // public String getName() { // return name; // } // // public List<FlowOp> getFlowOps() { // return flowOps; // } // // public boolean isStdInput() { // return stdInput; // } // // public boolean isStdOutput() { // return stdOutput; // } // // public String[] getOutputs() { // return outputs; // } // // @Override // public String toString() { // return "StreamDef{" + // "name='" + name + '\'' + // ", flowOps=" + flowOps + // '}'; // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // StreamDef streamDef = (StreamDef) o; // // if (stdInput != streamDef.stdInput) { // return false; // } // if (stdOutput != streamDef.stdOutput) { // return false; // } // if (flowOps != null ? !flowOps.equals(streamDef.flowOps) : streamDef.flowOps != null) { // return false; // } // if (name != null ? !name.equals(streamDef.name) : streamDef.name != null) { // return false; // } // if (!Arrays.equals(outputs, streamDef.outputs)) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = name != null ? name.hashCode() : 0; // result = 31 * result + (flowOps != null ? flowOps.hashCode() : 0); // result = 31 * result + (stdInput ? 1 : 0); // result = 31 * result + (stdOutput ? 1 : 0); // result = 31 * result + (outputs != null ? Arrays.hashCode(outputs) : 0); // return result; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // }
import java.util.ArrayList; import java.util.List; import org.calrissian.flowmix.core.model.StreamDef; import org.calrissian.flowmix.core.model.op.FlowOp;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.builder; public class StreamBuilder { private String name;
// Path: src/main/java/org/calrissian/flowmix/core/model/StreamDef.java // public class StreamDef implements Serializable { // // private String name; // private List<FlowOp> flowOps; // private boolean stdInput; // private boolean stdOutput; // private String[] outputs; // // public StreamDef(String name, List<FlowOp> flowOps, boolean stdInput, boolean stdOutput, String[] outputs) { // this.name = name; // this.flowOps = flowOps; // this.stdInput = stdInput; // this.stdOutput = stdOutput; // this.outputs = outputs; // } // // public String getName() { // return name; // } // // public List<FlowOp> getFlowOps() { // return flowOps; // } // // public boolean isStdInput() { // return stdInput; // } // // public boolean isStdOutput() { // return stdOutput; // } // // public String[] getOutputs() { // return outputs; // } // // @Override // public String toString() { // return "StreamDef{" + // "name='" + name + '\'' + // ", flowOps=" + flowOps + // '}'; // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // StreamDef streamDef = (StreamDef) o; // // if (stdInput != streamDef.stdInput) { // return false; // } // if (stdOutput != streamDef.stdOutput) { // return false; // } // if (flowOps != null ? !flowOps.equals(streamDef.flowOps) : streamDef.flowOps != null) { // return false; // } // if (name != null ? !name.equals(streamDef.name) : streamDef.name != null) { // return false; // } // if (!Arrays.equals(outputs, streamDef.outputs)) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = name != null ? name.hashCode() : 0; // result = 31 * result + (flowOps != null ? flowOps.hashCode() : 0); // result = 31 * result + (stdInput ? 1 : 0); // result = 31 * result + (stdOutput ? 1 : 0); // result = 31 * result + (outputs != null ? Arrays.hashCode(outputs) : 0); // return result; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // Path: src/main/java/org/calrissian/flowmix/api/builder/StreamBuilder.java import java.util.ArrayList; import java.util.List; import org.calrissian.flowmix.core.model.StreamDef; import org.calrissian.flowmix.core.model.op.FlowOp; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.builder; public class StreamBuilder { private String name;
private List<FlowOp> flowOpList = new ArrayList<FlowOp>();
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/builder/StreamBuilder.java
// Path: src/main/java/org/calrissian/flowmix/core/model/StreamDef.java // public class StreamDef implements Serializable { // // private String name; // private List<FlowOp> flowOps; // private boolean stdInput; // private boolean stdOutput; // private String[] outputs; // // public StreamDef(String name, List<FlowOp> flowOps, boolean stdInput, boolean stdOutput, String[] outputs) { // this.name = name; // this.flowOps = flowOps; // this.stdInput = stdInput; // this.stdOutput = stdOutput; // this.outputs = outputs; // } // // public String getName() { // return name; // } // // public List<FlowOp> getFlowOps() { // return flowOps; // } // // public boolean isStdInput() { // return stdInput; // } // // public boolean isStdOutput() { // return stdOutput; // } // // public String[] getOutputs() { // return outputs; // } // // @Override // public String toString() { // return "StreamDef{" + // "name='" + name + '\'' + // ", flowOps=" + flowOps + // '}'; // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // StreamDef streamDef = (StreamDef) o; // // if (stdInput != streamDef.stdInput) { // return false; // } // if (stdOutput != streamDef.stdOutput) { // return false; // } // if (flowOps != null ? !flowOps.equals(streamDef.flowOps) : streamDef.flowOps != null) { // return false; // } // if (name != null ? !name.equals(streamDef.name) : streamDef.name != null) { // return false; // } // if (!Arrays.equals(outputs, streamDef.outputs)) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = name != null ? name.hashCode() : 0; // result = 31 * result + (flowOps != null ? flowOps.hashCode() : 0); // result = 31 * result + (stdInput ? 1 : 0); // result = 31 * result + (stdOutput ? 1 : 0); // result = 31 * result + (outputs != null ? Arrays.hashCode(outputs) : 0); // return result; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // }
import java.util.ArrayList; import java.util.List; import org.calrissian.flowmix.core.model.StreamDef; import org.calrissian.flowmix.core.model.op.FlowOp;
public PartitionBuilder partition() { return new PartitionBuilder(this); } public SwitchBuilder stopGate() { return new SwitchBuilder(this); } public JoinBuilder join(String stream1, String stream2) { return new JoinBuilder(this, stream1, stream2); } public SplitBuilder split() { return new SplitBuilder(this); } public SortBuilder sort() { return new SortBuilder(this); } public EachBuilder each() { return new EachBuilder(this); } public FlowDefsBuilder endStream() { return endStream(true, null); } public FlowDefsBuilder endStream(boolean stdOutput, String... outputs) {
// Path: src/main/java/org/calrissian/flowmix/core/model/StreamDef.java // public class StreamDef implements Serializable { // // private String name; // private List<FlowOp> flowOps; // private boolean stdInput; // private boolean stdOutput; // private String[] outputs; // // public StreamDef(String name, List<FlowOp> flowOps, boolean stdInput, boolean stdOutput, String[] outputs) { // this.name = name; // this.flowOps = flowOps; // this.stdInput = stdInput; // this.stdOutput = stdOutput; // this.outputs = outputs; // } // // public String getName() { // return name; // } // // public List<FlowOp> getFlowOps() { // return flowOps; // } // // public boolean isStdInput() { // return stdInput; // } // // public boolean isStdOutput() { // return stdOutput; // } // // public String[] getOutputs() { // return outputs; // } // // @Override // public String toString() { // return "StreamDef{" + // "name='" + name + '\'' + // ", flowOps=" + flowOps + // '}'; // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // StreamDef streamDef = (StreamDef) o; // // if (stdInput != streamDef.stdInput) { // return false; // } // if (stdOutput != streamDef.stdOutput) { // return false; // } // if (flowOps != null ? !flowOps.equals(streamDef.flowOps) : streamDef.flowOps != null) { // return false; // } // if (name != null ? !name.equals(streamDef.name) : streamDef.name != null) { // return false; // } // if (!Arrays.equals(outputs, streamDef.outputs)) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = name != null ? name.hashCode() : 0; // result = 31 * result + (flowOps != null ? flowOps.hashCode() : 0); // result = 31 * result + (stdInput ? 1 : 0); // result = 31 * result + (stdOutput ? 1 : 0); // result = 31 * result + (outputs != null ? Arrays.hashCode(outputs) : 0); // return result; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // Path: src/main/java/org/calrissian/flowmix/api/builder/StreamBuilder.java import java.util.ArrayList; import java.util.List; import org.calrissian.flowmix.core.model.StreamDef; import org.calrissian.flowmix.core.model.op.FlowOp; public PartitionBuilder partition() { return new PartitionBuilder(this); } public SwitchBuilder stopGate() { return new SwitchBuilder(this); } public JoinBuilder join(String stream1, String stream2) { return new JoinBuilder(this, stream1, stream2); } public SplitBuilder split() { return new SplitBuilder(this); } public SortBuilder sort() { return new SortBuilder(this); } public EachBuilder each() { return new EachBuilder(this); } public FlowDefsBuilder endStream() { return endStream(true, null); } public FlowDefsBuilder endStream(boolean stdOutput, String... outputs) {
StreamDef def = new StreamDef(name, flowOpList, stdInput, stdOutput, outputs);
calrissian/flowmix
src/main/java/org/calrissian/flowmix/core/support/Utils.java
// Path: src/main/java/org/calrissian/flowmix/api/Flow.java // public class Flow implements Serializable{ // // String id; // String name; // String description; // // Map<String,StreamDef> streams = new HashMap<String, StreamDef>(); // // public String getId() { // return id; // } // // public String getName() { // return name; // } // // public String getDescription() { // return description; // } // // public Collection<StreamDef> getStreams() { // return streams.values(); // } // // public StreamDef getStream(String name) { // return streams.get(name); // } // // public void setId(String id) { // this.id = id; // } // // public void setName(String name) { // this.name = name; // } // // public void setDescription(String description) { // this.description = description; // } // // public void setStreams(List<StreamDef> streams) { // for(StreamDef def : streams) // this.streams.put(def.getName(), def); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Flow flow = (Flow) o; // // if (description != null ? !description.equals(flow.description) : flow.description != null) return false; // if (id != null ? !id.equals(flow.id) : flow.id != null) return false; // if (name != null ? !name.equals(flow.name) : flow.name != null) return false; // if (streams != null ? !streams.equals(flow.streams) : flow.streams != null) return false; // // return true; // } // // @Override // public int hashCode() { // int result = id != null ? id.hashCode() : 0; // result = 31 * result + (name != null ? name.hashCode() : 0); // result = 31 * result + (description != null ? description.hashCode() : 0); // result = 31 * result + (streams != null ? streams.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "Flow{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // ", description='" + description + '\'' + // ", streams=" + streams + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String OUTPUT = "output";
import java.util.Collection; import java.util.List; import java.util.SortedSet; import java.util.TreeSet; import org.calrissian.flowmix.api.Flow; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.mango.domain.Tuple; import org.calrissian.mango.domain.event.Event; import org.calrissian.mango.types.TypeRegistry; import static org.apache.commons.lang.StringUtils.join; import static org.calrissian.flowmix.core.Constants.OUTPUT; import static org.calrissian.mango.types.LexiTypeEncoders.LEXI_TYPES;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.support; public class Utils { private static final TypeRegistry<String> registry = LEXI_TYPES; private Utils() {} public static String buildKeyIndexForEvent(Event event, List<String> groupBy) { StringBuffer stringBuffer = new StringBuffer(); if(groupBy == null || groupBy.size() == 0) return stringBuffer.toString(); // default partition when no groupBy fields are specified. for(String groupField : groupBy) { Collection<Tuple> tuples = event.getAll(groupField); SortedSet<String> values = new TreeSet<String>(); if(tuples == null) { values.add(""); } else { for(Tuple tuple : tuples) values.add(registry.encode(tuple.getValue())); } stringBuffer.append(groupField + join(values, "") + "|"); } try { return stringBuffer.toString(); } catch (Exception e) { return null; } } public static String buildKeyIndexForEvent(String flowId, Event event, List<String> groupBy) { return flowId + buildKeyIndexForEvent(event, groupBy); }
// Path: src/main/java/org/calrissian/flowmix/api/Flow.java // public class Flow implements Serializable{ // // String id; // String name; // String description; // // Map<String,StreamDef> streams = new HashMap<String, StreamDef>(); // // public String getId() { // return id; // } // // public String getName() { // return name; // } // // public String getDescription() { // return description; // } // // public Collection<StreamDef> getStreams() { // return streams.values(); // } // // public StreamDef getStream(String name) { // return streams.get(name); // } // // public void setId(String id) { // this.id = id; // } // // public void setName(String name) { // this.name = name; // } // // public void setDescription(String description) { // this.description = description; // } // // public void setStreams(List<StreamDef> streams) { // for(StreamDef def : streams) // this.streams.put(def.getName(), def); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Flow flow = (Flow) o; // // if (description != null ? !description.equals(flow.description) : flow.description != null) return false; // if (id != null ? !id.equals(flow.id) : flow.id != null) return false; // if (name != null ? !name.equals(flow.name) : flow.name != null) return false; // if (streams != null ? !streams.equals(flow.streams) : flow.streams != null) return false; // // return true; // } // // @Override // public int hashCode() { // int result = id != null ? id.hashCode() : 0; // result = 31 * result + (name != null ? name.hashCode() : 0); // result = 31 * result + (description != null ? description.hashCode() : 0); // result = 31 * result + (streams != null ? streams.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "Flow{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // ", description='" + description + '\'' + // ", streams=" + streams + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String OUTPUT = "output"; // Path: src/main/java/org/calrissian/flowmix/core/support/Utils.java import java.util.Collection; import java.util.List; import java.util.SortedSet; import java.util.TreeSet; import org.calrissian.flowmix.api.Flow; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.mango.domain.Tuple; import org.calrissian.mango.domain.event.Event; import org.calrissian.mango.types.TypeRegistry; import static org.apache.commons.lang.StringUtils.join; import static org.calrissian.flowmix.core.Constants.OUTPUT; import static org.calrissian.mango.types.LexiTypeEncoders.LEXI_TYPES; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.support; public class Utils { private static final TypeRegistry<String> registry = LEXI_TYPES; private Utils() {} public static String buildKeyIndexForEvent(Event event, List<String> groupBy) { StringBuffer stringBuffer = new StringBuffer(); if(groupBy == null || groupBy.size() == 0) return stringBuffer.toString(); // default partition when no groupBy fields are specified. for(String groupField : groupBy) { Collection<Tuple> tuples = event.getAll(groupField); SortedSet<String> values = new TreeSet<String>(); if(tuples == null) { values.add(""); } else { for(Tuple tuple : tuples) values.add(registry.encode(tuple.getValue())); } stringBuffer.append(groupField + join(values, "") + "|"); } try { return stringBuffer.toString(); } catch (Exception e) { return null; } } public static String buildKeyIndexForEvent(String flowId, Event event, List<String> groupBy) { return flowId + buildKeyIndexForEvent(event, groupBy); }
public static String getNextStreamFromFlowInfo(Flow flow, String streamName, int idx) {
calrissian/flowmix
src/main/java/org/calrissian/flowmix/core/support/Utils.java
// Path: src/main/java/org/calrissian/flowmix/api/Flow.java // public class Flow implements Serializable{ // // String id; // String name; // String description; // // Map<String,StreamDef> streams = new HashMap<String, StreamDef>(); // // public String getId() { // return id; // } // // public String getName() { // return name; // } // // public String getDescription() { // return description; // } // // public Collection<StreamDef> getStreams() { // return streams.values(); // } // // public StreamDef getStream(String name) { // return streams.get(name); // } // // public void setId(String id) { // this.id = id; // } // // public void setName(String name) { // this.name = name; // } // // public void setDescription(String description) { // this.description = description; // } // // public void setStreams(List<StreamDef> streams) { // for(StreamDef def : streams) // this.streams.put(def.getName(), def); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Flow flow = (Flow) o; // // if (description != null ? !description.equals(flow.description) : flow.description != null) return false; // if (id != null ? !id.equals(flow.id) : flow.id != null) return false; // if (name != null ? !name.equals(flow.name) : flow.name != null) return false; // if (streams != null ? !streams.equals(flow.streams) : flow.streams != null) return false; // // return true; // } // // @Override // public int hashCode() { // int result = id != null ? id.hashCode() : 0; // result = 31 * result + (name != null ? name.hashCode() : 0); // result = 31 * result + (description != null ? description.hashCode() : 0); // result = 31 * result + (streams != null ? streams.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "Flow{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // ", description='" + description + '\'' + // ", streams=" + streams + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String OUTPUT = "output";
import java.util.Collection; import java.util.List; import java.util.SortedSet; import java.util.TreeSet; import org.calrissian.flowmix.api.Flow; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.mango.domain.Tuple; import org.calrissian.mango.domain.event.Event; import org.calrissian.mango.types.TypeRegistry; import static org.apache.commons.lang.StringUtils.join; import static org.calrissian.flowmix.core.Constants.OUTPUT; import static org.calrissian.mango.types.LexiTypeEncoders.LEXI_TYPES;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.support; public class Utils { private static final TypeRegistry<String> registry = LEXI_TYPES; private Utils() {} public static String buildKeyIndexForEvent(Event event, List<String> groupBy) { StringBuffer stringBuffer = new StringBuffer(); if(groupBy == null || groupBy.size() == 0) return stringBuffer.toString(); // default partition when no groupBy fields are specified. for(String groupField : groupBy) { Collection<Tuple> tuples = event.getAll(groupField); SortedSet<String> values = new TreeSet<String>(); if(tuples == null) { values.add(""); } else { for(Tuple tuple : tuples) values.add(registry.encode(tuple.getValue())); } stringBuffer.append(groupField + join(values, "") + "|"); } try { return stringBuffer.toString(); } catch (Exception e) { return null; } } public static String buildKeyIndexForEvent(String flowId, Event event, List<String> groupBy) { return flowId + buildKeyIndexForEvent(event, groupBy); } public static String getNextStreamFromFlowInfo(Flow flow, String streamName, int idx) { return idx+1 < flow.getStream(streamName).getFlowOps().size() ?
// Path: src/main/java/org/calrissian/flowmix/api/Flow.java // public class Flow implements Serializable{ // // String id; // String name; // String description; // // Map<String,StreamDef> streams = new HashMap<String, StreamDef>(); // // public String getId() { // return id; // } // // public String getName() { // return name; // } // // public String getDescription() { // return description; // } // // public Collection<StreamDef> getStreams() { // return streams.values(); // } // // public StreamDef getStream(String name) { // return streams.get(name); // } // // public void setId(String id) { // this.id = id; // } // // public void setName(String name) { // this.name = name; // } // // public void setDescription(String description) { // this.description = description; // } // // public void setStreams(List<StreamDef> streams) { // for(StreamDef def : streams) // this.streams.put(def.getName(), def); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Flow flow = (Flow) o; // // if (description != null ? !description.equals(flow.description) : flow.description != null) return false; // if (id != null ? !id.equals(flow.id) : flow.id != null) return false; // if (name != null ? !name.equals(flow.name) : flow.name != null) return false; // if (streams != null ? !streams.equals(flow.streams) : flow.streams != null) return false; // // return true; // } // // @Override // public int hashCode() { // int result = id != null ? id.hashCode() : 0; // result = 31 * result + (name != null ? name.hashCode() : 0); // result = 31 * result + (description != null ? description.hashCode() : 0); // result = 31 * result + (streams != null ? streams.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "Flow{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // ", description='" + description + '\'' + // ", streams=" + streams + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String OUTPUT = "output"; // Path: src/main/java/org/calrissian/flowmix/core/support/Utils.java import java.util.Collection; import java.util.List; import java.util.SortedSet; import java.util.TreeSet; import org.calrissian.flowmix.api.Flow; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.mango.domain.Tuple; import org.calrissian.mango.domain.event.Event; import org.calrissian.mango.types.TypeRegistry; import static org.apache.commons.lang.StringUtils.join; import static org.calrissian.flowmix.core.Constants.OUTPUT; import static org.calrissian.mango.types.LexiTypeEncoders.LEXI_TYPES; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.core.support; public class Utils { private static final TypeRegistry<String> registry = LEXI_TYPES; private Utils() {} public static String buildKeyIndexForEvent(Event event, List<String> groupBy) { StringBuffer stringBuffer = new StringBuffer(); if(groupBy == null || groupBy.size() == 0) return stringBuffer.toString(); // default partition when no groupBy fields are specified. for(String groupField : groupBy) { Collection<Tuple> tuples = event.getAll(groupField); SortedSet<String> values = new TreeSet<String>(); if(tuples == null) { values.add(""); } else { for(Tuple tuple : tuples) values.add(registry.encode(tuple.getValue())); } stringBuffer.append(groupField + join(values, "") + "|"); } try { return stringBuffer.toString(); } catch (Exception e) { return null; } } public static String buildKeyIndexForEvent(String flowId, Event event, List<String> groupBy) { return flowId + buildKeyIndexForEvent(event, groupBy); } public static String getNextStreamFromFlowInfo(Flow flow, String streamName, int idx) { return idx+1 < flow.getStream(streamName).getFlowOps().size() ?
flow.getStream(streamName).getFlowOps().get(idx + 1).getComponentName() : OUTPUT;
calrissian/flowmix
src/main/java/org/calrissian/flowmix/core/support/Utils.java
// Path: src/main/java/org/calrissian/flowmix/api/Flow.java // public class Flow implements Serializable{ // // String id; // String name; // String description; // // Map<String,StreamDef> streams = new HashMap<String, StreamDef>(); // // public String getId() { // return id; // } // // public String getName() { // return name; // } // // public String getDescription() { // return description; // } // // public Collection<StreamDef> getStreams() { // return streams.values(); // } // // public StreamDef getStream(String name) { // return streams.get(name); // } // // public void setId(String id) { // this.id = id; // } // // public void setName(String name) { // this.name = name; // } // // public void setDescription(String description) { // this.description = description; // } // // public void setStreams(List<StreamDef> streams) { // for(StreamDef def : streams) // this.streams.put(def.getName(), def); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Flow flow = (Flow) o; // // if (description != null ? !description.equals(flow.description) : flow.description != null) return false; // if (id != null ? !id.equals(flow.id) : flow.id != null) return false; // if (name != null ? !name.equals(flow.name) : flow.name != null) return false; // if (streams != null ? !streams.equals(flow.streams) : flow.streams != null) return false; // // return true; // } // // @Override // public int hashCode() { // int result = id != null ? id.hashCode() : 0; // result = 31 * result + (name != null ? name.hashCode() : 0); // result = 31 * result + (description != null ? description.hashCode() : 0); // result = 31 * result + (streams != null ? streams.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "Flow{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // ", description='" + description + '\'' + // ", streams=" + streams + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String OUTPUT = "output";
import java.util.Collection; import java.util.List; import java.util.SortedSet; import java.util.TreeSet; import org.calrissian.flowmix.api.Flow; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.mango.domain.Tuple; import org.calrissian.mango.domain.event.Event; import org.calrissian.mango.types.TypeRegistry; import static org.apache.commons.lang.StringUtils.join; import static org.calrissian.flowmix.core.Constants.OUTPUT; import static org.calrissian.mango.types.LexiTypeEncoders.LEXI_TYPES;
values.add(registry.encode(tuple.getValue())); } stringBuffer.append(groupField + join(values, "") + "|"); } try { return stringBuffer.toString(); } catch (Exception e) { return null; } } public static String buildKeyIndexForEvent(String flowId, Event event, List<String> groupBy) { return flowId + buildKeyIndexForEvent(event, groupBy); } public static String getNextStreamFromFlowInfo(Flow flow, String streamName, int idx) { return idx+1 < flow.getStream(streamName).getFlowOps().size() ? flow.getStream(streamName).getFlowOps().get(idx + 1).getComponentName() : OUTPUT; } public static boolean hasNextOutput(Flow flow, String streamName, String nextStream) { return (nextStream.equals(OUTPUT) && flow.getStream(streamName).isStdOutput()) || !nextStream.equals(OUTPUT); } public static boolean exportsToOtherStreams(Flow flow, String streamName, String nextStream) { return nextStream.equals(OUTPUT) && flow.getStream(streamName).getOutputs() != null; }
// Path: src/main/java/org/calrissian/flowmix/api/Flow.java // public class Flow implements Serializable{ // // String id; // String name; // String description; // // Map<String,StreamDef> streams = new HashMap<String, StreamDef>(); // // public String getId() { // return id; // } // // public String getName() { // return name; // } // // public String getDescription() { // return description; // } // // public Collection<StreamDef> getStreams() { // return streams.values(); // } // // public StreamDef getStream(String name) { // return streams.get(name); // } // // public void setId(String id) { // this.id = id; // } // // public void setName(String name) { // this.name = name; // } // // public void setDescription(String description) { // this.description = description; // } // // public void setStreams(List<StreamDef> streams) { // for(StreamDef def : streams) // this.streams.put(def.getName(), def); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Flow flow = (Flow) o; // // if (description != null ? !description.equals(flow.description) : flow.description != null) return false; // if (id != null ? !id.equals(flow.id) : flow.id != null) return false; // if (name != null ? !name.equals(flow.name) : flow.name != null) return false; // if (streams != null ? !streams.equals(flow.streams) : flow.streams != null) return false; // // return true; // } // // @Override // public int hashCode() { // int result = id != null ? id.hashCode() : 0; // result = 31 * result + (name != null ? name.hashCode() : 0); // result = 31 * result + (description != null ? description.hashCode() : 0); // result = 31 * result + (streams != null ? streams.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "Flow{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // ", description='" + description + '\'' + // ", streams=" + streams + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/model/op/FlowOp.java // public interface FlowOp extends Serializable { // // String getComponentName(); // } // // Path: src/main/java/org/calrissian/flowmix/core/Constants.java // public static final String OUTPUT = "output"; // Path: src/main/java/org/calrissian/flowmix/core/support/Utils.java import java.util.Collection; import java.util.List; import java.util.SortedSet; import java.util.TreeSet; import org.calrissian.flowmix.api.Flow; import org.calrissian.flowmix.core.model.op.FlowOp; import org.calrissian.mango.domain.Tuple; import org.calrissian.mango.domain.event.Event; import org.calrissian.mango.types.TypeRegistry; import static org.apache.commons.lang.StringUtils.join; import static org.calrissian.flowmix.core.Constants.OUTPUT; import static org.calrissian.mango.types.LexiTypeEncoders.LEXI_TYPES; values.add(registry.encode(tuple.getValue())); } stringBuffer.append(groupField + join(values, "") + "|"); } try { return stringBuffer.toString(); } catch (Exception e) { return null; } } public static String buildKeyIndexForEvent(String flowId, Event event, List<String> groupBy) { return flowId + buildKeyIndexForEvent(event, groupBy); } public static String getNextStreamFromFlowInfo(Flow flow, String streamName, int idx) { return idx+1 < flow.getStream(streamName).getFlowOps().size() ? flow.getStream(streamName).getFlowOps().get(idx + 1).getComponentName() : OUTPUT; } public static boolean hasNextOutput(Flow flow, String streamName, String nextStream) { return (nextStream.equals(OUTPUT) && flow.getStream(streamName).isStdOutput()) || !nextStream.equals(OUTPUT); } public static boolean exportsToOtherStreams(Flow flow, String streamName, String nextStream) { return nextStream.equals(OUTPUT) && flow.getStream(streamName).getOutputs() != null; }
public static <T extends FlowOp>T getFlowOpFromStream(Flow flow, String stream, int idx) {
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/aggregator/AbstractAggregator.java
// Path: src/main/java/org/calrissian/flowmix/api/Aggregator.java // public interface Aggregator extends Serializable { // // public static final String GROUP_BY = "groupBy"; // public static final String GROUP_BY_DELIM = "\u0000"; // // void configure(Map<String, String> configuration); // // void added(WindowItem item); // // void evicted(WindowItem item); // // List<AggregatedEvent> aggregate(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/event/AggregatedEvent.java // public class AggregatedEvent { // // private Event event; // private String previousStream; // // public AggregatedEvent(Event event, String previousStream) { // this.event = event; // this.previousStream = previousStream; // } // // public AggregatedEvent(Event event) { // this.event = event; // } // // public Event getEvent() { // return event; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // AggregatedEvent that = (AggregatedEvent) o; // // if (event != null ? !event.equals(that.event) : that.event != null) return false; // if (previousStream != null ? !previousStream.equals(that.previousStream) : that.previousStream != null) // return false; // // return true; // } // // @Override // public int hashCode() { // int result = event != null ? event.hashCode() : 0; // result = 31 * result + (previousStream != null ? previousStream.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "AggregatedEvent{" + // "event=" + event + // ", previousStream='" + previousStream + '\'' + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/support/window/WindowItem.java // public class WindowItem { // Event event; // long timestamp; // String previousStream; // // public WindowItem(Event event, long timestamp, String previousStream) { // this.event = event; // this.timestamp = timestamp; // this.previousStream = previousStream; // } // // public Event getEvent() { // return event; // } // // public long getTimestamp() { // return timestamp; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public String toString() { // return "WindowItem{" + // "event=" + event + // ", timestamp=" + timestamp + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/exceptions/FlowmixException.java // public class FlowmixException extends RuntimeException { // // public FlowmixException(String msg, Throwable t) { // super(msg, t); // } // // }
import org.calrissian.mango.domain.event.BaseEvent; import org.calrissian.mango.domain.event.Event; import static java.lang.System.currentTimeMillis; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import static java.util.UUID.randomUUID; import org.apache.commons.lang.StringUtils; import org.calrissian.flowmix.api.Aggregator; import static org.calrissian.flowmix.api.Aggregator.GROUP_BY; import static org.calrissian.flowmix.api.Aggregator.GROUP_BY_DELIM; import org.calrissian.flowmix.core.model.event.AggregatedEvent; import org.calrissian.flowmix.core.support.window.WindowItem; import org.calrissian.flowmix.exceptions.FlowmixException; import org.calrissian.mango.domain.Tuple;
/* * Copyright 2015 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.aggregator; /** * * Abstract aggregator for simple implementations * * @param <T> Aggregation result type * @param <F> Field type */ public abstract class AbstractAggregator<T, F> implements Aggregator { /** * field to operate with */ public static final String OPERATED_FIELD = "operatedField"; /** * output field */ public static final String OUTPUT_FIELD = "outputField"; /** * grouped fields description */ protected Map<String, Collection<Tuple>> groupedValues; /** * fields to group by */ protected String[] groupByFields; /** * operated field name */ protected String operatedField; /** * output field set by implementation */ protected String outputField = getOutputField(); /** * * @return output field implementation */ protected abstract String getOutputField(); /** * * @param configuration */ @Override public void configure(Map<String, String> configuration) { if (configuration.get(GROUP_BY) != null) { groupByFields = StringUtils.splitPreserveAllTokens(configuration.get(GROUP_BY), GROUP_BY_DELIM); } if (configuration.get(OUTPUT_FIELD) != null) { outputField = configuration.get(OUTPUT_FIELD); } if (configuration.get(OPERATED_FIELD) != null) { operatedField = configuration.get(OPERATED_FIELD); } else { throw new RuntimeException("Aggregator needs a field to operate it. Property missing: " + OPERATED_FIELD); } } /** * * @param fieldValue field value to work with after item is added to grouped * values */ public abstract void add(F fieldValue); /** * * @param item * @throws org.calrissian.flowmix.exceptions.FlowmixException */ @Override
// Path: src/main/java/org/calrissian/flowmix/api/Aggregator.java // public interface Aggregator extends Serializable { // // public static final String GROUP_BY = "groupBy"; // public static final String GROUP_BY_DELIM = "\u0000"; // // void configure(Map<String, String> configuration); // // void added(WindowItem item); // // void evicted(WindowItem item); // // List<AggregatedEvent> aggregate(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/event/AggregatedEvent.java // public class AggregatedEvent { // // private Event event; // private String previousStream; // // public AggregatedEvent(Event event, String previousStream) { // this.event = event; // this.previousStream = previousStream; // } // // public AggregatedEvent(Event event) { // this.event = event; // } // // public Event getEvent() { // return event; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // AggregatedEvent that = (AggregatedEvent) o; // // if (event != null ? !event.equals(that.event) : that.event != null) return false; // if (previousStream != null ? !previousStream.equals(that.previousStream) : that.previousStream != null) // return false; // // return true; // } // // @Override // public int hashCode() { // int result = event != null ? event.hashCode() : 0; // result = 31 * result + (previousStream != null ? previousStream.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "AggregatedEvent{" + // "event=" + event + // ", previousStream='" + previousStream + '\'' + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/support/window/WindowItem.java // public class WindowItem { // Event event; // long timestamp; // String previousStream; // // public WindowItem(Event event, long timestamp, String previousStream) { // this.event = event; // this.timestamp = timestamp; // this.previousStream = previousStream; // } // // public Event getEvent() { // return event; // } // // public long getTimestamp() { // return timestamp; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public String toString() { // return "WindowItem{" + // "event=" + event + // ", timestamp=" + timestamp + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/exceptions/FlowmixException.java // public class FlowmixException extends RuntimeException { // // public FlowmixException(String msg, Throwable t) { // super(msg, t); // } // // } // Path: src/main/java/org/calrissian/flowmix/api/aggregator/AbstractAggregator.java import org.calrissian.mango.domain.event.BaseEvent; import org.calrissian.mango.domain.event.Event; import static java.lang.System.currentTimeMillis; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import static java.util.UUID.randomUUID; import org.apache.commons.lang.StringUtils; import org.calrissian.flowmix.api.Aggregator; import static org.calrissian.flowmix.api.Aggregator.GROUP_BY; import static org.calrissian.flowmix.api.Aggregator.GROUP_BY_DELIM; import org.calrissian.flowmix.core.model.event.AggregatedEvent; import org.calrissian.flowmix.core.support.window.WindowItem; import org.calrissian.flowmix.exceptions.FlowmixException; import org.calrissian.mango.domain.Tuple; /* * Copyright 2015 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.aggregator; /** * * Abstract aggregator for simple implementations * * @param <T> Aggregation result type * @param <F> Field type */ public abstract class AbstractAggregator<T, F> implements Aggregator { /** * field to operate with */ public static final String OPERATED_FIELD = "operatedField"; /** * output field */ public static final String OUTPUT_FIELD = "outputField"; /** * grouped fields description */ protected Map<String, Collection<Tuple>> groupedValues; /** * fields to group by */ protected String[] groupByFields; /** * operated field name */ protected String operatedField; /** * output field set by implementation */ protected String outputField = getOutputField(); /** * * @return output field implementation */ protected abstract String getOutputField(); /** * * @param configuration */ @Override public void configure(Map<String, String> configuration) { if (configuration.get(GROUP_BY) != null) { groupByFields = StringUtils.splitPreserveAllTokens(configuration.get(GROUP_BY), GROUP_BY_DELIM); } if (configuration.get(OUTPUT_FIELD) != null) { outputField = configuration.get(OUTPUT_FIELD); } if (configuration.get(OPERATED_FIELD) != null) { operatedField = configuration.get(OPERATED_FIELD); } else { throw new RuntimeException("Aggregator needs a field to operate it. Property missing: " + OPERATED_FIELD); } } /** * * @param fieldValue field value to work with after item is added to grouped * values */ public abstract void add(F fieldValue); /** * * @param item * @throws org.calrissian.flowmix.exceptions.FlowmixException */ @Override
public void added(WindowItem item){
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/aggregator/AbstractAggregator.java
// Path: src/main/java/org/calrissian/flowmix/api/Aggregator.java // public interface Aggregator extends Serializable { // // public static final String GROUP_BY = "groupBy"; // public static final String GROUP_BY_DELIM = "\u0000"; // // void configure(Map<String, String> configuration); // // void added(WindowItem item); // // void evicted(WindowItem item); // // List<AggregatedEvent> aggregate(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/event/AggregatedEvent.java // public class AggregatedEvent { // // private Event event; // private String previousStream; // // public AggregatedEvent(Event event, String previousStream) { // this.event = event; // this.previousStream = previousStream; // } // // public AggregatedEvent(Event event) { // this.event = event; // } // // public Event getEvent() { // return event; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // AggregatedEvent that = (AggregatedEvent) o; // // if (event != null ? !event.equals(that.event) : that.event != null) return false; // if (previousStream != null ? !previousStream.equals(that.previousStream) : that.previousStream != null) // return false; // // return true; // } // // @Override // public int hashCode() { // int result = event != null ? event.hashCode() : 0; // result = 31 * result + (previousStream != null ? previousStream.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "AggregatedEvent{" + // "event=" + event + // ", previousStream='" + previousStream + '\'' + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/support/window/WindowItem.java // public class WindowItem { // Event event; // long timestamp; // String previousStream; // // public WindowItem(Event event, long timestamp, String previousStream) { // this.event = event; // this.timestamp = timestamp; // this.previousStream = previousStream; // } // // public Event getEvent() { // return event; // } // // public long getTimestamp() { // return timestamp; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public String toString() { // return "WindowItem{" + // "event=" + event + // ", timestamp=" + timestamp + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/exceptions/FlowmixException.java // public class FlowmixException extends RuntimeException { // // public FlowmixException(String msg, Throwable t) { // super(msg, t); // } // // }
import org.calrissian.mango.domain.event.BaseEvent; import org.calrissian.mango.domain.event.Event; import static java.lang.System.currentTimeMillis; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import static java.util.UUID.randomUUID; import org.apache.commons.lang.StringUtils; import org.calrissian.flowmix.api.Aggregator; import static org.calrissian.flowmix.api.Aggregator.GROUP_BY; import static org.calrissian.flowmix.api.Aggregator.GROUP_BY_DELIM; import org.calrissian.flowmix.core.model.event.AggregatedEvent; import org.calrissian.flowmix.core.support.window.WindowItem; import org.calrissian.flowmix.exceptions.FlowmixException; import org.calrissian.mango.domain.Tuple;
operatedField = configuration.get(OPERATED_FIELD); } else { throw new RuntimeException("Aggregator needs a field to operate it. Property missing: " + OPERATED_FIELD); } } /** * * @param fieldValue field value to work with after item is added to grouped * values */ public abstract void add(F fieldValue); /** * * @param item * @throws org.calrissian.flowmix.exceptions.FlowmixException */ @Override public void added(WindowItem item){ if (groupedValues == null && groupByFields != null) { groupedValues = new HashMap<String, Collection<Tuple>>(); for (String group : groupByFields) { groupedValues.put(group, item.getEvent().getAll(group)); } } if (item.getEvent().get(operatedField) != null) { try { add(((F) item.getEvent().get(operatedField).getValue())); } catch (ClassCastException e) {
// Path: src/main/java/org/calrissian/flowmix/api/Aggregator.java // public interface Aggregator extends Serializable { // // public static final String GROUP_BY = "groupBy"; // public static final String GROUP_BY_DELIM = "\u0000"; // // void configure(Map<String, String> configuration); // // void added(WindowItem item); // // void evicted(WindowItem item); // // List<AggregatedEvent> aggregate(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/event/AggregatedEvent.java // public class AggregatedEvent { // // private Event event; // private String previousStream; // // public AggregatedEvent(Event event, String previousStream) { // this.event = event; // this.previousStream = previousStream; // } // // public AggregatedEvent(Event event) { // this.event = event; // } // // public Event getEvent() { // return event; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // AggregatedEvent that = (AggregatedEvent) o; // // if (event != null ? !event.equals(that.event) : that.event != null) return false; // if (previousStream != null ? !previousStream.equals(that.previousStream) : that.previousStream != null) // return false; // // return true; // } // // @Override // public int hashCode() { // int result = event != null ? event.hashCode() : 0; // result = 31 * result + (previousStream != null ? previousStream.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "AggregatedEvent{" + // "event=" + event + // ", previousStream='" + previousStream + '\'' + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/support/window/WindowItem.java // public class WindowItem { // Event event; // long timestamp; // String previousStream; // // public WindowItem(Event event, long timestamp, String previousStream) { // this.event = event; // this.timestamp = timestamp; // this.previousStream = previousStream; // } // // public Event getEvent() { // return event; // } // // public long getTimestamp() { // return timestamp; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public String toString() { // return "WindowItem{" + // "event=" + event + // ", timestamp=" + timestamp + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/exceptions/FlowmixException.java // public class FlowmixException extends RuntimeException { // // public FlowmixException(String msg, Throwable t) { // super(msg, t); // } // // } // Path: src/main/java/org/calrissian/flowmix/api/aggregator/AbstractAggregator.java import org.calrissian.mango.domain.event.BaseEvent; import org.calrissian.mango.domain.event.Event; import static java.lang.System.currentTimeMillis; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import static java.util.UUID.randomUUID; import org.apache.commons.lang.StringUtils; import org.calrissian.flowmix.api.Aggregator; import static org.calrissian.flowmix.api.Aggregator.GROUP_BY; import static org.calrissian.flowmix.api.Aggregator.GROUP_BY_DELIM; import org.calrissian.flowmix.core.model.event.AggregatedEvent; import org.calrissian.flowmix.core.support.window.WindowItem; import org.calrissian.flowmix.exceptions.FlowmixException; import org.calrissian.mango.domain.Tuple; operatedField = configuration.get(OPERATED_FIELD); } else { throw new RuntimeException("Aggregator needs a field to operate it. Property missing: " + OPERATED_FIELD); } } /** * * @param fieldValue field value to work with after item is added to grouped * values */ public abstract void add(F fieldValue); /** * * @param item * @throws org.calrissian.flowmix.exceptions.FlowmixException */ @Override public void added(WindowItem item){ if (groupedValues == null && groupByFields != null) { groupedValues = new HashMap<String, Collection<Tuple>>(); for (String group : groupByFields) { groupedValues.put(group, item.getEvent().getAll(group)); } } if (item.getEvent().get(operatedField) != null) { try { add(((F) item.getEvent().get(operatedField).getValue())); } catch (ClassCastException e) {
throw new FlowmixException("Problem converting value " + item.getEvent().get(operatedField).getValue(), e);
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/aggregator/AbstractAggregator.java
// Path: src/main/java/org/calrissian/flowmix/api/Aggregator.java // public interface Aggregator extends Serializable { // // public static final String GROUP_BY = "groupBy"; // public static final String GROUP_BY_DELIM = "\u0000"; // // void configure(Map<String, String> configuration); // // void added(WindowItem item); // // void evicted(WindowItem item); // // List<AggregatedEvent> aggregate(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/event/AggregatedEvent.java // public class AggregatedEvent { // // private Event event; // private String previousStream; // // public AggregatedEvent(Event event, String previousStream) { // this.event = event; // this.previousStream = previousStream; // } // // public AggregatedEvent(Event event) { // this.event = event; // } // // public Event getEvent() { // return event; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // AggregatedEvent that = (AggregatedEvent) o; // // if (event != null ? !event.equals(that.event) : that.event != null) return false; // if (previousStream != null ? !previousStream.equals(that.previousStream) : that.previousStream != null) // return false; // // return true; // } // // @Override // public int hashCode() { // int result = event != null ? event.hashCode() : 0; // result = 31 * result + (previousStream != null ? previousStream.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "AggregatedEvent{" + // "event=" + event + // ", previousStream='" + previousStream + '\'' + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/support/window/WindowItem.java // public class WindowItem { // Event event; // long timestamp; // String previousStream; // // public WindowItem(Event event, long timestamp, String previousStream) { // this.event = event; // this.timestamp = timestamp; // this.previousStream = previousStream; // } // // public Event getEvent() { // return event; // } // // public long getTimestamp() { // return timestamp; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public String toString() { // return "WindowItem{" + // "event=" + event + // ", timestamp=" + timestamp + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/exceptions/FlowmixException.java // public class FlowmixException extends RuntimeException { // // public FlowmixException(String msg, Throwable t) { // super(msg, t); // } // // }
import org.calrissian.mango.domain.event.BaseEvent; import org.calrissian.mango.domain.event.Event; import static java.lang.System.currentTimeMillis; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import static java.util.UUID.randomUUID; import org.apache.commons.lang.StringUtils; import org.calrissian.flowmix.api.Aggregator; import static org.calrissian.flowmix.api.Aggregator.GROUP_BY; import static org.calrissian.flowmix.api.Aggregator.GROUP_BY_DELIM; import org.calrissian.flowmix.core.model.event.AggregatedEvent; import org.calrissian.flowmix.core.support.window.WindowItem; import org.calrissian.flowmix.exceptions.FlowmixException; import org.calrissian.mango.domain.Tuple;
/** * * @param item item to evict * @throws org.calrissian.flowmix.exceptions.FlowmixException */ @Override public void evicted(WindowItem item){ if (item.getEvent().get(operatedField) != null) { try { evict((F) item.getEvent().get(operatedField).getValue()); } catch (ClassCastException e) { throw new FlowmixException("Problem converting value " + item.getEvent().get(operatedField).getValue(), e); } } } public abstract void evict(F fieldValue); /** * * @return aggregation result provided by implementation */ protected abstract T aggregateResult(); /** * * @return */ @Override
// Path: src/main/java/org/calrissian/flowmix/api/Aggregator.java // public interface Aggregator extends Serializable { // // public static final String GROUP_BY = "groupBy"; // public static final String GROUP_BY_DELIM = "\u0000"; // // void configure(Map<String, String> configuration); // // void added(WindowItem item); // // void evicted(WindowItem item); // // List<AggregatedEvent> aggregate(); // } // // Path: src/main/java/org/calrissian/flowmix/core/model/event/AggregatedEvent.java // public class AggregatedEvent { // // private Event event; // private String previousStream; // // public AggregatedEvent(Event event, String previousStream) { // this.event = event; // this.previousStream = previousStream; // } // // public AggregatedEvent(Event event) { // this.event = event; // } // // public Event getEvent() { // return event; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // AggregatedEvent that = (AggregatedEvent) o; // // if (event != null ? !event.equals(that.event) : that.event != null) return false; // if (previousStream != null ? !previousStream.equals(that.previousStream) : that.previousStream != null) // return false; // // return true; // } // // @Override // public int hashCode() { // int result = event != null ? event.hashCode() : 0; // result = 31 * result + (previousStream != null ? previousStream.hashCode() : 0); // return result; // } // // @Override // public String toString() { // return "AggregatedEvent{" + // "event=" + event + // ", previousStream='" + previousStream + '\'' + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/core/support/window/WindowItem.java // public class WindowItem { // Event event; // long timestamp; // String previousStream; // // public WindowItem(Event event, long timestamp, String previousStream) { // this.event = event; // this.timestamp = timestamp; // this.previousStream = previousStream; // } // // public Event getEvent() { // return event; // } // // public long getTimestamp() { // return timestamp; // } // // public String getPreviousStream() { // return previousStream; // } // // @Override // public String toString() { // return "WindowItem{" + // "event=" + event + // ", timestamp=" + timestamp + // '}'; // } // } // // Path: src/main/java/org/calrissian/flowmix/exceptions/FlowmixException.java // public class FlowmixException extends RuntimeException { // // public FlowmixException(String msg, Throwable t) { // super(msg, t); // } // // } // Path: src/main/java/org/calrissian/flowmix/api/aggregator/AbstractAggregator.java import org.calrissian.mango.domain.event.BaseEvent; import org.calrissian.mango.domain.event.Event; import static java.lang.System.currentTimeMillis; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import static java.util.UUID.randomUUID; import org.apache.commons.lang.StringUtils; import org.calrissian.flowmix.api.Aggregator; import static org.calrissian.flowmix.api.Aggregator.GROUP_BY; import static org.calrissian.flowmix.api.Aggregator.GROUP_BY_DELIM; import org.calrissian.flowmix.core.model.event.AggregatedEvent; import org.calrissian.flowmix.core.support.window.WindowItem; import org.calrissian.flowmix.exceptions.FlowmixException; import org.calrissian.mango.domain.Tuple; /** * * @param item item to evict * @throws org.calrissian.flowmix.exceptions.FlowmixException */ @Override public void evicted(WindowItem item){ if (item.getEvent().get(operatedField) != null) { try { evict((F) item.getEvent().get(operatedField).getValue()); } catch (ClassCastException e) { throw new FlowmixException("Problem converting value " + item.getEvent().get(operatedField).getValue(), e); } } } public abstract void evict(F fieldValue); /** * * @return aggregation result provided by implementation */ protected abstract T aggregateResult(); /** * * @return */ @Override
public List<AggregatedEvent> aggregate() {
calrissian/flowmix
src/main/java/org/calrissian/flowmix/api/builder/FilterBuilder.java
// Path: src/main/java/org/calrissian/flowmix/core/model/op/FilterOp.java // public class FilterOp implements FlowOp { // // public static final String FILTER = "filter"; // Filter filter; // // public void setFilter(Filter filter) { // this.filter = filter; // } // // public Filter getFilter() { // return filter; // } // // @Override // public String getComponentName() { // return FILTER; // } // } // // Path: src/main/java/org/calrissian/flowmix/api/Filter.java // public interface Filter extends Serializable { // // boolean accept(Event event); // }
import org.calrissian.flowmix.core.model.op.FilterOp; import org.calrissian.flowmix.api.Filter;
/* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.builder; public class FilterBuilder extends AbstractOpBuilder { private FilterOp filterOp = new FilterOp(); public FilterBuilder(StreamBuilder fob) { super(fob); }
// Path: src/main/java/org/calrissian/flowmix/core/model/op/FilterOp.java // public class FilterOp implements FlowOp { // // public static final String FILTER = "filter"; // Filter filter; // // public void setFilter(Filter filter) { // this.filter = filter; // } // // public Filter getFilter() { // return filter; // } // // @Override // public String getComponentName() { // return FILTER; // } // } // // Path: src/main/java/org/calrissian/flowmix/api/Filter.java // public interface Filter extends Serializable { // // boolean accept(Event event); // } // Path: src/main/java/org/calrissian/flowmix/api/builder/FilterBuilder.java import org.calrissian.flowmix.core.model.op.FilterOp; import org.calrissian.flowmix.api.Filter; /* * Copyright (C) 2014 The Calrissian Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.calrissian.flowmix.api.builder; public class FilterBuilder extends AbstractOpBuilder { private FilterOp filterOp = new FilterOp(); public FilterBuilder(StreamBuilder fob) { super(fob); }
public FilterBuilder filter(Filter filter) {
Appolica/Flubber
Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/settings/SettingsFragment.java
// Path: Flubber/demo/src/main/java/com/appolica/sample/ui/animation/CustomAnimationBody.java // public class CustomAnimationBody extends AnimationBody implements Serializable { // // private transient Map<FieldName, PropertyMethodsHolder<Long>> longProperties; // private transient Map<FieldName, PropertyMethodsHolder<Float>> floatProperties; // private transient Map<Class<?>, Map<FieldName, ? extends PropertyMethodsHolder<?>>> typesMap; // // public CustomAnimationBody() { // init(); // } // // public void init() { // longProperties = new HashMap<>(); // floatProperties = new HashMap<>(); // typesMap = new HashMap<>(); // // longProperties.put(FieldName.DURATION, PropertyMethodsHolder.fields(this::getDuration, this::setDuration)); // longProperties.put(FieldName.DELAY, PropertyMethodsHolder.fields(this::getDelay, this::setDelay)); // // floatProperties.put(FieldName.FORCE, PropertyMethodsHolder.fields(this::getForce, this::setForce)); // floatProperties.put(FieldName.VELOCITY, PropertyMethodsHolder.fields(this::getVelocity, this::setVelocity)); // floatProperties.put(FieldName.DAMPING, PropertyMethodsHolder.fields(this::getDamping, this::setDamping)); // floatProperties.put(FieldName.SCALE, PropertyMethodsHolder.fields( // this::getEndScaleX, // (scale) -> { // setEndScaleX(scale); // setEndScaleY(scale); // })); // // typesMap.put(Long.class, longProperties); // typesMap.put(Float.class, floatProperties); // } // // public void setProperty(FieldName name, long value) { // final PropertyMethodsHolder<Long> methodsHolder = longProperties.get(name); // final PropertyMethodsHolder.Setter<Long> setter = methodsHolder.setter(); // // setter.set(value); // } // // public void setProperty(FieldName name, float value) { // final PropertyMethodsHolder<Float> methodsHolder = floatProperties.get(name); // final PropertyMethodsHolder.Setter<Float> setter = methodsHolder.setter(); // // setter.set(value); // } // // public <T extends Number> T getPropertyValue(FieldName name, Class<?> numberClass) { // if (!typesMap.containsKey(numberClass)) { // throw new IllegalArgumentException("There is no property of type: " + numberClass); // } // // final Map<FieldName, ? extends PropertyMethodsHolder<?>> propertiesMap = typesMap.get(numberClass); // final PropertyMethodsHolder<?> holder = propertiesMap.get(name); // final PropertyMethodsHolder.Getter<?> getter = holder.getter(); // // return (T) getter.get(); // } // // public Map<FieldName, PropertyMethodsHolder<Long>> getLongProperties() { // return longProperties; // } // // public Map<FieldName, PropertyMethodsHolder<Float>> getFloatProperties() { // return floatProperties; // } // // public enum FieldName { // DURATION(R.string.duration), // DELAY(R.string.delay), // FORCE(R.string.force), // VELOCITY(R.string.velocity), // DAMPING(R.string.damping), // SCALE(R.string.scale); // // private static final Map<Integer, FieldName> idNamesMap; // // static { // idNamesMap = // Stream.of(FieldName.values()) // .collect(Collectors.toMap((name -> name.stringId), (name -> name))); // } // // private final int stringId; // // FieldName(int stringId) { // this.stringId = stringId; // } // // @Nullable // public static FieldName forStringId(int stringId) { // return idNamesMap.get(stringId); // } // // public int getStringId() { // return stringId; // } // } // } // // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/AnimationBodyHolder.java // public interface AnimationBodyHolder { // void setAnimationBody(CustomAnimationBody animationBody); // } // // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/BaseFragment.java // public abstract class BaseFragment<AdapterT extends RecyclerView.Adapter> extends Fragment { // // private PagerFragmentBinding binding; // private AdapterT adapter; // // @Nullable // @Override // public View onCreateView( // LayoutInflater inflater, // @Nullable ViewGroup container, // @Nullable Bundle savedInstanceState) { // // binding = DataBindingUtil.inflate(inflater, R.layout.fragment_editor_page, container, false); // // return binding.getRoot(); // } // // @Override // public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // // binding.recyclerView.setHasFixedSize(true); // binding.recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); // adapter = getAdapterInstance(); // binding.recyclerView.setAdapter(adapter); // } // // protected abstract AdapterT getAdapterInstance(); // // public AdapterT getAdapter() { // return adapter; // } // }
import android.os.Bundle; import androidx.annotation.Nullable; import android.view.View; import com.appolica.sample.ui.animation.CustomAnimationBody; import com.appolica.sample.ui.editor.AnimationBodyHolder; import com.appolica.sample.ui.editor.pager.BaseFragment;
package com.appolica.sample.ui.editor.pager.settings; public class SettingsFragment extends BaseFragment<SettingsRVAdapter> implements SettingsRVAdapter.OnModelChangedCallback,
// Path: Flubber/demo/src/main/java/com/appolica/sample/ui/animation/CustomAnimationBody.java // public class CustomAnimationBody extends AnimationBody implements Serializable { // // private transient Map<FieldName, PropertyMethodsHolder<Long>> longProperties; // private transient Map<FieldName, PropertyMethodsHolder<Float>> floatProperties; // private transient Map<Class<?>, Map<FieldName, ? extends PropertyMethodsHolder<?>>> typesMap; // // public CustomAnimationBody() { // init(); // } // // public void init() { // longProperties = new HashMap<>(); // floatProperties = new HashMap<>(); // typesMap = new HashMap<>(); // // longProperties.put(FieldName.DURATION, PropertyMethodsHolder.fields(this::getDuration, this::setDuration)); // longProperties.put(FieldName.DELAY, PropertyMethodsHolder.fields(this::getDelay, this::setDelay)); // // floatProperties.put(FieldName.FORCE, PropertyMethodsHolder.fields(this::getForce, this::setForce)); // floatProperties.put(FieldName.VELOCITY, PropertyMethodsHolder.fields(this::getVelocity, this::setVelocity)); // floatProperties.put(FieldName.DAMPING, PropertyMethodsHolder.fields(this::getDamping, this::setDamping)); // floatProperties.put(FieldName.SCALE, PropertyMethodsHolder.fields( // this::getEndScaleX, // (scale) -> { // setEndScaleX(scale); // setEndScaleY(scale); // })); // // typesMap.put(Long.class, longProperties); // typesMap.put(Float.class, floatProperties); // } // // public void setProperty(FieldName name, long value) { // final PropertyMethodsHolder<Long> methodsHolder = longProperties.get(name); // final PropertyMethodsHolder.Setter<Long> setter = methodsHolder.setter(); // // setter.set(value); // } // // public void setProperty(FieldName name, float value) { // final PropertyMethodsHolder<Float> methodsHolder = floatProperties.get(name); // final PropertyMethodsHolder.Setter<Float> setter = methodsHolder.setter(); // // setter.set(value); // } // // public <T extends Number> T getPropertyValue(FieldName name, Class<?> numberClass) { // if (!typesMap.containsKey(numberClass)) { // throw new IllegalArgumentException("There is no property of type: " + numberClass); // } // // final Map<FieldName, ? extends PropertyMethodsHolder<?>> propertiesMap = typesMap.get(numberClass); // final PropertyMethodsHolder<?> holder = propertiesMap.get(name); // final PropertyMethodsHolder.Getter<?> getter = holder.getter(); // // return (T) getter.get(); // } // // public Map<FieldName, PropertyMethodsHolder<Long>> getLongProperties() { // return longProperties; // } // // public Map<FieldName, PropertyMethodsHolder<Float>> getFloatProperties() { // return floatProperties; // } // // public enum FieldName { // DURATION(R.string.duration), // DELAY(R.string.delay), // FORCE(R.string.force), // VELOCITY(R.string.velocity), // DAMPING(R.string.damping), // SCALE(R.string.scale); // // private static final Map<Integer, FieldName> idNamesMap; // // static { // idNamesMap = // Stream.of(FieldName.values()) // .collect(Collectors.toMap((name -> name.stringId), (name -> name))); // } // // private final int stringId; // // FieldName(int stringId) { // this.stringId = stringId; // } // // @Nullable // public static FieldName forStringId(int stringId) { // return idNamesMap.get(stringId); // } // // public int getStringId() { // return stringId; // } // } // } // // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/AnimationBodyHolder.java // public interface AnimationBodyHolder { // void setAnimationBody(CustomAnimationBody animationBody); // } // // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/BaseFragment.java // public abstract class BaseFragment<AdapterT extends RecyclerView.Adapter> extends Fragment { // // private PagerFragmentBinding binding; // private AdapterT adapter; // // @Nullable // @Override // public View onCreateView( // LayoutInflater inflater, // @Nullable ViewGroup container, // @Nullable Bundle savedInstanceState) { // // binding = DataBindingUtil.inflate(inflater, R.layout.fragment_editor_page, container, false); // // return binding.getRoot(); // } // // @Override // public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // // binding.recyclerView.setHasFixedSize(true); // binding.recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); // adapter = getAdapterInstance(); // binding.recyclerView.setAdapter(adapter); // } // // protected abstract AdapterT getAdapterInstance(); // // public AdapterT getAdapter() { // return adapter; // } // } // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/settings/SettingsFragment.java import android.os.Bundle; import androidx.annotation.Nullable; import android.view.View; import com.appolica.sample.ui.animation.CustomAnimationBody; import com.appolica.sample.ui.editor.AnimationBodyHolder; import com.appolica.sample.ui.editor.pager.BaseFragment; package com.appolica.sample.ui.editor.pager.settings; public class SettingsFragment extends BaseFragment<SettingsRVAdapter> implements SettingsRVAdapter.OnModelChangedCallback,
AnimationBodyHolder {
Appolica/Flubber
Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/settings/SettingsFragment.java
// Path: Flubber/demo/src/main/java/com/appolica/sample/ui/animation/CustomAnimationBody.java // public class CustomAnimationBody extends AnimationBody implements Serializable { // // private transient Map<FieldName, PropertyMethodsHolder<Long>> longProperties; // private transient Map<FieldName, PropertyMethodsHolder<Float>> floatProperties; // private transient Map<Class<?>, Map<FieldName, ? extends PropertyMethodsHolder<?>>> typesMap; // // public CustomAnimationBody() { // init(); // } // // public void init() { // longProperties = new HashMap<>(); // floatProperties = new HashMap<>(); // typesMap = new HashMap<>(); // // longProperties.put(FieldName.DURATION, PropertyMethodsHolder.fields(this::getDuration, this::setDuration)); // longProperties.put(FieldName.DELAY, PropertyMethodsHolder.fields(this::getDelay, this::setDelay)); // // floatProperties.put(FieldName.FORCE, PropertyMethodsHolder.fields(this::getForce, this::setForce)); // floatProperties.put(FieldName.VELOCITY, PropertyMethodsHolder.fields(this::getVelocity, this::setVelocity)); // floatProperties.put(FieldName.DAMPING, PropertyMethodsHolder.fields(this::getDamping, this::setDamping)); // floatProperties.put(FieldName.SCALE, PropertyMethodsHolder.fields( // this::getEndScaleX, // (scale) -> { // setEndScaleX(scale); // setEndScaleY(scale); // })); // // typesMap.put(Long.class, longProperties); // typesMap.put(Float.class, floatProperties); // } // // public void setProperty(FieldName name, long value) { // final PropertyMethodsHolder<Long> methodsHolder = longProperties.get(name); // final PropertyMethodsHolder.Setter<Long> setter = methodsHolder.setter(); // // setter.set(value); // } // // public void setProperty(FieldName name, float value) { // final PropertyMethodsHolder<Float> methodsHolder = floatProperties.get(name); // final PropertyMethodsHolder.Setter<Float> setter = methodsHolder.setter(); // // setter.set(value); // } // // public <T extends Number> T getPropertyValue(FieldName name, Class<?> numberClass) { // if (!typesMap.containsKey(numberClass)) { // throw new IllegalArgumentException("There is no property of type: " + numberClass); // } // // final Map<FieldName, ? extends PropertyMethodsHolder<?>> propertiesMap = typesMap.get(numberClass); // final PropertyMethodsHolder<?> holder = propertiesMap.get(name); // final PropertyMethodsHolder.Getter<?> getter = holder.getter(); // // return (T) getter.get(); // } // // public Map<FieldName, PropertyMethodsHolder<Long>> getLongProperties() { // return longProperties; // } // // public Map<FieldName, PropertyMethodsHolder<Float>> getFloatProperties() { // return floatProperties; // } // // public enum FieldName { // DURATION(R.string.duration), // DELAY(R.string.delay), // FORCE(R.string.force), // VELOCITY(R.string.velocity), // DAMPING(R.string.damping), // SCALE(R.string.scale); // // private static final Map<Integer, FieldName> idNamesMap; // // static { // idNamesMap = // Stream.of(FieldName.values()) // .collect(Collectors.toMap((name -> name.stringId), (name -> name))); // } // // private final int stringId; // // FieldName(int stringId) { // this.stringId = stringId; // } // // @Nullable // public static FieldName forStringId(int stringId) { // return idNamesMap.get(stringId); // } // // public int getStringId() { // return stringId; // } // } // } // // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/AnimationBodyHolder.java // public interface AnimationBodyHolder { // void setAnimationBody(CustomAnimationBody animationBody); // } // // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/BaseFragment.java // public abstract class BaseFragment<AdapterT extends RecyclerView.Adapter> extends Fragment { // // private PagerFragmentBinding binding; // private AdapterT adapter; // // @Nullable // @Override // public View onCreateView( // LayoutInflater inflater, // @Nullable ViewGroup container, // @Nullable Bundle savedInstanceState) { // // binding = DataBindingUtil.inflate(inflater, R.layout.fragment_editor_page, container, false); // // return binding.getRoot(); // } // // @Override // public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // // binding.recyclerView.setHasFixedSize(true); // binding.recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); // adapter = getAdapterInstance(); // binding.recyclerView.setAdapter(adapter); // } // // protected abstract AdapterT getAdapterInstance(); // // public AdapterT getAdapter() { // return adapter; // } // }
import android.os.Bundle; import androidx.annotation.Nullable; import android.view.View; import com.appolica.sample.ui.animation.CustomAnimationBody; import com.appolica.sample.ui.editor.AnimationBodyHolder; import com.appolica.sample.ui.editor.pager.BaseFragment;
package com.appolica.sample.ui.editor.pager.settings; public class SettingsFragment extends BaseFragment<SettingsRVAdapter> implements SettingsRVAdapter.OnModelChangedCallback, AnimationBodyHolder { public static final String TAG = "SettingsFragment"; private OnFieldChangedListener fieldChangedListener;
// Path: Flubber/demo/src/main/java/com/appolica/sample/ui/animation/CustomAnimationBody.java // public class CustomAnimationBody extends AnimationBody implements Serializable { // // private transient Map<FieldName, PropertyMethodsHolder<Long>> longProperties; // private transient Map<FieldName, PropertyMethodsHolder<Float>> floatProperties; // private transient Map<Class<?>, Map<FieldName, ? extends PropertyMethodsHolder<?>>> typesMap; // // public CustomAnimationBody() { // init(); // } // // public void init() { // longProperties = new HashMap<>(); // floatProperties = new HashMap<>(); // typesMap = new HashMap<>(); // // longProperties.put(FieldName.DURATION, PropertyMethodsHolder.fields(this::getDuration, this::setDuration)); // longProperties.put(FieldName.DELAY, PropertyMethodsHolder.fields(this::getDelay, this::setDelay)); // // floatProperties.put(FieldName.FORCE, PropertyMethodsHolder.fields(this::getForce, this::setForce)); // floatProperties.put(FieldName.VELOCITY, PropertyMethodsHolder.fields(this::getVelocity, this::setVelocity)); // floatProperties.put(FieldName.DAMPING, PropertyMethodsHolder.fields(this::getDamping, this::setDamping)); // floatProperties.put(FieldName.SCALE, PropertyMethodsHolder.fields( // this::getEndScaleX, // (scale) -> { // setEndScaleX(scale); // setEndScaleY(scale); // })); // // typesMap.put(Long.class, longProperties); // typesMap.put(Float.class, floatProperties); // } // // public void setProperty(FieldName name, long value) { // final PropertyMethodsHolder<Long> methodsHolder = longProperties.get(name); // final PropertyMethodsHolder.Setter<Long> setter = methodsHolder.setter(); // // setter.set(value); // } // // public void setProperty(FieldName name, float value) { // final PropertyMethodsHolder<Float> methodsHolder = floatProperties.get(name); // final PropertyMethodsHolder.Setter<Float> setter = methodsHolder.setter(); // // setter.set(value); // } // // public <T extends Number> T getPropertyValue(FieldName name, Class<?> numberClass) { // if (!typesMap.containsKey(numberClass)) { // throw new IllegalArgumentException("There is no property of type: " + numberClass); // } // // final Map<FieldName, ? extends PropertyMethodsHolder<?>> propertiesMap = typesMap.get(numberClass); // final PropertyMethodsHolder<?> holder = propertiesMap.get(name); // final PropertyMethodsHolder.Getter<?> getter = holder.getter(); // // return (T) getter.get(); // } // // public Map<FieldName, PropertyMethodsHolder<Long>> getLongProperties() { // return longProperties; // } // // public Map<FieldName, PropertyMethodsHolder<Float>> getFloatProperties() { // return floatProperties; // } // // public enum FieldName { // DURATION(R.string.duration), // DELAY(R.string.delay), // FORCE(R.string.force), // VELOCITY(R.string.velocity), // DAMPING(R.string.damping), // SCALE(R.string.scale); // // private static final Map<Integer, FieldName> idNamesMap; // // static { // idNamesMap = // Stream.of(FieldName.values()) // .collect(Collectors.toMap((name -> name.stringId), (name -> name))); // } // // private final int stringId; // // FieldName(int stringId) { // this.stringId = stringId; // } // // @Nullable // public static FieldName forStringId(int stringId) { // return idNamesMap.get(stringId); // } // // public int getStringId() { // return stringId; // } // } // } // // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/AnimationBodyHolder.java // public interface AnimationBodyHolder { // void setAnimationBody(CustomAnimationBody animationBody); // } // // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/BaseFragment.java // public abstract class BaseFragment<AdapterT extends RecyclerView.Adapter> extends Fragment { // // private PagerFragmentBinding binding; // private AdapterT adapter; // // @Nullable // @Override // public View onCreateView( // LayoutInflater inflater, // @Nullable ViewGroup container, // @Nullable Bundle savedInstanceState) { // // binding = DataBindingUtil.inflate(inflater, R.layout.fragment_editor_page, container, false); // // return binding.getRoot(); // } // // @Override // public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // // binding.recyclerView.setHasFixedSize(true); // binding.recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); // adapter = getAdapterInstance(); // binding.recyclerView.setAdapter(adapter); // } // // protected abstract AdapterT getAdapterInstance(); // // public AdapterT getAdapter() { // return adapter; // } // } // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/settings/SettingsFragment.java import android.os.Bundle; import androidx.annotation.Nullable; import android.view.View; import com.appolica.sample.ui.animation.CustomAnimationBody; import com.appolica.sample.ui.editor.AnimationBodyHolder; import com.appolica.sample.ui.editor.pager.BaseFragment; package com.appolica.sample.ui.editor.pager.settings; public class SettingsFragment extends BaseFragment<SettingsRVAdapter> implements SettingsRVAdapter.OnModelChangedCallback, AnimationBodyHolder { public static final String TAG = "SettingsFragment"; private OnFieldChangedListener fieldChangedListener;
private CustomAnimationBody animationBody;
Appolica/Flubber
Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/EditorFragmentType.java
// Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/animations/AnimationsFragment.java // public class AnimationsFragment // extends BaseRadioRVFragment // implements RadioRVAdapter.OnElementSelectedListener { // // public static final String TAG = "AnimationsFragment"; // // private Map<String, Flubber.AnimationPreset> animationNamesMap = // StringUtils.normalizedNameMapFor(Flubber.AnimationPreset.class); // // private OnAnimationSelectedListener selectedListener; // // @Override // public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // // final RadioRVAdapter adapter = getAdapter(); // // adapter.setSelectedListener(this); // // final AnimationBody animationBody = getAnimationBody(); // if (animationBody.getAnimation() == null) { // adapter.setSelected(0); // // } else { // final Flubber.AnimationProvider animationProvider = ((Flubber.AnimationPreset) animationBody.getAnimation()).getProvider(); // final Flubber.AnimationPreset animationPreset = Flubber.AnimationPreset.valueFor(animationProvider); // final RadioElementModel radioElementModel = Utils.convertEnumToModel(animationPreset); // // final int index = adapter.getData().indexOf(radioElementModel); // // adapter.setSelected(index); // } // } // // @Override // public List<RadioElementModel> getData() { // return Utils.convertMapToData(animationNamesMap); // } // // @Override // public void onElementSelected(RadioElementModel model) { // if (selectedListener != null) { // selectedListener.onAnimationSelected(animationNamesMap.get(model.getName().get())); // } // } // // public void setSelectedListener(OnAnimationSelectedListener selectedListener) { // this.selectedListener = selectedListener; // } // } // // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/interpolators/InterpolatorsFragment.java // public class InterpolatorsFragment // extends BaseRadioRVFragment // implements RadioRVAdapter.OnElementSelectedListener { // // public static final String TAG = "InterpolatorsFragment"; // // private Map<String, Flubber.Curve> interpolatorNamesMap = // StringUtils.normalizedNameMapFor(Flubber.Curve.class); // // private OnInterpolatorSelectedListener selectedListener; // // @Override // public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // // final RadioRVAdapter adapter = getAdapter(); // // getAdapter().setSelectedListener(this); // // final AnimationBody animationBody = getAnimationBody(); // if (animationBody.getInterpolator() == null) { // getAdapter().setSelected(0); // } else { // final Flubber.InterpolatorProvider interpolatorProvider = ((Flubber.Curve) animationBody.getInterpolator()).getProvider(); // final Flubber.Curve interpolator = Flubber.Curve.valueFor(interpolatorProvider); // final RadioElementModel radioElementModel = Utils.convertEnumToModel(interpolator); // // final int index = adapter.getData().indexOf(radioElementModel); // // adapter.setSelected(index); // } // } // // @Override // public List<RadioElementModel> getData() { // return Utils.convertMapToData(interpolatorNamesMap); // } // // @Override // public void onElementSelected(RadioElementModel model) { // if (selectedListener != null) { // selectedListener.onInterpolatorSelected(interpolatorNamesMap.get(model.getName().get())); // } // } // // public void setSelectedListener(OnInterpolatorSelectedListener selectedListener) { // this.selectedListener = selectedListener; // } // // } // // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/settings/SettingsFragment.java // public class SettingsFragment // extends BaseFragment<SettingsRVAdapter> // implements SettingsRVAdapter.OnModelChangedCallback, // AnimationBodyHolder { // // public static final String TAG = "SettingsFragment"; // // private OnFieldChangedListener fieldChangedListener; // private CustomAnimationBody animationBody; // // @Override // public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // // getAdapter().setAnimationBody(animationBody); // getAdapter().setModelChangedCallback(this); // } // // @Override // protected SettingsRVAdapter getAdapterInstance() { // return new SettingsRVAdapter(getContext()); // } // // @Override // public void onModelChanged(SeekBarModel model) { // if (fieldChangedListener != null) { // fieldChangedListener.onPropertyChanged(model); // } // } // // public void setFieldChangedListener(OnFieldChangedListener fieldChangedListener) { // this.fieldChangedListener = fieldChangedListener; // } // // @Override // public void setAnimationBody(CustomAnimationBody animationBody) { // this.animationBody = animationBody; // } // }
import androidx.fragment.app.Fragment; import com.appolica.sample.R; import com.appolica.sample.ui.editor.pager.animations.AnimationsFragment; import com.appolica.sample.ui.editor.pager.interpolators.InterpolatorsFragment; import com.appolica.sample.ui.editor.pager.settings.SettingsFragment;
package com.appolica.sample.ui.editor.pager; public enum EditorFragmentType { ANIMATIONS(AnimationsFragment.class, AnimationsFragment.TAG, R.string.tab_animation),
// Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/animations/AnimationsFragment.java // public class AnimationsFragment // extends BaseRadioRVFragment // implements RadioRVAdapter.OnElementSelectedListener { // // public static final String TAG = "AnimationsFragment"; // // private Map<String, Flubber.AnimationPreset> animationNamesMap = // StringUtils.normalizedNameMapFor(Flubber.AnimationPreset.class); // // private OnAnimationSelectedListener selectedListener; // // @Override // public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // // final RadioRVAdapter adapter = getAdapter(); // // adapter.setSelectedListener(this); // // final AnimationBody animationBody = getAnimationBody(); // if (animationBody.getAnimation() == null) { // adapter.setSelected(0); // // } else { // final Flubber.AnimationProvider animationProvider = ((Flubber.AnimationPreset) animationBody.getAnimation()).getProvider(); // final Flubber.AnimationPreset animationPreset = Flubber.AnimationPreset.valueFor(animationProvider); // final RadioElementModel radioElementModel = Utils.convertEnumToModel(animationPreset); // // final int index = adapter.getData().indexOf(radioElementModel); // // adapter.setSelected(index); // } // } // // @Override // public List<RadioElementModel> getData() { // return Utils.convertMapToData(animationNamesMap); // } // // @Override // public void onElementSelected(RadioElementModel model) { // if (selectedListener != null) { // selectedListener.onAnimationSelected(animationNamesMap.get(model.getName().get())); // } // } // // public void setSelectedListener(OnAnimationSelectedListener selectedListener) { // this.selectedListener = selectedListener; // } // } // // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/interpolators/InterpolatorsFragment.java // public class InterpolatorsFragment // extends BaseRadioRVFragment // implements RadioRVAdapter.OnElementSelectedListener { // // public static final String TAG = "InterpolatorsFragment"; // // private Map<String, Flubber.Curve> interpolatorNamesMap = // StringUtils.normalizedNameMapFor(Flubber.Curve.class); // // private OnInterpolatorSelectedListener selectedListener; // // @Override // public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // // final RadioRVAdapter adapter = getAdapter(); // // getAdapter().setSelectedListener(this); // // final AnimationBody animationBody = getAnimationBody(); // if (animationBody.getInterpolator() == null) { // getAdapter().setSelected(0); // } else { // final Flubber.InterpolatorProvider interpolatorProvider = ((Flubber.Curve) animationBody.getInterpolator()).getProvider(); // final Flubber.Curve interpolator = Flubber.Curve.valueFor(interpolatorProvider); // final RadioElementModel radioElementModel = Utils.convertEnumToModel(interpolator); // // final int index = adapter.getData().indexOf(radioElementModel); // // adapter.setSelected(index); // } // } // // @Override // public List<RadioElementModel> getData() { // return Utils.convertMapToData(interpolatorNamesMap); // } // // @Override // public void onElementSelected(RadioElementModel model) { // if (selectedListener != null) { // selectedListener.onInterpolatorSelected(interpolatorNamesMap.get(model.getName().get())); // } // } // // public void setSelectedListener(OnInterpolatorSelectedListener selectedListener) { // this.selectedListener = selectedListener; // } // // } // // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/settings/SettingsFragment.java // public class SettingsFragment // extends BaseFragment<SettingsRVAdapter> // implements SettingsRVAdapter.OnModelChangedCallback, // AnimationBodyHolder { // // public static final String TAG = "SettingsFragment"; // // private OnFieldChangedListener fieldChangedListener; // private CustomAnimationBody animationBody; // // @Override // public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // // getAdapter().setAnimationBody(animationBody); // getAdapter().setModelChangedCallback(this); // } // // @Override // protected SettingsRVAdapter getAdapterInstance() { // return new SettingsRVAdapter(getContext()); // } // // @Override // public void onModelChanged(SeekBarModel model) { // if (fieldChangedListener != null) { // fieldChangedListener.onPropertyChanged(model); // } // } // // public void setFieldChangedListener(OnFieldChangedListener fieldChangedListener) { // this.fieldChangedListener = fieldChangedListener; // } // // @Override // public void setAnimationBody(CustomAnimationBody animationBody) { // this.animationBody = animationBody; // } // } // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/EditorFragmentType.java import androidx.fragment.app.Fragment; import com.appolica.sample.R; import com.appolica.sample.ui.editor.pager.animations.AnimationsFragment; import com.appolica.sample.ui.editor.pager.interpolators.InterpolatorsFragment; import com.appolica.sample.ui.editor.pager.settings.SettingsFragment; package com.appolica.sample.ui.editor.pager; public enum EditorFragmentType { ANIMATIONS(AnimationsFragment.class, AnimationsFragment.TAG, R.string.tab_animation),
INTERPOLATORS(InterpolatorsFragment.class, InterpolatorsFragment.TAG, R.string.tab_curve),
Appolica/Flubber
Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/EditorFragmentType.java
// Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/animations/AnimationsFragment.java // public class AnimationsFragment // extends BaseRadioRVFragment // implements RadioRVAdapter.OnElementSelectedListener { // // public static final String TAG = "AnimationsFragment"; // // private Map<String, Flubber.AnimationPreset> animationNamesMap = // StringUtils.normalizedNameMapFor(Flubber.AnimationPreset.class); // // private OnAnimationSelectedListener selectedListener; // // @Override // public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // // final RadioRVAdapter adapter = getAdapter(); // // adapter.setSelectedListener(this); // // final AnimationBody animationBody = getAnimationBody(); // if (animationBody.getAnimation() == null) { // adapter.setSelected(0); // // } else { // final Flubber.AnimationProvider animationProvider = ((Flubber.AnimationPreset) animationBody.getAnimation()).getProvider(); // final Flubber.AnimationPreset animationPreset = Flubber.AnimationPreset.valueFor(animationProvider); // final RadioElementModel radioElementModel = Utils.convertEnumToModel(animationPreset); // // final int index = adapter.getData().indexOf(radioElementModel); // // adapter.setSelected(index); // } // } // // @Override // public List<RadioElementModel> getData() { // return Utils.convertMapToData(animationNamesMap); // } // // @Override // public void onElementSelected(RadioElementModel model) { // if (selectedListener != null) { // selectedListener.onAnimationSelected(animationNamesMap.get(model.getName().get())); // } // } // // public void setSelectedListener(OnAnimationSelectedListener selectedListener) { // this.selectedListener = selectedListener; // } // } // // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/interpolators/InterpolatorsFragment.java // public class InterpolatorsFragment // extends BaseRadioRVFragment // implements RadioRVAdapter.OnElementSelectedListener { // // public static final String TAG = "InterpolatorsFragment"; // // private Map<String, Flubber.Curve> interpolatorNamesMap = // StringUtils.normalizedNameMapFor(Flubber.Curve.class); // // private OnInterpolatorSelectedListener selectedListener; // // @Override // public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // // final RadioRVAdapter adapter = getAdapter(); // // getAdapter().setSelectedListener(this); // // final AnimationBody animationBody = getAnimationBody(); // if (animationBody.getInterpolator() == null) { // getAdapter().setSelected(0); // } else { // final Flubber.InterpolatorProvider interpolatorProvider = ((Flubber.Curve) animationBody.getInterpolator()).getProvider(); // final Flubber.Curve interpolator = Flubber.Curve.valueFor(interpolatorProvider); // final RadioElementModel radioElementModel = Utils.convertEnumToModel(interpolator); // // final int index = adapter.getData().indexOf(radioElementModel); // // adapter.setSelected(index); // } // } // // @Override // public List<RadioElementModel> getData() { // return Utils.convertMapToData(interpolatorNamesMap); // } // // @Override // public void onElementSelected(RadioElementModel model) { // if (selectedListener != null) { // selectedListener.onInterpolatorSelected(interpolatorNamesMap.get(model.getName().get())); // } // } // // public void setSelectedListener(OnInterpolatorSelectedListener selectedListener) { // this.selectedListener = selectedListener; // } // // } // // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/settings/SettingsFragment.java // public class SettingsFragment // extends BaseFragment<SettingsRVAdapter> // implements SettingsRVAdapter.OnModelChangedCallback, // AnimationBodyHolder { // // public static final String TAG = "SettingsFragment"; // // private OnFieldChangedListener fieldChangedListener; // private CustomAnimationBody animationBody; // // @Override // public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // // getAdapter().setAnimationBody(animationBody); // getAdapter().setModelChangedCallback(this); // } // // @Override // protected SettingsRVAdapter getAdapterInstance() { // return new SettingsRVAdapter(getContext()); // } // // @Override // public void onModelChanged(SeekBarModel model) { // if (fieldChangedListener != null) { // fieldChangedListener.onPropertyChanged(model); // } // } // // public void setFieldChangedListener(OnFieldChangedListener fieldChangedListener) { // this.fieldChangedListener = fieldChangedListener; // } // // @Override // public void setAnimationBody(CustomAnimationBody animationBody) { // this.animationBody = animationBody; // } // }
import androidx.fragment.app.Fragment; import com.appolica.sample.R; import com.appolica.sample.ui.editor.pager.animations.AnimationsFragment; import com.appolica.sample.ui.editor.pager.interpolators.InterpolatorsFragment; import com.appolica.sample.ui.editor.pager.settings.SettingsFragment;
package com.appolica.sample.ui.editor.pager; public enum EditorFragmentType { ANIMATIONS(AnimationsFragment.class, AnimationsFragment.TAG, R.string.tab_animation), INTERPOLATORS(InterpolatorsFragment.class, InterpolatorsFragment.TAG, R.string.tab_curve),
// Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/animations/AnimationsFragment.java // public class AnimationsFragment // extends BaseRadioRVFragment // implements RadioRVAdapter.OnElementSelectedListener { // // public static final String TAG = "AnimationsFragment"; // // private Map<String, Flubber.AnimationPreset> animationNamesMap = // StringUtils.normalizedNameMapFor(Flubber.AnimationPreset.class); // // private OnAnimationSelectedListener selectedListener; // // @Override // public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // // final RadioRVAdapter adapter = getAdapter(); // // adapter.setSelectedListener(this); // // final AnimationBody animationBody = getAnimationBody(); // if (animationBody.getAnimation() == null) { // adapter.setSelected(0); // // } else { // final Flubber.AnimationProvider animationProvider = ((Flubber.AnimationPreset) animationBody.getAnimation()).getProvider(); // final Flubber.AnimationPreset animationPreset = Flubber.AnimationPreset.valueFor(animationProvider); // final RadioElementModel radioElementModel = Utils.convertEnumToModel(animationPreset); // // final int index = adapter.getData().indexOf(radioElementModel); // // adapter.setSelected(index); // } // } // // @Override // public List<RadioElementModel> getData() { // return Utils.convertMapToData(animationNamesMap); // } // // @Override // public void onElementSelected(RadioElementModel model) { // if (selectedListener != null) { // selectedListener.onAnimationSelected(animationNamesMap.get(model.getName().get())); // } // } // // public void setSelectedListener(OnAnimationSelectedListener selectedListener) { // this.selectedListener = selectedListener; // } // } // // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/interpolators/InterpolatorsFragment.java // public class InterpolatorsFragment // extends BaseRadioRVFragment // implements RadioRVAdapter.OnElementSelectedListener { // // public static final String TAG = "InterpolatorsFragment"; // // private Map<String, Flubber.Curve> interpolatorNamesMap = // StringUtils.normalizedNameMapFor(Flubber.Curve.class); // // private OnInterpolatorSelectedListener selectedListener; // // @Override // public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // // final RadioRVAdapter adapter = getAdapter(); // // getAdapter().setSelectedListener(this); // // final AnimationBody animationBody = getAnimationBody(); // if (animationBody.getInterpolator() == null) { // getAdapter().setSelected(0); // } else { // final Flubber.InterpolatorProvider interpolatorProvider = ((Flubber.Curve) animationBody.getInterpolator()).getProvider(); // final Flubber.Curve interpolator = Flubber.Curve.valueFor(interpolatorProvider); // final RadioElementModel radioElementModel = Utils.convertEnumToModel(interpolator); // // final int index = adapter.getData().indexOf(radioElementModel); // // adapter.setSelected(index); // } // } // // @Override // public List<RadioElementModel> getData() { // return Utils.convertMapToData(interpolatorNamesMap); // } // // @Override // public void onElementSelected(RadioElementModel model) { // if (selectedListener != null) { // selectedListener.onInterpolatorSelected(interpolatorNamesMap.get(model.getName().get())); // } // } // // public void setSelectedListener(OnInterpolatorSelectedListener selectedListener) { // this.selectedListener = selectedListener; // } // // } // // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/settings/SettingsFragment.java // public class SettingsFragment // extends BaseFragment<SettingsRVAdapter> // implements SettingsRVAdapter.OnModelChangedCallback, // AnimationBodyHolder { // // public static final String TAG = "SettingsFragment"; // // private OnFieldChangedListener fieldChangedListener; // private CustomAnimationBody animationBody; // // @Override // public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // super.onViewCreated(view, savedInstanceState); // // getAdapter().setAnimationBody(animationBody); // getAdapter().setModelChangedCallback(this); // } // // @Override // protected SettingsRVAdapter getAdapterInstance() { // return new SettingsRVAdapter(getContext()); // } // // @Override // public void onModelChanged(SeekBarModel model) { // if (fieldChangedListener != null) { // fieldChangedListener.onPropertyChanged(model); // } // } // // public void setFieldChangedListener(OnFieldChangedListener fieldChangedListener) { // this.fieldChangedListener = fieldChangedListener; // } // // @Override // public void setAnimationBody(CustomAnimationBody animationBody) { // this.animationBody = animationBody; // } // } // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/EditorFragmentType.java import androidx.fragment.app.Fragment; import com.appolica.sample.R; import com.appolica.sample.ui.editor.pager.animations.AnimationsFragment; import com.appolica.sample.ui.editor.pager.interpolators.InterpolatorsFragment; import com.appolica.sample.ui.editor.pager.settings.SettingsFragment; package com.appolica.sample.ui.editor.pager; public enum EditorFragmentType { ANIMATIONS(AnimationsFragment.class, AnimationsFragment.TAG, R.string.tab_animation), INTERPOLATORS(InterpolatorsFragment.class, InterpolatorsFragment.TAG, R.string.tab_curve),
SETTINGS(SettingsFragment.class, SettingsFragment.TAG, R.string.tab_settings);
Appolica/Flubber
Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/ListenerProvider.java
// Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/animations/OnAnimationSelectedListener.java // public interface OnAnimationSelectedListener { // void onAnimationSelected(Flubber.AnimationProvider animationProvider); // } // // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/interpolators/OnInterpolatorSelectedListener.java // public interface OnInterpolatorSelectedListener { // void onInterpolatorSelected(Flubber.Curve interpolator); // } // // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/settings/OnFieldChangedListener.java // public interface OnFieldChangedListener { // void onPropertyChanged(SeekBarModel model); // }
import com.appolica.sample.ui.editor.pager.animations.OnAnimationSelectedListener; import com.appolica.sample.ui.editor.pager.interpolators.OnInterpolatorSelectedListener; import com.appolica.sample.ui.editor.pager.settings.OnFieldChangedListener;
package com.appolica.sample.ui.editor.pager; public interface ListenerProvider { OnAnimationSelectedListener getAnimationSelectedListener();
// Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/animations/OnAnimationSelectedListener.java // public interface OnAnimationSelectedListener { // void onAnimationSelected(Flubber.AnimationProvider animationProvider); // } // // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/interpolators/OnInterpolatorSelectedListener.java // public interface OnInterpolatorSelectedListener { // void onInterpolatorSelected(Flubber.Curve interpolator); // } // // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/settings/OnFieldChangedListener.java // public interface OnFieldChangedListener { // void onPropertyChanged(SeekBarModel model); // } // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/ListenerProvider.java import com.appolica.sample.ui.editor.pager.animations.OnAnimationSelectedListener; import com.appolica.sample.ui.editor.pager.interpolators.OnInterpolatorSelectedListener; import com.appolica.sample.ui.editor.pager.settings.OnFieldChangedListener; package com.appolica.sample.ui.editor.pager; public interface ListenerProvider { OnAnimationSelectedListener getAnimationSelectedListener();
OnInterpolatorSelectedListener getInterpolatorSelectedListener();
Appolica/Flubber
Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/ListenerProvider.java
// Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/animations/OnAnimationSelectedListener.java // public interface OnAnimationSelectedListener { // void onAnimationSelected(Flubber.AnimationProvider animationProvider); // } // // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/interpolators/OnInterpolatorSelectedListener.java // public interface OnInterpolatorSelectedListener { // void onInterpolatorSelected(Flubber.Curve interpolator); // } // // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/settings/OnFieldChangedListener.java // public interface OnFieldChangedListener { // void onPropertyChanged(SeekBarModel model); // }
import com.appolica.sample.ui.editor.pager.animations.OnAnimationSelectedListener; import com.appolica.sample.ui.editor.pager.interpolators.OnInterpolatorSelectedListener; import com.appolica.sample.ui.editor.pager.settings.OnFieldChangedListener;
package com.appolica.sample.ui.editor.pager; public interface ListenerProvider { OnAnimationSelectedListener getAnimationSelectedListener(); OnInterpolatorSelectedListener getInterpolatorSelectedListener();
// Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/animations/OnAnimationSelectedListener.java // public interface OnAnimationSelectedListener { // void onAnimationSelected(Flubber.AnimationProvider animationProvider); // } // // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/interpolators/OnInterpolatorSelectedListener.java // public interface OnInterpolatorSelectedListener { // void onInterpolatorSelected(Flubber.Curve interpolator); // } // // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/settings/OnFieldChangedListener.java // public interface OnFieldChangedListener { // void onPropertyChanged(SeekBarModel model); // } // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/ListenerProvider.java import com.appolica.sample.ui.editor.pager.animations.OnAnimationSelectedListener; import com.appolica.sample.ui.editor.pager.interpolators.OnInterpolatorSelectedListener; import com.appolica.sample.ui.editor.pager.settings.OnFieldChangedListener; package com.appolica.sample.ui.editor.pager; public interface ListenerProvider { OnAnimationSelectedListener getAnimationSelectedListener(); OnInterpolatorSelectedListener getInterpolatorSelectedListener();
OnFieldChangedListener getFieldChangedListener();
Appolica/Flubber
Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/settings/SettingsRVAdapter.java
// Path: Flubber/demo/src/main/java/com/appolica/sample/ui/animation/CustomAnimationBody.java // public class CustomAnimationBody extends AnimationBody implements Serializable { // // private transient Map<FieldName, PropertyMethodsHolder<Long>> longProperties; // private transient Map<FieldName, PropertyMethodsHolder<Float>> floatProperties; // private transient Map<Class<?>, Map<FieldName, ? extends PropertyMethodsHolder<?>>> typesMap; // // public CustomAnimationBody() { // init(); // } // // public void init() { // longProperties = new HashMap<>(); // floatProperties = new HashMap<>(); // typesMap = new HashMap<>(); // // longProperties.put(FieldName.DURATION, PropertyMethodsHolder.fields(this::getDuration, this::setDuration)); // longProperties.put(FieldName.DELAY, PropertyMethodsHolder.fields(this::getDelay, this::setDelay)); // // floatProperties.put(FieldName.FORCE, PropertyMethodsHolder.fields(this::getForce, this::setForce)); // floatProperties.put(FieldName.VELOCITY, PropertyMethodsHolder.fields(this::getVelocity, this::setVelocity)); // floatProperties.put(FieldName.DAMPING, PropertyMethodsHolder.fields(this::getDamping, this::setDamping)); // floatProperties.put(FieldName.SCALE, PropertyMethodsHolder.fields( // this::getEndScaleX, // (scale) -> { // setEndScaleX(scale); // setEndScaleY(scale); // })); // // typesMap.put(Long.class, longProperties); // typesMap.put(Float.class, floatProperties); // } // // public void setProperty(FieldName name, long value) { // final PropertyMethodsHolder<Long> methodsHolder = longProperties.get(name); // final PropertyMethodsHolder.Setter<Long> setter = methodsHolder.setter(); // // setter.set(value); // } // // public void setProperty(FieldName name, float value) { // final PropertyMethodsHolder<Float> methodsHolder = floatProperties.get(name); // final PropertyMethodsHolder.Setter<Float> setter = methodsHolder.setter(); // // setter.set(value); // } // // public <T extends Number> T getPropertyValue(FieldName name, Class<?> numberClass) { // if (!typesMap.containsKey(numberClass)) { // throw new IllegalArgumentException("There is no property of type: " + numberClass); // } // // final Map<FieldName, ? extends PropertyMethodsHolder<?>> propertiesMap = typesMap.get(numberClass); // final PropertyMethodsHolder<?> holder = propertiesMap.get(name); // final PropertyMethodsHolder.Getter<?> getter = holder.getter(); // // return (T) getter.get(); // } // // public Map<FieldName, PropertyMethodsHolder<Long>> getLongProperties() { // return longProperties; // } // // public Map<FieldName, PropertyMethodsHolder<Float>> getFloatProperties() { // return floatProperties; // } // // public enum FieldName { // DURATION(R.string.duration), // DELAY(R.string.delay), // FORCE(R.string.force), // VELOCITY(R.string.velocity), // DAMPING(R.string.damping), // SCALE(R.string.scale); // // private static final Map<Integer, FieldName> idNamesMap; // // static { // idNamesMap = // Stream.of(FieldName.values()) // .collect(Collectors.toMap((name -> name.stringId), (name -> name))); // } // // private final int stringId; // // FieldName(int stringId) { // this.stringId = stringId; // } // // @Nullable // public static FieldName forStringId(int stringId) { // return idNamesMap.get(stringId); // } // // public int getStringId() { // return stringId; // } // } // }
import android.content.Context; import androidx.databinding.DataBindingUtil; import androidx.databinding.Observable; import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.ViewGroup; import com.appolica.sample.R; import com.appolica.sample.databinding.ListItemProgressBinding; import com.appolica.sample.ui.animation.CustomAnimationBody; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map;
package com.appolica.sample.ui.editor.pager.settings; public class SettingsRVAdapter extends RecyclerView.Adapter<SettingsRVAdapter.BindingHolder> { private List<SeekBarModel> models = new ArrayList<>(); private Map<Observable, SeekBarModel> modelsMap = new LinkedHashMap<>(); private Context context; private OnModelChangedCallback modelChangedCallback; public SettingsRVAdapter(Context context) { this.context = context; } @Override public int getItemViewType(int position) { return super.getItemViewType(position); } @Override public BindingHolder onCreateViewHolder(ViewGroup parent, int viewType) { final LayoutInflater inflater = LayoutInflater.from(context); ListItemProgressBinding binding = DataBindingUtil.inflate(inflater, R.layout.list_item_progress, parent, false); return new BindingHolder(binding); } @Override public void onBindViewHolder(BindingHolder holder, int position) { holder.bindTo(models.get(position)); } @Override public int getItemCount() { return models.size(); }
// Path: Flubber/demo/src/main/java/com/appolica/sample/ui/animation/CustomAnimationBody.java // public class CustomAnimationBody extends AnimationBody implements Serializable { // // private transient Map<FieldName, PropertyMethodsHolder<Long>> longProperties; // private transient Map<FieldName, PropertyMethodsHolder<Float>> floatProperties; // private transient Map<Class<?>, Map<FieldName, ? extends PropertyMethodsHolder<?>>> typesMap; // // public CustomAnimationBody() { // init(); // } // // public void init() { // longProperties = new HashMap<>(); // floatProperties = new HashMap<>(); // typesMap = new HashMap<>(); // // longProperties.put(FieldName.DURATION, PropertyMethodsHolder.fields(this::getDuration, this::setDuration)); // longProperties.put(FieldName.DELAY, PropertyMethodsHolder.fields(this::getDelay, this::setDelay)); // // floatProperties.put(FieldName.FORCE, PropertyMethodsHolder.fields(this::getForce, this::setForce)); // floatProperties.put(FieldName.VELOCITY, PropertyMethodsHolder.fields(this::getVelocity, this::setVelocity)); // floatProperties.put(FieldName.DAMPING, PropertyMethodsHolder.fields(this::getDamping, this::setDamping)); // floatProperties.put(FieldName.SCALE, PropertyMethodsHolder.fields( // this::getEndScaleX, // (scale) -> { // setEndScaleX(scale); // setEndScaleY(scale); // })); // // typesMap.put(Long.class, longProperties); // typesMap.put(Float.class, floatProperties); // } // // public void setProperty(FieldName name, long value) { // final PropertyMethodsHolder<Long> methodsHolder = longProperties.get(name); // final PropertyMethodsHolder.Setter<Long> setter = methodsHolder.setter(); // // setter.set(value); // } // // public void setProperty(FieldName name, float value) { // final PropertyMethodsHolder<Float> methodsHolder = floatProperties.get(name); // final PropertyMethodsHolder.Setter<Float> setter = methodsHolder.setter(); // // setter.set(value); // } // // public <T extends Number> T getPropertyValue(FieldName name, Class<?> numberClass) { // if (!typesMap.containsKey(numberClass)) { // throw new IllegalArgumentException("There is no property of type: " + numberClass); // } // // final Map<FieldName, ? extends PropertyMethodsHolder<?>> propertiesMap = typesMap.get(numberClass); // final PropertyMethodsHolder<?> holder = propertiesMap.get(name); // final PropertyMethodsHolder.Getter<?> getter = holder.getter(); // // return (T) getter.get(); // } // // public Map<FieldName, PropertyMethodsHolder<Long>> getLongProperties() { // return longProperties; // } // // public Map<FieldName, PropertyMethodsHolder<Float>> getFloatProperties() { // return floatProperties; // } // // public enum FieldName { // DURATION(R.string.duration), // DELAY(R.string.delay), // FORCE(R.string.force), // VELOCITY(R.string.velocity), // DAMPING(R.string.damping), // SCALE(R.string.scale); // // private static final Map<Integer, FieldName> idNamesMap; // // static { // idNamesMap = // Stream.of(FieldName.values()) // .collect(Collectors.toMap((name -> name.stringId), (name -> name))); // } // // private final int stringId; // // FieldName(int stringId) { // this.stringId = stringId; // } // // @Nullable // public static FieldName forStringId(int stringId) { // return idNamesMap.get(stringId); // } // // public int getStringId() { // return stringId; // } // } // } // Path: Flubber/demo/src/main/java/com/appolica/sample/ui/editor/pager/settings/SettingsRVAdapter.java import android.content.Context; import androidx.databinding.DataBindingUtil; import androidx.databinding.Observable; import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.ViewGroup; import com.appolica.sample.R; import com.appolica.sample.databinding.ListItemProgressBinding; import com.appolica.sample.ui.animation.CustomAnimationBody; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; package com.appolica.sample.ui.editor.pager.settings; public class SettingsRVAdapter extends RecyclerView.Adapter<SettingsRVAdapter.BindingHolder> { private List<SeekBarModel> models = new ArrayList<>(); private Map<Observable, SeekBarModel> modelsMap = new LinkedHashMap<>(); private Context context; private OnModelChangedCallback modelChangedCallback; public SettingsRVAdapter(Context context) { this.context = context; } @Override public int getItemViewType(int position) { return super.getItemViewType(position); } @Override public BindingHolder onCreateViewHolder(ViewGroup parent, int viewType) { final LayoutInflater inflater = LayoutInflater.from(context); ListItemProgressBinding binding = DataBindingUtil.inflate(inflater, R.layout.list_item_progress, parent, false); return new BindingHolder(binding); } @Override public void onBindViewHolder(BindingHolder holder, int position) { holder.bindTo(models.get(position)); } @Override public int getItemCount() { return models.size(); }
public void setAnimationBody(final CustomAnimationBody animationBody) {
Erudika/scoold
src/main/java/com/erudika/scoold/ScooldConfig.java
// Path: src/main/java/com/erudika/scoold/ScooldServer.java // public static final String SIGNINLINK = HOMEPAGE + "signin";
import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import com.erudika.para.core.App; import com.erudika.para.core.annotations.Documented; import com.erudika.para.core.utils.Config; import com.erudika.para.core.utils.Para; import static com.erudika.scoold.ScooldServer.SIGNINLINK; import com.typesafe.config.ConfigObject; import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; import javax.inject.Named; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils;
@Documented(position = 2920, identifier = "max_fav_tags", value = "50", type = Integer.class, category = "Posts", description = "Maximum number of favorite tags.") public int maxFavoriteTags() { return getConfigInt("max_fav_tags", 50); } @Documented(position = 2930, identifier = "batch_request_size", value = "0", type = Integer.class, category = "Miscellaneous", description = "Maximum batch size for the Para client pagination requests.") public int batchRequestSize() { return getConfigInt("batch_request_size", 0); } @Documented(position = 2940, identifier = "signout_url", value = "/signin?code=5&success=true", category = "Miscellaneous", description = "The URL which users will be redirected to after they click 'Sign out'. Can be a page hosted" + " externally.") public String signoutUrl(int... code) { if (code == null || code.length < 1) { code = new int[]{5}; }
// Path: src/main/java/com/erudika/scoold/ScooldServer.java // public static final String SIGNINLINK = HOMEPAGE + "signin"; // Path: src/main/java/com/erudika/scoold/ScooldConfig.java import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import com.erudika.para.core.App; import com.erudika.para.core.annotations.Documented; import com.erudika.para.core.utils.Config; import com.erudika.para.core.utils.Para; import static com.erudika.scoold.ScooldServer.SIGNINLINK; import com.typesafe.config.ConfigObject; import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; import javax.inject.Named; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; @Documented(position = 2920, identifier = "max_fav_tags", value = "50", type = Integer.class, category = "Posts", description = "Maximum number of favorite tags.") public int maxFavoriteTags() { return getConfigInt("max_fav_tags", 50); } @Documented(position = 2930, identifier = "batch_request_size", value = "0", type = Integer.class, category = "Miscellaneous", description = "Maximum batch size for the Para client pagination requests.") public int batchRequestSize() { return getConfigInt("batch_request_size", 0); } @Documented(position = 2940, identifier = "signout_url", value = "/signin?code=5&success=true", category = "Miscellaneous", description = "The URL which users will be redirected to after they click 'Sign out'. Can be a page hosted" + " externally.") public String signoutUrl(int... code) { if (code == null || code.length < 1) { code = new int[]{5}; }
return getConfigParam("signout_url", SIGNINLINK + "?code=" + code[0] + "&success=true");
lantunes/fixd
src/test/java/org/bigtesting/fixd/tests/TestSimpleHttpRequest.java
// Path: src/main/java/org/bigtesting/fixd/request/impl/SimpleHttpRequest.java // public class SimpleHttpRequest implements HttpRequest { // // private final Request request; // // private final Session session; // // private final Route route; // // private final UnmarshallerProvider unmarshallerProvider; // // public SimpleHttpRequest(Request request, Session session, Route route, // UnmarshallerProvider unmarshallerProvider) { // // this.request = request; // this.session = session; // this.route = route; // this.unmarshallerProvider = unmarshallerProvider; // } // // public String getPath() { // // return request.getPath().getPath(); // } // // public String getUndecodedPath() { // // return RequestUtils.getUndecodedPath(request); // } // // public Set<String> getRequestParameterNames() { // // return request.getQuery().keySet(); // } // // public String getRequestParameter(String name) { // // return request.getParameter(name); // } // // public String getPathParameter(String name) { // // return getRoute().getNamedParameter(name, getPath()); // } // // public List<String> getHeaderNames() { // // return request.getNames(); // } // // public String getHeaderValue(String name) { // // return request.getValue(name); // } // // public String getBody() { // // try { // return new String(RequestUtils.readBody(getBodyAsStream())); // } catch (IOException e) { // throw new RuntimeException("error getting body", e); // } // } // // public InputStream getBodyAsStream() throws IOException { // // return request.getInputStream(); // } // // public <T> T getBody(Class<T> type) { // // Unmarshaller unmarshaller = unmarshallerProvider.getUnmarshaller(getContentType()); // if (unmarshaller == null) { // throw new RuntimeException("cannot unmarshall body as type " + // type.getName() + ", as no unmarshaller is available for" + // "content-type: " + getContentType()); // } // try { // return unmarshaller.unmarshal(getBodyAsStream(), type); // } catch (Exception e) { // throw new RuntimeException("error unmarshalling", e); // } // } // // public long getContentLength() { // // return request.getContentLength(); // } // // public String getContentType() { // // return request.getContentType().getType(); // } // // public String getMethod() { // // return request.getMethod(); // } // // public long getTime() { // // return request.getRequestTime(); // } // // public String getQuery() { // // return request.getQuery().toString(); // } // // public int getMajor() { // // return request.getMajor(); // } // // public int getMinor() { // // return request.getMinor(); // } // // public String getTarget() { // // return request.getTarget(); // } // // public Session getSession() { // // return session; // } // // public Route getRoute() { // // return route; // } // }
import static org.junit.Assert.*; import static org.mockito.Mockito.*; import org.bigtesting.fixd.request.impl.SimpleHttpRequest; import org.bigtesting.routd.Route; import org.junit.Test; import org.simpleframework.http.Path; import org.simpleframework.http.Request;
/* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.tests; /** * * @author Luis Antunes */ public class TestSimpleHttpRequest { @Test public void getPathParameter() { Request request = mock(Request.class); Path path = mock(Path.class); when(path.getPath()).thenReturn("/first-name/John/last-name/Doe"); when(request.getPath()).thenReturn(path); Route route = new Route("/first-name/:firstName/last-name/:lastName");
// Path: src/main/java/org/bigtesting/fixd/request/impl/SimpleHttpRequest.java // public class SimpleHttpRequest implements HttpRequest { // // private final Request request; // // private final Session session; // // private final Route route; // // private final UnmarshallerProvider unmarshallerProvider; // // public SimpleHttpRequest(Request request, Session session, Route route, // UnmarshallerProvider unmarshallerProvider) { // // this.request = request; // this.session = session; // this.route = route; // this.unmarshallerProvider = unmarshallerProvider; // } // // public String getPath() { // // return request.getPath().getPath(); // } // // public String getUndecodedPath() { // // return RequestUtils.getUndecodedPath(request); // } // // public Set<String> getRequestParameterNames() { // // return request.getQuery().keySet(); // } // // public String getRequestParameter(String name) { // // return request.getParameter(name); // } // // public String getPathParameter(String name) { // // return getRoute().getNamedParameter(name, getPath()); // } // // public List<String> getHeaderNames() { // // return request.getNames(); // } // // public String getHeaderValue(String name) { // // return request.getValue(name); // } // // public String getBody() { // // try { // return new String(RequestUtils.readBody(getBodyAsStream())); // } catch (IOException e) { // throw new RuntimeException("error getting body", e); // } // } // // public InputStream getBodyAsStream() throws IOException { // // return request.getInputStream(); // } // // public <T> T getBody(Class<T> type) { // // Unmarshaller unmarshaller = unmarshallerProvider.getUnmarshaller(getContentType()); // if (unmarshaller == null) { // throw new RuntimeException("cannot unmarshall body as type " + // type.getName() + ", as no unmarshaller is available for" + // "content-type: " + getContentType()); // } // try { // return unmarshaller.unmarshal(getBodyAsStream(), type); // } catch (Exception e) { // throw new RuntimeException("error unmarshalling", e); // } // } // // public long getContentLength() { // // return request.getContentLength(); // } // // public String getContentType() { // // return request.getContentType().getType(); // } // // public String getMethod() { // // return request.getMethod(); // } // // public long getTime() { // // return request.getRequestTime(); // } // // public String getQuery() { // // return request.getQuery().toString(); // } // // public int getMajor() { // // return request.getMajor(); // } // // public int getMinor() { // // return request.getMinor(); // } // // public String getTarget() { // // return request.getTarget(); // } // // public Session getSession() { // // return session; // } // // public Route getRoute() { // // return route; // } // } // Path: src/test/java/org/bigtesting/fixd/tests/TestSimpleHttpRequest.java import static org.junit.Assert.*; import static org.mockito.Mockito.*; import org.bigtesting.fixd.request.impl.SimpleHttpRequest; import org.bigtesting.routd.Route; import org.junit.Test; import org.simpleframework.http.Path; import org.simpleframework.http.Request; /* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.tests; /** * * @author Luis Antunes */ public class TestSimpleHttpRequest { @Test public void getPathParameter() { Request request = mock(Request.class); Path path = mock(Path.class); when(path.getPath()).thenReturn("/first-name/John/last-name/Doe"); when(request.getPath()).thenReturn(path); Route route = new Route("/first-name/:firstName/last-name/:lastName");
SimpleHttpRequest req = new SimpleHttpRequest(request, null, route, null);
lantunes/fixd
src/test/java/org/bigtesting/fixd/tests/TestResponseBodyInterpolator.java
// Path: src/main/java/org/bigtesting/fixd/interpolation/ResponseBodyInterpolator.java // public class ResponseBodyInterpolator { // // private static final Interpolator<HttpRequest> interpolator = new Interpolator<HttpRequest>(); // // private static final Map<String, RequestValueProvider<?>> requestValueProviders = // new HashMap<String, RequestValueProvider<?>>(); // // static { // requestValueProviders.put("request.body", new RequestBodyValueProvider()); // requestValueProviders.put("request.method", new RequestMethodValueProvider()); // requestValueProviders.put("request.time", new RequestTimeValueProvider()); // requestValueProviders.put("request.path", new RequestPathValueProvider()); // requestValueProviders.put("request.query", new RequestQueryValueProvider()); // requestValueProviders.put("request.major", new RequestMajorValueProvider()); // requestValueProviders.put("request.minor", new RequestMinorValueProvider()); // requestValueProviders.put("request.target", new RequestTargetValueProvider()); // // interpolator.when("[a-zA-Z0-9_]+").prefixedBy(":") // .handleWith(new Substitutor<HttpRequest>() { // public String substitute(String captured, HttpRequest req) { // // String path = req.getUndecodedPath(); // return req.getRoute().getNamedParameter(captured, path); // } // }); // // interpolator.when("[0-9]+").enclosedBy("*[").and("]") // .handleWith(new Substitutor<HttpRequest>() { // public String substitute(String captured, HttpRequest req) { // // String path = req.getUndecodedPath(); // int index = Integer.parseInt(captured); // return req.getRoute().getSplatParameter(index, path); // } // }); // // interpolator.when().enclosedBy("{").and("}") // .handleWith(new Substitutor<HttpRequest>() { // public String substitute(String captured, HttpRequest req) { // // if (req.getSession() != null) { // Object val = req.getSession().get(captured); // if (val != null) { // return val.toString(); // } // } // return null; // } // }); // // interpolator.when().enclosedBy("[").and("]") // .handleWith(new Substitutor<HttpRequest>() { // public String substitute(String captured, HttpRequest req) { // // if (captured.startsWith("request?")) { // return req.getRequestParameter(captured.replaceFirst("request\\?", "")); // } // // if (captured.startsWith("request$")) { // return req.getHeaderValue(captured.replaceFirst("request\\$", "")); // } // // RequestValueProvider<?> requestValueProvider = requestValueProviders.get(captured); // if (requestValueProvider != null) { // Object val = requestValueProvider.getValue(req); // if (val != null) { // return val.toString(); // } // } // return null; // } // }); // // interpolator.escapeWith("^"); // } // // public static String interpolate(String body, HttpRequest request) { // // return interpolator.interpolate(body, request); // } // } // // Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java // public interface HttpRequest { // // String getPath(); // // String getUndecodedPath(); // // Set<String> getRequestParameterNames(); // // String getRequestParameter(String name); // // String getPathParameter(String name); // // List<String> getHeaderNames(); // // String getHeaderValue(String name); // // String getBody(); // // InputStream getBodyAsStream() throws IOException; // // <T> T getBody(Class<T> type); // // long getContentLength(); // // String getContentType(); // // String getMethod(); // // long getTime(); // // String getQuery(); // // int getMajor(); // // int getMinor(); // // String getTarget(); // // /** // * @return a session, if it exists, or null if it does not // */ // Session getSession(); // // Route getRoute(); // } // // Path: src/main/java/org/bigtesting/fixd/session/Session.java // public class Session { // // private final String sessionId; // // private final Map<String, Object> values = new HashMap<String, Object>(); // // private boolean valid = true; // // public Session() { // // this.sessionId = UUID.randomUUID().toString(); // } // // public String getSessionId() { // // return sessionId; // } // // public Object get(String key) { // // return values.get(key); // } // // public void set(String key, Object value) { // // values.put(key, value); // } // // public Set<String> getAttributeNames() { // // return values.keySet(); // } // // public boolean isValid() { // // return valid; // } // // public void invalidate() { // // this.valid = false; // } // }
import static org.junit.Assert.*; import static org.mockito.Mockito.*; import java.io.ByteArrayInputStream; import java.io.InputStream; import org.bigtesting.fixd.interpolation.ResponseBodyInterpolator; import org.bigtesting.fixd.request.HttpRequest; import org.bigtesting.fixd.session.Session; import org.bigtesting.routd.Route; import org.junit.Test;
/* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.tests; /** * * @author Luis Antunes */ public class TestResponseBodyInterpolator { @Test public void testBodyReturnedUnmodifiedWhenNoInstructionsGiven() {
// Path: src/main/java/org/bigtesting/fixd/interpolation/ResponseBodyInterpolator.java // public class ResponseBodyInterpolator { // // private static final Interpolator<HttpRequest> interpolator = new Interpolator<HttpRequest>(); // // private static final Map<String, RequestValueProvider<?>> requestValueProviders = // new HashMap<String, RequestValueProvider<?>>(); // // static { // requestValueProviders.put("request.body", new RequestBodyValueProvider()); // requestValueProviders.put("request.method", new RequestMethodValueProvider()); // requestValueProviders.put("request.time", new RequestTimeValueProvider()); // requestValueProviders.put("request.path", new RequestPathValueProvider()); // requestValueProviders.put("request.query", new RequestQueryValueProvider()); // requestValueProviders.put("request.major", new RequestMajorValueProvider()); // requestValueProviders.put("request.minor", new RequestMinorValueProvider()); // requestValueProviders.put("request.target", new RequestTargetValueProvider()); // // interpolator.when("[a-zA-Z0-9_]+").prefixedBy(":") // .handleWith(new Substitutor<HttpRequest>() { // public String substitute(String captured, HttpRequest req) { // // String path = req.getUndecodedPath(); // return req.getRoute().getNamedParameter(captured, path); // } // }); // // interpolator.when("[0-9]+").enclosedBy("*[").and("]") // .handleWith(new Substitutor<HttpRequest>() { // public String substitute(String captured, HttpRequest req) { // // String path = req.getUndecodedPath(); // int index = Integer.parseInt(captured); // return req.getRoute().getSplatParameter(index, path); // } // }); // // interpolator.when().enclosedBy("{").and("}") // .handleWith(new Substitutor<HttpRequest>() { // public String substitute(String captured, HttpRequest req) { // // if (req.getSession() != null) { // Object val = req.getSession().get(captured); // if (val != null) { // return val.toString(); // } // } // return null; // } // }); // // interpolator.when().enclosedBy("[").and("]") // .handleWith(new Substitutor<HttpRequest>() { // public String substitute(String captured, HttpRequest req) { // // if (captured.startsWith("request?")) { // return req.getRequestParameter(captured.replaceFirst("request\\?", "")); // } // // if (captured.startsWith("request$")) { // return req.getHeaderValue(captured.replaceFirst("request\\$", "")); // } // // RequestValueProvider<?> requestValueProvider = requestValueProviders.get(captured); // if (requestValueProvider != null) { // Object val = requestValueProvider.getValue(req); // if (val != null) { // return val.toString(); // } // } // return null; // } // }); // // interpolator.escapeWith("^"); // } // // public static String interpolate(String body, HttpRequest request) { // // return interpolator.interpolate(body, request); // } // } // // Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java // public interface HttpRequest { // // String getPath(); // // String getUndecodedPath(); // // Set<String> getRequestParameterNames(); // // String getRequestParameter(String name); // // String getPathParameter(String name); // // List<String> getHeaderNames(); // // String getHeaderValue(String name); // // String getBody(); // // InputStream getBodyAsStream() throws IOException; // // <T> T getBody(Class<T> type); // // long getContentLength(); // // String getContentType(); // // String getMethod(); // // long getTime(); // // String getQuery(); // // int getMajor(); // // int getMinor(); // // String getTarget(); // // /** // * @return a session, if it exists, or null if it does not // */ // Session getSession(); // // Route getRoute(); // } // // Path: src/main/java/org/bigtesting/fixd/session/Session.java // public class Session { // // private final String sessionId; // // private final Map<String, Object> values = new HashMap<String, Object>(); // // private boolean valid = true; // // public Session() { // // this.sessionId = UUID.randomUUID().toString(); // } // // public String getSessionId() { // // return sessionId; // } // // public Object get(String key) { // // return values.get(key); // } // // public void set(String key, Object value) { // // values.put(key, value); // } // // public Set<String> getAttributeNames() { // // return values.keySet(); // } // // public boolean isValid() { // // return valid; // } // // public void invalidate() { // // this.valid = false; // } // } // Path: src/test/java/org/bigtesting/fixd/tests/TestResponseBodyInterpolator.java import static org.junit.Assert.*; import static org.mockito.Mockito.*; import java.io.ByteArrayInputStream; import java.io.InputStream; import org.bigtesting.fixd.interpolation.ResponseBodyInterpolator; import org.bigtesting.fixd.request.HttpRequest; import org.bigtesting.fixd.session.Session; import org.bigtesting.routd.Route; import org.junit.Test; /* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.tests; /** * * @author Luis Antunes */ public class TestResponseBodyInterpolator { @Test public void testBodyReturnedUnmodifiedWhenNoInstructionsGiven() {
HttpRequest req = mock(HttpRequest.class);
lantunes/fixd
src/main/java/org/bigtesting/fixd/core/container/MarshallerContainer.java
// Path: src/main/java/org/bigtesting/fixd/core/RequestMarshallerImpl.java // public class RequestMarshallerImpl implements RequestMarshaller { // // private final String contentType; // // private Marshaller marshaller; // // public RequestMarshallerImpl(String contentType) { // this.contentType = contentType; // } // // public void with(Marshaller marshaller) { // this.marshaller = marshaller; // } // // public String getContentType() { // return contentType; // } // // public Marshaller getMarshaller() { // return marshaller; // } // } // // Path: src/main/java/org/bigtesting/fixd/core/RequestUnmarshallerImpl.java // public class RequestUnmarshallerImpl implements RequestUnmarshaller { // // private final String contentType; // // private Unmarshaller unmarshaller; // // public RequestUnmarshallerImpl(String contentType) { // this.contentType = contentType; // } // // public void with(Unmarshaller unmarshaller) { // this.unmarshaller = unmarshaller; // } // // public String getContentType() { // return contentType; // } // // public Unmarshaller getUnmarshaller() { // return unmarshaller; // } // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/Marshaller.java // public interface Marshaller { // // InputStream marshal(Object entity); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/MarshallerProvider.java // public interface MarshallerProvider { // // /** // * // * Returns the Marshaller for the given content-type, // * or null if there is no Marshaller for the given // * content-type. // * // * @param contentType // * @return the Marshaller for the given content-type, or // * null if there is no Marshaller for the given // * content-type // */ // Marshaller getMarshaller(String contentType); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/Unmarshaller.java // public interface Unmarshaller { // // <T> T unmarshal(InputStream in, Class<T> type); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/UnmarshallerProvider.java // public interface UnmarshallerProvider { // // /** // * // * Returns the Unmarshaller for the given content-type, // * or null if there is no Unmarshaller for the given // * content-type. // * // * @param contentType // * @return the Unmarshaller for the given content-type, or // * null if there is no Unmarshaller for the given // * content-type // */ // Unmarshaller getUnmarshaller(String contentType); // }
import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.bigtesting.fixd.core.RequestMarshallerImpl; import org.bigtesting.fixd.core.RequestUnmarshallerImpl; import org.bigtesting.fixd.marshalling.Marshaller; import org.bigtesting.fixd.marshalling.MarshallerProvider; import org.bigtesting.fixd.marshalling.Unmarshaller; import org.bigtesting.fixd.marshalling.UnmarshallerProvider;
/* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.core.container; /** * * @author Luis Antunes */ class MarshallerContainer { private final Map<String, RequestMarshallerImpl> contentMarshallers = new ConcurrentHashMap<String, RequestMarshallerImpl>();
// Path: src/main/java/org/bigtesting/fixd/core/RequestMarshallerImpl.java // public class RequestMarshallerImpl implements RequestMarshaller { // // private final String contentType; // // private Marshaller marshaller; // // public RequestMarshallerImpl(String contentType) { // this.contentType = contentType; // } // // public void with(Marshaller marshaller) { // this.marshaller = marshaller; // } // // public String getContentType() { // return contentType; // } // // public Marshaller getMarshaller() { // return marshaller; // } // } // // Path: src/main/java/org/bigtesting/fixd/core/RequestUnmarshallerImpl.java // public class RequestUnmarshallerImpl implements RequestUnmarshaller { // // private final String contentType; // // private Unmarshaller unmarshaller; // // public RequestUnmarshallerImpl(String contentType) { // this.contentType = contentType; // } // // public void with(Unmarshaller unmarshaller) { // this.unmarshaller = unmarshaller; // } // // public String getContentType() { // return contentType; // } // // public Unmarshaller getUnmarshaller() { // return unmarshaller; // } // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/Marshaller.java // public interface Marshaller { // // InputStream marshal(Object entity); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/MarshallerProvider.java // public interface MarshallerProvider { // // /** // * // * Returns the Marshaller for the given content-type, // * or null if there is no Marshaller for the given // * content-type. // * // * @param contentType // * @return the Marshaller for the given content-type, or // * null if there is no Marshaller for the given // * content-type // */ // Marshaller getMarshaller(String contentType); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/Unmarshaller.java // public interface Unmarshaller { // // <T> T unmarshal(InputStream in, Class<T> type); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/UnmarshallerProvider.java // public interface UnmarshallerProvider { // // /** // * // * Returns the Unmarshaller for the given content-type, // * or null if there is no Unmarshaller for the given // * content-type. // * // * @param contentType // * @return the Unmarshaller for the given content-type, or // * null if there is no Unmarshaller for the given // * content-type // */ // Unmarshaller getUnmarshaller(String contentType); // } // Path: src/main/java/org/bigtesting/fixd/core/container/MarshallerContainer.java import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.bigtesting.fixd.core.RequestMarshallerImpl; import org.bigtesting.fixd.core.RequestUnmarshallerImpl; import org.bigtesting.fixd.marshalling.Marshaller; import org.bigtesting.fixd.marshalling.MarshallerProvider; import org.bigtesting.fixd.marshalling.Unmarshaller; import org.bigtesting.fixd.marshalling.UnmarshallerProvider; /* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.core.container; /** * * @author Luis Antunes */ class MarshallerContainer { private final Map<String, RequestMarshallerImpl> contentMarshallers = new ConcurrentHashMap<String, RequestMarshallerImpl>();
private final Map<String, RequestUnmarshallerImpl> contentUnmarshallers =
lantunes/fixd
src/main/java/org/bigtesting/fixd/core/container/MarshallerContainer.java
// Path: src/main/java/org/bigtesting/fixd/core/RequestMarshallerImpl.java // public class RequestMarshallerImpl implements RequestMarshaller { // // private final String contentType; // // private Marshaller marshaller; // // public RequestMarshallerImpl(String contentType) { // this.contentType = contentType; // } // // public void with(Marshaller marshaller) { // this.marshaller = marshaller; // } // // public String getContentType() { // return contentType; // } // // public Marshaller getMarshaller() { // return marshaller; // } // } // // Path: src/main/java/org/bigtesting/fixd/core/RequestUnmarshallerImpl.java // public class RequestUnmarshallerImpl implements RequestUnmarshaller { // // private final String contentType; // // private Unmarshaller unmarshaller; // // public RequestUnmarshallerImpl(String contentType) { // this.contentType = contentType; // } // // public void with(Unmarshaller unmarshaller) { // this.unmarshaller = unmarshaller; // } // // public String getContentType() { // return contentType; // } // // public Unmarshaller getUnmarshaller() { // return unmarshaller; // } // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/Marshaller.java // public interface Marshaller { // // InputStream marshal(Object entity); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/MarshallerProvider.java // public interface MarshallerProvider { // // /** // * // * Returns the Marshaller for the given content-type, // * or null if there is no Marshaller for the given // * content-type. // * // * @param contentType // * @return the Marshaller for the given content-type, or // * null if there is no Marshaller for the given // * content-type // */ // Marshaller getMarshaller(String contentType); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/Unmarshaller.java // public interface Unmarshaller { // // <T> T unmarshal(InputStream in, Class<T> type); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/UnmarshallerProvider.java // public interface UnmarshallerProvider { // // /** // * // * Returns the Unmarshaller for the given content-type, // * or null if there is no Unmarshaller for the given // * content-type. // * // * @param contentType // * @return the Unmarshaller for the given content-type, or // * null if there is no Unmarshaller for the given // * content-type // */ // Unmarshaller getUnmarshaller(String contentType); // }
import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.bigtesting.fixd.core.RequestMarshallerImpl; import org.bigtesting.fixd.core.RequestUnmarshallerImpl; import org.bigtesting.fixd.marshalling.Marshaller; import org.bigtesting.fixd.marshalling.MarshallerProvider; import org.bigtesting.fixd.marshalling.Unmarshaller; import org.bigtesting.fixd.marshalling.UnmarshallerProvider;
/* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.core.container; /** * * @author Luis Antunes */ class MarshallerContainer { private final Map<String, RequestMarshallerImpl> contentMarshallers = new ConcurrentHashMap<String, RequestMarshallerImpl>(); private final Map<String, RequestUnmarshallerImpl> contentUnmarshallers = new ConcurrentHashMap<String, RequestUnmarshallerImpl>(); public void addContentMarshaller(String contentType, RequestMarshallerImpl marshaller) { this.contentMarshallers.put(contentType, marshaller); } public void addContentUnmarshaller(String contentType, RequestUnmarshallerImpl unmarshaller) { this.contentUnmarshallers.put(contentType, unmarshaller); }
// Path: src/main/java/org/bigtesting/fixd/core/RequestMarshallerImpl.java // public class RequestMarshallerImpl implements RequestMarshaller { // // private final String contentType; // // private Marshaller marshaller; // // public RequestMarshallerImpl(String contentType) { // this.contentType = contentType; // } // // public void with(Marshaller marshaller) { // this.marshaller = marshaller; // } // // public String getContentType() { // return contentType; // } // // public Marshaller getMarshaller() { // return marshaller; // } // } // // Path: src/main/java/org/bigtesting/fixd/core/RequestUnmarshallerImpl.java // public class RequestUnmarshallerImpl implements RequestUnmarshaller { // // private final String contentType; // // private Unmarshaller unmarshaller; // // public RequestUnmarshallerImpl(String contentType) { // this.contentType = contentType; // } // // public void with(Unmarshaller unmarshaller) { // this.unmarshaller = unmarshaller; // } // // public String getContentType() { // return contentType; // } // // public Unmarshaller getUnmarshaller() { // return unmarshaller; // } // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/Marshaller.java // public interface Marshaller { // // InputStream marshal(Object entity); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/MarshallerProvider.java // public interface MarshallerProvider { // // /** // * // * Returns the Marshaller for the given content-type, // * or null if there is no Marshaller for the given // * content-type. // * // * @param contentType // * @return the Marshaller for the given content-type, or // * null if there is no Marshaller for the given // * content-type // */ // Marshaller getMarshaller(String contentType); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/Unmarshaller.java // public interface Unmarshaller { // // <T> T unmarshal(InputStream in, Class<T> type); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/UnmarshallerProvider.java // public interface UnmarshallerProvider { // // /** // * // * Returns the Unmarshaller for the given content-type, // * or null if there is no Unmarshaller for the given // * content-type. // * // * @param contentType // * @return the Unmarshaller for the given content-type, or // * null if there is no Unmarshaller for the given // * content-type // */ // Unmarshaller getUnmarshaller(String contentType); // } // Path: src/main/java/org/bigtesting/fixd/core/container/MarshallerContainer.java import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.bigtesting.fixd.core.RequestMarshallerImpl; import org.bigtesting.fixd.core.RequestUnmarshallerImpl; import org.bigtesting.fixd.marshalling.Marshaller; import org.bigtesting.fixd.marshalling.MarshallerProvider; import org.bigtesting.fixd.marshalling.Unmarshaller; import org.bigtesting.fixd.marshalling.UnmarshallerProvider; /* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.core.container; /** * * @author Luis Antunes */ class MarshallerContainer { private final Map<String, RequestMarshallerImpl> contentMarshallers = new ConcurrentHashMap<String, RequestMarshallerImpl>(); private final Map<String, RequestUnmarshallerImpl> contentUnmarshallers = new ConcurrentHashMap<String, RequestUnmarshallerImpl>(); public void addContentMarshaller(String contentType, RequestMarshallerImpl marshaller) { this.contentMarshallers.put(contentType, marshaller); } public void addContentUnmarshaller(String contentType, RequestUnmarshallerImpl unmarshaller) { this.contentUnmarshallers.put(contentType, unmarshaller); }
public MarshallerProvider newMarshallerProvider() {
lantunes/fixd
src/main/java/org/bigtesting/fixd/core/container/MarshallerContainer.java
// Path: src/main/java/org/bigtesting/fixd/core/RequestMarshallerImpl.java // public class RequestMarshallerImpl implements RequestMarshaller { // // private final String contentType; // // private Marshaller marshaller; // // public RequestMarshallerImpl(String contentType) { // this.contentType = contentType; // } // // public void with(Marshaller marshaller) { // this.marshaller = marshaller; // } // // public String getContentType() { // return contentType; // } // // public Marshaller getMarshaller() { // return marshaller; // } // } // // Path: src/main/java/org/bigtesting/fixd/core/RequestUnmarshallerImpl.java // public class RequestUnmarshallerImpl implements RequestUnmarshaller { // // private final String contentType; // // private Unmarshaller unmarshaller; // // public RequestUnmarshallerImpl(String contentType) { // this.contentType = contentType; // } // // public void with(Unmarshaller unmarshaller) { // this.unmarshaller = unmarshaller; // } // // public String getContentType() { // return contentType; // } // // public Unmarshaller getUnmarshaller() { // return unmarshaller; // } // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/Marshaller.java // public interface Marshaller { // // InputStream marshal(Object entity); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/MarshallerProvider.java // public interface MarshallerProvider { // // /** // * // * Returns the Marshaller for the given content-type, // * or null if there is no Marshaller for the given // * content-type. // * // * @param contentType // * @return the Marshaller for the given content-type, or // * null if there is no Marshaller for the given // * content-type // */ // Marshaller getMarshaller(String contentType); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/Unmarshaller.java // public interface Unmarshaller { // // <T> T unmarshal(InputStream in, Class<T> type); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/UnmarshallerProvider.java // public interface UnmarshallerProvider { // // /** // * // * Returns the Unmarshaller for the given content-type, // * or null if there is no Unmarshaller for the given // * content-type. // * // * @param contentType // * @return the Unmarshaller for the given content-type, or // * null if there is no Unmarshaller for the given // * content-type // */ // Unmarshaller getUnmarshaller(String contentType); // }
import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.bigtesting.fixd.core.RequestMarshallerImpl; import org.bigtesting.fixd.core.RequestUnmarshallerImpl; import org.bigtesting.fixd.marshalling.Marshaller; import org.bigtesting.fixd.marshalling.MarshallerProvider; import org.bigtesting.fixd.marshalling.Unmarshaller; import org.bigtesting.fixd.marshalling.UnmarshallerProvider;
/* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.core.container; /** * * @author Luis Antunes */ class MarshallerContainer { private final Map<String, RequestMarshallerImpl> contentMarshallers = new ConcurrentHashMap<String, RequestMarshallerImpl>(); private final Map<String, RequestUnmarshallerImpl> contentUnmarshallers = new ConcurrentHashMap<String, RequestUnmarshallerImpl>(); public void addContentMarshaller(String contentType, RequestMarshallerImpl marshaller) { this.contentMarshallers.put(contentType, marshaller); } public void addContentUnmarshaller(String contentType, RequestUnmarshallerImpl unmarshaller) { this.contentUnmarshallers.put(contentType, unmarshaller); } public MarshallerProvider newMarshallerProvider() { return new MarshallerProvider() {
// Path: src/main/java/org/bigtesting/fixd/core/RequestMarshallerImpl.java // public class RequestMarshallerImpl implements RequestMarshaller { // // private final String contentType; // // private Marshaller marshaller; // // public RequestMarshallerImpl(String contentType) { // this.contentType = contentType; // } // // public void with(Marshaller marshaller) { // this.marshaller = marshaller; // } // // public String getContentType() { // return contentType; // } // // public Marshaller getMarshaller() { // return marshaller; // } // } // // Path: src/main/java/org/bigtesting/fixd/core/RequestUnmarshallerImpl.java // public class RequestUnmarshallerImpl implements RequestUnmarshaller { // // private final String contentType; // // private Unmarshaller unmarshaller; // // public RequestUnmarshallerImpl(String contentType) { // this.contentType = contentType; // } // // public void with(Unmarshaller unmarshaller) { // this.unmarshaller = unmarshaller; // } // // public String getContentType() { // return contentType; // } // // public Unmarshaller getUnmarshaller() { // return unmarshaller; // } // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/Marshaller.java // public interface Marshaller { // // InputStream marshal(Object entity); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/MarshallerProvider.java // public interface MarshallerProvider { // // /** // * // * Returns the Marshaller for the given content-type, // * or null if there is no Marshaller for the given // * content-type. // * // * @param contentType // * @return the Marshaller for the given content-type, or // * null if there is no Marshaller for the given // * content-type // */ // Marshaller getMarshaller(String contentType); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/Unmarshaller.java // public interface Unmarshaller { // // <T> T unmarshal(InputStream in, Class<T> type); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/UnmarshallerProvider.java // public interface UnmarshallerProvider { // // /** // * // * Returns the Unmarshaller for the given content-type, // * or null if there is no Unmarshaller for the given // * content-type. // * // * @param contentType // * @return the Unmarshaller for the given content-type, or // * null if there is no Unmarshaller for the given // * content-type // */ // Unmarshaller getUnmarshaller(String contentType); // } // Path: src/main/java/org/bigtesting/fixd/core/container/MarshallerContainer.java import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.bigtesting.fixd.core.RequestMarshallerImpl; import org.bigtesting.fixd.core.RequestUnmarshallerImpl; import org.bigtesting.fixd.marshalling.Marshaller; import org.bigtesting.fixd.marshalling.MarshallerProvider; import org.bigtesting.fixd.marshalling.Unmarshaller; import org.bigtesting.fixd.marshalling.UnmarshallerProvider; /* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.core.container; /** * * @author Luis Antunes */ class MarshallerContainer { private final Map<String, RequestMarshallerImpl> contentMarshallers = new ConcurrentHashMap<String, RequestMarshallerImpl>(); private final Map<String, RequestUnmarshallerImpl> contentUnmarshallers = new ConcurrentHashMap<String, RequestUnmarshallerImpl>(); public void addContentMarshaller(String contentType, RequestMarshallerImpl marshaller) { this.contentMarshallers.put(contentType, marshaller); } public void addContentUnmarshaller(String contentType, RequestUnmarshallerImpl unmarshaller) { this.contentUnmarshallers.put(contentType, unmarshaller); } public MarshallerProvider newMarshallerProvider() { return new MarshallerProvider() {
public Marshaller getMarshaller(String contentType) {
lantunes/fixd
src/main/java/org/bigtesting/fixd/core/container/MarshallerContainer.java
// Path: src/main/java/org/bigtesting/fixd/core/RequestMarshallerImpl.java // public class RequestMarshallerImpl implements RequestMarshaller { // // private final String contentType; // // private Marshaller marshaller; // // public RequestMarshallerImpl(String contentType) { // this.contentType = contentType; // } // // public void with(Marshaller marshaller) { // this.marshaller = marshaller; // } // // public String getContentType() { // return contentType; // } // // public Marshaller getMarshaller() { // return marshaller; // } // } // // Path: src/main/java/org/bigtesting/fixd/core/RequestUnmarshallerImpl.java // public class RequestUnmarshallerImpl implements RequestUnmarshaller { // // private final String contentType; // // private Unmarshaller unmarshaller; // // public RequestUnmarshallerImpl(String contentType) { // this.contentType = contentType; // } // // public void with(Unmarshaller unmarshaller) { // this.unmarshaller = unmarshaller; // } // // public String getContentType() { // return contentType; // } // // public Unmarshaller getUnmarshaller() { // return unmarshaller; // } // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/Marshaller.java // public interface Marshaller { // // InputStream marshal(Object entity); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/MarshallerProvider.java // public interface MarshallerProvider { // // /** // * // * Returns the Marshaller for the given content-type, // * or null if there is no Marshaller for the given // * content-type. // * // * @param contentType // * @return the Marshaller for the given content-type, or // * null if there is no Marshaller for the given // * content-type // */ // Marshaller getMarshaller(String contentType); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/Unmarshaller.java // public interface Unmarshaller { // // <T> T unmarshal(InputStream in, Class<T> type); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/UnmarshallerProvider.java // public interface UnmarshallerProvider { // // /** // * // * Returns the Unmarshaller for the given content-type, // * or null if there is no Unmarshaller for the given // * content-type. // * // * @param contentType // * @return the Unmarshaller for the given content-type, or // * null if there is no Unmarshaller for the given // * content-type // */ // Unmarshaller getUnmarshaller(String contentType); // }
import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.bigtesting.fixd.core.RequestMarshallerImpl; import org.bigtesting.fixd.core.RequestUnmarshallerImpl; import org.bigtesting.fixd.marshalling.Marshaller; import org.bigtesting.fixd.marshalling.MarshallerProvider; import org.bigtesting.fixd.marshalling.Unmarshaller; import org.bigtesting.fixd.marshalling.UnmarshallerProvider;
/* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.core.container; /** * * @author Luis Antunes */ class MarshallerContainer { private final Map<String, RequestMarshallerImpl> contentMarshallers = new ConcurrentHashMap<String, RequestMarshallerImpl>(); private final Map<String, RequestUnmarshallerImpl> contentUnmarshallers = new ConcurrentHashMap<String, RequestUnmarshallerImpl>(); public void addContentMarshaller(String contentType, RequestMarshallerImpl marshaller) { this.contentMarshallers.put(contentType, marshaller); } public void addContentUnmarshaller(String contentType, RequestUnmarshallerImpl unmarshaller) { this.contentUnmarshallers.put(contentType, unmarshaller); } public MarshallerProvider newMarshallerProvider() { return new MarshallerProvider() { public Marshaller getMarshaller(String contentType) { RequestMarshallerImpl marsh = contentMarshallers.get(contentType); return marsh != null ? marsh.getMarshaller() : null; } }; }
// Path: src/main/java/org/bigtesting/fixd/core/RequestMarshallerImpl.java // public class RequestMarshallerImpl implements RequestMarshaller { // // private final String contentType; // // private Marshaller marshaller; // // public RequestMarshallerImpl(String contentType) { // this.contentType = contentType; // } // // public void with(Marshaller marshaller) { // this.marshaller = marshaller; // } // // public String getContentType() { // return contentType; // } // // public Marshaller getMarshaller() { // return marshaller; // } // } // // Path: src/main/java/org/bigtesting/fixd/core/RequestUnmarshallerImpl.java // public class RequestUnmarshallerImpl implements RequestUnmarshaller { // // private final String contentType; // // private Unmarshaller unmarshaller; // // public RequestUnmarshallerImpl(String contentType) { // this.contentType = contentType; // } // // public void with(Unmarshaller unmarshaller) { // this.unmarshaller = unmarshaller; // } // // public String getContentType() { // return contentType; // } // // public Unmarshaller getUnmarshaller() { // return unmarshaller; // } // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/Marshaller.java // public interface Marshaller { // // InputStream marshal(Object entity); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/MarshallerProvider.java // public interface MarshallerProvider { // // /** // * // * Returns the Marshaller for the given content-type, // * or null if there is no Marshaller for the given // * content-type. // * // * @param contentType // * @return the Marshaller for the given content-type, or // * null if there is no Marshaller for the given // * content-type // */ // Marshaller getMarshaller(String contentType); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/Unmarshaller.java // public interface Unmarshaller { // // <T> T unmarshal(InputStream in, Class<T> type); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/UnmarshallerProvider.java // public interface UnmarshallerProvider { // // /** // * // * Returns the Unmarshaller for the given content-type, // * or null if there is no Unmarshaller for the given // * content-type. // * // * @param contentType // * @return the Unmarshaller for the given content-type, or // * null if there is no Unmarshaller for the given // * content-type // */ // Unmarshaller getUnmarshaller(String contentType); // } // Path: src/main/java/org/bigtesting/fixd/core/container/MarshallerContainer.java import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.bigtesting.fixd.core.RequestMarshallerImpl; import org.bigtesting.fixd.core.RequestUnmarshallerImpl; import org.bigtesting.fixd.marshalling.Marshaller; import org.bigtesting.fixd.marshalling.MarshallerProvider; import org.bigtesting.fixd.marshalling.Unmarshaller; import org.bigtesting.fixd.marshalling.UnmarshallerProvider; /* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.core.container; /** * * @author Luis Antunes */ class MarshallerContainer { private final Map<String, RequestMarshallerImpl> contentMarshallers = new ConcurrentHashMap<String, RequestMarshallerImpl>(); private final Map<String, RequestUnmarshallerImpl> contentUnmarshallers = new ConcurrentHashMap<String, RequestUnmarshallerImpl>(); public void addContentMarshaller(String contentType, RequestMarshallerImpl marshaller) { this.contentMarshallers.put(contentType, marshaller); } public void addContentUnmarshaller(String contentType, RequestUnmarshallerImpl unmarshaller) { this.contentUnmarshallers.put(contentType, unmarshaller); } public MarshallerProvider newMarshallerProvider() { return new MarshallerProvider() { public Marshaller getMarshaller(String contentType) { RequestMarshallerImpl marsh = contentMarshallers.get(contentType); return marsh != null ? marsh.getMarshaller() : null; } }; }
public UnmarshallerProvider newUnmarshallerProvider() {
lantunes/fixd
src/main/java/org/bigtesting/fixd/core/container/MarshallerContainer.java
// Path: src/main/java/org/bigtesting/fixd/core/RequestMarshallerImpl.java // public class RequestMarshallerImpl implements RequestMarshaller { // // private final String contentType; // // private Marshaller marshaller; // // public RequestMarshallerImpl(String contentType) { // this.contentType = contentType; // } // // public void with(Marshaller marshaller) { // this.marshaller = marshaller; // } // // public String getContentType() { // return contentType; // } // // public Marshaller getMarshaller() { // return marshaller; // } // } // // Path: src/main/java/org/bigtesting/fixd/core/RequestUnmarshallerImpl.java // public class RequestUnmarshallerImpl implements RequestUnmarshaller { // // private final String contentType; // // private Unmarshaller unmarshaller; // // public RequestUnmarshallerImpl(String contentType) { // this.contentType = contentType; // } // // public void with(Unmarshaller unmarshaller) { // this.unmarshaller = unmarshaller; // } // // public String getContentType() { // return contentType; // } // // public Unmarshaller getUnmarshaller() { // return unmarshaller; // } // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/Marshaller.java // public interface Marshaller { // // InputStream marshal(Object entity); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/MarshallerProvider.java // public interface MarshallerProvider { // // /** // * // * Returns the Marshaller for the given content-type, // * or null if there is no Marshaller for the given // * content-type. // * // * @param contentType // * @return the Marshaller for the given content-type, or // * null if there is no Marshaller for the given // * content-type // */ // Marshaller getMarshaller(String contentType); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/Unmarshaller.java // public interface Unmarshaller { // // <T> T unmarshal(InputStream in, Class<T> type); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/UnmarshallerProvider.java // public interface UnmarshallerProvider { // // /** // * // * Returns the Unmarshaller for the given content-type, // * or null if there is no Unmarshaller for the given // * content-type. // * // * @param contentType // * @return the Unmarshaller for the given content-type, or // * null if there is no Unmarshaller for the given // * content-type // */ // Unmarshaller getUnmarshaller(String contentType); // }
import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.bigtesting.fixd.core.RequestMarshallerImpl; import org.bigtesting.fixd.core.RequestUnmarshallerImpl; import org.bigtesting.fixd.marshalling.Marshaller; import org.bigtesting.fixd.marshalling.MarshallerProvider; import org.bigtesting.fixd.marshalling.Unmarshaller; import org.bigtesting.fixd.marshalling.UnmarshallerProvider;
/* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.core.container; /** * * @author Luis Antunes */ class MarshallerContainer { private final Map<String, RequestMarshallerImpl> contentMarshallers = new ConcurrentHashMap<String, RequestMarshallerImpl>(); private final Map<String, RequestUnmarshallerImpl> contentUnmarshallers = new ConcurrentHashMap<String, RequestUnmarshallerImpl>(); public void addContentMarshaller(String contentType, RequestMarshallerImpl marshaller) { this.contentMarshallers.put(contentType, marshaller); } public void addContentUnmarshaller(String contentType, RequestUnmarshallerImpl unmarshaller) { this.contentUnmarshallers.put(contentType, unmarshaller); } public MarshallerProvider newMarshallerProvider() { return new MarshallerProvider() { public Marshaller getMarshaller(String contentType) { RequestMarshallerImpl marsh = contentMarshallers.get(contentType); return marsh != null ? marsh.getMarshaller() : null; } }; } public UnmarshallerProvider newUnmarshallerProvider() { return new UnmarshallerProvider() {
// Path: src/main/java/org/bigtesting/fixd/core/RequestMarshallerImpl.java // public class RequestMarshallerImpl implements RequestMarshaller { // // private final String contentType; // // private Marshaller marshaller; // // public RequestMarshallerImpl(String contentType) { // this.contentType = contentType; // } // // public void with(Marshaller marshaller) { // this.marshaller = marshaller; // } // // public String getContentType() { // return contentType; // } // // public Marshaller getMarshaller() { // return marshaller; // } // } // // Path: src/main/java/org/bigtesting/fixd/core/RequestUnmarshallerImpl.java // public class RequestUnmarshallerImpl implements RequestUnmarshaller { // // private final String contentType; // // private Unmarshaller unmarshaller; // // public RequestUnmarshallerImpl(String contentType) { // this.contentType = contentType; // } // // public void with(Unmarshaller unmarshaller) { // this.unmarshaller = unmarshaller; // } // // public String getContentType() { // return contentType; // } // // public Unmarshaller getUnmarshaller() { // return unmarshaller; // } // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/Marshaller.java // public interface Marshaller { // // InputStream marshal(Object entity); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/MarshallerProvider.java // public interface MarshallerProvider { // // /** // * // * Returns the Marshaller for the given content-type, // * or null if there is no Marshaller for the given // * content-type. // * // * @param contentType // * @return the Marshaller for the given content-type, or // * null if there is no Marshaller for the given // * content-type // */ // Marshaller getMarshaller(String contentType); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/Unmarshaller.java // public interface Unmarshaller { // // <T> T unmarshal(InputStream in, Class<T> type); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/UnmarshallerProvider.java // public interface UnmarshallerProvider { // // /** // * // * Returns the Unmarshaller for the given content-type, // * or null if there is no Unmarshaller for the given // * content-type. // * // * @param contentType // * @return the Unmarshaller for the given content-type, or // * null if there is no Unmarshaller for the given // * content-type // */ // Unmarshaller getUnmarshaller(String contentType); // } // Path: src/main/java/org/bigtesting/fixd/core/container/MarshallerContainer.java import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.bigtesting.fixd.core.RequestMarshallerImpl; import org.bigtesting.fixd.core.RequestUnmarshallerImpl; import org.bigtesting.fixd.marshalling.Marshaller; import org.bigtesting.fixd.marshalling.MarshallerProvider; import org.bigtesting.fixd.marshalling.Unmarshaller; import org.bigtesting.fixd.marshalling.UnmarshallerProvider; /* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.core.container; /** * * @author Luis Antunes */ class MarshallerContainer { private final Map<String, RequestMarshallerImpl> contentMarshallers = new ConcurrentHashMap<String, RequestMarshallerImpl>(); private final Map<String, RequestUnmarshallerImpl> contentUnmarshallers = new ConcurrentHashMap<String, RequestUnmarshallerImpl>(); public void addContentMarshaller(String contentType, RequestMarshallerImpl marshaller) { this.contentMarshallers.put(contentType, marshaller); } public void addContentUnmarshaller(String contentType, RequestUnmarshallerImpl unmarshaller) { this.contentUnmarshallers.put(contentType, unmarshaller); } public MarshallerProvider newMarshallerProvider() { return new MarshallerProvider() { public Marshaller getMarshaller(String contentType) { RequestMarshallerImpl marsh = contentMarshallers.get(contentType); return marsh != null ? marsh.getMarshaller() : null; } }; } public UnmarshallerProvider newUnmarshallerProvider() { return new UnmarshallerProvider() {
public Unmarshaller getUnmarshaller(String contentType) {
lantunes/fixd
src/test/java/org/bigtesting/fixd/tests/TestRequestParamSessionHandler.java
// Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java // public interface HttpRequest { // // String getPath(); // // String getUndecodedPath(); // // Set<String> getRequestParameterNames(); // // String getRequestParameter(String name); // // String getPathParameter(String name); // // List<String> getHeaderNames(); // // String getHeaderValue(String name); // // String getBody(); // // InputStream getBodyAsStream() throws IOException; // // <T> T getBody(Class<T> type); // // long getContentLength(); // // String getContentType(); // // String getMethod(); // // long getTime(); // // String getQuery(); // // int getMajor(); // // int getMinor(); // // String getTarget(); // // /** // * @return a session, if it exists, or null if it does not // */ // Session getSession(); // // Route getRoute(); // } // // Path: src/main/java/org/bigtesting/fixd/session/RequestParamSessionHandler.java // public class RequestParamSessionHandler implements SessionHandler { // // public void onCreate(HttpRequest request) { // // Set<String> params = request.getRequestParameterNames(); // // for (String param : params) { // request.getSession().set(param, request.getRequestParameter(param)); // } // } // } // // Path: src/main/java/org/bigtesting/fixd/session/Session.java // public class Session { // // private final String sessionId; // // private final Map<String, Object> values = new HashMap<String, Object>(); // // private boolean valid = true; // // public Session() { // // this.sessionId = UUID.randomUUID().toString(); // } // // public String getSessionId() { // // return sessionId; // } // // public Object get(String key) { // // return values.get(key); // } // // public void set(String key, Object value) { // // values.put(key, value); // } // // public Set<String> getAttributeNames() { // // return values.keySet(); // } // // public boolean isValid() { // // return valid; // } // // public void invalidate() { // // this.valid = false; // } // } // // Path: src/main/java/org/bigtesting/fixd/session/SessionHandler.java // public interface SessionHandler { // // void onCreate(HttpRequest request); // }
import org.junit.Test; import static org.junit.Assert.*; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; import org.bigtesting.fixd.request.HttpRequest; import org.bigtesting.fixd.session.RequestParamSessionHandler; import org.bigtesting.fixd.session.Session; import org.bigtesting.fixd.session.SessionHandler; import org.bigtesting.routd.Route;
/* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.tests; /** * * @author Luis Antunes */ public class TestRequestParamSessionHandler { @Test public void onCreateIsHandled() {
// Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java // public interface HttpRequest { // // String getPath(); // // String getUndecodedPath(); // // Set<String> getRequestParameterNames(); // // String getRequestParameter(String name); // // String getPathParameter(String name); // // List<String> getHeaderNames(); // // String getHeaderValue(String name); // // String getBody(); // // InputStream getBodyAsStream() throws IOException; // // <T> T getBody(Class<T> type); // // long getContentLength(); // // String getContentType(); // // String getMethod(); // // long getTime(); // // String getQuery(); // // int getMajor(); // // int getMinor(); // // String getTarget(); // // /** // * @return a session, if it exists, or null if it does not // */ // Session getSession(); // // Route getRoute(); // } // // Path: src/main/java/org/bigtesting/fixd/session/RequestParamSessionHandler.java // public class RequestParamSessionHandler implements SessionHandler { // // public void onCreate(HttpRequest request) { // // Set<String> params = request.getRequestParameterNames(); // // for (String param : params) { // request.getSession().set(param, request.getRequestParameter(param)); // } // } // } // // Path: src/main/java/org/bigtesting/fixd/session/Session.java // public class Session { // // private final String sessionId; // // private final Map<String, Object> values = new HashMap<String, Object>(); // // private boolean valid = true; // // public Session() { // // this.sessionId = UUID.randomUUID().toString(); // } // // public String getSessionId() { // // return sessionId; // } // // public Object get(String key) { // // return values.get(key); // } // // public void set(String key, Object value) { // // values.put(key, value); // } // // public Set<String> getAttributeNames() { // // return values.keySet(); // } // // public boolean isValid() { // // return valid; // } // // public void invalidate() { // // this.valid = false; // } // } // // Path: src/main/java/org/bigtesting/fixd/session/SessionHandler.java // public interface SessionHandler { // // void onCreate(HttpRequest request); // } // Path: src/test/java/org/bigtesting/fixd/tests/TestRequestParamSessionHandler.java import org.junit.Test; import static org.junit.Assert.*; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; import org.bigtesting.fixd.request.HttpRequest; import org.bigtesting.fixd.session.RequestParamSessionHandler; import org.bigtesting.fixd.session.Session; import org.bigtesting.fixd.session.SessionHandler; import org.bigtesting.routd.Route; /* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.tests; /** * * @author Luis Antunes */ public class TestRequestParamSessionHandler { @Test public void onCreateIsHandled() {
HttpRequest request = mock(HttpRequest.class);
lantunes/fixd
src/test/java/org/bigtesting/fixd/tests/TestRequestParamSessionHandler.java
// Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java // public interface HttpRequest { // // String getPath(); // // String getUndecodedPath(); // // Set<String> getRequestParameterNames(); // // String getRequestParameter(String name); // // String getPathParameter(String name); // // List<String> getHeaderNames(); // // String getHeaderValue(String name); // // String getBody(); // // InputStream getBodyAsStream() throws IOException; // // <T> T getBody(Class<T> type); // // long getContentLength(); // // String getContentType(); // // String getMethod(); // // long getTime(); // // String getQuery(); // // int getMajor(); // // int getMinor(); // // String getTarget(); // // /** // * @return a session, if it exists, or null if it does not // */ // Session getSession(); // // Route getRoute(); // } // // Path: src/main/java/org/bigtesting/fixd/session/RequestParamSessionHandler.java // public class RequestParamSessionHandler implements SessionHandler { // // public void onCreate(HttpRequest request) { // // Set<String> params = request.getRequestParameterNames(); // // for (String param : params) { // request.getSession().set(param, request.getRequestParameter(param)); // } // } // } // // Path: src/main/java/org/bigtesting/fixd/session/Session.java // public class Session { // // private final String sessionId; // // private final Map<String, Object> values = new HashMap<String, Object>(); // // private boolean valid = true; // // public Session() { // // this.sessionId = UUID.randomUUID().toString(); // } // // public String getSessionId() { // // return sessionId; // } // // public Object get(String key) { // // return values.get(key); // } // // public void set(String key, Object value) { // // values.put(key, value); // } // // public Set<String> getAttributeNames() { // // return values.keySet(); // } // // public boolean isValid() { // // return valid; // } // // public void invalidate() { // // this.valid = false; // } // } // // Path: src/main/java/org/bigtesting/fixd/session/SessionHandler.java // public interface SessionHandler { // // void onCreate(HttpRequest request); // }
import org.junit.Test; import static org.junit.Assert.*; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; import org.bigtesting.fixd.request.HttpRequest; import org.bigtesting.fixd.session.RequestParamSessionHandler; import org.bigtesting.fixd.session.Session; import org.bigtesting.fixd.session.SessionHandler; import org.bigtesting.routd.Route;
/* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.tests; /** * * @author Luis Antunes */ public class TestRequestParamSessionHandler { @Test public void onCreateIsHandled() { HttpRequest request = mock(HttpRequest.class); Set<String> params = new HashSet<String>(); params.add("firstName"); params.add("lastName"); when(request.getRequestParameterNames()).thenReturn(params); when(request.getRequestParameter("firstName")).thenReturn("John"); when(request.getRequestParameter("lastName")).thenReturn("Doe");
// Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java // public interface HttpRequest { // // String getPath(); // // String getUndecodedPath(); // // Set<String> getRequestParameterNames(); // // String getRequestParameter(String name); // // String getPathParameter(String name); // // List<String> getHeaderNames(); // // String getHeaderValue(String name); // // String getBody(); // // InputStream getBodyAsStream() throws IOException; // // <T> T getBody(Class<T> type); // // long getContentLength(); // // String getContentType(); // // String getMethod(); // // long getTime(); // // String getQuery(); // // int getMajor(); // // int getMinor(); // // String getTarget(); // // /** // * @return a session, if it exists, or null if it does not // */ // Session getSession(); // // Route getRoute(); // } // // Path: src/main/java/org/bigtesting/fixd/session/RequestParamSessionHandler.java // public class RequestParamSessionHandler implements SessionHandler { // // public void onCreate(HttpRequest request) { // // Set<String> params = request.getRequestParameterNames(); // // for (String param : params) { // request.getSession().set(param, request.getRequestParameter(param)); // } // } // } // // Path: src/main/java/org/bigtesting/fixd/session/Session.java // public class Session { // // private final String sessionId; // // private final Map<String, Object> values = new HashMap<String, Object>(); // // private boolean valid = true; // // public Session() { // // this.sessionId = UUID.randomUUID().toString(); // } // // public String getSessionId() { // // return sessionId; // } // // public Object get(String key) { // // return values.get(key); // } // // public void set(String key, Object value) { // // values.put(key, value); // } // // public Set<String> getAttributeNames() { // // return values.keySet(); // } // // public boolean isValid() { // // return valid; // } // // public void invalidate() { // // this.valid = false; // } // } // // Path: src/main/java/org/bigtesting/fixd/session/SessionHandler.java // public interface SessionHandler { // // void onCreate(HttpRequest request); // } // Path: src/test/java/org/bigtesting/fixd/tests/TestRequestParamSessionHandler.java import org.junit.Test; import static org.junit.Assert.*; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; import org.bigtesting.fixd.request.HttpRequest; import org.bigtesting.fixd.session.RequestParamSessionHandler; import org.bigtesting.fixd.session.Session; import org.bigtesting.fixd.session.SessionHandler; import org.bigtesting.routd.Route; /* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.tests; /** * * @author Luis Antunes */ public class TestRequestParamSessionHandler { @Test public void onCreateIsHandled() { HttpRequest request = mock(HttpRequest.class); Set<String> params = new HashSet<String>(); params.add("firstName"); params.add("lastName"); when(request.getRequestParameterNames()).thenReturn(params); when(request.getRequestParameter("firstName")).thenReturn("John"); when(request.getRequestParameter("lastName")).thenReturn("Doe");
Session session = new Session();
lantunes/fixd
src/test/java/org/bigtesting/fixd/tests/TestRequestParamSessionHandler.java
// Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java // public interface HttpRequest { // // String getPath(); // // String getUndecodedPath(); // // Set<String> getRequestParameterNames(); // // String getRequestParameter(String name); // // String getPathParameter(String name); // // List<String> getHeaderNames(); // // String getHeaderValue(String name); // // String getBody(); // // InputStream getBodyAsStream() throws IOException; // // <T> T getBody(Class<T> type); // // long getContentLength(); // // String getContentType(); // // String getMethod(); // // long getTime(); // // String getQuery(); // // int getMajor(); // // int getMinor(); // // String getTarget(); // // /** // * @return a session, if it exists, or null if it does not // */ // Session getSession(); // // Route getRoute(); // } // // Path: src/main/java/org/bigtesting/fixd/session/RequestParamSessionHandler.java // public class RequestParamSessionHandler implements SessionHandler { // // public void onCreate(HttpRequest request) { // // Set<String> params = request.getRequestParameterNames(); // // for (String param : params) { // request.getSession().set(param, request.getRequestParameter(param)); // } // } // } // // Path: src/main/java/org/bigtesting/fixd/session/Session.java // public class Session { // // private final String sessionId; // // private final Map<String, Object> values = new HashMap<String, Object>(); // // private boolean valid = true; // // public Session() { // // this.sessionId = UUID.randomUUID().toString(); // } // // public String getSessionId() { // // return sessionId; // } // // public Object get(String key) { // // return values.get(key); // } // // public void set(String key, Object value) { // // values.put(key, value); // } // // public Set<String> getAttributeNames() { // // return values.keySet(); // } // // public boolean isValid() { // // return valid; // } // // public void invalidate() { // // this.valid = false; // } // } // // Path: src/main/java/org/bigtesting/fixd/session/SessionHandler.java // public interface SessionHandler { // // void onCreate(HttpRequest request); // }
import org.junit.Test; import static org.junit.Assert.*; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; import org.bigtesting.fixd.request.HttpRequest; import org.bigtesting.fixd.session.RequestParamSessionHandler; import org.bigtesting.fixd.session.Session; import org.bigtesting.fixd.session.SessionHandler; import org.bigtesting.routd.Route;
newSessionHandler().onCreate(request); List<String> attributeNames = new ArrayList<String>(session.getAttributeNames()); Collections.sort(attributeNames); assertEquals("[firstName, lastName]", attributeNames.toString()); assertEquals("John", session.get("firstName")); assertEquals("Doe", session.get("lastName")); } @Test public void onCreateIsHandledWithNoParams() { HttpRequest request = mock(HttpRequest.class); when(request.getRequestParameterNames()).thenReturn(new HashSet<String>()); when(request.getRequestParameter(anyString())).thenReturn(null); Session session = new Session(); when(request.getSession()).thenReturn(session); Route route = new Route("/"); when(request.getRoute()).thenReturn(route); newSessionHandler().onCreate(request); assertEquals("[]", session.getAttributeNames().toString()); }
// Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java // public interface HttpRequest { // // String getPath(); // // String getUndecodedPath(); // // Set<String> getRequestParameterNames(); // // String getRequestParameter(String name); // // String getPathParameter(String name); // // List<String> getHeaderNames(); // // String getHeaderValue(String name); // // String getBody(); // // InputStream getBodyAsStream() throws IOException; // // <T> T getBody(Class<T> type); // // long getContentLength(); // // String getContentType(); // // String getMethod(); // // long getTime(); // // String getQuery(); // // int getMajor(); // // int getMinor(); // // String getTarget(); // // /** // * @return a session, if it exists, or null if it does not // */ // Session getSession(); // // Route getRoute(); // } // // Path: src/main/java/org/bigtesting/fixd/session/RequestParamSessionHandler.java // public class RequestParamSessionHandler implements SessionHandler { // // public void onCreate(HttpRequest request) { // // Set<String> params = request.getRequestParameterNames(); // // for (String param : params) { // request.getSession().set(param, request.getRequestParameter(param)); // } // } // } // // Path: src/main/java/org/bigtesting/fixd/session/Session.java // public class Session { // // private final String sessionId; // // private final Map<String, Object> values = new HashMap<String, Object>(); // // private boolean valid = true; // // public Session() { // // this.sessionId = UUID.randomUUID().toString(); // } // // public String getSessionId() { // // return sessionId; // } // // public Object get(String key) { // // return values.get(key); // } // // public void set(String key, Object value) { // // values.put(key, value); // } // // public Set<String> getAttributeNames() { // // return values.keySet(); // } // // public boolean isValid() { // // return valid; // } // // public void invalidate() { // // this.valid = false; // } // } // // Path: src/main/java/org/bigtesting/fixd/session/SessionHandler.java // public interface SessionHandler { // // void onCreate(HttpRequest request); // } // Path: src/test/java/org/bigtesting/fixd/tests/TestRequestParamSessionHandler.java import org.junit.Test; import static org.junit.Assert.*; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; import org.bigtesting.fixd.request.HttpRequest; import org.bigtesting.fixd.session.RequestParamSessionHandler; import org.bigtesting.fixd.session.Session; import org.bigtesting.fixd.session.SessionHandler; import org.bigtesting.routd.Route; newSessionHandler().onCreate(request); List<String> attributeNames = new ArrayList<String>(session.getAttributeNames()); Collections.sort(attributeNames); assertEquals("[firstName, lastName]", attributeNames.toString()); assertEquals("John", session.get("firstName")); assertEquals("Doe", session.get("lastName")); } @Test public void onCreateIsHandledWithNoParams() { HttpRequest request = mock(HttpRequest.class); when(request.getRequestParameterNames()).thenReturn(new HashSet<String>()); when(request.getRequestParameter(anyString())).thenReturn(null); Session session = new Session(); when(request.getSession()).thenReturn(session); Route route = new Route("/"); when(request.getRoute()).thenReturn(route); newSessionHandler().onCreate(request); assertEquals("[]", session.getAttributeNames().toString()); }
private SessionHandler newSessionHandler() {
lantunes/fixd
src/test/java/org/bigtesting/fixd/tests/TestRequestParamSessionHandler.java
// Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java // public interface HttpRequest { // // String getPath(); // // String getUndecodedPath(); // // Set<String> getRequestParameterNames(); // // String getRequestParameter(String name); // // String getPathParameter(String name); // // List<String> getHeaderNames(); // // String getHeaderValue(String name); // // String getBody(); // // InputStream getBodyAsStream() throws IOException; // // <T> T getBody(Class<T> type); // // long getContentLength(); // // String getContentType(); // // String getMethod(); // // long getTime(); // // String getQuery(); // // int getMajor(); // // int getMinor(); // // String getTarget(); // // /** // * @return a session, if it exists, or null if it does not // */ // Session getSession(); // // Route getRoute(); // } // // Path: src/main/java/org/bigtesting/fixd/session/RequestParamSessionHandler.java // public class RequestParamSessionHandler implements SessionHandler { // // public void onCreate(HttpRequest request) { // // Set<String> params = request.getRequestParameterNames(); // // for (String param : params) { // request.getSession().set(param, request.getRequestParameter(param)); // } // } // } // // Path: src/main/java/org/bigtesting/fixd/session/Session.java // public class Session { // // private final String sessionId; // // private final Map<String, Object> values = new HashMap<String, Object>(); // // private boolean valid = true; // // public Session() { // // this.sessionId = UUID.randomUUID().toString(); // } // // public String getSessionId() { // // return sessionId; // } // // public Object get(String key) { // // return values.get(key); // } // // public void set(String key, Object value) { // // values.put(key, value); // } // // public Set<String> getAttributeNames() { // // return values.keySet(); // } // // public boolean isValid() { // // return valid; // } // // public void invalidate() { // // this.valid = false; // } // } // // Path: src/main/java/org/bigtesting/fixd/session/SessionHandler.java // public interface SessionHandler { // // void onCreate(HttpRequest request); // }
import org.junit.Test; import static org.junit.Assert.*; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; import org.bigtesting.fixd.request.HttpRequest; import org.bigtesting.fixd.session.RequestParamSessionHandler; import org.bigtesting.fixd.session.Session; import org.bigtesting.fixd.session.SessionHandler; import org.bigtesting.routd.Route;
newSessionHandler().onCreate(request); List<String> attributeNames = new ArrayList<String>(session.getAttributeNames()); Collections.sort(attributeNames); assertEquals("[firstName, lastName]", attributeNames.toString()); assertEquals("John", session.get("firstName")); assertEquals("Doe", session.get("lastName")); } @Test public void onCreateIsHandledWithNoParams() { HttpRequest request = mock(HttpRequest.class); when(request.getRequestParameterNames()).thenReturn(new HashSet<String>()); when(request.getRequestParameter(anyString())).thenReturn(null); Session session = new Session(); when(request.getSession()).thenReturn(session); Route route = new Route("/"); when(request.getRoute()).thenReturn(route); newSessionHandler().onCreate(request); assertEquals("[]", session.getAttributeNames().toString()); } private SessionHandler newSessionHandler() {
// Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java // public interface HttpRequest { // // String getPath(); // // String getUndecodedPath(); // // Set<String> getRequestParameterNames(); // // String getRequestParameter(String name); // // String getPathParameter(String name); // // List<String> getHeaderNames(); // // String getHeaderValue(String name); // // String getBody(); // // InputStream getBodyAsStream() throws IOException; // // <T> T getBody(Class<T> type); // // long getContentLength(); // // String getContentType(); // // String getMethod(); // // long getTime(); // // String getQuery(); // // int getMajor(); // // int getMinor(); // // String getTarget(); // // /** // * @return a session, if it exists, or null if it does not // */ // Session getSession(); // // Route getRoute(); // } // // Path: src/main/java/org/bigtesting/fixd/session/RequestParamSessionHandler.java // public class RequestParamSessionHandler implements SessionHandler { // // public void onCreate(HttpRequest request) { // // Set<String> params = request.getRequestParameterNames(); // // for (String param : params) { // request.getSession().set(param, request.getRequestParameter(param)); // } // } // } // // Path: src/main/java/org/bigtesting/fixd/session/Session.java // public class Session { // // private final String sessionId; // // private final Map<String, Object> values = new HashMap<String, Object>(); // // private boolean valid = true; // // public Session() { // // this.sessionId = UUID.randomUUID().toString(); // } // // public String getSessionId() { // // return sessionId; // } // // public Object get(String key) { // // return values.get(key); // } // // public void set(String key, Object value) { // // values.put(key, value); // } // // public Set<String> getAttributeNames() { // // return values.keySet(); // } // // public boolean isValid() { // // return valid; // } // // public void invalidate() { // // this.valid = false; // } // } // // Path: src/main/java/org/bigtesting/fixd/session/SessionHandler.java // public interface SessionHandler { // // void onCreate(HttpRequest request); // } // Path: src/test/java/org/bigtesting/fixd/tests/TestRequestParamSessionHandler.java import org.junit.Test; import static org.junit.Assert.*; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; import org.bigtesting.fixd.request.HttpRequest; import org.bigtesting.fixd.session.RequestParamSessionHandler; import org.bigtesting.fixd.session.Session; import org.bigtesting.fixd.session.SessionHandler; import org.bigtesting.routd.Route; newSessionHandler().onCreate(request); List<String> attributeNames = new ArrayList<String>(session.getAttributeNames()); Collections.sort(attributeNames); assertEquals("[firstName, lastName]", attributeNames.toString()); assertEquals("John", session.get("firstName")); assertEquals("Doe", session.get("lastName")); } @Test public void onCreateIsHandledWithNoParams() { HttpRequest request = mock(HttpRequest.class); when(request.getRequestParameterNames()).thenReturn(new HashSet<String>()); when(request.getRequestParameter(anyString())).thenReturn(null); Session session = new Session(); when(request.getSession()).thenReturn(session); Route route = new Route("/"); when(request.getRoute()).thenReturn(route); newSessionHandler().onCreate(request); assertEquals("[]", session.getAttributeNames().toString()); } private SessionHandler newSessionHandler() {
return new RequestParamSessionHandler();
lantunes/fixd
src/main/java/org/bigtesting/fixd/core/container/CapturedRequestContainer.java
// Path: src/main/java/org/bigtesting/fixd/capture/CapturedRequest.java // public interface CapturedRequest { // // String getPath(); // // String getRequestLine(); // // String getMethod(); // // List<String> getHeaders(); // // byte[] getBody(); // // String getBody(String encoding); // // /** // * Returns true if this request was broadcast to any subscribers. // */ // boolean isBroadcast(); // } // // Path: src/main/java/org/bigtesting/fixd/capture/impl/SimpleCapturedRequest.java // public class SimpleCapturedRequest implements CapturedRequest { // // private final Request request; // // private boolean broadcast = false; // // public SimpleCapturedRequest(Request request) { // this.request = request; // } // // public String getPath() { // // return request.getPath().getPath(); // } // // public String getRequestLine() { // // return headerLines()[0]; // } // // public String getMethod() { // // return request.getMethod(); // } // // public List<String> getHeaders() { // // List<String> headers = new ArrayList<String>(); // String[] lines = headerLines(); // for (int i = 1; i < lines.length; i++) { // headers.add(lines[i]); // } // // return headers; // } // // public byte[] getBody() { // // try { // return RequestUtils.readBody(request.getInputStream()); // } catch (IOException e) { // throw new RuntimeException("error getting body", e); // } // } // // public String getBody(String encoding) { // // try { // // return new String(getBody(), encoding); // // } catch (UnsupportedEncodingException e) { // throw new RuntimeException("error getting encoded body", e); // } // } // // private String[] headerLines() { // // String header = request.getHeader().toString(); // return header.split("\\r?\\n"); // } // // public void setBroadcast(boolean broadcast) { // // this.broadcast = broadcast; // } // // public boolean isBroadcast() { // // return broadcast; // } // }
import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import org.bigtesting.fixd.capture.CapturedRequest; import org.bigtesting.fixd.capture.impl.SimpleCapturedRequest;
/* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.core.container; /** * * @author Luis Antunes */ class CapturedRequestContainer { private int capturedRequestLimit = -1;
// Path: src/main/java/org/bigtesting/fixd/capture/CapturedRequest.java // public interface CapturedRequest { // // String getPath(); // // String getRequestLine(); // // String getMethod(); // // List<String> getHeaders(); // // byte[] getBody(); // // String getBody(String encoding); // // /** // * Returns true if this request was broadcast to any subscribers. // */ // boolean isBroadcast(); // } // // Path: src/main/java/org/bigtesting/fixd/capture/impl/SimpleCapturedRequest.java // public class SimpleCapturedRequest implements CapturedRequest { // // private final Request request; // // private boolean broadcast = false; // // public SimpleCapturedRequest(Request request) { // this.request = request; // } // // public String getPath() { // // return request.getPath().getPath(); // } // // public String getRequestLine() { // // return headerLines()[0]; // } // // public String getMethod() { // // return request.getMethod(); // } // // public List<String> getHeaders() { // // List<String> headers = new ArrayList<String>(); // String[] lines = headerLines(); // for (int i = 1; i < lines.length; i++) { // headers.add(lines[i]); // } // // return headers; // } // // public byte[] getBody() { // // try { // return RequestUtils.readBody(request.getInputStream()); // } catch (IOException e) { // throw new RuntimeException("error getting body", e); // } // } // // public String getBody(String encoding) { // // try { // // return new String(getBody(), encoding); // // } catch (UnsupportedEncodingException e) { // throw new RuntimeException("error getting encoded body", e); // } // } // // private String[] headerLines() { // // String header = request.getHeader().toString(); // return header.split("\\r?\\n"); // } // // public void setBroadcast(boolean broadcast) { // // this.broadcast = broadcast; // } // // public boolean isBroadcast() { // // return broadcast; // } // } // Path: src/main/java/org/bigtesting/fixd/core/container/CapturedRequestContainer.java import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import org.bigtesting.fixd.capture.CapturedRequest; import org.bigtesting.fixd.capture.impl.SimpleCapturedRequest; /* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.core.container; /** * * @author Luis Antunes */ class CapturedRequestContainer { private int capturedRequestLimit = -1;
private final Queue<CapturedRequest> capturedRequests =
lantunes/fixd
src/main/java/org/bigtesting/fixd/core/container/CapturedRequestContainer.java
// Path: src/main/java/org/bigtesting/fixd/capture/CapturedRequest.java // public interface CapturedRequest { // // String getPath(); // // String getRequestLine(); // // String getMethod(); // // List<String> getHeaders(); // // byte[] getBody(); // // String getBody(String encoding); // // /** // * Returns true if this request was broadcast to any subscribers. // */ // boolean isBroadcast(); // } // // Path: src/main/java/org/bigtesting/fixd/capture/impl/SimpleCapturedRequest.java // public class SimpleCapturedRequest implements CapturedRequest { // // private final Request request; // // private boolean broadcast = false; // // public SimpleCapturedRequest(Request request) { // this.request = request; // } // // public String getPath() { // // return request.getPath().getPath(); // } // // public String getRequestLine() { // // return headerLines()[0]; // } // // public String getMethod() { // // return request.getMethod(); // } // // public List<String> getHeaders() { // // List<String> headers = new ArrayList<String>(); // String[] lines = headerLines(); // for (int i = 1; i < lines.length; i++) { // headers.add(lines[i]); // } // // return headers; // } // // public byte[] getBody() { // // try { // return RequestUtils.readBody(request.getInputStream()); // } catch (IOException e) { // throw new RuntimeException("error getting body", e); // } // } // // public String getBody(String encoding) { // // try { // // return new String(getBody(), encoding); // // } catch (UnsupportedEncodingException e) { // throw new RuntimeException("error getting encoded body", e); // } // } // // private String[] headerLines() { // // String header = request.getHeader().toString(); // return header.split("\\r?\\n"); // } // // public void setBroadcast(boolean broadcast) { // // this.broadcast = broadcast; // } // // public boolean isBroadcast() { // // return broadcast; // } // }
import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import org.bigtesting.fixd.capture.CapturedRequest; import org.bigtesting.fixd.capture.impl.SimpleCapturedRequest;
/* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.core.container; /** * * @author Luis Antunes */ class CapturedRequestContainer { private int capturedRequestLimit = -1; private final Queue<CapturedRequest> capturedRequests = new ConcurrentLinkedQueue<CapturedRequest>(); public Queue<CapturedRequest> getCapturedRequests() { return capturedRequests; } public CapturedRequest nextCapturedRequest() { return capturedRequests.poll(); } public void setCapturedRequestLimit(int limit) { this.capturedRequestLimit = limit; }
// Path: src/main/java/org/bigtesting/fixd/capture/CapturedRequest.java // public interface CapturedRequest { // // String getPath(); // // String getRequestLine(); // // String getMethod(); // // List<String> getHeaders(); // // byte[] getBody(); // // String getBody(String encoding); // // /** // * Returns true if this request was broadcast to any subscribers. // */ // boolean isBroadcast(); // } // // Path: src/main/java/org/bigtesting/fixd/capture/impl/SimpleCapturedRequest.java // public class SimpleCapturedRequest implements CapturedRequest { // // private final Request request; // // private boolean broadcast = false; // // public SimpleCapturedRequest(Request request) { // this.request = request; // } // // public String getPath() { // // return request.getPath().getPath(); // } // // public String getRequestLine() { // // return headerLines()[0]; // } // // public String getMethod() { // // return request.getMethod(); // } // // public List<String> getHeaders() { // // List<String> headers = new ArrayList<String>(); // String[] lines = headerLines(); // for (int i = 1; i < lines.length; i++) { // headers.add(lines[i]); // } // // return headers; // } // // public byte[] getBody() { // // try { // return RequestUtils.readBody(request.getInputStream()); // } catch (IOException e) { // throw new RuntimeException("error getting body", e); // } // } // // public String getBody(String encoding) { // // try { // // return new String(getBody(), encoding); // // } catch (UnsupportedEncodingException e) { // throw new RuntimeException("error getting encoded body", e); // } // } // // private String[] headerLines() { // // String header = request.getHeader().toString(); // return header.split("\\r?\\n"); // } // // public void setBroadcast(boolean broadcast) { // // this.broadcast = broadcast; // } // // public boolean isBroadcast() { // // return broadcast; // } // } // Path: src/main/java/org/bigtesting/fixd/core/container/CapturedRequestContainer.java import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import org.bigtesting.fixd.capture.CapturedRequest; import org.bigtesting.fixd.capture.impl.SimpleCapturedRequest; /* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.core.container; /** * * @author Luis Antunes */ class CapturedRequestContainer { private int capturedRequestLimit = -1; private final Queue<CapturedRequest> capturedRequests = new ConcurrentLinkedQueue<CapturedRequest>(); public Queue<CapturedRequest> getCapturedRequests() { return capturedRequests; } public CapturedRequest nextCapturedRequest() { return capturedRequests.poll(); } public void setCapturedRequestLimit(int limit) { this.capturedRequestLimit = limit; }
public void addCapturedRequest(SimpleCapturedRequest captured) {
lantunes/fixd
src/main/java/org/bigtesting/fixd/core/body/InterpolatedResponseBody.java
// Path: src/main/java/org/bigtesting/fixd/interpolation/ResponseBodyInterpolator.java // public class ResponseBodyInterpolator { // // private static final Interpolator<HttpRequest> interpolator = new Interpolator<HttpRequest>(); // // private static final Map<String, RequestValueProvider<?>> requestValueProviders = // new HashMap<String, RequestValueProvider<?>>(); // // static { // requestValueProviders.put("request.body", new RequestBodyValueProvider()); // requestValueProviders.put("request.method", new RequestMethodValueProvider()); // requestValueProviders.put("request.time", new RequestTimeValueProvider()); // requestValueProviders.put("request.path", new RequestPathValueProvider()); // requestValueProviders.put("request.query", new RequestQueryValueProvider()); // requestValueProviders.put("request.major", new RequestMajorValueProvider()); // requestValueProviders.put("request.minor", new RequestMinorValueProvider()); // requestValueProviders.put("request.target", new RequestTargetValueProvider()); // // interpolator.when("[a-zA-Z0-9_]+").prefixedBy(":") // .handleWith(new Substitutor<HttpRequest>() { // public String substitute(String captured, HttpRequest req) { // // String path = req.getUndecodedPath(); // return req.getRoute().getNamedParameter(captured, path); // } // }); // // interpolator.when("[0-9]+").enclosedBy("*[").and("]") // .handleWith(new Substitutor<HttpRequest>() { // public String substitute(String captured, HttpRequest req) { // // String path = req.getUndecodedPath(); // int index = Integer.parseInt(captured); // return req.getRoute().getSplatParameter(index, path); // } // }); // // interpolator.when().enclosedBy("{").and("}") // .handleWith(new Substitutor<HttpRequest>() { // public String substitute(String captured, HttpRequest req) { // // if (req.getSession() != null) { // Object val = req.getSession().get(captured); // if (val != null) { // return val.toString(); // } // } // return null; // } // }); // // interpolator.when().enclosedBy("[").and("]") // .handleWith(new Substitutor<HttpRequest>() { // public String substitute(String captured, HttpRequest req) { // // if (captured.startsWith("request?")) { // return req.getRequestParameter(captured.replaceFirst("request\\?", "")); // } // // if (captured.startsWith("request$")) { // return req.getHeaderValue(captured.replaceFirst("request\\$", "")); // } // // RequestValueProvider<?> requestValueProvider = requestValueProviders.get(captured); // if (requestValueProvider != null) { // Object val = requestValueProvider.getValue(req); // if (val != null) { // return val.toString(); // } // } // return null; // } // }); // // interpolator.escapeWith("^"); // } // // public static String interpolate(String body, HttpRequest request) { // // return interpolator.interpolate(body, request); // } // } // // Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java // public interface HttpRequest { // // String getPath(); // // String getUndecodedPath(); // // Set<String> getRequestParameterNames(); // // String getRequestParameter(String name); // // String getPathParameter(String name); // // List<String> getHeaderNames(); // // String getHeaderValue(String name); // // String getBody(); // // InputStream getBodyAsStream() throws IOException; // // <T> T getBody(Class<T> type); // // long getContentLength(); // // String getContentType(); // // String getMethod(); // // long getTime(); // // String getQuery(); // // int getMajor(); // // int getMinor(); // // String getTarget(); // // /** // * @return a session, if it exists, or null if it does not // */ // Session getSession(); // // Route getRoute(); // }
import org.bigtesting.fixd.interpolation.ResponseBodyInterpolator; import org.bigtesting.fixd.request.HttpRequest;
/* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.core.body; /** * * @author Luis Antunes */ public class InterpolatedResponseBody extends StringResponseBody { public InterpolatedResponseBody(String body, HttpRequest req) {
// Path: src/main/java/org/bigtesting/fixd/interpolation/ResponseBodyInterpolator.java // public class ResponseBodyInterpolator { // // private static final Interpolator<HttpRequest> interpolator = new Interpolator<HttpRequest>(); // // private static final Map<String, RequestValueProvider<?>> requestValueProviders = // new HashMap<String, RequestValueProvider<?>>(); // // static { // requestValueProviders.put("request.body", new RequestBodyValueProvider()); // requestValueProviders.put("request.method", new RequestMethodValueProvider()); // requestValueProviders.put("request.time", new RequestTimeValueProvider()); // requestValueProviders.put("request.path", new RequestPathValueProvider()); // requestValueProviders.put("request.query", new RequestQueryValueProvider()); // requestValueProviders.put("request.major", new RequestMajorValueProvider()); // requestValueProviders.put("request.minor", new RequestMinorValueProvider()); // requestValueProviders.put("request.target", new RequestTargetValueProvider()); // // interpolator.when("[a-zA-Z0-9_]+").prefixedBy(":") // .handleWith(new Substitutor<HttpRequest>() { // public String substitute(String captured, HttpRequest req) { // // String path = req.getUndecodedPath(); // return req.getRoute().getNamedParameter(captured, path); // } // }); // // interpolator.when("[0-9]+").enclosedBy("*[").and("]") // .handleWith(new Substitutor<HttpRequest>() { // public String substitute(String captured, HttpRequest req) { // // String path = req.getUndecodedPath(); // int index = Integer.parseInt(captured); // return req.getRoute().getSplatParameter(index, path); // } // }); // // interpolator.when().enclosedBy("{").and("}") // .handleWith(new Substitutor<HttpRequest>() { // public String substitute(String captured, HttpRequest req) { // // if (req.getSession() != null) { // Object val = req.getSession().get(captured); // if (val != null) { // return val.toString(); // } // } // return null; // } // }); // // interpolator.when().enclosedBy("[").and("]") // .handleWith(new Substitutor<HttpRequest>() { // public String substitute(String captured, HttpRequest req) { // // if (captured.startsWith("request?")) { // return req.getRequestParameter(captured.replaceFirst("request\\?", "")); // } // // if (captured.startsWith("request$")) { // return req.getHeaderValue(captured.replaceFirst("request\\$", "")); // } // // RequestValueProvider<?> requestValueProvider = requestValueProviders.get(captured); // if (requestValueProvider != null) { // Object val = requestValueProvider.getValue(req); // if (val != null) { // return val.toString(); // } // } // return null; // } // }); // // interpolator.escapeWith("^"); // } // // public static String interpolate(String body, HttpRequest request) { // // return interpolator.interpolate(body, request); // } // } // // Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java // public interface HttpRequest { // // String getPath(); // // String getUndecodedPath(); // // Set<String> getRequestParameterNames(); // // String getRequestParameter(String name); // // String getPathParameter(String name); // // List<String> getHeaderNames(); // // String getHeaderValue(String name); // // String getBody(); // // InputStream getBodyAsStream() throws IOException; // // <T> T getBody(Class<T> type); // // long getContentLength(); // // String getContentType(); // // String getMethod(); // // long getTime(); // // String getQuery(); // // int getMajor(); // // int getMinor(); // // String getTarget(); // // /** // * @return a session, if it exists, or null if it does not // */ // Session getSession(); // // Route getRoute(); // } // Path: src/main/java/org/bigtesting/fixd/core/body/InterpolatedResponseBody.java import org.bigtesting.fixd.interpolation.ResponseBodyInterpolator; import org.bigtesting.fixd.request.HttpRequest; /* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.core.body; /** * * @author Luis Antunes */ public class InterpolatedResponseBody extends StringResponseBody { public InterpolatedResponseBody(String body, HttpRequest req) {
super(ResponseBodyInterpolator.interpolate(body, req));
lantunes/fixd
src/test/java/org/bigtesting/fixd/tests/TestPathParamSessionHandler.java
// Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java // public interface HttpRequest { // // String getPath(); // // String getUndecodedPath(); // // Set<String> getRequestParameterNames(); // // String getRequestParameter(String name); // // String getPathParameter(String name); // // List<String> getHeaderNames(); // // String getHeaderValue(String name); // // String getBody(); // // InputStream getBodyAsStream() throws IOException; // // <T> T getBody(Class<T> type); // // long getContentLength(); // // String getContentType(); // // String getMethod(); // // long getTime(); // // String getQuery(); // // int getMajor(); // // int getMinor(); // // String getTarget(); // // /** // * @return a session, if it exists, or null if it does not // */ // Session getSession(); // // Route getRoute(); // } // // Path: src/main/java/org/bigtesting/fixd/session/PathParamSessionHandler.java // public class PathParamSessionHandler implements SessionHandler { // // public void onCreate(HttpRequest request) { // // List<NamedParameterElement> pathParams = request.getRoute().getNamedParameterElements(); // String[] pathTokens = RouteHelper.getPathElements(request.getPath()); // // for (NamedParameterElement pathParam : pathParams) { // request.getSession().set(pathParam.name(), pathTokens[pathParam.index()]); // } // } // } // // Path: src/main/java/org/bigtesting/fixd/session/Session.java // public class Session { // // private final String sessionId; // // private final Map<String, Object> values = new HashMap<String, Object>(); // // private boolean valid = true; // // public Session() { // // this.sessionId = UUID.randomUUID().toString(); // } // // public String getSessionId() { // // return sessionId; // } // // public Object get(String key) { // // return values.get(key); // } // // public void set(String key, Object value) { // // values.put(key, value); // } // // public Set<String> getAttributeNames() { // // return values.keySet(); // } // // public boolean isValid() { // // return valid; // } // // public void invalidate() { // // this.valid = false; // } // } // // Path: src/main/java/org/bigtesting/fixd/session/SessionHandler.java // public interface SessionHandler { // // void onCreate(HttpRequest request); // }
import static org.junit.Assert.*; import static org.mockito.Mockito.*; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.bigtesting.fixd.request.HttpRequest; import org.bigtesting.fixd.session.PathParamSessionHandler; import org.bigtesting.fixd.session.Session; import org.bigtesting.fixd.session.SessionHandler; import org.bigtesting.routd.Route; import org.junit.Test;
/* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.tests; /** * * @author Luis Antunes */ public class TestPathParamSessionHandler { @Test public void onCreateIsHandled() {
// Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java // public interface HttpRequest { // // String getPath(); // // String getUndecodedPath(); // // Set<String> getRequestParameterNames(); // // String getRequestParameter(String name); // // String getPathParameter(String name); // // List<String> getHeaderNames(); // // String getHeaderValue(String name); // // String getBody(); // // InputStream getBodyAsStream() throws IOException; // // <T> T getBody(Class<T> type); // // long getContentLength(); // // String getContentType(); // // String getMethod(); // // long getTime(); // // String getQuery(); // // int getMajor(); // // int getMinor(); // // String getTarget(); // // /** // * @return a session, if it exists, or null if it does not // */ // Session getSession(); // // Route getRoute(); // } // // Path: src/main/java/org/bigtesting/fixd/session/PathParamSessionHandler.java // public class PathParamSessionHandler implements SessionHandler { // // public void onCreate(HttpRequest request) { // // List<NamedParameterElement> pathParams = request.getRoute().getNamedParameterElements(); // String[] pathTokens = RouteHelper.getPathElements(request.getPath()); // // for (NamedParameterElement pathParam : pathParams) { // request.getSession().set(pathParam.name(), pathTokens[pathParam.index()]); // } // } // } // // Path: src/main/java/org/bigtesting/fixd/session/Session.java // public class Session { // // private final String sessionId; // // private final Map<String, Object> values = new HashMap<String, Object>(); // // private boolean valid = true; // // public Session() { // // this.sessionId = UUID.randomUUID().toString(); // } // // public String getSessionId() { // // return sessionId; // } // // public Object get(String key) { // // return values.get(key); // } // // public void set(String key, Object value) { // // values.put(key, value); // } // // public Set<String> getAttributeNames() { // // return values.keySet(); // } // // public boolean isValid() { // // return valid; // } // // public void invalidate() { // // this.valid = false; // } // } // // Path: src/main/java/org/bigtesting/fixd/session/SessionHandler.java // public interface SessionHandler { // // void onCreate(HttpRequest request); // } // Path: src/test/java/org/bigtesting/fixd/tests/TestPathParamSessionHandler.java import static org.junit.Assert.*; import static org.mockito.Mockito.*; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.bigtesting.fixd.request.HttpRequest; import org.bigtesting.fixd.session.PathParamSessionHandler; import org.bigtesting.fixd.session.Session; import org.bigtesting.fixd.session.SessionHandler; import org.bigtesting.routd.Route; import org.junit.Test; /* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.tests; /** * * @author Luis Antunes */ public class TestPathParamSessionHandler { @Test public void onCreateIsHandled() {
HttpRequest request = mock(HttpRequest.class);
lantunes/fixd
src/test/java/org/bigtesting/fixd/tests/TestPathParamSessionHandler.java
// Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java // public interface HttpRequest { // // String getPath(); // // String getUndecodedPath(); // // Set<String> getRequestParameterNames(); // // String getRequestParameter(String name); // // String getPathParameter(String name); // // List<String> getHeaderNames(); // // String getHeaderValue(String name); // // String getBody(); // // InputStream getBodyAsStream() throws IOException; // // <T> T getBody(Class<T> type); // // long getContentLength(); // // String getContentType(); // // String getMethod(); // // long getTime(); // // String getQuery(); // // int getMajor(); // // int getMinor(); // // String getTarget(); // // /** // * @return a session, if it exists, or null if it does not // */ // Session getSession(); // // Route getRoute(); // } // // Path: src/main/java/org/bigtesting/fixd/session/PathParamSessionHandler.java // public class PathParamSessionHandler implements SessionHandler { // // public void onCreate(HttpRequest request) { // // List<NamedParameterElement> pathParams = request.getRoute().getNamedParameterElements(); // String[] pathTokens = RouteHelper.getPathElements(request.getPath()); // // for (NamedParameterElement pathParam : pathParams) { // request.getSession().set(pathParam.name(), pathTokens[pathParam.index()]); // } // } // } // // Path: src/main/java/org/bigtesting/fixd/session/Session.java // public class Session { // // private final String sessionId; // // private final Map<String, Object> values = new HashMap<String, Object>(); // // private boolean valid = true; // // public Session() { // // this.sessionId = UUID.randomUUID().toString(); // } // // public String getSessionId() { // // return sessionId; // } // // public Object get(String key) { // // return values.get(key); // } // // public void set(String key, Object value) { // // values.put(key, value); // } // // public Set<String> getAttributeNames() { // // return values.keySet(); // } // // public boolean isValid() { // // return valid; // } // // public void invalidate() { // // this.valid = false; // } // } // // Path: src/main/java/org/bigtesting/fixd/session/SessionHandler.java // public interface SessionHandler { // // void onCreate(HttpRequest request); // }
import static org.junit.Assert.*; import static org.mockito.Mockito.*; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.bigtesting.fixd.request.HttpRequest; import org.bigtesting.fixd.session.PathParamSessionHandler; import org.bigtesting.fixd.session.Session; import org.bigtesting.fixd.session.SessionHandler; import org.bigtesting.routd.Route; import org.junit.Test;
/* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.tests; /** * * @author Luis Antunes */ public class TestPathParamSessionHandler { @Test public void onCreateIsHandled() { HttpRequest request = mock(HttpRequest.class); when(request.getPath()).thenReturn("/first-name/John/last-name/Doe");
// Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java // public interface HttpRequest { // // String getPath(); // // String getUndecodedPath(); // // Set<String> getRequestParameterNames(); // // String getRequestParameter(String name); // // String getPathParameter(String name); // // List<String> getHeaderNames(); // // String getHeaderValue(String name); // // String getBody(); // // InputStream getBodyAsStream() throws IOException; // // <T> T getBody(Class<T> type); // // long getContentLength(); // // String getContentType(); // // String getMethod(); // // long getTime(); // // String getQuery(); // // int getMajor(); // // int getMinor(); // // String getTarget(); // // /** // * @return a session, if it exists, or null if it does not // */ // Session getSession(); // // Route getRoute(); // } // // Path: src/main/java/org/bigtesting/fixd/session/PathParamSessionHandler.java // public class PathParamSessionHandler implements SessionHandler { // // public void onCreate(HttpRequest request) { // // List<NamedParameterElement> pathParams = request.getRoute().getNamedParameterElements(); // String[] pathTokens = RouteHelper.getPathElements(request.getPath()); // // for (NamedParameterElement pathParam : pathParams) { // request.getSession().set(pathParam.name(), pathTokens[pathParam.index()]); // } // } // } // // Path: src/main/java/org/bigtesting/fixd/session/Session.java // public class Session { // // private final String sessionId; // // private final Map<String, Object> values = new HashMap<String, Object>(); // // private boolean valid = true; // // public Session() { // // this.sessionId = UUID.randomUUID().toString(); // } // // public String getSessionId() { // // return sessionId; // } // // public Object get(String key) { // // return values.get(key); // } // // public void set(String key, Object value) { // // values.put(key, value); // } // // public Set<String> getAttributeNames() { // // return values.keySet(); // } // // public boolean isValid() { // // return valid; // } // // public void invalidate() { // // this.valid = false; // } // } // // Path: src/main/java/org/bigtesting/fixd/session/SessionHandler.java // public interface SessionHandler { // // void onCreate(HttpRequest request); // } // Path: src/test/java/org/bigtesting/fixd/tests/TestPathParamSessionHandler.java import static org.junit.Assert.*; import static org.mockito.Mockito.*; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.bigtesting.fixd.request.HttpRequest; import org.bigtesting.fixd.session.PathParamSessionHandler; import org.bigtesting.fixd.session.Session; import org.bigtesting.fixd.session.SessionHandler; import org.bigtesting.routd.Route; import org.junit.Test; /* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.tests; /** * * @author Luis Antunes */ public class TestPathParamSessionHandler { @Test public void onCreateIsHandled() { HttpRequest request = mock(HttpRequest.class); when(request.getPath()).thenReturn("/first-name/John/last-name/Doe");
Session session = new Session();
lantunes/fixd
src/test/java/org/bigtesting/fixd/tests/TestPathParamSessionHandler.java
// Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java // public interface HttpRequest { // // String getPath(); // // String getUndecodedPath(); // // Set<String> getRequestParameterNames(); // // String getRequestParameter(String name); // // String getPathParameter(String name); // // List<String> getHeaderNames(); // // String getHeaderValue(String name); // // String getBody(); // // InputStream getBodyAsStream() throws IOException; // // <T> T getBody(Class<T> type); // // long getContentLength(); // // String getContentType(); // // String getMethod(); // // long getTime(); // // String getQuery(); // // int getMajor(); // // int getMinor(); // // String getTarget(); // // /** // * @return a session, if it exists, or null if it does not // */ // Session getSession(); // // Route getRoute(); // } // // Path: src/main/java/org/bigtesting/fixd/session/PathParamSessionHandler.java // public class PathParamSessionHandler implements SessionHandler { // // public void onCreate(HttpRequest request) { // // List<NamedParameterElement> pathParams = request.getRoute().getNamedParameterElements(); // String[] pathTokens = RouteHelper.getPathElements(request.getPath()); // // for (NamedParameterElement pathParam : pathParams) { // request.getSession().set(pathParam.name(), pathTokens[pathParam.index()]); // } // } // } // // Path: src/main/java/org/bigtesting/fixd/session/Session.java // public class Session { // // private final String sessionId; // // private final Map<String, Object> values = new HashMap<String, Object>(); // // private boolean valid = true; // // public Session() { // // this.sessionId = UUID.randomUUID().toString(); // } // // public String getSessionId() { // // return sessionId; // } // // public Object get(String key) { // // return values.get(key); // } // // public void set(String key, Object value) { // // values.put(key, value); // } // // public Set<String> getAttributeNames() { // // return values.keySet(); // } // // public boolean isValid() { // // return valid; // } // // public void invalidate() { // // this.valid = false; // } // } // // Path: src/main/java/org/bigtesting/fixd/session/SessionHandler.java // public interface SessionHandler { // // void onCreate(HttpRequest request); // }
import static org.junit.Assert.*; import static org.mockito.Mockito.*; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.bigtesting.fixd.request.HttpRequest; import org.bigtesting.fixd.session.PathParamSessionHandler; import org.bigtesting.fixd.session.Session; import org.bigtesting.fixd.session.SessionHandler; import org.bigtesting.routd.Route; import org.junit.Test;
/* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.tests; /** * * @author Luis Antunes */ public class TestPathParamSessionHandler { @Test public void onCreateIsHandled() { HttpRequest request = mock(HttpRequest.class); when(request.getPath()).thenReturn("/first-name/John/last-name/Doe"); Session session = new Session(); when(request.getSession()).thenReturn(session); Route route = new Route("/first-name/:firstName/last-name/:lastName"); when(request.getRoute()).thenReturn(route); newSessionHandler().onCreate(request); List<String> attributeNames = new ArrayList<String>(session.getAttributeNames()); Collections.sort(attributeNames); assertEquals("[firstName, lastName]", attributeNames.toString()); assertEquals("John", session.get("firstName")); assertEquals("Doe", session.get("lastName")); } @Test public void onCreateIsHandledWithNoParams() { HttpRequest request = mock(HttpRequest.class); when(request.getPath()).thenReturn("/"); Session session = new Session(); when(request.getSession()).thenReturn(session); Route route = new Route("/"); when(request.getRoute()).thenReturn(route); newSessionHandler().onCreate(request); assertEquals("[]", session.getAttributeNames().toString()); }
// Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java // public interface HttpRequest { // // String getPath(); // // String getUndecodedPath(); // // Set<String> getRequestParameterNames(); // // String getRequestParameter(String name); // // String getPathParameter(String name); // // List<String> getHeaderNames(); // // String getHeaderValue(String name); // // String getBody(); // // InputStream getBodyAsStream() throws IOException; // // <T> T getBody(Class<T> type); // // long getContentLength(); // // String getContentType(); // // String getMethod(); // // long getTime(); // // String getQuery(); // // int getMajor(); // // int getMinor(); // // String getTarget(); // // /** // * @return a session, if it exists, or null if it does not // */ // Session getSession(); // // Route getRoute(); // } // // Path: src/main/java/org/bigtesting/fixd/session/PathParamSessionHandler.java // public class PathParamSessionHandler implements SessionHandler { // // public void onCreate(HttpRequest request) { // // List<NamedParameterElement> pathParams = request.getRoute().getNamedParameterElements(); // String[] pathTokens = RouteHelper.getPathElements(request.getPath()); // // for (NamedParameterElement pathParam : pathParams) { // request.getSession().set(pathParam.name(), pathTokens[pathParam.index()]); // } // } // } // // Path: src/main/java/org/bigtesting/fixd/session/Session.java // public class Session { // // private final String sessionId; // // private final Map<String, Object> values = new HashMap<String, Object>(); // // private boolean valid = true; // // public Session() { // // this.sessionId = UUID.randomUUID().toString(); // } // // public String getSessionId() { // // return sessionId; // } // // public Object get(String key) { // // return values.get(key); // } // // public void set(String key, Object value) { // // values.put(key, value); // } // // public Set<String> getAttributeNames() { // // return values.keySet(); // } // // public boolean isValid() { // // return valid; // } // // public void invalidate() { // // this.valid = false; // } // } // // Path: src/main/java/org/bigtesting/fixd/session/SessionHandler.java // public interface SessionHandler { // // void onCreate(HttpRequest request); // } // Path: src/test/java/org/bigtesting/fixd/tests/TestPathParamSessionHandler.java import static org.junit.Assert.*; import static org.mockito.Mockito.*; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.bigtesting.fixd.request.HttpRequest; import org.bigtesting.fixd.session.PathParamSessionHandler; import org.bigtesting.fixd.session.Session; import org.bigtesting.fixd.session.SessionHandler; import org.bigtesting.routd.Route; import org.junit.Test; /* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.tests; /** * * @author Luis Antunes */ public class TestPathParamSessionHandler { @Test public void onCreateIsHandled() { HttpRequest request = mock(HttpRequest.class); when(request.getPath()).thenReturn("/first-name/John/last-name/Doe"); Session session = new Session(); when(request.getSession()).thenReturn(session); Route route = new Route("/first-name/:firstName/last-name/:lastName"); when(request.getRoute()).thenReturn(route); newSessionHandler().onCreate(request); List<String> attributeNames = new ArrayList<String>(session.getAttributeNames()); Collections.sort(attributeNames); assertEquals("[firstName, lastName]", attributeNames.toString()); assertEquals("John", session.get("firstName")); assertEquals("Doe", session.get("lastName")); } @Test public void onCreateIsHandledWithNoParams() { HttpRequest request = mock(HttpRequest.class); when(request.getPath()).thenReturn("/"); Session session = new Session(); when(request.getSession()).thenReturn(session); Route route = new Route("/"); when(request.getRoute()).thenReturn(route); newSessionHandler().onCreate(request); assertEquals("[]", session.getAttributeNames().toString()); }
private SessionHandler newSessionHandler() {
lantunes/fixd
src/test/java/org/bigtesting/fixd/tests/TestPathParamSessionHandler.java
// Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java // public interface HttpRequest { // // String getPath(); // // String getUndecodedPath(); // // Set<String> getRequestParameterNames(); // // String getRequestParameter(String name); // // String getPathParameter(String name); // // List<String> getHeaderNames(); // // String getHeaderValue(String name); // // String getBody(); // // InputStream getBodyAsStream() throws IOException; // // <T> T getBody(Class<T> type); // // long getContentLength(); // // String getContentType(); // // String getMethod(); // // long getTime(); // // String getQuery(); // // int getMajor(); // // int getMinor(); // // String getTarget(); // // /** // * @return a session, if it exists, or null if it does not // */ // Session getSession(); // // Route getRoute(); // } // // Path: src/main/java/org/bigtesting/fixd/session/PathParamSessionHandler.java // public class PathParamSessionHandler implements SessionHandler { // // public void onCreate(HttpRequest request) { // // List<NamedParameterElement> pathParams = request.getRoute().getNamedParameterElements(); // String[] pathTokens = RouteHelper.getPathElements(request.getPath()); // // for (NamedParameterElement pathParam : pathParams) { // request.getSession().set(pathParam.name(), pathTokens[pathParam.index()]); // } // } // } // // Path: src/main/java/org/bigtesting/fixd/session/Session.java // public class Session { // // private final String sessionId; // // private final Map<String, Object> values = new HashMap<String, Object>(); // // private boolean valid = true; // // public Session() { // // this.sessionId = UUID.randomUUID().toString(); // } // // public String getSessionId() { // // return sessionId; // } // // public Object get(String key) { // // return values.get(key); // } // // public void set(String key, Object value) { // // values.put(key, value); // } // // public Set<String> getAttributeNames() { // // return values.keySet(); // } // // public boolean isValid() { // // return valid; // } // // public void invalidate() { // // this.valid = false; // } // } // // Path: src/main/java/org/bigtesting/fixd/session/SessionHandler.java // public interface SessionHandler { // // void onCreate(HttpRequest request); // }
import static org.junit.Assert.*; import static org.mockito.Mockito.*; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.bigtesting.fixd.request.HttpRequest; import org.bigtesting.fixd.session.PathParamSessionHandler; import org.bigtesting.fixd.session.Session; import org.bigtesting.fixd.session.SessionHandler; import org.bigtesting.routd.Route; import org.junit.Test;
/* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.tests; /** * * @author Luis Antunes */ public class TestPathParamSessionHandler { @Test public void onCreateIsHandled() { HttpRequest request = mock(HttpRequest.class); when(request.getPath()).thenReturn("/first-name/John/last-name/Doe"); Session session = new Session(); when(request.getSession()).thenReturn(session); Route route = new Route("/first-name/:firstName/last-name/:lastName"); when(request.getRoute()).thenReturn(route); newSessionHandler().onCreate(request); List<String> attributeNames = new ArrayList<String>(session.getAttributeNames()); Collections.sort(attributeNames); assertEquals("[firstName, lastName]", attributeNames.toString()); assertEquals("John", session.get("firstName")); assertEquals("Doe", session.get("lastName")); } @Test public void onCreateIsHandledWithNoParams() { HttpRequest request = mock(HttpRequest.class); when(request.getPath()).thenReturn("/"); Session session = new Session(); when(request.getSession()).thenReturn(session); Route route = new Route("/"); when(request.getRoute()).thenReturn(route); newSessionHandler().onCreate(request); assertEquals("[]", session.getAttributeNames().toString()); } private SessionHandler newSessionHandler() {
// Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java // public interface HttpRequest { // // String getPath(); // // String getUndecodedPath(); // // Set<String> getRequestParameterNames(); // // String getRequestParameter(String name); // // String getPathParameter(String name); // // List<String> getHeaderNames(); // // String getHeaderValue(String name); // // String getBody(); // // InputStream getBodyAsStream() throws IOException; // // <T> T getBody(Class<T> type); // // long getContentLength(); // // String getContentType(); // // String getMethod(); // // long getTime(); // // String getQuery(); // // int getMajor(); // // int getMinor(); // // String getTarget(); // // /** // * @return a session, if it exists, or null if it does not // */ // Session getSession(); // // Route getRoute(); // } // // Path: src/main/java/org/bigtesting/fixd/session/PathParamSessionHandler.java // public class PathParamSessionHandler implements SessionHandler { // // public void onCreate(HttpRequest request) { // // List<NamedParameterElement> pathParams = request.getRoute().getNamedParameterElements(); // String[] pathTokens = RouteHelper.getPathElements(request.getPath()); // // for (NamedParameterElement pathParam : pathParams) { // request.getSession().set(pathParam.name(), pathTokens[pathParam.index()]); // } // } // } // // Path: src/main/java/org/bigtesting/fixd/session/Session.java // public class Session { // // private final String sessionId; // // private final Map<String, Object> values = new HashMap<String, Object>(); // // private boolean valid = true; // // public Session() { // // this.sessionId = UUID.randomUUID().toString(); // } // // public String getSessionId() { // // return sessionId; // } // // public Object get(String key) { // // return values.get(key); // } // // public void set(String key, Object value) { // // values.put(key, value); // } // // public Set<String> getAttributeNames() { // // return values.keySet(); // } // // public boolean isValid() { // // return valid; // } // // public void invalidate() { // // this.valid = false; // } // } // // Path: src/main/java/org/bigtesting/fixd/session/SessionHandler.java // public interface SessionHandler { // // void onCreate(HttpRequest request); // } // Path: src/test/java/org/bigtesting/fixd/tests/TestPathParamSessionHandler.java import static org.junit.Assert.*; import static org.mockito.Mockito.*; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.bigtesting.fixd.request.HttpRequest; import org.bigtesting.fixd.session.PathParamSessionHandler; import org.bigtesting.fixd.session.Session; import org.bigtesting.fixd.session.SessionHandler; import org.bigtesting.routd.Route; import org.junit.Test; /* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.tests; /** * * @author Luis Antunes */ public class TestPathParamSessionHandler { @Test public void onCreateIsHandled() { HttpRequest request = mock(HttpRequest.class); when(request.getPath()).thenReturn("/first-name/John/last-name/Doe"); Session session = new Session(); when(request.getSession()).thenReturn(session); Route route = new Route("/first-name/:firstName/last-name/:lastName"); when(request.getRoute()).thenReturn(route); newSessionHandler().onCreate(request); List<String> attributeNames = new ArrayList<String>(session.getAttributeNames()); Collections.sort(attributeNames); assertEquals("[firstName, lastName]", attributeNames.toString()); assertEquals("John", session.get("firstName")); assertEquals("Doe", session.get("lastName")); } @Test public void onCreateIsHandledWithNoParams() { HttpRequest request = mock(HttpRequest.class); when(request.getPath()).thenReturn("/"); Session session = new Session(); when(request.getSession()).thenReturn(session); Route route = new Route("/"); when(request.getRoute()).thenReturn(route); newSessionHandler().onCreate(request); assertEquals("[]", session.getAttributeNames().toString()); } private SessionHandler newSessionHandler() {
return new PathParamSessionHandler();
lantunes/fixd
src/main/java/org/bigtesting/fixd/core/RequestMarshallerImpl.java
// Path: src/main/java/org/bigtesting/fixd/RequestMarshaller.java // public interface RequestMarshaller { // // void with(Marshaller marshaller); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/Marshaller.java // public interface Marshaller { // // InputStream marshal(Object entity); // }
import org.bigtesting.fixd.RequestMarshaller; import org.bigtesting.fixd.marshalling.Marshaller;
/* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.core; /** * * @author Luis Antunes */ public class RequestMarshallerImpl implements RequestMarshaller { private final String contentType;
// Path: src/main/java/org/bigtesting/fixd/RequestMarshaller.java // public interface RequestMarshaller { // // void with(Marshaller marshaller); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/Marshaller.java // public interface Marshaller { // // InputStream marshal(Object entity); // } // Path: src/main/java/org/bigtesting/fixd/core/RequestMarshallerImpl.java import org.bigtesting.fixd.RequestMarshaller; import org.bigtesting.fixd.marshalling.Marshaller; /* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.core; /** * * @author Luis Antunes */ public class RequestMarshallerImpl implements RequestMarshaller { private final String contentType;
private Marshaller marshaller;
lantunes/fixd
src/main/java/org/bigtesting/fixd/request/HttpRequest.java
// Path: src/main/java/org/bigtesting/fixd/session/Session.java // public class Session { // // private final String sessionId; // // private final Map<String, Object> values = new HashMap<String, Object>(); // // private boolean valid = true; // // public Session() { // // this.sessionId = UUID.randomUUID().toString(); // } // // public String getSessionId() { // // return sessionId; // } // // public Object get(String key) { // // return values.get(key); // } // // public void set(String key, Object value) { // // values.put(key, value); // } // // public Set<String> getAttributeNames() { // // return values.keySet(); // } // // public boolean isValid() { // // return valid; // } // // public void invalidate() { // // this.valid = false; // } // }
import java.io.IOException; import java.io.InputStream; import java.util.List; import java.util.Set; import org.bigtesting.fixd.session.Session; import org.bigtesting.routd.Route;
/* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.request; /** * * @author Luis Antunes */ public interface HttpRequest { String getPath(); String getUndecodedPath(); Set<String> getRequestParameterNames(); String getRequestParameter(String name); String getPathParameter(String name); List<String> getHeaderNames(); String getHeaderValue(String name); String getBody(); InputStream getBodyAsStream() throws IOException; <T> T getBody(Class<T> type); long getContentLength(); String getContentType(); String getMethod(); long getTime(); String getQuery(); int getMajor(); int getMinor(); String getTarget(); /** * @return a session, if it exists, or null if it does not */
// Path: src/main/java/org/bigtesting/fixd/session/Session.java // public class Session { // // private final String sessionId; // // private final Map<String, Object> values = new HashMap<String, Object>(); // // private boolean valid = true; // // public Session() { // // this.sessionId = UUID.randomUUID().toString(); // } // // public String getSessionId() { // // return sessionId; // } // // public Object get(String key) { // // return values.get(key); // } // // public void set(String key, Object value) { // // values.put(key, value); // } // // public Set<String> getAttributeNames() { // // return values.keySet(); // } // // public boolean isValid() { // // return valid; // } // // public void invalidate() { // // this.valid = false; // } // } // Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java import java.io.IOException; import java.io.InputStream; import java.util.List; import java.util.Set; import org.bigtesting.fixd.session.Session; import org.bigtesting.routd.Route; /* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.request; /** * * @author Luis Antunes */ public interface HttpRequest { String getPath(); String getUndecodedPath(); Set<String> getRequestParameterNames(); String getRequestParameter(String name); String getPathParameter(String name); List<String> getHeaderNames(); String getHeaderValue(String name); String getBody(); InputStream getBodyAsStream() throws IOException; <T> T getBody(Class<T> type); long getContentLength(); String getContentType(); String getMethod(); long getTime(); String getQuery(); int getMajor(); int getMinor(); String getTarget(); /** * @return a session, if it exists, or null if it does not */
Session getSession();
lantunes/fixd
src/test/java/org/bigtesting/fixd/tests/TestCapturedRequest.java
// Path: src/main/java/org/bigtesting/fixd/Method.java // public enum Method { // // GET, POST, PUT, TRACE, OPTIONS, HEAD, DELETE // } // // Path: src/main/java/org/bigtesting/fixd/ServerFixture.java // public class ServerFixture { // // private final int port; // private final FixtureContainer container; // // private Server server; // private Connection connection; // private InetSocketAddress actualConnectionAddress; // // /** // * Constructs a ServerFixture with the port chosen automatically. // * The actual port used can be obtained from the {@link #getPort() getPort} method. // */ // public ServerFixture() { // this(0); // } // // public ServerFixture(int port) { // // this.port = port; // this.container = new FixtureContainer(); // } // // public ServerFixture(int port, int aysncThreadPoolSize) { // // this.port = port; // this.container = new FixtureContainer(aysncThreadPoolSize); // } // // public void start() throws IOException { // // server = new FixdServer(new ContainerServer(container)); // connection = new SocketConnection(server, new LoggingAgent()); // SocketAddress address = new InetSocketAddress(port); // // actualConnectionAddress = (InetSocketAddress)connection.connect(address); // } // // public void stop() throws IOException { // // if (connection == null || server == null) { // throw new IllegalStateException("server has not been started"); // } // container.stop(); // connection.close(); // server.stop(); // } // // public int getPort() { // // if (actualConnectionAddress == null) { // throw new IllegalStateException("server has not been started"); // } // return actualConnectionAddress.getPort(); // } // // public RequestHandler handle(Method method, String resource) { // // RequestHandlerImpl handler = new RequestHandlerImpl(container); // container.addHandler(handler, method, resource); // return handler; // } // // public RequestHandler handle(Method method, String resource, String contentType) { // // RequestHandlerImpl handler = new RequestHandlerImpl(container); // container.addHandler(handler, method, resource, contentType); // return handler; // } // // public Collection<CapturedRequest> capturedRequests() { // // return container.getCapturedRequests(); // } // // public CapturedRequest request() { // // return container.nextCapturedRequest(); // } // // public void setMaxCapturedRequests(int limit) { // // container.setCapturedRequestLimit(limit); // } // // public RequestMarshaller marshal(String contentType) { // // RequestMarshallerImpl marshaller = new RequestMarshallerImpl(contentType); // container.addContentMarshaller(contentType, marshaller); // return marshaller; // } // // public RequestUnmarshaller unmarshal(String contentType) { // // RequestUnmarshallerImpl marshaller = new RequestUnmarshallerImpl(contentType); // container.addContentUnmarshaller(contentType, marshaller); // return marshaller; // } // } // // Path: src/main/java/org/bigtesting/fixd/capture/CapturedRequest.java // public interface CapturedRequest { // // String getPath(); // // String getRequestLine(); // // String getMethod(); // // List<String> getHeaders(); // // byte[] getBody(); // // String getBody(String encoding); // // /** // * Returns true if this request was broadcast to any subscribers. // */ // boolean isBroadcast(); // }
import static org.junit.Assert.*; import org.bigtesting.fixd.Method; import org.bigtesting.fixd.ServerFixture; import org.bigtesting.fixd.capture.CapturedRequest; import org.junit.After; import org.junit.Before; import org.junit.Test; import com.ning.http.client.AsyncHttpClient;
/* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.tests; /** * * @author Luis Antunes */ public class TestCapturedRequest { private ServerFixture server; private AsyncHttpClient client; @Before public void beforeEachTest() throws Exception { server = new ServerFixture(8080); server.start(); client = new AsyncHttpClient(); } @Test public void testGetPath_Root() throws Exception {
// Path: src/main/java/org/bigtesting/fixd/Method.java // public enum Method { // // GET, POST, PUT, TRACE, OPTIONS, HEAD, DELETE // } // // Path: src/main/java/org/bigtesting/fixd/ServerFixture.java // public class ServerFixture { // // private final int port; // private final FixtureContainer container; // // private Server server; // private Connection connection; // private InetSocketAddress actualConnectionAddress; // // /** // * Constructs a ServerFixture with the port chosen automatically. // * The actual port used can be obtained from the {@link #getPort() getPort} method. // */ // public ServerFixture() { // this(0); // } // // public ServerFixture(int port) { // // this.port = port; // this.container = new FixtureContainer(); // } // // public ServerFixture(int port, int aysncThreadPoolSize) { // // this.port = port; // this.container = new FixtureContainer(aysncThreadPoolSize); // } // // public void start() throws IOException { // // server = new FixdServer(new ContainerServer(container)); // connection = new SocketConnection(server, new LoggingAgent()); // SocketAddress address = new InetSocketAddress(port); // // actualConnectionAddress = (InetSocketAddress)connection.connect(address); // } // // public void stop() throws IOException { // // if (connection == null || server == null) { // throw new IllegalStateException("server has not been started"); // } // container.stop(); // connection.close(); // server.stop(); // } // // public int getPort() { // // if (actualConnectionAddress == null) { // throw new IllegalStateException("server has not been started"); // } // return actualConnectionAddress.getPort(); // } // // public RequestHandler handle(Method method, String resource) { // // RequestHandlerImpl handler = new RequestHandlerImpl(container); // container.addHandler(handler, method, resource); // return handler; // } // // public RequestHandler handle(Method method, String resource, String contentType) { // // RequestHandlerImpl handler = new RequestHandlerImpl(container); // container.addHandler(handler, method, resource, contentType); // return handler; // } // // public Collection<CapturedRequest> capturedRequests() { // // return container.getCapturedRequests(); // } // // public CapturedRequest request() { // // return container.nextCapturedRequest(); // } // // public void setMaxCapturedRequests(int limit) { // // container.setCapturedRequestLimit(limit); // } // // public RequestMarshaller marshal(String contentType) { // // RequestMarshallerImpl marshaller = new RequestMarshallerImpl(contentType); // container.addContentMarshaller(contentType, marshaller); // return marshaller; // } // // public RequestUnmarshaller unmarshal(String contentType) { // // RequestUnmarshallerImpl marshaller = new RequestUnmarshallerImpl(contentType); // container.addContentUnmarshaller(contentType, marshaller); // return marshaller; // } // } // // Path: src/main/java/org/bigtesting/fixd/capture/CapturedRequest.java // public interface CapturedRequest { // // String getPath(); // // String getRequestLine(); // // String getMethod(); // // List<String> getHeaders(); // // byte[] getBody(); // // String getBody(String encoding); // // /** // * Returns true if this request was broadcast to any subscribers. // */ // boolean isBroadcast(); // } // Path: src/test/java/org/bigtesting/fixd/tests/TestCapturedRequest.java import static org.junit.Assert.*; import org.bigtesting.fixd.Method; import org.bigtesting.fixd.ServerFixture; import org.bigtesting.fixd.capture.CapturedRequest; import org.junit.After; import org.junit.Before; import org.junit.Test; import com.ning.http.client.AsyncHttpClient; /* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.tests; /** * * @author Luis Antunes */ public class TestCapturedRequest { private ServerFixture server; private AsyncHttpClient client; @Before public void beforeEachTest() throws Exception { server = new ServerFixture(8080); server.start(); client = new AsyncHttpClient(); } @Test public void testGetPath_Root() throws Exception {
server.handle(Method.GET, "/")
lantunes/fixd
src/test/java/org/bigtesting/fixd/tests/TestCapturedRequest.java
// Path: src/main/java/org/bigtesting/fixd/Method.java // public enum Method { // // GET, POST, PUT, TRACE, OPTIONS, HEAD, DELETE // } // // Path: src/main/java/org/bigtesting/fixd/ServerFixture.java // public class ServerFixture { // // private final int port; // private final FixtureContainer container; // // private Server server; // private Connection connection; // private InetSocketAddress actualConnectionAddress; // // /** // * Constructs a ServerFixture with the port chosen automatically. // * The actual port used can be obtained from the {@link #getPort() getPort} method. // */ // public ServerFixture() { // this(0); // } // // public ServerFixture(int port) { // // this.port = port; // this.container = new FixtureContainer(); // } // // public ServerFixture(int port, int aysncThreadPoolSize) { // // this.port = port; // this.container = new FixtureContainer(aysncThreadPoolSize); // } // // public void start() throws IOException { // // server = new FixdServer(new ContainerServer(container)); // connection = new SocketConnection(server, new LoggingAgent()); // SocketAddress address = new InetSocketAddress(port); // // actualConnectionAddress = (InetSocketAddress)connection.connect(address); // } // // public void stop() throws IOException { // // if (connection == null || server == null) { // throw new IllegalStateException("server has not been started"); // } // container.stop(); // connection.close(); // server.stop(); // } // // public int getPort() { // // if (actualConnectionAddress == null) { // throw new IllegalStateException("server has not been started"); // } // return actualConnectionAddress.getPort(); // } // // public RequestHandler handle(Method method, String resource) { // // RequestHandlerImpl handler = new RequestHandlerImpl(container); // container.addHandler(handler, method, resource); // return handler; // } // // public RequestHandler handle(Method method, String resource, String contentType) { // // RequestHandlerImpl handler = new RequestHandlerImpl(container); // container.addHandler(handler, method, resource, contentType); // return handler; // } // // public Collection<CapturedRequest> capturedRequests() { // // return container.getCapturedRequests(); // } // // public CapturedRequest request() { // // return container.nextCapturedRequest(); // } // // public void setMaxCapturedRequests(int limit) { // // container.setCapturedRequestLimit(limit); // } // // public RequestMarshaller marshal(String contentType) { // // RequestMarshallerImpl marshaller = new RequestMarshallerImpl(contentType); // container.addContentMarshaller(contentType, marshaller); // return marshaller; // } // // public RequestUnmarshaller unmarshal(String contentType) { // // RequestUnmarshallerImpl marshaller = new RequestUnmarshallerImpl(contentType); // container.addContentUnmarshaller(contentType, marshaller); // return marshaller; // } // } // // Path: src/main/java/org/bigtesting/fixd/capture/CapturedRequest.java // public interface CapturedRequest { // // String getPath(); // // String getRequestLine(); // // String getMethod(); // // List<String> getHeaders(); // // byte[] getBody(); // // String getBody(String encoding); // // /** // * Returns true if this request was broadcast to any subscribers. // */ // boolean isBroadcast(); // }
import static org.junit.Assert.*; import org.bigtesting.fixd.Method; import org.bigtesting.fixd.ServerFixture; import org.bigtesting.fixd.capture.CapturedRequest; import org.junit.After; import org.junit.Before; import org.junit.Test; import com.ning.http.client.AsyncHttpClient;
/* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.tests; /** * * @author Luis Antunes */ public class TestCapturedRequest { private ServerFixture server; private AsyncHttpClient client; @Before public void beforeEachTest() throws Exception { server = new ServerFixture(8080); server.start(); client = new AsyncHttpClient(); } @Test public void testGetPath_Root() throws Exception { server.handle(Method.GET, "/") .with(200, "text/plain", "Hello"); client.prepareGet("http://localhost:8080/").execute().get();
// Path: src/main/java/org/bigtesting/fixd/Method.java // public enum Method { // // GET, POST, PUT, TRACE, OPTIONS, HEAD, DELETE // } // // Path: src/main/java/org/bigtesting/fixd/ServerFixture.java // public class ServerFixture { // // private final int port; // private final FixtureContainer container; // // private Server server; // private Connection connection; // private InetSocketAddress actualConnectionAddress; // // /** // * Constructs a ServerFixture with the port chosen automatically. // * The actual port used can be obtained from the {@link #getPort() getPort} method. // */ // public ServerFixture() { // this(0); // } // // public ServerFixture(int port) { // // this.port = port; // this.container = new FixtureContainer(); // } // // public ServerFixture(int port, int aysncThreadPoolSize) { // // this.port = port; // this.container = new FixtureContainer(aysncThreadPoolSize); // } // // public void start() throws IOException { // // server = new FixdServer(new ContainerServer(container)); // connection = new SocketConnection(server, new LoggingAgent()); // SocketAddress address = new InetSocketAddress(port); // // actualConnectionAddress = (InetSocketAddress)connection.connect(address); // } // // public void stop() throws IOException { // // if (connection == null || server == null) { // throw new IllegalStateException("server has not been started"); // } // container.stop(); // connection.close(); // server.stop(); // } // // public int getPort() { // // if (actualConnectionAddress == null) { // throw new IllegalStateException("server has not been started"); // } // return actualConnectionAddress.getPort(); // } // // public RequestHandler handle(Method method, String resource) { // // RequestHandlerImpl handler = new RequestHandlerImpl(container); // container.addHandler(handler, method, resource); // return handler; // } // // public RequestHandler handle(Method method, String resource, String contentType) { // // RequestHandlerImpl handler = new RequestHandlerImpl(container); // container.addHandler(handler, method, resource, contentType); // return handler; // } // // public Collection<CapturedRequest> capturedRequests() { // // return container.getCapturedRequests(); // } // // public CapturedRequest request() { // // return container.nextCapturedRequest(); // } // // public void setMaxCapturedRequests(int limit) { // // container.setCapturedRequestLimit(limit); // } // // public RequestMarshaller marshal(String contentType) { // // RequestMarshallerImpl marshaller = new RequestMarshallerImpl(contentType); // container.addContentMarshaller(contentType, marshaller); // return marshaller; // } // // public RequestUnmarshaller unmarshal(String contentType) { // // RequestUnmarshallerImpl marshaller = new RequestUnmarshallerImpl(contentType); // container.addContentUnmarshaller(contentType, marshaller); // return marshaller; // } // } // // Path: src/main/java/org/bigtesting/fixd/capture/CapturedRequest.java // public interface CapturedRequest { // // String getPath(); // // String getRequestLine(); // // String getMethod(); // // List<String> getHeaders(); // // byte[] getBody(); // // String getBody(String encoding); // // /** // * Returns true if this request was broadcast to any subscribers. // */ // boolean isBroadcast(); // } // Path: src/test/java/org/bigtesting/fixd/tests/TestCapturedRequest.java import static org.junit.Assert.*; import org.bigtesting.fixd.Method; import org.bigtesting.fixd.ServerFixture; import org.bigtesting.fixd.capture.CapturedRequest; import org.junit.After; import org.junit.Before; import org.junit.Test; import com.ning.http.client.AsyncHttpClient; /* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.tests; /** * * @author Luis Antunes */ public class TestCapturedRequest { private ServerFixture server; private AsyncHttpClient client; @Before public void beforeEachTest() throws Exception { server = new ServerFixture(8080); server.start(); client = new AsyncHttpClient(); } @Test public void testGetPath_Root() throws Exception { server.handle(Method.GET, "/") .with(200, "text/plain", "Hello"); client.prepareGet("http://localhost:8080/").execute().get();
CapturedRequest captured = server.request();
lantunes/fixd
src/main/java/org/bigtesting/fixd/request/impl/SimpleHttpRequest.java
// Path: src/main/java/org/bigtesting/fixd/marshalling/Unmarshaller.java // public interface Unmarshaller { // // <T> T unmarshal(InputStream in, Class<T> type); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/UnmarshallerProvider.java // public interface UnmarshallerProvider { // // /** // * // * Returns the Unmarshaller for the given content-type, // * or null if there is no Unmarshaller for the given // * content-type. // * // * @param contentType // * @return the Unmarshaller for the given content-type, or // * null if there is no Unmarshaller for the given // * content-type // */ // Unmarshaller getUnmarshaller(String contentType); // } // // Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java // public interface HttpRequest { // // String getPath(); // // String getUndecodedPath(); // // Set<String> getRequestParameterNames(); // // String getRequestParameter(String name); // // String getPathParameter(String name); // // List<String> getHeaderNames(); // // String getHeaderValue(String name); // // String getBody(); // // InputStream getBodyAsStream() throws IOException; // // <T> T getBody(Class<T> type); // // long getContentLength(); // // String getContentType(); // // String getMethod(); // // long getTime(); // // String getQuery(); // // int getMajor(); // // int getMinor(); // // String getTarget(); // // /** // * @return a session, if it exists, or null if it does not // */ // Session getSession(); // // Route getRoute(); // } // // Path: src/main/java/org/bigtesting/fixd/session/Session.java // public class Session { // // private final String sessionId; // // private final Map<String, Object> values = new HashMap<String, Object>(); // // private boolean valid = true; // // public Session() { // // this.sessionId = UUID.randomUUID().toString(); // } // // public String getSessionId() { // // return sessionId; // } // // public Object get(String key) { // // return values.get(key); // } // // public void set(String key, Object value) { // // values.put(key, value); // } // // public Set<String> getAttributeNames() { // // return values.keySet(); // } // // public boolean isValid() { // // return valid; // } // // public void invalidate() { // // this.valid = false; // } // } // // Path: src/main/java/org/bigtesting/fixd/util/RequestUtils.java // public class RequestUtils { // // public static byte[] readBody(InputStream in) { // // ByteArrayOutputStream out = new ByteArrayOutputStream(); // try { // // byte[] buffer = new byte[1024]; // int len = 0; // while ((len = in.read(buffer)) != -1) { // out.write(buffer, 0, len); // } // // } catch (IOException e) { // throw new RuntimeException("error getting body", e); // } finally { // if (in != null) try {in.close();} catch (IOException e2) {} // } // // return out.toByteArray(); // } // // public static String getUndecodedPath(Request request) { // // String path = request.getTarget(); // int queryIndex = path.indexOf('?'); // if (queryIndex != -1) { // path = path.substring(0, queryIndex); // } // return path; // } // }
import java.io.IOException; import java.io.InputStream; import java.util.List; import java.util.Set; import org.bigtesting.fixd.marshalling.Unmarshaller; import org.bigtesting.fixd.marshalling.UnmarshallerProvider; import org.bigtesting.fixd.request.HttpRequest; import org.bigtesting.fixd.session.Session; import org.bigtesting.fixd.util.RequestUtils; import org.bigtesting.routd.Route; import org.simpleframework.http.Request;
/* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.request.impl; /** * * @author Luis Antunes */ public class SimpleHttpRequest implements HttpRequest { private final Request request;
// Path: src/main/java/org/bigtesting/fixd/marshalling/Unmarshaller.java // public interface Unmarshaller { // // <T> T unmarshal(InputStream in, Class<T> type); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/UnmarshallerProvider.java // public interface UnmarshallerProvider { // // /** // * // * Returns the Unmarshaller for the given content-type, // * or null if there is no Unmarshaller for the given // * content-type. // * // * @param contentType // * @return the Unmarshaller for the given content-type, or // * null if there is no Unmarshaller for the given // * content-type // */ // Unmarshaller getUnmarshaller(String contentType); // } // // Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java // public interface HttpRequest { // // String getPath(); // // String getUndecodedPath(); // // Set<String> getRequestParameterNames(); // // String getRequestParameter(String name); // // String getPathParameter(String name); // // List<String> getHeaderNames(); // // String getHeaderValue(String name); // // String getBody(); // // InputStream getBodyAsStream() throws IOException; // // <T> T getBody(Class<T> type); // // long getContentLength(); // // String getContentType(); // // String getMethod(); // // long getTime(); // // String getQuery(); // // int getMajor(); // // int getMinor(); // // String getTarget(); // // /** // * @return a session, if it exists, or null if it does not // */ // Session getSession(); // // Route getRoute(); // } // // Path: src/main/java/org/bigtesting/fixd/session/Session.java // public class Session { // // private final String sessionId; // // private final Map<String, Object> values = new HashMap<String, Object>(); // // private boolean valid = true; // // public Session() { // // this.sessionId = UUID.randomUUID().toString(); // } // // public String getSessionId() { // // return sessionId; // } // // public Object get(String key) { // // return values.get(key); // } // // public void set(String key, Object value) { // // values.put(key, value); // } // // public Set<String> getAttributeNames() { // // return values.keySet(); // } // // public boolean isValid() { // // return valid; // } // // public void invalidate() { // // this.valid = false; // } // } // // Path: src/main/java/org/bigtesting/fixd/util/RequestUtils.java // public class RequestUtils { // // public static byte[] readBody(InputStream in) { // // ByteArrayOutputStream out = new ByteArrayOutputStream(); // try { // // byte[] buffer = new byte[1024]; // int len = 0; // while ((len = in.read(buffer)) != -1) { // out.write(buffer, 0, len); // } // // } catch (IOException e) { // throw new RuntimeException("error getting body", e); // } finally { // if (in != null) try {in.close();} catch (IOException e2) {} // } // // return out.toByteArray(); // } // // public static String getUndecodedPath(Request request) { // // String path = request.getTarget(); // int queryIndex = path.indexOf('?'); // if (queryIndex != -1) { // path = path.substring(0, queryIndex); // } // return path; // } // } // Path: src/main/java/org/bigtesting/fixd/request/impl/SimpleHttpRequest.java import java.io.IOException; import java.io.InputStream; import java.util.List; import java.util.Set; import org.bigtesting.fixd.marshalling.Unmarshaller; import org.bigtesting.fixd.marshalling.UnmarshallerProvider; import org.bigtesting.fixd.request.HttpRequest; import org.bigtesting.fixd.session.Session; import org.bigtesting.fixd.util.RequestUtils; import org.bigtesting.routd.Route; import org.simpleframework.http.Request; /* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.request.impl; /** * * @author Luis Antunes */ public class SimpleHttpRequest implements HttpRequest { private final Request request;
private final Session session;
lantunes/fixd
src/main/java/org/bigtesting/fixd/request/impl/SimpleHttpRequest.java
// Path: src/main/java/org/bigtesting/fixd/marshalling/Unmarshaller.java // public interface Unmarshaller { // // <T> T unmarshal(InputStream in, Class<T> type); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/UnmarshallerProvider.java // public interface UnmarshallerProvider { // // /** // * // * Returns the Unmarshaller for the given content-type, // * or null if there is no Unmarshaller for the given // * content-type. // * // * @param contentType // * @return the Unmarshaller for the given content-type, or // * null if there is no Unmarshaller for the given // * content-type // */ // Unmarshaller getUnmarshaller(String contentType); // } // // Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java // public interface HttpRequest { // // String getPath(); // // String getUndecodedPath(); // // Set<String> getRequestParameterNames(); // // String getRequestParameter(String name); // // String getPathParameter(String name); // // List<String> getHeaderNames(); // // String getHeaderValue(String name); // // String getBody(); // // InputStream getBodyAsStream() throws IOException; // // <T> T getBody(Class<T> type); // // long getContentLength(); // // String getContentType(); // // String getMethod(); // // long getTime(); // // String getQuery(); // // int getMajor(); // // int getMinor(); // // String getTarget(); // // /** // * @return a session, if it exists, or null if it does not // */ // Session getSession(); // // Route getRoute(); // } // // Path: src/main/java/org/bigtesting/fixd/session/Session.java // public class Session { // // private final String sessionId; // // private final Map<String, Object> values = new HashMap<String, Object>(); // // private boolean valid = true; // // public Session() { // // this.sessionId = UUID.randomUUID().toString(); // } // // public String getSessionId() { // // return sessionId; // } // // public Object get(String key) { // // return values.get(key); // } // // public void set(String key, Object value) { // // values.put(key, value); // } // // public Set<String> getAttributeNames() { // // return values.keySet(); // } // // public boolean isValid() { // // return valid; // } // // public void invalidate() { // // this.valid = false; // } // } // // Path: src/main/java/org/bigtesting/fixd/util/RequestUtils.java // public class RequestUtils { // // public static byte[] readBody(InputStream in) { // // ByteArrayOutputStream out = new ByteArrayOutputStream(); // try { // // byte[] buffer = new byte[1024]; // int len = 0; // while ((len = in.read(buffer)) != -1) { // out.write(buffer, 0, len); // } // // } catch (IOException e) { // throw new RuntimeException("error getting body", e); // } finally { // if (in != null) try {in.close();} catch (IOException e2) {} // } // // return out.toByteArray(); // } // // public static String getUndecodedPath(Request request) { // // String path = request.getTarget(); // int queryIndex = path.indexOf('?'); // if (queryIndex != -1) { // path = path.substring(0, queryIndex); // } // return path; // } // }
import java.io.IOException; import java.io.InputStream; import java.util.List; import java.util.Set; import org.bigtesting.fixd.marshalling.Unmarshaller; import org.bigtesting.fixd.marshalling.UnmarshallerProvider; import org.bigtesting.fixd.request.HttpRequest; import org.bigtesting.fixd.session.Session; import org.bigtesting.fixd.util.RequestUtils; import org.bigtesting.routd.Route; import org.simpleframework.http.Request;
/* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.request.impl; /** * * @author Luis Antunes */ public class SimpleHttpRequest implements HttpRequest { private final Request request; private final Session session; private final Route route;
// Path: src/main/java/org/bigtesting/fixd/marshalling/Unmarshaller.java // public interface Unmarshaller { // // <T> T unmarshal(InputStream in, Class<T> type); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/UnmarshallerProvider.java // public interface UnmarshallerProvider { // // /** // * // * Returns the Unmarshaller for the given content-type, // * or null if there is no Unmarshaller for the given // * content-type. // * // * @param contentType // * @return the Unmarshaller for the given content-type, or // * null if there is no Unmarshaller for the given // * content-type // */ // Unmarshaller getUnmarshaller(String contentType); // } // // Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java // public interface HttpRequest { // // String getPath(); // // String getUndecodedPath(); // // Set<String> getRequestParameterNames(); // // String getRequestParameter(String name); // // String getPathParameter(String name); // // List<String> getHeaderNames(); // // String getHeaderValue(String name); // // String getBody(); // // InputStream getBodyAsStream() throws IOException; // // <T> T getBody(Class<T> type); // // long getContentLength(); // // String getContentType(); // // String getMethod(); // // long getTime(); // // String getQuery(); // // int getMajor(); // // int getMinor(); // // String getTarget(); // // /** // * @return a session, if it exists, or null if it does not // */ // Session getSession(); // // Route getRoute(); // } // // Path: src/main/java/org/bigtesting/fixd/session/Session.java // public class Session { // // private final String sessionId; // // private final Map<String, Object> values = new HashMap<String, Object>(); // // private boolean valid = true; // // public Session() { // // this.sessionId = UUID.randomUUID().toString(); // } // // public String getSessionId() { // // return sessionId; // } // // public Object get(String key) { // // return values.get(key); // } // // public void set(String key, Object value) { // // values.put(key, value); // } // // public Set<String> getAttributeNames() { // // return values.keySet(); // } // // public boolean isValid() { // // return valid; // } // // public void invalidate() { // // this.valid = false; // } // } // // Path: src/main/java/org/bigtesting/fixd/util/RequestUtils.java // public class RequestUtils { // // public static byte[] readBody(InputStream in) { // // ByteArrayOutputStream out = new ByteArrayOutputStream(); // try { // // byte[] buffer = new byte[1024]; // int len = 0; // while ((len = in.read(buffer)) != -1) { // out.write(buffer, 0, len); // } // // } catch (IOException e) { // throw new RuntimeException("error getting body", e); // } finally { // if (in != null) try {in.close();} catch (IOException e2) {} // } // // return out.toByteArray(); // } // // public static String getUndecodedPath(Request request) { // // String path = request.getTarget(); // int queryIndex = path.indexOf('?'); // if (queryIndex != -1) { // path = path.substring(0, queryIndex); // } // return path; // } // } // Path: src/main/java/org/bigtesting/fixd/request/impl/SimpleHttpRequest.java import java.io.IOException; import java.io.InputStream; import java.util.List; import java.util.Set; import org.bigtesting.fixd.marshalling.Unmarshaller; import org.bigtesting.fixd.marshalling.UnmarshallerProvider; import org.bigtesting.fixd.request.HttpRequest; import org.bigtesting.fixd.session.Session; import org.bigtesting.fixd.util.RequestUtils; import org.bigtesting.routd.Route; import org.simpleframework.http.Request; /* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.request.impl; /** * * @author Luis Antunes */ public class SimpleHttpRequest implements HttpRequest { private final Request request; private final Session session; private final Route route;
private final UnmarshallerProvider unmarshallerProvider;
lantunes/fixd
src/main/java/org/bigtesting/fixd/request/impl/SimpleHttpRequest.java
// Path: src/main/java/org/bigtesting/fixd/marshalling/Unmarshaller.java // public interface Unmarshaller { // // <T> T unmarshal(InputStream in, Class<T> type); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/UnmarshallerProvider.java // public interface UnmarshallerProvider { // // /** // * // * Returns the Unmarshaller for the given content-type, // * or null if there is no Unmarshaller for the given // * content-type. // * // * @param contentType // * @return the Unmarshaller for the given content-type, or // * null if there is no Unmarshaller for the given // * content-type // */ // Unmarshaller getUnmarshaller(String contentType); // } // // Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java // public interface HttpRequest { // // String getPath(); // // String getUndecodedPath(); // // Set<String> getRequestParameterNames(); // // String getRequestParameter(String name); // // String getPathParameter(String name); // // List<String> getHeaderNames(); // // String getHeaderValue(String name); // // String getBody(); // // InputStream getBodyAsStream() throws IOException; // // <T> T getBody(Class<T> type); // // long getContentLength(); // // String getContentType(); // // String getMethod(); // // long getTime(); // // String getQuery(); // // int getMajor(); // // int getMinor(); // // String getTarget(); // // /** // * @return a session, if it exists, or null if it does not // */ // Session getSession(); // // Route getRoute(); // } // // Path: src/main/java/org/bigtesting/fixd/session/Session.java // public class Session { // // private final String sessionId; // // private final Map<String, Object> values = new HashMap<String, Object>(); // // private boolean valid = true; // // public Session() { // // this.sessionId = UUID.randomUUID().toString(); // } // // public String getSessionId() { // // return sessionId; // } // // public Object get(String key) { // // return values.get(key); // } // // public void set(String key, Object value) { // // values.put(key, value); // } // // public Set<String> getAttributeNames() { // // return values.keySet(); // } // // public boolean isValid() { // // return valid; // } // // public void invalidate() { // // this.valid = false; // } // } // // Path: src/main/java/org/bigtesting/fixd/util/RequestUtils.java // public class RequestUtils { // // public static byte[] readBody(InputStream in) { // // ByteArrayOutputStream out = new ByteArrayOutputStream(); // try { // // byte[] buffer = new byte[1024]; // int len = 0; // while ((len = in.read(buffer)) != -1) { // out.write(buffer, 0, len); // } // // } catch (IOException e) { // throw new RuntimeException("error getting body", e); // } finally { // if (in != null) try {in.close();} catch (IOException e2) {} // } // // return out.toByteArray(); // } // // public static String getUndecodedPath(Request request) { // // String path = request.getTarget(); // int queryIndex = path.indexOf('?'); // if (queryIndex != -1) { // path = path.substring(0, queryIndex); // } // return path; // } // }
import java.io.IOException; import java.io.InputStream; import java.util.List; import java.util.Set; import org.bigtesting.fixd.marshalling.Unmarshaller; import org.bigtesting.fixd.marshalling.UnmarshallerProvider; import org.bigtesting.fixd.request.HttpRequest; import org.bigtesting.fixd.session.Session; import org.bigtesting.fixd.util.RequestUtils; import org.bigtesting.routd.Route; import org.simpleframework.http.Request;
/* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.request.impl; /** * * @author Luis Antunes */ public class SimpleHttpRequest implements HttpRequest { private final Request request; private final Session session; private final Route route; private final UnmarshallerProvider unmarshallerProvider; public SimpleHttpRequest(Request request, Session session, Route route, UnmarshallerProvider unmarshallerProvider) { this.request = request; this.session = session; this.route = route; this.unmarshallerProvider = unmarshallerProvider; } public String getPath() { return request.getPath().getPath(); } public String getUndecodedPath() {
// Path: src/main/java/org/bigtesting/fixd/marshalling/Unmarshaller.java // public interface Unmarshaller { // // <T> T unmarshal(InputStream in, Class<T> type); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/UnmarshallerProvider.java // public interface UnmarshallerProvider { // // /** // * // * Returns the Unmarshaller for the given content-type, // * or null if there is no Unmarshaller for the given // * content-type. // * // * @param contentType // * @return the Unmarshaller for the given content-type, or // * null if there is no Unmarshaller for the given // * content-type // */ // Unmarshaller getUnmarshaller(String contentType); // } // // Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java // public interface HttpRequest { // // String getPath(); // // String getUndecodedPath(); // // Set<String> getRequestParameterNames(); // // String getRequestParameter(String name); // // String getPathParameter(String name); // // List<String> getHeaderNames(); // // String getHeaderValue(String name); // // String getBody(); // // InputStream getBodyAsStream() throws IOException; // // <T> T getBody(Class<T> type); // // long getContentLength(); // // String getContentType(); // // String getMethod(); // // long getTime(); // // String getQuery(); // // int getMajor(); // // int getMinor(); // // String getTarget(); // // /** // * @return a session, if it exists, or null if it does not // */ // Session getSession(); // // Route getRoute(); // } // // Path: src/main/java/org/bigtesting/fixd/session/Session.java // public class Session { // // private final String sessionId; // // private final Map<String, Object> values = new HashMap<String, Object>(); // // private boolean valid = true; // // public Session() { // // this.sessionId = UUID.randomUUID().toString(); // } // // public String getSessionId() { // // return sessionId; // } // // public Object get(String key) { // // return values.get(key); // } // // public void set(String key, Object value) { // // values.put(key, value); // } // // public Set<String> getAttributeNames() { // // return values.keySet(); // } // // public boolean isValid() { // // return valid; // } // // public void invalidate() { // // this.valid = false; // } // } // // Path: src/main/java/org/bigtesting/fixd/util/RequestUtils.java // public class RequestUtils { // // public static byte[] readBody(InputStream in) { // // ByteArrayOutputStream out = new ByteArrayOutputStream(); // try { // // byte[] buffer = new byte[1024]; // int len = 0; // while ((len = in.read(buffer)) != -1) { // out.write(buffer, 0, len); // } // // } catch (IOException e) { // throw new RuntimeException("error getting body", e); // } finally { // if (in != null) try {in.close();} catch (IOException e2) {} // } // // return out.toByteArray(); // } // // public static String getUndecodedPath(Request request) { // // String path = request.getTarget(); // int queryIndex = path.indexOf('?'); // if (queryIndex != -1) { // path = path.substring(0, queryIndex); // } // return path; // } // } // Path: src/main/java/org/bigtesting/fixd/request/impl/SimpleHttpRequest.java import java.io.IOException; import java.io.InputStream; import java.util.List; import java.util.Set; import org.bigtesting.fixd.marshalling.Unmarshaller; import org.bigtesting.fixd.marshalling.UnmarshallerProvider; import org.bigtesting.fixd.request.HttpRequest; import org.bigtesting.fixd.session.Session; import org.bigtesting.fixd.util.RequestUtils; import org.bigtesting.routd.Route; import org.simpleframework.http.Request; /* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.request.impl; /** * * @author Luis Antunes */ public class SimpleHttpRequest implements HttpRequest { private final Request request; private final Session session; private final Route route; private final UnmarshallerProvider unmarshallerProvider; public SimpleHttpRequest(Request request, Session session, Route route, UnmarshallerProvider unmarshallerProvider) { this.request = request; this.session = session; this.route = route; this.unmarshallerProvider = unmarshallerProvider; } public String getPath() { return request.getPath().getPath(); } public String getUndecodedPath() {
return RequestUtils.getUndecodedPath(request);
lantunes/fixd
src/main/java/org/bigtesting/fixd/request/impl/SimpleHttpRequest.java
// Path: src/main/java/org/bigtesting/fixd/marshalling/Unmarshaller.java // public interface Unmarshaller { // // <T> T unmarshal(InputStream in, Class<T> type); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/UnmarshallerProvider.java // public interface UnmarshallerProvider { // // /** // * // * Returns the Unmarshaller for the given content-type, // * or null if there is no Unmarshaller for the given // * content-type. // * // * @param contentType // * @return the Unmarshaller for the given content-type, or // * null if there is no Unmarshaller for the given // * content-type // */ // Unmarshaller getUnmarshaller(String contentType); // } // // Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java // public interface HttpRequest { // // String getPath(); // // String getUndecodedPath(); // // Set<String> getRequestParameterNames(); // // String getRequestParameter(String name); // // String getPathParameter(String name); // // List<String> getHeaderNames(); // // String getHeaderValue(String name); // // String getBody(); // // InputStream getBodyAsStream() throws IOException; // // <T> T getBody(Class<T> type); // // long getContentLength(); // // String getContentType(); // // String getMethod(); // // long getTime(); // // String getQuery(); // // int getMajor(); // // int getMinor(); // // String getTarget(); // // /** // * @return a session, if it exists, or null if it does not // */ // Session getSession(); // // Route getRoute(); // } // // Path: src/main/java/org/bigtesting/fixd/session/Session.java // public class Session { // // private final String sessionId; // // private final Map<String, Object> values = new HashMap<String, Object>(); // // private boolean valid = true; // // public Session() { // // this.sessionId = UUID.randomUUID().toString(); // } // // public String getSessionId() { // // return sessionId; // } // // public Object get(String key) { // // return values.get(key); // } // // public void set(String key, Object value) { // // values.put(key, value); // } // // public Set<String> getAttributeNames() { // // return values.keySet(); // } // // public boolean isValid() { // // return valid; // } // // public void invalidate() { // // this.valid = false; // } // } // // Path: src/main/java/org/bigtesting/fixd/util/RequestUtils.java // public class RequestUtils { // // public static byte[] readBody(InputStream in) { // // ByteArrayOutputStream out = new ByteArrayOutputStream(); // try { // // byte[] buffer = new byte[1024]; // int len = 0; // while ((len = in.read(buffer)) != -1) { // out.write(buffer, 0, len); // } // // } catch (IOException e) { // throw new RuntimeException("error getting body", e); // } finally { // if (in != null) try {in.close();} catch (IOException e2) {} // } // // return out.toByteArray(); // } // // public static String getUndecodedPath(Request request) { // // String path = request.getTarget(); // int queryIndex = path.indexOf('?'); // if (queryIndex != -1) { // path = path.substring(0, queryIndex); // } // return path; // } // }
import java.io.IOException; import java.io.InputStream; import java.util.List; import java.util.Set; import org.bigtesting.fixd.marshalling.Unmarshaller; import org.bigtesting.fixd.marshalling.UnmarshallerProvider; import org.bigtesting.fixd.request.HttpRequest; import org.bigtesting.fixd.session.Session; import org.bigtesting.fixd.util.RequestUtils; import org.bigtesting.routd.Route; import org.simpleframework.http.Request;
return getRoute().getNamedParameter(name, getPath()); } public List<String> getHeaderNames() { return request.getNames(); } public String getHeaderValue(String name) { return request.getValue(name); } public String getBody() { try { return new String(RequestUtils.readBody(getBodyAsStream())); } catch (IOException e) { throw new RuntimeException("error getting body", e); } } public InputStream getBodyAsStream() throws IOException { return request.getInputStream(); } public <T> T getBody(Class<T> type) {
// Path: src/main/java/org/bigtesting/fixd/marshalling/Unmarshaller.java // public interface Unmarshaller { // // <T> T unmarshal(InputStream in, Class<T> type); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/UnmarshallerProvider.java // public interface UnmarshallerProvider { // // /** // * // * Returns the Unmarshaller for the given content-type, // * or null if there is no Unmarshaller for the given // * content-type. // * // * @param contentType // * @return the Unmarshaller for the given content-type, or // * null if there is no Unmarshaller for the given // * content-type // */ // Unmarshaller getUnmarshaller(String contentType); // } // // Path: src/main/java/org/bigtesting/fixd/request/HttpRequest.java // public interface HttpRequest { // // String getPath(); // // String getUndecodedPath(); // // Set<String> getRequestParameterNames(); // // String getRequestParameter(String name); // // String getPathParameter(String name); // // List<String> getHeaderNames(); // // String getHeaderValue(String name); // // String getBody(); // // InputStream getBodyAsStream() throws IOException; // // <T> T getBody(Class<T> type); // // long getContentLength(); // // String getContentType(); // // String getMethod(); // // long getTime(); // // String getQuery(); // // int getMajor(); // // int getMinor(); // // String getTarget(); // // /** // * @return a session, if it exists, or null if it does not // */ // Session getSession(); // // Route getRoute(); // } // // Path: src/main/java/org/bigtesting/fixd/session/Session.java // public class Session { // // private final String sessionId; // // private final Map<String, Object> values = new HashMap<String, Object>(); // // private boolean valid = true; // // public Session() { // // this.sessionId = UUID.randomUUID().toString(); // } // // public String getSessionId() { // // return sessionId; // } // // public Object get(String key) { // // return values.get(key); // } // // public void set(String key, Object value) { // // values.put(key, value); // } // // public Set<String> getAttributeNames() { // // return values.keySet(); // } // // public boolean isValid() { // // return valid; // } // // public void invalidate() { // // this.valid = false; // } // } // // Path: src/main/java/org/bigtesting/fixd/util/RequestUtils.java // public class RequestUtils { // // public static byte[] readBody(InputStream in) { // // ByteArrayOutputStream out = new ByteArrayOutputStream(); // try { // // byte[] buffer = new byte[1024]; // int len = 0; // while ((len = in.read(buffer)) != -1) { // out.write(buffer, 0, len); // } // // } catch (IOException e) { // throw new RuntimeException("error getting body", e); // } finally { // if (in != null) try {in.close();} catch (IOException e2) {} // } // // return out.toByteArray(); // } // // public static String getUndecodedPath(Request request) { // // String path = request.getTarget(); // int queryIndex = path.indexOf('?'); // if (queryIndex != -1) { // path = path.substring(0, queryIndex); // } // return path; // } // } // Path: src/main/java/org/bigtesting/fixd/request/impl/SimpleHttpRequest.java import java.io.IOException; import java.io.InputStream; import java.util.List; import java.util.Set; import org.bigtesting.fixd.marshalling.Unmarshaller; import org.bigtesting.fixd.marshalling.UnmarshallerProvider; import org.bigtesting.fixd.request.HttpRequest; import org.bigtesting.fixd.session.Session; import org.bigtesting.fixd.util.RequestUtils; import org.bigtesting.routd.Route; import org.simpleframework.http.Request; return getRoute().getNamedParameter(name, getPath()); } public List<String> getHeaderNames() { return request.getNames(); } public String getHeaderValue(String name) { return request.getValue(name); } public String getBody() { try { return new String(RequestUtils.readBody(getBodyAsStream())); } catch (IOException e) { throw new RuntimeException("error getting body", e); } } public InputStream getBodyAsStream() throws IOException { return request.getInputStream(); } public <T> T getBody(Class<T> type) {
Unmarshaller unmarshaller = unmarshallerProvider.getUnmarshaller(getContentType());
lantunes/fixd
src/main/java/org/bigtesting/fixd/core/RequestUnmarshallerImpl.java
// Path: src/main/java/org/bigtesting/fixd/RequestUnmarshaller.java // public interface RequestUnmarshaller { // // void with(Unmarshaller unmarshaller); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/Unmarshaller.java // public interface Unmarshaller { // // <T> T unmarshal(InputStream in, Class<T> type); // }
import org.bigtesting.fixd.RequestUnmarshaller; import org.bigtesting.fixd.marshalling.Unmarshaller;
/* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.core; /** * * @author Luis Antunes */ public class RequestUnmarshallerImpl implements RequestUnmarshaller { private final String contentType;
// Path: src/main/java/org/bigtesting/fixd/RequestUnmarshaller.java // public interface RequestUnmarshaller { // // void with(Unmarshaller unmarshaller); // } // // Path: src/main/java/org/bigtesting/fixd/marshalling/Unmarshaller.java // public interface Unmarshaller { // // <T> T unmarshal(InputStream in, Class<T> type); // } // Path: src/main/java/org/bigtesting/fixd/core/RequestUnmarshallerImpl.java import org.bigtesting.fixd.RequestUnmarshaller; import org.bigtesting.fixd.marshalling.Unmarshaller; /* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd.core; /** * * @author Luis Antunes */ public class RequestUnmarshallerImpl implements RequestUnmarshaller { private final String contentType;
private Unmarshaller unmarshaller;
lantunes/fixd
src/main/java/org/bigtesting/fixd/RequestHandler.java
// Path: src/main/java/org/bigtesting/fixd/request/HttpRequestHandler.java // public interface HttpRequestHandler { // // void handle(HttpRequest request, HttpResponse response); // } // // Path: src/main/java/org/bigtesting/fixd/session/SessionHandler.java // public interface SessionHandler { // // void onCreate(HttpRequest request); // }
import java.util.concurrent.TimeUnit; import org.bigtesting.fixd.request.HttpRequestHandler; import org.bigtesting.fixd.session.SessionHandler;
/* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd; /** * * @author Luis Antunes */ public interface RequestHandler { RequestHandler with(int statusCode, String contentType, String body); RequestHandler with(int statusCode, String contentType, Object entity);
// Path: src/main/java/org/bigtesting/fixd/request/HttpRequestHandler.java // public interface HttpRequestHandler { // // void handle(HttpRequest request, HttpResponse response); // } // // Path: src/main/java/org/bigtesting/fixd/session/SessionHandler.java // public interface SessionHandler { // // void onCreate(HttpRequest request); // } // Path: src/main/java/org/bigtesting/fixd/RequestHandler.java import java.util.concurrent.TimeUnit; import org.bigtesting.fixd.request.HttpRequestHandler; import org.bigtesting.fixd.session.SessionHandler; /* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd; /** * * @author Luis Antunes */ public interface RequestHandler { RequestHandler with(int statusCode, String contentType, String body); RequestHandler with(int statusCode, String contentType, Object entity);
RequestHandler with(HttpRequestHandler customHandler);
lantunes/fixd
src/main/java/org/bigtesting/fixd/RequestHandler.java
// Path: src/main/java/org/bigtesting/fixd/request/HttpRequestHandler.java // public interface HttpRequestHandler { // // void handle(HttpRequest request, HttpResponse response); // } // // Path: src/main/java/org/bigtesting/fixd/session/SessionHandler.java // public interface SessionHandler { // // void onCreate(HttpRequest request); // }
import java.util.concurrent.TimeUnit; import org.bigtesting.fixd.request.HttpRequestHandler; import org.bigtesting.fixd.session.SessionHandler;
/* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd; /** * * @author Luis Antunes */ public interface RequestHandler { RequestHandler with(int statusCode, String contentType, String body); RequestHandler with(int statusCode, String contentType, Object entity); RequestHandler with(HttpRequestHandler customHandler);
// Path: src/main/java/org/bigtesting/fixd/request/HttpRequestHandler.java // public interface HttpRequestHandler { // // void handle(HttpRequest request, HttpResponse response); // } // // Path: src/main/java/org/bigtesting/fixd/session/SessionHandler.java // public interface SessionHandler { // // void onCreate(HttpRequest request); // } // Path: src/main/java/org/bigtesting/fixd/RequestHandler.java import java.util.concurrent.TimeUnit; import org.bigtesting.fixd.request.HttpRequestHandler; import org.bigtesting.fixd.session.SessionHandler; /* * Copyright (C) 2015 BigTesting.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bigtesting.fixd; /** * * @author Luis Antunes */ public interface RequestHandler { RequestHandler with(int statusCode, String contentType, String body); RequestHandler with(int statusCode, String contentType, Object entity); RequestHandler with(HttpRequestHandler customHandler);
RequestHandler withSessionHandler(SessionHandler sessionHandler);