org.apache.flink.mesos.configuration.MesosOptions Java Examples

The following examples show how to use org.apache.flink.mesos.configuration.MesosOptions. 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: LaunchableMesosWorkerTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void launch_withNonDefaultConfiguration_forwardsConfigurationValues() {
	final Configuration configuration = new Configuration();
	configuration.setString(MesosOptions.MASTER_URL, "foobar");
	final MemorySize memorySize = new MemorySize(1337L);
	configuration.set(TaskManagerOptions.MANAGED_MEMORY_SIZE, memorySize);
	configuration.set(TaskManagerOptions.TOTAL_PROCESS_MEMORY, MemorySize.parse("1g"));

	final LaunchableTask launchableTask = new LaunchableMesosWorker(
		ignored -> Option.empty(),
		MesosTaskManagerParameters.create(configuration),
		ContainerSpecification.from(configuration),
		Protos.TaskID.newBuilder().setValue("test-task-id").build(),
		MesosUtils.createMesosSchedulerConfiguration(configuration, "localhost"));

	final Protos.TaskInfo taskInfo = launchableTask.launch(
		Protos.SlaveID.newBuilder().setValue("test-slave-id").build(),
		new MesosResourceAllocation(Collections.singleton(ports(range(1000, 2000)))));

	assertThat(
		taskInfo.getCommand().getValue(),
		containsString(ContainerSpecification.createDynamicProperty(TaskManagerOptions.MANAGED_MEMORY_SIZE.key(), memorySize.toString())));
}
 
Example #2
Source File: MesosServicesUtils.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private static MesosArtifactServer createArtifactServer(Configuration configuration, String hostname) throws Exception {
	final int artifactServerPort = configuration.getInteger(MesosOptions.ARTIFACT_SERVER_PORT, 0);

	// a random prefix is affixed to artifact URLs to ensure uniqueness in the Mesos fetcher cache
	final String artifactServerPrefix = UUID.randomUUID().toString();

	return new MesosArtifactServer(artifactServerPrefix, hostname, artifactServerPort, configuration);
}
 
Example #3
Source File: MesosServicesUtils.java    From flink with Apache License 2.0 5 votes vote down vote up
private static MesosArtifactServer createArtifactServer(Configuration configuration, String hostname) throws Exception {
	final int artifactServerPort = configuration.getInteger(MesosOptions.ARTIFACT_SERVER_PORT, 0);

	// a random prefix is affixed to artifact URLs to ensure uniqueness in the Mesos fetcher cache
	final String artifactServerPrefix = UUID.randomUUID().toString();

	return new MesosArtifactServer(artifactServerPrefix, hostname, artifactServerPort, configuration);
}
 
Example #4
Source File: MesosServicesUtils.java    From flink with Apache License 2.0 5 votes vote down vote up
private static MesosArtifactServer createArtifactServer(Configuration configuration, String hostname) throws Exception {
	final int artifactServerPort = configuration.getInteger(MesosOptions.ARTIFACT_SERVER_PORT, 0);

	// a random prefix is affixed to artifact URLs to ensure uniqueness in the Mesos fetcher cache
	final String artifactServerPrefix = UUID.randomUUID().toString();

	return new MesosArtifactServer(artifactServerPrefix, hostname, artifactServerPort, configuration);
}
 
Example #5
Source File: MesosEntrypointUtils.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
/**
 * Loads and validates the Mesos scheduler configuration.
 * @param flinkConfig the global configuration.
 * @param hostname the hostname to advertise to the Mesos master.
 */
public static MesosConfiguration createMesosSchedulerConfiguration(Configuration flinkConfig, String hostname) {

	Protos.FrameworkInfo.Builder frameworkInfo = Protos.FrameworkInfo.newBuilder()
		.setHostname(hostname);
	Protos.Credential.Builder credential = null;

	if (!flinkConfig.contains(MesosOptions.MASTER_URL)) {
		throw new IllegalConfigurationException(MesosOptions.MASTER_URL.key() + " must be configured.");
	}
	String masterUrl = flinkConfig.getString(MesosOptions.MASTER_URL);

	Duration failoverTimeout = FiniteDuration.apply(
		flinkConfig.getInteger(
			MesosOptions.FAILOVER_TIMEOUT_SECONDS),
			TimeUnit.SECONDS);
	frameworkInfo.setFailoverTimeout(failoverTimeout.toSeconds());

	frameworkInfo.setName(flinkConfig.getString(
		MesosOptions.RESOURCEMANAGER_FRAMEWORK_NAME));

	frameworkInfo.setRole(flinkConfig.getString(
		MesosOptions.RESOURCEMANAGER_FRAMEWORK_ROLE));

	frameworkInfo.setUser(flinkConfig.getString(
		MesosOptions.RESOURCEMANAGER_FRAMEWORK_USER));

	if (flinkConfig.contains(MesosOptions.RESOURCEMANAGER_FRAMEWORK_PRINCIPAL)) {
		frameworkInfo.setPrincipal(flinkConfig.getString(
			MesosOptions.RESOURCEMANAGER_FRAMEWORK_PRINCIPAL));

		credential = Protos.Credential.newBuilder();
		credential.setPrincipal(frameworkInfo.getPrincipal());

		// some environments use a side-channel to communicate the secret to Mesos,
		// and thus don't set the 'secret' configuration setting
		if (flinkConfig.contains(MesosOptions.RESOURCEMANAGER_FRAMEWORK_SECRET)) {
			credential.setSecret(flinkConfig.getString(
				MesosOptions.RESOURCEMANAGER_FRAMEWORK_SECRET));
		}
	}

	MesosConfiguration mesos =
		new MesosConfiguration(masterUrl, frameworkInfo, scala.Option.apply(credential));

	return mesos;
}
 
