org.apache.flink.client.program.ProgramParametrizationException Java Examples

The following examples show how to use org.apache.flink.client.program.ProgramParametrizationException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GridGraph.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Configuration string to be parsed. The size integer and endpoint
 * wrapping boolean must be separated by a colon.
 *
 * @param field configuration string
 */
public Dimension(String field) {
	ProgramParametrizationException exception = new ProgramParametrizationException("Grid dimension must use " +
		"a colon to separate the integer size and boolean indicating whether the dimension endpoints are " +
		"connected: '" + field + "'");

	if (!field.contains(":")) {
		throw exception;
	}

	String[] parts = field.split(":");

	if (parts.length != 2) {
		throw exception;
	}

	try {
		size = Long.parseLong(parts[0]);
		wrapEndpoints = Boolean.parseBoolean(parts[1]);
	} catch (NumberFormatException ex) {
		throw exception;
	}
}
 
Example #2
Source File: GridGraph.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(ParameterTool parameterTool) throws ProgramParametrizationException {
	super.configure(parameterTool);

	// add dimensions as ordered by dimension ID (dim0, dim1, dim2, ...)

	Map<Integer, String> dimensionMap = new TreeMap<>();

	// first parse all dimensions into a sorted map
	for (String key : parameterTool.toMap().keySet()) {
		if (key.startsWith(PREFIX)) {
			int dimensionId = Integer.parseInt(key.substring(PREFIX.length()));
			dimensionMap.put(dimensionId, parameterTool.get(key));
		}
	}

	// then store dimensions in order
	for (String field : dimensionMap.values()) {
		dimensions.add(new Dimension(field));
	}
}
 
Example #3
Source File: Simplify.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(ParameterTool parameterTool) {
	String ordering = parameterTool.get("simplify");

	if (ordering == null) {
		value = Ordering.NONE;
	} else {
		switch (ordering.toLowerCase()) {
			case "directed":
				value = Ordering.DIRECTED;
				break;
			case "undirected":
				value = parameterTool.has("clip_and_flip") ? Ordering.UNDIRECTED_CLIP_AND_FLIP : Ordering.UNDIRECTED;
				break;
			default:
				throw new ProgramParametrizationException(
					"Expected 'directed' or 'undirected' ordering but received '" + ordering + "'");
		}
	}
}
 
Example #4
Source File: Simplify.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(ParameterTool parameterTool) {
	String ordering = parameterTool.get("simplify");

	if (ordering == null) {
		value = Ordering.NONE;
	} else {
		switch (ordering.toLowerCase()) {
			case "directed":
				value = Ordering.DIRECTED;
				break;
			case "undirected":
				value = parameterTool.has("clip_and_flip") ? Ordering.UNDIRECTED_CLIP_AND_FLIP : Ordering.UNDIRECTED;
				break;
			default:
				throw new ProgramParametrizationException(
					"Expected 'directed' or 'undirected' ordering but received '" + ordering + "'");
		}
	}
}
 
Example #5
Source File: GridGraph.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Configuration string to be parsed. The size integer and endpoint
 * wrapping boolean must be separated by a colon.
 *
 * @param field configuration string
 */
public Dimension(String field) {
	ProgramParametrizationException exception = new ProgramParametrizationException("Grid dimension must use " +
		"a colon to separate the integer size and boolean indicating whether the dimension endpoints are " +
		"connected: '" + field + "'");

	if (!field.contains(":")) {
		throw exception;
	}

	String[] parts = field.split(":");

	if (parts.length != 2) {
		throw exception;
	}

	try {
		size = Long.parseLong(parts[0]);
		wrapEndpoints = Boolean.parseBoolean(parts[1]);
	} catch (NumberFormatException ex) {
		throw exception;
	}
}
 
Example #6
Source File: DoubleParameterTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testMinAndMaxBelowRange() {
	parameter.setMinimumValue(-1, false);
	parameter.setMaximumValue(1, false);

	expectedException.expect(ProgramParametrizationException.class);
	expectedException.expectMessage("test must be greater than -1.0");

	parameter.configure(ParameterTool.fromArgs(new String[]{"--test", "-2"}));
}
 
Example #7
Source File: TriangleListingITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testLongDescription() throws Exception {
	String expected = regexSubstring(new TriangleListing().getLongDescription());

	expectedOutputFromException(
		new String[]{"--algorithm", "TriangleListing"},
		expected,
		ProgramParametrizationException.class);
}
 
