Java Code Examples for org.apache.flink.api.java.utils.ParameterTool#getDouble()

The following examples show how to use org.apache.flink.api.java.utils.ParameterTool#getDouble() . 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: IterationConvergence.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(ParameterTool parameterTool) {
	if (!parameterTool.has("iterations") && !parameterTool.has("convergence_threshold")) {
		// no configuration so use default iterations and maximum threshold
		value.iterations = defaultIterations;
		value.convergenceThreshold = Double.MAX_VALUE;
	} else {
		// use configured values and maximum default for unset values
		value.iterations = parameterTool.getInt("iterations", Integer.MAX_VALUE);
		Util.checkParameter(value.iterations > 0,
			"iterations must be greater than zero");

		value.convergenceThreshold = parameterTool.getDouble("convergence_threshold", Double.MAX_VALUE);
		Util.checkParameter(value.convergenceThreshold > 0,
			"convergence threshold must be greater than zero");
	}
}
 
Example 2
Source File: DoubleParameter.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(ParameterTool parameterTool) {
	value = hasDefaultValue ? parameterTool.getDouble(name, defaultValue) : parameterTool.getDouble(name);

	if (hasMinimumValue) {
		if (minimumValueInclusive) {
			Util.checkParameter(value >= minimumValue,
				name + " must be greater than or equal to " + minimumValue);
		} else {
			Util.checkParameter(value > minimumValue,
				name + " must be greater than " + minimumValue);
		}
	}

	if (hasMaximumValue) {
		if (maximumValueInclusive) {
			Util.checkParameter(value <= maximumValue,
				name + " must be less than or equal to " + maximumValue);
		} else {
			Util.checkParameter(value < maximumValue,
				name + " must be less than " + maximumValue);
		}
	}
}
 
Example 3
Source File: IterationConvergence.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(ParameterTool parameterTool) {
	if (!parameterTool.has("iterations") && !parameterTool.has("convergence_threshold")) {
		// no configuration so use default iterations and maximum threshold
		value.iterations = defaultIterations;
		value.convergenceThreshold = Double.MAX_VALUE;
	} else {
		// use configured values and maximum default for unset values
		value.iterations = parameterTool.getInt("iterations", Integer.MAX_VALUE);
		Util.checkParameter(value.iterations > 0,
			"iterations must be greater than zero");

		value.convergenceThreshold = parameterTool.getDouble("convergence_threshold", Double.MAX_VALUE);
		Util.checkParameter(value.convergenceThreshold > 0,
			"convergence threshold must be greater than zero");
	}
}
 
Example 4
Source File: DoubleParameter.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(ParameterTool parameterTool) {
	value = hasDefaultValue ? parameterTool.getDouble(name, defaultValue) : parameterTool.getDouble(name);

	if (hasMinimumValue) {
		if (minimumValueInclusive) {
			Util.checkParameter(value >= minimumValue,
				name + " must be greater than or equal to " + minimumValue);
		} else {
			Util.checkParameter(value > minimumValue,
				name + " must be greater than " + minimumValue);
		}
	}

	if (hasMaximumValue) {
		if (maximumValueInclusive) {
			Util.checkParameter(value <= maximumValue,
				name + " must be less than or equal to " + maximumValue);
		} else {
			Util.checkParameter(value < maximumValue,
				name + " must be less than " + maximumValue);
		}
	}
}
 
Example 5
Source File: IterationConvergence.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(ParameterTool parameterTool) {
	if (!parameterTool.has("iterations") && !parameterTool.has("convergence_threshold")) {
		// no configuration so use default iterations and maximum threshold
		value.iterations = defaultIterations;
		value.convergenceThreshold = Double.MAX_VALUE;
	} else {
		// use configured values and maximum default for unset values
		value.iterations = parameterTool.getInt("iterations", Integer.MAX_VALUE);
		Util.checkParameter(value.iterations > 0,
			"iterations must be greater than zero");

		value.convergenceThreshold = parameterTool.getDouble("convergence_threshold", Double.MAX_VALUE);
		Util.checkParameter(value.convergenceThreshold > 0,
			"convergence threshold must be greater than zero");
	}
}
 
Example 6
Source File: DoubleParameter.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(ParameterTool parameterTool) {
	value = hasDefaultValue ? parameterTool.getDouble(name, defaultValue) : parameterTool.getDouble(name);

	if (hasMinimumValue) {
		if (minimumValueInclusive) {
			Util.checkParameter(value >= minimumValue,
				name + " must be greater than or equal to " + minimumValue);
		} else {
			Util.checkParameter(value > minimumValue,
				name + " must be greater than " + minimumValue);
		}
	}

	if (hasMaximumValue) {
		if (maximumValueInclusive) {
			Util.checkParameter(value <= maximumValue,
				name + " must be less than or equal to " + maximumValue);
		} else {
			Util.checkParameter(value < maximumValue,
				name + " must be less than " + maximumValue);
		}
	}
}
 
Example 7
Source File: KafkaEventsGeneratorJob.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

		final ParameterTool params = ParameterTool.fromArgs(args);

		double errorRate = params.getDouble("error-rate", 0.0);
		int sleep = params.getInt("sleep", 1);

		String kafkaTopic = params.get("kafka-topic");
		String brokers = params.get("brokers", "localhost:9092");

		System.out.printf("Generating events to Kafka with standalone source with error rate %f and sleep delay %s millis\n", errorRate, sleep);
		System.out.println();

		final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

		env
			.addSource(new EventsGeneratorSource(errorRate, sleep))
			.addSink(new FlinkKafkaProducer010<>(brokers, kafkaTopic, new EventDeSerializer()));

		// trigger program execution
		env.execute("State machine example Kafka events generator job");
	}
 
Example 8
Source File: KafkaEventsGeneratorJob.java    From flink with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

		final ParameterTool params = ParameterTool.fromArgs(args);

		double errorRate = params.getDouble("error-rate", 0.0);
		int sleep = params.getInt("sleep", 1);

		String kafkaTopic = params.get("kafka-topic");
		String brokers = params.get("brokers", "localhost:9092");

		System.out.printf("Generating events to Kafka with standalone source with error rate %f and sleep delay %s millis\n", errorRate, sleep);
		System.out.println();

		final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

		env
			.addSource(new EventsGeneratorSource(errorRate, sleep))
			.addSink(new FlinkKafkaProducer<>(brokers, kafkaTopic, new EventDeSerializer()));

		// trigger program execution
		env.execute("State machine example Kafka events generator job");
	}
 
Example 9
Source File: SummaryAlertingCondition.java    From flink-tutorials with Apache License 2.0 4 votes vote down vote up
public SummaryAlertingCondition(ParameterTool params) {
	minNum = params.getInt(REPORTING_NUMBER_KEY, 100);
	minFailureRate = params.getDouble(REPORTING_FAILURE_RATE_KEY, 0.5);
}
 
Example 10
Source File: KafkaEventsGeneratorJob.java    From flink with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

		final ParameterTool params = ParameterTool.fromArgs(args);

		double errorRate = params.getDouble("error-rate", 0.0);
		int sleep = params.getInt("sleep", 1);

		String kafkaTopic = params.get("kafka-topic");
		String brokers = params.get("brokers", "localhost:9092");

		System.out.printf("Generating events to Kafka with standalone source with error rate %f and sleep delay %s millis\n", errorRate, sleep);
		System.out.println();

		final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

		env
			.addSource(new EventsGeneratorSource(errorRate, sleep))
			.addSink(new FlinkKafkaProducer<>(brokers, kafkaTopic, new EventDeSerializer()));

		// trigger program execution
		env.execute("State machine example Kafka events generator job");
	}