Example #6
Source File: MesosEntrypointUtils.java    From flink with Apache License 2.0 4 votes vote down vote up
/**
 * Loads and validates the Mesos scheduler configuration.
 * @param flinkConfig the global configuration.
 * @param hostname the hostname to advertise to the Mesos master.
 */
public static MesosConfiguration createMesosSchedulerConfiguration(Configuration flinkConfig, String hostname) {

	Protos.FrameworkInfo.Builder frameworkInfo = Protos.FrameworkInfo.newBuilder()
		.setHostname(hostname);
	Protos.Credential.Builder credential = null;

	if (!flinkConfig.contains(MesosOptions.MASTER_URL)) {
		throw new IllegalConfigurationException(MesosOptions.MASTER_URL.key() + " must be configured.");
	}
	String masterUrl = flinkConfig.getString(MesosOptions.MASTER_URL);

	Duration failoverTimeout = FiniteDuration.apply(
		flinkConfig.getInteger(
			MesosOptions.FAILOVER_TIMEOUT_SECONDS),
			TimeUnit.SECONDS);
	frameworkInfo.setFailoverTimeout(failoverTimeout.toSeconds());

	frameworkInfo.setName(flinkConfig.getString(
		MesosOptions.RESOURCEMANAGER_FRAMEWORK_NAME));

	frameworkInfo.setRole(flinkConfig.getString(
		MesosOptions.RESOURCEMANAGER_FRAMEWORK_ROLE));

	frameworkInfo.setUser(flinkConfig.getString(
		MesosOptions.RESOURCEMANAGER_FRAMEWORK_USER));

	if (flinkConfig.contains(MesosOptions.RESOURCEMANAGER_FRAMEWORK_PRINCIPAL)) {
		frameworkInfo.setPrincipal(flinkConfig.getString(
			MesosOptions.RESOURCEMANAGER_FRAMEWORK_PRINCIPAL));

		credential = Protos.Credential.newBuilder();
		credential.setPrincipal(frameworkInfo.getPrincipal());

		// some environments use a side-channel to communicate the secret to Mesos,
		// and thus don't set the 'secret' configuration setting
		if (flinkConfig.contains(MesosOptions.RESOURCEMANAGER_FRAMEWORK_SECRET)) {
			credential.setSecret(flinkConfig.getString(
				MesosOptions.RESOURCEMANAGER_FRAMEWORK_SECRET));
		}
	}

	MesosConfiguration mesos =
		new MesosConfiguration(masterUrl, frameworkInfo, scala.Option.apply(credential));

	return mesos;
}
 
Example #7
Source File: MesosUtils.java    From flink with Apache License 2.0 4 votes vote down vote up
/**
 * Loads and validates the Mesos scheduler configuration.
 * @param flinkConfig the global configuration.
 * @param hostname the hostname to advertise to the Mesos master.
 */
public static MesosConfiguration createMesosSchedulerConfiguration(Configuration flinkConfig, String hostname) {

	Protos.FrameworkInfo.Builder frameworkInfo = Protos.FrameworkInfo.newBuilder()
		.setHostname(hostname);
	Protos.Credential.Builder credential = null;

	if (!flinkConfig.contains(MesosOptions.MASTER_URL)) {
		throw new IllegalConfigurationException(MesosOptions.MASTER_URL.key() + " must be configured.");
	}
	String masterUrl = flinkConfig.getString(MesosOptions.MASTER_URL);

	Duration failoverTimeout = FiniteDuration.apply(
		flinkConfig.getInteger(
			MesosOptions.FAILOVER_TIMEOUT_SECONDS),
			TimeUnit.SECONDS);
	frameworkInfo.setFailoverTimeout(failoverTimeout.toSeconds());

	frameworkInfo.setName(flinkConfig.getString(
		MesosOptions.RESOURCEMANAGER_FRAMEWORK_NAME));

	frameworkInfo.setRole(flinkConfig.getString(
		MesosOptions.RESOURCEMANAGER_FRAMEWORK_ROLE));

	frameworkInfo.setUser(flinkConfig.getString(
		MesosOptions.RESOURCEMANAGER_FRAMEWORK_USER));

	if (flinkConfig.contains(MesosOptions.RESOURCEMANAGER_FRAMEWORK_PRINCIPAL)) {
		frameworkInfo.setPrincipal(flinkConfig.getString(
			MesosOptions.RESOURCEMANAGER_FRAMEWORK_PRINCIPAL));

		credential = Protos.Credential.newBuilder();
		credential.setPrincipal(frameworkInfo.getPrincipal());

		// some environments use a side-channel to communicate the secret to Mesos,
		// and thus don't set the 'secret' configuration setting
		if (flinkConfig.contains(MesosOptions.RESOURCEMANAGER_FRAMEWORK_SECRET)) {
			credential.setSecret(flinkConfig.getString(
				MesosOptions.RESOURCEMANAGER_FRAMEWORK_SECRET));
		}
	}

	MesosConfiguration mesos =
		new MesosConfiguration(masterUrl, frameworkInfo, scala.Option.apply(credential));

	return mesos;
}