Example #8
Source File: EdgeListITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testLongDescription() throws Exception {
	String expected = regexSubstring(new EdgeList().getLongDescription());

	expectedOutputFromException(
		new String[]{"--algorithm", "EdgeList"},
		expected,
		ProgramParametrizationException.class);
}
 
Example #9
Source File: DoubleParameterTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testMinAtRangeExclusive() {
	parameter.setMinimumValue(0, false);

	expectedException.expect(ProgramParametrizationException.class);
	expectedException.expectMessage("test must be greater than 0.0");

	parameter.configure(ParameterTool.fromArgs(new String[]{"--test", "0"}));
}
 
Example #10
Source File: DoubleParameterTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testMinAndMaxAtRangeMaximumExclusive() {
	parameter.setMinimumValue(-1, false);
	parameter.setMaximumValue(1, false);

	expectedException.expect(ProgramParametrizationException.class);
	expectedException.expectMessage("test must be less than 1.0");

	parameter.configure(ParameterTool.fromArgs(new String[]{"--test", "1"}));
}
 
Example #11
Source File: DoubleParameterTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testMinAndMaxAtRangeMinimumExclusive() {
	parameter.setMinimumValue(-1, false);
	parameter.setMaximumValue(1, false);

	expectedException.expect(ProgramParametrizationException.class);
	expectedException.expectMessage("test must be greater than -1.0");

	parameter.configure(ParameterTool.fromArgs(new String[]{"--test", "-1"}));
}
 
Example #12
Source File: DoubleParameterTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testDefaultValueAboveMaximum() {
	parameter.setMaximumValue(-1.0, false);

	expectedException.expect(ProgramParametrizationException.class);
	expectedException.expectMessage("Default value (0.0) must be less than maximum (-1.0)");

	parameter.setDefaultValue(0);
}
 
Example #13
Source File: DoubleParameterTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testMaxOutOfRangeExclusive() {
	parameter.setMaximumValue(0, true);

	expectedException.expect(ProgramParametrizationException.class);
	expectedException.expectMessage("test must be less than or equal to 0.0");

	parameter.configure(ParameterTool.fromArgs(new String[]{"--test", "1"}));
}
 
Example #14
Source File: DoubleParameterTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testMaxOutOfRange() {
	parameter.setMaximumValue(0, false);

	expectedException.expect(ProgramParametrizationException.class);
	expectedException.expectMessage("test must be less than 0.0");

	parameter.configure(ParameterTool.fromArgs(new String[]{"--test", "1"}));
}
 
Example #15
Source File: DoubleParameterTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testMaxAtRangeExclusive() {
	parameter.setMaximumValue(0, false);

	expectedException.expect(ProgramParametrizationException.class);
	expectedException.expectMessage("test must be less than 0.0");

	parameter.configure(ParameterTool.fromArgs(new String[]{"--test", "0"}));
}
 
Example #16
Source File: DoubleParameterTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testMinOutOfRangeExclusive() {
	parameter.setMinimumValue(0, true);

	expectedException.expect(ProgramParametrizationException.class);
	expectedException.expectMessage("test must be greater than or equal to 0.0");

	parameter.configure(ParameterTool.fromArgs(new String[]{"--test", "-1"}));
}
 
Example #17
Source File: DoubleParameterTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testMinOutOfRange() {
	parameter.setMinimumValue(0, false);

	expectedException.expect(ProgramParametrizationException.class);
	expectedException.expectMessage("test must be greater than 0.0");

	parameter.configure(ParameterTool.fromArgs(new String[]{"--test", "-1"}));
}
 
Example #18
Source File: RunnerITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithoutAlgorithm() throws Exception {
	String expected = "Select an algorithm to view usage:";

	thrown.expect(ProgramParametrizationException.class);
	thrown.expectMessage(expected);

	expectedOutput(new String[]{}, expected);
}
 
