當前位置: 首頁>>代碼示例>>Java>>正文


Java Configuration.contains方法代碼示例

本文整理匯總了Java中org.apache.flink.configuration.Configuration.contains方法的典型用法代碼示例。如果您正苦於以下問題:Java Configuration.contains方法的具體用法?Java Configuration.contains怎麽用?Java Configuration.contains使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.flink.configuration.Configuration的用法示例。


在下文中一共展示了Configuration.contains方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadConfiguration

import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
 * Loads the global configuration, adds the given dynamic properties configuration, and sets
 * the temp directory paths.
 *
 * @param dynamicProperties dynamic properties to integrate
 * @param log logger instance
 * @return the loaded and adapted global configuration
 */
public static Configuration loadConfiguration(Configuration dynamicProperties, Logger log) {
	Configuration configuration =
		GlobalConfiguration.loadConfigurationWithDynamicProperties(dynamicProperties);

	// read the environment variables
	final Map<String, String> envs = System.getenv();
	final String tmpDirs = envs.get(MesosConfigKeys.ENV_FLINK_TMP_DIR);

	// configure local directory
	if (configuration.contains(CoreOptions.TMP_DIRS)) {
		log.info("Overriding Mesos' temporary file directories with those " +
			"specified in the Flink config: " + configuration.getValue(CoreOptions.TMP_DIRS));
	}
	else if (tmpDirs != null) {
		log.info("Setting directories for temporary files to: {}", tmpDirs);
		configuration.setString(CoreOptions.TMP_DIRS, tmpDirs);
	}

	return configuration;
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:29,代碼來源:MesosEntrypointUtils.java

示例2: getUploadDir

import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
private File getUploadDir(Configuration configuration) {
	File baseDir = new File(configuration.getString(WebOptions.UPLOAD_DIR,
		getBaseDirStr(configuration)));

	boolean uploadDirSpecified = configuration.contains(WebOptions.UPLOAD_DIR);
	return uploadDirSpecified ? baseDir : new File(baseDir, "flink-web-" + UUID.randomUUID());
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:8,代碼來源:WebRuntimeMonitor.java

示例3: hasNewNetworkBufConf

import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
 * Returns whether the new network buffer memory configuration is present in the configuration
 * object, i.e. at least one new parameter is given or the old one is not present.
 *
 * @param config configuration object
 * @return <tt>true</tt> if the new configuration method is used, <tt>false</tt> otherwise
 */
@SuppressWarnings("deprecation")
public static boolean hasNewNetworkBufConf(final Configuration config) {
	return config.contains(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_FRACTION) ||
		config.contains(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MIN) ||
		config.contains(TaskManagerOptions.NETWORK_BUFFERS_MEMORY_MAX) ||
		!config.contains(TaskManagerOptions.NETWORK_NUM_BUFFERS);
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:15,代碼來源:TaskManagerServicesConfiguration.java

示例4: main

import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
 * All arguments are parsed to a {@link Configuration} and passed to the Taskmanager,
 * for instance: <code>--high-availability ZOOKEEPER --high-availability.zookeeper.quorum "xyz:123:456"</code>.
 */
public static void main(String[] args) throws Exception {
	try {
		Configuration config = ParameterTool.fromArgs(args).getConfiguration();

		if (!config.contains(TaskManagerOptions.MANAGED_MEMORY_SIZE)) {
			config.setLong(TaskManagerOptions.MANAGED_MEMORY_SIZE, 4L);
		}

		if (!config.contains(TaskManagerOptions.NETWORK_NUM_BUFFERS)) {
			config.setInteger(TaskManagerOptions.NETWORK_NUM_BUFFERS, 100);
		}


		LOG.info("Configuration: {}.", config);

		// Run the TaskManager
		TaskManager.selectNetworkInterfaceAndRunTaskManager(
			config,
			ResourceID.generate(),
			TaskManager.class);

		// Run forever
		new CountDownLatch(1).await();
	}
	catch (Throwable t) {
		LOG.error("Failed to start TaskManager process", t);
		System.exit(1);
	}
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:34,代碼來源:TaskManagerProcess.java

示例5: createMesosSchedulerConfiguration

import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:52,代碼來源:MesosEntrypointUtils.java

示例6: createConfiguration

import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
/**
 * Reads the global configuration from the given directory and adds the given parameters to it.
 *
 * @param baseDirectory directory to load the configuration from
 * @param additional additional parameters to be included in the configuration
 * @param log logger instance
 *
 * @return The configuration to be used by the TaskManagers.
 */
@SuppressWarnings("deprecation")
private static Configuration createConfiguration(String baseDirectory, Map<String, String> additional, Logger log) {
	LOG.info("Loading config from directory " + baseDirectory);

	Configuration configuration = GlobalConfiguration.loadConfiguration(baseDirectory);

	// add dynamic properties to JobManager configuration.
	for (Map.Entry<String, String> property : additional.entrySet()) {
		configuration.setString(property.getKey(), property.getValue());
	}

	// override zookeeper namespace with user cli argument (if provided)
	String cliZKNamespace = ENV.get(YarnConfigKeys.ENV_ZOOKEEPER_NAMESPACE);
	if (cliZKNamespace != null && !cliZKNamespace.isEmpty()) {
		configuration.setString(HighAvailabilityOptions.HA_CLUSTER_ID, cliZKNamespace);
	}

	// if a web monitor shall be started, set the port to random binding
	if (configuration.getInteger(WebOptions.PORT, 0) >= 0) {
		configuration.setInteger(WebOptions.PORT, 0);
	}

	// if the user has set the deprecated YARN-specific config keys, we add the
	// corresponding generic config keys instead. that way, later code needs not
	// deal with deprecated config keys

	BootstrapTools.substituteDeprecatedConfigPrefix(configuration,
		ConfigConstants.YARN_APPLICATION_MASTER_ENV_PREFIX,
		ResourceManagerOptions.CONTAINERIZED_MASTER_ENV_PREFIX);

	BootstrapTools.substituteDeprecatedConfigPrefix(configuration,
		ConfigConstants.YARN_TASK_MANAGER_ENV_PREFIX,
		ResourceManagerOptions.CONTAINERIZED_TASK_MANAGER_ENV_PREFIX);

	// configure local directory
	if (configuration.contains(CoreOptions.TMP_DIRS)) {
		log.info("Overriding YARN's temporary file directories with those " +
			"specified in the Flink config: " + configuration.getValue(CoreOptions.TMP_DIRS));
	}
	else {
		final String localDirs = ENV.get(Environment.LOCAL_DIRS.key());
		log.info("Setting directories for temporary files to: {}", localDirs);
		configuration.setString(CoreOptions.TMP_DIRS, localDirs);
	}

	return configuration;
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:57,代碼來源:YarnApplicationMasterRunner.java

示例7: loadConfiguration

import org.apache.flink.configuration.Configuration; //導入方法依賴的package包/類
public static Configuration loadConfiguration(String workingDirectory, Map<String, String> env, Logger log) {
		Configuration configuration = GlobalConfiguration.loadConfiguration(workingDirectory);

		final String remoteKeytabPrincipal = env.get(YarnConfigKeys.KEYTAB_PRINCIPAL);

		final String zooKeeperNamespace = env.get(YarnConfigKeys.ENV_ZOOKEEPER_NAMESPACE);

		final Map<String, String> dynamicProperties = FlinkYarnSessionCli.getDynamicProperties(
			env.get(YarnConfigKeys.ENV_DYNAMIC_PROPERTIES));

		final String hostname = env.get(ApplicationConstants.Environment.NM_HOST.key());
		Preconditions.checkState(
			hostname != null,
			"ApplicationMaster hostname variable %s not set",
			ApplicationConstants.Environment.NM_HOST.key());

		configuration.setString(JobManagerOptions.ADDRESS, hostname);
		configuration.setString(RestOptions.REST_ADDRESS, hostname);

		// TODO: Support port ranges for the AM
//		final String portRange = configuration.getString(
//			ConfigConstants.YARN_APPLICATION_MASTER_PORT,
//			ConfigConstants.DEFAULT_YARN_JOB_MANAGER_PORT);

		for (Map.Entry<String, String> property : dynamicProperties.entrySet()) {
			configuration.setString(property.getKey(), property.getValue());
		}

		if (zooKeeperNamespace != null) {
			configuration.setString(HighAvailabilityOptions.HA_CLUSTER_ID, zooKeeperNamespace);
		}

		// if a web monitor shall be started, set the port to random binding
		if (configuration.getInteger(WebOptions.PORT, 0) >= 0) {
			configuration.setInteger(WebOptions.PORT, 0);
		}

		if (configuration.getInteger(RestOptions.REST_PORT) >= 0) {
			// set the REST port to 0 to select it randomly
			configuration.setInteger(RestOptions.REST_PORT, 0);
		}

		// if the user has set the deprecated YARN-specific config keys, we add the
		// corresponding generic config keys instead. that way, later code needs not
		// deal with deprecated config keys

		BootstrapTools.substituteDeprecatedConfigPrefix(configuration,
			ConfigConstants.YARN_APPLICATION_MASTER_ENV_PREFIX,
			ResourceManagerOptions.CONTAINERIZED_MASTER_ENV_PREFIX);

		BootstrapTools.substituteDeprecatedConfigPrefix(configuration,
			ConfigConstants.YARN_TASK_MANAGER_ENV_PREFIX,
			ResourceManagerOptions.CONTAINERIZED_TASK_MANAGER_ENV_PREFIX);

		final String keytabPath;

		if (env.get(YarnConfigKeys.KEYTAB_PATH) == null) {
			keytabPath = null;
		} else {
			File f = new File(workingDirectory, Utils.KEYTAB_FILE_NAME);
			keytabPath = f.getAbsolutePath();
		}

		if (keytabPath != null && remoteKeytabPrincipal != null) {
			configuration.setString(SecurityOptions.KERBEROS_LOGIN_KEYTAB, keytabPath);
			configuration.setString(SecurityOptions.KERBEROS_LOGIN_PRINCIPAL, remoteKeytabPrincipal);
		}

		// configure local directory
		if (configuration.contains(CoreOptions.TMP_DIRS)) {
			log.info("Overriding YARN's temporary file directories with those " +
				"specified in the Flink config: " + configuration.getValue(CoreOptions.TMP_DIRS));
		}
		else {
			final String localDirs = env.get(ApplicationConstants.Environment.LOCAL_DIRS.key());
			log.info("Setting directories for temporary files to: {}", localDirs);
			configuration.setString(CoreOptions.TMP_DIRS, localDirs);
		}

		return configuration;
	}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:82,代碼來源:YarnEntrypointUtils.java


注:本文中的org.apache.flink.configuration.Configuration.contains方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。