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
|
|---|---|---|---|---|---|---|
nfl/glitr
|
src/main/java/com/nfl/glitr/calculator/QueryComplexityCalculator.java
|
// Path: src/main/java/com/nfl/glitr/exception/GlitrException.java
// public class GlitrException extends RuntimeException {
//
// public GlitrException(String message) {
// super(message);
// }
//
// public GlitrException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrFieldDefinition.java
// public class GlitrFieldDefinition extends FieldDefinition {
//
// private Set<GlitrMetaDefinition> metaDefinitions = new HashSet<>();
//
//
// public GlitrFieldDefinition(String name, Type type) {
// super(name, type);
// }
//
// public GlitrFieldDefinition(String name, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, null);
// this.metaDefinitions = metaDefinitions;
// }
//
// public GlitrFieldDefinition(String name, Type type, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, type);
// this.metaDefinitions = metaDefinitions;
// }
//
// public Set<GlitrMetaDefinition> getMetaDefinitions() {
// return metaDefinitions;
// }
//
// public void setMetaDefinitions(Set<GlitrMetaDefinition> metaDefinitions) {
// this.metaDefinitions = metaDefinitions;
// }
//
// public void addMetaDefinitions(GlitrMetaDefinition metaDefinition) {
// if (this.metaDefinitions == null) {
// this.metaDefinitions = new HashSet<>();
// }
// this.metaDefinitions.add(metaDefinition);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrMetaDefinition.java
// public class GlitrMetaDefinition {
//
// private String name;
// private Object value;
//
//
// public GlitrMetaDefinition(String name, Object value) {
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
//
// if (o == null || getClass() != o.getClass()) return false;
//
// GlitrMetaDefinition that = (GlitrMetaDefinition) o;
//
// return new EqualsBuilder()
// .append(name, that.name)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder(17, 37)
// .append(name)
// .toHashCode();
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GraphQLConnectionList.java
// public class GraphQLConnectionList extends GraphQLList {
// public GraphQLConnectionList(GraphQLType wrappedType) {
// super(wrappedType);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/util/NodeUtil.java
// public static final String COMPLEXITY_FORMULA_KEY = "complexity_formula";
//
// Path: src/main/java/com/nfl/glitr/util/NodeUtil.java
// public static final String COMPLEXITY_IGNORE_KEY = "complexity_ignore";
|
import com.nfl.glitr.exception.GlitrException;
import com.nfl.glitr.registry.schema.GlitrFieldDefinition;
import com.nfl.glitr.registry.schema.GlitrMetaDefinition;
import com.nfl.glitr.registry.schema.GraphQLConnectionList;
import graphql.language.*;
import graphql.parser.InvalidSyntaxException;
import graphql.parser.Parser;
import graphql.parser.antlr.GraphqlLexer;
import graphql.schema.*;
import net.objecthunter.exp4j.Expression;
import net.objecthunter.exp4j.ExpressionBuilder;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonToken;
import org.antlr.v4.runtime.InputMismatchException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.nfl.glitr.util.NodeUtil.COMPLEXITY_FORMULA_KEY;
import static com.nfl.glitr.util.NodeUtil.COMPLEXITY_IGNORE_KEY;
import static org.apache.commons.lang3.StringUtils.defaultString;
|
* @param variables graphQL query variables
* @return {@link QueryComplexityNode}
*/
public QueryComplexityNode queryScoreDetails(String query, Map<String, Object> variables) {
if (StringUtils.isBlank(query)) {
throw new GlitrException("query cannot be null or empty");
}
QueryComplexityNode complexityModel = buildComplexityModel(query);
return queryScoreDetails(complexityModel, 0, new HashMap<>(), variables);
}
private QueryComplexityNode buildComplexityModel(String query) {
Document document = parseRootNode(query);
Map<String, Pair<String, List<Selection>>> fragments = getFragments(document);
OperationDefinition operationDefinition = getFirstByType(document.getChildren(), OperationDefinition.class)
.orElseThrow(() -> new GlitrException("Cannot find node 'OperationDefinition'"));
Field queryEntryPoint = getFirstFieldNode(operationDefinition);
if (queryEntryPoint == null) {
return new QueryComplexityNode();
}
GraphQLFieldDefinition rootSchemaField = getRootSchemaField(query, queryEntryPoint.getName());
boolean mutationQuery = operationDefinition.getOperation() == OperationDefinition.Operation.MUTATION;
boolean ignoreField = ignoreFieldOrDefault(rootSchemaField, mutationQuery);
QueryComplexityNode rootComplexityNode = new QueryComplexityNode(queryEntryPoint.getName());
|
// Path: src/main/java/com/nfl/glitr/exception/GlitrException.java
// public class GlitrException extends RuntimeException {
//
// public GlitrException(String message) {
// super(message);
// }
//
// public GlitrException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrFieldDefinition.java
// public class GlitrFieldDefinition extends FieldDefinition {
//
// private Set<GlitrMetaDefinition> metaDefinitions = new HashSet<>();
//
//
// public GlitrFieldDefinition(String name, Type type) {
// super(name, type);
// }
//
// public GlitrFieldDefinition(String name, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, null);
// this.metaDefinitions = metaDefinitions;
// }
//
// public GlitrFieldDefinition(String name, Type type, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, type);
// this.metaDefinitions = metaDefinitions;
// }
//
// public Set<GlitrMetaDefinition> getMetaDefinitions() {
// return metaDefinitions;
// }
//
// public void setMetaDefinitions(Set<GlitrMetaDefinition> metaDefinitions) {
// this.metaDefinitions = metaDefinitions;
// }
//
// public void addMetaDefinitions(GlitrMetaDefinition metaDefinition) {
// if (this.metaDefinitions == null) {
// this.metaDefinitions = new HashSet<>();
// }
// this.metaDefinitions.add(metaDefinition);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrMetaDefinition.java
// public class GlitrMetaDefinition {
//
// private String name;
// private Object value;
//
//
// public GlitrMetaDefinition(String name, Object value) {
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
//
// if (o == null || getClass() != o.getClass()) return false;
//
// GlitrMetaDefinition that = (GlitrMetaDefinition) o;
//
// return new EqualsBuilder()
// .append(name, that.name)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder(17, 37)
// .append(name)
// .toHashCode();
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GraphQLConnectionList.java
// public class GraphQLConnectionList extends GraphQLList {
// public GraphQLConnectionList(GraphQLType wrappedType) {
// super(wrappedType);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/util/NodeUtil.java
// public static final String COMPLEXITY_FORMULA_KEY = "complexity_formula";
//
// Path: src/main/java/com/nfl/glitr/util/NodeUtil.java
// public static final String COMPLEXITY_IGNORE_KEY = "complexity_ignore";
// Path: src/main/java/com/nfl/glitr/calculator/QueryComplexityCalculator.java
import com.nfl.glitr.exception.GlitrException;
import com.nfl.glitr.registry.schema.GlitrFieldDefinition;
import com.nfl.glitr.registry.schema.GlitrMetaDefinition;
import com.nfl.glitr.registry.schema.GraphQLConnectionList;
import graphql.language.*;
import graphql.parser.InvalidSyntaxException;
import graphql.parser.Parser;
import graphql.parser.antlr.GraphqlLexer;
import graphql.schema.*;
import net.objecthunter.exp4j.Expression;
import net.objecthunter.exp4j.ExpressionBuilder;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonToken;
import org.antlr.v4.runtime.InputMismatchException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.nfl.glitr.util.NodeUtil.COMPLEXITY_FORMULA_KEY;
import static com.nfl.glitr.util.NodeUtil.COMPLEXITY_IGNORE_KEY;
import static org.apache.commons.lang3.StringUtils.defaultString;
* @param variables graphQL query variables
* @return {@link QueryComplexityNode}
*/
public QueryComplexityNode queryScoreDetails(String query, Map<String, Object> variables) {
if (StringUtils.isBlank(query)) {
throw new GlitrException("query cannot be null or empty");
}
QueryComplexityNode complexityModel = buildComplexityModel(query);
return queryScoreDetails(complexityModel, 0, new HashMap<>(), variables);
}
private QueryComplexityNode buildComplexityModel(String query) {
Document document = parseRootNode(query);
Map<String, Pair<String, List<Selection>>> fragments = getFragments(document);
OperationDefinition operationDefinition = getFirstByType(document.getChildren(), OperationDefinition.class)
.orElseThrow(() -> new GlitrException("Cannot find node 'OperationDefinition'"));
Field queryEntryPoint = getFirstFieldNode(operationDefinition);
if (queryEntryPoint == null) {
return new QueryComplexityNode();
}
GraphQLFieldDefinition rootSchemaField = getRootSchemaField(query, queryEntryPoint.getName());
boolean mutationQuery = operationDefinition.getOperation() == OperationDefinition.Operation.MUTATION;
boolean ignoreField = ignoreFieldOrDefault(rootSchemaField, mutationQuery);
QueryComplexityNode rootComplexityNode = new QueryComplexityNode(queryEntryPoint.getName());
|
rootComplexityNode.setFormula(getGraphQLMeta(rootSchemaField, COMPLEXITY_FORMULA_KEY));
|
nfl/glitr
|
src/main/java/com/nfl/glitr/calculator/QueryComplexityCalculator.java
|
// Path: src/main/java/com/nfl/glitr/exception/GlitrException.java
// public class GlitrException extends RuntimeException {
//
// public GlitrException(String message) {
// super(message);
// }
//
// public GlitrException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrFieldDefinition.java
// public class GlitrFieldDefinition extends FieldDefinition {
//
// private Set<GlitrMetaDefinition> metaDefinitions = new HashSet<>();
//
//
// public GlitrFieldDefinition(String name, Type type) {
// super(name, type);
// }
//
// public GlitrFieldDefinition(String name, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, null);
// this.metaDefinitions = metaDefinitions;
// }
//
// public GlitrFieldDefinition(String name, Type type, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, type);
// this.metaDefinitions = metaDefinitions;
// }
//
// public Set<GlitrMetaDefinition> getMetaDefinitions() {
// return metaDefinitions;
// }
//
// public void setMetaDefinitions(Set<GlitrMetaDefinition> metaDefinitions) {
// this.metaDefinitions = metaDefinitions;
// }
//
// public void addMetaDefinitions(GlitrMetaDefinition metaDefinition) {
// if (this.metaDefinitions == null) {
// this.metaDefinitions = new HashSet<>();
// }
// this.metaDefinitions.add(metaDefinition);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrMetaDefinition.java
// public class GlitrMetaDefinition {
//
// private String name;
// private Object value;
//
//
// public GlitrMetaDefinition(String name, Object value) {
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
//
// if (o == null || getClass() != o.getClass()) return false;
//
// GlitrMetaDefinition that = (GlitrMetaDefinition) o;
//
// return new EqualsBuilder()
// .append(name, that.name)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder(17, 37)
// .append(name)
// .toHashCode();
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GraphQLConnectionList.java
// public class GraphQLConnectionList extends GraphQLList {
// public GraphQLConnectionList(GraphQLType wrappedType) {
// super(wrappedType);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/util/NodeUtil.java
// public static final String COMPLEXITY_FORMULA_KEY = "complexity_formula";
//
// Path: src/main/java/com/nfl/glitr/util/NodeUtil.java
// public static final String COMPLEXITY_IGNORE_KEY = "complexity_ignore";
|
import com.nfl.glitr.exception.GlitrException;
import com.nfl.glitr.registry.schema.GlitrFieldDefinition;
import com.nfl.glitr.registry.schema.GlitrMetaDefinition;
import com.nfl.glitr.registry.schema.GraphQLConnectionList;
import graphql.language.*;
import graphql.parser.InvalidSyntaxException;
import graphql.parser.Parser;
import graphql.parser.antlr.GraphqlLexer;
import graphql.schema.*;
import net.objecthunter.exp4j.Expression;
import net.objecthunter.exp4j.ExpressionBuilder;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonToken;
import org.antlr.v4.runtime.InputMismatchException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.nfl.glitr.util.NodeUtil.COMPLEXITY_FORMULA_KEY;
import static com.nfl.glitr.util.NodeUtil.COMPLEXITY_IGNORE_KEY;
import static org.apache.commons.lang3.StringUtils.defaultString;
|
childScores += childComplexityNode.getTotalWeight();
}
double currentNodeScore = 0d;
if (!parentNode.isIgnore()) {
Map<String, Double> nodeContext = buildContext(parentNode, nestedContext, depth, childScores, queryVariables);
currentNodeScore = extractMultiplierFromListField(parentNode, nodeContext, queryVariables);
parentNode.setWeight(currentNodeScore);
}
parentNode.setTotalWeight(getTotalWeight(parentNode, queryVariables, currentNodeScore, childScores));
return parentNode;
}
private double getTotalWeight(QueryComplexityNode node, Map<String, Object> queryVariables, double currentNodeScore, double childScores) {
String multiplier = node.getFormula();
Optional<Integer> listLimit = getLimitArgIfPresent(node, queryVariables);
if (listLimit.isPresent() && StringUtils.isBlank(multiplier)) {
double collectionSize = listLimit.get();
if (childScores != 0) {
childScores = collectionSize * childScores;
}
return (collectionSize * defaultMultiplier) + childScores;
} else {
return currentNodeScore + childScores;
}
}
private <T> T getGraphQLMeta(GraphQLFieldDefinition graphQlObject, String name) {
|
// Path: src/main/java/com/nfl/glitr/exception/GlitrException.java
// public class GlitrException extends RuntimeException {
//
// public GlitrException(String message) {
// super(message);
// }
//
// public GlitrException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrFieldDefinition.java
// public class GlitrFieldDefinition extends FieldDefinition {
//
// private Set<GlitrMetaDefinition> metaDefinitions = new HashSet<>();
//
//
// public GlitrFieldDefinition(String name, Type type) {
// super(name, type);
// }
//
// public GlitrFieldDefinition(String name, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, null);
// this.metaDefinitions = metaDefinitions;
// }
//
// public GlitrFieldDefinition(String name, Type type, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, type);
// this.metaDefinitions = metaDefinitions;
// }
//
// public Set<GlitrMetaDefinition> getMetaDefinitions() {
// return metaDefinitions;
// }
//
// public void setMetaDefinitions(Set<GlitrMetaDefinition> metaDefinitions) {
// this.metaDefinitions = metaDefinitions;
// }
//
// public void addMetaDefinitions(GlitrMetaDefinition metaDefinition) {
// if (this.metaDefinitions == null) {
// this.metaDefinitions = new HashSet<>();
// }
// this.metaDefinitions.add(metaDefinition);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrMetaDefinition.java
// public class GlitrMetaDefinition {
//
// private String name;
// private Object value;
//
//
// public GlitrMetaDefinition(String name, Object value) {
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
//
// if (o == null || getClass() != o.getClass()) return false;
//
// GlitrMetaDefinition that = (GlitrMetaDefinition) o;
//
// return new EqualsBuilder()
// .append(name, that.name)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder(17, 37)
// .append(name)
// .toHashCode();
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GraphQLConnectionList.java
// public class GraphQLConnectionList extends GraphQLList {
// public GraphQLConnectionList(GraphQLType wrappedType) {
// super(wrappedType);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/util/NodeUtil.java
// public static final String COMPLEXITY_FORMULA_KEY = "complexity_formula";
//
// Path: src/main/java/com/nfl/glitr/util/NodeUtil.java
// public static final String COMPLEXITY_IGNORE_KEY = "complexity_ignore";
// Path: src/main/java/com/nfl/glitr/calculator/QueryComplexityCalculator.java
import com.nfl.glitr.exception.GlitrException;
import com.nfl.glitr.registry.schema.GlitrFieldDefinition;
import com.nfl.glitr.registry.schema.GlitrMetaDefinition;
import com.nfl.glitr.registry.schema.GraphQLConnectionList;
import graphql.language.*;
import graphql.parser.InvalidSyntaxException;
import graphql.parser.Parser;
import graphql.parser.antlr.GraphqlLexer;
import graphql.schema.*;
import net.objecthunter.exp4j.Expression;
import net.objecthunter.exp4j.ExpressionBuilder;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonToken;
import org.antlr.v4.runtime.InputMismatchException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.nfl.glitr.util.NodeUtil.COMPLEXITY_FORMULA_KEY;
import static com.nfl.glitr.util.NodeUtil.COMPLEXITY_IGNORE_KEY;
import static org.apache.commons.lang3.StringUtils.defaultString;
childScores += childComplexityNode.getTotalWeight();
}
double currentNodeScore = 0d;
if (!parentNode.isIgnore()) {
Map<String, Double> nodeContext = buildContext(parentNode, nestedContext, depth, childScores, queryVariables);
currentNodeScore = extractMultiplierFromListField(parentNode, nodeContext, queryVariables);
parentNode.setWeight(currentNodeScore);
}
parentNode.setTotalWeight(getTotalWeight(parentNode, queryVariables, currentNodeScore, childScores));
return parentNode;
}
private double getTotalWeight(QueryComplexityNode node, Map<String, Object> queryVariables, double currentNodeScore, double childScores) {
String multiplier = node.getFormula();
Optional<Integer> listLimit = getLimitArgIfPresent(node, queryVariables);
if (listLimit.isPresent() && StringUtils.isBlank(multiplier)) {
double collectionSize = listLimit.get();
if (childScores != 0) {
childScores = collectionSize * childScores;
}
return (collectionSize * defaultMultiplier) + childScores;
} else {
return currentNodeScore + childScores;
}
}
private <T> T getGraphQLMeta(GraphQLFieldDefinition graphQlObject, String name) {
|
Optional<Set<GlitrMetaDefinition>> metaDefinitions = Optional.ofNullable(graphQlObject)
|
nfl/glitr
|
src/main/java/com/nfl/glitr/calculator/QueryComplexityCalculator.java
|
// Path: src/main/java/com/nfl/glitr/exception/GlitrException.java
// public class GlitrException extends RuntimeException {
//
// public GlitrException(String message) {
// super(message);
// }
//
// public GlitrException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrFieldDefinition.java
// public class GlitrFieldDefinition extends FieldDefinition {
//
// private Set<GlitrMetaDefinition> metaDefinitions = new HashSet<>();
//
//
// public GlitrFieldDefinition(String name, Type type) {
// super(name, type);
// }
//
// public GlitrFieldDefinition(String name, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, null);
// this.metaDefinitions = metaDefinitions;
// }
//
// public GlitrFieldDefinition(String name, Type type, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, type);
// this.metaDefinitions = metaDefinitions;
// }
//
// public Set<GlitrMetaDefinition> getMetaDefinitions() {
// return metaDefinitions;
// }
//
// public void setMetaDefinitions(Set<GlitrMetaDefinition> metaDefinitions) {
// this.metaDefinitions = metaDefinitions;
// }
//
// public void addMetaDefinitions(GlitrMetaDefinition metaDefinition) {
// if (this.metaDefinitions == null) {
// this.metaDefinitions = new HashSet<>();
// }
// this.metaDefinitions.add(metaDefinition);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrMetaDefinition.java
// public class GlitrMetaDefinition {
//
// private String name;
// private Object value;
//
//
// public GlitrMetaDefinition(String name, Object value) {
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
//
// if (o == null || getClass() != o.getClass()) return false;
//
// GlitrMetaDefinition that = (GlitrMetaDefinition) o;
//
// return new EqualsBuilder()
// .append(name, that.name)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder(17, 37)
// .append(name)
// .toHashCode();
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GraphQLConnectionList.java
// public class GraphQLConnectionList extends GraphQLList {
// public GraphQLConnectionList(GraphQLType wrappedType) {
// super(wrappedType);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/util/NodeUtil.java
// public static final String COMPLEXITY_FORMULA_KEY = "complexity_formula";
//
// Path: src/main/java/com/nfl/glitr/util/NodeUtil.java
// public static final String COMPLEXITY_IGNORE_KEY = "complexity_ignore";
|
import com.nfl.glitr.exception.GlitrException;
import com.nfl.glitr.registry.schema.GlitrFieldDefinition;
import com.nfl.glitr.registry.schema.GlitrMetaDefinition;
import com.nfl.glitr.registry.schema.GraphQLConnectionList;
import graphql.language.*;
import graphql.parser.InvalidSyntaxException;
import graphql.parser.Parser;
import graphql.parser.antlr.GraphqlLexer;
import graphql.schema.*;
import net.objecthunter.exp4j.Expression;
import net.objecthunter.exp4j.ExpressionBuilder;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonToken;
import org.antlr.v4.runtime.InputMismatchException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.nfl.glitr.util.NodeUtil.COMPLEXITY_FORMULA_KEY;
import static com.nfl.glitr.util.NodeUtil.COMPLEXITY_IGNORE_KEY;
import static org.apache.commons.lang3.StringUtils.defaultString;
|
double currentNodeScore = 0d;
if (!parentNode.isIgnore()) {
Map<String, Double> nodeContext = buildContext(parentNode, nestedContext, depth, childScores, queryVariables);
currentNodeScore = extractMultiplierFromListField(parentNode, nodeContext, queryVariables);
parentNode.setWeight(currentNodeScore);
}
parentNode.setTotalWeight(getTotalWeight(parentNode, queryVariables, currentNodeScore, childScores));
return parentNode;
}
private double getTotalWeight(QueryComplexityNode node, Map<String, Object> queryVariables, double currentNodeScore, double childScores) {
String multiplier = node.getFormula();
Optional<Integer> listLimit = getLimitArgIfPresent(node, queryVariables);
if (listLimit.isPresent() && StringUtils.isBlank(multiplier)) {
double collectionSize = listLimit.get();
if (childScores != 0) {
childScores = collectionSize * childScores;
}
return (collectionSize * defaultMultiplier) + childScores;
} else {
return currentNodeScore + childScores;
}
}
private <T> T getGraphQLMeta(GraphQLFieldDefinition graphQlObject, String name) {
Optional<Set<GlitrMetaDefinition>> metaDefinitions = Optional.ofNullable(graphQlObject)
.map(GraphQLFieldDefinition::getDefinition)
|
// Path: src/main/java/com/nfl/glitr/exception/GlitrException.java
// public class GlitrException extends RuntimeException {
//
// public GlitrException(String message) {
// super(message);
// }
//
// public GlitrException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrFieldDefinition.java
// public class GlitrFieldDefinition extends FieldDefinition {
//
// private Set<GlitrMetaDefinition> metaDefinitions = new HashSet<>();
//
//
// public GlitrFieldDefinition(String name, Type type) {
// super(name, type);
// }
//
// public GlitrFieldDefinition(String name, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, null);
// this.metaDefinitions = metaDefinitions;
// }
//
// public GlitrFieldDefinition(String name, Type type, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, type);
// this.metaDefinitions = metaDefinitions;
// }
//
// public Set<GlitrMetaDefinition> getMetaDefinitions() {
// return metaDefinitions;
// }
//
// public void setMetaDefinitions(Set<GlitrMetaDefinition> metaDefinitions) {
// this.metaDefinitions = metaDefinitions;
// }
//
// public void addMetaDefinitions(GlitrMetaDefinition metaDefinition) {
// if (this.metaDefinitions == null) {
// this.metaDefinitions = new HashSet<>();
// }
// this.metaDefinitions.add(metaDefinition);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrMetaDefinition.java
// public class GlitrMetaDefinition {
//
// private String name;
// private Object value;
//
//
// public GlitrMetaDefinition(String name, Object value) {
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
//
// if (o == null || getClass() != o.getClass()) return false;
//
// GlitrMetaDefinition that = (GlitrMetaDefinition) o;
//
// return new EqualsBuilder()
// .append(name, that.name)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder(17, 37)
// .append(name)
// .toHashCode();
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GraphQLConnectionList.java
// public class GraphQLConnectionList extends GraphQLList {
// public GraphQLConnectionList(GraphQLType wrappedType) {
// super(wrappedType);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/util/NodeUtil.java
// public static final String COMPLEXITY_FORMULA_KEY = "complexity_formula";
//
// Path: src/main/java/com/nfl/glitr/util/NodeUtil.java
// public static final String COMPLEXITY_IGNORE_KEY = "complexity_ignore";
// Path: src/main/java/com/nfl/glitr/calculator/QueryComplexityCalculator.java
import com.nfl.glitr.exception.GlitrException;
import com.nfl.glitr.registry.schema.GlitrFieldDefinition;
import com.nfl.glitr.registry.schema.GlitrMetaDefinition;
import com.nfl.glitr.registry.schema.GraphQLConnectionList;
import graphql.language.*;
import graphql.parser.InvalidSyntaxException;
import graphql.parser.Parser;
import graphql.parser.antlr.GraphqlLexer;
import graphql.schema.*;
import net.objecthunter.exp4j.Expression;
import net.objecthunter.exp4j.ExpressionBuilder;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonToken;
import org.antlr.v4.runtime.InputMismatchException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.nfl.glitr.util.NodeUtil.COMPLEXITY_FORMULA_KEY;
import static com.nfl.glitr.util.NodeUtil.COMPLEXITY_IGNORE_KEY;
import static org.apache.commons.lang3.StringUtils.defaultString;
double currentNodeScore = 0d;
if (!parentNode.isIgnore()) {
Map<String, Double> nodeContext = buildContext(parentNode, nestedContext, depth, childScores, queryVariables);
currentNodeScore = extractMultiplierFromListField(parentNode, nodeContext, queryVariables);
parentNode.setWeight(currentNodeScore);
}
parentNode.setTotalWeight(getTotalWeight(parentNode, queryVariables, currentNodeScore, childScores));
return parentNode;
}
private double getTotalWeight(QueryComplexityNode node, Map<String, Object> queryVariables, double currentNodeScore, double childScores) {
String multiplier = node.getFormula();
Optional<Integer> listLimit = getLimitArgIfPresent(node, queryVariables);
if (listLimit.isPresent() && StringUtils.isBlank(multiplier)) {
double collectionSize = listLimit.get();
if (childScores != 0) {
childScores = collectionSize * childScores;
}
return (collectionSize * defaultMultiplier) + childScores;
} else {
return currentNodeScore + childScores;
}
}
private <T> T getGraphQLMeta(GraphQLFieldDefinition graphQlObject, String name) {
Optional<Set<GlitrMetaDefinition>> metaDefinitions = Optional.ofNullable(graphQlObject)
.map(GraphQLFieldDefinition::getDefinition)
|
.filter(x -> x instanceof GlitrFieldDefinition)
|
nfl/glitr
|
src/main/java/com/nfl/glitr/calculator/QueryComplexityCalculator.java
|
// Path: src/main/java/com/nfl/glitr/exception/GlitrException.java
// public class GlitrException extends RuntimeException {
//
// public GlitrException(String message) {
// super(message);
// }
//
// public GlitrException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrFieldDefinition.java
// public class GlitrFieldDefinition extends FieldDefinition {
//
// private Set<GlitrMetaDefinition> metaDefinitions = new HashSet<>();
//
//
// public GlitrFieldDefinition(String name, Type type) {
// super(name, type);
// }
//
// public GlitrFieldDefinition(String name, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, null);
// this.metaDefinitions = metaDefinitions;
// }
//
// public GlitrFieldDefinition(String name, Type type, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, type);
// this.metaDefinitions = metaDefinitions;
// }
//
// public Set<GlitrMetaDefinition> getMetaDefinitions() {
// return metaDefinitions;
// }
//
// public void setMetaDefinitions(Set<GlitrMetaDefinition> metaDefinitions) {
// this.metaDefinitions = metaDefinitions;
// }
//
// public void addMetaDefinitions(GlitrMetaDefinition metaDefinition) {
// if (this.metaDefinitions == null) {
// this.metaDefinitions = new HashSet<>();
// }
// this.metaDefinitions.add(metaDefinition);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrMetaDefinition.java
// public class GlitrMetaDefinition {
//
// private String name;
// private Object value;
//
//
// public GlitrMetaDefinition(String name, Object value) {
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
//
// if (o == null || getClass() != o.getClass()) return false;
//
// GlitrMetaDefinition that = (GlitrMetaDefinition) o;
//
// return new EqualsBuilder()
// .append(name, that.name)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder(17, 37)
// .append(name)
// .toHashCode();
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GraphQLConnectionList.java
// public class GraphQLConnectionList extends GraphQLList {
// public GraphQLConnectionList(GraphQLType wrappedType) {
// super(wrappedType);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/util/NodeUtil.java
// public static final String COMPLEXITY_FORMULA_KEY = "complexity_formula";
//
// Path: src/main/java/com/nfl/glitr/util/NodeUtil.java
// public static final String COMPLEXITY_IGNORE_KEY = "complexity_ignore";
|
import com.nfl.glitr.exception.GlitrException;
import com.nfl.glitr.registry.schema.GlitrFieldDefinition;
import com.nfl.glitr.registry.schema.GlitrMetaDefinition;
import com.nfl.glitr.registry.schema.GraphQLConnectionList;
import graphql.language.*;
import graphql.parser.InvalidSyntaxException;
import graphql.parser.Parser;
import graphql.parser.antlr.GraphqlLexer;
import graphql.schema.*;
import net.objecthunter.exp4j.Expression;
import net.objecthunter.exp4j.ExpressionBuilder;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonToken;
import org.antlr.v4.runtime.InputMismatchException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.nfl.glitr.util.NodeUtil.COMPLEXITY_FORMULA_KEY;
import static com.nfl.glitr.util.NodeUtil.COMPLEXITY_IGNORE_KEY;
import static org.apache.commons.lang3.StringUtils.defaultString;
|
return (collectionSize * defaultMultiplier) + childScores;
} else {
return currentNodeScore + childScores;
}
}
private <T> T getGraphQLMeta(GraphQLFieldDefinition graphQlObject, String name) {
Optional<Set<GlitrMetaDefinition>> metaDefinitions = Optional.ofNullable(graphQlObject)
.map(GraphQLFieldDefinition::getDefinition)
.filter(x -> x instanceof GlitrFieldDefinition)
.map(x -> ((GlitrFieldDefinition)x).getMetaDefinitions())
.filter(CollectionUtils::isNotEmpty);
if (metaDefinitions.isPresent()) {
return metaDefinitions.get().stream()
.filter(metaDefinition -> name.equals(metaDefinition.getName()))
.findFirst()
.map(metaDefinition -> (T) metaDefinition.getValue())
.orElse(null);
}
return null;
}
private boolean isConnectionNode(GraphQLFieldDefinition graphQlObject, String name) {
if (graphQlObject == null) {
return false;
}
GraphQLType objType = graphQlObject.getType();
|
// Path: src/main/java/com/nfl/glitr/exception/GlitrException.java
// public class GlitrException extends RuntimeException {
//
// public GlitrException(String message) {
// super(message);
// }
//
// public GlitrException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrFieldDefinition.java
// public class GlitrFieldDefinition extends FieldDefinition {
//
// private Set<GlitrMetaDefinition> metaDefinitions = new HashSet<>();
//
//
// public GlitrFieldDefinition(String name, Type type) {
// super(name, type);
// }
//
// public GlitrFieldDefinition(String name, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, null);
// this.metaDefinitions = metaDefinitions;
// }
//
// public GlitrFieldDefinition(String name, Type type, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, type);
// this.metaDefinitions = metaDefinitions;
// }
//
// public Set<GlitrMetaDefinition> getMetaDefinitions() {
// return metaDefinitions;
// }
//
// public void setMetaDefinitions(Set<GlitrMetaDefinition> metaDefinitions) {
// this.metaDefinitions = metaDefinitions;
// }
//
// public void addMetaDefinitions(GlitrMetaDefinition metaDefinition) {
// if (this.metaDefinitions == null) {
// this.metaDefinitions = new HashSet<>();
// }
// this.metaDefinitions.add(metaDefinition);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrMetaDefinition.java
// public class GlitrMetaDefinition {
//
// private String name;
// private Object value;
//
//
// public GlitrMetaDefinition(String name, Object value) {
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
//
// if (o == null || getClass() != o.getClass()) return false;
//
// GlitrMetaDefinition that = (GlitrMetaDefinition) o;
//
// return new EqualsBuilder()
// .append(name, that.name)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder(17, 37)
// .append(name)
// .toHashCode();
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GraphQLConnectionList.java
// public class GraphQLConnectionList extends GraphQLList {
// public GraphQLConnectionList(GraphQLType wrappedType) {
// super(wrappedType);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/util/NodeUtil.java
// public static final String COMPLEXITY_FORMULA_KEY = "complexity_formula";
//
// Path: src/main/java/com/nfl/glitr/util/NodeUtil.java
// public static final String COMPLEXITY_IGNORE_KEY = "complexity_ignore";
// Path: src/main/java/com/nfl/glitr/calculator/QueryComplexityCalculator.java
import com.nfl.glitr.exception.GlitrException;
import com.nfl.glitr.registry.schema.GlitrFieldDefinition;
import com.nfl.glitr.registry.schema.GlitrMetaDefinition;
import com.nfl.glitr.registry.schema.GraphQLConnectionList;
import graphql.language.*;
import graphql.parser.InvalidSyntaxException;
import graphql.parser.Parser;
import graphql.parser.antlr.GraphqlLexer;
import graphql.schema.*;
import net.objecthunter.exp4j.Expression;
import net.objecthunter.exp4j.ExpressionBuilder;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonToken;
import org.antlr.v4.runtime.InputMismatchException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.nfl.glitr.util.NodeUtil.COMPLEXITY_FORMULA_KEY;
import static com.nfl.glitr.util.NodeUtil.COMPLEXITY_IGNORE_KEY;
import static org.apache.commons.lang3.StringUtils.defaultString;
return (collectionSize * defaultMultiplier) + childScores;
} else {
return currentNodeScore + childScores;
}
}
private <T> T getGraphQLMeta(GraphQLFieldDefinition graphQlObject, String name) {
Optional<Set<GlitrMetaDefinition>> metaDefinitions = Optional.ofNullable(graphQlObject)
.map(GraphQLFieldDefinition::getDefinition)
.filter(x -> x instanceof GlitrFieldDefinition)
.map(x -> ((GlitrFieldDefinition)x).getMetaDefinitions())
.filter(CollectionUtils::isNotEmpty);
if (metaDefinitions.isPresent()) {
return metaDefinitions.get().stream()
.filter(metaDefinition -> name.equals(metaDefinition.getName()))
.findFirst()
.map(metaDefinition -> (T) metaDefinition.getValue())
.orElse(null);
}
return null;
}
private boolean isConnectionNode(GraphQLFieldDefinition graphQlObject, String name) {
if (graphQlObject == null) {
return false;
}
GraphQLType objType = graphQlObject.getType();
|
if (objType instanceof GraphQLConnectionList) {
|
nfl/glitr
|
src/main/java/com/nfl/glitr/calculator/QueryComplexityCalculator.java
|
// Path: src/main/java/com/nfl/glitr/exception/GlitrException.java
// public class GlitrException extends RuntimeException {
//
// public GlitrException(String message) {
// super(message);
// }
//
// public GlitrException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrFieldDefinition.java
// public class GlitrFieldDefinition extends FieldDefinition {
//
// private Set<GlitrMetaDefinition> metaDefinitions = new HashSet<>();
//
//
// public GlitrFieldDefinition(String name, Type type) {
// super(name, type);
// }
//
// public GlitrFieldDefinition(String name, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, null);
// this.metaDefinitions = metaDefinitions;
// }
//
// public GlitrFieldDefinition(String name, Type type, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, type);
// this.metaDefinitions = metaDefinitions;
// }
//
// public Set<GlitrMetaDefinition> getMetaDefinitions() {
// return metaDefinitions;
// }
//
// public void setMetaDefinitions(Set<GlitrMetaDefinition> metaDefinitions) {
// this.metaDefinitions = metaDefinitions;
// }
//
// public void addMetaDefinitions(GlitrMetaDefinition metaDefinition) {
// if (this.metaDefinitions == null) {
// this.metaDefinitions = new HashSet<>();
// }
// this.metaDefinitions.add(metaDefinition);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrMetaDefinition.java
// public class GlitrMetaDefinition {
//
// private String name;
// private Object value;
//
//
// public GlitrMetaDefinition(String name, Object value) {
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
//
// if (o == null || getClass() != o.getClass()) return false;
//
// GlitrMetaDefinition that = (GlitrMetaDefinition) o;
//
// return new EqualsBuilder()
// .append(name, that.name)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder(17, 37)
// .append(name)
// .toHashCode();
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GraphQLConnectionList.java
// public class GraphQLConnectionList extends GraphQLList {
// public GraphQLConnectionList(GraphQLType wrappedType) {
// super(wrappedType);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/util/NodeUtil.java
// public static final String COMPLEXITY_FORMULA_KEY = "complexity_formula";
//
// Path: src/main/java/com/nfl/glitr/util/NodeUtil.java
// public static final String COMPLEXITY_IGNORE_KEY = "complexity_ignore";
|
import com.nfl.glitr.exception.GlitrException;
import com.nfl.glitr.registry.schema.GlitrFieldDefinition;
import com.nfl.glitr.registry.schema.GlitrMetaDefinition;
import com.nfl.glitr.registry.schema.GraphQLConnectionList;
import graphql.language.*;
import graphql.parser.InvalidSyntaxException;
import graphql.parser.Parser;
import graphql.parser.antlr.GraphqlLexer;
import graphql.schema.*;
import net.objecthunter.exp4j.Expression;
import net.objecthunter.exp4j.ExpressionBuilder;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonToken;
import org.antlr.v4.runtime.InputMismatchException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.nfl.glitr.util.NodeUtil.COMPLEXITY_FORMULA_KEY;
import static com.nfl.glitr.util.NodeUtil.COMPLEXITY_IGNORE_KEY;
import static org.apache.commons.lang3.StringUtils.defaultString;
|
if (type.isAssignableFrom(o.getClass())) {
return Optional.of((T) o);
}
}
return Optional.empty();
}
@SuppressWarnings("unchecked")
private <T> List<T> getByType(Collection collection, Class<T> type) {
List<T> res = new ArrayList<>();
for (Object o : collection) {
if (type.isAssignableFrom(o.getClass())) {
res.add((T) o);
}
}
return res;
}
private Field getFirstFieldNode(OperationDefinition rootNode) {
return (Field) Optional.ofNullable(rootNode)
.map(OperationDefinition::getChildren)
.filter(CollectionUtils::isNotEmpty)
.flatMap(nodes -> nodes.stream().filter(node -> node instanceof SelectionSet).findFirst())
.map(Node::getChildren)
.filter(CollectionUtils::isNotEmpty)
.flatMap(nodes -> nodes.stream().filter(node -> node instanceof Field).findFirst())
.orElse(null);
}
private boolean ignoreFieldOrDefault(GraphQLFieldDefinition field, boolean defaultValue) {
|
// Path: src/main/java/com/nfl/glitr/exception/GlitrException.java
// public class GlitrException extends RuntimeException {
//
// public GlitrException(String message) {
// super(message);
// }
//
// public GlitrException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrFieldDefinition.java
// public class GlitrFieldDefinition extends FieldDefinition {
//
// private Set<GlitrMetaDefinition> metaDefinitions = new HashSet<>();
//
//
// public GlitrFieldDefinition(String name, Type type) {
// super(name, type);
// }
//
// public GlitrFieldDefinition(String name, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, null);
// this.metaDefinitions = metaDefinitions;
// }
//
// public GlitrFieldDefinition(String name, Type type, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, type);
// this.metaDefinitions = metaDefinitions;
// }
//
// public Set<GlitrMetaDefinition> getMetaDefinitions() {
// return metaDefinitions;
// }
//
// public void setMetaDefinitions(Set<GlitrMetaDefinition> metaDefinitions) {
// this.metaDefinitions = metaDefinitions;
// }
//
// public void addMetaDefinitions(GlitrMetaDefinition metaDefinition) {
// if (this.metaDefinitions == null) {
// this.metaDefinitions = new HashSet<>();
// }
// this.metaDefinitions.add(metaDefinition);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrMetaDefinition.java
// public class GlitrMetaDefinition {
//
// private String name;
// private Object value;
//
//
// public GlitrMetaDefinition(String name, Object value) {
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
//
// if (o == null || getClass() != o.getClass()) return false;
//
// GlitrMetaDefinition that = (GlitrMetaDefinition) o;
//
// return new EqualsBuilder()
// .append(name, that.name)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder(17, 37)
// .append(name)
// .toHashCode();
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GraphQLConnectionList.java
// public class GraphQLConnectionList extends GraphQLList {
// public GraphQLConnectionList(GraphQLType wrappedType) {
// super(wrappedType);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/util/NodeUtil.java
// public static final String COMPLEXITY_FORMULA_KEY = "complexity_formula";
//
// Path: src/main/java/com/nfl/glitr/util/NodeUtil.java
// public static final String COMPLEXITY_IGNORE_KEY = "complexity_ignore";
// Path: src/main/java/com/nfl/glitr/calculator/QueryComplexityCalculator.java
import com.nfl.glitr.exception.GlitrException;
import com.nfl.glitr.registry.schema.GlitrFieldDefinition;
import com.nfl.glitr.registry.schema.GlitrMetaDefinition;
import com.nfl.glitr.registry.schema.GraphQLConnectionList;
import graphql.language.*;
import graphql.parser.InvalidSyntaxException;
import graphql.parser.Parser;
import graphql.parser.antlr.GraphqlLexer;
import graphql.schema.*;
import net.objecthunter.exp4j.Expression;
import net.objecthunter.exp4j.ExpressionBuilder;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonToken;
import org.antlr.v4.runtime.InputMismatchException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.nfl.glitr.util.NodeUtil.COMPLEXITY_FORMULA_KEY;
import static com.nfl.glitr.util.NodeUtil.COMPLEXITY_IGNORE_KEY;
import static org.apache.commons.lang3.StringUtils.defaultString;
if (type.isAssignableFrom(o.getClass())) {
return Optional.of((T) o);
}
}
return Optional.empty();
}
@SuppressWarnings("unchecked")
private <T> List<T> getByType(Collection collection, Class<T> type) {
List<T> res = new ArrayList<>();
for (Object o : collection) {
if (type.isAssignableFrom(o.getClass())) {
res.add((T) o);
}
}
return res;
}
private Field getFirstFieldNode(OperationDefinition rootNode) {
return (Field) Optional.ofNullable(rootNode)
.map(OperationDefinition::getChildren)
.filter(CollectionUtils::isNotEmpty)
.flatMap(nodes -> nodes.stream().filter(node -> node instanceof SelectionSet).findFirst())
.map(Node::getChildren)
.filter(CollectionUtils::isNotEmpty)
.flatMap(nodes -> nodes.stream().filter(node -> node instanceof Field).findFirst())
.orElse(null);
}
private boolean ignoreFieldOrDefault(GraphQLFieldDefinition field, boolean defaultValue) {
|
Boolean ignore = getGraphQLMeta(field, COMPLEXITY_IGNORE_KEY);
|
nfl/glitr
|
src/main/java/com/nfl/glitr/registry/datafetcher/query/OverrideDataFetcher.java
|
// Path: src/main/java/com/nfl/glitr/exception/GlitrException.java
// public class GlitrException extends RuntimeException {
//
// public GlitrException(String message) {
// super(message);
// }
//
// public GlitrException(String message, Throwable cause) {
// super(message, cause);
// }
// }
|
import com.nfl.glitr.exception.GlitrException;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
|
package com.nfl.glitr.registry.datafetcher.query;
public class OverrideDataFetcher implements DataFetcher {
private static final Logger logger = LoggerFactory.getLogger(OverrideDataFetcher.class);
private Object override;
private Method overrideMethod;
/**
* This constructor is used for getter overrides placed in the class itself
*
* @param name field name
* @param clazz schema class
*/
public OverrideDataFetcher(String name, Class clazz) {
overrideMethod = findMethod("get" + StringUtils.capitalize(name), clazz);
if (overrideMethod != null) {
return;
}
overrideMethod = findMethod("is" + StringUtils.capitalize(name), clazz);
}
/**
* This constructor is used for getter overrides outside of the reference class
*
* @param name field name
* @param override override object
*/
public OverrideDataFetcher(String name, Object override) {
this(name, override.getClass());
this.override = override;
}
@Override
public Object get(DataFetchingEnvironment environment) {
if (overrideMethod == null) {
return null;
}
Object obj = override == null ? environment.getSource() : override;
try {
return overrideMethod.invoke(obj, environment);
} catch (InvocationTargetException e) {
// If the override method threw a RuntimeException just send it up
if (e.getTargetException() instanceof RuntimeException) {
logger.debug("Something went wrong - Unable to fetch result for overrideMethod={{}} of {}", overrideMethod.getName(), obj.getClass().getSimpleName(), e.getTargetException());
throw (RuntimeException) e.getTargetException();
}
// Otherwise, wrap it up in a Glitr Exception
logger.debug("Something went wrong - Unable to fetch result for overrideMethod={{}} of {}", overrideMethod.getName(), obj.getClass().getSimpleName());
|
// Path: src/main/java/com/nfl/glitr/exception/GlitrException.java
// public class GlitrException extends RuntimeException {
//
// public GlitrException(String message) {
// super(message);
// }
//
// public GlitrException(String message, Throwable cause) {
// super(message, cause);
// }
// }
// Path: src/main/java/com/nfl/glitr/registry/datafetcher/query/OverrideDataFetcher.java
import com.nfl.glitr.exception.GlitrException;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
package com.nfl.glitr.registry.datafetcher.query;
public class OverrideDataFetcher implements DataFetcher {
private static final Logger logger = LoggerFactory.getLogger(OverrideDataFetcher.class);
private Object override;
private Method overrideMethod;
/**
* This constructor is used for getter overrides placed in the class itself
*
* @param name field name
* @param clazz schema class
*/
public OverrideDataFetcher(String name, Class clazz) {
overrideMethod = findMethod("get" + StringUtils.capitalize(name), clazz);
if (overrideMethod != null) {
return;
}
overrideMethod = findMethod("is" + StringUtils.capitalize(name), clazz);
}
/**
* This constructor is used for getter overrides outside of the reference class
*
* @param name field name
* @param override override object
*/
public OverrideDataFetcher(String name, Object override) {
this(name, override.getClass());
this.override = override;
}
@Override
public Object get(DataFetchingEnvironment environment) {
if (overrideMethod == null) {
return null;
}
Object obj = override == null ? environment.getSource() : override;
try {
return overrideMethod.invoke(obj, environment);
} catch (InvocationTargetException e) {
// If the override method threw a RuntimeException just send it up
if (e.getTargetException() instanceof RuntimeException) {
logger.debug("Something went wrong - Unable to fetch result for overrideMethod={{}} of {}", overrideMethod.getName(), obj.getClass().getSimpleName(), e.getTargetException());
throw (RuntimeException) e.getTargetException();
}
// Otherwise, wrap it up in a Glitr Exception
logger.debug("Something went wrong - Unable to fetch result for overrideMethod={{}} of {}", overrideMethod.getName(), obj.getClass().getSimpleName());
|
throw new GlitrException("Overwrite method exception", e.getTargetException());
|
nfl/glitr
|
src/test/groovy/com/nfl/glitr/data/mutation/MutationType.java
|
// Path: src/main/java/com/nfl/glitr/registry/mutation/RelayMutation.java
// public interface RelayMutation<I extends RelayMutationType, R extends RelayMutationType> {
//
// R call(I input, DataFetchingEnvironment env);
// }
//
// Path: src/main/java/com/nfl/glitr/registry/mutation/RelayMutationDataFetcher.java
// public class RelayMutationDataFetcher implements DataFetcher {
//
// @SuppressWarnings("unused")
// private static final Logger logger = LoggerFactory.getLogger(RelayMutationDataFetcher.class);
//
// private final Class mutationInputClass;
// private final Validator validator;
// private final RelayMutation mutationFunc;
//
//
// public RelayMutationDataFetcher(Class mutationInputClass, RelayMutation mutationFunc) {
// this(mutationInputClass, mutationFunc, null);
// }
//
//
// public RelayMutationDataFetcher(Class mutationInputClass, RelayMutation mutationFunc, @Nullable Validator validator) {
// this.mutationInputClass = mutationInputClass;
// this.validator = validator;
// this.mutationFunc = mutationFunc;
// }
//
// @Override
// @SuppressWarnings("unchecked")
// public Object get(DataFetchingEnvironment env) {
// Map<String, Object> inputMap = env.getArgument("input");
//
// // map fields from input map to mutationInputClass
// Object inputPayloadMtn = Glitr.getObjectMapper().convertValue(inputMap, mutationInputClass);
// // apply some validation on inputPayloadMtn (should validation be in the mutationFunc instead?)
// validate(inputPayloadMtn);
// // mutate and return output
// RelayMutationType mutationOutput = mutationFunc.call((RelayMutationType) inputPayloadMtn, env);
// // set the client mutation id
// mutationOutput.setClientMutationId((String) inputMap.get("clientMutationId"));
//
// return mutationOutput;
// }
//
// private void validate(Object inputPayloadMtn) {
// if (validator == null) {
// return;
// }
//
// Set<ConstraintViolation<Object>> errors = validator.validate(inputPayloadMtn);
// if (!errors.isEmpty()) {
// throw new GlitrValidationException("Error validating input mutation.", errors);
// }
// }
// }
|
import com.nfl.glitr.annotation.GlitrArgument;
import com.nfl.glitr.annotation.GlitrArguments;
import com.nfl.glitr.annotation.GlitrDescription;
import com.nfl.glitr.registry.mutation.RelayMutation;
import com.nfl.glitr.registry.mutation.RelayMutationDataFetcher;
import graphql.schema.DataFetchingEnvironment;
|
package com.nfl.glitr.data.mutation;
public class MutationType {
@GlitrDescription("Saves Info related to a video")
@GlitrArguments({@GlitrArgument(name = "input", type = VideoMutationInput.class, required = true, defaultValue = "{default input}")})
public VideoMutationPayload getSaveVideoInfoMutation(DataFetchingEnvironment env) {
SaveVideoInfo saveVideoInfo = new SaveVideoInfo();
|
// Path: src/main/java/com/nfl/glitr/registry/mutation/RelayMutation.java
// public interface RelayMutation<I extends RelayMutationType, R extends RelayMutationType> {
//
// R call(I input, DataFetchingEnvironment env);
// }
//
// Path: src/main/java/com/nfl/glitr/registry/mutation/RelayMutationDataFetcher.java
// public class RelayMutationDataFetcher implements DataFetcher {
//
// @SuppressWarnings("unused")
// private static final Logger logger = LoggerFactory.getLogger(RelayMutationDataFetcher.class);
//
// private final Class mutationInputClass;
// private final Validator validator;
// private final RelayMutation mutationFunc;
//
//
// public RelayMutationDataFetcher(Class mutationInputClass, RelayMutation mutationFunc) {
// this(mutationInputClass, mutationFunc, null);
// }
//
//
// public RelayMutationDataFetcher(Class mutationInputClass, RelayMutation mutationFunc, @Nullable Validator validator) {
// this.mutationInputClass = mutationInputClass;
// this.validator = validator;
// this.mutationFunc = mutationFunc;
// }
//
// @Override
// @SuppressWarnings("unchecked")
// public Object get(DataFetchingEnvironment env) {
// Map<String, Object> inputMap = env.getArgument("input");
//
// // map fields from input map to mutationInputClass
// Object inputPayloadMtn = Glitr.getObjectMapper().convertValue(inputMap, mutationInputClass);
// // apply some validation on inputPayloadMtn (should validation be in the mutationFunc instead?)
// validate(inputPayloadMtn);
// // mutate and return output
// RelayMutationType mutationOutput = mutationFunc.call((RelayMutationType) inputPayloadMtn, env);
// // set the client mutation id
// mutationOutput.setClientMutationId((String) inputMap.get("clientMutationId"));
//
// return mutationOutput;
// }
//
// private void validate(Object inputPayloadMtn) {
// if (validator == null) {
// return;
// }
//
// Set<ConstraintViolation<Object>> errors = validator.validate(inputPayloadMtn);
// if (!errors.isEmpty()) {
// throw new GlitrValidationException("Error validating input mutation.", errors);
// }
// }
// }
// Path: src/test/groovy/com/nfl/glitr/data/mutation/MutationType.java
import com.nfl.glitr.annotation.GlitrArgument;
import com.nfl.glitr.annotation.GlitrArguments;
import com.nfl.glitr.annotation.GlitrDescription;
import com.nfl.glitr.registry.mutation.RelayMutation;
import com.nfl.glitr.registry.mutation.RelayMutationDataFetcher;
import graphql.schema.DataFetchingEnvironment;
package com.nfl.glitr.data.mutation;
public class MutationType {
@GlitrDescription("Saves Info related to a video")
@GlitrArguments({@GlitrArgument(name = "input", type = VideoMutationInput.class, required = true, defaultValue = "{default input}")})
public VideoMutationPayload getSaveVideoInfoMutation(DataFetchingEnvironment env) {
SaveVideoInfo saveVideoInfo = new SaveVideoInfo();
|
RelayMutationDataFetcher relayMutationDataFetcher = new RelayMutationDataFetcher(VideoMutationInput.class, saveVideoInfo);
|
nfl/glitr
|
src/test/groovy/com/nfl/glitr/data/mutation/MutationType.java
|
// Path: src/main/java/com/nfl/glitr/registry/mutation/RelayMutation.java
// public interface RelayMutation<I extends RelayMutationType, R extends RelayMutationType> {
//
// R call(I input, DataFetchingEnvironment env);
// }
//
// Path: src/main/java/com/nfl/glitr/registry/mutation/RelayMutationDataFetcher.java
// public class RelayMutationDataFetcher implements DataFetcher {
//
// @SuppressWarnings("unused")
// private static final Logger logger = LoggerFactory.getLogger(RelayMutationDataFetcher.class);
//
// private final Class mutationInputClass;
// private final Validator validator;
// private final RelayMutation mutationFunc;
//
//
// public RelayMutationDataFetcher(Class mutationInputClass, RelayMutation mutationFunc) {
// this(mutationInputClass, mutationFunc, null);
// }
//
//
// public RelayMutationDataFetcher(Class mutationInputClass, RelayMutation mutationFunc, @Nullable Validator validator) {
// this.mutationInputClass = mutationInputClass;
// this.validator = validator;
// this.mutationFunc = mutationFunc;
// }
//
// @Override
// @SuppressWarnings("unchecked")
// public Object get(DataFetchingEnvironment env) {
// Map<String, Object> inputMap = env.getArgument("input");
//
// // map fields from input map to mutationInputClass
// Object inputPayloadMtn = Glitr.getObjectMapper().convertValue(inputMap, mutationInputClass);
// // apply some validation on inputPayloadMtn (should validation be in the mutationFunc instead?)
// validate(inputPayloadMtn);
// // mutate and return output
// RelayMutationType mutationOutput = mutationFunc.call((RelayMutationType) inputPayloadMtn, env);
// // set the client mutation id
// mutationOutput.setClientMutationId((String) inputMap.get("clientMutationId"));
//
// return mutationOutput;
// }
//
// private void validate(Object inputPayloadMtn) {
// if (validator == null) {
// return;
// }
//
// Set<ConstraintViolation<Object>> errors = validator.validate(inputPayloadMtn);
// if (!errors.isEmpty()) {
// throw new GlitrValidationException("Error validating input mutation.", errors);
// }
// }
// }
|
import com.nfl.glitr.annotation.GlitrArgument;
import com.nfl.glitr.annotation.GlitrArguments;
import com.nfl.glitr.annotation.GlitrDescription;
import com.nfl.glitr.registry.mutation.RelayMutation;
import com.nfl.glitr.registry.mutation.RelayMutationDataFetcher;
import graphql.schema.DataFetchingEnvironment;
|
package com.nfl.glitr.data.mutation;
public class MutationType {
@GlitrDescription("Saves Info related to a video")
@GlitrArguments({@GlitrArgument(name = "input", type = VideoMutationInput.class, required = true, defaultValue = "{default input}")})
public VideoMutationPayload getSaveVideoInfoMutation(DataFetchingEnvironment env) {
SaveVideoInfo saveVideoInfo = new SaveVideoInfo();
RelayMutationDataFetcher relayMutationDataFetcher = new RelayMutationDataFetcher(VideoMutationInput.class, saveVideoInfo);
return (VideoMutationPayload) relayMutationDataFetcher.get(env);
}
|
// Path: src/main/java/com/nfl/glitr/registry/mutation/RelayMutation.java
// public interface RelayMutation<I extends RelayMutationType, R extends RelayMutationType> {
//
// R call(I input, DataFetchingEnvironment env);
// }
//
// Path: src/main/java/com/nfl/glitr/registry/mutation/RelayMutationDataFetcher.java
// public class RelayMutationDataFetcher implements DataFetcher {
//
// @SuppressWarnings("unused")
// private static final Logger logger = LoggerFactory.getLogger(RelayMutationDataFetcher.class);
//
// private final Class mutationInputClass;
// private final Validator validator;
// private final RelayMutation mutationFunc;
//
//
// public RelayMutationDataFetcher(Class mutationInputClass, RelayMutation mutationFunc) {
// this(mutationInputClass, mutationFunc, null);
// }
//
//
// public RelayMutationDataFetcher(Class mutationInputClass, RelayMutation mutationFunc, @Nullable Validator validator) {
// this.mutationInputClass = mutationInputClass;
// this.validator = validator;
// this.mutationFunc = mutationFunc;
// }
//
// @Override
// @SuppressWarnings("unchecked")
// public Object get(DataFetchingEnvironment env) {
// Map<String, Object> inputMap = env.getArgument("input");
//
// // map fields from input map to mutationInputClass
// Object inputPayloadMtn = Glitr.getObjectMapper().convertValue(inputMap, mutationInputClass);
// // apply some validation on inputPayloadMtn (should validation be in the mutationFunc instead?)
// validate(inputPayloadMtn);
// // mutate and return output
// RelayMutationType mutationOutput = mutationFunc.call((RelayMutationType) inputPayloadMtn, env);
// // set the client mutation id
// mutationOutput.setClientMutationId((String) inputMap.get("clientMutationId"));
//
// return mutationOutput;
// }
//
// private void validate(Object inputPayloadMtn) {
// if (validator == null) {
// return;
// }
//
// Set<ConstraintViolation<Object>> errors = validator.validate(inputPayloadMtn);
// if (!errors.isEmpty()) {
// throw new GlitrValidationException("Error validating input mutation.", errors);
// }
// }
// }
// Path: src/test/groovy/com/nfl/glitr/data/mutation/MutationType.java
import com.nfl.glitr.annotation.GlitrArgument;
import com.nfl.glitr.annotation.GlitrArguments;
import com.nfl.glitr.annotation.GlitrDescription;
import com.nfl.glitr.registry.mutation.RelayMutation;
import com.nfl.glitr.registry.mutation.RelayMutationDataFetcher;
import graphql.schema.DataFetchingEnvironment;
package com.nfl.glitr.data.mutation;
public class MutationType {
@GlitrDescription("Saves Info related to a video")
@GlitrArguments({@GlitrArgument(name = "input", type = VideoMutationInput.class, required = true, defaultValue = "{default input}")})
public VideoMutationPayload getSaveVideoInfoMutation(DataFetchingEnvironment env) {
SaveVideoInfo saveVideoInfo = new SaveVideoInfo();
RelayMutationDataFetcher relayMutationDataFetcher = new RelayMutationDataFetcher(VideoMutationInput.class, saveVideoInfo);
return (VideoMutationPayload) relayMutationDataFetcher.get(env);
}
|
class SaveVideoInfo implements RelayMutation<VideoMutationInput, VideoMutationPayload> {
|
nfl/glitr
|
src/test/groovy/com/nfl/glitr/registry/type/Test.java
|
// Path: src/test/groovy/com/nfl/glitr/data/mutation/Bitrate.java
// public class Bitrate implements Playable {
//
// private String id;
// private Integer kbps;
// private String url;
// private Integer[] frames;
// private Float gradeAverage;
// private Double grade;
// private Long durationNanos;
// private Boolean valid;
// private LocalDate createdDate;
// private Instant modifiedDateTime;
//
//
// public Integer getKbps() {
// return kbps;
// }
//
// public String getUrl() {
// return url;
// }
//
// public Long getDurationNanos() {
// return durationNanos;
// }
//
// public Integer[] getFrames() {
// return frames;
// }
//
// public Double getGrade() {
// return grade;
// }
//
// public Float getGradeAverage() {
// return gradeAverage;
// }
//
// public Boolean getValid() {
// return valid;
// }
//
// public LocalDate getCreatedDate() {
// return createdDate;
// }
//
// public Instant getModifiedDateTime() {
// return modifiedDateTime;
// }
//
// @Override
// public String getId() {
// return id;
// }
// }
|
import com.nfl.glitr.data.mutation.Bitrate;
|
package com.nfl.glitr.registry.type;
public class Test {
private String id;
private String url;
|
// Path: src/test/groovy/com/nfl/glitr/data/mutation/Bitrate.java
// public class Bitrate implements Playable {
//
// private String id;
// private Integer kbps;
// private String url;
// private Integer[] frames;
// private Float gradeAverage;
// private Double grade;
// private Long durationNanos;
// private Boolean valid;
// private LocalDate createdDate;
// private Instant modifiedDateTime;
//
//
// public Integer getKbps() {
// return kbps;
// }
//
// public String getUrl() {
// return url;
// }
//
// public Long getDurationNanos() {
// return durationNanos;
// }
//
// public Integer[] getFrames() {
// return frames;
// }
//
// public Double getGrade() {
// return grade;
// }
//
// public Float getGradeAverage() {
// return gradeAverage;
// }
//
// public Boolean getValid() {
// return valid;
// }
//
// public LocalDate getCreatedDate() {
// return createdDate;
// }
//
// public Instant getModifiedDateTime() {
// return modifiedDateTime;
// }
//
// @Override
// public String getId() {
// return id;
// }
// }
// Path: src/test/groovy/com/nfl/glitr/registry/type/Test.java
import com.nfl.glitr.data.mutation.Bitrate;
package com.nfl.glitr.registry.type;
public class Test {
private String id;
private String url;
|
private Bitrate bitrate;
|
nfl/glitr
|
src/main/java/com/nfl/glitr/registry/mutation/RelayMutationDataFetcher.java
|
// Path: src/main/java/com/nfl/glitr/Glitr.java
// public class Glitr {
//
// private final TypeRegistry typeRegistry;
// private final GraphQLCodeRegistry.Builder codeRegistryBuilder;
// private final RelayHelper relayHelper;
// private GraphQLSchema schema;
// private QueryComplexityCalculator queryComplexityCalculator;
// private static ObjectMapper objectMapper;
//
//
// public Glitr(TypeRegistry typeRegistry,
// GraphQLCodeRegistry.Builder codeRegistryBuilder,
// Class queryRoot,
// @Nullable GraphqlFieldVisibility fieldVisibility,
// @Nullable ObjectMapper objectMapper,
// @Nullable Class mutationRoot,
// @Nullable Class subscriptionRoot,
// @Nullable QueryComplexityCalculator queryComplexityCalculator) {
// this(typeRegistry, codeRegistryBuilder, queryRoot, fieldVisibility, objectMapper, null, mutationRoot, subscriptionRoot, queryComplexityCalculator);
// }
//
// public Glitr(TypeRegistry typeRegistry,
// GraphQLCodeRegistry.Builder codeRegistryBuilder,
// Class queryRoot,
// @Nullable GraphqlFieldVisibility fieldVisibility,
// @Nullable ObjectMapper objectMapper,
// @Nullable RelayHelper relayHelper,
// @Nullable Class mutationRoot,
// @Nullable Class subscriptionRoot,
// @Nullable QueryComplexityCalculator queryComplexityCalculator) {
// this.codeRegistryBuilder = assertNotNull(codeRegistryBuilder, "codeRegistryBuilder can't be null");
// this.typeRegistry = assertNotNull(typeRegistry, "TypeRegistry can't be null");
// assertNotNull(queryRoot, "queryRoot class can't be null");
// this.relayHelper = relayHelper;
//
// Glitr.objectMapper = objectMapper;
// this.schema = buildSchema(queryRoot, mutationRoot, subscriptionRoot, fieldVisibility);
//
// if (nonNull(queryComplexityCalculator)) {
// this.queryComplexityCalculator = queryComplexityCalculator.withSchema(this.schema);
// }
// }
//
// public TypeRegistry getTypeRegistry() {
// return typeRegistry;
// }
//
// @Nullable
// public QueryComplexityCalculator getQueryComplexityCalculator() {
// return queryComplexityCalculator;
// }
//
// @Nullable
// public RelayHelper getRelayHelper() {
// return relayHelper;
// }
//
// public GraphQLSchema getSchema() {
// return schema;
// }
//
// public static ObjectMapper getObjectMapper() {
// if (objectMapper == null) {
// throw new RuntimeException("Serialization Impossible. Can't find an ObjectMapper implementation. Please configure GLiTR to use an ObjectMapper.");
// }
// return objectMapper;
// }
//
// private GraphQLSchema buildSchema(Class queryRoot, Class mutationRoot, Class subscriptionRoot, GraphqlFieldVisibility fieldVisibility) {
// // create GraphQL Schema
// GraphQLObjectType mutationType = null;
// if (mutationRoot != null) {
// mutationType = typeRegistry.createRelayMutationType(mutationRoot);
// }
// GraphQLObjectType subscriptionType = null;
// if (subscriptionRoot != null) {
// subscriptionType = (GraphQLObjectType) typeRegistry.lookup(subscriptionRoot);
// }
// GraphQLObjectType queryType = (GraphQLObjectType) typeRegistry.lookup(queryRoot);
//
// if (fieldVisibility != null) {
// codeRegistryBuilder.fieldVisibility(fieldVisibility);
//
// return GraphQLSchema.newSchema()
// .query(queryType)
// .mutation(mutationType)
// .subscription(subscriptionType)
// .additionalTypes(typeRegistry.getTypeDictionary())
// .codeRegistry(codeRegistryBuilder.build())
// .build();
// }
//
// return GraphQLSchema.newSchema()
// .query(queryType)
// .mutation(mutationType)
// .subscription(subscriptionType)
// .additionalTypes(typeRegistry.getTypeDictionary())
// .codeRegistry(codeRegistryBuilder.build())
// .build();
// }
//
// public GraphQLSchema reloadSchema(Class queryRoot, Class mutationRoot, Class subscriptionRoot, GraphqlFieldVisibility fieldVisibility) {
// this.schema = buildSchema(queryRoot, mutationRoot, subscriptionRoot, fieldVisibility);
// return this.schema;
// }
// }
//
// Path: src/main/java/com/nfl/glitr/exception/GlitrValidationException.java
// public class GlitrValidationException extends GlitrException {
//
// private final Set<ConstraintViolation<Object>> violations;
//
//
// public GlitrValidationException(String message, Set<ConstraintViolation<Object>> violations) {
// super(message);
// this.violations = violations;
// }
//
// public Set<ConstraintViolation<Object>> getViolations() {
// return violations;
// }
// }
|
import com.nfl.glitr.Glitr;
import com.nfl.glitr.exception.GlitrValidationException;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import java.util.Map;
import java.util.Set;
|
package com.nfl.glitr.registry.mutation;
/**
* DataFetcher used when GraphQL operation is a mutation
*/
public class RelayMutationDataFetcher implements DataFetcher {
@SuppressWarnings("unused")
private static final Logger logger = LoggerFactory.getLogger(RelayMutationDataFetcher.class);
private final Class mutationInputClass;
private final Validator validator;
private final RelayMutation mutationFunc;
public RelayMutationDataFetcher(Class mutationInputClass, RelayMutation mutationFunc) {
this(mutationInputClass, mutationFunc, null);
}
public RelayMutationDataFetcher(Class mutationInputClass, RelayMutation mutationFunc, @Nullable Validator validator) {
this.mutationInputClass = mutationInputClass;
this.validator = validator;
this.mutationFunc = mutationFunc;
}
@Override
@SuppressWarnings("unchecked")
public Object get(DataFetchingEnvironment env) {
Map<String, Object> inputMap = env.getArgument("input");
// map fields from input map to mutationInputClass
|
// Path: src/main/java/com/nfl/glitr/Glitr.java
// public class Glitr {
//
// private final TypeRegistry typeRegistry;
// private final GraphQLCodeRegistry.Builder codeRegistryBuilder;
// private final RelayHelper relayHelper;
// private GraphQLSchema schema;
// private QueryComplexityCalculator queryComplexityCalculator;
// private static ObjectMapper objectMapper;
//
//
// public Glitr(TypeRegistry typeRegistry,
// GraphQLCodeRegistry.Builder codeRegistryBuilder,
// Class queryRoot,
// @Nullable GraphqlFieldVisibility fieldVisibility,
// @Nullable ObjectMapper objectMapper,
// @Nullable Class mutationRoot,
// @Nullable Class subscriptionRoot,
// @Nullable QueryComplexityCalculator queryComplexityCalculator) {
// this(typeRegistry, codeRegistryBuilder, queryRoot, fieldVisibility, objectMapper, null, mutationRoot, subscriptionRoot, queryComplexityCalculator);
// }
//
// public Glitr(TypeRegistry typeRegistry,
// GraphQLCodeRegistry.Builder codeRegistryBuilder,
// Class queryRoot,
// @Nullable GraphqlFieldVisibility fieldVisibility,
// @Nullable ObjectMapper objectMapper,
// @Nullable RelayHelper relayHelper,
// @Nullable Class mutationRoot,
// @Nullable Class subscriptionRoot,
// @Nullable QueryComplexityCalculator queryComplexityCalculator) {
// this.codeRegistryBuilder = assertNotNull(codeRegistryBuilder, "codeRegistryBuilder can't be null");
// this.typeRegistry = assertNotNull(typeRegistry, "TypeRegistry can't be null");
// assertNotNull(queryRoot, "queryRoot class can't be null");
// this.relayHelper = relayHelper;
//
// Glitr.objectMapper = objectMapper;
// this.schema = buildSchema(queryRoot, mutationRoot, subscriptionRoot, fieldVisibility);
//
// if (nonNull(queryComplexityCalculator)) {
// this.queryComplexityCalculator = queryComplexityCalculator.withSchema(this.schema);
// }
// }
//
// public TypeRegistry getTypeRegistry() {
// return typeRegistry;
// }
//
// @Nullable
// public QueryComplexityCalculator getQueryComplexityCalculator() {
// return queryComplexityCalculator;
// }
//
// @Nullable
// public RelayHelper getRelayHelper() {
// return relayHelper;
// }
//
// public GraphQLSchema getSchema() {
// return schema;
// }
//
// public static ObjectMapper getObjectMapper() {
// if (objectMapper == null) {
// throw new RuntimeException("Serialization Impossible. Can't find an ObjectMapper implementation. Please configure GLiTR to use an ObjectMapper.");
// }
// return objectMapper;
// }
//
// private GraphQLSchema buildSchema(Class queryRoot, Class mutationRoot, Class subscriptionRoot, GraphqlFieldVisibility fieldVisibility) {
// // create GraphQL Schema
// GraphQLObjectType mutationType = null;
// if (mutationRoot != null) {
// mutationType = typeRegistry.createRelayMutationType(mutationRoot);
// }
// GraphQLObjectType subscriptionType = null;
// if (subscriptionRoot != null) {
// subscriptionType = (GraphQLObjectType) typeRegistry.lookup(subscriptionRoot);
// }
// GraphQLObjectType queryType = (GraphQLObjectType) typeRegistry.lookup(queryRoot);
//
// if (fieldVisibility != null) {
// codeRegistryBuilder.fieldVisibility(fieldVisibility);
//
// return GraphQLSchema.newSchema()
// .query(queryType)
// .mutation(mutationType)
// .subscription(subscriptionType)
// .additionalTypes(typeRegistry.getTypeDictionary())
// .codeRegistry(codeRegistryBuilder.build())
// .build();
// }
//
// return GraphQLSchema.newSchema()
// .query(queryType)
// .mutation(mutationType)
// .subscription(subscriptionType)
// .additionalTypes(typeRegistry.getTypeDictionary())
// .codeRegistry(codeRegistryBuilder.build())
// .build();
// }
//
// public GraphQLSchema reloadSchema(Class queryRoot, Class mutationRoot, Class subscriptionRoot, GraphqlFieldVisibility fieldVisibility) {
// this.schema = buildSchema(queryRoot, mutationRoot, subscriptionRoot, fieldVisibility);
// return this.schema;
// }
// }
//
// Path: src/main/java/com/nfl/glitr/exception/GlitrValidationException.java
// public class GlitrValidationException extends GlitrException {
//
// private final Set<ConstraintViolation<Object>> violations;
//
//
// public GlitrValidationException(String message, Set<ConstraintViolation<Object>> violations) {
// super(message);
// this.violations = violations;
// }
//
// public Set<ConstraintViolation<Object>> getViolations() {
// return violations;
// }
// }
// Path: src/main/java/com/nfl/glitr/registry/mutation/RelayMutationDataFetcher.java
import com.nfl.glitr.Glitr;
import com.nfl.glitr.exception.GlitrValidationException;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import java.util.Map;
import java.util.Set;
package com.nfl.glitr.registry.mutation;
/**
* DataFetcher used when GraphQL operation is a mutation
*/
public class RelayMutationDataFetcher implements DataFetcher {
@SuppressWarnings("unused")
private static final Logger logger = LoggerFactory.getLogger(RelayMutationDataFetcher.class);
private final Class mutationInputClass;
private final Validator validator;
private final RelayMutation mutationFunc;
public RelayMutationDataFetcher(Class mutationInputClass, RelayMutation mutationFunc) {
this(mutationInputClass, mutationFunc, null);
}
public RelayMutationDataFetcher(Class mutationInputClass, RelayMutation mutationFunc, @Nullable Validator validator) {
this.mutationInputClass = mutationInputClass;
this.validator = validator;
this.mutationFunc = mutationFunc;
}
@Override
@SuppressWarnings("unchecked")
public Object get(DataFetchingEnvironment env) {
Map<String, Object> inputMap = env.getArgument("input");
// map fields from input map to mutationInputClass
|
Object inputPayloadMtn = Glitr.getObjectMapper().convertValue(inputMap, mutationInputClass);
|
nfl/glitr
|
src/main/java/com/nfl/glitr/relay/RelayImpl.java
|
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrFieldDefinition.java
// public class GlitrFieldDefinition extends FieldDefinition {
//
// private Set<GlitrMetaDefinition> metaDefinitions = new HashSet<>();
//
//
// public GlitrFieldDefinition(String name, Type type) {
// super(name, type);
// }
//
// public GlitrFieldDefinition(String name, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, null);
// this.metaDefinitions = metaDefinitions;
// }
//
// public GlitrFieldDefinition(String name, Type type, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, type);
// this.metaDefinitions = metaDefinitions;
// }
//
// public Set<GlitrMetaDefinition> getMetaDefinitions() {
// return metaDefinitions;
// }
//
// public void setMetaDefinitions(Set<GlitrMetaDefinition> metaDefinitions) {
// this.metaDefinitions = metaDefinitions;
// }
//
// public void addMetaDefinitions(GlitrMetaDefinition metaDefinition) {
// if (this.metaDefinitions == null) {
// this.metaDefinitions = new HashSet<>();
// }
// this.metaDefinitions.add(metaDefinition);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrMetaDefinition.java
// public class GlitrMetaDefinition {
//
// private String name;
// private Object value;
//
//
// public GlitrMetaDefinition(String name, Object value) {
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
//
// if (o == null || getClass() != o.getClass()) return false;
//
// GlitrMetaDefinition that = (GlitrMetaDefinition) o;
//
// return new EqualsBuilder()
// .append(name, that.name)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder(17, 37)
// .append(name)
// .toHashCode();
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GraphQLConnectionList.java
// public class GraphQLConnectionList extends GraphQLList {
// public GraphQLConnectionList(GraphQLType wrappedType) {
// super(wrappedType);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/util/NodeUtil.java
// public static final String COMPLEXITY_IGNORE_KEY = "complexity_ignore";
|
import com.google.common.collect.Sets;
import com.nfl.glitr.registry.schema.GlitrFieldDefinition;
import com.nfl.glitr.registry.schema.GlitrMetaDefinition;
import com.nfl.glitr.registry.schema.GraphQLConnectionList;
import graphql.schema.GraphQLFieldDefinition;
import graphql.schema.GraphQLNonNull;
import graphql.schema.GraphQLObjectType;
import java.util.List;
import static com.nfl.glitr.util.NodeUtil.COMPLEXITY_IGNORE_KEY;
import static graphql.Scalars.*;
import static graphql.schema.GraphQLFieldDefinition.newFieldDefinition;
import static graphql.schema.GraphQLObjectType.newObject;
|
.field(newFieldDefinition()
.name("startCursor")
.type(GraphQLString)
.description("When paginating backwards, the cursor to continue.")
.build())
.field(newFieldDefinition()
.name("endCursor")
.type(GraphQLString)
.description("When paginating forwards, the cursor to continue.")
.build())
.field(newFieldDefinition()
.name("previousPageStartCursor")
.type(GraphQLString)
.description("When paginating backwards, the cursor for the start of the previous page.")
.build())
.field(newFieldDefinition()
.name("total")
.type(GraphQLBigInteger)
.description("Total number of elements in the connection.")
.build())
.build();
@Override
public GraphQLObjectType connectionType(String name, GraphQLObjectType edgeType, List<GraphQLFieldDefinition> connectionFields) {
return newObject()
.name(name + "Connection")
.description("A connection to a list of items.")
.field(newFieldDefinition()
.name("edges")
|
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrFieldDefinition.java
// public class GlitrFieldDefinition extends FieldDefinition {
//
// private Set<GlitrMetaDefinition> metaDefinitions = new HashSet<>();
//
//
// public GlitrFieldDefinition(String name, Type type) {
// super(name, type);
// }
//
// public GlitrFieldDefinition(String name, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, null);
// this.metaDefinitions = metaDefinitions;
// }
//
// public GlitrFieldDefinition(String name, Type type, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, type);
// this.metaDefinitions = metaDefinitions;
// }
//
// public Set<GlitrMetaDefinition> getMetaDefinitions() {
// return metaDefinitions;
// }
//
// public void setMetaDefinitions(Set<GlitrMetaDefinition> metaDefinitions) {
// this.metaDefinitions = metaDefinitions;
// }
//
// public void addMetaDefinitions(GlitrMetaDefinition metaDefinition) {
// if (this.metaDefinitions == null) {
// this.metaDefinitions = new HashSet<>();
// }
// this.metaDefinitions.add(metaDefinition);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrMetaDefinition.java
// public class GlitrMetaDefinition {
//
// private String name;
// private Object value;
//
//
// public GlitrMetaDefinition(String name, Object value) {
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
//
// if (o == null || getClass() != o.getClass()) return false;
//
// GlitrMetaDefinition that = (GlitrMetaDefinition) o;
//
// return new EqualsBuilder()
// .append(name, that.name)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder(17, 37)
// .append(name)
// .toHashCode();
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GraphQLConnectionList.java
// public class GraphQLConnectionList extends GraphQLList {
// public GraphQLConnectionList(GraphQLType wrappedType) {
// super(wrappedType);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/util/NodeUtil.java
// public static final String COMPLEXITY_IGNORE_KEY = "complexity_ignore";
// Path: src/main/java/com/nfl/glitr/relay/RelayImpl.java
import com.google.common.collect.Sets;
import com.nfl.glitr.registry.schema.GlitrFieldDefinition;
import com.nfl.glitr.registry.schema.GlitrMetaDefinition;
import com.nfl.glitr.registry.schema.GraphQLConnectionList;
import graphql.schema.GraphQLFieldDefinition;
import graphql.schema.GraphQLNonNull;
import graphql.schema.GraphQLObjectType;
import java.util.List;
import static com.nfl.glitr.util.NodeUtil.COMPLEXITY_IGNORE_KEY;
import static graphql.Scalars.*;
import static graphql.schema.GraphQLFieldDefinition.newFieldDefinition;
import static graphql.schema.GraphQLObjectType.newObject;
.field(newFieldDefinition()
.name("startCursor")
.type(GraphQLString)
.description("When paginating backwards, the cursor to continue.")
.build())
.field(newFieldDefinition()
.name("endCursor")
.type(GraphQLString)
.description("When paginating forwards, the cursor to continue.")
.build())
.field(newFieldDefinition()
.name("previousPageStartCursor")
.type(GraphQLString)
.description("When paginating backwards, the cursor for the start of the previous page.")
.build())
.field(newFieldDefinition()
.name("total")
.type(GraphQLBigInteger)
.description("Total number of elements in the connection.")
.build())
.build();
@Override
public GraphQLObjectType connectionType(String name, GraphQLObjectType edgeType, List<GraphQLFieldDefinition> connectionFields) {
return newObject()
.name(name + "Connection")
.description("A connection to a list of items.")
.field(newFieldDefinition()
.name("edges")
|
.type(new GraphQLConnectionList(edgeType))
|
nfl/glitr
|
src/main/java/com/nfl/glitr/relay/RelayImpl.java
|
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrFieldDefinition.java
// public class GlitrFieldDefinition extends FieldDefinition {
//
// private Set<GlitrMetaDefinition> metaDefinitions = new HashSet<>();
//
//
// public GlitrFieldDefinition(String name, Type type) {
// super(name, type);
// }
//
// public GlitrFieldDefinition(String name, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, null);
// this.metaDefinitions = metaDefinitions;
// }
//
// public GlitrFieldDefinition(String name, Type type, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, type);
// this.metaDefinitions = metaDefinitions;
// }
//
// public Set<GlitrMetaDefinition> getMetaDefinitions() {
// return metaDefinitions;
// }
//
// public void setMetaDefinitions(Set<GlitrMetaDefinition> metaDefinitions) {
// this.metaDefinitions = metaDefinitions;
// }
//
// public void addMetaDefinitions(GlitrMetaDefinition metaDefinition) {
// if (this.metaDefinitions == null) {
// this.metaDefinitions = new HashSet<>();
// }
// this.metaDefinitions.add(metaDefinition);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrMetaDefinition.java
// public class GlitrMetaDefinition {
//
// private String name;
// private Object value;
//
//
// public GlitrMetaDefinition(String name, Object value) {
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
//
// if (o == null || getClass() != o.getClass()) return false;
//
// GlitrMetaDefinition that = (GlitrMetaDefinition) o;
//
// return new EqualsBuilder()
// .append(name, that.name)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder(17, 37)
// .append(name)
// .toHashCode();
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GraphQLConnectionList.java
// public class GraphQLConnectionList extends GraphQLList {
// public GraphQLConnectionList(GraphQLType wrappedType) {
// super(wrappedType);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/util/NodeUtil.java
// public static final String COMPLEXITY_IGNORE_KEY = "complexity_ignore";
|
import com.google.common.collect.Sets;
import com.nfl.glitr.registry.schema.GlitrFieldDefinition;
import com.nfl.glitr.registry.schema.GlitrMetaDefinition;
import com.nfl.glitr.registry.schema.GraphQLConnectionList;
import graphql.schema.GraphQLFieldDefinition;
import graphql.schema.GraphQLNonNull;
import graphql.schema.GraphQLObjectType;
import java.util.List;
import static com.nfl.glitr.util.NodeUtil.COMPLEXITY_IGNORE_KEY;
import static graphql.Scalars.*;
import static graphql.schema.GraphQLFieldDefinition.newFieldDefinition;
import static graphql.schema.GraphQLObjectType.newObject;
|
.field(newFieldDefinition()
.name("endCursor")
.type(GraphQLString)
.description("When paginating forwards, the cursor to continue.")
.build())
.field(newFieldDefinition()
.name("previousPageStartCursor")
.type(GraphQLString)
.description("When paginating backwards, the cursor for the start of the previous page.")
.build())
.field(newFieldDefinition()
.name("total")
.type(GraphQLBigInteger)
.description("Total number of elements in the connection.")
.build())
.build();
@Override
public GraphQLObjectType connectionType(String name, GraphQLObjectType edgeType, List<GraphQLFieldDefinition> connectionFields) {
return newObject()
.name(name + "Connection")
.description("A connection to a list of items.")
.field(newFieldDefinition()
.name("edges")
.type(new GraphQLConnectionList(edgeType))
.build())
.field(newFieldDefinition()
.name("pageInfo")
.type(new GraphQLNonNull(pageInfoType))
|
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrFieldDefinition.java
// public class GlitrFieldDefinition extends FieldDefinition {
//
// private Set<GlitrMetaDefinition> metaDefinitions = new HashSet<>();
//
//
// public GlitrFieldDefinition(String name, Type type) {
// super(name, type);
// }
//
// public GlitrFieldDefinition(String name, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, null);
// this.metaDefinitions = metaDefinitions;
// }
//
// public GlitrFieldDefinition(String name, Type type, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, type);
// this.metaDefinitions = metaDefinitions;
// }
//
// public Set<GlitrMetaDefinition> getMetaDefinitions() {
// return metaDefinitions;
// }
//
// public void setMetaDefinitions(Set<GlitrMetaDefinition> metaDefinitions) {
// this.metaDefinitions = metaDefinitions;
// }
//
// public void addMetaDefinitions(GlitrMetaDefinition metaDefinition) {
// if (this.metaDefinitions == null) {
// this.metaDefinitions = new HashSet<>();
// }
// this.metaDefinitions.add(metaDefinition);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrMetaDefinition.java
// public class GlitrMetaDefinition {
//
// private String name;
// private Object value;
//
//
// public GlitrMetaDefinition(String name, Object value) {
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
//
// if (o == null || getClass() != o.getClass()) return false;
//
// GlitrMetaDefinition that = (GlitrMetaDefinition) o;
//
// return new EqualsBuilder()
// .append(name, that.name)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder(17, 37)
// .append(name)
// .toHashCode();
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GraphQLConnectionList.java
// public class GraphQLConnectionList extends GraphQLList {
// public GraphQLConnectionList(GraphQLType wrappedType) {
// super(wrappedType);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/util/NodeUtil.java
// public static final String COMPLEXITY_IGNORE_KEY = "complexity_ignore";
// Path: src/main/java/com/nfl/glitr/relay/RelayImpl.java
import com.google.common.collect.Sets;
import com.nfl.glitr.registry.schema.GlitrFieldDefinition;
import com.nfl.glitr.registry.schema.GlitrMetaDefinition;
import com.nfl.glitr.registry.schema.GraphQLConnectionList;
import graphql.schema.GraphQLFieldDefinition;
import graphql.schema.GraphQLNonNull;
import graphql.schema.GraphQLObjectType;
import java.util.List;
import static com.nfl.glitr.util.NodeUtil.COMPLEXITY_IGNORE_KEY;
import static graphql.Scalars.*;
import static graphql.schema.GraphQLFieldDefinition.newFieldDefinition;
import static graphql.schema.GraphQLObjectType.newObject;
.field(newFieldDefinition()
.name("endCursor")
.type(GraphQLString)
.description("When paginating forwards, the cursor to continue.")
.build())
.field(newFieldDefinition()
.name("previousPageStartCursor")
.type(GraphQLString)
.description("When paginating backwards, the cursor for the start of the previous page.")
.build())
.field(newFieldDefinition()
.name("total")
.type(GraphQLBigInteger)
.description("Total number of elements in the connection.")
.build())
.build();
@Override
public GraphQLObjectType connectionType(String name, GraphQLObjectType edgeType, List<GraphQLFieldDefinition> connectionFields) {
return newObject()
.name(name + "Connection")
.description("A connection to a list of items.")
.field(newFieldDefinition()
.name("edges")
.type(new GraphQLConnectionList(edgeType))
.build())
.field(newFieldDefinition()
.name("pageInfo")
.type(new GraphQLNonNull(pageInfoType))
|
.definition(new GlitrFieldDefinition(name, Sets.newHashSet(new GlitrMetaDefinition(COMPLEXITY_IGNORE_KEY, true))))
|
nfl/glitr
|
src/main/java/com/nfl/glitr/relay/RelayImpl.java
|
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrFieldDefinition.java
// public class GlitrFieldDefinition extends FieldDefinition {
//
// private Set<GlitrMetaDefinition> metaDefinitions = new HashSet<>();
//
//
// public GlitrFieldDefinition(String name, Type type) {
// super(name, type);
// }
//
// public GlitrFieldDefinition(String name, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, null);
// this.metaDefinitions = metaDefinitions;
// }
//
// public GlitrFieldDefinition(String name, Type type, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, type);
// this.metaDefinitions = metaDefinitions;
// }
//
// public Set<GlitrMetaDefinition> getMetaDefinitions() {
// return metaDefinitions;
// }
//
// public void setMetaDefinitions(Set<GlitrMetaDefinition> metaDefinitions) {
// this.metaDefinitions = metaDefinitions;
// }
//
// public void addMetaDefinitions(GlitrMetaDefinition metaDefinition) {
// if (this.metaDefinitions == null) {
// this.metaDefinitions = new HashSet<>();
// }
// this.metaDefinitions.add(metaDefinition);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrMetaDefinition.java
// public class GlitrMetaDefinition {
//
// private String name;
// private Object value;
//
//
// public GlitrMetaDefinition(String name, Object value) {
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
//
// if (o == null || getClass() != o.getClass()) return false;
//
// GlitrMetaDefinition that = (GlitrMetaDefinition) o;
//
// return new EqualsBuilder()
// .append(name, that.name)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder(17, 37)
// .append(name)
// .toHashCode();
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GraphQLConnectionList.java
// public class GraphQLConnectionList extends GraphQLList {
// public GraphQLConnectionList(GraphQLType wrappedType) {
// super(wrappedType);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/util/NodeUtil.java
// public static final String COMPLEXITY_IGNORE_KEY = "complexity_ignore";
|
import com.google.common.collect.Sets;
import com.nfl.glitr.registry.schema.GlitrFieldDefinition;
import com.nfl.glitr.registry.schema.GlitrMetaDefinition;
import com.nfl.glitr.registry.schema.GraphQLConnectionList;
import graphql.schema.GraphQLFieldDefinition;
import graphql.schema.GraphQLNonNull;
import graphql.schema.GraphQLObjectType;
import java.util.List;
import static com.nfl.glitr.util.NodeUtil.COMPLEXITY_IGNORE_KEY;
import static graphql.Scalars.*;
import static graphql.schema.GraphQLFieldDefinition.newFieldDefinition;
import static graphql.schema.GraphQLObjectType.newObject;
|
.field(newFieldDefinition()
.name("endCursor")
.type(GraphQLString)
.description("When paginating forwards, the cursor to continue.")
.build())
.field(newFieldDefinition()
.name("previousPageStartCursor")
.type(GraphQLString)
.description("When paginating backwards, the cursor for the start of the previous page.")
.build())
.field(newFieldDefinition()
.name("total")
.type(GraphQLBigInteger)
.description("Total number of elements in the connection.")
.build())
.build();
@Override
public GraphQLObjectType connectionType(String name, GraphQLObjectType edgeType, List<GraphQLFieldDefinition> connectionFields) {
return newObject()
.name(name + "Connection")
.description("A connection to a list of items.")
.field(newFieldDefinition()
.name("edges")
.type(new GraphQLConnectionList(edgeType))
.build())
.field(newFieldDefinition()
.name("pageInfo")
.type(new GraphQLNonNull(pageInfoType))
|
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrFieldDefinition.java
// public class GlitrFieldDefinition extends FieldDefinition {
//
// private Set<GlitrMetaDefinition> metaDefinitions = new HashSet<>();
//
//
// public GlitrFieldDefinition(String name, Type type) {
// super(name, type);
// }
//
// public GlitrFieldDefinition(String name, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, null);
// this.metaDefinitions = metaDefinitions;
// }
//
// public GlitrFieldDefinition(String name, Type type, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, type);
// this.metaDefinitions = metaDefinitions;
// }
//
// public Set<GlitrMetaDefinition> getMetaDefinitions() {
// return metaDefinitions;
// }
//
// public void setMetaDefinitions(Set<GlitrMetaDefinition> metaDefinitions) {
// this.metaDefinitions = metaDefinitions;
// }
//
// public void addMetaDefinitions(GlitrMetaDefinition metaDefinition) {
// if (this.metaDefinitions == null) {
// this.metaDefinitions = new HashSet<>();
// }
// this.metaDefinitions.add(metaDefinition);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrMetaDefinition.java
// public class GlitrMetaDefinition {
//
// private String name;
// private Object value;
//
//
// public GlitrMetaDefinition(String name, Object value) {
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
//
// if (o == null || getClass() != o.getClass()) return false;
//
// GlitrMetaDefinition that = (GlitrMetaDefinition) o;
//
// return new EqualsBuilder()
// .append(name, that.name)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder(17, 37)
// .append(name)
// .toHashCode();
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GraphQLConnectionList.java
// public class GraphQLConnectionList extends GraphQLList {
// public GraphQLConnectionList(GraphQLType wrappedType) {
// super(wrappedType);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/util/NodeUtil.java
// public static final String COMPLEXITY_IGNORE_KEY = "complexity_ignore";
// Path: src/main/java/com/nfl/glitr/relay/RelayImpl.java
import com.google.common.collect.Sets;
import com.nfl.glitr.registry.schema.GlitrFieldDefinition;
import com.nfl.glitr.registry.schema.GlitrMetaDefinition;
import com.nfl.glitr.registry.schema.GraphQLConnectionList;
import graphql.schema.GraphQLFieldDefinition;
import graphql.schema.GraphQLNonNull;
import graphql.schema.GraphQLObjectType;
import java.util.List;
import static com.nfl.glitr.util.NodeUtil.COMPLEXITY_IGNORE_KEY;
import static graphql.Scalars.*;
import static graphql.schema.GraphQLFieldDefinition.newFieldDefinition;
import static graphql.schema.GraphQLObjectType.newObject;
.field(newFieldDefinition()
.name("endCursor")
.type(GraphQLString)
.description("When paginating forwards, the cursor to continue.")
.build())
.field(newFieldDefinition()
.name("previousPageStartCursor")
.type(GraphQLString)
.description("When paginating backwards, the cursor for the start of the previous page.")
.build())
.field(newFieldDefinition()
.name("total")
.type(GraphQLBigInteger)
.description("Total number of elements in the connection.")
.build())
.build();
@Override
public GraphQLObjectType connectionType(String name, GraphQLObjectType edgeType, List<GraphQLFieldDefinition> connectionFields) {
return newObject()
.name(name + "Connection")
.description("A connection to a list of items.")
.field(newFieldDefinition()
.name("edges")
.type(new GraphQLConnectionList(edgeType))
.build())
.field(newFieldDefinition()
.name("pageInfo")
.type(new GraphQLNonNull(pageInfoType))
|
.definition(new GlitrFieldDefinition(name, Sets.newHashSet(new GlitrMetaDefinition(COMPLEXITY_IGNORE_KEY, true))))
|
nfl/glitr
|
src/main/java/com/nfl/glitr/relay/RelayImpl.java
|
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrFieldDefinition.java
// public class GlitrFieldDefinition extends FieldDefinition {
//
// private Set<GlitrMetaDefinition> metaDefinitions = new HashSet<>();
//
//
// public GlitrFieldDefinition(String name, Type type) {
// super(name, type);
// }
//
// public GlitrFieldDefinition(String name, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, null);
// this.metaDefinitions = metaDefinitions;
// }
//
// public GlitrFieldDefinition(String name, Type type, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, type);
// this.metaDefinitions = metaDefinitions;
// }
//
// public Set<GlitrMetaDefinition> getMetaDefinitions() {
// return metaDefinitions;
// }
//
// public void setMetaDefinitions(Set<GlitrMetaDefinition> metaDefinitions) {
// this.metaDefinitions = metaDefinitions;
// }
//
// public void addMetaDefinitions(GlitrMetaDefinition metaDefinition) {
// if (this.metaDefinitions == null) {
// this.metaDefinitions = new HashSet<>();
// }
// this.metaDefinitions.add(metaDefinition);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrMetaDefinition.java
// public class GlitrMetaDefinition {
//
// private String name;
// private Object value;
//
//
// public GlitrMetaDefinition(String name, Object value) {
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
//
// if (o == null || getClass() != o.getClass()) return false;
//
// GlitrMetaDefinition that = (GlitrMetaDefinition) o;
//
// return new EqualsBuilder()
// .append(name, that.name)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder(17, 37)
// .append(name)
// .toHashCode();
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GraphQLConnectionList.java
// public class GraphQLConnectionList extends GraphQLList {
// public GraphQLConnectionList(GraphQLType wrappedType) {
// super(wrappedType);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/util/NodeUtil.java
// public static final String COMPLEXITY_IGNORE_KEY = "complexity_ignore";
|
import com.google.common.collect.Sets;
import com.nfl.glitr.registry.schema.GlitrFieldDefinition;
import com.nfl.glitr.registry.schema.GlitrMetaDefinition;
import com.nfl.glitr.registry.schema.GraphQLConnectionList;
import graphql.schema.GraphQLFieldDefinition;
import graphql.schema.GraphQLNonNull;
import graphql.schema.GraphQLObjectType;
import java.util.List;
import static com.nfl.glitr.util.NodeUtil.COMPLEXITY_IGNORE_KEY;
import static graphql.Scalars.*;
import static graphql.schema.GraphQLFieldDefinition.newFieldDefinition;
import static graphql.schema.GraphQLObjectType.newObject;
|
.field(newFieldDefinition()
.name("endCursor")
.type(GraphQLString)
.description("When paginating forwards, the cursor to continue.")
.build())
.field(newFieldDefinition()
.name("previousPageStartCursor")
.type(GraphQLString)
.description("When paginating backwards, the cursor for the start of the previous page.")
.build())
.field(newFieldDefinition()
.name("total")
.type(GraphQLBigInteger)
.description("Total number of elements in the connection.")
.build())
.build();
@Override
public GraphQLObjectType connectionType(String name, GraphQLObjectType edgeType, List<GraphQLFieldDefinition> connectionFields) {
return newObject()
.name(name + "Connection")
.description("A connection to a list of items.")
.field(newFieldDefinition()
.name("edges")
.type(new GraphQLConnectionList(edgeType))
.build())
.field(newFieldDefinition()
.name("pageInfo")
.type(new GraphQLNonNull(pageInfoType))
|
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrFieldDefinition.java
// public class GlitrFieldDefinition extends FieldDefinition {
//
// private Set<GlitrMetaDefinition> metaDefinitions = new HashSet<>();
//
//
// public GlitrFieldDefinition(String name, Type type) {
// super(name, type);
// }
//
// public GlitrFieldDefinition(String name, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, null);
// this.metaDefinitions = metaDefinitions;
// }
//
// public GlitrFieldDefinition(String name, Type type, Set<GlitrMetaDefinition> metaDefinitions) {
// super(name, type);
// this.metaDefinitions = metaDefinitions;
// }
//
// public Set<GlitrMetaDefinition> getMetaDefinitions() {
// return metaDefinitions;
// }
//
// public void setMetaDefinitions(Set<GlitrMetaDefinition> metaDefinitions) {
// this.metaDefinitions = metaDefinitions;
// }
//
// public void addMetaDefinitions(GlitrMetaDefinition metaDefinition) {
// if (this.metaDefinitions == null) {
// this.metaDefinitions = new HashSet<>();
// }
// this.metaDefinitions.add(metaDefinition);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GlitrMetaDefinition.java
// public class GlitrMetaDefinition {
//
// private String name;
// private Object value;
//
//
// public GlitrMetaDefinition(String name, Object value) {
// this.name = name;
// this.value = value;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
//
// if (o == null || getClass() != o.getClass()) return false;
//
// GlitrMetaDefinition that = (GlitrMetaDefinition) o;
//
// return new EqualsBuilder()
// .append(name, that.name)
// .isEquals();
// }
//
// @Override
// public int hashCode() {
// return new HashCodeBuilder(17, 37)
// .append(name)
// .toHashCode();
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/schema/GraphQLConnectionList.java
// public class GraphQLConnectionList extends GraphQLList {
// public GraphQLConnectionList(GraphQLType wrappedType) {
// super(wrappedType);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/util/NodeUtil.java
// public static final String COMPLEXITY_IGNORE_KEY = "complexity_ignore";
// Path: src/main/java/com/nfl/glitr/relay/RelayImpl.java
import com.google.common.collect.Sets;
import com.nfl.glitr.registry.schema.GlitrFieldDefinition;
import com.nfl.glitr.registry.schema.GlitrMetaDefinition;
import com.nfl.glitr.registry.schema.GraphQLConnectionList;
import graphql.schema.GraphQLFieldDefinition;
import graphql.schema.GraphQLNonNull;
import graphql.schema.GraphQLObjectType;
import java.util.List;
import static com.nfl.glitr.util.NodeUtil.COMPLEXITY_IGNORE_KEY;
import static graphql.Scalars.*;
import static graphql.schema.GraphQLFieldDefinition.newFieldDefinition;
import static graphql.schema.GraphQLObjectType.newObject;
.field(newFieldDefinition()
.name("endCursor")
.type(GraphQLString)
.description("When paginating forwards, the cursor to continue.")
.build())
.field(newFieldDefinition()
.name("previousPageStartCursor")
.type(GraphQLString)
.description("When paginating backwards, the cursor for the start of the previous page.")
.build())
.field(newFieldDefinition()
.name("total")
.type(GraphQLBigInteger)
.description("Total number of elements in the connection.")
.build())
.build();
@Override
public GraphQLObjectType connectionType(String name, GraphQLObjectType edgeType, List<GraphQLFieldDefinition> connectionFields) {
return newObject()
.name(name + "Connection")
.description("A connection to a list of items.")
.field(newFieldDefinition()
.name("edges")
.type(new GraphQLConnectionList(edgeType))
.build())
.field(newFieldDefinition()
.name("pageInfo")
.type(new GraphQLNonNull(pageInfoType))
|
.definition(new GlitrFieldDefinition(name, Sets.newHashSet(new GlitrMetaDefinition(COMPLEXITY_IGNORE_KEY, true))))
|
nfl/glitr
|
src/test/groovy/com/nfl/glitr/data/query/Video.java
|
// Path: src/test/groovy/com/nfl/glitr/data/mutation/Bitrate.java
// public class Bitrate implements Playable {
//
// private String id;
// private Integer kbps;
// private String url;
// private Integer[] frames;
// private Float gradeAverage;
// private Double grade;
// private Long durationNanos;
// private Boolean valid;
// private LocalDate createdDate;
// private Instant modifiedDateTime;
//
//
// public Integer getKbps() {
// return kbps;
// }
//
// public String getUrl() {
// return url;
// }
//
// public Long getDurationNanos() {
// return durationNanos;
// }
//
// public Integer[] getFrames() {
// return frames;
// }
//
// public Double getGrade() {
// return grade;
// }
//
// public Float getGradeAverage() {
// return gradeAverage;
// }
//
// public Boolean getValid() {
// return valid;
// }
//
// public LocalDate getCreatedDate() {
// return createdDate;
// }
//
// public Instant getModifiedDateTime() {
// return modifiedDateTime;
// }
//
// @Override
// public String getId() {
// return id;
// }
// }
|
import com.nfl.glitr.annotation.GlitrForwardPagingArguments;
import com.nfl.glitr.annotation.GlitrQueryComplexity;
import com.nfl.glitr.data.mutation.Bitrate;
import java.util.List;
|
package com.nfl.glitr.data.query;
public class Video extends AbstractContent implements Playable {
private String id;
private String url;
|
// Path: src/test/groovy/com/nfl/glitr/data/mutation/Bitrate.java
// public class Bitrate implements Playable {
//
// private String id;
// private Integer kbps;
// private String url;
// private Integer[] frames;
// private Float gradeAverage;
// private Double grade;
// private Long durationNanos;
// private Boolean valid;
// private LocalDate createdDate;
// private Instant modifiedDateTime;
//
//
// public Integer getKbps() {
// return kbps;
// }
//
// public String getUrl() {
// return url;
// }
//
// public Long getDurationNanos() {
// return durationNanos;
// }
//
// public Integer[] getFrames() {
// return frames;
// }
//
// public Double getGrade() {
// return grade;
// }
//
// public Float getGradeAverage() {
// return gradeAverage;
// }
//
// public Boolean getValid() {
// return valid;
// }
//
// public LocalDate getCreatedDate() {
// return createdDate;
// }
//
// public Instant getModifiedDateTime() {
// return modifiedDateTime;
// }
//
// @Override
// public String getId() {
// return id;
// }
// }
// Path: src/test/groovy/com/nfl/glitr/data/query/Video.java
import com.nfl.glitr.annotation.GlitrForwardPagingArguments;
import com.nfl.glitr.annotation.GlitrQueryComplexity;
import com.nfl.glitr.data.mutation.Bitrate;
import java.util.List;
package com.nfl.glitr.data.query;
public class Video extends AbstractContent implements Playable {
private String id;
private String url;
|
private List<Bitrate> bitrateList;
|
nfl/glitr
|
src/main/java/com/nfl/glitr/registry/datafetcher/query/batched/CompositeDataFetcherFactory.java
|
// Path: src/main/java/com/nfl/glitr/registry/datafetcher/query/CompositeDataFetcher.java
// public class CompositeDataFetcher extends AbstractCompositeDataFetcher {
//
// @SuppressWarnings("unused")
// private static final Logger logger = LoggerFactory.getLogger(CompositeDataFetcher.class);
//
//
// public CompositeDataFetcher(DataFetcher[] fetchers) {
// super(fetchers);
// }
//
// public CompositeDataFetcher(List<DataFetcher> fetchers) {
// super(fetchers);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/datafetcher/query/OverrideDataFetcher.java
// public class OverrideDataFetcher implements DataFetcher {
//
// private static final Logger logger = LoggerFactory.getLogger(OverrideDataFetcher.class);
//
// private Object override;
// private Method overrideMethod;
//
//
// /**
// * This constructor is used for getter overrides placed in the class itself
// *
// * @param name field name
// * @param clazz schema class
// */
// public OverrideDataFetcher(String name, Class clazz) {
// overrideMethod = findMethod("get" + StringUtils.capitalize(name), clazz);
// if (overrideMethod != null) {
// return;
// }
// overrideMethod = findMethod("is" + StringUtils.capitalize(name), clazz);
// }
//
// /**
// * This constructor is used for getter overrides outside of the reference class
// *
// * @param name field name
// * @param override override object
// */
// public OverrideDataFetcher(String name, Object override) {
// this(name, override.getClass());
// this.override = override;
// }
//
// @Override
// public Object get(DataFetchingEnvironment environment) {
// if (overrideMethod == null) {
// return null;
// }
//
// Object obj = override == null ? environment.getSource() : override;
//
// try {
// return overrideMethod.invoke(obj, environment);
// } catch (InvocationTargetException e) {
//
// // If the override method threw a RuntimeException just send it up
// if (e.getTargetException() instanceof RuntimeException) {
// logger.debug("Something went wrong - Unable to fetch result for overrideMethod={{}} of {}", overrideMethod.getName(), obj.getClass().getSimpleName(), e.getTargetException());
// throw (RuntimeException) e.getTargetException();
// }
//
// // Otherwise, wrap it up in a Glitr Exception
// logger.debug("Something went wrong - Unable to fetch result for overrideMethod={{}} of {}", overrideMethod.getName(), obj.getClass().getSimpleName());
// throw new GlitrException("Overwrite method exception", e.getTargetException());
// } catch (Exception e) {
// logger.debug("Something went wrong - Unable to fetch result for overrideMethod={{}} of {}", overrideMethod.getName(), obj.getClass().getSimpleName());
// }
// return null;
// }
//
// private Method findMethod(String name, Class clazz) {
// try {
// //noinspection unchecked
// return clazz.getMethod(name, DataFetchingEnvironment.class);
// } catch (NoSuchMethodException e) {
// logger.debug("Couldn't find method for name {} and class {}", name, clazz, e.getMessage());
// }
// return null;
// }
//
// public Method getOverrideMethod() {
// return overrideMethod;
// }
//
// public Object getOverride() {
// return override;
// }
// }
|
import com.nfl.glitr.registry.datafetcher.query.CompositeDataFetcher;
import com.nfl.glitr.registry.datafetcher.query.OverrideDataFetcher;
import graphql.schema.DataFetcher;
import java.util.List;
import java.util.stream.Collectors;
|
package com.nfl.glitr.registry.datafetcher.query.batched;
/**
* Create a CompositeDataFetcher based on the supplied DataFetchers.
*
*/
public class CompositeDataFetcherFactory {
public static DataFetcher create(final List<DataFetcher> supplied) {
List<DataFetcher> fetchers = supplied.stream()
// filter out all the OverrideDataFetchers that have a null overrideMethod since type registry adds a default overrideDF
|
// Path: src/main/java/com/nfl/glitr/registry/datafetcher/query/CompositeDataFetcher.java
// public class CompositeDataFetcher extends AbstractCompositeDataFetcher {
//
// @SuppressWarnings("unused")
// private static final Logger logger = LoggerFactory.getLogger(CompositeDataFetcher.class);
//
//
// public CompositeDataFetcher(DataFetcher[] fetchers) {
// super(fetchers);
// }
//
// public CompositeDataFetcher(List<DataFetcher> fetchers) {
// super(fetchers);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/datafetcher/query/OverrideDataFetcher.java
// public class OverrideDataFetcher implements DataFetcher {
//
// private static final Logger logger = LoggerFactory.getLogger(OverrideDataFetcher.class);
//
// private Object override;
// private Method overrideMethod;
//
//
// /**
// * This constructor is used for getter overrides placed in the class itself
// *
// * @param name field name
// * @param clazz schema class
// */
// public OverrideDataFetcher(String name, Class clazz) {
// overrideMethod = findMethod("get" + StringUtils.capitalize(name), clazz);
// if (overrideMethod != null) {
// return;
// }
// overrideMethod = findMethod("is" + StringUtils.capitalize(name), clazz);
// }
//
// /**
// * This constructor is used for getter overrides outside of the reference class
// *
// * @param name field name
// * @param override override object
// */
// public OverrideDataFetcher(String name, Object override) {
// this(name, override.getClass());
// this.override = override;
// }
//
// @Override
// public Object get(DataFetchingEnvironment environment) {
// if (overrideMethod == null) {
// return null;
// }
//
// Object obj = override == null ? environment.getSource() : override;
//
// try {
// return overrideMethod.invoke(obj, environment);
// } catch (InvocationTargetException e) {
//
// // If the override method threw a RuntimeException just send it up
// if (e.getTargetException() instanceof RuntimeException) {
// logger.debug("Something went wrong - Unable to fetch result for overrideMethod={{}} of {}", overrideMethod.getName(), obj.getClass().getSimpleName(), e.getTargetException());
// throw (RuntimeException) e.getTargetException();
// }
//
// // Otherwise, wrap it up in a Glitr Exception
// logger.debug("Something went wrong - Unable to fetch result for overrideMethod={{}} of {}", overrideMethod.getName(), obj.getClass().getSimpleName());
// throw new GlitrException("Overwrite method exception", e.getTargetException());
// } catch (Exception e) {
// logger.debug("Something went wrong - Unable to fetch result for overrideMethod={{}} of {}", overrideMethod.getName(), obj.getClass().getSimpleName());
// }
// return null;
// }
//
// private Method findMethod(String name, Class clazz) {
// try {
// //noinspection unchecked
// return clazz.getMethod(name, DataFetchingEnvironment.class);
// } catch (NoSuchMethodException e) {
// logger.debug("Couldn't find method for name {} and class {}", name, clazz, e.getMessage());
// }
// return null;
// }
//
// public Method getOverrideMethod() {
// return overrideMethod;
// }
//
// public Object getOverride() {
// return override;
// }
// }
// Path: src/main/java/com/nfl/glitr/registry/datafetcher/query/batched/CompositeDataFetcherFactory.java
import com.nfl.glitr.registry.datafetcher.query.CompositeDataFetcher;
import com.nfl.glitr.registry.datafetcher.query.OverrideDataFetcher;
import graphql.schema.DataFetcher;
import java.util.List;
import java.util.stream.Collectors;
package com.nfl.glitr.registry.datafetcher.query.batched;
/**
* Create a CompositeDataFetcher based on the supplied DataFetchers.
*
*/
public class CompositeDataFetcherFactory {
public static DataFetcher create(final List<DataFetcher> supplied) {
List<DataFetcher> fetchers = supplied.stream()
// filter out all the OverrideDataFetchers that have a null overrideMethod since type registry adds a default overrideDF
|
.filter(f -> !(f instanceof OverrideDataFetcher) || ((OverrideDataFetcher)f).getOverrideMethod() != null)
|
nfl/glitr
|
src/main/java/com/nfl/glitr/registry/datafetcher/query/batched/CompositeDataFetcherFactory.java
|
// Path: src/main/java/com/nfl/glitr/registry/datafetcher/query/CompositeDataFetcher.java
// public class CompositeDataFetcher extends AbstractCompositeDataFetcher {
//
// @SuppressWarnings("unused")
// private static final Logger logger = LoggerFactory.getLogger(CompositeDataFetcher.class);
//
//
// public CompositeDataFetcher(DataFetcher[] fetchers) {
// super(fetchers);
// }
//
// public CompositeDataFetcher(List<DataFetcher> fetchers) {
// super(fetchers);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/datafetcher/query/OverrideDataFetcher.java
// public class OverrideDataFetcher implements DataFetcher {
//
// private static final Logger logger = LoggerFactory.getLogger(OverrideDataFetcher.class);
//
// private Object override;
// private Method overrideMethod;
//
//
// /**
// * This constructor is used for getter overrides placed in the class itself
// *
// * @param name field name
// * @param clazz schema class
// */
// public OverrideDataFetcher(String name, Class clazz) {
// overrideMethod = findMethod("get" + StringUtils.capitalize(name), clazz);
// if (overrideMethod != null) {
// return;
// }
// overrideMethod = findMethod("is" + StringUtils.capitalize(name), clazz);
// }
//
// /**
// * This constructor is used for getter overrides outside of the reference class
// *
// * @param name field name
// * @param override override object
// */
// public OverrideDataFetcher(String name, Object override) {
// this(name, override.getClass());
// this.override = override;
// }
//
// @Override
// public Object get(DataFetchingEnvironment environment) {
// if (overrideMethod == null) {
// return null;
// }
//
// Object obj = override == null ? environment.getSource() : override;
//
// try {
// return overrideMethod.invoke(obj, environment);
// } catch (InvocationTargetException e) {
//
// // If the override method threw a RuntimeException just send it up
// if (e.getTargetException() instanceof RuntimeException) {
// logger.debug("Something went wrong - Unable to fetch result for overrideMethod={{}} of {}", overrideMethod.getName(), obj.getClass().getSimpleName(), e.getTargetException());
// throw (RuntimeException) e.getTargetException();
// }
//
// // Otherwise, wrap it up in a Glitr Exception
// logger.debug("Something went wrong - Unable to fetch result for overrideMethod={{}} of {}", overrideMethod.getName(), obj.getClass().getSimpleName());
// throw new GlitrException("Overwrite method exception", e.getTargetException());
// } catch (Exception e) {
// logger.debug("Something went wrong - Unable to fetch result for overrideMethod={{}} of {}", overrideMethod.getName(), obj.getClass().getSimpleName());
// }
// return null;
// }
//
// private Method findMethod(String name, Class clazz) {
// try {
// //noinspection unchecked
// return clazz.getMethod(name, DataFetchingEnvironment.class);
// } catch (NoSuchMethodException e) {
// logger.debug("Couldn't find method for name {} and class {}", name, clazz, e.getMessage());
// }
// return null;
// }
//
// public Method getOverrideMethod() {
// return overrideMethod;
// }
//
// public Object getOverride() {
// return override;
// }
// }
|
import com.nfl.glitr.registry.datafetcher.query.CompositeDataFetcher;
import com.nfl.glitr.registry.datafetcher.query.OverrideDataFetcher;
import graphql.schema.DataFetcher;
import java.util.List;
import java.util.stream.Collectors;
|
package com.nfl.glitr.registry.datafetcher.query.batched;
/**
* Create a CompositeDataFetcher based on the supplied DataFetchers.
*
*/
public class CompositeDataFetcherFactory {
public static DataFetcher create(final List<DataFetcher> supplied) {
List<DataFetcher> fetchers = supplied.stream()
// filter out all the OverrideDataFetchers that have a null overrideMethod since type registry adds a default overrideDF
.filter(f -> !(f instanceof OverrideDataFetcher) || ((OverrideDataFetcher)f).getOverrideMethod() != null)
.collect(Collectors.toList());
|
// Path: src/main/java/com/nfl/glitr/registry/datafetcher/query/CompositeDataFetcher.java
// public class CompositeDataFetcher extends AbstractCompositeDataFetcher {
//
// @SuppressWarnings("unused")
// private static final Logger logger = LoggerFactory.getLogger(CompositeDataFetcher.class);
//
//
// public CompositeDataFetcher(DataFetcher[] fetchers) {
// super(fetchers);
// }
//
// public CompositeDataFetcher(List<DataFetcher> fetchers) {
// super(fetchers);
// }
// }
//
// Path: src/main/java/com/nfl/glitr/registry/datafetcher/query/OverrideDataFetcher.java
// public class OverrideDataFetcher implements DataFetcher {
//
// private static final Logger logger = LoggerFactory.getLogger(OverrideDataFetcher.class);
//
// private Object override;
// private Method overrideMethod;
//
//
// /**
// * This constructor is used for getter overrides placed in the class itself
// *
// * @param name field name
// * @param clazz schema class
// */
// public OverrideDataFetcher(String name, Class clazz) {
// overrideMethod = findMethod("get" + StringUtils.capitalize(name), clazz);
// if (overrideMethod != null) {
// return;
// }
// overrideMethod = findMethod("is" + StringUtils.capitalize(name), clazz);
// }
//
// /**
// * This constructor is used for getter overrides outside of the reference class
// *
// * @param name field name
// * @param override override object
// */
// public OverrideDataFetcher(String name, Object override) {
// this(name, override.getClass());
// this.override = override;
// }
//
// @Override
// public Object get(DataFetchingEnvironment environment) {
// if (overrideMethod == null) {
// return null;
// }
//
// Object obj = override == null ? environment.getSource() : override;
//
// try {
// return overrideMethod.invoke(obj, environment);
// } catch (InvocationTargetException e) {
//
// // If the override method threw a RuntimeException just send it up
// if (e.getTargetException() instanceof RuntimeException) {
// logger.debug("Something went wrong - Unable to fetch result for overrideMethod={{}} of {}", overrideMethod.getName(), obj.getClass().getSimpleName(), e.getTargetException());
// throw (RuntimeException) e.getTargetException();
// }
//
// // Otherwise, wrap it up in a Glitr Exception
// logger.debug("Something went wrong - Unable to fetch result for overrideMethod={{}} of {}", overrideMethod.getName(), obj.getClass().getSimpleName());
// throw new GlitrException("Overwrite method exception", e.getTargetException());
// } catch (Exception e) {
// logger.debug("Something went wrong - Unable to fetch result for overrideMethod={{}} of {}", overrideMethod.getName(), obj.getClass().getSimpleName());
// }
// return null;
// }
//
// private Method findMethod(String name, Class clazz) {
// try {
// //noinspection unchecked
// return clazz.getMethod(name, DataFetchingEnvironment.class);
// } catch (NoSuchMethodException e) {
// logger.debug("Couldn't find method for name {} and class {}", name, clazz, e.getMessage());
// }
// return null;
// }
//
// public Method getOverrideMethod() {
// return overrideMethod;
// }
//
// public Object getOverride() {
// return override;
// }
// }
// Path: src/main/java/com/nfl/glitr/registry/datafetcher/query/batched/CompositeDataFetcherFactory.java
import com.nfl.glitr.registry.datafetcher.query.CompositeDataFetcher;
import com.nfl.glitr.registry.datafetcher.query.OverrideDataFetcher;
import graphql.schema.DataFetcher;
import java.util.List;
import java.util.stream.Collectors;
package com.nfl.glitr.registry.datafetcher.query.batched;
/**
* Create a CompositeDataFetcher based on the supplied DataFetchers.
*
*/
public class CompositeDataFetcherFactory {
public static DataFetcher create(final List<DataFetcher> supplied) {
List<DataFetcher> fetchers = supplied.stream()
// filter out all the OverrideDataFetchers that have a null overrideMethod since type registry adds a default overrideDF
.filter(f -> !(f instanceof OverrideDataFetcher) || ((OverrideDataFetcher)f).getOverrideMethod() != null)
.collect(Collectors.toList());
|
return new CompositeDataFetcher(fetchers);
|
nfl/glitr
|
src/main/java/com/nfl/glitr/registry/GlitrTypeMap.java
|
// Path: src/main/java/com/nfl/glitr/exception/GlitrException.java
// public class GlitrException extends RuntimeException {
//
// public GlitrException(String message) {
// super(message);
// }
//
// public GlitrException(String message, Throwable cause) {
// super(message, cause);
// }
// }
|
import com.nfl.glitr.exception.GlitrException;
import graphql.schema.GraphQLType;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
|
package com.nfl.glitr.registry;
/**
* A map implementation to sync the two kinds of registries currently in {@link com.nfl.glitr.registry.TypeRegistry}.
* Syncs happen dynamically, keeping the nameRegistry appraised of classRegistry additions to ensure unique GraphQLTypes
*/
public class GlitrTypeMap implements ConcurrentMap {
private final Map<Class, GraphQLType> classRegistry = new ConcurrentHashMap<>();
private final Map<String, GraphQLType> nameRegistry = new ConcurrentHashMap<>();
@Override
public Object getOrDefault(Object key, Object defaultValue) {
if (isClass(key)) {
return classRegistry.getOrDefault(key, (GraphQLType) defaultValue);
} else if (isString(key)) {
return nameRegistry.getOrDefault(key, (GraphQLType) defaultValue);
}
|
// Path: src/main/java/com/nfl/glitr/exception/GlitrException.java
// public class GlitrException extends RuntimeException {
//
// public GlitrException(String message) {
// super(message);
// }
//
// public GlitrException(String message, Throwable cause) {
// super(message, cause);
// }
// }
// Path: src/main/java/com/nfl/glitr/registry/GlitrTypeMap.java
import com.nfl.glitr.exception.GlitrException;
import graphql.schema.GraphQLType;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
package com.nfl.glitr.registry;
/**
* A map implementation to sync the two kinds of registries currently in {@link com.nfl.glitr.registry.TypeRegistry}.
* Syncs happen dynamically, keeping the nameRegistry appraised of classRegistry additions to ensure unique GraphQLTypes
*/
public class GlitrTypeMap implements ConcurrentMap {
private final Map<Class, GraphQLType> classRegistry = new ConcurrentHashMap<>();
private final Map<String, GraphQLType> nameRegistry = new ConcurrentHashMap<>();
@Override
public Object getOrDefault(Object key, Object defaultValue) {
if (isClass(key)) {
return classRegistry.getOrDefault(key, (GraphQLType) defaultValue);
} else if (isString(key)) {
return nameRegistry.getOrDefault(key, (GraphQLType) defaultValue);
}
|
throw new GlitrException("Unsupported type passed as key to GlitrTypeMap");
|
nfl/glitr
|
src/main/java/com/nfl/glitr/registry/TypeRegistryBuilder.java
|
// Path: src/main/java/com/nfl/glitr/registry/datafetcher/AnnotationBasedDataFetcherFactory.java
// public interface AnnotationBasedDataFetcherFactory {
//
// DataFetcher create(@Nullable Field field, @Nonnull Method method, @Nonnull Class declaringClass, @Nonnull Annotation annotation);
// }
//
// Path: src/main/java/com/nfl/glitr/relay/Relay.java
// public interface Relay {
//
// GraphQLInterfaceType nodeInterface(TypeResolver typeResolver);
// GraphQLFieldDefinition nodeField(GraphQLInterfaceType nodeInterface, DataFetcher nodeDataFetcher);
//
// List<GraphQLArgument> getConnectionFieldArguments();
// List<GraphQLArgument> getBackwardPaginationConnectionFieldArguments();
// List<GraphQLArgument> getForwardPaginationConnectionFieldArguments();
//
// GraphQLObjectType edgeType(String name,
// GraphQLOutputType nodeType,
// GraphQLInterfaceType nodeInterface,
// List<GraphQLFieldDefinition> edgeFields);
// GraphQLObjectType connectionType(String name,
// GraphQLObjectType edgeType,
// List<GraphQLFieldDefinition> connectionFields);
//
// String toGlobalId(String type, String id);
// graphql.relay.Relay.ResolvedGlobalId fromGlobalId(String globalId);
//
// GraphQLFieldDefinition mutationWithClientMutationId(String name, String fieldName,
// List<GraphQLInputObjectField> inputFields,
// List<GraphQLFieldDefinition> outputFields,
// DataFetcher dataFetcher);
//
// class ResolvedGlobalId {
// public ResolvedGlobalId(String type, String id) {
// this.type = type;
// this.id = id;
// }
//
// public String type;
// public String id;
// }
// }
//
// Path: src/main/java/com/nfl/glitr/relay/RelayConfig.java
// public class RelayConfig {
//
// public static final boolean EXPLICIT_RELAY_NODE_SCAN_DEFAULT = false;
// private final Relay relay;
// private final boolean explicitRelayNodeScanEnabled;
//
//
// private RelayConfig(Relay relay, boolean explicitRelayNodeScanEnabled) {
// this.relay = relay;
// this.explicitRelayNodeScanEnabled = explicitRelayNodeScanEnabled;
// }
//
// public static RelayConfigBuilder newRelayConfig() {
// return new RelayConfigBuilder();
// }
//
// public static class RelayConfigBuilder {
//
// private Relay relay = null;
// private boolean explicitRelayNodeScanEnabled = EXPLICIT_RELAY_NODE_SCAN_DEFAULT;
//
// public RelayConfigBuilder withRelay(Relay relay) {
// this.relay = relay;
// return this;
// }
//
// public RelayConfigBuilder withExplicitRelayNodeScan() {
// this.explicitRelayNodeScanEnabled = true;
// return this;
// }
//
// public RelayConfig build() {
// if (relay == null) {
// this.relay = new RelayImpl();
// }
//
// return new RelayConfig(relay, explicitRelayNodeScanEnabled);
// }
// }
//
// public Relay getRelay() {
// return relay;
// }
//
// public boolean isExplicitRelayNodeScanEnabled() {
// return explicitRelayNodeScanEnabled;
// }
// }
|
import com.nfl.glitr.registry.datafetcher.AnnotationBasedDataFetcherFactory;
import com.nfl.glitr.relay.Relay;
import com.nfl.glitr.relay.RelayConfig;
import graphql.schema.DataFetcher;
import graphql.schema.GraphQLArgument;
import graphql.schema.GraphQLOutputType;
import graphql.schema.GraphQLType;
import rx.functions.Func4;
import rx.functions.Func5;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
|
package com.nfl.glitr.registry;
public class TypeRegistryBuilder {
private Map<Class, List<Object>> overrides = new HashMap<>();
private Map<Class<? extends Annotation>, Func4<Field, Method, Class, Annotation, List<GraphQLArgument>>> annotationToArgumentsProviderMap = new HashMap<>();
private Map<Class<? extends Annotation>, Func5<TypeRegistry, Field, Method, Class, Annotation, GraphQLOutputType>> annotationToGraphQLOutputTypeMap = new HashMap<>();
|
// Path: src/main/java/com/nfl/glitr/registry/datafetcher/AnnotationBasedDataFetcherFactory.java
// public interface AnnotationBasedDataFetcherFactory {
//
// DataFetcher create(@Nullable Field field, @Nonnull Method method, @Nonnull Class declaringClass, @Nonnull Annotation annotation);
// }
//
// Path: src/main/java/com/nfl/glitr/relay/Relay.java
// public interface Relay {
//
// GraphQLInterfaceType nodeInterface(TypeResolver typeResolver);
// GraphQLFieldDefinition nodeField(GraphQLInterfaceType nodeInterface, DataFetcher nodeDataFetcher);
//
// List<GraphQLArgument> getConnectionFieldArguments();
// List<GraphQLArgument> getBackwardPaginationConnectionFieldArguments();
// List<GraphQLArgument> getForwardPaginationConnectionFieldArguments();
//
// GraphQLObjectType edgeType(String name,
// GraphQLOutputType nodeType,
// GraphQLInterfaceType nodeInterface,
// List<GraphQLFieldDefinition> edgeFields);
// GraphQLObjectType connectionType(String name,
// GraphQLObjectType edgeType,
// List<GraphQLFieldDefinition> connectionFields);
//
// String toGlobalId(String type, String id);
// graphql.relay.Relay.ResolvedGlobalId fromGlobalId(String globalId);
//
// GraphQLFieldDefinition mutationWithClientMutationId(String name, String fieldName,
// List<GraphQLInputObjectField> inputFields,
// List<GraphQLFieldDefinition> outputFields,
// DataFetcher dataFetcher);
//
// class ResolvedGlobalId {
// public ResolvedGlobalId(String type, String id) {
// this.type = type;
// this.id = id;
// }
//
// public String type;
// public String id;
// }
// }
//
// Path: src/main/java/com/nfl/glitr/relay/RelayConfig.java
// public class RelayConfig {
//
// public static final boolean EXPLICIT_RELAY_NODE_SCAN_DEFAULT = false;
// private final Relay relay;
// private final boolean explicitRelayNodeScanEnabled;
//
//
// private RelayConfig(Relay relay, boolean explicitRelayNodeScanEnabled) {
// this.relay = relay;
// this.explicitRelayNodeScanEnabled = explicitRelayNodeScanEnabled;
// }
//
// public static RelayConfigBuilder newRelayConfig() {
// return new RelayConfigBuilder();
// }
//
// public static class RelayConfigBuilder {
//
// private Relay relay = null;
// private boolean explicitRelayNodeScanEnabled = EXPLICIT_RELAY_NODE_SCAN_DEFAULT;
//
// public RelayConfigBuilder withRelay(Relay relay) {
// this.relay = relay;
// return this;
// }
//
// public RelayConfigBuilder withExplicitRelayNodeScan() {
// this.explicitRelayNodeScanEnabled = true;
// return this;
// }
//
// public RelayConfig build() {
// if (relay == null) {
// this.relay = new RelayImpl();
// }
//
// return new RelayConfig(relay, explicitRelayNodeScanEnabled);
// }
// }
//
// public Relay getRelay() {
// return relay;
// }
//
// public boolean isExplicitRelayNodeScanEnabled() {
// return explicitRelayNodeScanEnabled;
// }
// }
// Path: src/main/java/com/nfl/glitr/registry/TypeRegistryBuilder.java
import com.nfl.glitr.registry.datafetcher.AnnotationBasedDataFetcherFactory;
import com.nfl.glitr.relay.Relay;
import com.nfl.glitr.relay.RelayConfig;
import graphql.schema.DataFetcher;
import graphql.schema.GraphQLArgument;
import graphql.schema.GraphQLOutputType;
import graphql.schema.GraphQLType;
import rx.functions.Func4;
import rx.functions.Func5;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
package com.nfl.glitr.registry;
public class TypeRegistryBuilder {
private Map<Class, List<Object>> overrides = new HashMap<>();
private Map<Class<? extends Annotation>, Func4<Field, Method, Class, Annotation, List<GraphQLArgument>>> annotationToArgumentsProviderMap = new HashMap<>();
private Map<Class<? extends Annotation>, Func5<TypeRegistry, Field, Method, Class, Annotation, GraphQLOutputType>> annotationToGraphQLOutputTypeMap = new HashMap<>();
|
private Map<Class<? extends Annotation>, AnnotationBasedDataFetcherFactory> annotationToDataFetcherFactoryMap = new HashMap<>();
|
nfl/glitr
|
src/main/java/com/nfl/glitr/registry/TypeRegistryBuilder.java
|
// Path: src/main/java/com/nfl/glitr/registry/datafetcher/AnnotationBasedDataFetcherFactory.java
// public interface AnnotationBasedDataFetcherFactory {
//
// DataFetcher create(@Nullable Field field, @Nonnull Method method, @Nonnull Class declaringClass, @Nonnull Annotation annotation);
// }
//
// Path: src/main/java/com/nfl/glitr/relay/Relay.java
// public interface Relay {
//
// GraphQLInterfaceType nodeInterface(TypeResolver typeResolver);
// GraphQLFieldDefinition nodeField(GraphQLInterfaceType nodeInterface, DataFetcher nodeDataFetcher);
//
// List<GraphQLArgument> getConnectionFieldArguments();
// List<GraphQLArgument> getBackwardPaginationConnectionFieldArguments();
// List<GraphQLArgument> getForwardPaginationConnectionFieldArguments();
//
// GraphQLObjectType edgeType(String name,
// GraphQLOutputType nodeType,
// GraphQLInterfaceType nodeInterface,
// List<GraphQLFieldDefinition> edgeFields);
// GraphQLObjectType connectionType(String name,
// GraphQLObjectType edgeType,
// List<GraphQLFieldDefinition> connectionFields);
//
// String toGlobalId(String type, String id);
// graphql.relay.Relay.ResolvedGlobalId fromGlobalId(String globalId);
//
// GraphQLFieldDefinition mutationWithClientMutationId(String name, String fieldName,
// List<GraphQLInputObjectField> inputFields,
// List<GraphQLFieldDefinition> outputFields,
// DataFetcher dataFetcher);
//
// class ResolvedGlobalId {
// public ResolvedGlobalId(String type, String id) {
// this.type = type;
// this.id = id;
// }
//
// public String type;
// public String id;
// }
// }
//
// Path: src/main/java/com/nfl/glitr/relay/RelayConfig.java
// public class RelayConfig {
//
// public static final boolean EXPLICIT_RELAY_NODE_SCAN_DEFAULT = false;
// private final Relay relay;
// private final boolean explicitRelayNodeScanEnabled;
//
//
// private RelayConfig(Relay relay, boolean explicitRelayNodeScanEnabled) {
// this.relay = relay;
// this.explicitRelayNodeScanEnabled = explicitRelayNodeScanEnabled;
// }
//
// public static RelayConfigBuilder newRelayConfig() {
// return new RelayConfigBuilder();
// }
//
// public static class RelayConfigBuilder {
//
// private Relay relay = null;
// private boolean explicitRelayNodeScanEnabled = EXPLICIT_RELAY_NODE_SCAN_DEFAULT;
//
// public RelayConfigBuilder withRelay(Relay relay) {
// this.relay = relay;
// return this;
// }
//
// public RelayConfigBuilder withExplicitRelayNodeScan() {
// this.explicitRelayNodeScanEnabled = true;
// return this;
// }
//
// public RelayConfig build() {
// if (relay == null) {
// this.relay = new RelayImpl();
// }
//
// return new RelayConfig(relay, explicitRelayNodeScanEnabled);
// }
// }
//
// public Relay getRelay() {
// return relay;
// }
//
// public boolean isExplicitRelayNodeScanEnabled() {
// return explicitRelayNodeScanEnabled;
// }
// }
|
import com.nfl.glitr.registry.datafetcher.AnnotationBasedDataFetcherFactory;
import com.nfl.glitr.relay.Relay;
import com.nfl.glitr.relay.RelayConfig;
import graphql.schema.DataFetcher;
import graphql.schema.GraphQLArgument;
import graphql.schema.GraphQLOutputType;
import graphql.schema.GraphQLType;
import rx.functions.Func4;
import rx.functions.Func5;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
|
package com.nfl.glitr.registry;
public class TypeRegistryBuilder {
private Map<Class, List<Object>> overrides = new HashMap<>();
private Map<Class<? extends Annotation>, Func4<Field, Method, Class, Annotation, List<GraphQLArgument>>> annotationToArgumentsProviderMap = new HashMap<>();
private Map<Class<? extends Annotation>, Func5<TypeRegistry, Field, Method, Class, Annotation, GraphQLOutputType>> annotationToGraphQLOutputTypeMap = new HashMap<>();
private Map<Class<? extends Annotation>, AnnotationBasedDataFetcherFactory> annotationToDataFetcherFactoryMap = new HashMap<>();
private Map<Class<? extends Annotation>, DataFetcher> annotationToDataFetcherMap = new HashMap<>();
private Map<Class, GraphQLType> javaTypeDeclaredAsScalarMap = new HashMap<>();
|
// Path: src/main/java/com/nfl/glitr/registry/datafetcher/AnnotationBasedDataFetcherFactory.java
// public interface AnnotationBasedDataFetcherFactory {
//
// DataFetcher create(@Nullable Field field, @Nonnull Method method, @Nonnull Class declaringClass, @Nonnull Annotation annotation);
// }
//
// Path: src/main/java/com/nfl/glitr/relay/Relay.java
// public interface Relay {
//
// GraphQLInterfaceType nodeInterface(TypeResolver typeResolver);
// GraphQLFieldDefinition nodeField(GraphQLInterfaceType nodeInterface, DataFetcher nodeDataFetcher);
//
// List<GraphQLArgument> getConnectionFieldArguments();
// List<GraphQLArgument> getBackwardPaginationConnectionFieldArguments();
// List<GraphQLArgument> getForwardPaginationConnectionFieldArguments();
//
// GraphQLObjectType edgeType(String name,
// GraphQLOutputType nodeType,
// GraphQLInterfaceType nodeInterface,
// List<GraphQLFieldDefinition> edgeFields);
// GraphQLObjectType connectionType(String name,
// GraphQLObjectType edgeType,
// List<GraphQLFieldDefinition> connectionFields);
//
// String toGlobalId(String type, String id);
// graphql.relay.Relay.ResolvedGlobalId fromGlobalId(String globalId);
//
// GraphQLFieldDefinition mutationWithClientMutationId(String name, String fieldName,
// List<GraphQLInputObjectField> inputFields,
// List<GraphQLFieldDefinition> outputFields,
// DataFetcher dataFetcher);
//
// class ResolvedGlobalId {
// public ResolvedGlobalId(String type, String id) {
// this.type = type;
// this.id = id;
// }
//
// public String type;
// public String id;
// }
// }
//
// Path: src/main/java/com/nfl/glitr/relay/RelayConfig.java
// public class RelayConfig {
//
// public static final boolean EXPLICIT_RELAY_NODE_SCAN_DEFAULT = false;
// private final Relay relay;
// private final boolean explicitRelayNodeScanEnabled;
//
//
// private RelayConfig(Relay relay, boolean explicitRelayNodeScanEnabled) {
// this.relay = relay;
// this.explicitRelayNodeScanEnabled = explicitRelayNodeScanEnabled;
// }
//
// public static RelayConfigBuilder newRelayConfig() {
// return new RelayConfigBuilder();
// }
//
// public static class RelayConfigBuilder {
//
// private Relay relay = null;
// private boolean explicitRelayNodeScanEnabled = EXPLICIT_RELAY_NODE_SCAN_DEFAULT;
//
// public RelayConfigBuilder withRelay(Relay relay) {
// this.relay = relay;
// return this;
// }
//
// public RelayConfigBuilder withExplicitRelayNodeScan() {
// this.explicitRelayNodeScanEnabled = true;
// return this;
// }
//
// public RelayConfig build() {
// if (relay == null) {
// this.relay = new RelayImpl();
// }
//
// return new RelayConfig(relay, explicitRelayNodeScanEnabled);
// }
// }
//
// public Relay getRelay() {
// return relay;
// }
//
// public boolean isExplicitRelayNodeScanEnabled() {
// return explicitRelayNodeScanEnabled;
// }
// }
// Path: src/main/java/com/nfl/glitr/registry/TypeRegistryBuilder.java
import com.nfl.glitr.registry.datafetcher.AnnotationBasedDataFetcherFactory;
import com.nfl.glitr.relay.Relay;
import com.nfl.glitr.relay.RelayConfig;
import graphql.schema.DataFetcher;
import graphql.schema.GraphQLArgument;
import graphql.schema.GraphQLOutputType;
import graphql.schema.GraphQLType;
import rx.functions.Func4;
import rx.functions.Func5;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
package com.nfl.glitr.registry;
public class TypeRegistryBuilder {
private Map<Class, List<Object>> overrides = new HashMap<>();
private Map<Class<? extends Annotation>, Func4<Field, Method, Class, Annotation, List<GraphQLArgument>>> annotationToArgumentsProviderMap = new HashMap<>();
private Map<Class<? extends Annotation>, Func5<TypeRegistry, Field, Method, Class, Annotation, GraphQLOutputType>> annotationToGraphQLOutputTypeMap = new HashMap<>();
private Map<Class<? extends Annotation>, AnnotationBasedDataFetcherFactory> annotationToDataFetcherFactoryMap = new HashMap<>();
private Map<Class<? extends Annotation>, DataFetcher> annotationToDataFetcherMap = new HashMap<>();
private Map<Class, GraphQLType> javaTypeDeclaredAsScalarMap = new HashMap<>();
|
private Relay relay = null;
|
nfl/glitr
|
src/main/java/com/nfl/glitr/registry/TypeRegistryBuilder.java
|
// Path: src/main/java/com/nfl/glitr/registry/datafetcher/AnnotationBasedDataFetcherFactory.java
// public interface AnnotationBasedDataFetcherFactory {
//
// DataFetcher create(@Nullable Field field, @Nonnull Method method, @Nonnull Class declaringClass, @Nonnull Annotation annotation);
// }
//
// Path: src/main/java/com/nfl/glitr/relay/Relay.java
// public interface Relay {
//
// GraphQLInterfaceType nodeInterface(TypeResolver typeResolver);
// GraphQLFieldDefinition nodeField(GraphQLInterfaceType nodeInterface, DataFetcher nodeDataFetcher);
//
// List<GraphQLArgument> getConnectionFieldArguments();
// List<GraphQLArgument> getBackwardPaginationConnectionFieldArguments();
// List<GraphQLArgument> getForwardPaginationConnectionFieldArguments();
//
// GraphQLObjectType edgeType(String name,
// GraphQLOutputType nodeType,
// GraphQLInterfaceType nodeInterface,
// List<GraphQLFieldDefinition> edgeFields);
// GraphQLObjectType connectionType(String name,
// GraphQLObjectType edgeType,
// List<GraphQLFieldDefinition> connectionFields);
//
// String toGlobalId(String type, String id);
// graphql.relay.Relay.ResolvedGlobalId fromGlobalId(String globalId);
//
// GraphQLFieldDefinition mutationWithClientMutationId(String name, String fieldName,
// List<GraphQLInputObjectField> inputFields,
// List<GraphQLFieldDefinition> outputFields,
// DataFetcher dataFetcher);
//
// class ResolvedGlobalId {
// public ResolvedGlobalId(String type, String id) {
// this.type = type;
// this.id = id;
// }
//
// public String type;
// public String id;
// }
// }
//
// Path: src/main/java/com/nfl/glitr/relay/RelayConfig.java
// public class RelayConfig {
//
// public static final boolean EXPLICIT_RELAY_NODE_SCAN_DEFAULT = false;
// private final Relay relay;
// private final boolean explicitRelayNodeScanEnabled;
//
//
// private RelayConfig(Relay relay, boolean explicitRelayNodeScanEnabled) {
// this.relay = relay;
// this.explicitRelayNodeScanEnabled = explicitRelayNodeScanEnabled;
// }
//
// public static RelayConfigBuilder newRelayConfig() {
// return new RelayConfigBuilder();
// }
//
// public static class RelayConfigBuilder {
//
// private Relay relay = null;
// private boolean explicitRelayNodeScanEnabled = EXPLICIT_RELAY_NODE_SCAN_DEFAULT;
//
// public RelayConfigBuilder withRelay(Relay relay) {
// this.relay = relay;
// return this;
// }
//
// public RelayConfigBuilder withExplicitRelayNodeScan() {
// this.explicitRelayNodeScanEnabled = true;
// return this;
// }
//
// public RelayConfig build() {
// if (relay == null) {
// this.relay = new RelayImpl();
// }
//
// return new RelayConfig(relay, explicitRelayNodeScanEnabled);
// }
// }
//
// public Relay getRelay() {
// return relay;
// }
//
// public boolean isExplicitRelayNodeScanEnabled() {
// return explicitRelayNodeScanEnabled;
// }
// }
|
import com.nfl.glitr.registry.datafetcher.AnnotationBasedDataFetcherFactory;
import com.nfl.glitr.relay.Relay;
import com.nfl.glitr.relay.RelayConfig;
import graphql.schema.DataFetcher;
import graphql.schema.GraphQLArgument;
import graphql.schema.GraphQLOutputType;
import graphql.schema.GraphQLType;
import rx.functions.Func4;
import rx.functions.Func5;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
|
package com.nfl.glitr.registry;
public class TypeRegistryBuilder {
private Map<Class, List<Object>> overrides = new HashMap<>();
private Map<Class<? extends Annotation>, Func4<Field, Method, Class, Annotation, List<GraphQLArgument>>> annotationToArgumentsProviderMap = new HashMap<>();
private Map<Class<? extends Annotation>, Func5<TypeRegistry, Field, Method, Class, Annotation, GraphQLOutputType>> annotationToGraphQLOutputTypeMap = new HashMap<>();
private Map<Class<? extends Annotation>, AnnotationBasedDataFetcherFactory> annotationToDataFetcherFactoryMap = new HashMap<>();
private Map<Class<? extends Annotation>, DataFetcher> annotationToDataFetcherMap = new HashMap<>();
private Map<Class, GraphQLType> javaTypeDeclaredAsScalarMap = new HashMap<>();
private Relay relay = null;
|
// Path: src/main/java/com/nfl/glitr/registry/datafetcher/AnnotationBasedDataFetcherFactory.java
// public interface AnnotationBasedDataFetcherFactory {
//
// DataFetcher create(@Nullable Field field, @Nonnull Method method, @Nonnull Class declaringClass, @Nonnull Annotation annotation);
// }
//
// Path: src/main/java/com/nfl/glitr/relay/Relay.java
// public interface Relay {
//
// GraphQLInterfaceType nodeInterface(TypeResolver typeResolver);
// GraphQLFieldDefinition nodeField(GraphQLInterfaceType nodeInterface, DataFetcher nodeDataFetcher);
//
// List<GraphQLArgument> getConnectionFieldArguments();
// List<GraphQLArgument> getBackwardPaginationConnectionFieldArguments();
// List<GraphQLArgument> getForwardPaginationConnectionFieldArguments();
//
// GraphQLObjectType edgeType(String name,
// GraphQLOutputType nodeType,
// GraphQLInterfaceType nodeInterface,
// List<GraphQLFieldDefinition> edgeFields);
// GraphQLObjectType connectionType(String name,
// GraphQLObjectType edgeType,
// List<GraphQLFieldDefinition> connectionFields);
//
// String toGlobalId(String type, String id);
// graphql.relay.Relay.ResolvedGlobalId fromGlobalId(String globalId);
//
// GraphQLFieldDefinition mutationWithClientMutationId(String name, String fieldName,
// List<GraphQLInputObjectField> inputFields,
// List<GraphQLFieldDefinition> outputFields,
// DataFetcher dataFetcher);
//
// class ResolvedGlobalId {
// public ResolvedGlobalId(String type, String id) {
// this.type = type;
// this.id = id;
// }
//
// public String type;
// public String id;
// }
// }
//
// Path: src/main/java/com/nfl/glitr/relay/RelayConfig.java
// public class RelayConfig {
//
// public static final boolean EXPLICIT_RELAY_NODE_SCAN_DEFAULT = false;
// private final Relay relay;
// private final boolean explicitRelayNodeScanEnabled;
//
//
// private RelayConfig(Relay relay, boolean explicitRelayNodeScanEnabled) {
// this.relay = relay;
// this.explicitRelayNodeScanEnabled = explicitRelayNodeScanEnabled;
// }
//
// public static RelayConfigBuilder newRelayConfig() {
// return new RelayConfigBuilder();
// }
//
// public static class RelayConfigBuilder {
//
// private Relay relay = null;
// private boolean explicitRelayNodeScanEnabled = EXPLICIT_RELAY_NODE_SCAN_DEFAULT;
//
// public RelayConfigBuilder withRelay(Relay relay) {
// this.relay = relay;
// return this;
// }
//
// public RelayConfigBuilder withExplicitRelayNodeScan() {
// this.explicitRelayNodeScanEnabled = true;
// return this;
// }
//
// public RelayConfig build() {
// if (relay == null) {
// this.relay = new RelayImpl();
// }
//
// return new RelayConfig(relay, explicitRelayNodeScanEnabled);
// }
// }
//
// public Relay getRelay() {
// return relay;
// }
//
// public boolean isExplicitRelayNodeScanEnabled() {
// return explicitRelayNodeScanEnabled;
// }
// }
// Path: src/main/java/com/nfl/glitr/registry/TypeRegistryBuilder.java
import com.nfl.glitr.registry.datafetcher.AnnotationBasedDataFetcherFactory;
import com.nfl.glitr.relay.Relay;
import com.nfl.glitr.relay.RelayConfig;
import graphql.schema.DataFetcher;
import graphql.schema.GraphQLArgument;
import graphql.schema.GraphQLOutputType;
import graphql.schema.GraphQLType;
import rx.functions.Func4;
import rx.functions.Func5;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
package com.nfl.glitr.registry;
public class TypeRegistryBuilder {
private Map<Class, List<Object>> overrides = new HashMap<>();
private Map<Class<? extends Annotation>, Func4<Field, Method, Class, Annotation, List<GraphQLArgument>>> annotationToArgumentsProviderMap = new HashMap<>();
private Map<Class<? extends Annotation>, Func5<TypeRegistry, Field, Method, Class, Annotation, GraphQLOutputType>> annotationToGraphQLOutputTypeMap = new HashMap<>();
private Map<Class<? extends Annotation>, AnnotationBasedDataFetcherFactory> annotationToDataFetcherFactoryMap = new HashMap<>();
private Map<Class<? extends Annotation>, DataFetcher> annotationToDataFetcherMap = new HashMap<>();
private Map<Class, GraphQLType> javaTypeDeclaredAsScalarMap = new HashMap<>();
private Relay relay = null;
|
private boolean explicitRelayNodeScanEnabled = RelayConfig.EXPLICIT_RELAY_NODE_SCAN_DEFAULT;
|
nfl/glitr
|
src/test/groovy/com/nfl/glitr/data/query/additionalTypes/QueryRoot.java
|
// Path: src/test/groovy/com/nfl/glitr/data/query/PublishType.java
// public enum PublishType {
// PUBLISHED, UNPUBLISHED, UNLISTED
// }
//
// Path: src/test/groovy/com/nfl/glitr/data/query/Video.java
// public class Video extends AbstractContent implements Playable {
//
// private String id;
// private String url;
// private List<Bitrate> bitrateList;
//
//
// public List<Bitrate> getBitrateList() {
// return bitrateList;
// }
//
// public String getId() {
// return id;
// }
//
// public String getUrl() {
// return url;
// }
//
// @GlitrForwardPagingArguments
// public List<Video> getChildren() {
// return null;
// }
//
// @GlitrQueryComplexity("#{depth}")
// public List<Video> getDepth() {
// return null;
// }
//
// @GlitrQueryComplexity("#{totalCollectionsSize}")
// public List<Video> getTotalCollectionsSize() {
// return null;
// }
//
// @GlitrQueryComplexity("#{depth} + #{childScore} + #{currentCollectionSize} + #{totalCollectionsSize} + #{maxCharacterLimit} + #{maxDepthLimit} + #{maxScoreLimit} + #{defaultMultiplier} + 5")
// public List<Video> getAllVariablesComplexityFormula() {
// return null;
// }
//
// @GlitrQueryComplexity(ignore = true)
// public List<Video> getIgnore() {
// return null;
// }
//
// @GlitrForwardPagingArguments
// public List<Video> getFragments() {
// return null;
// }
// }
|
import com.nfl.glitr.annotation.GlitrArgument;
import com.nfl.glitr.data.query.PublishType;
import com.nfl.glitr.data.query.Video;
import java.util.List;
|
package com.nfl.glitr.data.query.additionalTypes;
public class QueryRoot {
public Person getPerson() {
return null;
}
@GlitrArgument(name = "video_default", defaultValue = "No Default Value", type = String.class, required = true)
|
// Path: src/test/groovy/com/nfl/glitr/data/query/PublishType.java
// public enum PublishType {
// PUBLISHED, UNPUBLISHED, UNLISTED
// }
//
// Path: src/test/groovy/com/nfl/glitr/data/query/Video.java
// public class Video extends AbstractContent implements Playable {
//
// private String id;
// private String url;
// private List<Bitrate> bitrateList;
//
//
// public List<Bitrate> getBitrateList() {
// return bitrateList;
// }
//
// public String getId() {
// return id;
// }
//
// public String getUrl() {
// return url;
// }
//
// @GlitrForwardPagingArguments
// public List<Video> getChildren() {
// return null;
// }
//
// @GlitrQueryComplexity("#{depth}")
// public List<Video> getDepth() {
// return null;
// }
//
// @GlitrQueryComplexity("#{totalCollectionsSize}")
// public List<Video> getTotalCollectionsSize() {
// return null;
// }
//
// @GlitrQueryComplexity("#{depth} + #{childScore} + #{currentCollectionSize} + #{totalCollectionsSize} + #{maxCharacterLimit} + #{maxDepthLimit} + #{maxScoreLimit} + #{defaultMultiplier} + 5")
// public List<Video> getAllVariablesComplexityFormula() {
// return null;
// }
//
// @GlitrQueryComplexity(ignore = true)
// public List<Video> getIgnore() {
// return null;
// }
//
// @GlitrForwardPagingArguments
// public List<Video> getFragments() {
// return null;
// }
// }
// Path: src/test/groovy/com/nfl/glitr/data/query/additionalTypes/QueryRoot.java
import com.nfl.glitr.annotation.GlitrArgument;
import com.nfl.glitr.data.query.PublishType;
import com.nfl.glitr.data.query.Video;
import java.util.List;
package com.nfl.glitr.data.query.additionalTypes;
public class QueryRoot {
public Person getPerson() {
return null;
}
@GlitrArgument(name = "video_default", defaultValue = "No Default Value", type = String.class, required = true)
|
public List<Video> getDefaultVideo() {
|
nfl/glitr
|
src/test/groovy/com/nfl/glitr/data/query/additionalTypes/QueryRoot.java
|
// Path: src/test/groovy/com/nfl/glitr/data/query/PublishType.java
// public enum PublishType {
// PUBLISHED, UNPUBLISHED, UNLISTED
// }
//
// Path: src/test/groovy/com/nfl/glitr/data/query/Video.java
// public class Video extends AbstractContent implements Playable {
//
// private String id;
// private String url;
// private List<Bitrate> bitrateList;
//
//
// public List<Bitrate> getBitrateList() {
// return bitrateList;
// }
//
// public String getId() {
// return id;
// }
//
// public String getUrl() {
// return url;
// }
//
// @GlitrForwardPagingArguments
// public List<Video> getChildren() {
// return null;
// }
//
// @GlitrQueryComplexity("#{depth}")
// public List<Video> getDepth() {
// return null;
// }
//
// @GlitrQueryComplexity("#{totalCollectionsSize}")
// public List<Video> getTotalCollectionsSize() {
// return null;
// }
//
// @GlitrQueryComplexity("#{depth} + #{childScore} + #{currentCollectionSize} + #{totalCollectionsSize} + #{maxCharacterLimit} + #{maxDepthLimit} + #{maxScoreLimit} + #{defaultMultiplier} + 5")
// public List<Video> getAllVariablesComplexityFormula() {
// return null;
// }
//
// @GlitrQueryComplexity(ignore = true)
// public List<Video> getIgnore() {
// return null;
// }
//
// @GlitrForwardPagingArguments
// public List<Video> getFragments() {
// return null;
// }
// }
|
import com.nfl.glitr.annotation.GlitrArgument;
import com.nfl.glitr.data.query.PublishType;
import com.nfl.glitr.data.query.Video;
import java.util.List;
|
package com.nfl.glitr.data.query.additionalTypes;
public class QueryRoot {
public Person getPerson() {
return null;
}
@GlitrArgument(name = "video_default", defaultValue = "No Default Value", type = String.class, required = true)
public List<Video> getDefaultVideo() {
return null;
}
@GlitrArgument(name = "video_non_enum", defaultValue = "defaultTest", type = String.class, required = true)
public List<Video> getNonEnumVideo() {
return null;
}
|
// Path: src/test/groovy/com/nfl/glitr/data/query/PublishType.java
// public enum PublishType {
// PUBLISHED, UNPUBLISHED, UNLISTED
// }
//
// Path: src/test/groovy/com/nfl/glitr/data/query/Video.java
// public class Video extends AbstractContent implements Playable {
//
// private String id;
// private String url;
// private List<Bitrate> bitrateList;
//
//
// public List<Bitrate> getBitrateList() {
// return bitrateList;
// }
//
// public String getId() {
// return id;
// }
//
// public String getUrl() {
// return url;
// }
//
// @GlitrForwardPagingArguments
// public List<Video> getChildren() {
// return null;
// }
//
// @GlitrQueryComplexity("#{depth}")
// public List<Video> getDepth() {
// return null;
// }
//
// @GlitrQueryComplexity("#{totalCollectionsSize}")
// public List<Video> getTotalCollectionsSize() {
// return null;
// }
//
// @GlitrQueryComplexity("#{depth} + #{childScore} + #{currentCollectionSize} + #{totalCollectionsSize} + #{maxCharacterLimit} + #{maxDepthLimit} + #{maxScoreLimit} + #{defaultMultiplier} + 5")
// public List<Video> getAllVariablesComplexityFormula() {
// return null;
// }
//
// @GlitrQueryComplexity(ignore = true)
// public List<Video> getIgnore() {
// return null;
// }
//
// @GlitrForwardPagingArguments
// public List<Video> getFragments() {
// return null;
// }
// }
// Path: src/test/groovy/com/nfl/glitr/data/query/additionalTypes/QueryRoot.java
import com.nfl.glitr.annotation.GlitrArgument;
import com.nfl.glitr.data.query.PublishType;
import com.nfl.glitr.data.query.Video;
import java.util.List;
package com.nfl.glitr.data.query.additionalTypes;
public class QueryRoot {
public Person getPerson() {
return null;
}
@GlitrArgument(name = "video_default", defaultValue = "No Default Value", type = String.class, required = true)
public List<Video> getDefaultVideo() {
return null;
}
@GlitrArgument(name = "video_non_enum", defaultValue = "defaultTest", type = String.class, required = true)
public List<Video> getNonEnumVideo() {
return null;
}
|
@GlitrArgument(name = "video_enum", defaultValue = "PUBLISHED", type = PublishType.class, required = true)
|
nighthary/phoneContact
|
Contacts_1.1.0/src/com/night/contact/contact/Utils.java
|
// Path: Contacts_1.1.0/src/com/night/contact/bean/SortEntry.java
// public class SortEntry implements Parcelable{
// public String mID; // ÔÚÊý¾Ý¿âÖеÄIDºÅ
// public String mName; // ÐÕÃû
// public String mPY; // ÐÕÃûÆ´Òô
// public String mNum; // µç»°ºÅÂë
// public String mFisrtSpell; // ÖÐÎÄÃûÊ××Öĸ Àý:ÕÅÑ©±ù:zxb
// public int mchoose; // ÊÇ·ñÑ¡ÖÐ 0--δѡÖÐ 1---Ñ¡ÖÐ
// public int mOrder; // ÔÚÔCursorÖеÄλÖÃ
// public String lookUpKey;
// public int photoId;
// public int groupId;
// public String groupName;
// public Bitmap contactPhoto;// ÕÕÆ¬
// public String formattedNumber;
// @Override
// public int describeContents() {
// return 0;
// }
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(mID);
// dest.writeString(mName);
// dest.writeString(mPY);
// dest.writeString(mNum);
// dest.writeString(mFisrtSpell);
// dest.writeInt(mchoose);
// dest.writeInt(mOrder);
// dest.writeString(lookUpKey);
// dest.writeInt(photoId);
// dest.writeInt(groupId);
// dest.writeString(groupName);
// dest.writeString(formattedNumber);
// }
//
//
// // ÖØÐ´Creator
// public static final Parcelable.Creator<SortEntry> CREATOR = new Creator<SortEntry>() {
//
// @Override
// public SortEntry createFromParcel(Parcel source) {
// SortEntry contact = new SortEntry();
// contact.mID = source.readString();
// contact.mName = source.readString();
// contact.mPY = source.readString();
// contact.mNum = source.readString();
// contact.mFisrtSpell = source.readString();
// contact.mchoose = source.readInt();
// contact.mOrder = source.readInt();
// contact.lookUpKey = source.readString();
// contact.photoId = source.readInt();
// contact.groupId = source.readInt();
// contact.groupName = source.readString();
// contact.formattedNumber = source.readString();
// return contact;
// }
//
// @Override
// public SortEntry[] newArray(int size) {
// return new SortEntry[size];
// }
//
// };
// }
|
import java.util.ArrayList;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.net.Uri;
import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.CommonDataKinds.StructuredName;
import android.provider.ContactsContract.RawContacts;
import android.provider.ContactsContract.RawContacts.Data;
import android.util.Log;
import com.night.contact.bean.SortEntry;
|
package com.night.contact.contact;
/**
* database²Ù×÷Àà
* @deprecated
* @author NightHary
*
*/
public class Utils {
public static Context m_context;
//ËùÓÐÁªÏµÈ˵ÄÊý¾Ýlist
|
// Path: Contacts_1.1.0/src/com/night/contact/bean/SortEntry.java
// public class SortEntry implements Parcelable{
// public String mID; // ÔÚÊý¾Ý¿âÖеÄIDºÅ
// public String mName; // ÐÕÃû
// public String mPY; // ÐÕÃûÆ´Òô
// public String mNum; // µç»°ºÅÂë
// public String mFisrtSpell; // ÖÐÎÄÃûÊ××Öĸ Àý:ÕÅÑ©±ù:zxb
// public int mchoose; // ÊÇ·ñÑ¡ÖÐ 0--δѡÖÐ 1---Ñ¡ÖÐ
// public int mOrder; // ÔÚÔCursorÖеÄλÖÃ
// public String lookUpKey;
// public int photoId;
// public int groupId;
// public String groupName;
// public Bitmap contactPhoto;// ÕÕÆ¬
// public String formattedNumber;
// @Override
// public int describeContents() {
// return 0;
// }
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(mID);
// dest.writeString(mName);
// dest.writeString(mPY);
// dest.writeString(mNum);
// dest.writeString(mFisrtSpell);
// dest.writeInt(mchoose);
// dest.writeInt(mOrder);
// dest.writeString(lookUpKey);
// dest.writeInt(photoId);
// dest.writeInt(groupId);
// dest.writeString(groupName);
// dest.writeString(formattedNumber);
// }
//
//
// // ÖØÐ´Creator
// public static final Parcelable.Creator<SortEntry> CREATOR = new Creator<SortEntry>() {
//
// @Override
// public SortEntry createFromParcel(Parcel source) {
// SortEntry contact = new SortEntry();
// contact.mID = source.readString();
// contact.mName = source.readString();
// contact.mPY = source.readString();
// contact.mNum = source.readString();
// contact.mFisrtSpell = source.readString();
// contact.mchoose = source.readInt();
// contact.mOrder = source.readInt();
// contact.lookUpKey = source.readString();
// contact.photoId = source.readInt();
// contact.groupId = source.readInt();
// contact.groupName = source.readString();
// contact.formattedNumber = source.readString();
// return contact;
// }
//
// @Override
// public SortEntry[] newArray(int size) {
// return new SortEntry[size];
// }
//
// };
// }
// Path: Contacts_1.1.0/src/com/night/contact/contact/Utils.java
import java.util.ArrayList;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.net.Uri;
import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.CommonDataKinds.StructuredName;
import android.provider.ContactsContract.RawContacts;
import android.provider.ContactsContract.RawContacts.Data;
import android.util.Log;
import com.night.contact.bean.SortEntry;
package com.night.contact.contact;
/**
* database²Ù×÷Àà
* @deprecated
* @author NightHary
*
*/
public class Utils {
public static Context m_context;
//ËùÓÐÁªÏµÈ˵ÄÊý¾Ýlist
|
public static ArrayList<SortEntry> mPersons = new ArrayList<SortEntry>();
|
nighthary/phoneContact
|
Contacts_1.1.0/src/com/night/contact/util/PinyinUtils.java
|
// Path: Contacts_1.1.0/src/com/night/contact/util/HanziToPinyin.java
// public static class Token {
// /**
// * Separator between target string for each source char
// */
// public static final String SEPARATOR = " ";
//
// public static final int LATIN = 1;
// public static final int PINYIN = 2;
// public static final int UNKNOWN = 3;
//
// public Token() {
// }
//
// public Token(int type, String source, String target) {
// this.type = type;
// this.source = source;
// this.target = target;
// }
//
// /**
// * Type of this token, ASCII, PINYIN or UNKNOWN.
// */
// public int type;
// /**
// * Original string before translation.
// */
// public String source;
// /**
// * Translated string of source. For Han, target is corresponding Pinyin. Otherwise target is
// * original string in source.
// */
// public String target;
// }
|
import java.util.ArrayList;
import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
import com.night.contact.util.HanziToPinyin.Token;
|
* ºº×Öת»»ÎªººÓïÆ´ÒôÊ××Öĸ£¬Ó¢ÎÄ×Ö·û²»±ä
* »¨»¨´óÉñ->hhds
* @param chines
* ºº×Ö
* @return Æ´Òô
*/
public static String getFirstSpell(String chinese) {
StringBuffer pybf = new StringBuffer();
char[] arr = chinese.toCharArray();
HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
for (char curchar : arr) {
if (curchar > 128) {
try {
String[] temp = PinyinHelper.toHanyuPinyinStringArray(curchar, defaultFormat);
if (temp != null) {
pybf.append(temp[0].charAt(0));
}
} catch (BadHanyuPinyinOutputFormatCombination e) {
e.printStackTrace();
}
} else {
pybf.append(curchar);
}
}
return pybf.toString().replaceAll("\\W", "").trim();
}
public static String getPingYin1(String input){
|
// Path: Contacts_1.1.0/src/com/night/contact/util/HanziToPinyin.java
// public static class Token {
// /**
// * Separator between target string for each source char
// */
// public static final String SEPARATOR = " ";
//
// public static final int LATIN = 1;
// public static final int PINYIN = 2;
// public static final int UNKNOWN = 3;
//
// public Token() {
// }
//
// public Token(int type, String source, String target) {
// this.type = type;
// this.source = source;
// this.target = target;
// }
//
// /**
// * Type of this token, ASCII, PINYIN or UNKNOWN.
// */
// public int type;
// /**
// * Original string before translation.
// */
// public String source;
// /**
// * Translated string of source. For Han, target is corresponding Pinyin. Otherwise target is
// * original string in source.
// */
// public String target;
// }
// Path: Contacts_1.1.0/src/com/night/contact/util/PinyinUtils.java
import java.util.ArrayList;
import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
import com.night.contact.util.HanziToPinyin.Token;
* ºº×Öת»»ÎªººÓïÆ´ÒôÊ××Öĸ£¬Ó¢ÎÄ×Ö·û²»±ä
* »¨»¨´óÉñ->hhds
* @param chines
* ºº×Ö
* @return Æ´Òô
*/
public static String getFirstSpell(String chinese) {
StringBuffer pybf = new StringBuffer();
char[] arr = chinese.toCharArray();
HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
for (char curchar : arr) {
if (curchar > 128) {
try {
String[] temp = PinyinHelper.toHanyuPinyinStringArray(curchar, defaultFormat);
if (temp != null) {
pybf.append(temp[0].charAt(0));
}
} catch (BadHanyuPinyinOutputFormatCombination e) {
e.printStackTrace();
}
} else {
pybf.append(curchar);
}
}
return pybf.toString().replaceAll("\\W", "").trim();
}
public static String getPingYin1(String input){
|
ArrayList<Token> tokens = HanziToPinyin.getInstance().get(input);
|
nighthary/phoneContact
|
Contacts_1.1.0/src/com/night/contact/contact/ContactsCursorAdapter.java
|
// Path: Contacts_1.1.0/src/com/night/contact/util/PinyinUtils.java
// public class PinyinUtils {
// /**
// * ½«×Ö·û´®ÖеÄÖÐÎÄת»¯ÎªÆ´Òô,ÆäËû×Ö·û²»±ä
// * @param inputString
// * @return
// */
// public static String getPingYin(String inputString) {
// HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
// format.setCaseType(HanyuPinyinCaseType.LOWERCASE);
// format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
// format.setVCharType(HanyuPinyinVCharType.WITH_V);
//
// char[] input = inputString.trim().toCharArray();
// String output = "";
//
// try {
// for (char curchar : input) {
// if (java.lang.Character.toString(curchar).matches(
// "[\\u4E00-\\u9FA5]+")) {
// String[] temp = PinyinHelper.toHanyuPinyinStringArray(
// curchar, format);
// output += temp[0];
// } else
// output += java.lang.Character.toString(curchar);
// }
// } catch (BadHanyuPinyinOutputFormatCombination e) {
// e.printStackTrace();
// }
// return output;
// }
//
// /**
// * ºº×Öת»»ÎªººÓïÆ´ÒôÊ××Öĸ£¬Ó¢ÎÄ×Ö·û²»±ä
// * »¨»¨´óÉñ->hhds
// * @param chines
// * ºº×Ö
// * @return Æ´Òô
// */
// public static String getFirstSpell(String chinese) {
// StringBuffer pybf = new StringBuffer();
// char[] arr = chinese.toCharArray();
// HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
// defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
// defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
// for (char curchar : arr) {
// if (curchar > 128) {
// try {
// String[] temp = PinyinHelper.toHanyuPinyinStringArray(curchar, defaultFormat);
// if (temp != null) {
// pybf.append(temp[0].charAt(0));
// }
// } catch (BadHanyuPinyinOutputFormatCombination e) {
// e.printStackTrace();
// }
// } else {
// pybf.append(curchar);
// }
// }
// return pybf.toString().replaceAll("\\W", "").trim();
// }
//
// public static String getPingYin1(String input){
// ArrayList<Token> tokens = HanziToPinyin.getInstance().get(input);
// StringBuilder sb = new StringBuilder();
// if(tokens != null && tokens.size() >0){
// for(Token token : tokens){
// if(Token.PINYIN == token.type){
// sb.append(token.target);
// }
// else{
// sb.append(token.source);
// }
// }
// }
// return sb.toString().toLowerCase();
// }
// }
|
import java.io.InputStream;
import android.annotation.SuppressLint;
import android.content.ContentUris;
import android.content.Context;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.provider.ContactsContract;
import android.provider.ContactsContract.RawContacts.Data;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.night.contact.ui.R;
import com.night.contact.util.PinyinUtils;
|
@Override
public void bindView(View view, Context context, Cursor cursor) {
if(cursor == null)
{
return;
}
TextView name = (TextView) view.findViewById(R.id.contacts_name);
name.setText(cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)));
ImageView photo = (ImageView) view.findViewById(R.id.contact_photo);
int photoId = cursor.getInt
(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.PHOTO_ID));
String contactID = cursor.getString(cursor
.getColumnIndex(Data.RAW_CONTACT_ID));
if(0 == photoId){
photo.setImageResource(R.drawable.default_contact_photo);
}else{
Uri uri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI,Integer.parseInt(contactID));
InputStream input = ContactsContract.Contacts.openContactPhotoInputStream(context.getContentResolver(), uri);
Bitmap contactPhoto = BitmapFactory.decodeStream(input);
photo.setImageBitmap(contactPhoto);
}
ImageView chooseView = (ImageView)view.findViewById(R.id.choose_contact);
chooseView.setVisibility(View.GONE);
//×ÖĸÌáʾtextviewµÄÏÔʾ
TextView letterTag = (TextView)view.findViewById(R.id.pb_item_LetterTag);
//»ñµÃµ±Ç°ÐÕÃûµÄÆ´ÒôÊ××Öĸ
|
// Path: Contacts_1.1.0/src/com/night/contact/util/PinyinUtils.java
// public class PinyinUtils {
// /**
// * ½«×Ö·û´®ÖеÄÖÐÎÄת»¯ÎªÆ´Òô,ÆäËû×Ö·û²»±ä
// * @param inputString
// * @return
// */
// public static String getPingYin(String inputString) {
// HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
// format.setCaseType(HanyuPinyinCaseType.LOWERCASE);
// format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
// format.setVCharType(HanyuPinyinVCharType.WITH_V);
//
// char[] input = inputString.trim().toCharArray();
// String output = "";
//
// try {
// for (char curchar : input) {
// if (java.lang.Character.toString(curchar).matches(
// "[\\u4E00-\\u9FA5]+")) {
// String[] temp = PinyinHelper.toHanyuPinyinStringArray(
// curchar, format);
// output += temp[0];
// } else
// output += java.lang.Character.toString(curchar);
// }
// } catch (BadHanyuPinyinOutputFormatCombination e) {
// e.printStackTrace();
// }
// return output;
// }
//
// /**
// * ºº×Öת»»ÎªººÓïÆ´ÒôÊ××Öĸ£¬Ó¢ÎÄ×Ö·û²»±ä
// * »¨»¨´óÉñ->hhds
// * @param chines
// * ºº×Ö
// * @return Æ´Òô
// */
// public static String getFirstSpell(String chinese) {
// StringBuffer pybf = new StringBuffer();
// char[] arr = chinese.toCharArray();
// HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
// defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
// defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
// for (char curchar : arr) {
// if (curchar > 128) {
// try {
// String[] temp = PinyinHelper.toHanyuPinyinStringArray(curchar, defaultFormat);
// if (temp != null) {
// pybf.append(temp[0].charAt(0));
// }
// } catch (BadHanyuPinyinOutputFormatCombination e) {
// e.printStackTrace();
// }
// } else {
// pybf.append(curchar);
// }
// }
// return pybf.toString().replaceAll("\\W", "").trim();
// }
//
// public static String getPingYin1(String input){
// ArrayList<Token> tokens = HanziToPinyin.getInstance().get(input);
// StringBuilder sb = new StringBuilder();
// if(tokens != null && tokens.size() >0){
// for(Token token : tokens){
// if(Token.PINYIN == token.type){
// sb.append(token.target);
// }
// else{
// sb.append(token.source);
// }
// }
// }
// return sb.toString().toLowerCase();
// }
// }
// Path: Contacts_1.1.0/src/com/night/contact/contact/ContactsCursorAdapter.java
import java.io.InputStream;
import android.annotation.SuppressLint;
import android.content.ContentUris;
import android.content.Context;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.provider.ContactsContract;
import android.provider.ContactsContract.RawContacts.Data;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.night.contact.ui.R;
import com.night.contact.util.PinyinUtils;
@Override
public void bindView(View view, Context context, Cursor cursor) {
if(cursor == null)
{
return;
}
TextView name = (TextView) view.findViewById(R.id.contacts_name);
name.setText(cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)));
ImageView photo = (ImageView) view.findViewById(R.id.contact_photo);
int photoId = cursor.getInt
(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.PHOTO_ID));
String contactID = cursor.getString(cursor
.getColumnIndex(Data.RAW_CONTACT_ID));
if(0 == photoId){
photo.setImageResource(R.drawable.default_contact_photo);
}else{
Uri uri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI,Integer.parseInt(contactID));
InputStream input = ContactsContract.Contacts.openContactPhotoInputStream(context.getContentResolver(), uri);
Bitmap contactPhoto = BitmapFactory.decodeStream(input);
photo.setImageBitmap(contactPhoto);
}
ImageView chooseView = (ImageView)view.findViewById(R.id.choose_contact);
chooseView.setVisibility(View.GONE);
//×ÖĸÌáʾtextviewµÄÏÔʾ
TextView letterTag = (TextView)view.findViewById(R.id.pb_item_LetterTag);
//»ñµÃµ±Ç°ÐÕÃûµÄÆ´ÒôÊ××Öĸ
|
String firstLetter = PinyinUtils.getPingYin(cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME))).substring(0,1).toUpperCase();
|
nighthary/phoneContact
|
Contacts_1.1.0/src/com/night/contact/util/Tools.java
|
// Path: Contacts_1.1.0/src/com/night/contact/bean/SortEntry.java
// public class SortEntry implements Parcelable{
// public String mID; // ÔÚÊý¾Ý¿âÖеÄIDºÅ
// public String mName; // ÐÕÃû
// public String mPY; // ÐÕÃûÆ´Òô
// public String mNum; // µç»°ºÅÂë
// public String mFisrtSpell; // ÖÐÎÄÃûÊ××Öĸ Àý:ÕÅÑ©±ù:zxb
// public int mchoose; // ÊÇ·ñÑ¡ÖÐ 0--δѡÖÐ 1---Ñ¡ÖÐ
// public int mOrder; // ÔÚÔCursorÖеÄλÖÃ
// public String lookUpKey;
// public int photoId;
// public int groupId;
// public String groupName;
// public Bitmap contactPhoto;// ÕÕÆ¬
// public String formattedNumber;
// @Override
// public int describeContents() {
// return 0;
// }
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(mID);
// dest.writeString(mName);
// dest.writeString(mPY);
// dest.writeString(mNum);
// dest.writeString(mFisrtSpell);
// dest.writeInt(mchoose);
// dest.writeInt(mOrder);
// dest.writeString(lookUpKey);
// dest.writeInt(photoId);
// dest.writeInt(groupId);
// dest.writeString(groupName);
// dest.writeString(formattedNumber);
// }
//
//
// // ÖØÐ´Creator
// public static final Parcelable.Creator<SortEntry> CREATOR = new Creator<SortEntry>() {
//
// @Override
// public SortEntry createFromParcel(Parcel source) {
// SortEntry contact = new SortEntry();
// contact.mID = source.readString();
// contact.mName = source.readString();
// contact.mPY = source.readString();
// contact.mNum = source.readString();
// contact.mFisrtSpell = source.readString();
// contact.mchoose = source.readInt();
// contact.mOrder = source.readInt();
// contact.lookUpKey = source.readString();
// contact.photoId = source.readInt();
// contact.groupId = source.readInt();
// contact.groupName = source.readString();
// contact.formattedNumber = source.readString();
// return contact;
// }
//
// @Override
// public SortEntry[] newArray(int size) {
// return new SortEntry[size];
// }
//
// };
// }
|
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import android.content.Context;
import android.os.Environment;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.Toast;
import com.night.contact.bean.SortEntry;
|
String[] numbers;
numbers = phoneNumber.split("#");
return numbers;
}
/**
* ´òÓ¡ÏûÏ¢
*
* @param context
* ÉÏÏÂÎÄ
* @param message
* ´òÓ¡µÄÏûÏ¢ÄÚÈÝ
*/
public static void Toast(Context context, String message) {
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
}
public static String pinYinToHanZi(String pinYin) {
if (pinYin.equals("add")) {
return "Ìí¼Ó";
} else {
return "ɾ³ý";
}
}
/**
* ÅжÏÖØ¸´µç»°ºÅÂë
*
* @return
*/
|
// Path: Contacts_1.1.0/src/com/night/contact/bean/SortEntry.java
// public class SortEntry implements Parcelable{
// public String mID; // ÔÚÊý¾Ý¿âÖеÄIDºÅ
// public String mName; // ÐÕÃû
// public String mPY; // ÐÕÃûÆ´Òô
// public String mNum; // µç»°ºÅÂë
// public String mFisrtSpell; // ÖÐÎÄÃûÊ××Öĸ Àý:ÕÅÑ©±ù:zxb
// public int mchoose; // ÊÇ·ñÑ¡ÖÐ 0--δѡÖÐ 1---Ñ¡ÖÐ
// public int mOrder; // ÔÚÔCursorÖеÄλÖÃ
// public String lookUpKey;
// public int photoId;
// public int groupId;
// public String groupName;
// public Bitmap contactPhoto;// ÕÕÆ¬
// public String formattedNumber;
// @Override
// public int describeContents() {
// return 0;
// }
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(mID);
// dest.writeString(mName);
// dest.writeString(mPY);
// dest.writeString(mNum);
// dest.writeString(mFisrtSpell);
// dest.writeInt(mchoose);
// dest.writeInt(mOrder);
// dest.writeString(lookUpKey);
// dest.writeInt(photoId);
// dest.writeInt(groupId);
// dest.writeString(groupName);
// dest.writeString(formattedNumber);
// }
//
//
// // ÖØÐ´Creator
// public static final Parcelable.Creator<SortEntry> CREATOR = new Creator<SortEntry>() {
//
// @Override
// public SortEntry createFromParcel(Parcel source) {
// SortEntry contact = new SortEntry();
// contact.mID = source.readString();
// contact.mName = source.readString();
// contact.mPY = source.readString();
// contact.mNum = source.readString();
// contact.mFisrtSpell = source.readString();
// contact.mchoose = source.readInt();
// contact.mOrder = source.readInt();
// contact.lookUpKey = source.readString();
// contact.photoId = source.readInt();
// contact.groupId = source.readInt();
// contact.groupName = source.readString();
// contact.formattedNumber = source.readString();
// return contact;
// }
//
// @Override
// public SortEntry[] newArray(int size) {
// return new SortEntry[size];
// }
//
// };
// }
// Path: Contacts_1.1.0/src/com/night/contact/util/Tools.java
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import android.content.Context;
import android.os.Environment;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.Toast;
import com.night.contact.bean.SortEntry;
String[] numbers;
numbers = phoneNumber.split("#");
return numbers;
}
/**
* ´òÓ¡ÏûÏ¢
*
* @param context
* ÉÏÏÂÎÄ
* @param message
* ´òÓ¡µÄÏûÏ¢ÄÚÈÝ
*/
public static void Toast(Context context, String message) {
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
}
public static String pinYinToHanZi(String pinYin) {
if (pinYin.equals("add")) {
return "Ìí¼Ó";
} else {
return "ɾ³ý";
}
}
/**
* ÅжÏÖØ¸´µç»°ºÅÂë
*
* @return
*/
|
public static List<SortEntry> duplicateNum(List<SortEntry> entrys) {
|
nighthary/phoneContact
|
Contacts_1.1.0/src/com/night/contact/util/SerializableMap.java
|
// Path: Contacts_1.1.0/src/com/night/contact/bean/SortEntry.java
// public class SortEntry implements Parcelable{
// public String mID; // ÔÚÊý¾Ý¿âÖеÄIDºÅ
// public String mName; // ÐÕÃû
// public String mPY; // ÐÕÃûÆ´Òô
// public String mNum; // µç»°ºÅÂë
// public String mFisrtSpell; // ÖÐÎÄÃûÊ××Öĸ Àý:ÕÅÑ©±ù:zxb
// public int mchoose; // ÊÇ·ñÑ¡ÖÐ 0--δѡÖÐ 1---Ñ¡ÖÐ
// public int mOrder; // ÔÚÔCursorÖеÄλÖÃ
// public String lookUpKey;
// public int photoId;
// public int groupId;
// public String groupName;
// public Bitmap contactPhoto;// ÕÕÆ¬
// public String formattedNumber;
// @Override
// public int describeContents() {
// return 0;
// }
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(mID);
// dest.writeString(mName);
// dest.writeString(mPY);
// dest.writeString(mNum);
// dest.writeString(mFisrtSpell);
// dest.writeInt(mchoose);
// dest.writeInt(mOrder);
// dest.writeString(lookUpKey);
// dest.writeInt(photoId);
// dest.writeInt(groupId);
// dest.writeString(groupName);
// dest.writeString(formattedNumber);
// }
//
//
// // ÖØÐ´Creator
// public static final Parcelable.Creator<SortEntry> CREATOR = new Creator<SortEntry>() {
//
// @Override
// public SortEntry createFromParcel(Parcel source) {
// SortEntry contact = new SortEntry();
// contact.mID = source.readString();
// contact.mName = source.readString();
// contact.mPY = source.readString();
// contact.mNum = source.readString();
// contact.mFisrtSpell = source.readString();
// contact.mchoose = source.readInt();
// contact.mOrder = source.readInt();
// contact.lookUpKey = source.readString();
// contact.photoId = source.readInt();
// contact.groupId = source.readInt();
// contact.groupName = source.readString();
// contact.formattedNumber = source.readString();
// return contact;
// }
//
// @Override
// public SortEntry[] newArray(int size) {
// return new SortEntry[size];
// }
//
// };
// }
|
import java.io.Serializable;
import java.util.Map;
import com.night.contact.bean.SortEntry;
|
package com.night.contact.util;
public class SerializableMap implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
|
// Path: Contacts_1.1.0/src/com/night/contact/bean/SortEntry.java
// public class SortEntry implements Parcelable{
// public String mID; // ÔÚÊý¾Ý¿âÖеÄIDºÅ
// public String mName; // ÐÕÃû
// public String mPY; // ÐÕÃûÆ´Òô
// public String mNum; // µç»°ºÅÂë
// public String mFisrtSpell; // ÖÐÎÄÃûÊ××Öĸ Àý:ÕÅÑ©±ù:zxb
// public int mchoose; // ÊÇ·ñÑ¡ÖÐ 0--δѡÖÐ 1---Ñ¡ÖÐ
// public int mOrder; // ÔÚÔCursorÖеÄλÖÃ
// public String lookUpKey;
// public int photoId;
// public int groupId;
// public String groupName;
// public Bitmap contactPhoto;// ÕÕÆ¬
// public String formattedNumber;
// @Override
// public int describeContents() {
// return 0;
// }
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(mID);
// dest.writeString(mName);
// dest.writeString(mPY);
// dest.writeString(mNum);
// dest.writeString(mFisrtSpell);
// dest.writeInt(mchoose);
// dest.writeInt(mOrder);
// dest.writeString(lookUpKey);
// dest.writeInt(photoId);
// dest.writeInt(groupId);
// dest.writeString(groupName);
// dest.writeString(formattedNumber);
// }
//
//
// // ÖØÐ´Creator
// public static final Parcelable.Creator<SortEntry> CREATOR = new Creator<SortEntry>() {
//
// @Override
// public SortEntry createFromParcel(Parcel source) {
// SortEntry contact = new SortEntry();
// contact.mID = source.readString();
// contact.mName = source.readString();
// contact.mPY = source.readString();
// contact.mNum = source.readString();
// contact.mFisrtSpell = source.readString();
// contact.mchoose = source.readInt();
// contact.mOrder = source.readInt();
// contact.lookUpKey = source.readString();
// contact.photoId = source.readInt();
// contact.groupId = source.readInt();
// contact.groupName = source.readString();
// contact.formattedNumber = source.readString();
// return contact;
// }
//
// @Override
// public SortEntry[] newArray(int size) {
// return new SortEntry[size];
// }
//
// };
// }
// Path: Contacts_1.1.0/src/com/night/contact/util/SerializableMap.java
import java.io.Serializable;
import java.util.Map;
import com.night.contact.bean.SortEntry;
package com.night.contact.util;
public class SerializableMap implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
|
private Map<String,SortEntry> map;
|
nighthary/phoneContact
|
Contacts_1.1.0/src/com/night/contact/adapter/GroupAdapter.java
|
// Path: Contacts_1.1.0/src/com/night/contact/bean/GroupBean.java
// public class GroupBean implements Parcelable{
//
// private int id;
// private String name;
// private int count;
//
// public GroupBean() {
// super();
// }
// public GroupBean(int id, String name) {
// super();
// this.id = id;
// this.name = name;
// }
// public GroupBean(int id, String name, int count) {
// super();
// this.id = id;
// this.name = name;
// this.count = count;
// }
// public int getId() {
// return id;
// }
// public void setId(int id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public int getCount() {
// return count;
// }
// public void setCount(int count) {
// this.count = count;
// }
// /**
// * ÐòÁл¯
// */
// @Override
// public int describeContents() {
// return 0;
// }
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(getId());
// dest.writeString(getName());
// dest.writeInt(getCount());
// }
// //ÖØÐ´Creator
// public static final Parcelable.Creator<GroupBean> CREATOR = new Creator<GroupBean>(){
//
// @Override
// public GroupBean createFromParcel(Parcel source) {
// GroupBean group = new GroupBean();
// group.id = source.readInt();
// group.name = source.readString();
// group.count = source.readInt();
// return group;
// }
//
// @Override
// public GroupBean[] newArray(int size) {
// return new GroupBean[size];
// }
//
// };
// }
|
import java.util.List;
import android.annotation.SuppressLint;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.night.contact.bean.GroupBean;
import com.night.contact.ui.R;
|
package com.night.contact.adapter;
/**
* ±êÌâÀ¸ÏÂÀ²Ëµ¥Ñ¡ÏîÊÊÅäÆ÷
* @author NightHary
*
*/
public class GroupAdapter extends BaseAdapter {
private Context context ;
|
// Path: Contacts_1.1.0/src/com/night/contact/bean/GroupBean.java
// public class GroupBean implements Parcelable{
//
// private int id;
// private String name;
// private int count;
//
// public GroupBean() {
// super();
// }
// public GroupBean(int id, String name) {
// super();
// this.id = id;
// this.name = name;
// }
// public GroupBean(int id, String name, int count) {
// super();
// this.id = id;
// this.name = name;
// this.count = count;
// }
// public int getId() {
// return id;
// }
// public void setId(int id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public int getCount() {
// return count;
// }
// public void setCount(int count) {
// this.count = count;
// }
// /**
// * ÐòÁл¯
// */
// @Override
// public int describeContents() {
// return 0;
// }
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(getId());
// dest.writeString(getName());
// dest.writeInt(getCount());
// }
// //ÖØÐ´Creator
// public static final Parcelable.Creator<GroupBean> CREATOR = new Creator<GroupBean>(){
//
// @Override
// public GroupBean createFromParcel(Parcel source) {
// GroupBean group = new GroupBean();
// group.id = source.readInt();
// group.name = source.readString();
// group.count = source.readInt();
// return group;
// }
//
// @Override
// public GroupBean[] newArray(int size) {
// return new GroupBean[size];
// }
//
// };
// }
// Path: Contacts_1.1.0/src/com/night/contact/adapter/GroupAdapter.java
import java.util.List;
import android.annotation.SuppressLint;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.night.contact.bean.GroupBean;
import com.night.contact.ui.R;
package com.night.contact.adapter;
/**
* ±êÌâÀ¸ÏÂÀ²Ëµ¥Ñ¡ÏîÊÊÅäÆ÷
* @author NightHary
*
*/
public class GroupAdapter extends BaseAdapter {
private Context context ;
|
private List<GroupBean> groupList;
|
nighthary/phoneContact
|
Contacts_1.1.0/src/com/night/contact/DAO/GroupDAO.java
|
// Path: Contacts_1.1.0/src/com/night/contact/bean/GroupBean.java
// public class GroupBean implements Parcelable{
//
// private int id;
// private String name;
// private int count;
//
// public GroupBean() {
// super();
// }
// public GroupBean(int id, String name) {
// super();
// this.id = id;
// this.name = name;
// }
// public GroupBean(int id, String name, int count) {
// super();
// this.id = id;
// this.name = name;
// this.count = count;
// }
// public int getId() {
// return id;
// }
// public void setId(int id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public int getCount() {
// return count;
// }
// public void setCount(int count) {
// this.count = count;
// }
// /**
// * ÐòÁл¯
// */
// @Override
// public int describeContents() {
// return 0;
// }
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(getId());
// dest.writeString(getName());
// dest.writeInt(getCount());
// }
// //ÖØÐ´Creator
// public static final Parcelable.Creator<GroupBean> CREATOR = new Creator<GroupBean>(){
//
// @Override
// public GroupBean createFromParcel(Parcel source) {
// GroupBean group = new GroupBean();
// group.id = source.readInt();
// group.name = source.readString();
// group.count = source.readInt();
// return group;
// }
//
// @Override
// public GroupBean[] newArray(int size) {
// return new GroupBean[size];
// }
//
// };
// }
|
import java.util.ArrayList;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.ContactsContract;
import android.provider.ContactsContract.Groups;
import com.night.contact.bean.GroupBean;
|
package com.night.contact.DAO;
/**
* Ⱥ×é²Ù×÷³Ö¾Ã²ã
*
* @author NightHary
*
*/
public class GroupDAO {
private Context context;
public GroupDAO(Context context) {
this.context = context;
}
/**
* »ñÈ¡ËùÓÐÁªÏµÈË·Ö×é
*
* @param context
* ÉÏÏÂÎÄ
* @return
*/
|
// Path: Contacts_1.1.0/src/com/night/contact/bean/GroupBean.java
// public class GroupBean implements Parcelable{
//
// private int id;
// private String name;
// private int count;
//
// public GroupBean() {
// super();
// }
// public GroupBean(int id, String name) {
// super();
// this.id = id;
// this.name = name;
// }
// public GroupBean(int id, String name, int count) {
// super();
// this.id = id;
// this.name = name;
// this.count = count;
// }
// public int getId() {
// return id;
// }
// public void setId(int id) {
// this.id = id;
// }
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
// public int getCount() {
// return count;
// }
// public void setCount(int count) {
// this.count = count;
// }
// /**
// * ÐòÁл¯
// */
// @Override
// public int describeContents() {
// return 0;
// }
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(getId());
// dest.writeString(getName());
// dest.writeInt(getCount());
// }
// //ÖØÐ´Creator
// public static final Parcelable.Creator<GroupBean> CREATOR = new Creator<GroupBean>(){
//
// @Override
// public GroupBean createFromParcel(Parcel source) {
// GroupBean group = new GroupBean();
// group.id = source.readInt();
// group.name = source.readString();
// group.count = source.readInt();
// return group;
// }
//
// @Override
// public GroupBean[] newArray(int size) {
// return new GroupBean[size];
// }
//
// };
// }
// Path: Contacts_1.1.0/src/com/night/contact/DAO/GroupDAO.java
import java.util.ArrayList;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.ContactsContract;
import android.provider.ContactsContract.Groups;
import com.night.contact.bean.GroupBean;
package com.night.contact.DAO;
/**
* Ⱥ×é²Ù×÷³Ö¾Ã²ã
*
* @author NightHary
*
*/
public class GroupDAO {
private Context context;
public GroupDAO(Context context) {
this.context = context;
}
/**
* »ñÈ¡ËùÓÐÁªÏµÈË·Ö×é
*
* @param context
* ÉÏÏÂÎÄ
* @return
*/
|
public ArrayList<GroupBean> getGroups() {
|
nighthary/phoneContact
|
Contacts_1.1.0/src/com/night/contact/adapter/FilterAdapter.java
|
// Path: Contacts_1.1.0/src/com/night/contact/bean/SortEntry.java
// public class SortEntry implements Parcelable{
// public String mID; // ÔÚÊý¾Ý¿âÖеÄIDºÅ
// public String mName; // ÐÕÃû
// public String mPY; // ÐÕÃûÆ´Òô
// public String mNum; // µç»°ºÅÂë
// public String mFisrtSpell; // ÖÐÎÄÃûÊ××Öĸ Àý:ÕÅÑ©±ù:zxb
// public int mchoose; // ÊÇ·ñÑ¡ÖÐ 0--δѡÖÐ 1---Ñ¡ÖÐ
// public int mOrder; // ÔÚÔCursorÖеÄλÖÃ
// public String lookUpKey;
// public int photoId;
// public int groupId;
// public String groupName;
// public Bitmap contactPhoto;// ÕÕÆ¬
// public String formattedNumber;
// @Override
// public int describeContents() {
// return 0;
// }
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(mID);
// dest.writeString(mName);
// dest.writeString(mPY);
// dest.writeString(mNum);
// dest.writeString(mFisrtSpell);
// dest.writeInt(mchoose);
// dest.writeInt(mOrder);
// dest.writeString(lookUpKey);
// dest.writeInt(photoId);
// dest.writeInt(groupId);
// dest.writeString(groupName);
// dest.writeString(formattedNumber);
// }
//
//
// // ÖØÐ´Creator
// public static final Parcelable.Creator<SortEntry> CREATOR = new Creator<SortEntry>() {
//
// @Override
// public SortEntry createFromParcel(Parcel source) {
// SortEntry contact = new SortEntry();
// contact.mID = source.readString();
// contact.mName = source.readString();
// contact.mPY = source.readString();
// contact.mNum = source.readString();
// contact.mFisrtSpell = source.readString();
// contact.mchoose = source.readInt();
// contact.mOrder = source.readInt();
// contact.lookUpKey = source.readString();
// contact.photoId = source.readInt();
// contact.groupId = source.readInt();
// contact.groupName = source.readString();
// contact.formattedNumber = source.readString();
// return contact;
// }
//
// @Override
// public SortEntry[] newArray(int size) {
// return new SortEntry[size];
// }
//
// };
// }
|
import java.io.InputStream;
import java.util.ArrayList;
import android.annotation.SuppressLint;
import android.content.ContentUris;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.provider.ContactsContract;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.night.contact.bean.SortEntry;
import com.night.contact.ui.R;
|
package com.night.contact.adapter;
/**
* ÁªÏµÈ˹ýÂËÊÊÅäÆ÷
* @author NightHary
*
*/
@SuppressLint({ "ViewHolder", "InflateParams" })
public class FilterAdapter extends BaseAdapter{
private LayoutInflater mInflater;
|
// Path: Contacts_1.1.0/src/com/night/contact/bean/SortEntry.java
// public class SortEntry implements Parcelable{
// public String mID; // ÔÚÊý¾Ý¿âÖеÄIDºÅ
// public String mName; // ÐÕÃû
// public String mPY; // ÐÕÃûÆ´Òô
// public String mNum; // µç»°ºÅÂë
// public String mFisrtSpell; // ÖÐÎÄÃûÊ××Öĸ Àý:ÕÅÑ©±ù:zxb
// public int mchoose; // ÊÇ·ñÑ¡ÖÐ 0--δѡÖÐ 1---Ñ¡ÖÐ
// public int mOrder; // ÔÚÔCursorÖеÄλÖÃ
// public String lookUpKey;
// public int photoId;
// public int groupId;
// public String groupName;
// public Bitmap contactPhoto;// ÕÕÆ¬
// public String formattedNumber;
// @Override
// public int describeContents() {
// return 0;
// }
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(mID);
// dest.writeString(mName);
// dest.writeString(mPY);
// dest.writeString(mNum);
// dest.writeString(mFisrtSpell);
// dest.writeInt(mchoose);
// dest.writeInt(mOrder);
// dest.writeString(lookUpKey);
// dest.writeInt(photoId);
// dest.writeInt(groupId);
// dest.writeString(groupName);
// dest.writeString(formattedNumber);
// }
//
//
// // ÖØÐ´Creator
// public static final Parcelable.Creator<SortEntry> CREATOR = new Creator<SortEntry>() {
//
// @Override
// public SortEntry createFromParcel(Parcel source) {
// SortEntry contact = new SortEntry();
// contact.mID = source.readString();
// contact.mName = source.readString();
// contact.mPY = source.readString();
// contact.mNum = source.readString();
// contact.mFisrtSpell = source.readString();
// contact.mchoose = source.readInt();
// contact.mOrder = source.readInt();
// contact.lookUpKey = source.readString();
// contact.photoId = source.readInt();
// contact.groupId = source.readInt();
// contact.groupName = source.readString();
// contact.formattedNumber = source.readString();
// return contact;
// }
//
// @Override
// public SortEntry[] newArray(int size) {
// return new SortEntry[size];
// }
//
// };
// }
// Path: Contacts_1.1.0/src/com/night/contact/adapter/FilterAdapter.java
import java.io.InputStream;
import java.util.ArrayList;
import android.annotation.SuppressLint;
import android.content.ContentUris;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.provider.ContactsContract;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.night.contact.bean.SortEntry;
import com.night.contact.ui.R;
package com.night.contact.adapter;
/**
* ÁªÏµÈ˹ýÂËÊÊÅäÆ÷
* @author NightHary
*
*/
@SuppressLint({ "ViewHolder", "InflateParams" })
public class FilterAdapter extends BaseAdapter{
private LayoutInflater mInflater;
|
private ArrayList<SortEntry> data;
|
Comcast/flume2storm
|
static-location-service/src/main/java/com/comcast/viper/flume2storm/location/StaticLocationService.java
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
|
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.comcast.viper.flume2storm.F2SConfigurationException;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.location;
/**
* An implementation of LocationService that gets the list of ServiceProviders
* from a static configuration. No subsequent ServiceProvider
* registration/unregistration is permitted.
*
* @param <SP>
* The actual class for the ServiceProvider
*/
public class StaticLocationService<SP extends ServiceProvider<?>> extends AbstractLocationService<SP> {
private static final Logger LOG = LoggerFactory.getLogger(StaticLocationService.class);
private final ServiceProviderSerialization<SP> serialization;
/**
* @param configuration
* The configuration that contains the {@link ServiceProvider}
* @param serialization
* The {@link ServiceProviderSerialization} to use
* @throws F2SConfigurationException
* If the configuration is invalid
*/
public StaticLocationService(Configuration configuration, final ServiceProviderSerialization<SP> serialization)
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
// Path: static-location-service/src/main/java/com/comcast/viper/flume2storm/location/StaticLocationService.java
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.comcast.viper.flume2storm.F2SConfigurationException;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.location;
/**
* An implementation of LocationService that gets the list of ServiceProviders
* from a static configuration. No subsequent ServiceProvider
* registration/unregistration is permitted.
*
* @param <SP>
* The actual class for the ServiceProvider
*/
public class StaticLocationService<SP extends ServiceProvider<?>> extends AbstractLocationService<SP> {
private static final Logger LOG = LoggerFactory.getLogger(StaticLocationService.class);
private final ServiceProviderSerialization<SP> serialization;
/**
* @param configuration
* The configuration that contains the {@link ServiceProvider}
* @param serialization
* The {@link ServiceProviderSerialization} to use
* @throws F2SConfigurationException
* If the configuration is invalid
*/
public StaticLocationService(Configuration configuration, final ServiceProviderSerialization<SP> serialization)
|
throws F2SConfigurationException {
|
Comcast/flume2storm
|
test-impl/src/main/java/com/comcast/viper/flume2storm/zookeeper/ZkTestServer.java
|
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestUtils.java
// public class TestUtils {
// private static final int DEFAULT_RETRY_TIMEOUT = 100;
// private static Random random = new Random();
//
// /**
// * @return An ephemeral port available for test usage
// */
// public static int getAvailablePort() {
// try (ServerSocket s = new ServerSocket(0)) {
// return s.getLocalPort();
// } catch (Exception e) {
// throw new AssertionError("Failed to find available port", e);
// }
// }
//
// /**
// * @param n
// * Max int allowed
// * @return A random number between 1 and n
// */
// public static final int getRandomPositiveInt(int n) {
// Preconditions.checkArgument(n > 1, "Cannot generate this kind of number!");
// return random.nextInt(n - 1) + 1;
// }
//
// /**
// * Waits that the condition is fulfilled - careful, this may never return!
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static void waitFor(final TestCondition condition) throws InterruptedException {
// waitFor(condition, Integer.MAX_VALUE);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs) throws InterruptedException {
// return waitFor(condition, maxWaitInMs, DEFAULT_RETRY_TIMEOUT);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @param retryTimeout
// * The number of milliseconds to wait before retry the test
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs, final int retryTimeout)
// throws InterruptedException {
// final long t0 = System.currentTimeMillis();
// while (!condition.evaluate() && (System.currentTimeMillis() - t0) < maxWaitInMs) {
// Thread.sleep(retryTimeout);
// }
// if (condition.evaluate()) {
// return true;
// }
// throw new AssertionError("TestCondition did not validate in time");
// }
// }
|
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.apache.zookeeper.server.ServerCnxnFactory;
import org.apache.zookeeper.server.ServerConfig;
import org.apache.zookeeper.server.ZooKeeperServer;
import org.apache.zookeeper.server.persistence.FileTxnSnapLog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.comcast.viper.flume2storm.utility.test.TestUtils;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.zookeeper;
/**
* A ZooKeeper test server, for test purpose
*/
public class ZkTestServer {
protected static final Logger LOG = LoggerFactory.getLogger(ZkTestServer.class);
protected static final File ZK_DIR = new File("src/test/zkTestData");
protected static final int TICKTIME_DEFAULT = 500;
protected final Integer port;
protected final Integer ticktime;
protected ServerCnxnFactory cnxnFactory;
protected ZooKeeperServer zkServer;
protected volatile boolean started;
/**
* Create a ZooKeeper test server using a random port available
*
* @throws Exception
* errors
*/
public ZkTestServer() {
|
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestUtils.java
// public class TestUtils {
// private static final int DEFAULT_RETRY_TIMEOUT = 100;
// private static Random random = new Random();
//
// /**
// * @return An ephemeral port available for test usage
// */
// public static int getAvailablePort() {
// try (ServerSocket s = new ServerSocket(0)) {
// return s.getLocalPort();
// } catch (Exception e) {
// throw new AssertionError("Failed to find available port", e);
// }
// }
//
// /**
// * @param n
// * Max int allowed
// * @return A random number between 1 and n
// */
// public static final int getRandomPositiveInt(int n) {
// Preconditions.checkArgument(n > 1, "Cannot generate this kind of number!");
// return random.nextInt(n - 1) + 1;
// }
//
// /**
// * Waits that the condition is fulfilled - careful, this may never return!
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static void waitFor(final TestCondition condition) throws InterruptedException {
// waitFor(condition, Integer.MAX_VALUE);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs) throws InterruptedException {
// return waitFor(condition, maxWaitInMs, DEFAULT_RETRY_TIMEOUT);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @param retryTimeout
// * The number of milliseconds to wait before retry the test
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs, final int retryTimeout)
// throws InterruptedException {
// final long t0 = System.currentTimeMillis();
// while (!condition.evaluate() && (System.currentTimeMillis() - t0) < maxWaitInMs) {
// Thread.sleep(retryTimeout);
// }
// if (condition.evaluate()) {
// return true;
// }
// throw new AssertionError("TestCondition did not validate in time");
// }
// }
// Path: test-impl/src/main/java/com/comcast/viper/flume2storm/zookeeper/ZkTestServer.java
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.apache.zookeeper.server.ServerCnxnFactory;
import org.apache.zookeeper.server.ServerConfig;
import org.apache.zookeeper.server.ZooKeeperServer;
import org.apache.zookeeper.server.persistence.FileTxnSnapLog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.comcast.viper.flume2storm.utility.test.TestUtils;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.zookeeper;
/**
* A ZooKeeper test server, for test purpose
*/
public class ZkTestServer {
protected static final Logger LOG = LoggerFactory.getLogger(ZkTestServer.class);
protected static final File ZK_DIR = new File("src/test/zkTestData");
protected static final int TICKTIME_DEFAULT = 500;
protected final Integer port;
protected final Integer ticktime;
protected ServerCnxnFactory cnxnFactory;
protected ZooKeeperServer zkServer;
protected volatile boolean started;
/**
* Create a ZooKeeper test server using a random port available
*
* @throws Exception
* errors
*/
public ZkTestServer() {
|
this(TestUtils.getAvailablePort(), TICKTIME_DEFAULT);
|
Comcast/flume2storm
|
flume-spout/src/main/java/com/comcast/viper/flume2storm/spout/F2SEventEmitter.java
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/event/F2SEvent.java
// public final class F2SEvent implements Serializable {
// private static final long serialVersionUID = -5906404402187281472L;
// private final Map<String, String> headers;
// private final byte[] body;
//
// F2SEvent() {
// headers = ImmutableMap.of();
// body = new byte[0];
// }
//
// /**
// * Constructor to build Flume2Storm events
// *
// * @param headers
// * See {@link #getHeaders()}. If null, the headers is an empty
// * immutable map.
// * @param body
// * See {@link #getBody()}. If null, the payload of the event is an
// * empty byte array.
// */
// public F2SEvent(Map<String, String> headers, byte[] body) {
// if (headers == null) {
// this.headers = ImmutableMap.of();
// } else {
// this.headers = ImmutableMap.copyOf(headers);
// }
// if (body == null) {
// this.body = ArrayUtils.EMPTY_BYTE_ARRAY;
// } else {
// this.body = ArrayUtils.clone(body);
// }
// }
//
// /**
// * Copy constructor
// *
// * @param event
// * Another Flume2Storm event
// */
// public F2SEvent(F2SEvent event) {
// headers = ImmutableMap.copyOf(event.getHeaders());
// body = event.body;
// }
//
// /**
// * @return The event body
// */
// public byte[] getBody() {
// return body;
// }
//
// /**
// * @return The headers (key/value pairs) associated to the event
// */
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// /**
// * @param key
// * A header name (i.e. key)
// * @return The value of the header, or null if it does not exist
// */
// public String getHeader(String key) {
// return headers.get(key);
// }
//
// /**
// * @see java.lang.Object#hashCode()
// */
// @Override
// public int hashCode() {
// return new HashCodeBuilder().append(headers).append(body).hashCode();
// }
//
// /**
// * @see java.lang.Object#equals(java.lang.Object)
// */
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// F2SEvent other = (F2SEvent) obj;
// return new EqualsBuilder().append(this.headers, other.headers)
// .append(this.body, other.body).isEquals();
// }
//
// /**
// * @see java.lang.Object#toString()
// */
// @Override
// public String toString() {
// ToStringBuilder toStringBuilder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("headers",
// headers);
// String bodyStr = StringUtils.toEncodedString(body, F2SEventFactory.DEFAULT_CHARACTER_SET);
// if (StringUtils.isAsciiPrintable(bodyStr)) {
// toStringBuilder.append("body", bodyStr);
// } else {
// toStringBuilder.append(Hex.encodeHexString(body));
// }
// return toStringBuilder.toString();
// }
// }
|
import java.io.Serializable;
import backtype.storm.spout.SpoutOutputCollector;
import backtype.storm.topology.OutputFieldsDeclarer;
import com.comcast.viper.flume2storm.event.F2SEvent;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.spout;
/**
* Interface to connect the Flume-Spout to the rest of the topology
*/
public interface F2SEventEmitter extends Serializable {
/**
* Implement this method to specify what tuples the Flume-Spout will emit on
* which stream.
*
* @param declarer
* Storm {@link OutputFieldsDeclarer}
*/
public void declareOutputFields(OutputFieldsDeclarer declarer);
/**
* Method to actually emit the Flume2Storm events down the topology. Tuples
* must match what has been declared in
* {@link #declareOutputFields(OutputFieldsDeclarer)}.
*
* @param event
* The event being emitted
* @param collector
* The collector to use
*/
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/event/F2SEvent.java
// public final class F2SEvent implements Serializable {
// private static final long serialVersionUID = -5906404402187281472L;
// private final Map<String, String> headers;
// private final byte[] body;
//
// F2SEvent() {
// headers = ImmutableMap.of();
// body = new byte[0];
// }
//
// /**
// * Constructor to build Flume2Storm events
// *
// * @param headers
// * See {@link #getHeaders()}. If null, the headers is an empty
// * immutable map.
// * @param body
// * See {@link #getBody()}. If null, the payload of the event is an
// * empty byte array.
// */
// public F2SEvent(Map<String, String> headers, byte[] body) {
// if (headers == null) {
// this.headers = ImmutableMap.of();
// } else {
// this.headers = ImmutableMap.copyOf(headers);
// }
// if (body == null) {
// this.body = ArrayUtils.EMPTY_BYTE_ARRAY;
// } else {
// this.body = ArrayUtils.clone(body);
// }
// }
//
// /**
// * Copy constructor
// *
// * @param event
// * Another Flume2Storm event
// */
// public F2SEvent(F2SEvent event) {
// headers = ImmutableMap.copyOf(event.getHeaders());
// body = event.body;
// }
//
// /**
// * @return The event body
// */
// public byte[] getBody() {
// return body;
// }
//
// /**
// * @return The headers (key/value pairs) associated to the event
// */
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// /**
// * @param key
// * A header name (i.e. key)
// * @return The value of the header, or null if it does not exist
// */
// public String getHeader(String key) {
// return headers.get(key);
// }
//
// /**
// * @see java.lang.Object#hashCode()
// */
// @Override
// public int hashCode() {
// return new HashCodeBuilder().append(headers).append(body).hashCode();
// }
//
// /**
// * @see java.lang.Object#equals(java.lang.Object)
// */
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// F2SEvent other = (F2SEvent) obj;
// return new EqualsBuilder().append(this.headers, other.headers)
// .append(this.body, other.body).isEquals();
// }
//
// /**
// * @see java.lang.Object#toString()
// */
// @Override
// public String toString() {
// ToStringBuilder toStringBuilder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("headers",
// headers);
// String bodyStr = StringUtils.toEncodedString(body, F2SEventFactory.DEFAULT_CHARACTER_SET);
// if (StringUtils.isAsciiPrintable(bodyStr)) {
// toStringBuilder.append("body", bodyStr);
// } else {
// toStringBuilder.append(Hex.encodeHexString(body));
// }
// return toStringBuilder.toString();
// }
// }
// Path: flume-spout/src/main/java/com/comcast/viper/flume2storm/spout/F2SEventEmitter.java
import java.io.Serializable;
import backtype.storm.spout.SpoutOutputCollector;
import backtype.storm.topology.OutputFieldsDeclarer;
import com.comcast.viper.flume2storm.event.F2SEvent;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.spout;
/**
* Interface to connect the Flume-Spout to the rest of the topology
*/
public interface F2SEventEmitter extends Serializable {
/**
* Implement this method to specify what tuples the Flume-Spout will emit on
* which stream.
*
* @param declarer
* Storm {@link OutputFieldsDeclarer}
*/
public void declareOutputFields(OutputFieldsDeclarer declarer);
/**
* Method to actually emit the Flume2Storm events down the topology. Tuples
* must match what has been declared in
* {@link #declareOutputFields(OutputFieldsDeclarer)}.
*
* @param event
* The event being emitted
* @param collector
* The collector to use
*/
|
public void emitEvent(F2SEvent event, SpoutOutputCollector collector);
|
Comcast/flume2storm
|
core/src/main/java/com/comcast/viper/flume2storm/connection/receptor/EventReceptorListener.java
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/event/F2SEvent.java
// public final class F2SEvent implements Serializable {
// private static final long serialVersionUID = -5906404402187281472L;
// private final Map<String, String> headers;
// private final byte[] body;
//
// F2SEvent() {
// headers = ImmutableMap.of();
// body = new byte[0];
// }
//
// /**
// * Constructor to build Flume2Storm events
// *
// * @param headers
// * See {@link #getHeaders()}. If null, the headers is an empty
// * immutable map.
// * @param body
// * See {@link #getBody()}. If null, the payload of the event is an
// * empty byte array.
// */
// public F2SEvent(Map<String, String> headers, byte[] body) {
// if (headers == null) {
// this.headers = ImmutableMap.of();
// } else {
// this.headers = ImmutableMap.copyOf(headers);
// }
// if (body == null) {
// this.body = ArrayUtils.EMPTY_BYTE_ARRAY;
// } else {
// this.body = ArrayUtils.clone(body);
// }
// }
//
// /**
// * Copy constructor
// *
// * @param event
// * Another Flume2Storm event
// */
// public F2SEvent(F2SEvent event) {
// headers = ImmutableMap.copyOf(event.getHeaders());
// body = event.body;
// }
//
// /**
// * @return The event body
// */
// public byte[] getBody() {
// return body;
// }
//
// /**
// * @return The headers (key/value pairs) associated to the event
// */
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// /**
// * @param key
// * A header name (i.e. key)
// * @return The value of the header, or null if it does not exist
// */
// public String getHeader(String key) {
// return headers.get(key);
// }
//
// /**
// * @see java.lang.Object#hashCode()
// */
// @Override
// public int hashCode() {
// return new HashCodeBuilder().append(headers).append(body).hashCode();
// }
//
// /**
// * @see java.lang.Object#equals(java.lang.Object)
// */
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// F2SEvent other = (F2SEvent) obj;
// return new EqualsBuilder().append(this.headers, other.headers)
// .append(this.body, other.body).isEquals();
// }
//
// /**
// * @see java.lang.Object#toString()
// */
// @Override
// public String toString() {
// ToStringBuilder toStringBuilder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("headers",
// headers);
// String bodyStr = StringUtils.toEncodedString(body, F2SEventFactory.DEFAULT_CHARACTER_SET);
// if (StringUtils.isAsciiPrintable(bodyStr)) {
// toStringBuilder.append("body", bodyStr);
// } else {
// toStringBuilder.append(Hex.encodeHexString(body));
// }
// return toStringBuilder.toString();
// }
// }
|
import java.util.List;
import com.comcast.viper.flume2storm.event.F2SEvent;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.connection.receptor;
/**
* Listener for {@link EventReceptor} events.
*/
public interface EventReceptorListener {
/**
* Callback method on {@link EventReceptor} connection event
*/
void onConnection();
/**
* Callback method on {@link EventReceptor} disconnection event
*/
void onDisconnection();
/**
* Callback method on Flume2Storm events reception
*
* @param events
* The Flume2Storm events received
*/
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/event/F2SEvent.java
// public final class F2SEvent implements Serializable {
// private static final long serialVersionUID = -5906404402187281472L;
// private final Map<String, String> headers;
// private final byte[] body;
//
// F2SEvent() {
// headers = ImmutableMap.of();
// body = new byte[0];
// }
//
// /**
// * Constructor to build Flume2Storm events
// *
// * @param headers
// * See {@link #getHeaders()}. If null, the headers is an empty
// * immutable map.
// * @param body
// * See {@link #getBody()}. If null, the payload of the event is an
// * empty byte array.
// */
// public F2SEvent(Map<String, String> headers, byte[] body) {
// if (headers == null) {
// this.headers = ImmutableMap.of();
// } else {
// this.headers = ImmutableMap.copyOf(headers);
// }
// if (body == null) {
// this.body = ArrayUtils.EMPTY_BYTE_ARRAY;
// } else {
// this.body = ArrayUtils.clone(body);
// }
// }
//
// /**
// * Copy constructor
// *
// * @param event
// * Another Flume2Storm event
// */
// public F2SEvent(F2SEvent event) {
// headers = ImmutableMap.copyOf(event.getHeaders());
// body = event.body;
// }
//
// /**
// * @return The event body
// */
// public byte[] getBody() {
// return body;
// }
//
// /**
// * @return The headers (key/value pairs) associated to the event
// */
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// /**
// * @param key
// * A header name (i.e. key)
// * @return The value of the header, or null if it does not exist
// */
// public String getHeader(String key) {
// return headers.get(key);
// }
//
// /**
// * @see java.lang.Object#hashCode()
// */
// @Override
// public int hashCode() {
// return new HashCodeBuilder().append(headers).append(body).hashCode();
// }
//
// /**
// * @see java.lang.Object#equals(java.lang.Object)
// */
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// F2SEvent other = (F2SEvent) obj;
// return new EqualsBuilder().append(this.headers, other.headers)
// .append(this.body, other.body).isEquals();
// }
//
// /**
// * @see java.lang.Object#toString()
// */
// @Override
// public String toString() {
// ToStringBuilder toStringBuilder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("headers",
// headers);
// String bodyStr = StringUtils.toEncodedString(body, F2SEventFactory.DEFAULT_CHARACTER_SET);
// if (StringUtils.isAsciiPrintable(bodyStr)) {
// toStringBuilder.append("body", bodyStr);
// } else {
// toStringBuilder.append(Hex.encodeHexString(body));
// }
// return toStringBuilder.toString();
// }
// }
// Path: core/src/main/java/com/comcast/viper/flume2storm/connection/receptor/EventReceptorListener.java
import java.util.List;
import com.comcast.viper.flume2storm.event.F2SEvent;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.connection.receptor;
/**
* Listener for {@link EventReceptor} events.
*/
public interface EventReceptorListener {
/**
* Callback method on {@link EventReceptor} connection event
*/
void onConnection();
/**
* Callback method on {@link EventReceptor} disconnection event
*/
void onDisconnection();
/**
* Callback method on Flume2Storm events reception
*
* @param events
* The Flume2Storm events received
*/
|
void onEvent(List<F2SEvent> events);
|
Comcast/flume2storm
|
test-impl/src/main/java/com/comcast/viper/flume2storm/connection/receptor/EventReceptorTestUtils.java
|
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestCondition.java
// public interface TestCondition {
// /**
// * @return True when the condition is fulfilled, false otherwise
// */
// boolean evaluate();
// }
//
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestUtils.java
// public class TestUtils {
// private static final int DEFAULT_RETRY_TIMEOUT = 100;
// private static Random random = new Random();
//
// /**
// * @return An ephemeral port available for test usage
// */
// public static int getAvailablePort() {
// try (ServerSocket s = new ServerSocket(0)) {
// return s.getLocalPort();
// } catch (Exception e) {
// throw new AssertionError("Failed to find available port", e);
// }
// }
//
// /**
// * @param n
// * Max int allowed
// * @return A random number between 1 and n
// */
// public static final int getRandomPositiveInt(int n) {
// Preconditions.checkArgument(n > 1, "Cannot generate this kind of number!");
// return random.nextInt(n - 1) + 1;
// }
//
// /**
// * Waits that the condition is fulfilled - careful, this may never return!
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static void waitFor(final TestCondition condition) throws InterruptedException {
// waitFor(condition, Integer.MAX_VALUE);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs) throws InterruptedException {
// return waitFor(condition, maxWaitInMs, DEFAULT_RETRY_TIMEOUT);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @param retryTimeout
// * The number of milliseconds to wait before retry the test
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs, final int retryTimeout)
// throws InterruptedException {
// final long t0 = System.currentTimeMillis();
// while (!condition.evaluate() && (System.currentTimeMillis() - t0) < maxWaitInMs) {
// Thread.sleep(retryTimeout);
// }
// if (condition.evaluate()) {
// return true;
// }
// throw new AssertionError("TestCondition did not validate in time");
// }
// }
|
import com.comcast.viper.flume2storm.utility.test.TestCondition;
import com.comcast.viper.flume2storm.utility.test.TestUtils;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.connection.receptor;
/**
* Utilities to facilitate testing of an {@link EventReceptor}
*/
public class EventReceptorTestUtils {
protected static final int TIMEOUT_DEFAULT = 500;
/**
* Condition fulfilled when the {@link EventReceptor} is connected
*/
|
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestCondition.java
// public interface TestCondition {
// /**
// * @return True when the condition is fulfilled, false otherwise
// */
// boolean evaluate();
// }
//
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestUtils.java
// public class TestUtils {
// private static final int DEFAULT_RETRY_TIMEOUT = 100;
// private static Random random = new Random();
//
// /**
// * @return An ephemeral port available for test usage
// */
// public static int getAvailablePort() {
// try (ServerSocket s = new ServerSocket(0)) {
// return s.getLocalPort();
// } catch (Exception e) {
// throw new AssertionError("Failed to find available port", e);
// }
// }
//
// /**
// * @param n
// * Max int allowed
// * @return A random number between 1 and n
// */
// public static final int getRandomPositiveInt(int n) {
// Preconditions.checkArgument(n > 1, "Cannot generate this kind of number!");
// return random.nextInt(n - 1) + 1;
// }
//
// /**
// * Waits that the condition is fulfilled - careful, this may never return!
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static void waitFor(final TestCondition condition) throws InterruptedException {
// waitFor(condition, Integer.MAX_VALUE);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs) throws InterruptedException {
// return waitFor(condition, maxWaitInMs, DEFAULT_RETRY_TIMEOUT);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @param retryTimeout
// * The number of milliseconds to wait before retry the test
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs, final int retryTimeout)
// throws InterruptedException {
// final long t0 = System.currentTimeMillis();
// while (!condition.evaluate() && (System.currentTimeMillis() - t0) < maxWaitInMs) {
// Thread.sleep(retryTimeout);
// }
// if (condition.evaluate()) {
// return true;
// }
// throw new AssertionError("TestCondition did not validate in time");
// }
// }
// Path: test-impl/src/main/java/com/comcast/viper/flume2storm/connection/receptor/EventReceptorTestUtils.java
import com.comcast.viper.flume2storm.utility.test.TestCondition;
import com.comcast.viper.flume2storm.utility.test.TestUtils;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.connection.receptor;
/**
* Utilities to facilitate testing of an {@link EventReceptor}
*/
public class EventReceptorTestUtils {
protected static final int TIMEOUT_DEFAULT = 500;
/**
* Condition fulfilled when the {@link EventReceptor} is connected
*/
|
static class EventReceptorConnected implements TestCondition {
|
Comcast/flume2storm
|
test-impl/src/main/java/com/comcast/viper/flume2storm/connection/receptor/EventReceptorTestUtils.java
|
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestCondition.java
// public interface TestCondition {
// /**
// * @return True when the condition is fulfilled, false otherwise
// */
// boolean evaluate();
// }
//
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestUtils.java
// public class TestUtils {
// private static final int DEFAULT_RETRY_TIMEOUT = 100;
// private static Random random = new Random();
//
// /**
// * @return An ephemeral port available for test usage
// */
// public static int getAvailablePort() {
// try (ServerSocket s = new ServerSocket(0)) {
// return s.getLocalPort();
// } catch (Exception e) {
// throw new AssertionError("Failed to find available port", e);
// }
// }
//
// /**
// * @param n
// * Max int allowed
// * @return A random number between 1 and n
// */
// public static final int getRandomPositiveInt(int n) {
// Preconditions.checkArgument(n > 1, "Cannot generate this kind of number!");
// return random.nextInt(n - 1) + 1;
// }
//
// /**
// * Waits that the condition is fulfilled - careful, this may never return!
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static void waitFor(final TestCondition condition) throws InterruptedException {
// waitFor(condition, Integer.MAX_VALUE);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs) throws InterruptedException {
// return waitFor(condition, maxWaitInMs, DEFAULT_RETRY_TIMEOUT);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @param retryTimeout
// * The number of milliseconds to wait before retry the test
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs, final int retryTimeout)
// throws InterruptedException {
// final long t0 = System.currentTimeMillis();
// while (!condition.evaluate() && (System.currentTimeMillis() - t0) < maxWaitInMs) {
// Thread.sleep(retryTimeout);
// }
// if (condition.evaluate()) {
// return true;
// }
// throw new AssertionError("TestCondition did not validate in time");
// }
// }
|
import com.comcast.viper.flume2storm.utility.test.TestCondition;
import com.comcast.viper.flume2storm.utility.test.TestUtils;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.connection.receptor;
/**
* Utilities to facilitate testing of an {@link EventReceptor}
*/
public class EventReceptorTestUtils {
protected static final int TIMEOUT_DEFAULT = 500;
/**
* Condition fulfilled when the {@link EventReceptor} is connected
*/
static class EventReceptorConnected implements TestCondition {
private final EventReceptor<?> eventReceptor;
public EventReceptorConnected(EventReceptor<?> eventReceptor) {
this.eventReceptor = eventReceptor;
}
@Override
public boolean evaluate() {
return eventReceptor.getStats().isConnected();
}
}
/**
* Condition fulfilled when the {@link EventReceptor} is disconnected
*/
static class EventReceptorDisconnected implements TestCondition {
private final EventReceptor<?> eventReceptor;
public EventReceptorDisconnected(EventReceptor<?> eventReceptor) {
this.eventReceptor = eventReceptor;
}
@Override
public boolean evaluate() {
return !eventReceptor.getStats().isConnected();
}
}
/**
* Waits until the specified {@link EventReceptor} is connected. It throws an
* assertion failure otherwise
*
* @param eventReceptor
* The event receptor
* @param timeout
* The maximum number of milliseconds to wait
* @throws InterruptedException
* If interrupted while waiting
*/
public static void waitConnected(EventReceptor<?> eventReceptor, int timeout) throws InterruptedException {
|
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestCondition.java
// public interface TestCondition {
// /**
// * @return True when the condition is fulfilled, false otherwise
// */
// boolean evaluate();
// }
//
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestUtils.java
// public class TestUtils {
// private static final int DEFAULT_RETRY_TIMEOUT = 100;
// private static Random random = new Random();
//
// /**
// * @return An ephemeral port available for test usage
// */
// public static int getAvailablePort() {
// try (ServerSocket s = new ServerSocket(0)) {
// return s.getLocalPort();
// } catch (Exception e) {
// throw new AssertionError("Failed to find available port", e);
// }
// }
//
// /**
// * @param n
// * Max int allowed
// * @return A random number between 1 and n
// */
// public static final int getRandomPositiveInt(int n) {
// Preconditions.checkArgument(n > 1, "Cannot generate this kind of number!");
// return random.nextInt(n - 1) + 1;
// }
//
// /**
// * Waits that the condition is fulfilled - careful, this may never return!
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static void waitFor(final TestCondition condition) throws InterruptedException {
// waitFor(condition, Integer.MAX_VALUE);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs) throws InterruptedException {
// return waitFor(condition, maxWaitInMs, DEFAULT_RETRY_TIMEOUT);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @param retryTimeout
// * The number of milliseconds to wait before retry the test
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs, final int retryTimeout)
// throws InterruptedException {
// final long t0 = System.currentTimeMillis();
// while (!condition.evaluate() && (System.currentTimeMillis() - t0) < maxWaitInMs) {
// Thread.sleep(retryTimeout);
// }
// if (condition.evaluate()) {
// return true;
// }
// throw new AssertionError("TestCondition did not validate in time");
// }
// }
// Path: test-impl/src/main/java/com/comcast/viper/flume2storm/connection/receptor/EventReceptorTestUtils.java
import com.comcast.viper.flume2storm.utility.test.TestCondition;
import com.comcast.viper.flume2storm.utility.test.TestUtils;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.connection.receptor;
/**
* Utilities to facilitate testing of an {@link EventReceptor}
*/
public class EventReceptorTestUtils {
protected static final int TIMEOUT_DEFAULT = 500;
/**
* Condition fulfilled when the {@link EventReceptor} is connected
*/
static class EventReceptorConnected implements TestCondition {
private final EventReceptor<?> eventReceptor;
public EventReceptorConnected(EventReceptor<?> eventReceptor) {
this.eventReceptor = eventReceptor;
}
@Override
public boolean evaluate() {
return eventReceptor.getStats().isConnected();
}
}
/**
* Condition fulfilled when the {@link EventReceptor} is disconnected
*/
static class EventReceptorDisconnected implements TestCondition {
private final EventReceptor<?> eventReceptor;
public EventReceptorDisconnected(EventReceptor<?> eventReceptor) {
this.eventReceptor = eventReceptor;
}
@Override
public boolean evaluate() {
return !eventReceptor.getStats().isConnected();
}
}
/**
* Waits until the specified {@link EventReceptor} is connected. It throws an
* assertion failure otherwise
*
* @param eventReceptor
* The event receptor
* @param timeout
* The maximum number of milliseconds to wait
* @throws InterruptedException
* If interrupted while waiting
*/
public static void waitConnected(EventReceptor<?> eventReceptor, int timeout) throws InterruptedException {
|
if (!TestUtils.waitFor(new EventReceptorConnected(eventReceptor), timeout)) {
|
Comcast/flume2storm
|
kryonet-flume2storm/src/main/java/com/comcast/viper/flume2storm/connection/sender/KryoNetSimpleRealtimeStrategy.java
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/event/F2SEvent.java
// public final class F2SEvent implements Serializable {
// private static final long serialVersionUID = -5906404402187281472L;
// private final Map<String, String> headers;
// private final byte[] body;
//
// F2SEvent() {
// headers = ImmutableMap.of();
// body = new byte[0];
// }
//
// /**
// * Constructor to build Flume2Storm events
// *
// * @param headers
// * See {@link #getHeaders()}. If null, the headers is an empty
// * immutable map.
// * @param body
// * See {@link #getBody()}. If null, the payload of the event is an
// * empty byte array.
// */
// public F2SEvent(Map<String, String> headers, byte[] body) {
// if (headers == null) {
// this.headers = ImmutableMap.of();
// } else {
// this.headers = ImmutableMap.copyOf(headers);
// }
// if (body == null) {
// this.body = ArrayUtils.EMPTY_BYTE_ARRAY;
// } else {
// this.body = ArrayUtils.clone(body);
// }
// }
//
// /**
// * Copy constructor
// *
// * @param event
// * Another Flume2Storm event
// */
// public F2SEvent(F2SEvent event) {
// headers = ImmutableMap.copyOf(event.getHeaders());
// body = event.body;
// }
//
// /**
// * @return The event body
// */
// public byte[] getBody() {
// return body;
// }
//
// /**
// * @return The headers (key/value pairs) associated to the event
// */
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// /**
// * @param key
// * A header name (i.e. key)
// * @return The value of the header, or null if it does not exist
// */
// public String getHeader(String key) {
// return headers.get(key);
// }
//
// /**
// * @see java.lang.Object#hashCode()
// */
// @Override
// public int hashCode() {
// return new HashCodeBuilder().append(headers).append(body).hashCode();
// }
//
// /**
// * @see java.lang.Object#equals(java.lang.Object)
// */
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// F2SEvent other = (F2SEvent) obj;
// return new EqualsBuilder().append(this.headers, other.headers)
// .append(this.body, other.body).isEquals();
// }
//
// /**
// * @see java.lang.Object#toString()
// */
// @Override
// public String toString() {
// ToStringBuilder toStringBuilder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("headers",
// headers);
// String bodyStr = StringUtils.toEncodedString(body, F2SEventFactory.DEFAULT_CHARACTER_SET);
// if (StringUtils.isAsciiPrintable(bodyStr)) {
// toStringBuilder.append("body", bodyStr);
// } else {
// toStringBuilder.append(Hex.encodeHexString(body));
// }
// return toStringBuilder.toString();
// }
// }
|
import java.io.Serializable;
import java.util.Iterator;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.comcast.viper.flume2storm.event.F2SEvent;
import com.esotericsoftware.kryonet.Connection;
import com.google.common.base.Preconditions;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.connection.sender;
/**
* This is a single-thread strategy that load-balances the events to send
* between each client. If a client fail to receive the event, it tries another
* client (for a configurable amount of retries).
*/
public class KryoNetSimpleRealtimeStrategy implements KryoNetEventSenderStrategy, Serializable {
private static final long serialVersionUID = 3735055103606316628L;
private static final Logger LOG = LoggerFactory.getLogger(KryoNetSimpleRealtimeStrategy.class);
private final KryoNetEventSender knEventSender;
private final int maxRetries;
private final int writeBufferSize;
private final int objectBufferSize;
/**
* @param knEventSender
* The KryoNet event sender associated with this strategy
* implementation
* @param maxRetries
* The maximum number of times the event sender will attempt to send
* an event before giving up
* @param writeBufferSize
* KryoNet write buffer size
* @param objectBufferSize
* KryoNet object buffer size
*/
public KryoNetSimpleRealtimeStrategy(KryoNetEventSender knEventSender, final int maxRetries,
final int writeBufferSize, final int objectBufferSize) {
this.knEventSender = knEventSender;
this.maxRetries = maxRetries;
this.writeBufferSize = writeBufferSize;
this.objectBufferSize = objectBufferSize;
}
/**
* @see com.comcast.viper.flume2storm.connection.sender.KryoNetEventSenderStrategy#send(java.util.List)
*/
@Override
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/event/F2SEvent.java
// public final class F2SEvent implements Serializable {
// private static final long serialVersionUID = -5906404402187281472L;
// private final Map<String, String> headers;
// private final byte[] body;
//
// F2SEvent() {
// headers = ImmutableMap.of();
// body = new byte[0];
// }
//
// /**
// * Constructor to build Flume2Storm events
// *
// * @param headers
// * See {@link #getHeaders()}. If null, the headers is an empty
// * immutable map.
// * @param body
// * See {@link #getBody()}. If null, the payload of the event is an
// * empty byte array.
// */
// public F2SEvent(Map<String, String> headers, byte[] body) {
// if (headers == null) {
// this.headers = ImmutableMap.of();
// } else {
// this.headers = ImmutableMap.copyOf(headers);
// }
// if (body == null) {
// this.body = ArrayUtils.EMPTY_BYTE_ARRAY;
// } else {
// this.body = ArrayUtils.clone(body);
// }
// }
//
// /**
// * Copy constructor
// *
// * @param event
// * Another Flume2Storm event
// */
// public F2SEvent(F2SEvent event) {
// headers = ImmutableMap.copyOf(event.getHeaders());
// body = event.body;
// }
//
// /**
// * @return The event body
// */
// public byte[] getBody() {
// return body;
// }
//
// /**
// * @return The headers (key/value pairs) associated to the event
// */
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// /**
// * @param key
// * A header name (i.e. key)
// * @return The value of the header, or null if it does not exist
// */
// public String getHeader(String key) {
// return headers.get(key);
// }
//
// /**
// * @see java.lang.Object#hashCode()
// */
// @Override
// public int hashCode() {
// return new HashCodeBuilder().append(headers).append(body).hashCode();
// }
//
// /**
// * @see java.lang.Object#equals(java.lang.Object)
// */
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// F2SEvent other = (F2SEvent) obj;
// return new EqualsBuilder().append(this.headers, other.headers)
// .append(this.body, other.body).isEquals();
// }
//
// /**
// * @see java.lang.Object#toString()
// */
// @Override
// public String toString() {
// ToStringBuilder toStringBuilder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("headers",
// headers);
// String bodyStr = StringUtils.toEncodedString(body, F2SEventFactory.DEFAULT_CHARACTER_SET);
// if (StringUtils.isAsciiPrintable(bodyStr)) {
// toStringBuilder.append("body", bodyStr);
// } else {
// toStringBuilder.append(Hex.encodeHexString(body));
// }
// return toStringBuilder.toString();
// }
// }
// Path: kryonet-flume2storm/src/main/java/com/comcast/viper/flume2storm/connection/sender/KryoNetSimpleRealtimeStrategy.java
import java.io.Serializable;
import java.util.Iterator;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.comcast.viper.flume2storm.event.F2SEvent;
import com.esotericsoftware.kryonet.Connection;
import com.google.common.base.Preconditions;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.connection.sender;
/**
* This is a single-thread strategy that load-balances the events to send
* between each client. If a client fail to receive the event, it tries another
* client (for a configurable amount of retries).
*/
public class KryoNetSimpleRealtimeStrategy implements KryoNetEventSenderStrategy, Serializable {
private static final long serialVersionUID = 3735055103606316628L;
private static final Logger LOG = LoggerFactory.getLogger(KryoNetSimpleRealtimeStrategy.class);
private final KryoNetEventSender knEventSender;
private final int maxRetries;
private final int writeBufferSize;
private final int objectBufferSize;
/**
* @param knEventSender
* The KryoNet event sender associated with this strategy
* implementation
* @param maxRetries
* The maximum number of times the event sender will attempt to send
* an event before giving up
* @param writeBufferSize
* KryoNet write buffer size
* @param objectBufferSize
* KryoNet object buffer size
*/
public KryoNetSimpleRealtimeStrategy(KryoNetEventSender knEventSender, final int maxRetries,
final int writeBufferSize, final int objectBufferSize) {
this.knEventSender = knEventSender;
this.maxRetries = maxRetries;
this.writeBufferSize = writeBufferSize;
this.objectBufferSize = objectBufferSize;
}
/**
* @see com.comcast.viper.flume2storm.connection.sender.KryoNetEventSenderStrategy#send(java.util.List)
*/
@Override
|
public int send(List<F2SEvent> events) {
|
Comcast/flume2storm
|
integration-tests/src/main/java/com/comcast/viper/flume2storm/example/ExampleStringEmitter.java
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/event/F2SEvent.java
// public final class F2SEvent implements Serializable {
// private static final long serialVersionUID = -5906404402187281472L;
// private final Map<String, String> headers;
// private final byte[] body;
//
// F2SEvent() {
// headers = ImmutableMap.of();
// body = new byte[0];
// }
//
// /**
// * Constructor to build Flume2Storm events
// *
// * @param headers
// * See {@link #getHeaders()}. If null, the headers is an empty
// * immutable map.
// * @param body
// * See {@link #getBody()}. If null, the payload of the event is an
// * empty byte array.
// */
// public F2SEvent(Map<String, String> headers, byte[] body) {
// if (headers == null) {
// this.headers = ImmutableMap.of();
// } else {
// this.headers = ImmutableMap.copyOf(headers);
// }
// if (body == null) {
// this.body = ArrayUtils.EMPTY_BYTE_ARRAY;
// } else {
// this.body = ArrayUtils.clone(body);
// }
// }
//
// /**
// * Copy constructor
// *
// * @param event
// * Another Flume2Storm event
// */
// public F2SEvent(F2SEvent event) {
// headers = ImmutableMap.copyOf(event.getHeaders());
// body = event.body;
// }
//
// /**
// * @return The event body
// */
// public byte[] getBody() {
// return body;
// }
//
// /**
// * @return The headers (key/value pairs) associated to the event
// */
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// /**
// * @param key
// * A header name (i.e. key)
// * @return The value of the header, or null if it does not exist
// */
// public String getHeader(String key) {
// return headers.get(key);
// }
//
// /**
// * @see java.lang.Object#hashCode()
// */
// @Override
// public int hashCode() {
// return new HashCodeBuilder().append(headers).append(body).hashCode();
// }
//
// /**
// * @see java.lang.Object#equals(java.lang.Object)
// */
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// F2SEvent other = (F2SEvent) obj;
// return new EqualsBuilder().append(this.headers, other.headers)
// .append(this.body, other.body).isEquals();
// }
//
// /**
// * @see java.lang.Object#toString()
// */
// @Override
// public String toString() {
// ToStringBuilder toStringBuilder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("headers",
// headers);
// String bodyStr = StringUtils.toEncodedString(body, F2SEventFactory.DEFAULT_CHARACTER_SET);
// if (StringUtils.isAsciiPrintable(bodyStr)) {
// toStringBuilder.append("body", bodyStr);
// } else {
// toStringBuilder.append(Hex.encodeHexString(body));
// }
// return toStringBuilder.toString();
// }
// }
//
// Path: flume-spout/src/main/java/com/comcast/viper/flume2storm/spout/F2SEventEmitter.java
// public interface F2SEventEmitter extends Serializable {
// /**
// * Implement this method to specify what tuples the Flume-Spout will emit on
// * which stream.
// *
// * @param declarer
// * Storm {@link OutputFieldsDeclarer}
// */
// public void declareOutputFields(OutputFieldsDeclarer declarer);
//
// /**
// * Method to actually emit the Flume2Storm events down the topology. Tuples
// * must match what has been declared in
// * {@link #declareOutputFields(OutputFieldsDeclarer)}.
// *
// * @param event
// * The event being emitted
// * @param collector
// * The collector to use
// */
// public void emitEvent(F2SEvent event, SpoutOutputCollector collector);
//
// // TODO Add acknowledgement methods
// }
|
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import backtype.storm.spout.SpoutOutputCollector;
import backtype.storm.topology.OutputFieldsDeclarer;
import backtype.storm.tuple.Fields;
import com.comcast.viper.flume2storm.event.F2SEvent;
import com.comcast.viper.flume2storm.spout.F2SEventEmitter;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.example;
public class ExampleStringEmitter implements F2SEventEmitter {
private static final long serialVersionUID = 5204406640833581933L;
public static final Fields fields = new Fields("field");
private static final Logger LOG = LoggerFactory.getLogger(ExampleStringEmitter.class);
@Override
public void declareOutputFields(OutputFieldsDeclarer declarer) {
declarer.declare(fields);
}
@Override
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/event/F2SEvent.java
// public final class F2SEvent implements Serializable {
// private static final long serialVersionUID = -5906404402187281472L;
// private final Map<String, String> headers;
// private final byte[] body;
//
// F2SEvent() {
// headers = ImmutableMap.of();
// body = new byte[0];
// }
//
// /**
// * Constructor to build Flume2Storm events
// *
// * @param headers
// * See {@link #getHeaders()}. If null, the headers is an empty
// * immutable map.
// * @param body
// * See {@link #getBody()}. If null, the payload of the event is an
// * empty byte array.
// */
// public F2SEvent(Map<String, String> headers, byte[] body) {
// if (headers == null) {
// this.headers = ImmutableMap.of();
// } else {
// this.headers = ImmutableMap.copyOf(headers);
// }
// if (body == null) {
// this.body = ArrayUtils.EMPTY_BYTE_ARRAY;
// } else {
// this.body = ArrayUtils.clone(body);
// }
// }
//
// /**
// * Copy constructor
// *
// * @param event
// * Another Flume2Storm event
// */
// public F2SEvent(F2SEvent event) {
// headers = ImmutableMap.copyOf(event.getHeaders());
// body = event.body;
// }
//
// /**
// * @return The event body
// */
// public byte[] getBody() {
// return body;
// }
//
// /**
// * @return The headers (key/value pairs) associated to the event
// */
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// /**
// * @param key
// * A header name (i.e. key)
// * @return The value of the header, or null if it does not exist
// */
// public String getHeader(String key) {
// return headers.get(key);
// }
//
// /**
// * @see java.lang.Object#hashCode()
// */
// @Override
// public int hashCode() {
// return new HashCodeBuilder().append(headers).append(body).hashCode();
// }
//
// /**
// * @see java.lang.Object#equals(java.lang.Object)
// */
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// F2SEvent other = (F2SEvent) obj;
// return new EqualsBuilder().append(this.headers, other.headers)
// .append(this.body, other.body).isEquals();
// }
//
// /**
// * @see java.lang.Object#toString()
// */
// @Override
// public String toString() {
// ToStringBuilder toStringBuilder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("headers",
// headers);
// String bodyStr = StringUtils.toEncodedString(body, F2SEventFactory.DEFAULT_CHARACTER_SET);
// if (StringUtils.isAsciiPrintable(bodyStr)) {
// toStringBuilder.append("body", bodyStr);
// } else {
// toStringBuilder.append(Hex.encodeHexString(body));
// }
// return toStringBuilder.toString();
// }
// }
//
// Path: flume-spout/src/main/java/com/comcast/viper/flume2storm/spout/F2SEventEmitter.java
// public interface F2SEventEmitter extends Serializable {
// /**
// * Implement this method to specify what tuples the Flume-Spout will emit on
// * which stream.
// *
// * @param declarer
// * Storm {@link OutputFieldsDeclarer}
// */
// public void declareOutputFields(OutputFieldsDeclarer declarer);
//
// /**
// * Method to actually emit the Flume2Storm events down the topology. Tuples
// * must match what has been declared in
// * {@link #declareOutputFields(OutputFieldsDeclarer)}.
// *
// * @param event
// * The event being emitted
// * @param collector
// * The collector to use
// */
// public void emitEvent(F2SEvent event, SpoutOutputCollector collector);
//
// // TODO Add acknowledgement methods
// }
// Path: integration-tests/src/main/java/com/comcast/viper/flume2storm/example/ExampleStringEmitter.java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import backtype.storm.spout.SpoutOutputCollector;
import backtype.storm.topology.OutputFieldsDeclarer;
import backtype.storm.tuple.Fields;
import com.comcast.viper.flume2storm.event.F2SEvent;
import com.comcast.viper.flume2storm.spout.F2SEventEmitter;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.example;
public class ExampleStringEmitter implements F2SEventEmitter {
private static final long serialVersionUID = 5204406640833581933L;
public static final Fields fields = new Fields("field");
private static final Logger LOG = LoggerFactory.getLogger(ExampleStringEmitter.class);
@Override
public void declareOutputFields(OutputFieldsDeclarer declarer) {
declarer.declare(fields);
}
@Override
|
public void emitEvent(F2SEvent event, SpoutOutputCollector collector) {
|
Comcast/flume2storm
|
kryonet-flume2storm/src/main/java/com/comcast/viper/flume2storm/connection/parameters/KryoNetConnectionParameters.java
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
//
// Path: core/src/main/java/com/comcast/viper/flume2storm/connection/parameters/ConnectionParameters.java
// public interface ConnectionParameters {
// /**
// * @return A unique identifier of the associated {@link EventSender} /
// * {@link ServiceProvider} (hostname:port for instance)
// *
// */
// String getId();
// }
|
import java.io.Serializable;
import java.net.InetAddress;
import java.net.UnknownHostException;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.comcast.viper.flume2storm.F2SConfigurationException;
import com.comcast.viper.flume2storm.connection.parameters.ConnectionParameters;
import com.google.common.base.Preconditions;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.connection.parameters;
/**
* Configuration for the KryoNet connection. Note that the hostname of the
* server is configured according to the following algorithm:
* <ol>
* <li>If the {@link #ADDRESS} parameter is specified, this is the
* address/hostname that is used</li>
* <li>Otherwise, the IP address of the host is retrieved and used</li>
* <li>If the previous step failed, the default hostname
* {@link #ADDRESS_DEFAULT} is used</li>
* </ol>
*/
public class KryoNetConnectionParameters implements ConnectionParameters, Serializable {
private static final long serialVersionUID = -5178954514610562054L;
/** Configuration attribute name for {@link #getAddress()} */
public static final String ADDRESS = "address";
/** Default value for {@value #ADDRESS} */
public static final String ADDRESS_DEFAULT = "localhost";
/** Configuration attribute name for {@link #getPort()} */
public static final String PORT = "port";
/** Default value for {@value #PORT} */
public static final int PORT_DEFAULT = 7000;
/** Configuration attribute name for {@link #getObjectBufferSize()} */
public static final String OBJECT_BUFFER_SZ = "object.buffer.size";
/** Default value for {@value #OBJECT_BUFFER_SZ} */
public static final int OBJECT_BUFFER_SIZE_DEFAULT = 3024;
/** Configuration attribute name for {@link #getWriteBufferSize()} */
public static final String WRITE_BUFFER_SZ = "write.buffer.size";
/** Default value for {@value #WRITE_BUFFER_SZ} */
public static final int WRITE_BUFFER_SIZE_DEFAULT = OBJECT_BUFFER_SIZE_DEFAULT * 1000;
protected String address;
protected int port;
protected int objectBufferSize;
protected int writeBufferSize;
/**
* @param config
* The configuration to use
* @return The newly constructed {@link KryoNetConnectionParameters} based on
* the {@link Configuration} specified
* @throws F2SConfigurationException
* If the configuration specified is invalid
*/
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
//
// Path: core/src/main/java/com/comcast/viper/flume2storm/connection/parameters/ConnectionParameters.java
// public interface ConnectionParameters {
// /**
// * @return A unique identifier of the associated {@link EventSender} /
// * {@link ServiceProvider} (hostname:port for instance)
// *
// */
// String getId();
// }
// Path: kryonet-flume2storm/src/main/java/com/comcast/viper/flume2storm/connection/parameters/KryoNetConnectionParameters.java
import java.io.Serializable;
import java.net.InetAddress;
import java.net.UnknownHostException;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.comcast.viper.flume2storm.F2SConfigurationException;
import com.comcast.viper.flume2storm.connection.parameters.ConnectionParameters;
import com.google.common.base.Preconditions;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.connection.parameters;
/**
* Configuration for the KryoNet connection. Note that the hostname of the
* server is configured according to the following algorithm:
* <ol>
* <li>If the {@link #ADDRESS} parameter is specified, this is the
* address/hostname that is used</li>
* <li>Otherwise, the IP address of the host is retrieved and used</li>
* <li>If the previous step failed, the default hostname
* {@link #ADDRESS_DEFAULT} is used</li>
* </ol>
*/
public class KryoNetConnectionParameters implements ConnectionParameters, Serializable {
private static final long serialVersionUID = -5178954514610562054L;
/** Configuration attribute name for {@link #getAddress()} */
public static final String ADDRESS = "address";
/** Default value for {@value #ADDRESS} */
public static final String ADDRESS_DEFAULT = "localhost";
/** Configuration attribute name for {@link #getPort()} */
public static final String PORT = "port";
/** Default value for {@value #PORT} */
public static final int PORT_DEFAULT = 7000;
/** Configuration attribute name for {@link #getObjectBufferSize()} */
public static final String OBJECT_BUFFER_SZ = "object.buffer.size";
/** Default value for {@value #OBJECT_BUFFER_SZ} */
public static final int OBJECT_BUFFER_SIZE_DEFAULT = 3024;
/** Configuration attribute name for {@link #getWriteBufferSize()} */
public static final String WRITE_BUFFER_SZ = "write.buffer.size";
/** Default value for {@value #WRITE_BUFFER_SZ} */
public static final int WRITE_BUFFER_SIZE_DEFAULT = OBJECT_BUFFER_SIZE_DEFAULT * 1000;
protected String address;
protected int port;
protected int objectBufferSize;
protected int writeBufferSize;
/**
* @param config
* The configuration to use
* @return The newly constructed {@link KryoNetConnectionParameters} based on
* the {@link Configuration} specified
* @throws F2SConfigurationException
* If the configuration specified is invalid
*/
|
public static KryoNetConnectionParameters from(Configuration config) throws F2SConfigurationException {
|
Comcast/flume2storm
|
test-impl/src/main/java/com/comcast/viper/flume2storm/connection/sender/EventSenderTestUtils.java
|
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestCondition.java
// public interface TestCondition {
// /**
// * @return True when the condition is fulfilled, false otherwise
// */
// boolean evaluate();
// }
//
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestUtils.java
// public class TestUtils {
// private static final int DEFAULT_RETRY_TIMEOUT = 100;
// private static Random random = new Random();
//
// /**
// * @return An ephemeral port available for test usage
// */
// public static int getAvailablePort() {
// try (ServerSocket s = new ServerSocket(0)) {
// return s.getLocalPort();
// } catch (Exception e) {
// throw new AssertionError("Failed to find available port", e);
// }
// }
//
// /**
// * @param n
// * Max int allowed
// * @return A random number between 1 and n
// */
// public static final int getRandomPositiveInt(int n) {
// Preconditions.checkArgument(n > 1, "Cannot generate this kind of number!");
// return random.nextInt(n - 1) + 1;
// }
//
// /**
// * Waits that the condition is fulfilled - careful, this may never return!
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static void waitFor(final TestCondition condition) throws InterruptedException {
// waitFor(condition, Integer.MAX_VALUE);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs) throws InterruptedException {
// return waitFor(condition, maxWaitInMs, DEFAULT_RETRY_TIMEOUT);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @param retryTimeout
// * The number of milliseconds to wait before retry the test
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs, final int retryTimeout)
// throws InterruptedException {
// final long t0 = System.currentTimeMillis();
// while (!condition.evaluate() && (System.currentTimeMillis() - t0) < maxWaitInMs) {
// Thread.sleep(retryTimeout);
// }
// if (condition.evaluate()) {
// return true;
// }
// throw new AssertionError("TestCondition did not validate in time");
// }
// }
|
import com.comcast.viper.flume2storm.utility.test.TestCondition;
import com.comcast.viper.flume2storm.utility.test.TestUtils;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.connection.sender;
/**
* Utilities to facilitate testing of an {@link EventSender}
*/
public class EventSenderTestUtils {
protected static final int TIMEOUT_DEFAULT = 500;
/**
* Condition fulfilled when the {@link EventSender} does not have any
*/
|
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestCondition.java
// public interface TestCondition {
// /**
// * @return True when the condition is fulfilled, false otherwise
// */
// boolean evaluate();
// }
//
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestUtils.java
// public class TestUtils {
// private static final int DEFAULT_RETRY_TIMEOUT = 100;
// private static Random random = new Random();
//
// /**
// * @return An ephemeral port available for test usage
// */
// public static int getAvailablePort() {
// try (ServerSocket s = new ServerSocket(0)) {
// return s.getLocalPort();
// } catch (Exception e) {
// throw new AssertionError("Failed to find available port", e);
// }
// }
//
// /**
// * @param n
// * Max int allowed
// * @return A random number between 1 and n
// */
// public static final int getRandomPositiveInt(int n) {
// Preconditions.checkArgument(n > 1, "Cannot generate this kind of number!");
// return random.nextInt(n - 1) + 1;
// }
//
// /**
// * Waits that the condition is fulfilled - careful, this may never return!
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static void waitFor(final TestCondition condition) throws InterruptedException {
// waitFor(condition, Integer.MAX_VALUE);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs) throws InterruptedException {
// return waitFor(condition, maxWaitInMs, DEFAULT_RETRY_TIMEOUT);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @param retryTimeout
// * The number of milliseconds to wait before retry the test
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs, final int retryTimeout)
// throws InterruptedException {
// final long t0 = System.currentTimeMillis();
// while (!condition.evaluate() && (System.currentTimeMillis() - t0) < maxWaitInMs) {
// Thread.sleep(retryTimeout);
// }
// if (condition.evaluate()) {
// return true;
// }
// throw new AssertionError("TestCondition did not validate in time");
// }
// }
// Path: test-impl/src/main/java/com/comcast/viper/flume2storm/connection/sender/EventSenderTestUtils.java
import com.comcast.viper.flume2storm.utility.test.TestCondition;
import com.comcast.viper.flume2storm.utility.test.TestUtils;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.connection.sender;
/**
* Utilities to facilitate testing of an {@link EventSender}
*/
public class EventSenderTestUtils {
protected static final int TIMEOUT_DEFAULT = 500;
/**
* Condition fulfilled when the {@link EventSender} does not have any
*/
|
static class NoReceptorCondition implements TestCondition {
|
Comcast/flume2storm
|
test-impl/src/main/java/com/comcast/viper/flume2storm/connection/sender/EventSenderTestUtils.java
|
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestCondition.java
// public interface TestCondition {
// /**
// * @return True when the condition is fulfilled, false otherwise
// */
// boolean evaluate();
// }
//
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestUtils.java
// public class TestUtils {
// private static final int DEFAULT_RETRY_TIMEOUT = 100;
// private static Random random = new Random();
//
// /**
// * @return An ephemeral port available for test usage
// */
// public static int getAvailablePort() {
// try (ServerSocket s = new ServerSocket(0)) {
// return s.getLocalPort();
// } catch (Exception e) {
// throw new AssertionError("Failed to find available port", e);
// }
// }
//
// /**
// * @param n
// * Max int allowed
// * @return A random number between 1 and n
// */
// public static final int getRandomPositiveInt(int n) {
// Preconditions.checkArgument(n > 1, "Cannot generate this kind of number!");
// return random.nextInt(n - 1) + 1;
// }
//
// /**
// * Waits that the condition is fulfilled - careful, this may never return!
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static void waitFor(final TestCondition condition) throws InterruptedException {
// waitFor(condition, Integer.MAX_VALUE);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs) throws InterruptedException {
// return waitFor(condition, maxWaitInMs, DEFAULT_RETRY_TIMEOUT);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @param retryTimeout
// * The number of milliseconds to wait before retry the test
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs, final int retryTimeout)
// throws InterruptedException {
// final long t0 = System.currentTimeMillis();
// while (!condition.evaluate() && (System.currentTimeMillis() - t0) < maxWaitInMs) {
// Thread.sleep(retryTimeout);
// }
// if (condition.evaluate()) {
// return true;
// }
// throw new AssertionError("TestCondition did not validate in time");
// }
// }
|
import com.comcast.viper.flume2storm.utility.test.TestCondition;
import com.comcast.viper.flume2storm.utility.test.TestUtils;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.connection.sender;
/**
* Utilities to facilitate testing of an {@link EventSender}
*/
public class EventSenderTestUtils {
protected static final int TIMEOUT_DEFAULT = 500;
/**
* Condition fulfilled when the {@link EventSender} does not have any
*/
static class NoReceptorCondition implements TestCondition {
private final EventSender<?> sender;
public NoReceptorCondition(final EventSender<?> sender) {
this.sender = sender;
}
@Override
public boolean evaluate() {
return sender.getStats().getNbClients() == 0;
}
}
/**
* Waits that there is no receptor connected to the sender. It throws an
* assertion failure otherwise
*
* @param sender
* The {@link EventSender}
* @param timeout
* Max wait time, in milliseconds
* @throws InterruptedException
*/
public static void waitNoReceptor(EventSender<?> sender, final int timeout) throws InterruptedException {
|
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestCondition.java
// public interface TestCondition {
// /**
// * @return True when the condition is fulfilled, false otherwise
// */
// boolean evaluate();
// }
//
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestUtils.java
// public class TestUtils {
// private static final int DEFAULT_RETRY_TIMEOUT = 100;
// private static Random random = new Random();
//
// /**
// * @return An ephemeral port available for test usage
// */
// public static int getAvailablePort() {
// try (ServerSocket s = new ServerSocket(0)) {
// return s.getLocalPort();
// } catch (Exception e) {
// throw new AssertionError("Failed to find available port", e);
// }
// }
//
// /**
// * @param n
// * Max int allowed
// * @return A random number between 1 and n
// */
// public static final int getRandomPositiveInt(int n) {
// Preconditions.checkArgument(n > 1, "Cannot generate this kind of number!");
// return random.nextInt(n - 1) + 1;
// }
//
// /**
// * Waits that the condition is fulfilled - careful, this may never return!
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static void waitFor(final TestCondition condition) throws InterruptedException {
// waitFor(condition, Integer.MAX_VALUE);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs) throws InterruptedException {
// return waitFor(condition, maxWaitInMs, DEFAULT_RETRY_TIMEOUT);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @param retryTimeout
// * The number of milliseconds to wait before retry the test
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs, final int retryTimeout)
// throws InterruptedException {
// final long t0 = System.currentTimeMillis();
// while (!condition.evaluate() && (System.currentTimeMillis() - t0) < maxWaitInMs) {
// Thread.sleep(retryTimeout);
// }
// if (condition.evaluate()) {
// return true;
// }
// throw new AssertionError("TestCondition did not validate in time");
// }
// }
// Path: test-impl/src/main/java/com/comcast/viper/flume2storm/connection/sender/EventSenderTestUtils.java
import com.comcast.viper.flume2storm.utility.test.TestCondition;
import com.comcast.viper.flume2storm.utility.test.TestUtils;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.connection.sender;
/**
* Utilities to facilitate testing of an {@link EventSender}
*/
public class EventSenderTestUtils {
protected static final int TIMEOUT_DEFAULT = 500;
/**
* Condition fulfilled when the {@link EventSender} does not have any
*/
static class NoReceptorCondition implements TestCondition {
private final EventSender<?> sender;
public NoReceptorCondition(final EventSender<?> sender) {
this.sender = sender;
}
@Override
public boolean evaluate() {
return sender.getStats().getNbClients() == 0;
}
}
/**
* Waits that there is no receptor connected to the sender. It throws an
* assertion failure otherwise
*
* @param sender
* The {@link EventSender}
* @param timeout
* Max wait time, in milliseconds
* @throws InterruptedException
*/
public static void waitNoReceptor(EventSender<?> sender, final int timeout) throws InterruptedException {
|
if (!TestUtils.waitFor(new NoReceptorCondition(sender), timeout)) {
|
Comcast/flume2storm
|
dynamic-location-service/src/test/java/com/comcast/viper/flume2storm/zookeeper/ZkTestUtils.java
|
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestCondition.java
// public interface TestCondition {
// /**
// * @return True when the condition is fulfilled, false otherwise
// */
// boolean evaluate();
// }
//
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestUtils.java
// public class TestUtils {
// private static final int DEFAULT_RETRY_TIMEOUT = 100;
// private static Random random = new Random();
//
// /**
// * @return An ephemeral port available for test usage
// */
// public static int getAvailablePort() {
// try (ServerSocket s = new ServerSocket(0)) {
// return s.getLocalPort();
// } catch (Exception e) {
// throw new AssertionError("Failed to find available port", e);
// }
// }
//
// /**
// * @param n
// * Max int allowed
// * @return A random number between 1 and n
// */
// public static final int getRandomPositiveInt(int n) {
// Preconditions.checkArgument(n > 1, "Cannot generate this kind of number!");
// return random.nextInt(n - 1) + 1;
// }
//
// /**
// * Waits that the condition is fulfilled - careful, this may never return!
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static void waitFor(final TestCondition condition) throws InterruptedException {
// waitFor(condition, Integer.MAX_VALUE);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs) throws InterruptedException {
// return waitFor(condition, maxWaitInMs, DEFAULT_RETRY_TIMEOUT);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @param retryTimeout
// * The number of milliseconds to wait before retry the test
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs, final int retryTimeout)
// throws InterruptedException {
// final long t0 = System.currentTimeMillis();
// while (!condition.evaluate() && (System.currentTimeMillis() - t0) < maxWaitInMs) {
// Thread.sleep(retryTimeout);
// }
// if (condition.evaluate()) {
// return true;
// }
// throw new AssertionError("TestCondition did not validate in time");
// }
// }
|
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;
import org.apache.commons.lang.StringUtils;
import com.comcast.viper.flume2storm.utility.test.TestCondition;
import com.comcast.viper.flume2storm.utility.test.TestUtils;
import com.google.common.base.Preconditions;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.zookeeper;
/**
*
*/
public class ZkTestUtils {
public static final int TEST_TIMEOUT = 10000;
public static final int ZK_OP_TIMEOUT = 3000;
public static final int A_LITTLE = 1500;
public static final String HOST = "127.0.0.1";
|
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestCondition.java
// public interface TestCondition {
// /**
// * @return True when the condition is fulfilled, false otherwise
// */
// boolean evaluate();
// }
//
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestUtils.java
// public class TestUtils {
// private static final int DEFAULT_RETRY_TIMEOUT = 100;
// private static Random random = new Random();
//
// /**
// * @return An ephemeral port available for test usage
// */
// public static int getAvailablePort() {
// try (ServerSocket s = new ServerSocket(0)) {
// return s.getLocalPort();
// } catch (Exception e) {
// throw new AssertionError("Failed to find available port", e);
// }
// }
//
// /**
// * @param n
// * Max int allowed
// * @return A random number between 1 and n
// */
// public static final int getRandomPositiveInt(int n) {
// Preconditions.checkArgument(n > 1, "Cannot generate this kind of number!");
// return random.nextInt(n - 1) + 1;
// }
//
// /**
// * Waits that the condition is fulfilled - careful, this may never return!
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static void waitFor(final TestCondition condition) throws InterruptedException {
// waitFor(condition, Integer.MAX_VALUE);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs) throws InterruptedException {
// return waitFor(condition, maxWaitInMs, DEFAULT_RETRY_TIMEOUT);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @param retryTimeout
// * The number of milliseconds to wait before retry the test
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs, final int retryTimeout)
// throws InterruptedException {
// final long t0 = System.currentTimeMillis();
// while (!condition.evaluate() && (System.currentTimeMillis() - t0) < maxWaitInMs) {
// Thread.sleep(retryTimeout);
// }
// if (condition.evaluate()) {
// return true;
// }
// throw new AssertionError("TestCondition did not validate in time");
// }
// }
// Path: dynamic-location-service/src/test/java/com/comcast/viper/flume2storm/zookeeper/ZkTestUtils.java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;
import org.apache.commons.lang.StringUtils;
import com.comcast.viper.flume2storm.utility.test.TestCondition;
import com.comcast.viper.flume2storm.utility.test.TestUtils;
import com.google.common.base.Preconditions;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.zookeeper;
/**
*
*/
public class ZkTestUtils {
public static final int TEST_TIMEOUT = 10000;
public static final int ZK_OP_TIMEOUT = 3000;
public static final int A_LITTLE = 1500;
public static final String HOST = "127.0.0.1";
|
public static final int PORT = TestUtils.getAvailablePort();
|
Comcast/flume2storm
|
dynamic-location-service/src/test/java/com/comcast/viper/flume2storm/zookeeper/ZkTestUtils.java
|
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestCondition.java
// public interface TestCondition {
// /**
// * @return True when the condition is fulfilled, false otherwise
// */
// boolean evaluate();
// }
//
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestUtils.java
// public class TestUtils {
// private static final int DEFAULT_RETRY_TIMEOUT = 100;
// private static Random random = new Random();
//
// /**
// * @return An ephemeral port available for test usage
// */
// public static int getAvailablePort() {
// try (ServerSocket s = new ServerSocket(0)) {
// return s.getLocalPort();
// } catch (Exception e) {
// throw new AssertionError("Failed to find available port", e);
// }
// }
//
// /**
// * @param n
// * Max int allowed
// * @return A random number between 1 and n
// */
// public static final int getRandomPositiveInt(int n) {
// Preconditions.checkArgument(n > 1, "Cannot generate this kind of number!");
// return random.nextInt(n - 1) + 1;
// }
//
// /**
// * Waits that the condition is fulfilled - careful, this may never return!
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static void waitFor(final TestCondition condition) throws InterruptedException {
// waitFor(condition, Integer.MAX_VALUE);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs) throws InterruptedException {
// return waitFor(condition, maxWaitInMs, DEFAULT_RETRY_TIMEOUT);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @param retryTimeout
// * The number of milliseconds to wait before retry the test
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs, final int retryTimeout)
// throws InterruptedException {
// final long t0 = System.currentTimeMillis();
// while (!condition.evaluate() && (System.currentTimeMillis() - t0) < maxWaitInMs) {
// Thread.sleep(retryTimeout);
// }
// if (condition.evaluate()) {
// return true;
// }
// throw new AssertionError("TestCondition did not validate in time");
// }
// }
|
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;
import org.apache.commons.lang.StringUtils;
import com.comcast.viper.flume2storm.utility.test.TestCondition;
import com.comcast.viper.flume2storm.utility.test.TestUtils;
import com.google.common.base.Preconditions;
|
final Socket sock = new Socket(host, port);
OutputStream outstream = null;
BufferedReader reader = null;
try {
outstream = sock.getOutputStream();
outstream.write(cmd.getBytes());
outstream.flush();
reader = new BufferedReader(new InputStreamReader(sock.getInputStream()));
final StringBuilder sb = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
return sb.toString();
} finally {
if (outstream != null) {
outstream.close();
}
sock.close();
if (reader != null) {
reader.close();
}
}
} catch (final Exception e) {
System.out.println(e.getMessage());
return StringUtils.EMPTY;
}
}
|
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestCondition.java
// public interface TestCondition {
// /**
// * @return True when the condition is fulfilled, false otherwise
// */
// boolean evaluate();
// }
//
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestUtils.java
// public class TestUtils {
// private static final int DEFAULT_RETRY_TIMEOUT = 100;
// private static Random random = new Random();
//
// /**
// * @return An ephemeral port available for test usage
// */
// public static int getAvailablePort() {
// try (ServerSocket s = new ServerSocket(0)) {
// return s.getLocalPort();
// } catch (Exception e) {
// throw new AssertionError("Failed to find available port", e);
// }
// }
//
// /**
// * @param n
// * Max int allowed
// * @return A random number between 1 and n
// */
// public static final int getRandomPositiveInt(int n) {
// Preconditions.checkArgument(n > 1, "Cannot generate this kind of number!");
// return random.nextInt(n - 1) + 1;
// }
//
// /**
// * Waits that the condition is fulfilled - careful, this may never return!
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static void waitFor(final TestCondition condition) throws InterruptedException {
// waitFor(condition, Integer.MAX_VALUE);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs) throws InterruptedException {
// return waitFor(condition, maxWaitInMs, DEFAULT_RETRY_TIMEOUT);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @param retryTimeout
// * The number of milliseconds to wait before retry the test
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs, final int retryTimeout)
// throws InterruptedException {
// final long t0 = System.currentTimeMillis();
// while (!condition.evaluate() && (System.currentTimeMillis() - t0) < maxWaitInMs) {
// Thread.sleep(retryTimeout);
// }
// if (condition.evaluate()) {
// return true;
// }
// throw new AssertionError("TestCondition did not validate in time");
// }
// }
// Path: dynamic-location-service/src/test/java/com/comcast/viper/flume2storm/zookeeper/ZkTestUtils.java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;
import org.apache.commons.lang.StringUtils;
import com.comcast.viper.flume2storm.utility.test.TestCondition;
import com.comcast.viper.flume2storm.utility.test.TestUtils;
import com.google.common.base.Preconditions;
final Socket sock = new Socket(host, port);
OutputStream outstream = null;
BufferedReader reader = null;
try {
outstream = sock.getOutputStream();
outstream.write(cmd.getBytes());
outstream.flush();
reader = new BufferedReader(new InputStreamReader(sock.getInputStream()));
final StringBuilder sb = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
return sb.toString();
} finally {
if (outstream != null) {
outstream.close();
}
sock.close();
if (reader != null) {
reader.close();
}
}
} catch (final Exception e) {
System.out.println(e.getMessage());
return StringUtils.EMPTY;
}
}
|
public static final TestCondition ZK_IS_ON = new TestCondition() {
|
Comcast/flume2storm
|
test-impl/src/test/java/com/comcast/viper/flume2storm/location/TestSimpleLocationService.java
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
|
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
import com.comcast.viper.flume2storm.F2SConfigurationException;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.location;
/**
* Unit test for {@link SimpleLocationService}
*/
public class TestSimpleLocationService {
/**
* Test {@link SimpleLocationService}s
*
* @throws F2SConfigurationException
* Never actually thrown
*/
@Test
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
// Path: test-impl/src/test/java/com/comcast/viper/flume2storm/location/TestSimpleLocationService.java
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
import com.comcast.viper.flume2storm.F2SConfigurationException;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.location;
/**
* Unit test for {@link SimpleLocationService}
*/
public class TestSimpleLocationService {
/**
* Test {@link SimpleLocationService}s
*
* @throws F2SConfigurationException
* Never actually thrown
*/
@Test
|
public void testWithListeners() throws F2SConfigurationException {
|
Comcast/flume2storm
|
dynamic-location-service/src/main/java/com/comcast/viper/flume2storm/zookeeper/ZkClientConfiguration.java
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
|
import java.io.Serializable;
import org.apache.commons.configuration.Configuration;
import com.comcast.viper.flume2storm.F2SConfigurationException;
import com.google.common.base.Preconditions;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.zookeeper;
/**
* Configuration for {@link ZkClient}
*/
public class ZkClientConfiguration implements Serializable {
private static final long serialVersionUID = 4096690012104970344L;
/** Configuration attribute name for {@link #getConnectionStr()} */
public static final String CONNECTION_STRING = "connection.string";
/** Default value for {@value #CONNECTION_STRING} */
public static final String CONNECTION_STRING_DEFAULT = "localhost:2181";
/** Configuration attribute name for {@link #getSessionTimeout()} */
public static final String SESSION_TIMEOUT = "session.timeout";
/** Default value for {@value #SESSION_TIMEOUT} */
public static final int SESSION_TIMEOUT_DEFAULT = 30000;
/** Configuration attribute name for {@link #getConnectionTimeout()} */
public static final String CONNECTION_TIMEOUT = "connection.timeout";
/** Default value for {@value #CONNECTION_TIMEOUT} */
public static final int CONNECTION_TIMEOUT_DEFAULT = 10000;
/** Configuration attribute name for {@link #getReconnectionDelay()} */
public static final String RECONNECTION_DELAY = "reconnection.delay.in.ms";
/** Default value for {@value #RECONNECTION_DELAY} */
public static final int RECONNECTION_DELAY_DEFAULT = 10000;
/** Configuration attribute name for {@link #getTerminationTimeout()} */
public static final String TERMINATION_TIMEOUT = "termination.timeout";
/** Default value for {@value #TERMINATION_TIMEOUT} */
public static final int TERMINATION_TIMEOUT_DEFAULT = 10000;
protected String connectionStr;
protected int sessionTimeout;
protected int connectionTimeout;
protected int reconnectionDelay;
protected int terminationTimeout;
/**
* Builds a new {@link ZkClientConfiguration} based on a Configuration
*
* @param config
* The configuration to use
* @return The newly built {@link ZkClientConfiguration} based on the
* configuration specified
* @throws F2SConfigurationException
* If the configuration is invalid
*/
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
// Path: dynamic-location-service/src/main/java/com/comcast/viper/flume2storm/zookeeper/ZkClientConfiguration.java
import java.io.Serializable;
import org.apache.commons.configuration.Configuration;
import com.comcast.viper.flume2storm.F2SConfigurationException;
import com.google.common.base.Preconditions;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.zookeeper;
/**
* Configuration for {@link ZkClient}
*/
public class ZkClientConfiguration implements Serializable {
private static final long serialVersionUID = 4096690012104970344L;
/** Configuration attribute name for {@link #getConnectionStr()} */
public static final String CONNECTION_STRING = "connection.string";
/** Default value for {@value #CONNECTION_STRING} */
public static final String CONNECTION_STRING_DEFAULT = "localhost:2181";
/** Configuration attribute name for {@link #getSessionTimeout()} */
public static final String SESSION_TIMEOUT = "session.timeout";
/** Default value for {@value #SESSION_TIMEOUT} */
public static final int SESSION_TIMEOUT_DEFAULT = 30000;
/** Configuration attribute name for {@link #getConnectionTimeout()} */
public static final String CONNECTION_TIMEOUT = "connection.timeout";
/** Default value for {@value #CONNECTION_TIMEOUT} */
public static final int CONNECTION_TIMEOUT_DEFAULT = 10000;
/** Configuration attribute name for {@link #getReconnectionDelay()} */
public static final String RECONNECTION_DELAY = "reconnection.delay.in.ms";
/** Default value for {@value #RECONNECTION_DELAY} */
public static final int RECONNECTION_DELAY_DEFAULT = 10000;
/** Configuration attribute name for {@link #getTerminationTimeout()} */
public static final String TERMINATION_TIMEOUT = "termination.timeout";
/** Default value for {@value #TERMINATION_TIMEOUT} */
public static final int TERMINATION_TIMEOUT_DEFAULT = 10000;
protected String connectionStr;
protected int sessionTimeout;
protected int connectionTimeout;
protected int reconnectionDelay;
protected int terminationTimeout;
/**
* Builds a new {@link ZkClientConfiguration} based on a Configuration
*
* @param config
* The configuration to use
* @return The newly built {@link ZkClientConfiguration} based on the
* configuration specified
* @throws F2SConfigurationException
* If the configuration is invalid
*/
|
public static ZkClientConfiguration from(Configuration config) throws F2SConfigurationException {
|
Comcast/flume2storm
|
kryo-utils/src/main/java/com/comcast/viper/flume2storm/KryoUtil.java
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/event/F2SEvent.java
// public final class F2SEvent implements Serializable {
// private static final long serialVersionUID = -5906404402187281472L;
// private final Map<String, String> headers;
// private final byte[] body;
//
// F2SEvent() {
// headers = ImmutableMap.of();
// body = new byte[0];
// }
//
// /**
// * Constructor to build Flume2Storm events
// *
// * @param headers
// * See {@link #getHeaders()}. If null, the headers is an empty
// * immutable map.
// * @param body
// * See {@link #getBody()}. If null, the payload of the event is an
// * empty byte array.
// */
// public F2SEvent(Map<String, String> headers, byte[] body) {
// if (headers == null) {
// this.headers = ImmutableMap.of();
// } else {
// this.headers = ImmutableMap.copyOf(headers);
// }
// if (body == null) {
// this.body = ArrayUtils.EMPTY_BYTE_ARRAY;
// } else {
// this.body = ArrayUtils.clone(body);
// }
// }
//
// /**
// * Copy constructor
// *
// * @param event
// * Another Flume2Storm event
// */
// public F2SEvent(F2SEvent event) {
// headers = ImmutableMap.copyOf(event.getHeaders());
// body = event.body;
// }
//
// /**
// * @return The event body
// */
// public byte[] getBody() {
// return body;
// }
//
// /**
// * @return The headers (key/value pairs) associated to the event
// */
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// /**
// * @param key
// * A header name (i.e. key)
// * @return The value of the header, or null if it does not exist
// */
// public String getHeader(String key) {
// return headers.get(key);
// }
//
// /**
// * @see java.lang.Object#hashCode()
// */
// @Override
// public int hashCode() {
// return new HashCodeBuilder().append(headers).append(body).hashCode();
// }
//
// /**
// * @see java.lang.Object#equals(java.lang.Object)
// */
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// F2SEvent other = (F2SEvent) obj;
// return new EqualsBuilder().append(this.headers, other.headers)
// .append(this.body, other.body).isEquals();
// }
//
// /**
// * @see java.lang.Object#toString()
// */
// @Override
// public String toString() {
// ToStringBuilder toStringBuilder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("headers",
// headers);
// String bodyStr = StringUtils.toEncodedString(body, F2SEventFactory.DEFAULT_CHARACTER_SET);
// if (StringUtils.isAsciiPrintable(bodyStr)) {
// toStringBuilder.append("body", bodyStr);
// } else {
// toStringBuilder.append(Hex.encodeHexString(body));
// }
// return toStringBuilder.toString();
// }
// }
|
import com.comcast.viper.flume2storm.event.F2SEvent;
import com.esotericsoftware.kryo.Kryo;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm;
/**
* Common utilities for Kryo serialization of Flume2Storm event
*/
public class KryoUtil {
/**
* Registers to the Kryo instance provided the classes needed for Flume2Storm
*
* @param kryo
* A Kryo instance
*/
public static void register(final Kryo kryo) {
kryo.register(byte[].class);
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/event/F2SEvent.java
// public final class F2SEvent implements Serializable {
// private static final long serialVersionUID = -5906404402187281472L;
// private final Map<String, String> headers;
// private final byte[] body;
//
// F2SEvent() {
// headers = ImmutableMap.of();
// body = new byte[0];
// }
//
// /**
// * Constructor to build Flume2Storm events
// *
// * @param headers
// * See {@link #getHeaders()}. If null, the headers is an empty
// * immutable map.
// * @param body
// * See {@link #getBody()}. If null, the payload of the event is an
// * empty byte array.
// */
// public F2SEvent(Map<String, String> headers, byte[] body) {
// if (headers == null) {
// this.headers = ImmutableMap.of();
// } else {
// this.headers = ImmutableMap.copyOf(headers);
// }
// if (body == null) {
// this.body = ArrayUtils.EMPTY_BYTE_ARRAY;
// } else {
// this.body = ArrayUtils.clone(body);
// }
// }
//
// /**
// * Copy constructor
// *
// * @param event
// * Another Flume2Storm event
// */
// public F2SEvent(F2SEvent event) {
// headers = ImmutableMap.copyOf(event.getHeaders());
// body = event.body;
// }
//
// /**
// * @return The event body
// */
// public byte[] getBody() {
// return body;
// }
//
// /**
// * @return The headers (key/value pairs) associated to the event
// */
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// /**
// * @param key
// * A header name (i.e. key)
// * @return The value of the header, or null if it does not exist
// */
// public String getHeader(String key) {
// return headers.get(key);
// }
//
// /**
// * @see java.lang.Object#hashCode()
// */
// @Override
// public int hashCode() {
// return new HashCodeBuilder().append(headers).append(body).hashCode();
// }
//
// /**
// * @see java.lang.Object#equals(java.lang.Object)
// */
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// F2SEvent other = (F2SEvent) obj;
// return new EqualsBuilder().append(this.headers, other.headers)
// .append(this.body, other.body).isEquals();
// }
//
// /**
// * @see java.lang.Object#toString()
// */
// @Override
// public String toString() {
// ToStringBuilder toStringBuilder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("headers",
// headers);
// String bodyStr = StringUtils.toEncodedString(body, F2SEventFactory.DEFAULT_CHARACTER_SET);
// if (StringUtils.isAsciiPrintable(bodyStr)) {
// toStringBuilder.append("body", bodyStr);
// } else {
// toStringBuilder.append(Hex.encodeHexString(body));
// }
// return toStringBuilder.toString();
// }
// }
// Path: kryo-utils/src/main/java/com/comcast/viper/flume2storm/KryoUtil.java
import com.comcast.viper.flume2storm.event.F2SEvent;
import com.esotericsoftware.kryo.Kryo;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm;
/**
* Common utilities for Kryo serialization of Flume2Storm event
*/
public class KryoUtil {
/**
* Registers to the Kryo instance provided the classes needed for Flume2Storm
*
* @param kryo
* A Kryo instance
*/
public static void register(final Kryo kryo) {
kryo.register(byte[].class);
|
kryo.register(F2SEvent.class, new F2SEventSerializer());
|
Comcast/flume2storm
|
dynamic-location-service/src/main/java/com/comcast/viper/flume2storm/location/DynamicLocationServiceFactory.java
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
|
import org.apache.commons.configuration.Configuration;
import com.comcast.viper.flume2storm.F2SConfigurationException;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.location;
/**
* Factory class for {@link DynamicLocationService}
*
* @param <SP>
* The Service Provider class
*/
public class DynamicLocationServiceFactory<SP extends ServiceProvider<?>> implements LocationServiceFactory<SP> {
/** Configuration attribute base name */
public static final String CONFIG_BASE_NAME = "dynamic.location.service";
/**
* @see com.comcast.viper.flume2storm.location.LocationServiceFactory#create(org.apache.commons.configuration.Configuration,
* com.comcast.viper.flume2storm.location.ServiceProviderSerialization)
*/
@Override
public LocationService<SP> create(Configuration config, ServiceProviderSerialization<SP> serviceProviderSerialization)
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
// Path: dynamic-location-service/src/main/java/com/comcast/viper/flume2storm/location/DynamicLocationServiceFactory.java
import org.apache.commons.configuration.Configuration;
import com.comcast.viper.flume2storm.F2SConfigurationException;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.location;
/**
* Factory class for {@link DynamicLocationService}
*
* @param <SP>
* The Service Provider class
*/
public class DynamicLocationServiceFactory<SP extends ServiceProvider<?>> implements LocationServiceFactory<SP> {
/** Configuration attribute base name */
public static final String CONFIG_BASE_NAME = "dynamic.location.service";
/**
* @see com.comcast.viper.flume2storm.location.LocationServiceFactory#create(org.apache.commons.configuration.Configuration,
* com.comcast.viper.flume2storm.location.ServiceProviderSerialization)
*/
@Override
public LocationService<SP> create(Configuration config, ServiceProviderSerialization<SP> serviceProviderSerialization)
|
throws F2SConfigurationException {
|
Comcast/flume2storm
|
utility/src/test/java/com/comcast/viper/flume2storm/utility/test/TestUtilsTest.java
|
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/Constants.java
// public interface Constants {
// /**
// * The maximum unsigned short value
// */
// int MAX_UNSIGNED_SHORT = 0xFFFF;
// }
|
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.comcast.viper.flume2storm.utility.Constants;
|
final Thread thread = new TestThread();
thread.start();
LOG.debug("Waiting for condition (thread terminated)...");
TestUtils.waitFor(new MyTestCondition(), DURATION / 2);
}
/**
* Test {@link TestUtils#waitFor(TestCondition, int)} success
*
* @throws InterruptedException
* If interrupted
*/
@Test
public void testTimeoutSuccess() throws InterruptedException {
final Thread thread = new TestThread();
thread.start();
LOG.debug("Waiting for condition (thread terminated)...");
final boolean result = TestUtils.waitFor(new MyTestCondition(), DURATION * 2);
LOG.debug("Done waiting");
Assert.assertTrue(result);
thread.join();
}
/**
* Test {@link TestUtils#getAvailablePort()}
*/
@Test
public void testGetAvailablePort() {
int port1 = TestUtils.getAvailablePort();
Assert.assertTrue(port1 > 0);
|
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/Constants.java
// public interface Constants {
// /**
// * The maximum unsigned short value
// */
// int MAX_UNSIGNED_SHORT = 0xFFFF;
// }
// Path: utility/src/test/java/com/comcast/viper/flume2storm/utility/test/TestUtilsTest.java
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.comcast.viper.flume2storm.utility.Constants;
final Thread thread = new TestThread();
thread.start();
LOG.debug("Waiting for condition (thread terminated)...");
TestUtils.waitFor(new MyTestCondition(), DURATION / 2);
}
/**
* Test {@link TestUtils#waitFor(TestCondition, int)} success
*
* @throws InterruptedException
* If interrupted
*/
@Test
public void testTimeoutSuccess() throws InterruptedException {
final Thread thread = new TestThread();
thread.start();
LOG.debug("Waiting for condition (thread terminated)...");
final boolean result = TestUtils.waitFor(new MyTestCondition(), DURATION * 2);
LOG.debug("Done waiting");
Assert.assertTrue(result);
thread.join();
}
/**
* Test {@link TestUtils#getAvailablePort()}
*/
@Test
public void testGetAvailablePort() {
int port1 = TestUtils.getAvailablePort();
Assert.assertTrue(port1 > 0);
|
Assert.assertTrue(port1 < Constants.MAX_UNSIGNED_SHORT);
|
Comcast/flume2storm
|
kryonet-flume2storm/src/main/java/com/comcast/viper/flume2storm/connection/parameters/KryoNetConnectionParametersFactory.java
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
//
// Path: core/src/main/java/com/comcast/viper/flume2storm/connection/parameters/ConnectionParametersFactory.java
// public interface ConnectionParametersFactory<CP extends ConnectionParameters> {
// /**
// * Creates a new {@link ConnectionParameters} based on the configuration
// * provided
// *
// * @param config
// * Configuration for the connections parameters
// * @return The newly created {@link ConnectionParameters}
// * @throws F2SConfigurationException
// * If the configuration specified is invalid
// */
// CP create(Configuration config) throws F2SConfigurationException;
// }
|
import org.apache.commons.configuration.Configuration;
import com.comcast.viper.flume2storm.F2SConfigurationException;
import com.comcast.viper.flume2storm.connection.parameters.ConnectionParametersFactory;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.connection.parameters;
/**
* Implementation of the Connection Parameters factory for KryoNet
*/
public class KryoNetConnectionParametersFactory implements ConnectionParametersFactory<KryoNetConnectionParameters> {
/** Configuration attribute base name */
public static final String CONFIG_BASE_NAME = "kryonet.connection.parameters";
/**
* @see com.comcast.viper.flume2storm.connection.parameters.ConnectionParametersFactory#create(org.apache.commons.configuration.Configuration)
*/
@Override
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
//
// Path: core/src/main/java/com/comcast/viper/flume2storm/connection/parameters/ConnectionParametersFactory.java
// public interface ConnectionParametersFactory<CP extends ConnectionParameters> {
// /**
// * Creates a new {@link ConnectionParameters} based on the configuration
// * provided
// *
// * @param config
// * Configuration for the connections parameters
// * @return The newly created {@link ConnectionParameters}
// * @throws F2SConfigurationException
// * If the configuration specified is invalid
// */
// CP create(Configuration config) throws F2SConfigurationException;
// }
// Path: kryonet-flume2storm/src/main/java/com/comcast/viper/flume2storm/connection/parameters/KryoNetConnectionParametersFactory.java
import org.apache.commons.configuration.Configuration;
import com.comcast.viper.flume2storm.F2SConfigurationException;
import com.comcast.viper.flume2storm.connection.parameters.ConnectionParametersFactory;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.connection.parameters;
/**
* Implementation of the Connection Parameters factory for KryoNet
*/
public class KryoNetConnectionParametersFactory implements ConnectionParametersFactory<KryoNetConnectionParameters> {
/** Configuration attribute base name */
public static final String CONFIG_BASE_NAME = "kryonet.connection.parameters";
/**
* @see com.comcast.viper.flume2storm.connection.parameters.ConnectionParametersFactory#create(org.apache.commons.configuration.Configuration)
*/
@Override
|
public KryoNetConnectionParameters create(Configuration config) throws F2SConfigurationException {
|
Comcast/flume2storm
|
dynamic-location-service/src/test/java/com/comcast/viper/flume2storm/zookeeper/ZkClientConfigurationTest.java
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
|
import junit.framework.Assert;
import org.apache.commons.configuration.BaseConfiguration;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang.StringUtils;
import org.junit.Test;
import com.comcast.viper.flume2storm.F2SConfigurationException;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.zookeeper;
public class ZkClientConfigurationTest {
@Test
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
// Path: dynamic-location-service/src/test/java/com/comcast/viper/flume2storm/zookeeper/ZkClientConfigurationTest.java
import junit.framework.Assert;
import org.apache.commons.configuration.BaseConfiguration;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang.StringUtils;
import org.junit.Test;
import com.comcast.viper.flume2storm.F2SConfigurationException;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.zookeeper;
public class ZkClientConfigurationTest {
@Test
|
public void testFromConfiguration() throws F2SConfigurationException {
|
Comcast/flume2storm
|
core/src/main/java/com/comcast/viper/flume2storm/location/LocationServiceFactory.java
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
|
import org.apache.commons.configuration.Configuration;
import com.comcast.viper.flume2storm.F2SConfigurationException;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.location;
/**
* Interface to build a Location Service. It follows the abstract factory design
* pattern. Implementation of this factory must have a no-argument constructor.
*
* @param <SP>
* The Service Provider class
*/
public interface LocationServiceFactory<SP extends ServiceProvider<?>> {
/**
* Creates a new {@link LocationService} based on the configuration provided
*
* @param config
* Configuration for the location service
* @param serviceProviderSerialization
* The {@link ServiceProviderSerialization} to use
* @return The newly created {@link LocationService}
* @throws F2SConfigurationException
* If the configuration specified is invalid
*/
LocationService<SP> create(Configuration config, ServiceProviderSerialization<SP> serviceProviderSerialization)
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
// Path: core/src/main/java/com/comcast/viper/flume2storm/location/LocationServiceFactory.java
import org.apache.commons.configuration.Configuration;
import com.comcast.viper.flume2storm.F2SConfigurationException;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.location;
/**
* Interface to build a Location Service. It follows the abstract factory design
* pattern. Implementation of this factory must have a no-argument constructor.
*
* @param <SP>
* The Service Provider class
*/
public interface LocationServiceFactory<SP extends ServiceProvider<?>> {
/**
* Creates a new {@link LocationService} based on the configuration provided
*
* @param config
* Configuration for the location service
* @param serviceProviderSerialization
* The {@link ServiceProviderSerialization} to use
* @return The newly created {@link LocationService}
* @throws F2SConfigurationException
* If the configuration specified is invalid
*/
LocationService<SP> create(Configuration config, ServiceProviderSerialization<SP> serviceProviderSerialization)
|
throws F2SConfigurationException;
|
Comcast/flume2storm
|
flume-spout/src/test/java/com/comcast/viper/flume2storm/spout/MemoryStorage.java
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/event/F2SEvent.java
// public final class F2SEvent implements Serializable {
// private static final long serialVersionUID = -5906404402187281472L;
// private final Map<String, String> headers;
// private final byte[] body;
//
// F2SEvent() {
// headers = ImmutableMap.of();
// body = new byte[0];
// }
//
// /**
// * Constructor to build Flume2Storm events
// *
// * @param headers
// * See {@link #getHeaders()}. If null, the headers is an empty
// * immutable map.
// * @param body
// * See {@link #getBody()}. If null, the payload of the event is an
// * empty byte array.
// */
// public F2SEvent(Map<String, String> headers, byte[] body) {
// if (headers == null) {
// this.headers = ImmutableMap.of();
// } else {
// this.headers = ImmutableMap.copyOf(headers);
// }
// if (body == null) {
// this.body = ArrayUtils.EMPTY_BYTE_ARRAY;
// } else {
// this.body = ArrayUtils.clone(body);
// }
// }
//
// /**
// * Copy constructor
// *
// * @param event
// * Another Flume2Storm event
// */
// public F2SEvent(F2SEvent event) {
// headers = ImmutableMap.copyOf(event.getHeaders());
// body = event.body;
// }
//
// /**
// * @return The event body
// */
// public byte[] getBody() {
// return body;
// }
//
// /**
// * @return The headers (key/value pairs) associated to the event
// */
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// /**
// * @param key
// * A header name (i.e. key)
// * @return The value of the header, or null if it does not exist
// */
// public String getHeader(String key) {
// return headers.get(key);
// }
//
// /**
// * @see java.lang.Object#hashCode()
// */
// @Override
// public int hashCode() {
// return new HashCodeBuilder().append(headers).append(body).hashCode();
// }
//
// /**
// * @see java.lang.Object#equals(java.lang.Object)
// */
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// F2SEvent other = (F2SEvent) obj;
// return new EqualsBuilder().append(this.headers, other.headers)
// .append(this.body, other.body).isEquals();
// }
//
// /**
// * @see java.lang.Object#toString()
// */
// @Override
// public String toString() {
// ToStringBuilder toStringBuilder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("headers",
// headers);
// String bodyStr = StringUtils.toEncodedString(body, F2SEventFactory.DEFAULT_CHARACTER_SET);
// if (StringUtils.isAsciiPrintable(bodyStr)) {
// toStringBuilder.append("body", bodyStr);
// } else {
// toStringBuilder.append(Hex.encodeHexString(body));
// }
// return toStringBuilder.toString();
// }
// }
//
// Path: core/src/main/java/com/comcast/viper/flume2storm/event/F2SEventComparator.java
// public class F2SEventComparator implements Comparator<F2SEvent> {
// /**
// * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
// */
// public int compare(F2SEvent e1, F2SEvent e2) {
// Preconditions.checkNotNull(e1, "Cannot compare null Flume2Storm events");
// Preconditions.checkNotNull(e2, "Cannot compare null Flume2Storm events");
// return ComparisonChain.start().compare(new String(e1.getBody()), new String(e2.getBody())).result();
// }
// }
|
import java.util.SortedSet;
import java.util.TreeSet;
import com.comcast.viper.flume2storm.event.F2SEvent;
import com.comcast.viper.flume2storm.event.F2SEventComparator;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.spout;
/**
* Stores {@link F2SEvent} in memory for test purpose
*/
public class MemoryStorage {
private static MemoryStorage instance = new MemoryStorage();
public static MemoryStorage getInstance() {
return instance;
}
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/event/F2SEvent.java
// public final class F2SEvent implements Serializable {
// private static final long serialVersionUID = -5906404402187281472L;
// private final Map<String, String> headers;
// private final byte[] body;
//
// F2SEvent() {
// headers = ImmutableMap.of();
// body = new byte[0];
// }
//
// /**
// * Constructor to build Flume2Storm events
// *
// * @param headers
// * See {@link #getHeaders()}. If null, the headers is an empty
// * immutable map.
// * @param body
// * See {@link #getBody()}. If null, the payload of the event is an
// * empty byte array.
// */
// public F2SEvent(Map<String, String> headers, byte[] body) {
// if (headers == null) {
// this.headers = ImmutableMap.of();
// } else {
// this.headers = ImmutableMap.copyOf(headers);
// }
// if (body == null) {
// this.body = ArrayUtils.EMPTY_BYTE_ARRAY;
// } else {
// this.body = ArrayUtils.clone(body);
// }
// }
//
// /**
// * Copy constructor
// *
// * @param event
// * Another Flume2Storm event
// */
// public F2SEvent(F2SEvent event) {
// headers = ImmutableMap.copyOf(event.getHeaders());
// body = event.body;
// }
//
// /**
// * @return The event body
// */
// public byte[] getBody() {
// return body;
// }
//
// /**
// * @return The headers (key/value pairs) associated to the event
// */
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// /**
// * @param key
// * A header name (i.e. key)
// * @return The value of the header, or null if it does not exist
// */
// public String getHeader(String key) {
// return headers.get(key);
// }
//
// /**
// * @see java.lang.Object#hashCode()
// */
// @Override
// public int hashCode() {
// return new HashCodeBuilder().append(headers).append(body).hashCode();
// }
//
// /**
// * @see java.lang.Object#equals(java.lang.Object)
// */
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// F2SEvent other = (F2SEvent) obj;
// return new EqualsBuilder().append(this.headers, other.headers)
// .append(this.body, other.body).isEquals();
// }
//
// /**
// * @see java.lang.Object#toString()
// */
// @Override
// public String toString() {
// ToStringBuilder toStringBuilder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("headers",
// headers);
// String bodyStr = StringUtils.toEncodedString(body, F2SEventFactory.DEFAULT_CHARACTER_SET);
// if (StringUtils.isAsciiPrintable(bodyStr)) {
// toStringBuilder.append("body", bodyStr);
// } else {
// toStringBuilder.append(Hex.encodeHexString(body));
// }
// return toStringBuilder.toString();
// }
// }
//
// Path: core/src/main/java/com/comcast/viper/flume2storm/event/F2SEventComparator.java
// public class F2SEventComparator implements Comparator<F2SEvent> {
// /**
// * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
// */
// public int compare(F2SEvent e1, F2SEvent e2) {
// Preconditions.checkNotNull(e1, "Cannot compare null Flume2Storm events");
// Preconditions.checkNotNull(e2, "Cannot compare null Flume2Storm events");
// return ComparisonChain.start().compare(new String(e1.getBody()), new String(e2.getBody())).result();
// }
// }
// Path: flume-spout/src/test/java/com/comcast/viper/flume2storm/spout/MemoryStorage.java
import java.util.SortedSet;
import java.util.TreeSet;
import com.comcast.viper.flume2storm.event.F2SEvent;
import com.comcast.viper.flume2storm.event.F2SEventComparator;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.spout;
/**
* Stores {@link F2SEvent} in memory for test purpose
*/
public class MemoryStorage {
private static MemoryStorage instance = new MemoryStorage();
public static MemoryStorage getInstance() {
return instance;
}
|
protected SortedSet<F2SEvent> receivedEvents;
|
Comcast/flume2storm
|
flume-spout/src/test/java/com/comcast/viper/flume2storm/spout/MemoryStorage.java
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/event/F2SEvent.java
// public final class F2SEvent implements Serializable {
// private static final long serialVersionUID = -5906404402187281472L;
// private final Map<String, String> headers;
// private final byte[] body;
//
// F2SEvent() {
// headers = ImmutableMap.of();
// body = new byte[0];
// }
//
// /**
// * Constructor to build Flume2Storm events
// *
// * @param headers
// * See {@link #getHeaders()}. If null, the headers is an empty
// * immutable map.
// * @param body
// * See {@link #getBody()}. If null, the payload of the event is an
// * empty byte array.
// */
// public F2SEvent(Map<String, String> headers, byte[] body) {
// if (headers == null) {
// this.headers = ImmutableMap.of();
// } else {
// this.headers = ImmutableMap.copyOf(headers);
// }
// if (body == null) {
// this.body = ArrayUtils.EMPTY_BYTE_ARRAY;
// } else {
// this.body = ArrayUtils.clone(body);
// }
// }
//
// /**
// * Copy constructor
// *
// * @param event
// * Another Flume2Storm event
// */
// public F2SEvent(F2SEvent event) {
// headers = ImmutableMap.copyOf(event.getHeaders());
// body = event.body;
// }
//
// /**
// * @return The event body
// */
// public byte[] getBody() {
// return body;
// }
//
// /**
// * @return The headers (key/value pairs) associated to the event
// */
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// /**
// * @param key
// * A header name (i.e. key)
// * @return The value of the header, or null if it does not exist
// */
// public String getHeader(String key) {
// return headers.get(key);
// }
//
// /**
// * @see java.lang.Object#hashCode()
// */
// @Override
// public int hashCode() {
// return new HashCodeBuilder().append(headers).append(body).hashCode();
// }
//
// /**
// * @see java.lang.Object#equals(java.lang.Object)
// */
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// F2SEvent other = (F2SEvent) obj;
// return new EqualsBuilder().append(this.headers, other.headers)
// .append(this.body, other.body).isEquals();
// }
//
// /**
// * @see java.lang.Object#toString()
// */
// @Override
// public String toString() {
// ToStringBuilder toStringBuilder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("headers",
// headers);
// String bodyStr = StringUtils.toEncodedString(body, F2SEventFactory.DEFAULT_CHARACTER_SET);
// if (StringUtils.isAsciiPrintable(bodyStr)) {
// toStringBuilder.append("body", bodyStr);
// } else {
// toStringBuilder.append(Hex.encodeHexString(body));
// }
// return toStringBuilder.toString();
// }
// }
//
// Path: core/src/main/java/com/comcast/viper/flume2storm/event/F2SEventComparator.java
// public class F2SEventComparator implements Comparator<F2SEvent> {
// /**
// * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
// */
// public int compare(F2SEvent e1, F2SEvent e2) {
// Preconditions.checkNotNull(e1, "Cannot compare null Flume2Storm events");
// Preconditions.checkNotNull(e2, "Cannot compare null Flume2Storm events");
// return ComparisonChain.start().compare(new String(e1.getBody()), new String(e2.getBody())).result();
// }
// }
|
import java.util.SortedSet;
import java.util.TreeSet;
import com.comcast.viper.flume2storm.event.F2SEvent;
import com.comcast.viper.flume2storm.event.F2SEventComparator;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.spout;
/**
* Stores {@link F2SEvent} in memory for test purpose
*/
public class MemoryStorage {
private static MemoryStorage instance = new MemoryStorage();
public static MemoryStorage getInstance() {
return instance;
}
protected SortedSet<F2SEvent> receivedEvents;
public MemoryStorage() {
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/event/F2SEvent.java
// public final class F2SEvent implements Serializable {
// private static final long serialVersionUID = -5906404402187281472L;
// private final Map<String, String> headers;
// private final byte[] body;
//
// F2SEvent() {
// headers = ImmutableMap.of();
// body = new byte[0];
// }
//
// /**
// * Constructor to build Flume2Storm events
// *
// * @param headers
// * See {@link #getHeaders()}. If null, the headers is an empty
// * immutable map.
// * @param body
// * See {@link #getBody()}. If null, the payload of the event is an
// * empty byte array.
// */
// public F2SEvent(Map<String, String> headers, byte[] body) {
// if (headers == null) {
// this.headers = ImmutableMap.of();
// } else {
// this.headers = ImmutableMap.copyOf(headers);
// }
// if (body == null) {
// this.body = ArrayUtils.EMPTY_BYTE_ARRAY;
// } else {
// this.body = ArrayUtils.clone(body);
// }
// }
//
// /**
// * Copy constructor
// *
// * @param event
// * Another Flume2Storm event
// */
// public F2SEvent(F2SEvent event) {
// headers = ImmutableMap.copyOf(event.getHeaders());
// body = event.body;
// }
//
// /**
// * @return The event body
// */
// public byte[] getBody() {
// return body;
// }
//
// /**
// * @return The headers (key/value pairs) associated to the event
// */
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// /**
// * @param key
// * A header name (i.e. key)
// * @return The value of the header, or null if it does not exist
// */
// public String getHeader(String key) {
// return headers.get(key);
// }
//
// /**
// * @see java.lang.Object#hashCode()
// */
// @Override
// public int hashCode() {
// return new HashCodeBuilder().append(headers).append(body).hashCode();
// }
//
// /**
// * @see java.lang.Object#equals(java.lang.Object)
// */
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// F2SEvent other = (F2SEvent) obj;
// return new EqualsBuilder().append(this.headers, other.headers)
// .append(this.body, other.body).isEquals();
// }
//
// /**
// * @see java.lang.Object#toString()
// */
// @Override
// public String toString() {
// ToStringBuilder toStringBuilder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("headers",
// headers);
// String bodyStr = StringUtils.toEncodedString(body, F2SEventFactory.DEFAULT_CHARACTER_SET);
// if (StringUtils.isAsciiPrintable(bodyStr)) {
// toStringBuilder.append("body", bodyStr);
// } else {
// toStringBuilder.append(Hex.encodeHexString(body));
// }
// return toStringBuilder.toString();
// }
// }
//
// Path: core/src/main/java/com/comcast/viper/flume2storm/event/F2SEventComparator.java
// public class F2SEventComparator implements Comparator<F2SEvent> {
// /**
// * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
// */
// public int compare(F2SEvent e1, F2SEvent e2) {
// Preconditions.checkNotNull(e1, "Cannot compare null Flume2Storm events");
// Preconditions.checkNotNull(e2, "Cannot compare null Flume2Storm events");
// return ComparisonChain.start().compare(new String(e1.getBody()), new String(e2.getBody())).result();
// }
// }
// Path: flume-spout/src/test/java/com/comcast/viper/flume2storm/spout/MemoryStorage.java
import java.util.SortedSet;
import java.util.TreeSet;
import com.comcast.viper.flume2storm.event.F2SEvent;
import com.comcast.viper.flume2storm.event.F2SEventComparator;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.spout;
/**
* Stores {@link F2SEvent} in memory for test purpose
*/
public class MemoryStorage {
private static MemoryStorage instance = new MemoryStorage();
public static MemoryStorage getInstance() {
return instance;
}
protected SortedSet<F2SEvent> receivedEvents;
public MemoryStorage() {
|
receivedEvents = new TreeSet<F2SEvent>(new F2SEventComparator());
|
Comcast/flume2storm
|
static-location-service/src/main/java/com/comcast/viper/flume2storm/location/StaticLocationServiceFactory.java
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
|
import org.apache.commons.configuration.Configuration;
import com.comcast.viper.flume2storm.F2SConfigurationException;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.location;
/**
* Factory class for {@link StaticLocationService}
*
* @param <SP>
* The actual class for the ServiceProvider
*/
public class StaticLocationServiceFactory<SP extends ServiceProvider<?>> implements LocationServiceFactory<SP> {
/** Configuration attribute base name */
public static final String CONFIG_BASE_NAME = "static.location.service";
/**
* @see com.comcast.viper.flume2storm.location.LocationServiceFactory#create(org.apache.commons.configuration.Configuration,
* com.comcast.viper.flume2storm.location.ServiceProviderSerialization)
*/
@Override
public LocationService<SP> create(Configuration config, ServiceProviderSerialization<SP> serviceProviderSerialization)
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
// Path: static-location-service/src/main/java/com/comcast/viper/flume2storm/location/StaticLocationServiceFactory.java
import org.apache.commons.configuration.Configuration;
import com.comcast.viper.flume2storm.F2SConfigurationException;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.location;
/**
* Factory class for {@link StaticLocationService}
*
* @param <SP>
* The actual class for the ServiceProvider
*/
public class StaticLocationServiceFactory<SP extends ServiceProvider<?>> implements LocationServiceFactory<SP> {
/** Configuration attribute base name */
public static final String CONFIG_BASE_NAME = "static.location.service";
/**
* @see com.comcast.viper.flume2storm.location.LocationServiceFactory#create(org.apache.commons.configuration.Configuration,
* com.comcast.viper.flume2storm.location.ServiceProviderSerialization)
*/
@Override
public LocationService<SP> create(Configuration config, ServiceProviderSerialization<SP> serviceProviderSerialization)
|
throws F2SConfigurationException {
|
Comcast/flume2storm
|
dynamic-location-service/src/test/java/com/comcast/viper/flume2storm/location/DynamicLocationServiceConfigurationTest.java
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
|
import junit.framework.Assert;
import org.apache.commons.configuration.BaseConfiguration;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang.StringUtils;
import org.junit.Ignore;
import org.junit.Test;
import com.comcast.viper.flume2storm.F2SConfigurationException;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.location;
/**
* Unit test for Dynamic Location Service Configuration
*/
public class DynamicLocationServiceConfigurationTest {
/**
* Test building {@link DynamicLocationServiceConfiguration} from a
* {@link Configuration} object
*
* @throws F2SConfigurationException
*/
@Ignore
@Test
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
// Path: dynamic-location-service/src/test/java/com/comcast/viper/flume2storm/location/DynamicLocationServiceConfigurationTest.java
import junit.framework.Assert;
import org.apache.commons.configuration.BaseConfiguration;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang.StringUtils;
import org.junit.Ignore;
import org.junit.Test;
import com.comcast.viper.flume2storm.F2SConfigurationException;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.location;
/**
* Unit test for Dynamic Location Service Configuration
*/
public class DynamicLocationServiceConfigurationTest {
/**
* Test building {@link DynamicLocationServiceConfiguration} from a
* {@link Configuration} object
*
* @throws F2SConfigurationException
*/
@Ignore
@Test
|
public void testFromConfiguration() throws F2SConfigurationException {
|
Comcast/flume2storm
|
kryonet-flume2storm/src/test/java/com/comcast/viper/flume2storm/connection/KryoNetParametersTest.java
|
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestUtils.java
// public class TestUtils {
// private static final int DEFAULT_RETRY_TIMEOUT = 100;
// private static Random random = new Random();
//
// /**
// * @return An ephemeral port available for test usage
// */
// public static int getAvailablePort() {
// try (ServerSocket s = new ServerSocket(0)) {
// return s.getLocalPort();
// } catch (Exception e) {
// throw new AssertionError("Failed to find available port", e);
// }
// }
//
// /**
// * @param n
// * Max int allowed
// * @return A random number between 1 and n
// */
// public static final int getRandomPositiveInt(int n) {
// Preconditions.checkArgument(n > 1, "Cannot generate this kind of number!");
// return random.nextInt(n - 1) + 1;
// }
//
// /**
// * Waits that the condition is fulfilled - careful, this may never return!
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static void waitFor(final TestCondition condition) throws InterruptedException {
// waitFor(condition, Integer.MAX_VALUE);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs) throws InterruptedException {
// return waitFor(condition, maxWaitInMs, DEFAULT_RETRY_TIMEOUT);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @param retryTimeout
// * The number of milliseconds to wait before retry the test
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs, final int retryTimeout)
// throws InterruptedException {
// final long t0 = System.currentTimeMillis();
// while (!condition.evaluate() && (System.currentTimeMillis() - t0) < maxWaitInMs) {
// Thread.sleep(retryTimeout);
// }
// if (condition.evaluate()) {
// return true;
// }
// throw new AssertionError("TestCondition did not validate in time");
// }
// }
|
import junit.framework.Assert;
import org.apache.commons.configuration.BaseConfiguration;
import org.apache.commons.configuration.Configuration;
import org.junit.Test;
import com.comcast.viper.flume2storm.utility.test.TestUtils;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.connection;
public class KryoNetParametersTest {
@Test
public void testEmpty() throws Exception {
KryoNetParameters params = KryoNetParameters.from(new BaseConfiguration());
Assert.assertEquals(KryoNetParameters.CONNECTION_TIMEOUT_DEFAULT, params.getConnectionTimeout());
Assert.assertEquals(KryoNetParameters.RETRY_SLEEP_DELAY_DEFAULT, params.getRetrySleepDelay());
Assert.assertEquals(KryoNetParameters.RECONNECTION_DELAY_DEFAULT, params.getReconnectionDelay());
Assert.assertEquals(KryoNetParameters.TERMINATION_TO_DEFAULT, params.getTerminationTimeout());
}
@Test
public void testFromConfiguration() throws Exception {
|
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestUtils.java
// public class TestUtils {
// private static final int DEFAULT_RETRY_TIMEOUT = 100;
// private static Random random = new Random();
//
// /**
// * @return An ephemeral port available for test usage
// */
// public static int getAvailablePort() {
// try (ServerSocket s = new ServerSocket(0)) {
// return s.getLocalPort();
// } catch (Exception e) {
// throw new AssertionError("Failed to find available port", e);
// }
// }
//
// /**
// * @param n
// * Max int allowed
// * @return A random number between 1 and n
// */
// public static final int getRandomPositiveInt(int n) {
// Preconditions.checkArgument(n > 1, "Cannot generate this kind of number!");
// return random.nextInt(n - 1) + 1;
// }
//
// /**
// * Waits that the condition is fulfilled - careful, this may never return!
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static void waitFor(final TestCondition condition) throws InterruptedException {
// waitFor(condition, Integer.MAX_VALUE);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs) throws InterruptedException {
// return waitFor(condition, maxWaitInMs, DEFAULT_RETRY_TIMEOUT);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @param retryTimeout
// * The number of milliseconds to wait before retry the test
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs, final int retryTimeout)
// throws InterruptedException {
// final long t0 = System.currentTimeMillis();
// while (!condition.evaluate() && (System.currentTimeMillis() - t0) < maxWaitInMs) {
// Thread.sleep(retryTimeout);
// }
// if (condition.evaluate()) {
// return true;
// }
// throw new AssertionError("TestCondition did not validate in time");
// }
// }
// Path: kryonet-flume2storm/src/test/java/com/comcast/viper/flume2storm/connection/KryoNetParametersTest.java
import junit.framework.Assert;
import org.apache.commons.configuration.BaseConfiguration;
import org.apache.commons.configuration.Configuration;
import org.junit.Test;
import com.comcast.viper.flume2storm.utility.test.TestUtils;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.connection;
public class KryoNetParametersTest {
@Test
public void testEmpty() throws Exception {
KryoNetParameters params = KryoNetParameters.from(new BaseConfiguration());
Assert.assertEquals(KryoNetParameters.CONNECTION_TIMEOUT_DEFAULT, params.getConnectionTimeout());
Assert.assertEquals(KryoNetParameters.RETRY_SLEEP_DELAY_DEFAULT, params.getRetrySleepDelay());
Assert.assertEquals(KryoNetParameters.RECONNECTION_DELAY_DEFAULT, params.getReconnectionDelay());
Assert.assertEquals(KryoNetParameters.TERMINATION_TO_DEFAULT, params.getTerminationTimeout());
}
@Test
public void testFromConfiguration() throws Exception {
|
int connectionTo = TestUtils.getRandomPositiveInt(100000);
|
Comcast/flume2storm
|
storm-sink/src/test/java/com/comcast/viper/flume2storm/sink/EventConverterTest.java
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/event/F2SEvent.java
// public final class F2SEvent implements Serializable {
// private static final long serialVersionUID = -5906404402187281472L;
// private final Map<String, String> headers;
// private final byte[] body;
//
// F2SEvent() {
// headers = ImmutableMap.of();
// body = new byte[0];
// }
//
// /**
// * Constructor to build Flume2Storm events
// *
// * @param headers
// * See {@link #getHeaders()}. If null, the headers is an empty
// * immutable map.
// * @param body
// * See {@link #getBody()}. If null, the payload of the event is an
// * empty byte array.
// */
// public F2SEvent(Map<String, String> headers, byte[] body) {
// if (headers == null) {
// this.headers = ImmutableMap.of();
// } else {
// this.headers = ImmutableMap.copyOf(headers);
// }
// if (body == null) {
// this.body = ArrayUtils.EMPTY_BYTE_ARRAY;
// } else {
// this.body = ArrayUtils.clone(body);
// }
// }
//
// /**
// * Copy constructor
// *
// * @param event
// * Another Flume2Storm event
// */
// public F2SEvent(F2SEvent event) {
// headers = ImmutableMap.copyOf(event.getHeaders());
// body = event.body;
// }
//
// /**
// * @return The event body
// */
// public byte[] getBody() {
// return body;
// }
//
// /**
// * @return The headers (key/value pairs) associated to the event
// */
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// /**
// * @param key
// * A header name (i.e. key)
// * @return The value of the header, or null if it does not exist
// */
// public String getHeader(String key) {
// return headers.get(key);
// }
//
// /**
// * @see java.lang.Object#hashCode()
// */
// @Override
// public int hashCode() {
// return new HashCodeBuilder().append(headers).append(body).hashCode();
// }
//
// /**
// * @see java.lang.Object#equals(java.lang.Object)
// */
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// F2SEvent other = (F2SEvent) obj;
// return new EqualsBuilder().append(this.headers, other.headers)
// .append(this.body, other.body).isEquals();
// }
//
// /**
// * @see java.lang.Object#toString()
// */
// @Override
// public String toString() {
// ToStringBuilder toStringBuilder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("headers",
// headers);
// String bodyStr = StringUtils.toEncodedString(body, F2SEventFactory.DEFAULT_CHARACTER_SET);
// if (StringUtils.isAsciiPrintable(bodyStr)) {
// toStringBuilder.append("body", bodyStr);
// } else {
// toStringBuilder.append(Hex.encodeHexString(body));
// }
// return toStringBuilder.toString();
// }
// }
|
import static org.assertj.core.api.Assertions.assertThat;
import org.apache.flume.Event;
import org.apache.flume.event.EventBuilder;
import org.joda.time.Instant;
import org.junit.Test;
import com.comcast.viper.flume2storm.event.F2SEvent;
import com.google.common.collect.ImmutableMap;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.sink;
/**
* Tests for {@link EventConverter}
*/
public class EventConverterTest {
/**
* Test conversion of a complete event
*/
@Test
public void testCompleteEvent() {
EventConverter converter = new EventConverter();
Event event = EventBuilder.withBody("whatever".getBytes(), ImmutableMap.of("timestamp", Instant.now().toString()));
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/event/F2SEvent.java
// public final class F2SEvent implements Serializable {
// private static final long serialVersionUID = -5906404402187281472L;
// private final Map<String, String> headers;
// private final byte[] body;
//
// F2SEvent() {
// headers = ImmutableMap.of();
// body = new byte[0];
// }
//
// /**
// * Constructor to build Flume2Storm events
// *
// * @param headers
// * See {@link #getHeaders()}. If null, the headers is an empty
// * immutable map.
// * @param body
// * See {@link #getBody()}. If null, the payload of the event is an
// * empty byte array.
// */
// public F2SEvent(Map<String, String> headers, byte[] body) {
// if (headers == null) {
// this.headers = ImmutableMap.of();
// } else {
// this.headers = ImmutableMap.copyOf(headers);
// }
// if (body == null) {
// this.body = ArrayUtils.EMPTY_BYTE_ARRAY;
// } else {
// this.body = ArrayUtils.clone(body);
// }
// }
//
// /**
// * Copy constructor
// *
// * @param event
// * Another Flume2Storm event
// */
// public F2SEvent(F2SEvent event) {
// headers = ImmutableMap.copyOf(event.getHeaders());
// body = event.body;
// }
//
// /**
// * @return The event body
// */
// public byte[] getBody() {
// return body;
// }
//
// /**
// * @return The headers (key/value pairs) associated to the event
// */
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// /**
// * @param key
// * A header name (i.e. key)
// * @return The value of the header, or null if it does not exist
// */
// public String getHeader(String key) {
// return headers.get(key);
// }
//
// /**
// * @see java.lang.Object#hashCode()
// */
// @Override
// public int hashCode() {
// return new HashCodeBuilder().append(headers).append(body).hashCode();
// }
//
// /**
// * @see java.lang.Object#equals(java.lang.Object)
// */
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// F2SEvent other = (F2SEvent) obj;
// return new EqualsBuilder().append(this.headers, other.headers)
// .append(this.body, other.body).isEquals();
// }
//
// /**
// * @see java.lang.Object#toString()
// */
// @Override
// public String toString() {
// ToStringBuilder toStringBuilder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("headers",
// headers);
// String bodyStr = StringUtils.toEncodedString(body, F2SEventFactory.DEFAULT_CHARACTER_SET);
// if (StringUtils.isAsciiPrintable(bodyStr)) {
// toStringBuilder.append("body", bodyStr);
// } else {
// toStringBuilder.append(Hex.encodeHexString(body));
// }
// return toStringBuilder.toString();
// }
// }
// Path: storm-sink/src/test/java/com/comcast/viper/flume2storm/sink/EventConverterTest.java
import static org.assertj.core.api.Assertions.assertThat;
import org.apache.flume.Event;
import org.apache.flume.event.EventBuilder;
import org.joda.time.Instant;
import org.junit.Test;
import com.comcast.viper.flume2storm.event.F2SEvent;
import com.google.common.collect.ImmutableMap;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.sink;
/**
* Tests for {@link EventConverter}
*/
public class EventConverterTest {
/**
* Test conversion of a complete event
*/
@Test
public void testCompleteEvent() {
EventConverter converter = new EventConverter();
Event event = EventBuilder.withBody("whatever".getBytes(), ImmutableMap.of("timestamp", Instant.now().toString()));
|
F2SEvent f2sEvent = converter.convert(event);
|
Comcast/flume2storm
|
core/src/main/java/com/comcast/viper/flume2storm/connection/sender/EventSender.java
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/connection/parameters/ConnectionParameters.java
// public interface ConnectionParameters {
// /**
// * @return A unique identifier of the associated {@link EventSender} /
// * {@link ServiceProvider} (hostname:port for instance)
// *
// */
// String getId();
// }
//
// Path: core/src/main/java/com/comcast/viper/flume2storm/event/F2SEvent.java
// public final class F2SEvent implements Serializable {
// private static final long serialVersionUID = -5906404402187281472L;
// private final Map<String, String> headers;
// private final byte[] body;
//
// F2SEvent() {
// headers = ImmutableMap.of();
// body = new byte[0];
// }
//
// /**
// * Constructor to build Flume2Storm events
// *
// * @param headers
// * See {@link #getHeaders()}. If null, the headers is an empty
// * immutable map.
// * @param body
// * See {@link #getBody()}. If null, the payload of the event is an
// * empty byte array.
// */
// public F2SEvent(Map<String, String> headers, byte[] body) {
// if (headers == null) {
// this.headers = ImmutableMap.of();
// } else {
// this.headers = ImmutableMap.copyOf(headers);
// }
// if (body == null) {
// this.body = ArrayUtils.EMPTY_BYTE_ARRAY;
// } else {
// this.body = ArrayUtils.clone(body);
// }
// }
//
// /**
// * Copy constructor
// *
// * @param event
// * Another Flume2Storm event
// */
// public F2SEvent(F2SEvent event) {
// headers = ImmutableMap.copyOf(event.getHeaders());
// body = event.body;
// }
//
// /**
// * @return The event body
// */
// public byte[] getBody() {
// return body;
// }
//
// /**
// * @return The headers (key/value pairs) associated to the event
// */
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// /**
// * @param key
// * A header name (i.e. key)
// * @return The value of the header, or null if it does not exist
// */
// public String getHeader(String key) {
// return headers.get(key);
// }
//
// /**
// * @see java.lang.Object#hashCode()
// */
// @Override
// public int hashCode() {
// return new HashCodeBuilder().append(headers).append(body).hashCode();
// }
//
// /**
// * @see java.lang.Object#equals(java.lang.Object)
// */
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// F2SEvent other = (F2SEvent) obj;
// return new EqualsBuilder().append(this.headers, other.headers)
// .append(this.body, other.body).isEquals();
// }
//
// /**
// * @see java.lang.Object#toString()
// */
// @Override
// public String toString() {
// ToStringBuilder toStringBuilder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("headers",
// headers);
// String bodyStr = StringUtils.toEncodedString(body, F2SEventFactory.DEFAULT_CHARACTER_SET);
// if (StringUtils.isAsciiPrintable(bodyStr)) {
// toStringBuilder.append("body", bodyStr);
// } else {
// toStringBuilder.append(Hex.encodeHexString(body));
// }
// return toStringBuilder.toString();
// }
// }
//
// Path: core/src/main/java/com/comcast/viper/flume2storm/location/ServiceProvider.java
// public interface ServiceProvider<CP extends ConnectionParameters> extends Serializable, Comparable<ServiceProvider<CP>> {
// /**
// * @return The connection parameters for this service provider
// */
// CP getConnectionParameters();
// }
|
import java.util.List;
import com.comcast.viper.flume2storm.connection.parameters.ConnectionParameters;
import com.comcast.viper.flume2storm.event.F2SEvent;
import com.comcast.viper.flume2storm.location.ServiceProvider;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.connection.sender;
/**
* The server-side of the Flume2Storm connector, which sends the Flume2Storm
* events to the Event Receptor.<br />
* This is also an instance of a service provider, which is what gets registered
* to the location service.
*
* @param <CP>
* The Connection Parameters class
*/
public interface EventSender<CP extends ConnectionParameters> extends ServiceProvider<CP> {
/**
* @return True if the {@link EventSender} started successfully, false
* otherwise
*/
boolean start();
/**
* @return True if the {@link EventSender} stopped successfully, false
* otherwise
*/
boolean stop();
/**
* @return Statistics related to this {@link EventSender}
*/
EventSenderStatsMBean getStats();
/**
* @param events
* The events to send
* @return The number of events successfully sent
*/
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/connection/parameters/ConnectionParameters.java
// public interface ConnectionParameters {
// /**
// * @return A unique identifier of the associated {@link EventSender} /
// * {@link ServiceProvider} (hostname:port for instance)
// *
// */
// String getId();
// }
//
// Path: core/src/main/java/com/comcast/viper/flume2storm/event/F2SEvent.java
// public final class F2SEvent implements Serializable {
// private static final long serialVersionUID = -5906404402187281472L;
// private final Map<String, String> headers;
// private final byte[] body;
//
// F2SEvent() {
// headers = ImmutableMap.of();
// body = new byte[0];
// }
//
// /**
// * Constructor to build Flume2Storm events
// *
// * @param headers
// * See {@link #getHeaders()}. If null, the headers is an empty
// * immutable map.
// * @param body
// * See {@link #getBody()}. If null, the payload of the event is an
// * empty byte array.
// */
// public F2SEvent(Map<String, String> headers, byte[] body) {
// if (headers == null) {
// this.headers = ImmutableMap.of();
// } else {
// this.headers = ImmutableMap.copyOf(headers);
// }
// if (body == null) {
// this.body = ArrayUtils.EMPTY_BYTE_ARRAY;
// } else {
// this.body = ArrayUtils.clone(body);
// }
// }
//
// /**
// * Copy constructor
// *
// * @param event
// * Another Flume2Storm event
// */
// public F2SEvent(F2SEvent event) {
// headers = ImmutableMap.copyOf(event.getHeaders());
// body = event.body;
// }
//
// /**
// * @return The event body
// */
// public byte[] getBody() {
// return body;
// }
//
// /**
// * @return The headers (key/value pairs) associated to the event
// */
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// /**
// * @param key
// * A header name (i.e. key)
// * @return The value of the header, or null if it does not exist
// */
// public String getHeader(String key) {
// return headers.get(key);
// }
//
// /**
// * @see java.lang.Object#hashCode()
// */
// @Override
// public int hashCode() {
// return new HashCodeBuilder().append(headers).append(body).hashCode();
// }
//
// /**
// * @see java.lang.Object#equals(java.lang.Object)
// */
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// F2SEvent other = (F2SEvent) obj;
// return new EqualsBuilder().append(this.headers, other.headers)
// .append(this.body, other.body).isEquals();
// }
//
// /**
// * @see java.lang.Object#toString()
// */
// @Override
// public String toString() {
// ToStringBuilder toStringBuilder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("headers",
// headers);
// String bodyStr = StringUtils.toEncodedString(body, F2SEventFactory.DEFAULT_CHARACTER_SET);
// if (StringUtils.isAsciiPrintable(bodyStr)) {
// toStringBuilder.append("body", bodyStr);
// } else {
// toStringBuilder.append(Hex.encodeHexString(body));
// }
// return toStringBuilder.toString();
// }
// }
//
// Path: core/src/main/java/com/comcast/viper/flume2storm/location/ServiceProvider.java
// public interface ServiceProvider<CP extends ConnectionParameters> extends Serializable, Comparable<ServiceProvider<CP>> {
// /**
// * @return The connection parameters for this service provider
// */
// CP getConnectionParameters();
// }
// Path: core/src/main/java/com/comcast/viper/flume2storm/connection/sender/EventSender.java
import java.util.List;
import com.comcast.viper.flume2storm.connection.parameters.ConnectionParameters;
import com.comcast.viper.flume2storm.event.F2SEvent;
import com.comcast.viper.flume2storm.location.ServiceProvider;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.connection.sender;
/**
* The server-side of the Flume2Storm connector, which sends the Flume2Storm
* events to the Event Receptor.<br />
* This is also an instance of a service provider, which is what gets registered
* to the location service.
*
* @param <CP>
* The Connection Parameters class
*/
public interface EventSender<CP extends ConnectionParameters> extends ServiceProvider<CP> {
/**
* @return True if the {@link EventSender} started successfully, false
* otherwise
*/
boolean start();
/**
* @return True if the {@link EventSender} stopped successfully, false
* otherwise
*/
boolean stop();
/**
* @return Statistics related to this {@link EventSender}
*/
EventSenderStatsMBean getStats();
/**
* @param events
* The events to send
* @return The number of events successfully sent
*/
|
int send(List<F2SEvent> events);
|
Comcast/flume2storm
|
dynamic-location-service/src/test/java/com/comcast/viper/flume2storm/zookeeper/ZkClientTestUtils.java
|
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestCondition.java
// public interface TestCondition {
// /**
// * @return True when the condition is fulfilled, false otherwise
// */
// boolean evaluate();
// }
//
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestUtils.java
// public class TestUtils {
// private static final int DEFAULT_RETRY_TIMEOUT = 100;
// private static Random random = new Random();
//
// /**
// * @return An ephemeral port available for test usage
// */
// public static int getAvailablePort() {
// try (ServerSocket s = new ServerSocket(0)) {
// return s.getLocalPort();
// } catch (Exception e) {
// throw new AssertionError("Failed to find available port", e);
// }
// }
//
// /**
// * @param n
// * Max int allowed
// * @return A random number between 1 and n
// */
// public static final int getRandomPositiveInt(int n) {
// Preconditions.checkArgument(n > 1, "Cannot generate this kind of number!");
// return random.nextInt(n - 1) + 1;
// }
//
// /**
// * Waits that the condition is fulfilled - careful, this may never return!
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static void waitFor(final TestCondition condition) throws InterruptedException {
// waitFor(condition, Integer.MAX_VALUE);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs) throws InterruptedException {
// return waitFor(condition, maxWaitInMs, DEFAULT_RETRY_TIMEOUT);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @param retryTimeout
// * The number of milliseconds to wait before retry the test
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs, final int retryTimeout)
// throws InterruptedException {
// final long t0 = System.currentTimeMillis();
// while (!condition.evaluate() && (System.currentTimeMillis() - t0) < maxWaitInMs) {
// Thread.sleep(retryTimeout);
// }
// if (condition.evaluate()) {
// return true;
// }
// throw new AssertionError("TestCondition did not validate in time");
// }
// }
|
import junit.framework.Assert;
import com.comcast.viper.flume2storm.utility.test.TestCondition;
import com.comcast.viper.flume2storm.utility.test.TestUtils;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.zookeeper;
/**
*
*/
public class ZkClientTestUtils extends ZkTestUtils {
public static final int TEST_RECONNECTION_DELAY = 2000;
public static ZkClientConfiguration getZkClientConfig(ZkTestServer zkServer) {
final ZkClientConfiguration result = new ZkClientConfiguration();
result.setConnectionStr(zkServer.getConnectString());
result.setReconnectionDelay(TEST_RECONNECTION_DELAY);
return result;
}
protected static ZkClient zkClient;
|
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestCondition.java
// public interface TestCondition {
// /**
// * @return True when the condition is fulfilled, false otherwise
// */
// boolean evaluate();
// }
//
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestUtils.java
// public class TestUtils {
// private static final int DEFAULT_RETRY_TIMEOUT = 100;
// private static Random random = new Random();
//
// /**
// * @return An ephemeral port available for test usage
// */
// public static int getAvailablePort() {
// try (ServerSocket s = new ServerSocket(0)) {
// return s.getLocalPort();
// } catch (Exception e) {
// throw new AssertionError("Failed to find available port", e);
// }
// }
//
// /**
// * @param n
// * Max int allowed
// * @return A random number between 1 and n
// */
// public static final int getRandomPositiveInt(int n) {
// Preconditions.checkArgument(n > 1, "Cannot generate this kind of number!");
// return random.nextInt(n - 1) + 1;
// }
//
// /**
// * Waits that the condition is fulfilled - careful, this may never return!
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static void waitFor(final TestCondition condition) throws InterruptedException {
// waitFor(condition, Integer.MAX_VALUE);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs) throws InterruptedException {
// return waitFor(condition, maxWaitInMs, DEFAULT_RETRY_TIMEOUT);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @param retryTimeout
// * The number of milliseconds to wait before retry the test
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs, final int retryTimeout)
// throws InterruptedException {
// final long t0 = System.currentTimeMillis();
// while (!condition.evaluate() && (System.currentTimeMillis() - t0) < maxWaitInMs) {
// Thread.sleep(retryTimeout);
// }
// if (condition.evaluate()) {
// return true;
// }
// throw new AssertionError("TestCondition did not validate in time");
// }
// }
// Path: dynamic-location-service/src/test/java/com/comcast/viper/flume2storm/zookeeper/ZkClientTestUtils.java
import junit.framework.Assert;
import com.comcast.viper.flume2storm.utility.test.TestCondition;
import com.comcast.viper.flume2storm.utility.test.TestUtils;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.zookeeper;
/**
*
*/
public class ZkClientTestUtils extends ZkTestUtils {
public static final int TEST_RECONNECTION_DELAY = 2000;
public static ZkClientConfiguration getZkClientConfig(ZkTestServer zkServer) {
final ZkClientConfiguration result = new ZkClientConfiguration();
result.setConnectionStr(zkServer.getConnectString());
result.setReconnectionDelay(TEST_RECONNECTION_DELAY);
return result;
}
protected static ZkClient zkClient;
|
public static class ClientStartedCondition implements TestCondition {
|
Comcast/flume2storm
|
dynamic-location-service/src/test/java/com/comcast/viper/flume2storm/zookeeper/ZkClientTestUtils.java
|
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestCondition.java
// public interface TestCondition {
// /**
// * @return True when the condition is fulfilled, false otherwise
// */
// boolean evaluate();
// }
//
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestUtils.java
// public class TestUtils {
// private static final int DEFAULT_RETRY_TIMEOUT = 100;
// private static Random random = new Random();
//
// /**
// * @return An ephemeral port available for test usage
// */
// public static int getAvailablePort() {
// try (ServerSocket s = new ServerSocket(0)) {
// return s.getLocalPort();
// } catch (Exception e) {
// throw new AssertionError("Failed to find available port", e);
// }
// }
//
// /**
// * @param n
// * Max int allowed
// * @return A random number between 1 and n
// */
// public static final int getRandomPositiveInt(int n) {
// Preconditions.checkArgument(n > 1, "Cannot generate this kind of number!");
// return random.nextInt(n - 1) + 1;
// }
//
// /**
// * Waits that the condition is fulfilled - careful, this may never return!
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static void waitFor(final TestCondition condition) throws InterruptedException {
// waitFor(condition, Integer.MAX_VALUE);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs) throws InterruptedException {
// return waitFor(condition, maxWaitInMs, DEFAULT_RETRY_TIMEOUT);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @param retryTimeout
// * The number of milliseconds to wait before retry the test
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs, final int retryTimeout)
// throws InterruptedException {
// final long t0 = System.currentTimeMillis();
// while (!condition.evaluate() && (System.currentTimeMillis() - t0) < maxWaitInMs) {
// Thread.sleep(retryTimeout);
// }
// if (condition.evaluate()) {
// return true;
// }
// throw new AssertionError("TestCondition did not validate in time");
// }
// }
|
import junit.framework.Assert;
import com.comcast.viper.flume2storm.utility.test.TestCondition;
import com.comcast.viper.flume2storm.utility.test.TestUtils;
|
}
}
public static class ClientDisconnectedCondition implements TestCondition {
private final ZkClient zkClient;
public ClientDisconnectedCondition(final ZkClient zkClient) {
this.zkClient = zkClient;
}
@Override
public boolean evaluate() {
return !zkClient.getState().isConnected();
}
}
public static class ClientSetupCondition implements TestCondition {
private final ZkClient zkClient;
public ClientSetupCondition(final ZkClient zkClient) {
this.zkClient = zkClient;
}
@Override
public boolean evaluate() {
return zkClient.getState().isSetup();
}
}
public static void waitZkClientStarted(final int timeout) throws Exception {
|
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestCondition.java
// public interface TestCondition {
// /**
// * @return True when the condition is fulfilled, false otherwise
// */
// boolean evaluate();
// }
//
// Path: utility/src/main/java/com/comcast/viper/flume2storm/utility/test/TestUtils.java
// public class TestUtils {
// private static final int DEFAULT_RETRY_TIMEOUT = 100;
// private static Random random = new Random();
//
// /**
// * @return An ephemeral port available for test usage
// */
// public static int getAvailablePort() {
// try (ServerSocket s = new ServerSocket(0)) {
// return s.getLocalPort();
// } catch (Exception e) {
// throw new AssertionError("Failed to find available port", e);
// }
// }
//
// /**
// * @param n
// * Max int allowed
// * @return A random number between 1 and n
// */
// public static final int getRandomPositiveInt(int n) {
// Preconditions.checkArgument(n > 1, "Cannot generate this kind of number!");
// return random.nextInt(n - 1) + 1;
// }
//
// /**
// * Waits that the condition is fulfilled - careful, this may never return!
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static void waitFor(final TestCondition condition) throws InterruptedException {
// waitFor(condition, Integer.MAX_VALUE);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs) throws InterruptedException {
// return waitFor(condition, maxWaitInMs, DEFAULT_RETRY_TIMEOUT);
// }
//
// /**
// * Waits that the condition is fulfilled, for up to a specified amount of time
// *
// * @param condition
// * The condition to evaluate. It should be fast to evaluate
// * @param maxWaitInMs
// * The maximum number of milliseconds to wait
// * @param retryTimeout
// * The number of milliseconds to wait before retry the test
// * @return True if the condition is fulfilled in time, false otherwise
// * @throws InterruptedException
// * If wait is interrupted
// */
// public static boolean waitFor(final TestCondition condition, final int maxWaitInMs, final int retryTimeout)
// throws InterruptedException {
// final long t0 = System.currentTimeMillis();
// while (!condition.evaluate() && (System.currentTimeMillis() - t0) < maxWaitInMs) {
// Thread.sleep(retryTimeout);
// }
// if (condition.evaluate()) {
// return true;
// }
// throw new AssertionError("TestCondition did not validate in time");
// }
// }
// Path: dynamic-location-service/src/test/java/com/comcast/viper/flume2storm/zookeeper/ZkClientTestUtils.java
import junit.framework.Assert;
import com.comcast.viper.flume2storm.utility.test.TestCondition;
import com.comcast.viper.flume2storm.utility.test.TestUtils;
}
}
public static class ClientDisconnectedCondition implements TestCondition {
private final ZkClient zkClient;
public ClientDisconnectedCondition(final ZkClient zkClient) {
this.zkClient = zkClient;
}
@Override
public boolean evaluate() {
return !zkClient.getState().isConnected();
}
}
public static class ClientSetupCondition implements TestCondition {
private final ZkClient zkClient;
public ClientSetupCondition(final ZkClient zkClient) {
this.zkClient = zkClient;
}
@Override
public boolean evaluate() {
return zkClient.getState().isSetup();
}
}
public static void waitZkClientStarted(final int timeout) throws Exception {
|
Assert.assertTrue(TestUtils.waitFor(new ClientStartedCondition(zkClient), timeout));
|
Comcast/flume2storm
|
test-impl/src/test/java/com/comcast/viper/flume2storm/location/TestServiceProviderManager.java
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/location/ServiceProviderManager.java
// class ServiceProviderManager<SP extends ServiceProvider<?>> {
// private static final Logger LOG = LoggerFactory.getLogger(ServiceProviderManager.class);
// /** The one listener we'll notify (i.e. the location service) */
// protected final ServiceListener<SP> listener;
// /** Current list of active servers */
// protected final Map<String, SP> serviceProviders;
//
// public ServiceProviderManager(ServiceListener<SP> listener) {
// this.listener = listener;
// serviceProviders = new HashMap<String, SP>();
// }
//
// public synchronized List<SP> get() {
// return ImmutableList.copyOf(serviceProviders.values());
// }
//
// /**
// * Updates the list of service providers, providing add/remove notifications
// * to the listener
// *
// * @param newList
// * The new list of service providers
// */
// public synchronized void set(final Collection<SP> newList) {
// final List<SP> oldList = new ArrayList<SP>(serviceProviders.values());
// final Iterator<SP> it = newList.iterator();
// while (it.hasNext()) {
// final SP current = it.next();
// if (contains(current.getConnectionParameters().getId())) {
// /*
// * The element is in the current and the new list - no modification of
// * the current list, but we remove it from the old list in order to see
// * the ones we did not have already
// */
// oldList.remove(current);
// } else {
// // The element is only in the new list - adding it
// addServiceProvider(current);
// }
// }
// /*
// * At this point, all the elements of the old list that were in the old and
// * the new list have been removed, therefore, the remaining elements have
// * been removed
// */
// for (final SP current : oldList) {
// removeServiceProvider(current);
// }
// }
//
// protected void addServiceProvider(final SP sp) {
// SP previous = serviceProviders.put(sp.getConnectionParameters().getId(), sp);
// if (previous == null) {
// LOG.debug("Adding: {}", sp);
// try {
// listener.onProviderAdded(sp);
// } catch (final Exception e) {
// LOG.warn("Failed to notify listener about the addition of service provider {} : {}", sp,
// e.getLocalizedMessage());
// }
// }
// }
//
// protected void removeServiceProvider(final SP sp) {
// SP removed = serviceProviders.remove(sp.getConnectionParameters().getId());
// if (removed != null) {
// LOG.debug("Removing: {}", sp);
// try {
// listener.onProviderRemoved(sp);
// } catch (final Exception e) {
// LOG.warn("Failed to notify listener about the removal of service provider {} : {}", sp, e.getLocalizedMessage());
// }
// }
// }
//
// /**
// * Adds a service provider, providing a notification to the listener
// *
// * @param sp
// * The new service provider
// */
// public synchronized void add(final SP sp) {
// if (!contains(sp.getConnectionParameters().getId())) {
// addServiceProvider(sp);
// }
// }
//
// /**
// * Adds a collection of service providers, providing a notification to the
// * listener
// *
// * @param serviceProviders
// * The new service providers to add
// */
// public synchronized void addAll(final Collection<SP> serviceProviders) {
// for (SP sp : serviceProviders) {
// add(sp);
// }
// }
//
// /**
// * Removes a service provider, providing a notification to the listener
// *
// * @param sp
// * A service provider
// */
// public synchronized void remove(final SP sp) {
// removeServiceProvider(sp);
// }
//
// /**
// * Removes all the {@link ServiceProvider} from the list
// */
// public synchronized void clear() {
// for (SP sp : serviceProviders.values()) {
// removeServiceProvider(sp);
// }
// }
//
// /**
// * @param spId
// * A service provider
// * @return True if the specified {@link ServiceProvider} is registered, false
// * otherwise
// */
// public synchronized boolean contains(final String spId) {
// return serviceProviders.containsKey(spId);
// }
// }
|
import java.util.ArrayList;
import java.util.List;
import junit.framework.Assert;
import org.junit.Test;
import com.comcast.viper.flume2storm.location.ServiceProviderManager;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.location;
/**
* Unit test for {@link ServiceProviderManager}
*/
public class TestServiceProviderManager {
/**
* TODO better test coverage
*/
@Test
public void testIt() {
SimpleServiceListener listener = new SimpleServiceListener();
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/location/ServiceProviderManager.java
// class ServiceProviderManager<SP extends ServiceProvider<?>> {
// private static final Logger LOG = LoggerFactory.getLogger(ServiceProviderManager.class);
// /** The one listener we'll notify (i.e. the location service) */
// protected final ServiceListener<SP> listener;
// /** Current list of active servers */
// protected final Map<String, SP> serviceProviders;
//
// public ServiceProviderManager(ServiceListener<SP> listener) {
// this.listener = listener;
// serviceProviders = new HashMap<String, SP>();
// }
//
// public synchronized List<SP> get() {
// return ImmutableList.copyOf(serviceProviders.values());
// }
//
// /**
// * Updates the list of service providers, providing add/remove notifications
// * to the listener
// *
// * @param newList
// * The new list of service providers
// */
// public synchronized void set(final Collection<SP> newList) {
// final List<SP> oldList = new ArrayList<SP>(serviceProviders.values());
// final Iterator<SP> it = newList.iterator();
// while (it.hasNext()) {
// final SP current = it.next();
// if (contains(current.getConnectionParameters().getId())) {
// /*
// * The element is in the current and the new list - no modification of
// * the current list, but we remove it from the old list in order to see
// * the ones we did not have already
// */
// oldList.remove(current);
// } else {
// // The element is only in the new list - adding it
// addServiceProvider(current);
// }
// }
// /*
// * At this point, all the elements of the old list that were in the old and
// * the new list have been removed, therefore, the remaining elements have
// * been removed
// */
// for (final SP current : oldList) {
// removeServiceProvider(current);
// }
// }
//
// protected void addServiceProvider(final SP sp) {
// SP previous = serviceProviders.put(sp.getConnectionParameters().getId(), sp);
// if (previous == null) {
// LOG.debug("Adding: {}", sp);
// try {
// listener.onProviderAdded(sp);
// } catch (final Exception e) {
// LOG.warn("Failed to notify listener about the addition of service provider {} : {}", sp,
// e.getLocalizedMessage());
// }
// }
// }
//
// protected void removeServiceProvider(final SP sp) {
// SP removed = serviceProviders.remove(sp.getConnectionParameters().getId());
// if (removed != null) {
// LOG.debug("Removing: {}", sp);
// try {
// listener.onProviderRemoved(sp);
// } catch (final Exception e) {
// LOG.warn("Failed to notify listener about the removal of service provider {} : {}", sp, e.getLocalizedMessage());
// }
// }
// }
//
// /**
// * Adds a service provider, providing a notification to the listener
// *
// * @param sp
// * The new service provider
// */
// public synchronized void add(final SP sp) {
// if (!contains(sp.getConnectionParameters().getId())) {
// addServiceProvider(sp);
// }
// }
//
// /**
// * Adds a collection of service providers, providing a notification to the
// * listener
// *
// * @param serviceProviders
// * The new service providers to add
// */
// public synchronized void addAll(final Collection<SP> serviceProviders) {
// for (SP sp : serviceProviders) {
// add(sp);
// }
// }
//
// /**
// * Removes a service provider, providing a notification to the listener
// *
// * @param sp
// * A service provider
// */
// public synchronized void remove(final SP sp) {
// removeServiceProvider(sp);
// }
//
// /**
// * Removes all the {@link ServiceProvider} from the list
// */
// public synchronized void clear() {
// for (SP sp : serviceProviders.values()) {
// removeServiceProvider(sp);
// }
// }
//
// /**
// * @param spId
// * A service provider
// * @return True if the specified {@link ServiceProvider} is registered, false
// * otherwise
// */
// public synchronized boolean contains(final String spId) {
// return serviceProviders.containsKey(spId);
// }
// }
// Path: test-impl/src/test/java/com/comcast/viper/flume2storm/location/TestServiceProviderManager.java
import java.util.ArrayList;
import java.util.List;
import junit.framework.Assert;
import org.junit.Test;
import com.comcast.viper.flume2storm.location.ServiceProviderManager;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.location;
/**
* Unit test for {@link ServiceProviderManager}
*/
public class TestServiceProviderManager {
/**
* TODO better test coverage
*/
@Test
public void testIt() {
SimpleServiceListener listener = new SimpleServiceListener();
|
ServiceProviderManager<SimpleServiceProvider> manager = new ServiceProviderManager<SimpleServiceProvider>(listener);
|
Comcast/flume2storm
|
flume-spout/src/main/java/com/comcast/viper/flume2storm/spout/FlumeSpoutConfiguration.java
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
//
// Path: core/src/main/java/com/comcast/viper/flume2storm/connection/receptor/EventReceptorFactory.java
// public interface EventReceptorFactory<CP extends ConnectionParameters> {
// /**
// * Creates a new {@link EventReceptor} based on the connection parameters
// * provided
// *
// * @param connectionParams
// * Connections parameters to use to configure the
// * {@link EventReceptor}
// * @param config
// * Additional configuration for the creation of the event receptor
// * @return The newly created {@link EventReceptor}
// * @throws F2SConfigurationException
// * If the configuration specified is invalid
// */
// EventReceptor<CP> create(CP connectionParams, Configuration config) throws F2SConfigurationException;
// }
//
// Path: core/src/main/java/com/comcast/viper/flume2storm/location/LocationServiceFactory.java
// public interface LocationServiceFactory<SP extends ServiceProvider<?>> {
// /**
// * Creates a new {@link LocationService} based on the configuration provided
// *
// * @param config
// * Configuration for the location service
// * @param serviceProviderSerialization
// * The {@link ServiceProviderSerialization} to use
// * @return The newly created {@link LocationService}
// * @throws F2SConfigurationException
// * If the configuration specified is invalid
// */
// LocationService<SP> create(Configuration config, ServiceProviderSerialization<SP> serviceProviderSerialization)
// throws F2SConfigurationException;
// }
//
// Path: core/src/main/java/com/comcast/viper/flume2storm/location/ServiceProviderSerialization.java
// public interface ServiceProviderSerialization<SP extends ServiceProvider<?>> extends Serializable {
// /**
// * Serializes a {@link ServiceProvider} into a byte array
// *
// * @param serviceProvider
// * The service provider to serialize
// * @return The serialized service provider
// */
// byte[] serialize(SP serviceProvider);
//
// /**
// * Deserializes a {@link ServiceProvider} from a byte array
// *
// * @param bytes
// * The serialized service provider
// * @return The deserialized service provider
// */
// SP deserialize(byte[] bytes);
// }
|
import com.google.common.base.Preconditions;
import com.google.common.base.Supplier;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.MapConfiguration;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import com.comcast.viper.flume2storm.F2SConfigurationException;
import com.comcast.viper.flume2storm.connection.receptor.EventReceptorFactory;
import com.comcast.viper.flume2storm.location.LocationServiceFactory;
import com.comcast.viper.flume2storm.location.ServiceProviderSerialization;
|
}
/**
* Copy constructor
*
* @param other
* the configuration to copy
*/
public FlumeSpoutConfiguration(final FlumeSpoutConfiguration other) {
locationServiceFactoryClassName = other.locationServiceFactoryClassName;
serviceProviderSerializationClassName = other.serviceProviderSerializationClassName;
eventReceptorFactoryClassName = other.eventReceptorFactoryClassName;
configuration = new HashMap<String, Object>(other.configuration);
}
/**
* @return The class name of the location service factory
*/
public String getLocationServiceFactoryClassName() {
return locationServiceFactoryClassName;
}
/**
* @param locationServiceFactoryClassName
* See {@link #getLocationServiceFactoryClassName()}
* @throws ClassNotFoundException
* If the class specified is not found in the classpath
*/
public void setLocationServiceFactoryClassName(String locationServiceFactoryClassName) throws ClassNotFoundException {
Class<?> locationServiceFactoryClass = Class.forName(locationServiceFactoryClassName);
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
//
// Path: core/src/main/java/com/comcast/viper/flume2storm/connection/receptor/EventReceptorFactory.java
// public interface EventReceptorFactory<CP extends ConnectionParameters> {
// /**
// * Creates a new {@link EventReceptor} based on the connection parameters
// * provided
// *
// * @param connectionParams
// * Connections parameters to use to configure the
// * {@link EventReceptor}
// * @param config
// * Additional configuration for the creation of the event receptor
// * @return The newly created {@link EventReceptor}
// * @throws F2SConfigurationException
// * If the configuration specified is invalid
// */
// EventReceptor<CP> create(CP connectionParams, Configuration config) throws F2SConfigurationException;
// }
//
// Path: core/src/main/java/com/comcast/viper/flume2storm/location/LocationServiceFactory.java
// public interface LocationServiceFactory<SP extends ServiceProvider<?>> {
// /**
// * Creates a new {@link LocationService} based on the configuration provided
// *
// * @param config
// * Configuration for the location service
// * @param serviceProviderSerialization
// * The {@link ServiceProviderSerialization} to use
// * @return The newly created {@link LocationService}
// * @throws F2SConfigurationException
// * If the configuration specified is invalid
// */
// LocationService<SP> create(Configuration config, ServiceProviderSerialization<SP> serviceProviderSerialization)
// throws F2SConfigurationException;
// }
//
// Path: core/src/main/java/com/comcast/viper/flume2storm/location/ServiceProviderSerialization.java
// public interface ServiceProviderSerialization<SP extends ServiceProvider<?>> extends Serializable {
// /**
// * Serializes a {@link ServiceProvider} into a byte array
// *
// * @param serviceProvider
// * The service provider to serialize
// * @return The serialized service provider
// */
// byte[] serialize(SP serviceProvider);
//
// /**
// * Deserializes a {@link ServiceProvider} from a byte array
// *
// * @param bytes
// * The serialized service provider
// * @return The deserialized service provider
// */
// SP deserialize(byte[] bytes);
// }
// Path: flume-spout/src/main/java/com/comcast/viper/flume2storm/spout/FlumeSpoutConfiguration.java
import com.google.common.base.Preconditions;
import com.google.common.base.Supplier;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.MapConfiguration;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import com.comcast.viper.flume2storm.F2SConfigurationException;
import com.comcast.viper.flume2storm.connection.receptor.EventReceptorFactory;
import com.comcast.viper.flume2storm.location.LocationServiceFactory;
import com.comcast.viper.flume2storm.location.ServiceProviderSerialization;
}
/**
* Copy constructor
*
* @param other
* the configuration to copy
*/
public FlumeSpoutConfiguration(final FlumeSpoutConfiguration other) {
locationServiceFactoryClassName = other.locationServiceFactoryClassName;
serviceProviderSerializationClassName = other.serviceProviderSerializationClassName;
eventReceptorFactoryClassName = other.eventReceptorFactoryClassName;
configuration = new HashMap<String, Object>(other.configuration);
}
/**
* @return The class name of the location service factory
*/
public String getLocationServiceFactoryClassName() {
return locationServiceFactoryClassName;
}
/**
* @param locationServiceFactoryClassName
* See {@link #getLocationServiceFactoryClassName()}
* @throws ClassNotFoundException
* If the class specified is not found in the classpath
*/
public void setLocationServiceFactoryClassName(String locationServiceFactoryClassName) throws ClassNotFoundException {
Class<?> locationServiceFactoryClass = Class.forName(locationServiceFactoryClassName);
|
Preconditions.checkArgument(LocationServiceFactory.class.isAssignableFrom(locationServiceFactoryClass),
|
Comcast/flume2storm
|
test-impl/src/main/java/com/comcast/viper/flume2storm/connection/parameters/SimpleConnectionParametersFactory.java
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
|
import org.apache.commons.configuration.Configuration;
import com.comcast.viper.flume2storm.F2SConfigurationException;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.connection.parameters;
/**
* Implementation of the {@link ConnectionParametersFactory} for test purpose
*/
public class SimpleConnectionParametersFactory implements ConnectionParametersFactory<SimpleConnectionParameters> {
/** Configuration attribute base name */
public static final String CONFIG_BASE_NAME = "connection";
/**
* @see com.comcast.viper.flume2storm.connection.parameters.ConnectionParametersFactory#create(org.apache.commons.configuration.Configuration)
*/
@Override
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
// Path: test-impl/src/main/java/com/comcast/viper/flume2storm/connection/parameters/SimpleConnectionParametersFactory.java
import org.apache.commons.configuration.Configuration;
import com.comcast.viper.flume2storm.F2SConfigurationException;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.connection.parameters;
/**
* Implementation of the {@link ConnectionParametersFactory} for test purpose
*/
public class SimpleConnectionParametersFactory implements ConnectionParametersFactory<SimpleConnectionParameters> {
/** Configuration attribute base name */
public static final String CONFIG_BASE_NAME = "connection";
/**
* @see com.comcast.viper.flume2storm.connection.parameters.ConnectionParametersFactory#create(org.apache.commons.configuration.Configuration)
*/
@Override
|
public SimpleConnectionParameters create(Configuration config) throws F2SConfigurationException {
|
Comcast/flume2storm
|
kryonet-flume2storm/src/main/java/com/comcast/viper/flume2storm/connection/KryoNetParameters.java
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
|
import java.io.Serializable;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.comcast.viper.flume2storm.F2SConfigurationException;
import com.google.common.base.Preconditions;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.connection;
/**
* Configuration for the KryoNet sender and receiver
*/
public class KryoNetParameters implements Serializable {
private static final long serialVersionUID = -5348116647457735026L;
/** Configuration attribute base name */
public static final String CONFIG_BASE_NAME = "kryonet";
/** Configuration attribute name for {@link #getConnectionTimeout()} */
public static final String CONNECTION_TIMEOUT = "connection.timeout.in.ms";
/** Default value for {@value #CONNECTION_TIMEOUT} */
public static final int CONNECTION_TIMEOUT_DEFAULT = 10000;
/** Configuration attribute name for {@link #getRetrySleepDelay()} */
public static final String RETRY_SLEEP_DELAY = "retry.sleep.delay.in.ms";
/** Default value for {@value #RETRY_SLEEP_DELAY} */
public static final int RETRY_SLEEP_DELAY_DEFAULT = 50;
/** Configuration attribute name for {@link #getReconnectionDelay()} */
public static final String RECONNECTION_DELAY = "reconnection.delay.in.ms";
/** Default value for {@value #RECONNECTION_DELAY} */
public static final int RECONNECTION_DELAY_DEFAULT = 2000;
/** Configuration attribute name for {@link #getTerminationTimeout()} */
public static final String TERMINATION_TO = "termination.timeout.in.ms";
/** Default value for {@value #TERMINATION_TO} */
public static final int TERMINATION_TO_DEFAULT = 10000;
/** Configuration attribute name for {@link #getMaxRetries()} */
public static final String MAX_RETRIES = "max.retries";
/** Default value for {@value #MAX_RETRIES} */
public static final int MAX_RETRIES_DEFAULT = 3;
protected int connectionTimeout;
protected int retrySleepDelay;
protected int reconnectionDelay;
protected int terminationTimeout;
protected int maxRetries;
/**
* Builds a new {@link KryoNetParameters} based on a Configuration
*
* @param config
* The configuration to use
* @return The newly created {@link KryoNetParameters}
* @throws F2SConfigurationException
* If the configuration specified is invalid
*/
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
// Path: kryonet-flume2storm/src/main/java/com/comcast/viper/flume2storm/connection/KryoNetParameters.java
import java.io.Serializable;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.comcast.viper.flume2storm.F2SConfigurationException;
import com.google.common.base.Preconditions;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.connection;
/**
* Configuration for the KryoNet sender and receiver
*/
public class KryoNetParameters implements Serializable {
private static final long serialVersionUID = -5348116647457735026L;
/** Configuration attribute base name */
public static final String CONFIG_BASE_NAME = "kryonet";
/** Configuration attribute name for {@link #getConnectionTimeout()} */
public static final String CONNECTION_TIMEOUT = "connection.timeout.in.ms";
/** Default value for {@value #CONNECTION_TIMEOUT} */
public static final int CONNECTION_TIMEOUT_DEFAULT = 10000;
/** Configuration attribute name for {@link #getRetrySleepDelay()} */
public static final String RETRY_SLEEP_DELAY = "retry.sleep.delay.in.ms";
/** Default value for {@value #RETRY_SLEEP_DELAY} */
public static final int RETRY_SLEEP_DELAY_DEFAULT = 50;
/** Configuration attribute name for {@link #getReconnectionDelay()} */
public static final String RECONNECTION_DELAY = "reconnection.delay.in.ms";
/** Default value for {@value #RECONNECTION_DELAY} */
public static final int RECONNECTION_DELAY_DEFAULT = 2000;
/** Configuration attribute name for {@link #getTerminationTimeout()} */
public static final String TERMINATION_TO = "termination.timeout.in.ms";
/** Default value for {@value #TERMINATION_TO} */
public static final int TERMINATION_TO_DEFAULT = 10000;
/** Configuration attribute name for {@link #getMaxRetries()} */
public static final String MAX_RETRIES = "max.retries";
/** Default value for {@value #MAX_RETRIES} */
public static final int MAX_RETRIES_DEFAULT = 3;
protected int connectionTimeout;
protected int retrySleepDelay;
protected int reconnectionDelay;
protected int terminationTimeout;
protected int maxRetries;
/**
* Builds a new {@link KryoNetParameters} based on a Configuration
*
* @param config
* The configuration to use
* @return The newly created {@link KryoNetParameters}
* @throws F2SConfigurationException
* If the configuration specified is invalid
*/
|
public static KryoNetParameters from(final Configuration config) throws F2SConfigurationException {
|
Comcast/flume2storm
|
test-impl/src/main/java/com/comcast/viper/flume2storm/location/SimpleLocationServiceFactory.java
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
|
import org.apache.commons.configuration.Configuration;
import com.comcast.viper.flume2storm.F2SConfigurationException;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.location;
/**
* A simple implementation of the {@link LocationServiceFactory} for test
* purpose
*/
public class SimpleLocationServiceFactory implements LocationServiceFactory<SimpleServiceProvider> {
/**
* @see com.comcast.viper.flume2storm.location.LocationServiceFactory#create(org.apache.commons.configuration.Configuration,
* com.comcast.viper.flume2storm.location.ServiceProviderSerialization)
*/
@Override
public SimpleLocationService create(Configuration config,
ServiceProviderSerialization<SimpleServiceProvider> serviceProviderSerialization)
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
// Path: test-impl/src/main/java/com/comcast/viper/flume2storm/location/SimpleLocationServiceFactory.java
import org.apache.commons.configuration.Configuration;
import com.comcast.viper.flume2storm.F2SConfigurationException;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.location;
/**
* A simple implementation of the {@link LocationServiceFactory} for test
* purpose
*/
public class SimpleLocationServiceFactory implements LocationServiceFactory<SimpleServiceProvider> {
/**
* @see com.comcast.viper.flume2storm.location.LocationServiceFactory#create(org.apache.commons.configuration.Configuration,
* com.comcast.viper.flume2storm.location.ServiceProviderSerialization)
*/
@Override
public SimpleLocationService create(Configuration config,
ServiceProviderSerialization<SimpleServiceProvider> serviceProviderSerialization)
|
throws F2SConfigurationException {
|
Comcast/flume2storm
|
static-location-service/src/main/java/com/comcast/viper/flume2storm/location/StaticLocationServiceConfiguration.java
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
|
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.comcast.viper.flume2storm.F2SConfigurationException;
import com.google.common.base.Preconditions;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.location;
/**
* Configuration for {@link StaticLocationService}
*/
public class StaticLocationServiceConfiguration {
/** Configuration attribute name to get the list of service providers */
public static final String SERVICE_PROVIDER_LIST = "service.providers";
/** The {@link ServiceProvider} list separator */
public static final String SERVICE_PROVIDER_LIST_SEPARATOR = " ";
/** Configuration attribute name for {@link #getServiceProviderBase()} */
public static final String SERVICE_PROVIDER_BASE = "service.providers.base";
/** Default value for {@value #SERVICE_PROVIDER_BASE} */
public static final String SERVICE_PROVIDER_BASE_DEFAULT = "service.providers";
/**
* Configuration attribute name for the
* {@link ServiceProviderConfigurationLoader} class name
*/
public static final String CONFIGURATION_LOADER_CLASS = "configuration.loader.class";
protected String serviceProviderBase;
private String configurationLoaderClassName;
/**
* @param config
* The configuration to use
* @return The newly built {@link StaticLocationServiceConfiguration} based on
* the configuration specified
* @throws F2SConfigurationException
* If the configuration is invalid
*/
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
// Path: static-location-service/src/main/java/com/comcast/viper/flume2storm/location/StaticLocationServiceConfiguration.java
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.comcast.viper.flume2storm.F2SConfigurationException;
import com.google.common.base.Preconditions;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.location;
/**
* Configuration for {@link StaticLocationService}
*/
public class StaticLocationServiceConfiguration {
/** Configuration attribute name to get the list of service providers */
public static final String SERVICE_PROVIDER_LIST = "service.providers";
/** The {@link ServiceProvider} list separator */
public static final String SERVICE_PROVIDER_LIST_SEPARATOR = " ";
/** Configuration attribute name for {@link #getServiceProviderBase()} */
public static final String SERVICE_PROVIDER_BASE = "service.providers.base";
/** Default value for {@value #SERVICE_PROVIDER_BASE} */
public static final String SERVICE_PROVIDER_BASE_DEFAULT = "service.providers";
/**
* Configuration attribute name for the
* {@link ServiceProviderConfigurationLoader} class name
*/
public static final String CONFIGURATION_LOADER_CLASS = "configuration.loader.class";
protected String serviceProviderBase;
private String configurationLoaderClassName;
/**
* @param config
* The configuration to use
* @return The newly built {@link StaticLocationServiceConfiguration} based on
* the configuration specified
* @throws F2SConfigurationException
* If the configuration is invalid
*/
|
public static StaticLocationServiceConfiguration from(Configuration config) throws F2SConfigurationException {
|
Comcast/flume2storm
|
static-location-service/src/test/java/com/comcast/viper/flume2storm/location/StaticLocationServiceConfigurationTest.java
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
|
import junit.framework.Assert;
import org.apache.commons.configuration.BaseConfiguration;
import org.apache.commons.configuration.Configuration;
import org.junit.Test;
import com.comcast.viper.flume2storm.F2SConfigurationException;
|
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.location;
/**
* Unit test for {@link StaticLocationServiceConfiguration}
*/
public class StaticLocationServiceConfigurationTest {
/**
* Test {@link StaticLocationServiceConfiguration#from(Configuration)}
*
* @throws F2SConfigurationException
* If the configuration is invalid
*/
@Test
|
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
// private static final long serialVersionUID = 4941423443352427505L;
//
// /**
// * @param config
// * The configuration that contains the invalid parameter
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
// return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is invalid
// * @param value
// * The configured value of the parameter
// * @param throwable
// * The exception that occurred when setting the parameter's value
// * @return The newly built F2SConfigurationException related to a specific
// * invalid parameter
// */
// public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
// return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
// }
//
// protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
// return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
// .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
// .append(throwable.getLocalizedMessage()).toString();
// }
//
// /**
// * @param parameter
// * The name of the configuration parameter that is missing
// * @return The newly built F2SConfigurationException related to a specific
// * missing parameter
// */
// public static F2SConfigurationException missing(String parameter) {
// return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
// .append("\" is required but not specified").toString());
// }
//
// public F2SConfigurationException() {
// super();
// }
//
// public F2SConfigurationException(String message) {
// super(message);
// }
//
// public F2SConfigurationException(Throwable throwable) {
// super(throwable);
// }
//
// public F2SConfigurationException(String message, Throwable throwable) {
// super(message, throwable);
// }
// }
// Path: static-location-service/src/test/java/com/comcast/viper/flume2storm/location/StaticLocationServiceConfigurationTest.java
import junit.framework.Assert;
import org.apache.commons.configuration.BaseConfiguration;
import org.apache.commons.configuration.Configuration;
import org.junit.Test;
import com.comcast.viper.flume2storm.F2SConfigurationException;
/**
* Copyright 2014 Comcast Cable Communications Management, LLC
*
* 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 com.comcast.viper.flume2storm.location;
/**
* Unit test for {@link StaticLocationServiceConfiguration}
*/
public class StaticLocationServiceConfigurationTest {
/**
* Test {@link StaticLocationServiceConfiguration#from(Configuration)}
*
* @throws F2SConfigurationException
* If the configuration is invalid
*/
@Test
|
public void testFromConfiguration() throws F2SConfigurationException {
|
opcoach/Conferences
|
ECF14/ecf14_files/step6-EngineControlPanel/DashBoard.java
|
// Path: ECF14/ecf14_files/step5-SimulatorEngine/EngineSimulator.java
// public class EngineSimulator {
//
// // Define the constants to get/set values from context
// public static final String ECF2014_SPEED_VALUE = "ecf2014.speedValue";
// public static final String ECF2014_RPM_VALUE = "ecf2014.rpmValue";
// public static final String ECF2014_TANK_VALUE = "ecf2014.tankValue";
//
// @Inject
// IEclipseContext ctx; // The context where values will be injected
//
// // Physical values
// int speed, rpm, tankLevel;
// int acceleration = 2;
//
// Timer timer = null;
//
// @Inject
// EngineSimulator() {
// this(65);
// }
//
// EngineSimulator(int tankInit) {
// tankLevel = tankInit;
//
// }
//
// public void start() {
// if (timer == null) {
// timer = new Timer();
// timer.scheduleAtFixedRate(new EngineTimerTask(), 1000, 1500);
// }
// }
//
// public void stop() {
// if (timer != null) {
// timer.cancel();
// ctx.set(ECF2014_SPEED_VALUE, 0);
// ctx.set(ECF2014_RPM_VALUE, 0);
//
// }
// timer = null;
// }
//
// @PostConstruct
// void declareInContext() {
// ctx.set(EngineSimulator.class, this);
//
// }
//
// private class EngineTimerTask extends TimerTask {
// @Override
// public void run() {
// speed = speed + acceleration;
// rpm = speed * 75;
//
// if (speed < 0)
// speed = 0;
// if (rpm < 0)
// rpm = 0;
//
// System.out.println("New value for speed : " + speed + " and rpm : "
// + rpm);
// ctx.set(ECF2014_SPEED_VALUE, speed);
// ctx.set(ECF2014_RPM_VALUE, rpm);
// }
// }
//
// /**
// * accelerate or brake
// *
// * @param a
// * acceleration in m/s2
// */
// public void accelerate(int a) {
// acceleration = a;
// }
//
// }
|
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.GridLayout;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.di.UISynchronize;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.nebula.visualization.widgets.figures.GaugeFigure;
import org.eclipse.nebula.visualization.xygraph.util.XYGraphMediaFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import com.opcoach.ecf2014.engine.core.EngineSimulator;
|
package com.opcoach.ecf14.eap.parts;
public class DashBoard
{
private GaugeFigure speedCounter;
private GaugeFigure rpmCounter;
private XYGraphMediaFactory gmfactory;
private Canvas canvas;
@Inject
public DashBoard(MApplication appli)
{
// Step 5 : create and start Engine.
|
// Path: ECF14/ecf14_files/step5-SimulatorEngine/EngineSimulator.java
// public class EngineSimulator {
//
// // Define the constants to get/set values from context
// public static final String ECF2014_SPEED_VALUE = "ecf2014.speedValue";
// public static final String ECF2014_RPM_VALUE = "ecf2014.rpmValue";
// public static final String ECF2014_TANK_VALUE = "ecf2014.tankValue";
//
// @Inject
// IEclipseContext ctx; // The context where values will be injected
//
// // Physical values
// int speed, rpm, tankLevel;
// int acceleration = 2;
//
// Timer timer = null;
//
// @Inject
// EngineSimulator() {
// this(65);
// }
//
// EngineSimulator(int tankInit) {
// tankLevel = tankInit;
//
// }
//
// public void start() {
// if (timer == null) {
// timer = new Timer();
// timer.scheduleAtFixedRate(new EngineTimerTask(), 1000, 1500);
// }
// }
//
// public void stop() {
// if (timer != null) {
// timer.cancel();
// ctx.set(ECF2014_SPEED_VALUE, 0);
// ctx.set(ECF2014_RPM_VALUE, 0);
//
// }
// timer = null;
// }
//
// @PostConstruct
// void declareInContext() {
// ctx.set(EngineSimulator.class, this);
//
// }
//
// private class EngineTimerTask extends TimerTask {
// @Override
// public void run() {
// speed = speed + acceleration;
// rpm = speed * 75;
//
// if (speed < 0)
// speed = 0;
// if (rpm < 0)
// rpm = 0;
//
// System.out.println("New value for speed : " + speed + " and rpm : "
// + rpm);
// ctx.set(ECF2014_SPEED_VALUE, speed);
// ctx.set(ECF2014_RPM_VALUE, rpm);
// }
// }
//
// /**
// * accelerate or brake
// *
// * @param a
// * acceleration in m/s2
// */
// public void accelerate(int a) {
// acceleration = a;
// }
//
// }
// Path: ECF14/ecf14_files/step6-EngineControlPanel/DashBoard.java
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.GridLayout;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.di.UISynchronize;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.nebula.visualization.widgets.figures.GaugeFigure;
import org.eclipse.nebula.visualization.xygraph.util.XYGraphMediaFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import com.opcoach.ecf2014.engine.core.EngineSimulator;
package com.opcoach.ecf14.eap.parts;
public class DashBoard
{
private GaugeFigure speedCounter;
private GaugeFigure rpmCounter;
private XYGraphMediaFactory gmfactory;
private Canvas canvas;
@Inject
public DashBoard(MApplication appli)
{
// Step 5 : create and start Engine.
|
EngineSimulator simu = ContextInjectionFactory.make(EngineSimulator.class, appli.getContext());
|
opcoach/Conferences
|
ECF14/ecf14_files/step9-AlarmViewer/AlarmPart.java
|
// Path: ECF14/ecf14_files/step8-EngineWatcher/Alarm.java
// public class Alarm
// {
// private Date when; private String what; private int value;
//
// public Alarm(String what, int value)
// {
// this.what = what;
// this.value = value;
// when = new Date();
// }
//
// public Date getWhen() { return when; }
// public String getWhat() { return what; }
// public int getValue() { return value; }
//
// @Override public String toString()
// {
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
// return "Alarm : " + sdf.format(when) + " " + what + " : " + value;
// }
// }
//
// Path: ECF14/ecf14_files/step8-EngineWatcher/EngineWatcher.java
// public class EngineWatcher
// {
// // Define the sent topics
// public static final String ALARM_TOPIC = "Alarm/*";
// public static final String ALARM_RPM_TOO_HIGH = "Alarm/RpmTooHigh";
// public static final String ALARM_SPEED_TOO_HIGH = "Alarm/SpeedTooHigh";
//
// // Get the event broker by injection
// @Inject
// IEventBroker ebroker;
//
// @Optional
// @Inject
// public void checkRpmValue(final @Named(EngineSimulator.ECF2014_RPM_VALUE) int value)
// {
// if (value > 5000)
// {
// // Send an alarm
// Alarm a = new Alarm("rpm is too high (" + value + ")", value);
// ebroker.send(ALARM_RPM_TOO_HIGH, a);
// }
// }
//
// @Optional
// @Inject
// public void checkSpeedValue(final @Named(EngineSimulator.ECF2014_SPEED_VALUE) int value)
// {
// System.out.println("Check speed value for alarm : " + value);
// if (value > 160)
// {
// // Send an alarm
// Alarm a = new Alarm("speed is too high (" + value + ")", value);
// ebroker.send(ALARM_SPEED_TOO_HIGH, a);
// }
// }
//
// }
|
import java.text.SimpleDateFormat;
import java.util.Vector;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.di.UIEventTopic;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import com.opcoach.ecf2014.engine.core.Alarm;
import com.opcoach.ecf2014.engine.core.EngineWatcher;
|
package com.opcoach.ecf2014.engine.ui.parts;
public class AlarmPart
{
@Optional
@Inject
|
// Path: ECF14/ecf14_files/step8-EngineWatcher/Alarm.java
// public class Alarm
// {
// private Date when; private String what; private int value;
//
// public Alarm(String what, int value)
// {
// this.what = what;
// this.value = value;
// when = new Date();
// }
//
// public Date getWhen() { return when; }
// public String getWhat() { return what; }
// public int getValue() { return value; }
//
// @Override public String toString()
// {
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
// return "Alarm : " + sdf.format(when) + " " + what + " : " + value;
// }
// }
//
// Path: ECF14/ecf14_files/step8-EngineWatcher/EngineWatcher.java
// public class EngineWatcher
// {
// // Define the sent topics
// public static final String ALARM_TOPIC = "Alarm/*";
// public static final String ALARM_RPM_TOO_HIGH = "Alarm/RpmTooHigh";
// public static final String ALARM_SPEED_TOO_HIGH = "Alarm/SpeedTooHigh";
//
// // Get the event broker by injection
// @Inject
// IEventBroker ebroker;
//
// @Optional
// @Inject
// public void checkRpmValue(final @Named(EngineSimulator.ECF2014_RPM_VALUE) int value)
// {
// if (value > 5000)
// {
// // Send an alarm
// Alarm a = new Alarm("rpm is too high (" + value + ")", value);
// ebroker.send(ALARM_RPM_TOO_HIGH, a);
// }
// }
//
// @Optional
// @Inject
// public void checkSpeedValue(final @Named(EngineSimulator.ECF2014_SPEED_VALUE) int value)
// {
// System.out.println("Check speed value for alarm : " + value);
// if (value > 160)
// {
// // Send an alarm
// Alarm a = new Alarm("speed is too high (" + value + ")", value);
// ebroker.send(ALARM_SPEED_TOO_HIGH, a);
// }
// }
//
// }
// Path: ECF14/ecf14_files/step9-AlarmViewer/AlarmPart.java
import java.text.SimpleDateFormat;
import java.util.Vector;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.di.UIEventTopic;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import com.opcoach.ecf2014.engine.core.Alarm;
import com.opcoach.ecf2014.engine.core.EngineWatcher;
package com.opcoach.ecf2014.engine.ui.parts;
public class AlarmPart
{
@Optional
@Inject
|
private EngineWatcher engineWatcher;
|
opcoach/Conferences
|
ECF14/ecf14_files/step9-AlarmViewer/AlarmPart.java
|
// Path: ECF14/ecf14_files/step8-EngineWatcher/Alarm.java
// public class Alarm
// {
// private Date when; private String what; private int value;
//
// public Alarm(String what, int value)
// {
// this.what = what;
// this.value = value;
// when = new Date();
// }
//
// public Date getWhen() { return when; }
// public String getWhat() { return what; }
// public int getValue() { return value; }
//
// @Override public String toString()
// {
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
// return "Alarm : " + sdf.format(when) + " " + what + " : " + value;
// }
// }
//
// Path: ECF14/ecf14_files/step8-EngineWatcher/EngineWatcher.java
// public class EngineWatcher
// {
// // Define the sent topics
// public static final String ALARM_TOPIC = "Alarm/*";
// public static final String ALARM_RPM_TOO_HIGH = "Alarm/RpmTooHigh";
// public static final String ALARM_SPEED_TOO_HIGH = "Alarm/SpeedTooHigh";
//
// // Get the event broker by injection
// @Inject
// IEventBroker ebroker;
//
// @Optional
// @Inject
// public void checkRpmValue(final @Named(EngineSimulator.ECF2014_RPM_VALUE) int value)
// {
// if (value > 5000)
// {
// // Send an alarm
// Alarm a = new Alarm("rpm is too high (" + value + ")", value);
// ebroker.send(ALARM_RPM_TOO_HIGH, a);
// }
// }
//
// @Optional
// @Inject
// public void checkSpeedValue(final @Named(EngineSimulator.ECF2014_SPEED_VALUE) int value)
// {
// System.out.println("Check speed value for alarm : " + value);
// if (value > 160)
// {
// // Send an alarm
// Alarm a = new Alarm("speed is too high (" + value + ")", value);
// ebroker.send(ALARM_SPEED_TOO_HIGH, a);
// }
// }
//
// }
|
import java.text.SimpleDateFormat;
import java.util.Vector;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.di.UIEventTopic;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import com.opcoach.ecf2014.engine.core.Alarm;
import com.opcoach.ecf2014.engine.core.EngineWatcher;
|
package com.opcoach.ecf2014.engine.ui.parts;
public class AlarmPart
{
@Optional
@Inject
private EngineWatcher engineWatcher;
|
// Path: ECF14/ecf14_files/step8-EngineWatcher/Alarm.java
// public class Alarm
// {
// private Date when; private String what; private int value;
//
// public Alarm(String what, int value)
// {
// this.what = what;
// this.value = value;
// when = new Date();
// }
//
// public Date getWhen() { return when; }
// public String getWhat() { return what; }
// public int getValue() { return value; }
//
// @Override public String toString()
// {
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
// return "Alarm : " + sdf.format(when) + " " + what + " : " + value;
// }
// }
//
// Path: ECF14/ecf14_files/step8-EngineWatcher/EngineWatcher.java
// public class EngineWatcher
// {
// // Define the sent topics
// public static final String ALARM_TOPIC = "Alarm/*";
// public static final String ALARM_RPM_TOO_HIGH = "Alarm/RpmTooHigh";
// public static final String ALARM_SPEED_TOO_HIGH = "Alarm/SpeedTooHigh";
//
// // Get the event broker by injection
// @Inject
// IEventBroker ebroker;
//
// @Optional
// @Inject
// public void checkRpmValue(final @Named(EngineSimulator.ECF2014_RPM_VALUE) int value)
// {
// if (value > 5000)
// {
// // Send an alarm
// Alarm a = new Alarm("rpm is too high (" + value + ")", value);
// ebroker.send(ALARM_RPM_TOO_HIGH, a);
// }
// }
//
// @Optional
// @Inject
// public void checkSpeedValue(final @Named(EngineSimulator.ECF2014_SPEED_VALUE) int value)
// {
// System.out.println("Check speed value for alarm : " + value);
// if (value > 160)
// {
// // Send an alarm
// Alarm a = new Alarm("speed is too high (" + value + ")", value);
// ebroker.send(ALARM_SPEED_TOO_HIGH, a);
// }
// }
//
// }
// Path: ECF14/ecf14_files/step9-AlarmViewer/AlarmPart.java
import java.text.SimpleDateFormat;
import java.util.Vector;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.di.UIEventTopic;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import com.opcoach.ecf2014.engine.core.Alarm;
import com.opcoach.ecf2014.engine.core.EngineWatcher;
package com.opcoach.ecf2014.engine.ui.parts;
public class AlarmPart
{
@Optional
@Inject
private EngineWatcher engineWatcher;
|
Vector<Alarm> alarms = new Vector<Alarm>();
|
opcoach/Conferences
|
ECF14/com.opcoach.ecf2014.engine.ui/src/com/opcoach/ecf2014/engine/ui/parts/DashBoard.java
|
// Path: ECF14/ecf14_files/step5-SimulatorEngine/EngineSimulator.java
// public class EngineSimulator {
//
// // Define the constants to get/set values from context
// public static final String ECF2014_SPEED_VALUE = "ecf2014.speedValue";
// public static final String ECF2014_RPM_VALUE = "ecf2014.rpmValue";
// public static final String ECF2014_TANK_VALUE = "ecf2014.tankValue";
//
// @Inject
// IEclipseContext ctx; // The context where values will be injected
//
// // Physical values
// int speed, rpm, tankLevel;
// int acceleration = 2;
//
// Timer timer = null;
//
// @Inject
// EngineSimulator() {
// this(65);
// }
//
// EngineSimulator(int tankInit) {
// tankLevel = tankInit;
//
// }
//
// public void start() {
// if (timer == null) {
// timer = new Timer();
// timer.scheduleAtFixedRate(new EngineTimerTask(), 1000, 1500);
// }
// }
//
// public void stop() {
// if (timer != null) {
// timer.cancel();
// ctx.set(ECF2014_SPEED_VALUE, 0);
// ctx.set(ECF2014_RPM_VALUE, 0);
//
// }
// timer = null;
// }
//
// @PostConstruct
// void declareInContext() {
// ctx.set(EngineSimulator.class, this);
//
// }
//
// private class EngineTimerTask extends TimerTask {
// @Override
// public void run() {
// speed = speed + acceleration;
// rpm = speed * 75;
//
// if (speed < 0)
// speed = 0;
// if (rpm < 0)
// rpm = 0;
//
// System.out.println("New value for speed : " + speed + " and rpm : "
// + rpm);
// ctx.set(ECF2014_SPEED_VALUE, speed);
// ctx.set(ECF2014_RPM_VALUE, rpm);
// }
// }
//
// /**
// * accelerate or brake
// *
// * @param a
// * acceleration in m/s2
// */
// public void accelerate(int a) {
// acceleration = a;
// }
//
// }
//
// Path: ECF14/ecf14_files/step8-EngineWatcher/EngineWatcher.java
// public class EngineWatcher
// {
// // Define the sent topics
// public static final String ALARM_TOPIC = "Alarm/*";
// public static final String ALARM_RPM_TOO_HIGH = "Alarm/RpmTooHigh";
// public static final String ALARM_SPEED_TOO_HIGH = "Alarm/SpeedTooHigh";
//
// // Get the event broker by injection
// @Inject
// IEventBroker ebroker;
//
// @Optional
// @Inject
// public void checkRpmValue(final @Named(EngineSimulator.ECF2014_RPM_VALUE) int value)
// {
// if (value > 5000)
// {
// // Send an alarm
// Alarm a = new Alarm("rpm is too high (" + value + ")", value);
// ebroker.send(ALARM_RPM_TOO_HIGH, a);
// }
// }
//
// @Optional
// @Inject
// public void checkSpeedValue(final @Named(EngineSimulator.ECF2014_SPEED_VALUE) int value)
// {
// System.out.println("Check speed value for alarm : " + value);
// if (value > 160)
// {
// // Send an alarm
// Alarm a = new Alarm("speed is too high (" + value + ")", value);
// ebroker.send(ALARM_SPEED_TOO_HIGH, a);
// }
// }
//
// }
|
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.di.UISynchronize;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.nebula.visualization.widgets.figures.GaugeFigure;
import org.eclipse.nebula.visualization.xygraph.util.XYGraphMediaFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import com.opcoach.ecf2014.engine.core.EngineSimulator;
import com.opcoach.ecf2014.engine.core.EngineWatcher;
|
package com.opcoach.ecf2014.engine.ui.parts;
public class DashBoard
{
private GaugeFigure speedCounter;
private GaugeFigure rpmCounter;
private XYGraphMediaFactory gmfactory;
private static final int COUNTER_SIZE = 200;
private static final int COUNTER_MARGIN = 15;
private Canvas canvas;
@Inject
public DashBoard(MApplication appli)
{
// We will use the application context to store and inject values.
IEclipseContext appliContext = appli.getContext();
// We also need an ImageRegistry for the application
appliContext.set(ImageRegistry.class, new ImageRegistry());
// Step 5 : create and start Engine.
|
// Path: ECF14/ecf14_files/step5-SimulatorEngine/EngineSimulator.java
// public class EngineSimulator {
//
// // Define the constants to get/set values from context
// public static final String ECF2014_SPEED_VALUE = "ecf2014.speedValue";
// public static final String ECF2014_RPM_VALUE = "ecf2014.rpmValue";
// public static final String ECF2014_TANK_VALUE = "ecf2014.tankValue";
//
// @Inject
// IEclipseContext ctx; // The context where values will be injected
//
// // Physical values
// int speed, rpm, tankLevel;
// int acceleration = 2;
//
// Timer timer = null;
//
// @Inject
// EngineSimulator() {
// this(65);
// }
//
// EngineSimulator(int tankInit) {
// tankLevel = tankInit;
//
// }
//
// public void start() {
// if (timer == null) {
// timer = new Timer();
// timer.scheduleAtFixedRate(new EngineTimerTask(), 1000, 1500);
// }
// }
//
// public void stop() {
// if (timer != null) {
// timer.cancel();
// ctx.set(ECF2014_SPEED_VALUE, 0);
// ctx.set(ECF2014_RPM_VALUE, 0);
//
// }
// timer = null;
// }
//
// @PostConstruct
// void declareInContext() {
// ctx.set(EngineSimulator.class, this);
//
// }
//
// private class EngineTimerTask extends TimerTask {
// @Override
// public void run() {
// speed = speed + acceleration;
// rpm = speed * 75;
//
// if (speed < 0)
// speed = 0;
// if (rpm < 0)
// rpm = 0;
//
// System.out.println("New value for speed : " + speed + " and rpm : "
// + rpm);
// ctx.set(ECF2014_SPEED_VALUE, speed);
// ctx.set(ECF2014_RPM_VALUE, rpm);
// }
// }
//
// /**
// * accelerate or brake
// *
// * @param a
// * acceleration in m/s2
// */
// public void accelerate(int a) {
// acceleration = a;
// }
//
// }
//
// Path: ECF14/ecf14_files/step8-EngineWatcher/EngineWatcher.java
// public class EngineWatcher
// {
// // Define the sent topics
// public static final String ALARM_TOPIC = "Alarm/*";
// public static final String ALARM_RPM_TOO_HIGH = "Alarm/RpmTooHigh";
// public static final String ALARM_SPEED_TOO_HIGH = "Alarm/SpeedTooHigh";
//
// // Get the event broker by injection
// @Inject
// IEventBroker ebroker;
//
// @Optional
// @Inject
// public void checkRpmValue(final @Named(EngineSimulator.ECF2014_RPM_VALUE) int value)
// {
// if (value > 5000)
// {
// // Send an alarm
// Alarm a = new Alarm("rpm is too high (" + value + ")", value);
// ebroker.send(ALARM_RPM_TOO_HIGH, a);
// }
// }
//
// @Optional
// @Inject
// public void checkSpeedValue(final @Named(EngineSimulator.ECF2014_SPEED_VALUE) int value)
// {
// System.out.println("Check speed value for alarm : " + value);
// if (value > 160)
// {
// // Send an alarm
// Alarm a = new Alarm("speed is too high (" + value + ")", value);
// ebroker.send(ALARM_SPEED_TOO_HIGH, a);
// }
// }
//
// }
// Path: ECF14/com.opcoach.ecf2014.engine.ui/src/com/opcoach/ecf2014/engine/ui/parts/DashBoard.java
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.di.UISynchronize;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.nebula.visualization.widgets.figures.GaugeFigure;
import org.eclipse.nebula.visualization.xygraph.util.XYGraphMediaFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import com.opcoach.ecf2014.engine.core.EngineSimulator;
import com.opcoach.ecf2014.engine.core.EngineWatcher;
package com.opcoach.ecf2014.engine.ui.parts;
public class DashBoard
{
private GaugeFigure speedCounter;
private GaugeFigure rpmCounter;
private XYGraphMediaFactory gmfactory;
private static final int COUNTER_SIZE = 200;
private static final int COUNTER_MARGIN = 15;
private Canvas canvas;
@Inject
public DashBoard(MApplication appli)
{
// We will use the application context to store and inject values.
IEclipseContext appliContext = appli.getContext();
// We also need an ImageRegistry for the application
appliContext.set(ImageRegistry.class, new ImageRegistry());
// Step 5 : create and start Engine.
|
EngineSimulator simu = ContextInjectionFactory.make(EngineSimulator.class, appliContext);
|
opcoach/Conferences
|
ECF14/com.opcoach.ecf2014.engine.ui/src/com/opcoach/ecf2014/engine/ui/parts/DashBoard.java
|
// Path: ECF14/ecf14_files/step5-SimulatorEngine/EngineSimulator.java
// public class EngineSimulator {
//
// // Define the constants to get/set values from context
// public static final String ECF2014_SPEED_VALUE = "ecf2014.speedValue";
// public static final String ECF2014_RPM_VALUE = "ecf2014.rpmValue";
// public static final String ECF2014_TANK_VALUE = "ecf2014.tankValue";
//
// @Inject
// IEclipseContext ctx; // The context where values will be injected
//
// // Physical values
// int speed, rpm, tankLevel;
// int acceleration = 2;
//
// Timer timer = null;
//
// @Inject
// EngineSimulator() {
// this(65);
// }
//
// EngineSimulator(int tankInit) {
// tankLevel = tankInit;
//
// }
//
// public void start() {
// if (timer == null) {
// timer = new Timer();
// timer.scheduleAtFixedRate(new EngineTimerTask(), 1000, 1500);
// }
// }
//
// public void stop() {
// if (timer != null) {
// timer.cancel();
// ctx.set(ECF2014_SPEED_VALUE, 0);
// ctx.set(ECF2014_RPM_VALUE, 0);
//
// }
// timer = null;
// }
//
// @PostConstruct
// void declareInContext() {
// ctx.set(EngineSimulator.class, this);
//
// }
//
// private class EngineTimerTask extends TimerTask {
// @Override
// public void run() {
// speed = speed + acceleration;
// rpm = speed * 75;
//
// if (speed < 0)
// speed = 0;
// if (rpm < 0)
// rpm = 0;
//
// System.out.println("New value for speed : " + speed + " and rpm : "
// + rpm);
// ctx.set(ECF2014_SPEED_VALUE, speed);
// ctx.set(ECF2014_RPM_VALUE, rpm);
// }
// }
//
// /**
// * accelerate or brake
// *
// * @param a
// * acceleration in m/s2
// */
// public void accelerate(int a) {
// acceleration = a;
// }
//
// }
//
// Path: ECF14/ecf14_files/step8-EngineWatcher/EngineWatcher.java
// public class EngineWatcher
// {
// // Define the sent topics
// public static final String ALARM_TOPIC = "Alarm/*";
// public static final String ALARM_RPM_TOO_HIGH = "Alarm/RpmTooHigh";
// public static final String ALARM_SPEED_TOO_HIGH = "Alarm/SpeedTooHigh";
//
// // Get the event broker by injection
// @Inject
// IEventBroker ebroker;
//
// @Optional
// @Inject
// public void checkRpmValue(final @Named(EngineSimulator.ECF2014_RPM_VALUE) int value)
// {
// if (value > 5000)
// {
// // Send an alarm
// Alarm a = new Alarm("rpm is too high (" + value + ")", value);
// ebroker.send(ALARM_RPM_TOO_HIGH, a);
// }
// }
//
// @Optional
// @Inject
// public void checkSpeedValue(final @Named(EngineSimulator.ECF2014_SPEED_VALUE) int value)
// {
// System.out.println("Check speed value for alarm : " + value);
// if (value > 160)
// {
// // Send an alarm
// Alarm a = new Alarm("speed is too high (" + value + ")", value);
// ebroker.send(ALARM_SPEED_TOO_HIGH, a);
// }
// }
//
// }
|
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.di.UISynchronize;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.nebula.visualization.widgets.figures.GaugeFigure;
import org.eclipse.nebula.visualization.xygraph.util.XYGraphMediaFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import com.opcoach.ecf2014.engine.core.EngineSimulator;
import com.opcoach.ecf2014.engine.core.EngineWatcher;
|
package com.opcoach.ecf2014.engine.ui.parts;
public class DashBoard
{
private GaugeFigure speedCounter;
private GaugeFigure rpmCounter;
private XYGraphMediaFactory gmfactory;
private static final int COUNTER_SIZE = 200;
private static final int COUNTER_MARGIN = 15;
private Canvas canvas;
@Inject
public DashBoard(MApplication appli)
{
// We will use the application context to store and inject values.
IEclipseContext appliContext = appli.getContext();
// We also need an ImageRegistry for the application
appliContext.set(ImageRegistry.class, new ImageRegistry());
// Step 5 : create and start Engine.
EngineSimulator simu = ContextInjectionFactory.make(EngineSimulator.class, appliContext);
appliContext.set(EngineSimulator.class, simu);
// Step 8 : create the engine alarm watcher and keep a reference on it !
|
// Path: ECF14/ecf14_files/step5-SimulatorEngine/EngineSimulator.java
// public class EngineSimulator {
//
// // Define the constants to get/set values from context
// public static final String ECF2014_SPEED_VALUE = "ecf2014.speedValue";
// public static final String ECF2014_RPM_VALUE = "ecf2014.rpmValue";
// public static final String ECF2014_TANK_VALUE = "ecf2014.tankValue";
//
// @Inject
// IEclipseContext ctx; // The context where values will be injected
//
// // Physical values
// int speed, rpm, tankLevel;
// int acceleration = 2;
//
// Timer timer = null;
//
// @Inject
// EngineSimulator() {
// this(65);
// }
//
// EngineSimulator(int tankInit) {
// tankLevel = tankInit;
//
// }
//
// public void start() {
// if (timer == null) {
// timer = new Timer();
// timer.scheduleAtFixedRate(new EngineTimerTask(), 1000, 1500);
// }
// }
//
// public void stop() {
// if (timer != null) {
// timer.cancel();
// ctx.set(ECF2014_SPEED_VALUE, 0);
// ctx.set(ECF2014_RPM_VALUE, 0);
//
// }
// timer = null;
// }
//
// @PostConstruct
// void declareInContext() {
// ctx.set(EngineSimulator.class, this);
//
// }
//
// private class EngineTimerTask extends TimerTask {
// @Override
// public void run() {
// speed = speed + acceleration;
// rpm = speed * 75;
//
// if (speed < 0)
// speed = 0;
// if (rpm < 0)
// rpm = 0;
//
// System.out.println("New value for speed : " + speed + " and rpm : "
// + rpm);
// ctx.set(ECF2014_SPEED_VALUE, speed);
// ctx.set(ECF2014_RPM_VALUE, rpm);
// }
// }
//
// /**
// * accelerate or brake
// *
// * @param a
// * acceleration in m/s2
// */
// public void accelerate(int a) {
// acceleration = a;
// }
//
// }
//
// Path: ECF14/ecf14_files/step8-EngineWatcher/EngineWatcher.java
// public class EngineWatcher
// {
// // Define the sent topics
// public static final String ALARM_TOPIC = "Alarm/*";
// public static final String ALARM_RPM_TOO_HIGH = "Alarm/RpmTooHigh";
// public static final String ALARM_SPEED_TOO_HIGH = "Alarm/SpeedTooHigh";
//
// // Get the event broker by injection
// @Inject
// IEventBroker ebroker;
//
// @Optional
// @Inject
// public void checkRpmValue(final @Named(EngineSimulator.ECF2014_RPM_VALUE) int value)
// {
// if (value > 5000)
// {
// // Send an alarm
// Alarm a = new Alarm("rpm is too high (" + value + ")", value);
// ebroker.send(ALARM_RPM_TOO_HIGH, a);
// }
// }
//
// @Optional
// @Inject
// public void checkSpeedValue(final @Named(EngineSimulator.ECF2014_SPEED_VALUE) int value)
// {
// System.out.println("Check speed value for alarm : " + value);
// if (value > 160)
// {
// // Send an alarm
// Alarm a = new Alarm("speed is too high (" + value + ")", value);
// ebroker.send(ALARM_SPEED_TOO_HIGH, a);
// }
// }
//
// }
// Path: ECF14/com.opcoach.ecf2014.engine.ui/src/com/opcoach/ecf2014/engine/ui/parts/DashBoard.java
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.di.UISynchronize;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.nebula.visualization.widgets.figures.GaugeFigure;
import org.eclipse.nebula.visualization.xygraph.util.XYGraphMediaFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import com.opcoach.ecf2014.engine.core.EngineSimulator;
import com.opcoach.ecf2014.engine.core.EngineWatcher;
package com.opcoach.ecf2014.engine.ui.parts;
public class DashBoard
{
private GaugeFigure speedCounter;
private GaugeFigure rpmCounter;
private XYGraphMediaFactory gmfactory;
private static final int COUNTER_SIZE = 200;
private static final int COUNTER_MARGIN = 15;
private Canvas canvas;
@Inject
public DashBoard(MApplication appli)
{
// We will use the application context to store and inject values.
IEclipseContext appliContext = appli.getContext();
// We also need an ImageRegistry for the application
appliContext.set(ImageRegistry.class, new ImageRegistry());
// Step 5 : create and start Engine.
EngineSimulator simu = ContextInjectionFactory.make(EngineSimulator.class, appliContext);
appliContext.set(EngineSimulator.class, simu);
// Step 8 : create the engine alarm watcher and keep a reference on it !
|
EngineWatcher watcher = ContextInjectionFactory.make(EngineWatcher.class, appliContext);
|
opcoach/Conferences
|
ECF14/ecf14_files/step8-EngineWatcher/DashBoard.java
|
// Path: ECF14/ecf14_files/step8-EngineWatcher/EngineWatcher.java
// public class EngineWatcher
// {
// // Define the sent topics
// public static final String ALARM_TOPIC = "Alarm/*";
// public static final String ALARM_RPM_TOO_HIGH = "Alarm/RpmTooHigh";
// public static final String ALARM_SPEED_TOO_HIGH = "Alarm/SpeedTooHigh";
//
// // Get the event broker by injection
// @Inject
// IEventBroker ebroker;
//
// @Optional
// @Inject
// public void checkRpmValue(final @Named(EngineSimulator.ECF2014_RPM_VALUE) int value)
// {
// if (value > 5000)
// {
// // Send an alarm
// Alarm a = new Alarm("rpm is too high (" + value + ")", value);
// ebroker.send(ALARM_RPM_TOO_HIGH, a);
// }
// }
//
// @Optional
// @Inject
// public void checkSpeedValue(final @Named(EngineSimulator.ECF2014_SPEED_VALUE) int value)
// {
// System.out.println("Check speed value for alarm : " + value);
// if (value > 160)
// {
// // Send an alarm
// Alarm a = new Alarm("speed is too high (" + value + ")", value);
// ebroker.send(ALARM_SPEED_TOO_HIGH, a);
// }
// }
//
// }
//
// Path: ECF14/ecf14_files/step5-SimulatorEngine/EngineSimulator.java
// public class EngineSimulator {
//
// // Define the constants to get/set values from context
// public static final String ECF2014_SPEED_VALUE = "ecf2014.speedValue";
// public static final String ECF2014_RPM_VALUE = "ecf2014.rpmValue";
// public static final String ECF2014_TANK_VALUE = "ecf2014.tankValue";
//
// @Inject
// IEclipseContext ctx; // The context where values will be injected
//
// // Physical values
// int speed, rpm, tankLevel;
// int acceleration = 2;
//
// Timer timer = null;
//
// @Inject
// EngineSimulator() {
// this(65);
// }
//
// EngineSimulator(int tankInit) {
// tankLevel = tankInit;
//
// }
//
// public void start() {
// if (timer == null) {
// timer = new Timer();
// timer.scheduleAtFixedRate(new EngineTimerTask(), 1000, 1500);
// }
// }
//
// public void stop() {
// if (timer != null) {
// timer.cancel();
// ctx.set(ECF2014_SPEED_VALUE, 0);
// ctx.set(ECF2014_RPM_VALUE, 0);
//
// }
// timer = null;
// }
//
// @PostConstruct
// void declareInContext() {
// ctx.set(EngineSimulator.class, this);
//
// }
//
// private class EngineTimerTask extends TimerTask {
// @Override
// public void run() {
// speed = speed + acceleration;
// rpm = speed * 75;
//
// if (speed < 0)
// speed = 0;
// if (rpm < 0)
// rpm = 0;
//
// System.out.println("New value for speed : " + speed + " and rpm : "
// + rpm);
// ctx.set(ECF2014_SPEED_VALUE, speed);
// ctx.set(ECF2014_RPM_VALUE, rpm);
// }
// }
//
// /**
// * accelerate or brake
// *
// * @param a
// * acceleration in m/s2
// */
// public void accelerate(int a) {
// acceleration = a;
// }
//
// }
|
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.GridLayout;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.di.UISynchronize;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.nebula.visualization.widgets.figures.GaugeFigure;
import org.eclipse.nebula.visualization.xygraph.util.XYGraphMediaFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import com.opcoach.ecf2014.engine.core.EngineWatcher;
import com.opcoach.ecf2014.engine.core.EngineSimulator;
|
package com.opcoach.ecf14.eap.parts;
public class DashBoard
{
private GaugeFigure speedCounter;
private GaugeFigure rpmCounter;
private XYGraphMediaFactory gmfactory;
private Canvas canvas;
@Inject
public DashBoard(MApplication appli)
{
// We will use the application context to store and inject values.
IEclipseContext appliContext = appli.getContext();
// Step 5 : create and start Engine.
|
// Path: ECF14/ecf14_files/step8-EngineWatcher/EngineWatcher.java
// public class EngineWatcher
// {
// // Define the sent topics
// public static final String ALARM_TOPIC = "Alarm/*";
// public static final String ALARM_RPM_TOO_HIGH = "Alarm/RpmTooHigh";
// public static final String ALARM_SPEED_TOO_HIGH = "Alarm/SpeedTooHigh";
//
// // Get the event broker by injection
// @Inject
// IEventBroker ebroker;
//
// @Optional
// @Inject
// public void checkRpmValue(final @Named(EngineSimulator.ECF2014_RPM_VALUE) int value)
// {
// if (value > 5000)
// {
// // Send an alarm
// Alarm a = new Alarm("rpm is too high (" + value + ")", value);
// ebroker.send(ALARM_RPM_TOO_HIGH, a);
// }
// }
//
// @Optional
// @Inject
// public void checkSpeedValue(final @Named(EngineSimulator.ECF2014_SPEED_VALUE) int value)
// {
// System.out.println("Check speed value for alarm : " + value);
// if (value > 160)
// {
// // Send an alarm
// Alarm a = new Alarm("speed is too high (" + value + ")", value);
// ebroker.send(ALARM_SPEED_TOO_HIGH, a);
// }
// }
//
// }
//
// Path: ECF14/ecf14_files/step5-SimulatorEngine/EngineSimulator.java
// public class EngineSimulator {
//
// // Define the constants to get/set values from context
// public static final String ECF2014_SPEED_VALUE = "ecf2014.speedValue";
// public static final String ECF2014_RPM_VALUE = "ecf2014.rpmValue";
// public static final String ECF2014_TANK_VALUE = "ecf2014.tankValue";
//
// @Inject
// IEclipseContext ctx; // The context where values will be injected
//
// // Physical values
// int speed, rpm, tankLevel;
// int acceleration = 2;
//
// Timer timer = null;
//
// @Inject
// EngineSimulator() {
// this(65);
// }
//
// EngineSimulator(int tankInit) {
// tankLevel = tankInit;
//
// }
//
// public void start() {
// if (timer == null) {
// timer = new Timer();
// timer.scheduleAtFixedRate(new EngineTimerTask(), 1000, 1500);
// }
// }
//
// public void stop() {
// if (timer != null) {
// timer.cancel();
// ctx.set(ECF2014_SPEED_VALUE, 0);
// ctx.set(ECF2014_RPM_VALUE, 0);
//
// }
// timer = null;
// }
//
// @PostConstruct
// void declareInContext() {
// ctx.set(EngineSimulator.class, this);
//
// }
//
// private class EngineTimerTask extends TimerTask {
// @Override
// public void run() {
// speed = speed + acceleration;
// rpm = speed * 75;
//
// if (speed < 0)
// speed = 0;
// if (rpm < 0)
// rpm = 0;
//
// System.out.println("New value for speed : " + speed + " and rpm : "
// + rpm);
// ctx.set(ECF2014_SPEED_VALUE, speed);
// ctx.set(ECF2014_RPM_VALUE, rpm);
// }
// }
//
// /**
// * accelerate or brake
// *
// * @param a
// * acceleration in m/s2
// */
// public void accelerate(int a) {
// acceleration = a;
// }
//
// }
// Path: ECF14/ecf14_files/step8-EngineWatcher/DashBoard.java
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.GridLayout;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.di.UISynchronize;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.nebula.visualization.widgets.figures.GaugeFigure;
import org.eclipse.nebula.visualization.xygraph.util.XYGraphMediaFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import com.opcoach.ecf2014.engine.core.EngineWatcher;
import com.opcoach.ecf2014.engine.core.EngineSimulator;
package com.opcoach.ecf14.eap.parts;
public class DashBoard
{
private GaugeFigure speedCounter;
private GaugeFigure rpmCounter;
private XYGraphMediaFactory gmfactory;
private Canvas canvas;
@Inject
public DashBoard(MApplication appli)
{
// We will use the application context to store and inject values.
IEclipseContext appliContext = appli.getContext();
// Step 5 : create and start Engine.
|
EngineSimulator simu = ContextInjectionFactory.make(EngineSimulator.class, appliContext);
|
opcoach/Conferences
|
ECF14/ecf14_files/step8-EngineWatcher/DashBoard.java
|
// Path: ECF14/ecf14_files/step8-EngineWatcher/EngineWatcher.java
// public class EngineWatcher
// {
// // Define the sent topics
// public static final String ALARM_TOPIC = "Alarm/*";
// public static final String ALARM_RPM_TOO_HIGH = "Alarm/RpmTooHigh";
// public static final String ALARM_SPEED_TOO_HIGH = "Alarm/SpeedTooHigh";
//
// // Get the event broker by injection
// @Inject
// IEventBroker ebroker;
//
// @Optional
// @Inject
// public void checkRpmValue(final @Named(EngineSimulator.ECF2014_RPM_VALUE) int value)
// {
// if (value > 5000)
// {
// // Send an alarm
// Alarm a = new Alarm("rpm is too high (" + value + ")", value);
// ebroker.send(ALARM_RPM_TOO_HIGH, a);
// }
// }
//
// @Optional
// @Inject
// public void checkSpeedValue(final @Named(EngineSimulator.ECF2014_SPEED_VALUE) int value)
// {
// System.out.println("Check speed value for alarm : " + value);
// if (value > 160)
// {
// // Send an alarm
// Alarm a = new Alarm("speed is too high (" + value + ")", value);
// ebroker.send(ALARM_SPEED_TOO_HIGH, a);
// }
// }
//
// }
//
// Path: ECF14/ecf14_files/step5-SimulatorEngine/EngineSimulator.java
// public class EngineSimulator {
//
// // Define the constants to get/set values from context
// public static final String ECF2014_SPEED_VALUE = "ecf2014.speedValue";
// public static final String ECF2014_RPM_VALUE = "ecf2014.rpmValue";
// public static final String ECF2014_TANK_VALUE = "ecf2014.tankValue";
//
// @Inject
// IEclipseContext ctx; // The context where values will be injected
//
// // Physical values
// int speed, rpm, tankLevel;
// int acceleration = 2;
//
// Timer timer = null;
//
// @Inject
// EngineSimulator() {
// this(65);
// }
//
// EngineSimulator(int tankInit) {
// tankLevel = tankInit;
//
// }
//
// public void start() {
// if (timer == null) {
// timer = new Timer();
// timer.scheduleAtFixedRate(new EngineTimerTask(), 1000, 1500);
// }
// }
//
// public void stop() {
// if (timer != null) {
// timer.cancel();
// ctx.set(ECF2014_SPEED_VALUE, 0);
// ctx.set(ECF2014_RPM_VALUE, 0);
//
// }
// timer = null;
// }
//
// @PostConstruct
// void declareInContext() {
// ctx.set(EngineSimulator.class, this);
//
// }
//
// private class EngineTimerTask extends TimerTask {
// @Override
// public void run() {
// speed = speed + acceleration;
// rpm = speed * 75;
//
// if (speed < 0)
// speed = 0;
// if (rpm < 0)
// rpm = 0;
//
// System.out.println("New value for speed : " + speed + " and rpm : "
// + rpm);
// ctx.set(ECF2014_SPEED_VALUE, speed);
// ctx.set(ECF2014_RPM_VALUE, rpm);
// }
// }
//
// /**
// * accelerate or brake
// *
// * @param a
// * acceleration in m/s2
// */
// public void accelerate(int a) {
// acceleration = a;
// }
//
// }
|
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.GridLayout;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.di.UISynchronize;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.nebula.visualization.widgets.figures.GaugeFigure;
import org.eclipse.nebula.visualization.xygraph.util.XYGraphMediaFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import com.opcoach.ecf2014.engine.core.EngineWatcher;
import com.opcoach.ecf2014.engine.core.EngineSimulator;
|
package com.opcoach.ecf14.eap.parts;
public class DashBoard
{
private GaugeFigure speedCounter;
private GaugeFigure rpmCounter;
private XYGraphMediaFactory gmfactory;
private Canvas canvas;
@Inject
public DashBoard(MApplication appli)
{
// We will use the application context to store and inject values.
IEclipseContext appliContext = appli.getContext();
// Step 5 : create and start Engine.
EngineSimulator simu = ContextInjectionFactory.make(EngineSimulator.class, appliContext);
appliContext.set(EngineSimulator.class, simu);
// Step 8 : create the engine alarm watcher and keep a reference on it !
|
// Path: ECF14/ecf14_files/step8-EngineWatcher/EngineWatcher.java
// public class EngineWatcher
// {
// // Define the sent topics
// public static final String ALARM_TOPIC = "Alarm/*";
// public static final String ALARM_RPM_TOO_HIGH = "Alarm/RpmTooHigh";
// public static final String ALARM_SPEED_TOO_HIGH = "Alarm/SpeedTooHigh";
//
// // Get the event broker by injection
// @Inject
// IEventBroker ebroker;
//
// @Optional
// @Inject
// public void checkRpmValue(final @Named(EngineSimulator.ECF2014_RPM_VALUE) int value)
// {
// if (value > 5000)
// {
// // Send an alarm
// Alarm a = new Alarm("rpm is too high (" + value + ")", value);
// ebroker.send(ALARM_RPM_TOO_HIGH, a);
// }
// }
//
// @Optional
// @Inject
// public void checkSpeedValue(final @Named(EngineSimulator.ECF2014_SPEED_VALUE) int value)
// {
// System.out.println("Check speed value for alarm : " + value);
// if (value > 160)
// {
// // Send an alarm
// Alarm a = new Alarm("speed is too high (" + value + ")", value);
// ebroker.send(ALARM_SPEED_TOO_HIGH, a);
// }
// }
//
// }
//
// Path: ECF14/ecf14_files/step5-SimulatorEngine/EngineSimulator.java
// public class EngineSimulator {
//
// // Define the constants to get/set values from context
// public static final String ECF2014_SPEED_VALUE = "ecf2014.speedValue";
// public static final String ECF2014_RPM_VALUE = "ecf2014.rpmValue";
// public static final String ECF2014_TANK_VALUE = "ecf2014.tankValue";
//
// @Inject
// IEclipseContext ctx; // The context where values will be injected
//
// // Physical values
// int speed, rpm, tankLevel;
// int acceleration = 2;
//
// Timer timer = null;
//
// @Inject
// EngineSimulator() {
// this(65);
// }
//
// EngineSimulator(int tankInit) {
// tankLevel = tankInit;
//
// }
//
// public void start() {
// if (timer == null) {
// timer = new Timer();
// timer.scheduleAtFixedRate(new EngineTimerTask(), 1000, 1500);
// }
// }
//
// public void stop() {
// if (timer != null) {
// timer.cancel();
// ctx.set(ECF2014_SPEED_VALUE, 0);
// ctx.set(ECF2014_RPM_VALUE, 0);
//
// }
// timer = null;
// }
//
// @PostConstruct
// void declareInContext() {
// ctx.set(EngineSimulator.class, this);
//
// }
//
// private class EngineTimerTask extends TimerTask {
// @Override
// public void run() {
// speed = speed + acceleration;
// rpm = speed * 75;
//
// if (speed < 0)
// speed = 0;
// if (rpm < 0)
// rpm = 0;
//
// System.out.println("New value for speed : " + speed + " and rpm : "
// + rpm);
// ctx.set(ECF2014_SPEED_VALUE, speed);
// ctx.set(ECF2014_RPM_VALUE, rpm);
// }
// }
//
// /**
// * accelerate or brake
// *
// * @param a
// * acceleration in m/s2
// */
// public void accelerate(int a) {
// acceleration = a;
// }
//
// }
// Path: ECF14/ecf14_files/step8-EngineWatcher/DashBoard.java
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.GridLayout;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.di.UISynchronize;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.nebula.visualization.widgets.figures.GaugeFigure;
import org.eclipse.nebula.visualization.xygraph.util.XYGraphMediaFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import com.opcoach.ecf2014.engine.core.EngineWatcher;
import com.opcoach.ecf2014.engine.core.EngineSimulator;
package com.opcoach.ecf14.eap.parts;
public class DashBoard
{
private GaugeFigure speedCounter;
private GaugeFigure rpmCounter;
private XYGraphMediaFactory gmfactory;
private Canvas canvas;
@Inject
public DashBoard(MApplication appli)
{
// We will use the application context to store and inject values.
IEclipseContext appliContext = appli.getContext();
// Step 5 : create and start Engine.
EngineSimulator simu = ContextInjectionFactory.make(EngineSimulator.class, appliContext);
appliContext.set(EngineSimulator.class, simu);
// Step 8 : create the engine alarm watcher and keep a reference on it !
|
EngineWatcher watcher = ContextInjectionFactory.make(EngineWatcher.class, appliContext);
|
opcoach/Conferences
|
ECF14/ecf14_files/step6-EngineControlPanel/EngineControlPart.java
|
// Path: ECF14/ecf14_files/step5-SimulatorEngine/EngineSimulator.java
// public class EngineSimulator {
//
// // Define the constants to get/set values from context
// public static final String ECF2014_SPEED_VALUE = "ecf2014.speedValue";
// public static final String ECF2014_RPM_VALUE = "ecf2014.rpmValue";
// public static final String ECF2014_TANK_VALUE = "ecf2014.tankValue";
//
// @Inject
// IEclipseContext ctx; // The context where values will be injected
//
// // Physical values
// int speed, rpm, tankLevel;
// int acceleration = 2;
//
// Timer timer = null;
//
// @Inject
// EngineSimulator() {
// this(65);
// }
//
// EngineSimulator(int tankInit) {
// tankLevel = tankInit;
//
// }
//
// public void start() {
// if (timer == null) {
// timer = new Timer();
// timer.scheduleAtFixedRate(new EngineTimerTask(), 1000, 1500);
// }
// }
//
// public void stop() {
// if (timer != null) {
// timer.cancel();
// ctx.set(ECF2014_SPEED_VALUE, 0);
// ctx.set(ECF2014_RPM_VALUE, 0);
//
// }
// timer = null;
// }
//
// @PostConstruct
// void declareInContext() {
// ctx.set(EngineSimulator.class, this);
//
// }
//
// private class EngineTimerTask extends TimerTask {
// @Override
// public void run() {
// speed = speed + acceleration;
// rpm = speed * 75;
//
// if (speed < 0)
// speed = 0;
// if (rpm < 0)
// rpm = 0;
//
// System.out.println("New value for speed : " + speed + " and rpm : "
// + rpm);
// ctx.set(ECF2014_SPEED_VALUE, speed);
// ctx.set(ECF2014_RPM_VALUE, rpm);
// }
// }
//
// /**
// * accelerate or brake
// *
// * @param a
// * acceleration in m/s2
// */
// public void accelerate(int a) {
// acceleration = a;
// }
//
// }
|
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.nebula.visualization.widgets.datadefinition.IManualValueChangeListener;
import org.eclipse.nebula.visualization.widgets.figures.ScaledSliderFigure;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import com.opcoach.ecf2014.engine.core.EngineSimulator;
|
package com.opcoach.ecf2014.engine.ui.parts;
public class EngineControlPart
{
@Inject
@Optional
|
// Path: ECF14/ecf14_files/step5-SimulatorEngine/EngineSimulator.java
// public class EngineSimulator {
//
// // Define the constants to get/set values from context
// public static final String ECF2014_SPEED_VALUE = "ecf2014.speedValue";
// public static final String ECF2014_RPM_VALUE = "ecf2014.rpmValue";
// public static final String ECF2014_TANK_VALUE = "ecf2014.tankValue";
//
// @Inject
// IEclipseContext ctx; // The context where values will be injected
//
// // Physical values
// int speed, rpm, tankLevel;
// int acceleration = 2;
//
// Timer timer = null;
//
// @Inject
// EngineSimulator() {
// this(65);
// }
//
// EngineSimulator(int tankInit) {
// tankLevel = tankInit;
//
// }
//
// public void start() {
// if (timer == null) {
// timer = new Timer();
// timer.scheduleAtFixedRate(new EngineTimerTask(), 1000, 1500);
// }
// }
//
// public void stop() {
// if (timer != null) {
// timer.cancel();
// ctx.set(ECF2014_SPEED_VALUE, 0);
// ctx.set(ECF2014_RPM_VALUE, 0);
//
// }
// timer = null;
// }
//
// @PostConstruct
// void declareInContext() {
// ctx.set(EngineSimulator.class, this);
//
// }
//
// private class EngineTimerTask extends TimerTask {
// @Override
// public void run() {
// speed = speed + acceleration;
// rpm = speed * 75;
//
// if (speed < 0)
// speed = 0;
// if (rpm < 0)
// rpm = 0;
//
// System.out.println("New value for speed : " + speed + " and rpm : "
// + rpm);
// ctx.set(ECF2014_SPEED_VALUE, speed);
// ctx.set(ECF2014_RPM_VALUE, rpm);
// }
// }
//
// /**
// * accelerate or brake
// *
// * @param a
// * acceleration in m/s2
// */
// public void accelerate(int a) {
// acceleration = a;
// }
//
// }
// Path: ECF14/ecf14_files/step6-EngineControlPanel/EngineControlPart.java
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.nebula.visualization.widgets.datadefinition.IManualValueChangeListener;
import org.eclipse.nebula.visualization.widgets.figures.ScaledSliderFigure;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import com.opcoach.ecf2014.engine.core.EngineSimulator;
package com.opcoach.ecf2014.engine.ui.parts;
public class EngineControlPart
{
@Inject
@Optional
|
EngineSimulator engineSimu;
|
opcoach/Conferences
|
ECF14/com.opcoach.ecf2014.engine.core/src/com/opcoach/ecf2014/engine/core/EngineContextFunction.java
|
// Path: ECF14/com.opcoach.ecf2014.engine.core/src/com/opcoach/ecf2014/engine/core/impl/DefaultEngineLogger.java
// public class DefaultEngineLogger implements IEngineLogger
// {
//
// private SimpleDateFormat sdf;
//
// @Inject
// public DefaultEngineLogger() {
// sdf = new SimpleDateFormat("HH:mm:ss");
// }
//
// @Override
// public void logMessage(String message)
// {
//
// System.out.println("-> Engine Logger : " + sdf.format(new Date()) + " " + message);
// }
//
// }
|
import org.eclipse.e4.core.contexts.ContextFunction;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.ui.model.application.MApplication;
import com.opcoach.ecf2014.engine.core.impl.DefaultEngineLogger;
|
package com.opcoach.ecf2014.engine.core;
public class EngineContextFunction extends ContextFunction
{
@Override
public Object compute(IEclipseContext context, String contextKey)
{
System.out.println("---> Enter in EngineContextFunction");
|
// Path: ECF14/com.opcoach.ecf2014.engine.core/src/com/opcoach/ecf2014/engine/core/impl/DefaultEngineLogger.java
// public class DefaultEngineLogger implements IEngineLogger
// {
//
// private SimpleDateFormat sdf;
//
// @Inject
// public DefaultEngineLogger() {
// sdf = new SimpleDateFormat("HH:mm:ss");
// }
//
// @Override
// public void logMessage(String message)
// {
//
// System.out.println("-> Engine Logger : " + sdf.format(new Date()) + " " + message);
// }
//
// }
// Path: ECF14/com.opcoach.ecf2014.engine.core/src/com/opcoach/ecf2014/engine/core/EngineContextFunction.java
import org.eclipse.e4.core.contexts.ContextFunction;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.ui.model.application.MApplication;
import com.opcoach.ecf2014.engine.core.impl.DefaultEngineLogger;
package com.opcoach.ecf2014.engine.core;
public class EngineContextFunction extends ContextFunction
{
@Override
public Object compute(IEclipseContext context, String contextKey)
{
System.out.println("---> Enter in EngineContextFunction");
|
IEngineLogger result = ContextInjectionFactory.make(DefaultEngineLogger.class, context);
|
opcoach/Conferences
|
ECF14/ecf14_files/step5-SimulatorEngine/DashBoard.java
|
// Path: ECF14/ecf14_files/step5-SimulatorEngine/EngineSimulator.java
// public class EngineSimulator {
//
// // Define the constants to get/set values from context
// public static final String ECF2014_SPEED_VALUE = "ecf2014.speedValue";
// public static final String ECF2014_RPM_VALUE = "ecf2014.rpmValue";
// public static final String ECF2014_TANK_VALUE = "ecf2014.tankValue";
//
// @Inject
// IEclipseContext ctx; // The context where values will be injected
//
// // Physical values
// int speed, rpm, tankLevel;
// int acceleration = 2;
//
// Timer timer = null;
//
// @Inject
// EngineSimulator() {
// this(65);
// }
//
// EngineSimulator(int tankInit) {
// tankLevel = tankInit;
//
// }
//
// public void start() {
// if (timer == null) {
// timer = new Timer();
// timer.scheduleAtFixedRate(new EngineTimerTask(), 1000, 1500);
// }
// }
//
// public void stop() {
// if (timer != null) {
// timer.cancel();
// ctx.set(ECF2014_SPEED_VALUE, 0);
// ctx.set(ECF2014_RPM_VALUE, 0);
//
// }
// timer = null;
// }
//
// @PostConstruct
// void declareInContext() {
// ctx.set(EngineSimulator.class, this);
//
// }
//
// private class EngineTimerTask extends TimerTask {
// @Override
// public void run() {
// speed = speed + acceleration;
// rpm = speed * 75;
//
// if (speed < 0)
// speed = 0;
// if (rpm < 0)
// rpm = 0;
//
// System.out.println("New value for speed : " + speed + " and rpm : "
// + rpm);
// ctx.set(ECF2014_SPEED_VALUE, speed);
// ctx.set(ECF2014_RPM_VALUE, rpm);
// }
// }
//
// /**
// * accelerate or brake
// *
// * @param a
// * acceleration in m/s2
// */
// public void accelerate(int a) {
// acceleration = a;
// }
//
// }
|
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.GridLayout;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.di.UISynchronize;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.nebula.visualization.widgets.figures.GaugeFigure;
import org.eclipse.nebula.visualization.xygraph.util.XYGraphMediaFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import com.opcoach.ecf2014.engine.core.EngineSimulator;
|
package com.opcoach.ecf14.eap.parts;
public class DashBoard
{
private GaugeFigure speedCounter;
private GaugeFigure rpmCounter;
private XYGraphMediaFactory gmfactory;
private Canvas canvas;
@Inject
public DashBoard(MApplication appli)
{
// Step 5 : create and start Engine.
|
// Path: ECF14/ecf14_files/step5-SimulatorEngine/EngineSimulator.java
// public class EngineSimulator {
//
// // Define the constants to get/set values from context
// public static final String ECF2014_SPEED_VALUE = "ecf2014.speedValue";
// public static final String ECF2014_RPM_VALUE = "ecf2014.rpmValue";
// public static final String ECF2014_TANK_VALUE = "ecf2014.tankValue";
//
// @Inject
// IEclipseContext ctx; // The context where values will be injected
//
// // Physical values
// int speed, rpm, tankLevel;
// int acceleration = 2;
//
// Timer timer = null;
//
// @Inject
// EngineSimulator() {
// this(65);
// }
//
// EngineSimulator(int tankInit) {
// tankLevel = tankInit;
//
// }
//
// public void start() {
// if (timer == null) {
// timer = new Timer();
// timer.scheduleAtFixedRate(new EngineTimerTask(), 1000, 1500);
// }
// }
//
// public void stop() {
// if (timer != null) {
// timer.cancel();
// ctx.set(ECF2014_SPEED_VALUE, 0);
// ctx.set(ECF2014_RPM_VALUE, 0);
//
// }
// timer = null;
// }
//
// @PostConstruct
// void declareInContext() {
// ctx.set(EngineSimulator.class, this);
//
// }
//
// private class EngineTimerTask extends TimerTask {
// @Override
// public void run() {
// speed = speed + acceleration;
// rpm = speed * 75;
//
// if (speed < 0)
// speed = 0;
// if (rpm < 0)
// rpm = 0;
//
// System.out.println("New value for speed : " + speed + " and rpm : "
// + rpm);
// ctx.set(ECF2014_SPEED_VALUE, speed);
// ctx.set(ECF2014_RPM_VALUE, rpm);
// }
// }
//
// /**
// * accelerate or brake
// *
// * @param a
// * acceleration in m/s2
// */
// public void accelerate(int a) {
// acceleration = a;
// }
//
// }
// Path: ECF14/ecf14_files/step5-SimulatorEngine/DashBoard.java
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.GridLayout;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.di.UISynchronize;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.nebula.visualization.widgets.figures.GaugeFigure;
import org.eclipse.nebula.visualization.xygraph.util.XYGraphMediaFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import com.opcoach.ecf2014.engine.core.EngineSimulator;
package com.opcoach.ecf14.eap.parts;
public class DashBoard
{
private GaugeFigure speedCounter;
private GaugeFigure rpmCounter;
private XYGraphMediaFactory gmfactory;
private Canvas canvas;
@Inject
public DashBoard(MApplication appli)
{
// Step 5 : create and start Engine.
|
EngineSimulator simu = ContextInjectionFactory.make(EngineSimulator.class, appli.getContext());
|
opcoach/Conferences
|
ECF14/com.opcoach.ecf2014.engine.ui/src/com/opcoach/ecf2014/engine/ui/parts/EngineControlPart.java
|
// Path: ECF14/ecf14_files/step5-SimulatorEngine/EngineSimulator.java
// public class EngineSimulator {
//
// // Define the constants to get/set values from context
// public static final String ECF2014_SPEED_VALUE = "ecf2014.speedValue";
// public static final String ECF2014_RPM_VALUE = "ecf2014.rpmValue";
// public static final String ECF2014_TANK_VALUE = "ecf2014.tankValue";
//
// @Inject
// IEclipseContext ctx; // The context where values will be injected
//
// // Physical values
// int speed, rpm, tankLevel;
// int acceleration = 2;
//
// Timer timer = null;
//
// @Inject
// EngineSimulator() {
// this(65);
// }
//
// EngineSimulator(int tankInit) {
// tankLevel = tankInit;
//
// }
//
// public void start() {
// if (timer == null) {
// timer = new Timer();
// timer.scheduleAtFixedRate(new EngineTimerTask(), 1000, 1500);
// }
// }
//
// public void stop() {
// if (timer != null) {
// timer.cancel();
// ctx.set(ECF2014_SPEED_VALUE, 0);
// ctx.set(ECF2014_RPM_VALUE, 0);
//
// }
// timer = null;
// }
//
// @PostConstruct
// void declareInContext() {
// ctx.set(EngineSimulator.class, this);
//
// }
//
// private class EngineTimerTask extends TimerTask {
// @Override
// public void run() {
// speed = speed + acceleration;
// rpm = speed * 75;
//
// if (speed < 0)
// speed = 0;
// if (rpm < 0)
// rpm = 0;
//
// System.out.println("New value for speed : " + speed + " and rpm : "
// + rpm);
// ctx.set(ECF2014_SPEED_VALUE, speed);
// ctx.set(ECF2014_RPM_VALUE, rpm);
// }
// }
//
// /**
// * accelerate or brake
// *
// * @param a
// * acceleration in m/s2
// */
// public void accelerate(int a) {
// acceleration = a;
// }
//
// }
|
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.nebula.visualization.widgets.datadefinition.IManualValueChangeListener;
import org.eclipse.nebula.visualization.widgets.figures.ScaledSliderFigure;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;
import com.opcoach.ecf2014.engine.core.EngineSimulator;
|
package com.opcoach.ecf2014.engine.ui.parts;
public class EngineControlPart
{
private static final String IMG_START = "icons/startButton.png";
private static final String IMG_STOP = "icons/stopButton.png";
// private static final String IMG_FUNCTION = "icons/functionButton.png";
@Inject
|
// Path: ECF14/ecf14_files/step5-SimulatorEngine/EngineSimulator.java
// public class EngineSimulator {
//
// // Define the constants to get/set values from context
// public static final String ECF2014_SPEED_VALUE = "ecf2014.speedValue";
// public static final String ECF2014_RPM_VALUE = "ecf2014.rpmValue";
// public static final String ECF2014_TANK_VALUE = "ecf2014.tankValue";
//
// @Inject
// IEclipseContext ctx; // The context where values will be injected
//
// // Physical values
// int speed, rpm, tankLevel;
// int acceleration = 2;
//
// Timer timer = null;
//
// @Inject
// EngineSimulator() {
// this(65);
// }
//
// EngineSimulator(int tankInit) {
// tankLevel = tankInit;
//
// }
//
// public void start() {
// if (timer == null) {
// timer = new Timer();
// timer.scheduleAtFixedRate(new EngineTimerTask(), 1000, 1500);
// }
// }
//
// public void stop() {
// if (timer != null) {
// timer.cancel();
// ctx.set(ECF2014_SPEED_VALUE, 0);
// ctx.set(ECF2014_RPM_VALUE, 0);
//
// }
// timer = null;
// }
//
// @PostConstruct
// void declareInContext() {
// ctx.set(EngineSimulator.class, this);
//
// }
//
// private class EngineTimerTask extends TimerTask {
// @Override
// public void run() {
// speed = speed + acceleration;
// rpm = speed * 75;
//
// if (speed < 0)
// speed = 0;
// if (rpm < 0)
// rpm = 0;
//
// System.out.println("New value for speed : " + speed + " and rpm : "
// + rpm);
// ctx.set(ECF2014_SPEED_VALUE, speed);
// ctx.set(ECF2014_RPM_VALUE, rpm);
// }
// }
//
// /**
// * accelerate or brake
// *
// * @param a
// * acceleration in m/s2
// */
// public void accelerate(int a) {
// acceleration = a;
// }
//
// }
// Path: ECF14/com.opcoach.ecf2014.engine.ui/src/com/opcoach/ecf2014/engine/ui/parts/EngineControlPart.java
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.nebula.visualization.widgets.datadefinition.IManualValueChangeListener;
import org.eclipse.nebula.visualization.widgets.figures.ScaledSliderFigure;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;
import com.opcoach.ecf2014.engine.core.EngineSimulator;
package com.opcoach.ecf2014.engine.ui.parts;
public class EngineControlPart
{
private static final String IMG_START = "icons/startButton.png";
private static final String IMG_STOP = "icons/stopButton.png";
// private static final String IMG_FUNCTION = "icons/functionButton.png";
@Inject
|
private EngineSimulator engineSimu;
|
advantageous/ddp-client-java
|
ddp-client/src/main/java/io/advantageous/ddp/subscription/message/NoSubscriptionMessage.java
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPError.java
// public class DDPError {
//
// private final int error;
//
// private final String reason;
//
// private final String details;
//
// public DDPError(final int error, final String reason, final String details) {
// this.error = error;
// this.reason = reason;
// this.details = details;
// }
//
// public int getError() {
// return error;
// }
//
// public String getReason() {
// return reason;
// }
//
// public String getDetails() {
// return details;
// }
//
// @Override
// public String toString() {
// return "DDPError{" +
// "error=" + error +
// ", reason='" + reason + '\'' +
// ", details='" + details + '\'' +
// '}';
// }
// }
|
import io.advantageous.ddp.DDPError;
|
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp.subscription.message;
/**
* No Subscription Message
*
* @author geoffc@gmail.com
* @since 1/17/14 at 6:10 PM.
*/
public class NoSubscriptionMessage {
private String id;
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPError.java
// public class DDPError {
//
// private final int error;
//
// private final String reason;
//
// private final String details;
//
// public DDPError(final int error, final String reason, final String details) {
// this.error = error;
// this.reason = reason;
// this.details = details;
// }
//
// public int getError() {
// return error;
// }
//
// public String getReason() {
// return reason;
// }
//
// public String getDetails() {
// return details;
// }
//
// @Override
// public String toString() {
// return "DDPError{" +
// "error=" + error +
// ", reason='" + reason + '\'' +
// ", details='" + details + '\'' +
// '}';
// }
// }
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/NoSubscriptionMessage.java
import io.advantageous.ddp.DDPError;
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp.subscription.message;
/**
* No Subscription Message
*
* @author geoffc@gmail.com
* @since 1/17/14 at 6:10 PM.
*/
public class NoSubscriptionMessage {
private String id;
|
private DDPError error;
|
advantageous/ddp-client-java
|
ddp-client/src/main/java/io/advantageous/ddp/repository/MeteorCollectionRepository.java
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/rpc/RPCClient.java
// public interface RPCClient {
//
// void call(String methodName,
// Object[] params,
// SuccessHandler<Object> successHandler,
// FailureHandler failureHandler) throws IOException;
//
// interface SuccessHandler<T> {
// void onSuccess(T result);
// }
//
// interface FailureHandler {
// void onFailure(DDPError message);
// }
// }
|
import io.advantageous.ddp.rpc.RPCClient;
import java.io.IOException;
import java.util.Map;
|
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp.repository;
/**
* description
*
* @author geoffc@gmail.com
* @since 4/30/14 at 5:24 PM.
*/
public interface MeteorCollectionRepository {
void delete(String collectionName,
String docId) throws IOException;
void delete(String collectionName,
String docId,
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/rpc/RPCClient.java
// public interface RPCClient {
//
// void call(String methodName,
// Object[] params,
// SuccessHandler<Object> successHandler,
// FailureHandler failureHandler) throws IOException;
//
// interface SuccessHandler<T> {
// void onSuccess(T result);
// }
//
// interface FailureHandler {
// void onFailure(DDPError message);
// }
// }
// Path: ddp-client/src/main/java/io/advantageous/ddp/repository/MeteorCollectionRepository.java
import io.advantageous.ddp.rpc.RPCClient;
import java.io.IOException;
import java.util.Map;
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp.repository;
/**
* description
*
* @author geoffc@gmail.com
* @since 4/30/14 at 5:24 PM.
*/
public interface MeteorCollectionRepository {
void delete(String collectionName,
String docId) throws IOException;
void delete(String collectionName,
String docId,
|
RPCClient.SuccessHandler<Object> onSuccess,
|
advantageous/ddp-client-java
|
ddp-client/src/main/java/io/advantageous/ddp/rpc/RPCClient.java
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPError.java
// public class DDPError {
//
// private final int error;
//
// private final String reason;
//
// private final String details;
//
// public DDPError(final int error, final String reason, final String details) {
// this.error = error;
// this.reason = reason;
// this.details = details;
// }
//
// public int getError() {
// return error;
// }
//
// public String getReason() {
// return reason;
// }
//
// public String getDetails() {
// return details;
// }
//
// @Override
// public String toString() {
// return "DDPError{" +
// "error=" + error +
// ", reason='" + reason + '\'' +
// ", details='" + details + '\'' +
// '}';
// }
// }
|
import io.advantageous.ddp.DDPError;
import java.io.IOException;
|
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp.rpc;
/**
* This is a client interface for Meteor's RPC protocol.
*
* @author geoffc@gmail.com
* @since 1/22/14 at 2:01 PM.
*/
public interface RPCClient {
void call(String methodName,
Object[] params,
SuccessHandler<Object> successHandler,
FailureHandler failureHandler) throws IOException;
interface SuccessHandler<T> {
void onSuccess(T result);
}
interface FailureHandler {
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPError.java
// public class DDPError {
//
// private final int error;
//
// private final String reason;
//
// private final String details;
//
// public DDPError(final int error, final String reason, final String details) {
// this.error = error;
// this.reason = reason;
// this.details = details;
// }
//
// public int getError() {
// return error;
// }
//
// public String getReason() {
// return reason;
// }
//
// public String getDetails() {
// return details;
// }
//
// @Override
// public String toString() {
// return "DDPError{" +
// "error=" + error +
// ", reason='" + reason + '\'' +
// ", details='" + details + '\'' +
// '}';
// }
// }
// Path: ddp-client/src/main/java/io/advantageous/ddp/rpc/RPCClient.java
import io.advantageous.ddp.DDPError;
import java.io.IOException;
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp.rpc;
/**
* This is a client interface for Meteor's RPC protocol.
*
* @author geoffc@gmail.com
* @since 1/22/14 at 2:01 PM.
*/
public interface RPCClient {
void call(String methodName,
Object[] params,
SuccessHandler<Object> successHandler,
FailureHandler failureHandler) throws IOException;
interface SuccessHandler<T> {
void onSuccess(T result);
}
interface FailureHandler {
|
void onFailure(DDPError message);
|
advantageous/ddp-client-java
|
ddp-client/src/main/java/io/advantageous/ddp/MessageConverter.java
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/rpc/MethodMessage.java
// public class MethodMessage {
//
// private String method;
//
// private String id;
//
// private Object[] params;
//
// public String getMethod() {
// return method;
// }
//
// public void setMethod(String method) {
// this.method = method;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public Object[] getParams() {
// return params;
// }
//
// public void setParams(Object[] params) {
// this.params = params;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/rpc/ResultMessage.java
// public class ResultMessage {
//
// private String id;
//
// private DDPError error;
//
// private Object result;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public DDPError getError() {
// return error;
// }
//
// public void setError(DDPError error) {
// this.error = error;
// }
//
// public Object getResult() {
// return result;
// }
//
// public void setResult(Object result) {
// this.result = result;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/rpc/UpdatedMessage.java
// public class UpdatedMessage {
//
// private String[] methods;
//
// public String[] getMethods() {
// return methods;
// }
// }
|
import io.advantageous.ddp.rpc.MethodMessage;
import io.advantageous.ddp.rpc.ResultMessage;
import io.advantageous.ddp.rpc.UpdatedMessage;
import io.advantageous.ddp.subscription.message.*;
import java.util.HashMap;
import java.util.Map;
|
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp;
/**
* Interface for converting DDP messages to and from raw string types.
*
* @author geoffc@gmail.com
* @since 1/17/14 at 7:08 PM.
*/
public interface MessageConverter {
public Object fromDDP(String message) throws UnsupportedMessageException;
public String toDDP(Object object);
static class MessageRegistry {
static final Map<String, Class> STRING_CLASS_HASH_MAP = new HashMap<>();
static final Map<Class, String> CLASS_STRING_HASH_MAP = new HashMap<>();
static void register(String name, Class clazz) {
STRING_CLASS_HASH_MAP.put(name, clazz);
CLASS_STRING_HASH_MAP.put(clazz, name);
}
static String get(Class clazz) {
return CLASS_STRING_HASH_MAP.get(clazz);
}
static Class get(String key) {
return STRING_CLASS_HASH_MAP.get(key);
}
static {
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/rpc/MethodMessage.java
// public class MethodMessage {
//
// private String method;
//
// private String id;
//
// private Object[] params;
//
// public String getMethod() {
// return method;
// }
//
// public void setMethod(String method) {
// this.method = method;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public Object[] getParams() {
// return params;
// }
//
// public void setParams(Object[] params) {
// this.params = params;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/rpc/ResultMessage.java
// public class ResultMessage {
//
// private String id;
//
// private DDPError error;
//
// private Object result;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public DDPError getError() {
// return error;
// }
//
// public void setError(DDPError error) {
// this.error = error;
// }
//
// public Object getResult() {
// return result;
// }
//
// public void setResult(Object result) {
// this.result = result;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/rpc/UpdatedMessage.java
// public class UpdatedMessage {
//
// private String[] methods;
//
// public String[] getMethods() {
// return methods;
// }
// }
// Path: ddp-client/src/main/java/io/advantageous/ddp/MessageConverter.java
import io.advantageous.ddp.rpc.MethodMessage;
import io.advantageous.ddp.rpc.ResultMessage;
import io.advantageous.ddp.rpc.UpdatedMessage;
import io.advantageous.ddp.subscription.message.*;
import java.util.HashMap;
import java.util.Map;
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp;
/**
* Interface for converting DDP messages to and from raw string types.
*
* @author geoffc@gmail.com
* @since 1/17/14 at 7:08 PM.
*/
public interface MessageConverter {
public Object fromDDP(String message) throws UnsupportedMessageException;
public String toDDP(Object object);
static class MessageRegistry {
static final Map<String, Class> STRING_CLASS_HASH_MAP = new HashMap<>();
static final Map<Class, String> CLASS_STRING_HASH_MAP = new HashMap<>();
static void register(String name, Class clazz) {
STRING_CLASS_HASH_MAP.put(name, clazz);
CLASS_STRING_HASH_MAP.put(clazz, name);
}
static String get(Class clazz) {
return CLASS_STRING_HASH_MAP.get(clazz);
}
static Class get(String key) {
return STRING_CLASS_HASH_MAP.get(key);
}
static {
|
register("method", MethodMessage.class);
|
advantageous/ddp-client-java
|
ddp-client/src/main/java/io/advantageous/ddp/MessageConverter.java
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/rpc/MethodMessage.java
// public class MethodMessage {
//
// private String method;
//
// private String id;
//
// private Object[] params;
//
// public String getMethod() {
// return method;
// }
//
// public void setMethod(String method) {
// this.method = method;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public Object[] getParams() {
// return params;
// }
//
// public void setParams(Object[] params) {
// this.params = params;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/rpc/ResultMessage.java
// public class ResultMessage {
//
// private String id;
//
// private DDPError error;
//
// private Object result;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public DDPError getError() {
// return error;
// }
//
// public void setError(DDPError error) {
// this.error = error;
// }
//
// public Object getResult() {
// return result;
// }
//
// public void setResult(Object result) {
// this.result = result;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/rpc/UpdatedMessage.java
// public class UpdatedMessage {
//
// private String[] methods;
//
// public String[] getMethods() {
// return methods;
// }
// }
|
import io.advantageous.ddp.rpc.MethodMessage;
import io.advantageous.ddp.rpc.ResultMessage;
import io.advantageous.ddp.rpc.UpdatedMessage;
import io.advantageous.ddp.subscription.message.*;
import java.util.HashMap;
import java.util.Map;
|
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp;
/**
* Interface for converting DDP messages to and from raw string types.
*
* @author geoffc@gmail.com
* @since 1/17/14 at 7:08 PM.
*/
public interface MessageConverter {
public Object fromDDP(String message) throws UnsupportedMessageException;
public String toDDP(Object object);
static class MessageRegistry {
static final Map<String, Class> STRING_CLASS_HASH_MAP = new HashMap<>();
static final Map<Class, String> CLASS_STRING_HASH_MAP = new HashMap<>();
static void register(String name, Class clazz) {
STRING_CLASS_HASH_MAP.put(name, clazz);
CLASS_STRING_HASH_MAP.put(clazz, name);
}
static String get(Class clazz) {
return CLASS_STRING_HASH_MAP.get(clazz);
}
static Class get(String key) {
return STRING_CLASS_HASH_MAP.get(key);
}
static {
register("method", MethodMessage.class);
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/rpc/MethodMessage.java
// public class MethodMessage {
//
// private String method;
//
// private String id;
//
// private Object[] params;
//
// public String getMethod() {
// return method;
// }
//
// public void setMethod(String method) {
// this.method = method;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public Object[] getParams() {
// return params;
// }
//
// public void setParams(Object[] params) {
// this.params = params;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/rpc/ResultMessage.java
// public class ResultMessage {
//
// private String id;
//
// private DDPError error;
//
// private Object result;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public DDPError getError() {
// return error;
// }
//
// public void setError(DDPError error) {
// this.error = error;
// }
//
// public Object getResult() {
// return result;
// }
//
// public void setResult(Object result) {
// this.result = result;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/rpc/UpdatedMessage.java
// public class UpdatedMessage {
//
// private String[] methods;
//
// public String[] getMethods() {
// return methods;
// }
// }
// Path: ddp-client/src/main/java/io/advantageous/ddp/MessageConverter.java
import io.advantageous.ddp.rpc.MethodMessage;
import io.advantageous.ddp.rpc.ResultMessage;
import io.advantageous.ddp.rpc.UpdatedMessage;
import io.advantageous.ddp.subscription.message.*;
import java.util.HashMap;
import java.util.Map;
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp;
/**
* Interface for converting DDP messages to and from raw string types.
*
* @author geoffc@gmail.com
* @since 1/17/14 at 7:08 PM.
*/
public interface MessageConverter {
public Object fromDDP(String message) throws UnsupportedMessageException;
public String toDDP(Object object);
static class MessageRegistry {
static final Map<String, Class> STRING_CLASS_HASH_MAP = new HashMap<>();
static final Map<Class, String> CLASS_STRING_HASH_MAP = new HashMap<>();
static void register(String name, Class clazz) {
STRING_CLASS_HASH_MAP.put(name, clazz);
CLASS_STRING_HASH_MAP.put(clazz, name);
}
static String get(Class clazz) {
return CLASS_STRING_HASH_MAP.get(clazz);
}
static Class get(String key) {
return STRING_CLASS_HASH_MAP.get(key);
}
static {
register("method", MethodMessage.class);
|
register("result", ResultMessage.class);
|
advantageous/ddp-client-java
|
ddp-client/src/main/java/io/advantageous/ddp/MessageConverter.java
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/rpc/MethodMessage.java
// public class MethodMessage {
//
// private String method;
//
// private String id;
//
// private Object[] params;
//
// public String getMethod() {
// return method;
// }
//
// public void setMethod(String method) {
// this.method = method;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public Object[] getParams() {
// return params;
// }
//
// public void setParams(Object[] params) {
// this.params = params;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/rpc/ResultMessage.java
// public class ResultMessage {
//
// private String id;
//
// private DDPError error;
//
// private Object result;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public DDPError getError() {
// return error;
// }
//
// public void setError(DDPError error) {
// this.error = error;
// }
//
// public Object getResult() {
// return result;
// }
//
// public void setResult(Object result) {
// this.result = result;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/rpc/UpdatedMessage.java
// public class UpdatedMessage {
//
// private String[] methods;
//
// public String[] getMethods() {
// return methods;
// }
// }
|
import io.advantageous.ddp.rpc.MethodMessage;
import io.advantageous.ddp.rpc.ResultMessage;
import io.advantageous.ddp.rpc.UpdatedMessage;
import io.advantageous.ddp.subscription.message.*;
import java.util.HashMap;
import java.util.Map;
|
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp;
/**
* Interface for converting DDP messages to and from raw string types.
*
* @author geoffc@gmail.com
* @since 1/17/14 at 7:08 PM.
*/
public interface MessageConverter {
public Object fromDDP(String message) throws UnsupportedMessageException;
public String toDDP(Object object);
static class MessageRegistry {
static final Map<String, Class> STRING_CLASS_HASH_MAP = new HashMap<>();
static final Map<Class, String> CLASS_STRING_HASH_MAP = new HashMap<>();
static void register(String name, Class clazz) {
STRING_CLASS_HASH_MAP.put(name, clazz);
CLASS_STRING_HASH_MAP.put(clazz, name);
}
static String get(Class clazz) {
return CLASS_STRING_HASH_MAP.get(clazz);
}
static Class get(String key) {
return STRING_CLASS_HASH_MAP.get(key);
}
static {
register("method", MethodMessage.class);
register("result", ResultMessage.class);
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/rpc/MethodMessage.java
// public class MethodMessage {
//
// private String method;
//
// private String id;
//
// private Object[] params;
//
// public String getMethod() {
// return method;
// }
//
// public void setMethod(String method) {
// this.method = method;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public Object[] getParams() {
// return params;
// }
//
// public void setParams(Object[] params) {
// this.params = params;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/rpc/ResultMessage.java
// public class ResultMessage {
//
// private String id;
//
// private DDPError error;
//
// private Object result;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public DDPError getError() {
// return error;
// }
//
// public void setError(DDPError error) {
// this.error = error;
// }
//
// public Object getResult() {
// return result;
// }
//
// public void setResult(Object result) {
// this.result = result;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/rpc/UpdatedMessage.java
// public class UpdatedMessage {
//
// private String[] methods;
//
// public String[] getMethods() {
// return methods;
// }
// }
// Path: ddp-client/src/main/java/io/advantageous/ddp/MessageConverter.java
import io.advantageous.ddp.rpc.MethodMessage;
import io.advantageous.ddp.rpc.ResultMessage;
import io.advantageous.ddp.rpc.UpdatedMessage;
import io.advantageous.ddp.subscription.message.*;
import java.util.HashMap;
import java.util.Map;
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp;
/**
* Interface for converting DDP messages to and from raw string types.
*
* @author geoffc@gmail.com
* @since 1/17/14 at 7:08 PM.
*/
public interface MessageConverter {
public Object fromDDP(String message) throws UnsupportedMessageException;
public String toDDP(Object object);
static class MessageRegistry {
static final Map<String, Class> STRING_CLASS_HASH_MAP = new HashMap<>();
static final Map<Class, String> CLASS_STRING_HASH_MAP = new HashMap<>();
static void register(String name, Class clazz) {
STRING_CLASS_HASH_MAP.put(name, clazz);
CLASS_STRING_HASH_MAP.put(clazz, name);
}
static String get(Class clazz) {
return CLASS_STRING_HASH_MAP.get(clazz);
}
static Class get(String key) {
return STRING_CLASS_HASH_MAP.get(key);
}
static {
register("method", MethodMessage.class);
register("result", ResultMessage.class);
|
register("updated", UpdatedMessage.class);
|
advantageous/ddp-client-java
|
ddp-client/src/main/java/io/advantageous/ddp/subscription/BaseSubscriptionAdapter.java
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPMessageEndpoint.java
// public interface DDPMessageEndpoint {
// void disconnect() throws IOException;
//
// void connect(String address) throws IOException, InterruptedException;
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler.Phase phase, DDPMessageHandler<T> handler);
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler<T> handler);
//
// void await() throws InterruptedException;
//
// void send(Object message) throws IOException;
//
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/NoSubscriptionMessage.java
// public class NoSubscriptionMessage {
//
// private String id;
//
// private DDPError error;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public DDPError getError() {
// return error;
// }
//
// public void setError(DDPError error) {
// this.error = error;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/ReadyMessage.java
// public class ReadyMessage {
//
// private String[] subs;
//
// public String[] getSubs() {
// return subs;
// }
//
// public void setSubs(String[] subs) {
// this.subs = subs;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/SubscribeMessage.java
// public class SubscribeMessage {
//
// private String id;
//
// private String name;
//
// private Object[] params;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object[] getParams() {
// return params;
// }
//
// public void setParams(Object[] params) {
// this.params = params;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/UnsubscribeMessage.java
// public class UnsubscribeMessage {
//
// private String id;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
// }
|
import io.advantageous.ddp.DDPMessageEndpoint;
import io.advantageous.ddp.subscription.message.NoSubscriptionMessage;
import io.advantageous.ddp.subscription.message.ReadyMessage;
import io.advantageous.ddp.subscription.message.SubscribeMessage;
import io.advantageous.ddp.subscription.message.UnsubscribeMessage;
import javax.inject.Inject;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
|
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp.subscription;
/**
* Base class for handling DDP subscriptions.
*
* @author geoffc@gmail.com
* @since 1/21/14 at 3:55 PM.
*/
public class BaseSubscriptionAdapter implements SubscriptionAdapter {
private static final AtomicLong SEQUENCE = new AtomicLong(0);
protected final Map<String, Subscription.Callback> callbackMap = new ConcurrentHashMap<>();
protected final ObjectConverter objectConverter;
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPMessageEndpoint.java
// public interface DDPMessageEndpoint {
// void disconnect() throws IOException;
//
// void connect(String address) throws IOException, InterruptedException;
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler.Phase phase, DDPMessageHandler<T> handler);
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler<T> handler);
//
// void await() throws InterruptedException;
//
// void send(Object message) throws IOException;
//
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/NoSubscriptionMessage.java
// public class NoSubscriptionMessage {
//
// private String id;
//
// private DDPError error;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public DDPError getError() {
// return error;
// }
//
// public void setError(DDPError error) {
// this.error = error;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/ReadyMessage.java
// public class ReadyMessage {
//
// private String[] subs;
//
// public String[] getSubs() {
// return subs;
// }
//
// public void setSubs(String[] subs) {
// this.subs = subs;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/SubscribeMessage.java
// public class SubscribeMessage {
//
// private String id;
//
// private String name;
//
// private Object[] params;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object[] getParams() {
// return params;
// }
//
// public void setParams(Object[] params) {
// this.params = params;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/UnsubscribeMessage.java
// public class UnsubscribeMessage {
//
// private String id;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
// }
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/BaseSubscriptionAdapter.java
import io.advantageous.ddp.DDPMessageEndpoint;
import io.advantageous.ddp.subscription.message.NoSubscriptionMessage;
import io.advantageous.ddp.subscription.message.ReadyMessage;
import io.advantageous.ddp.subscription.message.SubscribeMessage;
import io.advantageous.ddp.subscription.message.UnsubscribeMessage;
import javax.inject.Inject;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp.subscription;
/**
* Base class for handling DDP subscriptions.
*
* @author geoffc@gmail.com
* @since 1/21/14 at 3:55 PM.
*/
public class BaseSubscriptionAdapter implements SubscriptionAdapter {
private static final AtomicLong SEQUENCE = new AtomicLong(0);
protected final Map<String, Subscription.Callback> callbackMap = new ConcurrentHashMap<>();
protected final ObjectConverter objectConverter;
|
protected final DDPMessageEndpoint messageEndpoint;
|
advantageous/ddp-client-java
|
ddp-client/src/main/java/io/advantageous/ddp/subscription/BaseSubscriptionAdapter.java
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPMessageEndpoint.java
// public interface DDPMessageEndpoint {
// void disconnect() throws IOException;
//
// void connect(String address) throws IOException, InterruptedException;
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler.Phase phase, DDPMessageHandler<T> handler);
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler<T> handler);
//
// void await() throws InterruptedException;
//
// void send(Object message) throws IOException;
//
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/NoSubscriptionMessage.java
// public class NoSubscriptionMessage {
//
// private String id;
//
// private DDPError error;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public DDPError getError() {
// return error;
// }
//
// public void setError(DDPError error) {
// this.error = error;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/ReadyMessage.java
// public class ReadyMessage {
//
// private String[] subs;
//
// public String[] getSubs() {
// return subs;
// }
//
// public void setSubs(String[] subs) {
// this.subs = subs;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/SubscribeMessage.java
// public class SubscribeMessage {
//
// private String id;
//
// private String name;
//
// private Object[] params;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object[] getParams() {
// return params;
// }
//
// public void setParams(Object[] params) {
// this.params = params;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/UnsubscribeMessage.java
// public class UnsubscribeMessage {
//
// private String id;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
// }
|
import io.advantageous.ddp.DDPMessageEndpoint;
import io.advantageous.ddp.subscription.message.NoSubscriptionMessage;
import io.advantageous.ddp.subscription.message.ReadyMessage;
import io.advantageous.ddp.subscription.message.SubscribeMessage;
import io.advantageous.ddp.subscription.message.UnsubscribeMessage;
import javax.inject.Inject;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
|
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp.subscription;
/**
* Base class for handling DDP subscriptions.
*
* @author geoffc@gmail.com
* @since 1/21/14 at 3:55 PM.
*/
public class BaseSubscriptionAdapter implements SubscriptionAdapter {
private static final AtomicLong SEQUENCE = new AtomicLong(0);
protected final Map<String, Subscription.Callback> callbackMap = new ConcurrentHashMap<>();
protected final ObjectConverter objectConverter;
protected final DDPMessageEndpoint messageEndpoint;
@Inject
public BaseSubscriptionAdapter(final DDPMessageEndpoint messageEndpoint,
final ObjectConverter objectConverter) {
this.objectConverter = objectConverter;
this.messageEndpoint = messageEndpoint;
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPMessageEndpoint.java
// public interface DDPMessageEndpoint {
// void disconnect() throws IOException;
//
// void connect(String address) throws IOException, InterruptedException;
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler.Phase phase, DDPMessageHandler<T> handler);
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler<T> handler);
//
// void await() throws InterruptedException;
//
// void send(Object message) throws IOException;
//
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/NoSubscriptionMessage.java
// public class NoSubscriptionMessage {
//
// private String id;
//
// private DDPError error;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public DDPError getError() {
// return error;
// }
//
// public void setError(DDPError error) {
// this.error = error;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/ReadyMessage.java
// public class ReadyMessage {
//
// private String[] subs;
//
// public String[] getSubs() {
// return subs;
// }
//
// public void setSubs(String[] subs) {
// this.subs = subs;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/SubscribeMessage.java
// public class SubscribeMessage {
//
// private String id;
//
// private String name;
//
// private Object[] params;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object[] getParams() {
// return params;
// }
//
// public void setParams(Object[] params) {
// this.params = params;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/UnsubscribeMessage.java
// public class UnsubscribeMessage {
//
// private String id;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
// }
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/BaseSubscriptionAdapter.java
import io.advantageous.ddp.DDPMessageEndpoint;
import io.advantageous.ddp.subscription.message.NoSubscriptionMessage;
import io.advantageous.ddp.subscription.message.ReadyMessage;
import io.advantageous.ddp.subscription.message.SubscribeMessage;
import io.advantageous.ddp.subscription.message.UnsubscribeMessage;
import javax.inject.Inject;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp.subscription;
/**
* Base class for handling DDP subscriptions.
*
* @author geoffc@gmail.com
* @since 1/21/14 at 3:55 PM.
*/
public class BaseSubscriptionAdapter implements SubscriptionAdapter {
private static final AtomicLong SEQUENCE = new AtomicLong(0);
protected final Map<String, Subscription.Callback> callbackMap = new ConcurrentHashMap<>();
protected final ObjectConverter objectConverter;
protected final DDPMessageEndpoint messageEndpoint;
@Inject
public BaseSubscriptionAdapter(final DDPMessageEndpoint messageEndpoint,
final ObjectConverter objectConverter) {
this.objectConverter = objectConverter;
this.messageEndpoint = messageEndpoint;
|
messageEndpoint.registerHandler(ReadyMessage.class, message -> {
|
advantageous/ddp-client-java
|
ddp-client/src/main/java/io/advantageous/ddp/subscription/BaseSubscriptionAdapter.java
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPMessageEndpoint.java
// public interface DDPMessageEndpoint {
// void disconnect() throws IOException;
//
// void connect(String address) throws IOException, InterruptedException;
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler.Phase phase, DDPMessageHandler<T> handler);
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler<T> handler);
//
// void await() throws InterruptedException;
//
// void send(Object message) throws IOException;
//
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/NoSubscriptionMessage.java
// public class NoSubscriptionMessage {
//
// private String id;
//
// private DDPError error;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public DDPError getError() {
// return error;
// }
//
// public void setError(DDPError error) {
// this.error = error;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/ReadyMessage.java
// public class ReadyMessage {
//
// private String[] subs;
//
// public String[] getSubs() {
// return subs;
// }
//
// public void setSubs(String[] subs) {
// this.subs = subs;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/SubscribeMessage.java
// public class SubscribeMessage {
//
// private String id;
//
// private String name;
//
// private Object[] params;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object[] getParams() {
// return params;
// }
//
// public void setParams(Object[] params) {
// this.params = params;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/UnsubscribeMessage.java
// public class UnsubscribeMessage {
//
// private String id;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
// }
|
import io.advantageous.ddp.DDPMessageEndpoint;
import io.advantageous.ddp.subscription.message.NoSubscriptionMessage;
import io.advantageous.ddp.subscription.message.ReadyMessage;
import io.advantageous.ddp.subscription.message.SubscribeMessage;
import io.advantageous.ddp.subscription.message.UnsubscribeMessage;
import javax.inject.Inject;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
|
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp.subscription;
/**
* Base class for handling DDP subscriptions.
*
* @author geoffc@gmail.com
* @since 1/21/14 at 3:55 PM.
*/
public class BaseSubscriptionAdapter implements SubscriptionAdapter {
private static final AtomicLong SEQUENCE = new AtomicLong(0);
protected final Map<String, Subscription.Callback> callbackMap = new ConcurrentHashMap<>();
protected final ObjectConverter objectConverter;
protected final DDPMessageEndpoint messageEndpoint;
@Inject
public BaseSubscriptionAdapter(final DDPMessageEndpoint messageEndpoint,
final ObjectConverter objectConverter) {
this.objectConverter = objectConverter;
this.messageEndpoint = messageEndpoint;
messageEndpoint.registerHandler(ReadyMessage.class, message -> {
for (final String sub : message.getSubs()) {
final Subscription.Callback callback = this.callbackMap.get(sub);
if (callback != null) {
callback.onReady(sub);
this.callbackMap.remove(sub);
}
}
});
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPMessageEndpoint.java
// public interface DDPMessageEndpoint {
// void disconnect() throws IOException;
//
// void connect(String address) throws IOException, InterruptedException;
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler.Phase phase, DDPMessageHandler<T> handler);
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler<T> handler);
//
// void await() throws InterruptedException;
//
// void send(Object message) throws IOException;
//
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/NoSubscriptionMessage.java
// public class NoSubscriptionMessage {
//
// private String id;
//
// private DDPError error;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public DDPError getError() {
// return error;
// }
//
// public void setError(DDPError error) {
// this.error = error;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/ReadyMessage.java
// public class ReadyMessage {
//
// private String[] subs;
//
// public String[] getSubs() {
// return subs;
// }
//
// public void setSubs(String[] subs) {
// this.subs = subs;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/SubscribeMessage.java
// public class SubscribeMessage {
//
// private String id;
//
// private String name;
//
// private Object[] params;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object[] getParams() {
// return params;
// }
//
// public void setParams(Object[] params) {
// this.params = params;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/UnsubscribeMessage.java
// public class UnsubscribeMessage {
//
// private String id;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
// }
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/BaseSubscriptionAdapter.java
import io.advantageous.ddp.DDPMessageEndpoint;
import io.advantageous.ddp.subscription.message.NoSubscriptionMessage;
import io.advantageous.ddp.subscription.message.ReadyMessage;
import io.advantageous.ddp.subscription.message.SubscribeMessage;
import io.advantageous.ddp.subscription.message.UnsubscribeMessage;
import javax.inject.Inject;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp.subscription;
/**
* Base class for handling DDP subscriptions.
*
* @author geoffc@gmail.com
* @since 1/21/14 at 3:55 PM.
*/
public class BaseSubscriptionAdapter implements SubscriptionAdapter {
private static final AtomicLong SEQUENCE = new AtomicLong(0);
protected final Map<String, Subscription.Callback> callbackMap = new ConcurrentHashMap<>();
protected final ObjectConverter objectConverter;
protected final DDPMessageEndpoint messageEndpoint;
@Inject
public BaseSubscriptionAdapter(final DDPMessageEndpoint messageEndpoint,
final ObjectConverter objectConverter) {
this.objectConverter = objectConverter;
this.messageEndpoint = messageEndpoint;
messageEndpoint.registerHandler(ReadyMessage.class, message -> {
for (final String sub : message.getSubs()) {
final Subscription.Callback callback = this.callbackMap.get(sub);
if (callback != null) {
callback.onReady(sub);
this.callbackMap.remove(sub);
}
}
});
|
messageEndpoint.registerHandler(NoSubscriptionMessage.class, message -> {
|
advantageous/ddp-client-java
|
ddp-client/src/main/java/io/advantageous/ddp/subscription/BaseSubscriptionAdapter.java
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPMessageEndpoint.java
// public interface DDPMessageEndpoint {
// void disconnect() throws IOException;
//
// void connect(String address) throws IOException, InterruptedException;
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler.Phase phase, DDPMessageHandler<T> handler);
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler<T> handler);
//
// void await() throws InterruptedException;
//
// void send(Object message) throws IOException;
//
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/NoSubscriptionMessage.java
// public class NoSubscriptionMessage {
//
// private String id;
//
// private DDPError error;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public DDPError getError() {
// return error;
// }
//
// public void setError(DDPError error) {
// this.error = error;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/ReadyMessage.java
// public class ReadyMessage {
//
// private String[] subs;
//
// public String[] getSubs() {
// return subs;
// }
//
// public void setSubs(String[] subs) {
// this.subs = subs;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/SubscribeMessage.java
// public class SubscribeMessage {
//
// private String id;
//
// private String name;
//
// private Object[] params;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object[] getParams() {
// return params;
// }
//
// public void setParams(Object[] params) {
// this.params = params;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/UnsubscribeMessage.java
// public class UnsubscribeMessage {
//
// private String id;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
// }
|
import io.advantageous.ddp.DDPMessageEndpoint;
import io.advantageous.ddp.subscription.message.NoSubscriptionMessage;
import io.advantageous.ddp.subscription.message.ReadyMessage;
import io.advantageous.ddp.subscription.message.SubscribeMessage;
import io.advantageous.ddp.subscription.message.UnsubscribeMessage;
import javax.inject.Inject;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
|
this.messageEndpoint = messageEndpoint;
messageEndpoint.registerHandler(ReadyMessage.class, message -> {
for (final String sub : message.getSubs()) {
final Subscription.Callback callback = this.callbackMap.get(sub);
if (callback != null) {
callback.onReady(sub);
this.callbackMap.remove(sub);
}
}
});
messageEndpoint.registerHandler(NoSubscriptionMessage.class, message -> {
final Subscription.Callback callback = this.callbackMap.get(message.getId());
if (callback != null) {
callback.onFailure(message.getId(), message.getError());
this.callbackMap.remove(message.getId());
}
});
}
@Override
public void subscribe(final Subscription subscription) throws IOException {
final Long subscriptionId = SEQUENCE.getAndIncrement();
final String id = subscriptionId.toString();
final Subscription.Callback callback = subscription.getCallback();
if (callback != null) {
this.callbackMap.put(id, subscription.getCallback());
}
this.objectConverter.register(subscription.getSubscriptionName(), subscription.getClazz());
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPMessageEndpoint.java
// public interface DDPMessageEndpoint {
// void disconnect() throws IOException;
//
// void connect(String address) throws IOException, InterruptedException;
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler.Phase phase, DDPMessageHandler<T> handler);
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler<T> handler);
//
// void await() throws InterruptedException;
//
// void send(Object message) throws IOException;
//
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/NoSubscriptionMessage.java
// public class NoSubscriptionMessage {
//
// private String id;
//
// private DDPError error;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public DDPError getError() {
// return error;
// }
//
// public void setError(DDPError error) {
// this.error = error;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/ReadyMessage.java
// public class ReadyMessage {
//
// private String[] subs;
//
// public String[] getSubs() {
// return subs;
// }
//
// public void setSubs(String[] subs) {
// this.subs = subs;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/SubscribeMessage.java
// public class SubscribeMessage {
//
// private String id;
//
// private String name;
//
// private Object[] params;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object[] getParams() {
// return params;
// }
//
// public void setParams(Object[] params) {
// this.params = params;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/UnsubscribeMessage.java
// public class UnsubscribeMessage {
//
// private String id;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
// }
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/BaseSubscriptionAdapter.java
import io.advantageous.ddp.DDPMessageEndpoint;
import io.advantageous.ddp.subscription.message.NoSubscriptionMessage;
import io.advantageous.ddp.subscription.message.ReadyMessage;
import io.advantageous.ddp.subscription.message.SubscribeMessage;
import io.advantageous.ddp.subscription.message.UnsubscribeMessage;
import javax.inject.Inject;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
this.messageEndpoint = messageEndpoint;
messageEndpoint.registerHandler(ReadyMessage.class, message -> {
for (final String sub : message.getSubs()) {
final Subscription.Callback callback = this.callbackMap.get(sub);
if (callback != null) {
callback.onReady(sub);
this.callbackMap.remove(sub);
}
}
});
messageEndpoint.registerHandler(NoSubscriptionMessage.class, message -> {
final Subscription.Callback callback = this.callbackMap.get(message.getId());
if (callback != null) {
callback.onFailure(message.getId(), message.getError());
this.callbackMap.remove(message.getId());
}
});
}
@Override
public void subscribe(final Subscription subscription) throws IOException {
final Long subscriptionId = SEQUENCE.getAndIncrement();
final String id = subscriptionId.toString();
final Subscription.Callback callback = subscription.getCallback();
if (callback != null) {
this.callbackMap.put(id, subscription.getCallback());
}
this.objectConverter.register(subscription.getSubscriptionName(), subscription.getClazz());
|
final SubscribeMessage message = new SubscribeMessage();
|
advantageous/ddp-client-java
|
ddp-client/src/main/java/io/advantageous/ddp/subscription/BaseSubscriptionAdapter.java
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPMessageEndpoint.java
// public interface DDPMessageEndpoint {
// void disconnect() throws IOException;
//
// void connect(String address) throws IOException, InterruptedException;
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler.Phase phase, DDPMessageHandler<T> handler);
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler<T> handler);
//
// void await() throws InterruptedException;
//
// void send(Object message) throws IOException;
//
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/NoSubscriptionMessage.java
// public class NoSubscriptionMessage {
//
// private String id;
//
// private DDPError error;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public DDPError getError() {
// return error;
// }
//
// public void setError(DDPError error) {
// this.error = error;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/ReadyMessage.java
// public class ReadyMessage {
//
// private String[] subs;
//
// public String[] getSubs() {
// return subs;
// }
//
// public void setSubs(String[] subs) {
// this.subs = subs;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/SubscribeMessage.java
// public class SubscribeMessage {
//
// private String id;
//
// private String name;
//
// private Object[] params;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object[] getParams() {
// return params;
// }
//
// public void setParams(Object[] params) {
// this.params = params;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/UnsubscribeMessage.java
// public class UnsubscribeMessage {
//
// private String id;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
// }
|
import io.advantageous.ddp.DDPMessageEndpoint;
import io.advantageous.ddp.subscription.message.NoSubscriptionMessage;
import io.advantageous.ddp.subscription.message.ReadyMessage;
import io.advantageous.ddp.subscription.message.SubscribeMessage;
import io.advantageous.ddp.subscription.message.UnsubscribeMessage;
import javax.inject.Inject;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
|
});
messageEndpoint.registerHandler(NoSubscriptionMessage.class, message -> {
final Subscription.Callback callback = this.callbackMap.get(message.getId());
if (callback != null) {
callback.onFailure(message.getId(), message.getError());
this.callbackMap.remove(message.getId());
}
});
}
@Override
public void subscribe(final Subscription subscription) throws IOException {
final Long subscriptionId = SEQUENCE.getAndIncrement();
final String id = subscriptionId.toString();
final Subscription.Callback callback = subscription.getCallback();
if (callback != null) {
this.callbackMap.put(id, subscription.getCallback());
}
this.objectConverter.register(subscription.getSubscriptionName(), subscription.getClazz());
final SubscribeMessage message = new SubscribeMessage();
message.setId(id);
message.setName(subscription.getSubscriptionName());
message.setParams(subscription.getParams());
this.messageEndpoint.send(message);
}
@Override
public void unsubscribe(final String subscriptionId) throws IOException {
this.callbackMap.remove(subscriptionId);
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPMessageEndpoint.java
// public interface DDPMessageEndpoint {
// void disconnect() throws IOException;
//
// void connect(String address) throws IOException, InterruptedException;
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler.Phase phase, DDPMessageHandler<T> handler);
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler<T> handler);
//
// void await() throws InterruptedException;
//
// void send(Object message) throws IOException;
//
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/NoSubscriptionMessage.java
// public class NoSubscriptionMessage {
//
// private String id;
//
// private DDPError error;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public DDPError getError() {
// return error;
// }
//
// public void setError(DDPError error) {
// this.error = error;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/ReadyMessage.java
// public class ReadyMessage {
//
// private String[] subs;
//
// public String[] getSubs() {
// return subs;
// }
//
// public void setSubs(String[] subs) {
// this.subs = subs;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/SubscribeMessage.java
// public class SubscribeMessage {
//
// private String id;
//
// private String name;
//
// private Object[] params;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public Object[] getParams() {
// return params;
// }
//
// public void setParams(Object[] params) {
// this.params = params;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/UnsubscribeMessage.java
// public class UnsubscribeMessage {
//
// private String id;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
// }
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/BaseSubscriptionAdapter.java
import io.advantageous.ddp.DDPMessageEndpoint;
import io.advantageous.ddp.subscription.message.NoSubscriptionMessage;
import io.advantageous.ddp.subscription.message.ReadyMessage;
import io.advantageous.ddp.subscription.message.SubscribeMessage;
import io.advantageous.ddp.subscription.message.UnsubscribeMessage;
import javax.inject.Inject;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
});
messageEndpoint.registerHandler(NoSubscriptionMessage.class, message -> {
final Subscription.Callback callback = this.callbackMap.get(message.getId());
if (callback != null) {
callback.onFailure(message.getId(), message.getError());
this.callbackMap.remove(message.getId());
}
});
}
@Override
public void subscribe(final Subscription subscription) throws IOException {
final Long subscriptionId = SEQUENCE.getAndIncrement();
final String id = subscriptionId.toString();
final Subscription.Callback callback = subscription.getCallback();
if (callback != null) {
this.callbackMap.put(id, subscription.getCallback());
}
this.objectConverter.register(subscription.getSubscriptionName(), subscription.getClazz());
final SubscribeMessage message = new SubscribeMessage();
message.setId(id);
message.setName(subscription.getSubscriptionName());
message.setParams(subscription.getParams());
this.messageEndpoint.send(message);
}
@Override
public void unsubscribe(final String subscriptionId) throws IOException {
this.callbackMap.remove(subscriptionId);
|
final UnsubscribeMessage message = new UnsubscribeMessage();
|
advantageous/ddp-client-java
|
ddp-client/src/main/java/io/advantageous/ddp/rpc/ResultMessage.java
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPError.java
// public class DDPError {
//
// private final int error;
//
// private final String reason;
//
// private final String details;
//
// public DDPError(final int error, final String reason, final String details) {
// this.error = error;
// this.reason = reason;
// this.details = details;
// }
//
// public int getError() {
// return error;
// }
//
// public String getReason() {
// return reason;
// }
//
// public String getDetails() {
// return details;
// }
//
// @Override
// public String toString() {
// return "DDPError{" +
// "error=" + error +
// ", reason='" + reason + '\'' +
// ", details='" + details + '\'' +
// '}';
// }
// }
|
import io.advantageous.ddp.DDPError;
|
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp.rpc;
/**
* Message that indicates the result of an RPC call.
*
* @author geoffc@gmail.com
* @since 1/17/14 at 6:17 PM.
*/
public class ResultMessage {
private String id;
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPError.java
// public class DDPError {
//
// private final int error;
//
// private final String reason;
//
// private final String details;
//
// public DDPError(final int error, final String reason, final String details) {
// this.error = error;
// this.reason = reason;
// this.details = details;
// }
//
// public int getError() {
// return error;
// }
//
// public String getReason() {
// return reason;
// }
//
// public String getDetails() {
// return details;
// }
//
// @Override
// public String toString() {
// return "DDPError{" +
// "error=" + error +
// ", reason='" + reason + '\'' +
// ", details='" + details + '\'' +
// '}';
// }
// }
// Path: ddp-client/src/main/java/io/advantageous/ddp/rpc/ResultMessage.java
import io.advantageous.ddp.DDPError;
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp.rpc;
/**
* Message that indicates the result of an RPC call.
*
* @author geoffc@gmail.com
* @since 1/17/14 at 6:17 PM.
*/
public class ResultMessage {
private String id;
|
private DDPError error;
|
advantageous/ddp-client-java
|
ddp-client/src/main/java/io/advantageous/ddp/subscription/Subscription.java
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPError.java
// public class DDPError {
//
// private final int error;
//
// private final String reason;
//
// private final String details;
//
// public DDPError(final int error, final String reason, final String details) {
// this.error = error;
// this.reason = reason;
// this.details = details;
// }
//
// public int getError() {
// return error;
// }
//
// public String getReason() {
// return reason;
// }
//
// public String getDetails() {
// return details;
// }
//
// @Override
// public String toString() {
// return "DDPError{" +
// "error=" + error +
// ", reason='" + reason + '\'' +
// ", details='" + details + '\'' +
// '}';
// }
// }
|
import io.advantageous.ddp.DDPError;
|
this(subscriptionName, null, clazz, callback);
}
public Subscription(String subscriptionName, Object[] params, Callback callback) {
this(subscriptionName, params, Object.class, callback);
}
public String getSubscriptionName() {
return subscriptionName;
}
public Object[] getParams() {
return params;
}
public Class getClazz() {
return clazz;
}
public Callback getCallback() {
return callback;
}
/**
* Callback run when a subscription is handled.
*/
public interface Callback {
void onReady(String subscriptionId);
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPError.java
// public class DDPError {
//
// private final int error;
//
// private final String reason;
//
// private final String details;
//
// public DDPError(final int error, final String reason, final String details) {
// this.error = error;
// this.reason = reason;
// this.details = details;
// }
//
// public int getError() {
// return error;
// }
//
// public String getReason() {
// return reason;
// }
//
// public String getDetails() {
// return details;
// }
//
// @Override
// public String toString() {
// return "DDPError{" +
// "error=" + error +
// ", reason='" + reason + '\'' +
// ", details='" + details + '\'' +
// '}';
// }
// }
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/Subscription.java
import io.advantageous.ddp.DDPError;
this(subscriptionName, null, clazz, callback);
}
public Subscription(String subscriptionName, Object[] params, Callback callback) {
this(subscriptionName, params, Object.class, callback);
}
public String getSubscriptionName() {
return subscriptionName;
}
public Object[] getParams() {
return params;
}
public Class getClazz() {
return clazz;
}
public Callback getCallback() {
return callback;
}
/**
* Callback run when a subscription is handled.
*/
public interface Callback {
void onReady(String subscriptionId);
|
void onFailure(String subscriptionId, DDPError error);
|
advantageous/ddp-client-java
|
ddp-client/src/main/java/io/advantageous/ddp/rpc/RPCClientImpl.java
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPError.java
// public class DDPError {
//
// private final int error;
//
// private final String reason;
//
// private final String details;
//
// public DDPError(final int error, final String reason, final String details) {
// this.error = error;
// this.reason = reason;
// this.details = details;
// }
//
// public int getError() {
// return error;
// }
//
// public String getReason() {
// return reason;
// }
//
// public String getDetails() {
// return details;
// }
//
// @Override
// public String toString() {
// return "DDPError{" +
// "error=" + error +
// ", reason='" + reason + '\'' +
// ", details='" + details + '\'' +
// '}';
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPMessageEndpoint.java
// public interface DDPMessageEndpoint {
// void disconnect() throws IOException;
//
// void connect(String address) throws IOException, InterruptedException;
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler.Phase phase, DDPMessageHandler<T> handler);
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler<T> handler);
//
// void await() throws InterruptedException;
//
// void send(Object message) throws IOException;
//
// }
|
import io.advantageous.ddp.DDPError;
import io.advantageous.ddp.DDPMessageEndpoint;
import javax.inject.Inject;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
|
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp.rpc;
/**
* This is a client for Meteor's RPC protocol.
*
* @author geoffc@gmail.com
* @since 1/18/14 at 12:55 AM.
*/
public class RPCClientImpl implements RPCClient {
private static final AtomicLong SEQUENCE = new AtomicLong(0);
private static final Map<String, DeferredMethodInvocation> CALLBACK_MAP = new ConcurrentHashMap<>();
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPError.java
// public class DDPError {
//
// private final int error;
//
// private final String reason;
//
// private final String details;
//
// public DDPError(final int error, final String reason, final String details) {
// this.error = error;
// this.reason = reason;
// this.details = details;
// }
//
// public int getError() {
// return error;
// }
//
// public String getReason() {
// return reason;
// }
//
// public String getDetails() {
// return details;
// }
//
// @Override
// public String toString() {
// return "DDPError{" +
// "error=" + error +
// ", reason='" + reason + '\'' +
// ", details='" + details + '\'' +
// '}';
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPMessageEndpoint.java
// public interface DDPMessageEndpoint {
// void disconnect() throws IOException;
//
// void connect(String address) throws IOException, InterruptedException;
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler.Phase phase, DDPMessageHandler<T> handler);
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler<T> handler);
//
// void await() throws InterruptedException;
//
// void send(Object message) throws IOException;
//
// }
// Path: ddp-client/src/main/java/io/advantageous/ddp/rpc/RPCClientImpl.java
import io.advantageous.ddp.DDPError;
import io.advantageous.ddp.DDPMessageEndpoint;
import javax.inject.Inject;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp.rpc;
/**
* This is a client for Meteor's RPC protocol.
*
* @author geoffc@gmail.com
* @since 1/18/14 at 12:55 AM.
*/
public class RPCClientImpl implements RPCClient {
private static final AtomicLong SEQUENCE = new AtomicLong(0);
private static final Map<String, DeferredMethodInvocation> CALLBACK_MAP = new ConcurrentHashMap<>();
|
private final DDPMessageEndpoint client;
|
advantageous/ddp-client-java
|
ddp-client/src/main/java/io/advantageous/ddp/rpc/RPCClientImpl.java
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPError.java
// public class DDPError {
//
// private final int error;
//
// private final String reason;
//
// private final String details;
//
// public DDPError(final int error, final String reason, final String details) {
// this.error = error;
// this.reason = reason;
// this.details = details;
// }
//
// public int getError() {
// return error;
// }
//
// public String getReason() {
// return reason;
// }
//
// public String getDetails() {
// return details;
// }
//
// @Override
// public String toString() {
// return "DDPError{" +
// "error=" + error +
// ", reason='" + reason + '\'' +
// ", details='" + details + '\'' +
// '}';
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPMessageEndpoint.java
// public interface DDPMessageEndpoint {
// void disconnect() throws IOException;
//
// void connect(String address) throws IOException, InterruptedException;
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler.Phase phase, DDPMessageHandler<T> handler);
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler<T> handler);
//
// void await() throws InterruptedException;
//
// void send(Object message) throws IOException;
//
// }
|
import io.advantageous.ddp.DDPError;
import io.advantageous.ddp.DDPMessageEndpoint;
import javax.inject.Inject;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
|
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp.rpc;
/**
* This is a client for Meteor's RPC protocol.
*
* @author geoffc@gmail.com
* @since 1/18/14 at 12:55 AM.
*/
public class RPCClientImpl implements RPCClient {
private static final AtomicLong SEQUENCE = new AtomicLong(0);
private static final Map<String, DeferredMethodInvocation> CALLBACK_MAP = new ConcurrentHashMap<>();
private final DDPMessageEndpoint client;
@Inject
public RPCClientImpl(final DDPMessageEndpoint client) {
this.client = client;
this.client.registerHandler(ResultMessage.class, result -> {
final DeferredMethodInvocation invocation = CALLBACK_MAP.get(result.getId());
// Exit early if this message wasn't for us.
if (invocation == null) return;
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPError.java
// public class DDPError {
//
// private final int error;
//
// private final String reason;
//
// private final String details;
//
// public DDPError(final int error, final String reason, final String details) {
// this.error = error;
// this.reason = reason;
// this.details = details;
// }
//
// public int getError() {
// return error;
// }
//
// public String getReason() {
// return reason;
// }
//
// public String getDetails() {
// return details;
// }
//
// @Override
// public String toString() {
// return "DDPError{" +
// "error=" + error +
// ", reason='" + reason + '\'' +
// ", details='" + details + '\'' +
// '}';
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPMessageEndpoint.java
// public interface DDPMessageEndpoint {
// void disconnect() throws IOException;
//
// void connect(String address) throws IOException, InterruptedException;
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler.Phase phase, DDPMessageHandler<T> handler);
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler<T> handler);
//
// void await() throws InterruptedException;
//
// void send(Object message) throws IOException;
//
// }
// Path: ddp-client/src/main/java/io/advantageous/ddp/rpc/RPCClientImpl.java
import io.advantageous.ddp.DDPError;
import io.advantageous.ddp.DDPMessageEndpoint;
import javax.inject.Inject;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp.rpc;
/**
* This is a client for Meteor's RPC protocol.
*
* @author geoffc@gmail.com
* @since 1/18/14 at 12:55 AM.
*/
public class RPCClientImpl implements RPCClient {
private static final AtomicLong SEQUENCE = new AtomicLong(0);
private static final Map<String, DeferredMethodInvocation> CALLBACK_MAP = new ConcurrentHashMap<>();
private final DDPMessageEndpoint client;
@Inject
public RPCClientImpl(final DDPMessageEndpoint client) {
this.client = client;
this.client.registerHandler(ResultMessage.class, result -> {
final DeferredMethodInvocation invocation = CALLBACK_MAP.get(result.getId());
// Exit early if this message wasn't for us.
if (invocation == null) return;
|
final DDPError error = result.getError();
|
advantageous/ddp-client-java
|
ddp-client/src/test/java/io/advantageous/ddp/subscription/MapSubscriptionAdapterTest.java
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/AddedMessage.java
// public class AddedMessage {
//
// private String collection;
//
// private String id;
//
// private JsonObject fields;
//
// public String getCollection() {
// return collection;
// }
//
// public void setCollection(String collection) {
// this.collection = collection;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public JsonObject getFields() {
// return fields;
// }
//
// public void setFields(JsonObject fields) {
// this.fields = fields;
// }
//
// @Override
// public String toString() {
// return "Added{" +
// "collection='" + collection + '\'' +
// ", id='" + id + '\'' +
// ", fields=" + fields +
// '}';
// }
// }
|
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.*;
import io.advantageous.ddp.*;
import io.advantageous.ddp.subscription.message.AddedMessage;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import javax.websocket.*;
import java.io.IOException;
import java.net.URI;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
|
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp.subscription;
public class MapSubscriptionAdapterTest {
private static final String CONNECTED_MESSAGE = "{\"msg\":\"connected\",\"session\":\"DNLpTnL8ZPTTizPvC\"}";
private static final String[] ADDED_MESSAGES = {
"{\"msg\":\"added\",\"collection\":\"tabs\",\"id\":\"uA6nsqCHnmjT3xmsm\",\"fields\":{\"name\":\"Ian Serlin\",\"total\":45.00}}",
"{\"msg\":\"added\",\"collection\":\"tabs\",\"id\":\"GkXcKNamHLesd57wi\",\"fields\":{\"name\":\"Geoff Chandler\",\"total\":50.00}}",
"{\"msg\":\"added\",\"collection\":\"tabs\",\"id\":\"odje77pej68MiSdPB\",\"fields\":{\"name\":\"Daniel Baron\",\"total\":255.00}}",
"{\"msg\":\"added\",\"collection\":\"tabs\",\"id\":\"uWz3rCXYAuevqX2bJ\",\"fields\":{\"name\":\"Foo\",\"total\":5}}"
};
private WebSocketContainer wsContainer;
private Session mockSession;
@Before
public void setup() throws Exception {
this.wsContainer = mock(WebSocketContainer.class);
this.mockSession = mock(Session.class);
when(mockSession.isOpen()).thenReturn(true);
RemoteEndpoint.Async asyncRemote = mock(RemoteEndpoint.Async.class);
when(mockSession.getAsyncRemote()).thenReturn(asyncRemote);
}
@Test
@SuppressWarnings("unchecked")
public void testAdded() throws Exception {
final Map<String, Map<String, Object>> localData = new HashMap<>();
final DDPMessageEndpoint client = new DDPMessageEndpointImpl(wsContainer, new JsonMessageConverter());
final ObjectConverter converter = new JsonObjectConverter();
final SubscriptionAdapter adapter = new MapSubscriptionAdapter(client, converter, localData);
final Set<Object> results = new HashSet<>();
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/message/AddedMessage.java
// public class AddedMessage {
//
// private String collection;
//
// private String id;
//
// private JsonObject fields;
//
// public String getCollection() {
// return collection;
// }
//
// public void setCollection(String collection) {
// this.collection = collection;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public JsonObject getFields() {
// return fields;
// }
//
// public void setFields(JsonObject fields) {
// this.fields = fields;
// }
//
// @Override
// public String toString() {
// return "Added{" +
// "collection='" + collection + '\'' +
// ", id='" + id + '\'' +
// ", fields=" + fields +
// '}';
// }
// }
// Path: ddp-client/src/test/java/io/advantageous/ddp/subscription/MapSubscriptionAdapterTest.java
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.*;
import io.advantageous.ddp.*;
import io.advantageous.ddp.subscription.message.AddedMessage;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import javax.websocket.*;
import java.io.IOException;
import java.net.URI;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp.subscription;
public class MapSubscriptionAdapterTest {
private static final String CONNECTED_MESSAGE = "{\"msg\":\"connected\",\"session\":\"DNLpTnL8ZPTTizPvC\"}";
private static final String[] ADDED_MESSAGES = {
"{\"msg\":\"added\",\"collection\":\"tabs\",\"id\":\"uA6nsqCHnmjT3xmsm\",\"fields\":{\"name\":\"Ian Serlin\",\"total\":45.00}}",
"{\"msg\":\"added\",\"collection\":\"tabs\",\"id\":\"GkXcKNamHLesd57wi\",\"fields\":{\"name\":\"Geoff Chandler\",\"total\":50.00}}",
"{\"msg\":\"added\",\"collection\":\"tabs\",\"id\":\"odje77pej68MiSdPB\",\"fields\":{\"name\":\"Daniel Baron\",\"total\":255.00}}",
"{\"msg\":\"added\",\"collection\":\"tabs\",\"id\":\"uWz3rCXYAuevqX2bJ\",\"fields\":{\"name\":\"Foo\",\"total\":5}}"
};
private WebSocketContainer wsContainer;
private Session mockSession;
@Before
public void setup() throws Exception {
this.wsContainer = mock(WebSocketContainer.class);
this.mockSession = mock(Session.class);
when(mockSession.isOpen()).thenReturn(true);
RemoteEndpoint.Async asyncRemote = mock(RemoteEndpoint.Async.class);
when(mockSession.getAsyncRemote()).thenReturn(asyncRemote);
}
@Test
@SuppressWarnings("unchecked")
public void testAdded() throws Exception {
final Map<String, Map<String, Object>> localData = new HashMap<>();
final DDPMessageEndpoint client = new DDPMessageEndpointImpl(wsContainer, new JsonMessageConverter());
final ObjectConverter converter = new JsonObjectConverter();
final SubscriptionAdapter adapter = new MapSubscriptionAdapter(client, converter, localData);
final Set<Object> results = new HashSet<>();
|
client.registerHandler(AddedMessage.class, DDPMessageHandler.Phase.AFTER_UPDATE, message -> {
|
advantageous/ddp-client-java
|
ddp-client/src/test/java/io/advantageous/ddp/JsonMessageConverterTest.java
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/JsonMessageConverter.java
// public class JsonMessageConverter implements MessageConverter {
//
// private static final Gson GSON = new Gson();
//
// @Override
// public Object fromDDP(final String rawMessage) throws UnsupportedMessageException {
// final Map jsonMap = GSON.fromJson(rawMessage, HashMap.class);
// final Object msg = jsonMap.get("msg");
// if (msg != null) {
// final String ddpMessageType = msg.toString();
// final Class messageClass = MessageRegistry.get(ddpMessageType);
// if (messageClass == null) throw new UnsupportedMessageException(rawMessage);
// return GSON.fromJson(rawMessage, messageClass);
// }
// return null;
// }
//
// @Override
// public String toDDP(final Object object) {
// final String json = GSON.toJson(object, object.getClass());
// final StringBuilder buffer = new StringBuilder(json);
// buffer.insert(1, "\"msg\":\"" + MessageRegistry.get(object.getClass()) + "\",");
// return buffer.toString();
// }
// }
|
import io.advantageous.ddp.JsonMessageConverter;
import org.junit.Assert;
import org.junit.Test;
import java.util.Date;
|
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp;
public class JsonMessageConverterTest {
@Test
public void testConversionToDdp() throws Exception {
MyTestClass foo = new MyTestClass();
foo.setName("Hello, world!");
foo.setDate(new Date());
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/JsonMessageConverter.java
// public class JsonMessageConverter implements MessageConverter {
//
// private static final Gson GSON = new Gson();
//
// @Override
// public Object fromDDP(final String rawMessage) throws UnsupportedMessageException {
// final Map jsonMap = GSON.fromJson(rawMessage, HashMap.class);
// final Object msg = jsonMap.get("msg");
// if (msg != null) {
// final String ddpMessageType = msg.toString();
// final Class messageClass = MessageRegistry.get(ddpMessageType);
// if (messageClass == null) throw new UnsupportedMessageException(rawMessage);
// return GSON.fromJson(rawMessage, messageClass);
// }
// return null;
// }
//
// @Override
// public String toDDP(final Object object) {
// final String json = GSON.toJson(object, object.getClass());
// final StringBuilder buffer = new StringBuilder(json);
// buffer.insert(1, "\"msg\":\"" + MessageRegistry.get(object.getClass()) + "\",");
// return buffer.toString();
// }
// }
// Path: ddp-client/src/test/java/io/advantageous/ddp/JsonMessageConverterTest.java
import io.advantageous.ddp.JsonMessageConverter;
import org.junit.Assert;
import org.junit.Test;
import java.util.Date;
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp;
public class JsonMessageConverterTest {
@Test
public void testConversionToDdp() throws Exception {
MyTestClass foo = new MyTestClass();
foo.setName("Hello, world!");
foo.setDate(new Date());
|
JsonMessageConverter converter = new JsonMessageConverter();
|
advantageous/ddp-client-java
|
ddp-client/src/main/java/io/advantageous/ddp/subscription/MapSubscriptionAdapter.java
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPMessageEndpoint.java
// public interface DDPMessageEndpoint {
// void disconnect() throws IOException;
//
// void connect(String address) throws IOException, InterruptedException;
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler.Phase phase, DDPMessageHandler<T> handler);
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler<T> handler);
//
// void await() throws InterruptedException;
//
// void send(Object message) throws IOException;
//
// }
|
import io.advantageous.ddp.DDPMessageEndpoint;
import io.advantageous.ddp.subscription.message.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import javax.inject.Named;
import java.util.HashMap;
import java.util.Map;
|
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp.subscription;
/**
* Simple subscription adapter to keep a map in sync with a meteor subscription.
*
* @author geoffc@gmail.com
* @since 1/21/14 at 4:24 PM.
*/
public class MapSubscriptionAdapter extends BaseSubscriptionAdapter {
private static final Logger LOGGER = LoggerFactory.getLogger(MapSubscriptionAdapter.class);
private static final boolean DEBUG = LOGGER.isDebugEnabled();
private static final boolean WARN = LOGGER.isWarnEnabled();
private final Map<String, Map<String, Object>> dataMap;
@Inject
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPMessageEndpoint.java
// public interface DDPMessageEndpoint {
// void disconnect() throws IOException;
//
// void connect(String address) throws IOException, InterruptedException;
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler.Phase phase, DDPMessageHandler<T> handler);
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler<T> handler);
//
// void await() throws InterruptedException;
//
// void send(Object message) throws IOException;
//
// }
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/MapSubscriptionAdapter.java
import io.advantageous.ddp.DDPMessageEndpoint;
import io.advantageous.ddp.subscription.message.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import javax.inject.Named;
import java.util.HashMap;
import java.util.Map;
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp.subscription;
/**
* Simple subscription adapter to keep a map in sync with a meteor subscription.
*
* @author geoffc@gmail.com
* @since 1/21/14 at 4:24 PM.
*/
public class MapSubscriptionAdapter extends BaseSubscriptionAdapter {
private static final Logger LOGGER = LoggerFactory.getLogger(MapSubscriptionAdapter.class);
private static final boolean DEBUG = LOGGER.isDebugEnabled();
private static final boolean WARN = LOGGER.isWarnEnabled();
private final Map<String, Map<String, Object>> dataMap;
@Inject
|
public MapSubscriptionAdapter(final DDPMessageEndpoint endpoint,
|
advantageous/ddp-client-java
|
examples/java-fx/src/main/java/io/advantageous/ddp/example/MainViewController.java
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/repository/MeteorCollectionRepository.java
// public interface MeteorCollectionRepository {
// void delete(String collectionName,
// String docId) throws IOException;
//
// void delete(String collectionName,
// String docId,
// RPCClient.SuccessHandler<Object> onSuccess,
// RPCClient.FailureHandler onFailure) throws IOException;
//
// void insert(String collectionName,
// Map<String, Object> insertParams,
// RPCClient.SuccessHandler<Object> onSuccess,
// RPCClient.FailureHandler onFailure) throws IOException;
//
// void update(String collectionName, String docId,
// Map<String, Object> updateParams,
// RPCClient.SuccessHandler<Object> onSuccess,
// RPCClient.FailureHandler onFailure) throws IOException;
// }
|
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.ResourceBundle;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import io.advantageous.ddp.repository.MeteorCollectionRepository;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.io.IOException;
|
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp.example;
@Singleton
@Presents("MainView.fxml")
public class MainViewController implements Initializable {
private static final Logger LOGGER = LoggerFactory.getLogger(MainViewController.class);
@FXML
private VBox scrollingVBox;
@FXML
private AnchorPane root;
@Inject
private EventBus eventBus;
@Inject
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/repository/MeteorCollectionRepository.java
// public interface MeteorCollectionRepository {
// void delete(String collectionName,
// String docId) throws IOException;
//
// void delete(String collectionName,
// String docId,
// RPCClient.SuccessHandler<Object> onSuccess,
// RPCClient.FailureHandler onFailure) throws IOException;
//
// void insert(String collectionName,
// Map<String, Object> insertParams,
// RPCClient.SuccessHandler<Object> onSuccess,
// RPCClient.FailureHandler onFailure) throws IOException;
//
// void update(String collectionName, String docId,
// Map<String, Object> updateParams,
// RPCClient.SuccessHandler<Object> onSuccess,
// RPCClient.FailureHandler onFailure) throws IOException;
// }
// Path: examples/java-fx/src/main/java/io/advantageous/ddp/example/MainViewController.java
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.ResourceBundle;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import io.advantageous.ddp.repository.MeteorCollectionRepository;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.io.IOException;
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp.example;
@Singleton
@Presents("MainView.fxml")
public class MainViewController implements Initializable {
private static final Logger LOGGER = LoggerFactory.getLogger(MainViewController.class);
@FXML
private VBox scrollingVBox;
@FXML
private AnchorPane root;
@Inject
private EventBus eventBus;
@Inject
|
private MeteorCollectionRepository meteorCollectionRepository;
|
advantageous/ddp-client-java
|
examples/java-fx/src/main/java/io/advantageous/ddp/example/SampleApplication.java
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/ConnectedMessage.java
// public class ConnectedMessage {
//
// private String session;
//
// public String getSession() {
// return session;
// }
//
// public void setSession(String session) {
// this.session = session;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPMessageEndpoint.java
// public interface DDPMessageEndpoint {
// void disconnect() throws IOException;
//
// void connect(String address) throws IOException, InterruptedException;
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler.Phase phase, DDPMessageHandler<T> handler);
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler<T> handler);
//
// void await() throws InterruptedException;
//
// void send(Object message) throws IOException;
//
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/ErrorMessage.java
// public class ErrorMessage {
//
// private String reason;
//
// private Object offendingMessage;
//
// public String getReason() {
// return reason;
// }
//
// public void setReason(String reason) {
// this.reason = reason;
// }
//
// public Object getOffendingMessage() {
// return offendingMessage;
// }
//
// public void setOffendingMessage(Object offendingMessage) {
// this.offendingMessage = offendingMessage;
// }
//
// @Override
// public String toString() {
// return "Error{" +
// "reason='" + reason + '\'' +
// ", offendingMessage=" + offendingMessage +
// '}';
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/Subscription.java
// public class Subscription {
//
// private final String subscriptionName;
//
// private final Object[] params;
//
// private final Class clazz;
//
// private final Callback callback;
//
// public Subscription(String subscriptionName, Object[] params, Class clazz, Callback callback) {
// this.subscriptionName = subscriptionName;
// this.params = params;
// this.clazz = clazz;
// this.callback = callback;
// }
//
// public Subscription(String subscriptionName) {
// this(subscriptionName, null, Object.class, null);
// }
//
// public Subscription(String subscriptionName, Object[] params) {
// this(subscriptionName, params, Object.class, null);
// }
//
// public Subscription(String subscriptionName, Class clazz) {
// this(subscriptionName, null, clazz, null);
// }
//
// public Subscription(String subscriptionName, Object[] params, Class clazz) {
// this(subscriptionName, params, clazz, null);
// }
//
// public Subscription(String subscriptionName, Class clazz, Callback callback) {
// this(subscriptionName, null, clazz, callback);
// }
//
// public Subscription(String subscriptionName, Object[] params, Callback callback) {
// this(subscriptionName, params, Object.class, callback);
// }
//
// public String getSubscriptionName() {
// return subscriptionName;
// }
//
// public Object[] getParams() {
// return params;
// }
//
// public Class getClazz() {
// return clazz;
// }
//
// public Callback getCallback() {
// return callback;
// }
//
// /**
// * Callback run when a subscription is handled.
// */
// public interface Callback {
//
// void onReady(String subscriptionId);
//
// void onFailure(String subscriptionId, DDPError error);
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/SubscriptionAdapter.java
// public interface SubscriptionAdapter {
//
// void subscribe(Subscription subscription) throws IOException;
//
// void unsubscribe(String subscriptionId) throws IOException;
//
// }
|
import javax.inject.Inject;
import java.io.IOException;
import com.google.inject.Guice;
import io.advantageous.ddp.ConnectedMessage;
import io.advantageous.ddp.DDPMessageEndpoint;
import io.advantageous.ddp.ErrorMessage;
import io.advantageous.ddp.subscription.Subscription;
import io.advantageous.ddp.subscription.SubscriptionAdapter;
import javafx.application.Application;
import javafx.concurrent.Service;
import javafx.concurrent.Task;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
|
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp.example;
public class SampleApplication extends Application {
private static final Logger LOGGER = LoggerFactory.getLogger(SampleApplication.class);
@Inject
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/ConnectedMessage.java
// public class ConnectedMessage {
//
// private String session;
//
// public String getSession() {
// return session;
// }
//
// public void setSession(String session) {
// this.session = session;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPMessageEndpoint.java
// public interface DDPMessageEndpoint {
// void disconnect() throws IOException;
//
// void connect(String address) throws IOException, InterruptedException;
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler.Phase phase, DDPMessageHandler<T> handler);
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler<T> handler);
//
// void await() throws InterruptedException;
//
// void send(Object message) throws IOException;
//
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/ErrorMessage.java
// public class ErrorMessage {
//
// private String reason;
//
// private Object offendingMessage;
//
// public String getReason() {
// return reason;
// }
//
// public void setReason(String reason) {
// this.reason = reason;
// }
//
// public Object getOffendingMessage() {
// return offendingMessage;
// }
//
// public void setOffendingMessage(Object offendingMessage) {
// this.offendingMessage = offendingMessage;
// }
//
// @Override
// public String toString() {
// return "Error{" +
// "reason='" + reason + '\'' +
// ", offendingMessage=" + offendingMessage +
// '}';
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/Subscription.java
// public class Subscription {
//
// private final String subscriptionName;
//
// private final Object[] params;
//
// private final Class clazz;
//
// private final Callback callback;
//
// public Subscription(String subscriptionName, Object[] params, Class clazz, Callback callback) {
// this.subscriptionName = subscriptionName;
// this.params = params;
// this.clazz = clazz;
// this.callback = callback;
// }
//
// public Subscription(String subscriptionName) {
// this(subscriptionName, null, Object.class, null);
// }
//
// public Subscription(String subscriptionName, Object[] params) {
// this(subscriptionName, params, Object.class, null);
// }
//
// public Subscription(String subscriptionName, Class clazz) {
// this(subscriptionName, null, clazz, null);
// }
//
// public Subscription(String subscriptionName, Object[] params, Class clazz) {
// this(subscriptionName, params, clazz, null);
// }
//
// public Subscription(String subscriptionName, Class clazz, Callback callback) {
// this(subscriptionName, null, clazz, callback);
// }
//
// public Subscription(String subscriptionName, Object[] params, Callback callback) {
// this(subscriptionName, params, Object.class, callback);
// }
//
// public String getSubscriptionName() {
// return subscriptionName;
// }
//
// public Object[] getParams() {
// return params;
// }
//
// public Class getClazz() {
// return clazz;
// }
//
// public Callback getCallback() {
// return callback;
// }
//
// /**
// * Callback run when a subscription is handled.
// */
// public interface Callback {
//
// void onReady(String subscriptionId);
//
// void onFailure(String subscriptionId, DDPError error);
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/SubscriptionAdapter.java
// public interface SubscriptionAdapter {
//
// void subscribe(Subscription subscription) throws IOException;
//
// void unsubscribe(String subscriptionId) throws IOException;
//
// }
// Path: examples/java-fx/src/main/java/io/advantageous/ddp/example/SampleApplication.java
import javax.inject.Inject;
import java.io.IOException;
import com.google.inject.Guice;
import io.advantageous.ddp.ConnectedMessage;
import io.advantageous.ddp.DDPMessageEndpoint;
import io.advantageous.ddp.ErrorMessage;
import io.advantageous.ddp.subscription.Subscription;
import io.advantageous.ddp.subscription.SubscriptionAdapter;
import javafx.application.Application;
import javafx.concurrent.Service;
import javafx.concurrent.Task;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp.example;
public class SampleApplication extends Application {
private static final Logger LOGGER = LoggerFactory.getLogger(SampleApplication.class);
@Inject
|
private DDPMessageEndpoint endpoint;
|
advantageous/ddp-client-java
|
examples/java-fx/src/main/java/io/advantageous/ddp/example/SampleApplication.java
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/ConnectedMessage.java
// public class ConnectedMessage {
//
// private String session;
//
// public String getSession() {
// return session;
// }
//
// public void setSession(String session) {
// this.session = session;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPMessageEndpoint.java
// public interface DDPMessageEndpoint {
// void disconnect() throws IOException;
//
// void connect(String address) throws IOException, InterruptedException;
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler.Phase phase, DDPMessageHandler<T> handler);
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler<T> handler);
//
// void await() throws InterruptedException;
//
// void send(Object message) throws IOException;
//
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/ErrorMessage.java
// public class ErrorMessage {
//
// private String reason;
//
// private Object offendingMessage;
//
// public String getReason() {
// return reason;
// }
//
// public void setReason(String reason) {
// this.reason = reason;
// }
//
// public Object getOffendingMessage() {
// return offendingMessage;
// }
//
// public void setOffendingMessage(Object offendingMessage) {
// this.offendingMessage = offendingMessage;
// }
//
// @Override
// public String toString() {
// return "Error{" +
// "reason='" + reason + '\'' +
// ", offendingMessage=" + offendingMessage +
// '}';
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/Subscription.java
// public class Subscription {
//
// private final String subscriptionName;
//
// private final Object[] params;
//
// private final Class clazz;
//
// private final Callback callback;
//
// public Subscription(String subscriptionName, Object[] params, Class clazz, Callback callback) {
// this.subscriptionName = subscriptionName;
// this.params = params;
// this.clazz = clazz;
// this.callback = callback;
// }
//
// public Subscription(String subscriptionName) {
// this(subscriptionName, null, Object.class, null);
// }
//
// public Subscription(String subscriptionName, Object[] params) {
// this(subscriptionName, params, Object.class, null);
// }
//
// public Subscription(String subscriptionName, Class clazz) {
// this(subscriptionName, null, clazz, null);
// }
//
// public Subscription(String subscriptionName, Object[] params, Class clazz) {
// this(subscriptionName, params, clazz, null);
// }
//
// public Subscription(String subscriptionName, Class clazz, Callback callback) {
// this(subscriptionName, null, clazz, callback);
// }
//
// public Subscription(String subscriptionName, Object[] params, Callback callback) {
// this(subscriptionName, params, Object.class, callback);
// }
//
// public String getSubscriptionName() {
// return subscriptionName;
// }
//
// public Object[] getParams() {
// return params;
// }
//
// public Class getClazz() {
// return clazz;
// }
//
// public Callback getCallback() {
// return callback;
// }
//
// /**
// * Callback run when a subscription is handled.
// */
// public interface Callback {
//
// void onReady(String subscriptionId);
//
// void onFailure(String subscriptionId, DDPError error);
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/SubscriptionAdapter.java
// public interface SubscriptionAdapter {
//
// void subscribe(Subscription subscription) throws IOException;
//
// void unsubscribe(String subscriptionId) throws IOException;
//
// }
|
import javax.inject.Inject;
import java.io.IOException;
import com.google.inject.Guice;
import io.advantageous.ddp.ConnectedMessage;
import io.advantageous.ddp.DDPMessageEndpoint;
import io.advantageous.ddp.ErrorMessage;
import io.advantageous.ddp.subscription.Subscription;
import io.advantageous.ddp.subscription.SubscriptionAdapter;
import javafx.application.Application;
import javafx.concurrent.Service;
import javafx.concurrent.Task;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
|
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp.example;
public class SampleApplication extends Application {
private static final Logger LOGGER = LoggerFactory.getLogger(SampleApplication.class);
@Inject
private DDPMessageEndpoint endpoint;
@Inject
private MainViewController mainController;
@Inject
|
// Path: ddp-client/src/main/java/io/advantageous/ddp/ConnectedMessage.java
// public class ConnectedMessage {
//
// private String session;
//
// public String getSession() {
// return session;
// }
//
// public void setSession(String session) {
// this.session = session;
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/DDPMessageEndpoint.java
// public interface DDPMessageEndpoint {
// void disconnect() throws IOException;
//
// void connect(String address) throws IOException, InterruptedException;
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler.Phase phase, DDPMessageHandler<T> handler);
//
// <T> void registerHandler(Class<T> messageType, DDPMessageHandler<T> handler);
//
// void await() throws InterruptedException;
//
// void send(Object message) throws IOException;
//
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/ErrorMessage.java
// public class ErrorMessage {
//
// private String reason;
//
// private Object offendingMessage;
//
// public String getReason() {
// return reason;
// }
//
// public void setReason(String reason) {
// this.reason = reason;
// }
//
// public Object getOffendingMessage() {
// return offendingMessage;
// }
//
// public void setOffendingMessage(Object offendingMessage) {
// this.offendingMessage = offendingMessage;
// }
//
// @Override
// public String toString() {
// return "Error{" +
// "reason='" + reason + '\'' +
// ", offendingMessage=" + offendingMessage +
// '}';
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/Subscription.java
// public class Subscription {
//
// private final String subscriptionName;
//
// private final Object[] params;
//
// private final Class clazz;
//
// private final Callback callback;
//
// public Subscription(String subscriptionName, Object[] params, Class clazz, Callback callback) {
// this.subscriptionName = subscriptionName;
// this.params = params;
// this.clazz = clazz;
// this.callback = callback;
// }
//
// public Subscription(String subscriptionName) {
// this(subscriptionName, null, Object.class, null);
// }
//
// public Subscription(String subscriptionName, Object[] params) {
// this(subscriptionName, params, Object.class, null);
// }
//
// public Subscription(String subscriptionName, Class clazz) {
// this(subscriptionName, null, clazz, null);
// }
//
// public Subscription(String subscriptionName, Object[] params, Class clazz) {
// this(subscriptionName, params, clazz, null);
// }
//
// public Subscription(String subscriptionName, Class clazz, Callback callback) {
// this(subscriptionName, null, clazz, callback);
// }
//
// public Subscription(String subscriptionName, Object[] params, Callback callback) {
// this(subscriptionName, params, Object.class, callback);
// }
//
// public String getSubscriptionName() {
// return subscriptionName;
// }
//
// public Object[] getParams() {
// return params;
// }
//
// public Class getClazz() {
// return clazz;
// }
//
// public Callback getCallback() {
// return callback;
// }
//
// /**
// * Callback run when a subscription is handled.
// */
// public interface Callback {
//
// void onReady(String subscriptionId);
//
// void onFailure(String subscriptionId, DDPError error);
// }
// }
//
// Path: ddp-client/src/main/java/io/advantageous/ddp/subscription/SubscriptionAdapter.java
// public interface SubscriptionAdapter {
//
// void subscribe(Subscription subscription) throws IOException;
//
// void unsubscribe(String subscriptionId) throws IOException;
//
// }
// Path: examples/java-fx/src/main/java/io/advantageous/ddp/example/SampleApplication.java
import javax.inject.Inject;
import java.io.IOException;
import com.google.inject.Guice;
import io.advantageous.ddp.ConnectedMessage;
import io.advantageous.ddp.DDPMessageEndpoint;
import io.advantageous.ddp.ErrorMessage;
import io.advantageous.ddp.subscription.Subscription;
import io.advantageous.ddp.subscription.SubscriptionAdapter;
import javafx.application.Application;
import javafx.concurrent.Service;
import javafx.concurrent.Task;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*
* Copyright (C) 2014. Geoffrey Chandler.
*
* 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 io.advantageous.ddp.example;
public class SampleApplication extends Application {
private static final Logger LOGGER = LoggerFactory.getLogger(SampleApplication.class);
@Inject
private DDPMessageEndpoint endpoint;
@Inject
private MainViewController mainController;
@Inject
|
private SubscriptionAdapter adapter;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.