/** * Displays an optional exception message for incorrect program parametrization. * * @param e The exception to display. * @return The return code for the process. */ private static int handleParametrizationException(ProgramParametrizationException e) { LOG.error("Program has not been parametrized properly.", e); System.err.println(e.getMessage()); return 1; }
@Override protected long vertexCount() { BigInteger vertexCount = BigInteger.ONE; for (Dimension dimension : dimensions) { vertexCount = vertexCount.multiply(BigInteger.valueOf(dimension.size)); } if (vertexCount.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) > 0) { throw new ProgramParametrizationException("Number of vertices in grid graph '" + vertexCount + "' is greater than Long.MAX_VALUE."); } return vertexCount.longValue(); }
/** * Displays an optional exception message for incorrect program parametrization. * * @param e The exception to display. * @return The return code for the process. */ private int handleParametrizationException(ProgramParametrizationException e) { System.err.println(e.getMessage()); return 1; }
/** * Checks the given boolean condition, and throws an {@code ProgramParametrizationException} if * the condition is not met (evaluates to {@code false}). The exception will have the * given error message. * * @param condition The condition to check * @param errorMessage The message for the {@code ProgramParametrizationException} that is thrown if the check fails. * * @throws ProgramParametrizationException Thrown, if the condition is violated. * * @see Preconditions#checkNotNull(Object, String) */ public static void checkParameter(boolean condition, @Nullable Object errorMessage) { if (!condition) { throw new ProgramParametrizationException(String.valueOf(errorMessage)); } } }
/** * Displays an optional exception message for incorrect program parametrization. * * @param e The exception to display. * @return The return code for the process. */ private static int handleParametrizationException(ProgramParametrizationException e) { LOG.error("Program has not been parametrized properly.", e); System.err.println(e.getMessage()); return 1; }
/** * 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; } }
/** * Displays an optional exception message for incorrect program parametrization. * * @param e The exception to display. * @return The return code for the process. */ private static int handleParametrizationException(ProgramParametrizationException e) { LOG.error("Program has not been parametrized properly.", e); System.err.println(e.getMessage()); return 1; }
/** * Configure a runtime component. Catch {@link RuntimeException} and * re-throw with a Flink internal exception which is processed by * CliFrontend for display to the user. * * @param parameterized the component to be configured */ private void parameterize(Parameterized parameterized) { try { parameterized.configure(parameters); } catch (RuntimeException ex) { throw new ProgramParametrizationException(ex.getMessage()); } }
@Override public void configure(ParameterTool parameterTool) { Preconditions.checkArgument(choices.size() > 0, "No choices provided"); String selected = parameterTool.get(name); if (selected == null) { if (hasDefaultValue) { value = defaultValue; return; } else { throw new ProgramParametrizationException( "Must select a choice for option '" + name + "': '[" + StringUtils.join(choices, ", ") + "]'"); } } for (String choice : choices) { if (choice.equals(selected)) { this.value = selected; return; } } for (String choice : hiddenChoices) { if (choice.equals(selected)) { this.value = selected; return; } } throw new ProgramParametrizationException( "Selection '" + selected + "' for option '" + name + "' is not in choices '[" + StringUtils.join(choices, ", ") + "]'"); }
@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 + "'"); } } }
ProgramParametrizationException exception = new ProgramParametrizationException("Circulant offset range" + " must use a colon to separate the integer offset and integer length:" + field + "'");
this.configure(parameters); } catch (RuntimeException ex) { throw new ProgramParametrizationException(ex.getMessage()); throw new ProgramParametrizationException(getAlgorithmsListing()); throw new ProgramParametrizationException("Unknown algorithm name: " + algorithmName); if (!parameters.has(OUTPUT)) { throw new ProgramParametrizationException(getAlgorithmUsage(algorithmName)); throw new ProgramParametrizationException("No input given"); throw new ProgramParametrizationException("Unknown input type: " + inputName); throw new ProgramParametrizationException("No output given"); throw new ProgramParametrizationException("Unknown output type: " + outputName); throw new ProgramParametrizationException("Unrequested parameters: " + parameters.getUnrequestedParameters()); throw new ProgramParametrizationException("Unknown output type: " + outputName); output.configure(parameters); } catch (RuntimeException ex) { throw new ProgramParametrizationException(ex.getMessage());
throw new ProgramParametrizationException("Unknown type '" + type.getValue() + "'");
throw new ProgramParametrizationException("Unknown type '" + type.getValue() + "'"); throw new ProgramParametrizationException("Vertex count '" + vertexCount + "' must be no greater than " + maxVertexCount + " for type '" + type.getValue() + "'.");
throw new ProgramParametrizationException("Unknown type '" + type.getValue() + "'");