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 Project: Flink-CEPplus   Author: ljygz   File: Simplify.java    License: 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 #2
Source Project: Flink-CEPplus   Author: ljygz   File: GridGraph.java    License: 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 #3
Source Project: flink   Author: flink-tpc-ds   File: Simplify.java    License: 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 Project: flink   Author: flink-tpc-ds   File: GridGraph.java    License: 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 #5
Source Project: flink   Author: flink-tpc-ds   File: GridGraph.java    License: 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 Project: flink   Author: flink-tpc-ds   File: PageRankITCase.java    License: 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 #7
Source Project: flink   Author: flink-tpc-ds   File: RunnerITCase.java    License: 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 #8
Source Project: Flink-CEPplus   Author: ljygz   File: CSV.java    License: 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 #9
Source Project: Flink-CEPplus   Author: ljygz   File: TriangleListingITCase.java    License: 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 #10
Source Project: Flink-CEPplus   Author: ljygz   File: HITSITCase.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testLongDescription() throws Exception {
	String expected = regexSubstring(new HITS().getLongDescription());

	expectedOutputFromException(
		new String[]{"--algorithm", "HITS"},
		expected,
		ProgramParametrizationException.class);
}
 
Example #11
Source Project: Flink-CEPplus   Author: ljygz   File: ClusteringCoefficientITCase.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testLongDescription() throws Exception {
	String expected = regexSubstring(new ClusteringCoefficient().getLongDescription());

	expectedOutputFromException(
		new String[]{"--algorithm", "ClusteringCoefficient"},
		expected,
		ProgramParametrizationException.class);
}
 
Example #12
Source Project: flink   Author: flink-tpc-ds   File: LongParameterTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testMaximumValueBelowMinimum() {
	parameter.setMinimumValue(0);

	expectedException.expect(ProgramParametrizationException.class);
	expectedException.expectMessage("Maximum value (-1) must be greater than or equal to minimum (0)");

	parameter.setMaximumValue(-1);
}
 
Example #13
Source Project: flink   Author: flink-tpc-ds   File: LongParameterTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testMinimumValueAboveMaximum() {
	parameter.setMaximumValue(0);

	expectedException.expect(ProgramParametrizationException.class);
	expectedException.expectMessage("Minimum value (1) must be less than or equal to maximum (0)");

	parameter.setMinimumValue(1);
}
 
Example #14
Source Project: Flink-CEPplus   Author: ljygz   File: DoubleParameterTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testMinimumValueAboveMaximum() {
	parameter.setMaximumValue(0.0, false);

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

	parameter.setMinimumValue(1.0, false);
}
 
Example #15
Source Project: Flink-CEPplus   Author: ljygz   File: DoubleParameterTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testMinimumValueAboveDefault() {
	parameter.setDefaultValue(0);

	expectedException.expect(ProgramParametrizationException.class);
	expectedException.expectMessage("Minimum value (1.0) must be less than default (0.0)");

	parameter.setMinimumValue(1.0, false);
}
 
Example #16
Source Project: Flink-CEPplus   Author: ljygz   File: DoubleParameterTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testMaximumValueBelowMinimum() {
	parameter.setMinimumValue(0.0, false);

	expectedException.expect(ProgramParametrizationException.class);
	expectedException.expectMessage("Maximum value (-1.0) must be greater than minimum (0.0)");

	parameter.setMaximumValue(-1.0, false);
}
 
Example #17
Source Project: Flink-CEPplus   Author: ljygz   File: DoubleParameterTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testMaximumValueBelowDefault() {
	parameter.setDefaultValue(0);

	expectedException.expect(ProgramParametrizationException.class);
	expectedException.expectMessage("Maximum value (-1.0) must be greater than default (0.0)");

	parameter.setMaximumValue(-1.0, false);
}
 
Example #18
Source Project: Flink-CEPplus   Author: ljygz   File: DoubleParameterTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testMinimumEqualsMaximumExclusive() {
	parameter.setMaximumValue(0.0, true);

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

	parameter.setMinimumValue(0.0, false);
}
 
Example #19
Source Project: Flink-CEPplus   Author: ljygz   File: DoubleParameterTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testMaximumEqualsMinimumExclusive() {
	parameter.setMinimumValue(0.0, true);

	expectedException.expect(ProgramParametrizationException.class);
	expectedException.expectMessage("Maximum value (0.0) must be greater than minimum (0.0)");

	parameter.setMaximumValue(0.0, false);
}
 
Example #20
Source Project: Flink-CEPplus   Author: ljygz   File: DoubleParameterTest.java    License: 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 #21
Source Project: flink   Author: flink-tpc-ds   File: RunnerITCase.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testAlgorithmUsage() throws Exception {
	String expected = "Pass-through of the graph's edge list.";

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

	expectedOutput(new String[]{"--algorithm", "EdgeList"}, expected);
}
 
Example #22
Source Project: flink   Author: flink-tpc-ds   File: ConnectedComponentsITCase.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testLongDescription() throws Exception {
	String expected = regexSubstring(new ConnectedComponents().getLongDescription());

	expectedOutputFromException(
		new String[]{"--algorithm", "ConnectedComponents"},
		expected,
		ProgramParametrizationException.class);
}
 
Example #23
Source Project: Flink-CEPplus   Author: ljygz   File: DoubleParameterTest.java    License: 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 #24
Source Project: Flink-CEPplus   Author: ljygz   File: DoubleParameterTest.java    License: 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 #25
Source Project: Flink-CEPplus   Author: ljygz   File: DoubleParameterTest.java    License: 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 #26
Source Project: Flink-CEPplus   Author: ljygz   File: DoubleParameterTest.java    License: 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 #27
Source Project: Flink-CEPplus   Author: ljygz   File: DoubleParameterTest.java    License: 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 #28
Source Project: Flink-CEPplus   Author: ljygz   File: DoubleParameterTest.java    License: 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 #29
Source Project: Flink-CEPplus   Author: ljygz   File: DoubleParameterTest.java    License: 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 #30
Source Project: Flink-CEPplus   Author: ljygz   File: LongParameterTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testMinimumValueAboveMaximum() {
	parameter.setMaximumValue(0);

	expectedException.expect(ProgramParametrizationException.class);
	expectedException.expectMessage("Minimum value (1) must be less than or equal to maximum (0)");

	parameter.setMinimumValue(1);
}