Example #19
Source File: CSV.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Graph<K, NullValue, NullValue> create(ExecutionEnvironment env) throws Exception {
	GraphCsvReader reader = Graph.fromCsvReader(inputFilename.getValue(), env)
		.ignoreCommentsEdges(commentPrefix.getValue())
		.lineDelimiterEdges(lineDelimiter.getValue())
		.fieldDelimiterEdges(fieldDelimiter.getValue());

	Graph<K, NullValue, NullValue> graph;

	switch (type.getValue()) {
		case INTEGER:
			graph = (Graph<K, NullValue, NullValue>) reader
				.keyType(IntValue.class);
			break;

		case LONG:
			graph = (Graph<K, NullValue, NullValue>) reader
				.keyType(LongValue.class);
			break;

		case STRING:
			graph = (Graph<K, NullValue, NullValue>) reader
				.keyType(StringValue.class);
			break;

		default:
			throw new ProgramParametrizationException("Unknown type '" + type.getValue() + "'");
	}

	return simplify.simplify(graph, parallelism.getValue().intValue());
}
 
Example #20
Source File: LongParameterTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testMinOutOfRange() {
	parameter.setMinimumValue(0);

	expectedException.expect(ProgramParametrizationException.class);
	expectedException.expectMessage("test must be greater than or equal to 0");

	parameter.configure(ParameterTool.fromArgs(new String[]{"--test", "-1"}));
}
 
Example #21
Source File: JaccardIndexITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testLongDescription() throws Exception {
	String expected = regexSubstring(new JaccardIndex().getLongDescription());

	expectedOutputFromException(
		new String[]{"--algorithm", "JaccardIndex"},
		expected,
		ProgramParametrizationException.class);
}
 
Example #22
Source File: RunnerITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithoutOutput() throws Exception {
	String expected = "No output given";

	thrown.expect(ProgramParametrizationException.class);
	thrown.expectMessage(expected);

	expectedOutput(
		new String[]{"--algorithm", "EdgeList",
			"--input", "RMatGraph"},
		expected);
}
 
Example #23
Source File: RunnerITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithUnknownInput() throws Exception {
	String expected = "Unknown input type: NotAnInput";

	thrown.expect(ProgramParametrizationException.class);
	thrown.expectMessage(expected);

	expectedOutput(
		new String[]{"--algorithm", "EdgeList",
			"--input", "NotAnInput"},
		expected);
}
 
Example #24
Source File: LongParameterTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testMinAndMaxBelowRange() {
	parameter.setMinimumValue(-1);
	parameter.setMaximumValue(1);

	expectedException.expect(ProgramParametrizationException.class);
	expectedException.expectMessage("test must be greater than or equal to -1");

	parameter.configure(ParameterTool.fromArgs(new String[]{"--test", "-2"}));
}
 
Example #25
Source File: DoubleParameterTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testMinAndMaxAboveRange() {
	parameter.setMinimumValue(-1, false);
	parameter.setMaximumValue(1, false);

	expectedException.expect(ProgramParametrizationException.class);
	expectedException.expectMessage("test must be less than 1.0");

	parameter.configure(ParameterTool.fromArgs(new String[]{"--test", "2"}));
}
 
Example #26
Source File: RunnerITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithUnknownAlgorithm() throws Exception {
	String expected = "Unknown algorithm name: NotAnAlgorithm";

	thrown.expect(ProgramParametrizationException.class);
	thrown.expectMessage(expected);

	expectedOutput(new String[]{"--algorithm", "NotAnAlgorithm"}, expected);
}
 
Example #27
Source File: RunnerITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithoutAlgorithm() throws Exception {
	String expected = "Select an algorithm to view usage:";

	thrown.expect(ProgramParametrizationException.class);
	thrown.expectMessage(expected);

	expectedOutput(new String[]{}, expected);
}
 
Example #28
Source File: RunnerITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithUnknownInput() throws Exception {
	String expected = "Unknown input type: NotAnInput";

	thrown.expect(ProgramParametrizationException.class);
	thrown.expectMessage(expected);

	expectedOutput(
		new String[]{"--algorithm", "EdgeList",
			"--input", "NotAnInput"},
		expected);
}
 
Example #29
Source File: PageRankITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testLongDescription() throws Exception {
	String expected = regexSubstring(new PageRank().getLongDescription());

	expectedOutputFromException(
		new String[]{"--algorithm", "PageRank"},
		expected,
		ProgramParametrizationException.class);
}
 
Example #30
Source File: RunnerITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithoutInput() throws Exception {
	String expected = "No input given";

	thrown.expect(ProgramParametrizationException.class);
	thrown.expectMessage(expected);

	expectedOutput(
		new String[]{"--algorithm", "EdgeList",
			"--output", "NotAnOutput"},
		expected);
}