当前位置: 首页>>代码示例>>Java>>正文


Java FileSystem.initialize方法代码示例

本文整理汇总了Java中org.apache.flink.core.fs.FileSystem.initialize方法的典型用法代码示例。如果您正苦于以下问题:Java FileSystem.initialize方法的具体用法?Java FileSystem.initialize怎么用?Java FileSystem.initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.flink.core.fs.FileSystem的用法示例。


在下文中一共展示了FileSystem.initialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testExplicitlySetToOther

import org.apache.flink.core.fs.FileSystem; //导入方法依赖的package包/类
@Test
public void testExplicitlySetToOther() throws Exception {
	final Configuration conf = new Configuration();
	conf.setString(CoreOptions.DEFAULT_FILESYSTEM_SCHEME, "otherFS://localhost:1234/");
	FileSystem.initialize(conf);

	URI justPath = new URI(tempFolder.newFile().toURI().getPath());
	assertNull(justPath.getScheme());

	try {
		FileSystem.get(justPath);
		fail("should have failed with an exception");
	}
	catch (UnsupportedFileSystemSchemeException e) {
		assertTrue(e.getMessage().contains("otherFS"));
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:18,代码来源:FilesystemSchemeConfigTest.java

示例2: CliFrontend

import org.apache.flink.core.fs.FileSystem; //导入方法依赖的package包/类
public CliFrontend(String configDir) throws Exception {
	configurationDirectory = Preconditions.checkNotNull(configDir);

	// configure the config directory
	File configDirectory = new File(configDir);
	LOG.info("Using configuration directory " + configDirectory.getAbsolutePath());

	// load the configuration
	LOG.info("Trying to load configuration file");
	this.config = GlobalConfiguration.loadConfiguration(configDirectory.getAbsolutePath());

	try {
		FileSystem.initialize(config);
	} catch (IOException e) {
		throw new Exception("Error while setting the default " +
			"filesystem scheme from configuration.", e);
	}

	this.clientTimeout = AkkaUtils.getClientTimeout(config);
	this.defaultParallelism = GlobalConfiguration.loadConfiguration().getInteger(
													ConfigConstants.DEFAULT_PARALLELISM_KEY,
													ConfigConstants.DEFAULT_PARALLELISM);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:24,代码来源:CliFrontend.java

示例3: CliFrontend

import org.apache.flink.core.fs.FileSystem; //导入方法依赖的package包/类
public CliFrontend(
		Configuration configuration,
		List<CustomCommandLine<?>> customCommandLines) throws Exception {
	this.configuration = Preconditions.checkNotNull(configuration);
	this.customCommandLines = Preconditions.checkNotNull(customCommandLines);

	try {
		FileSystem.initialize(this.configuration);
	} catch (IOException e) {
		throw new Exception("Error while setting the default " +
			"filesystem scheme from configuration.", e);
	}

	this.customCommandLineOptions = new Options();

	for (CustomCommandLine<?> customCommandLine : customCommandLines) {
		customCommandLine.addGeneralOptions(customCommandLineOptions);
		customCommandLine.addRunOptions(customCommandLineOptions);
	}

	this.clientTimeout = AkkaUtils.getClientTimeout(this.configuration);
	this.defaultParallelism = configuration.getInteger(
		ConfigConstants.DEFAULT_PARALLELISM_KEY,
		ConfigConstants.DEFAULT_PARALLELISM);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:26,代码来源:CliFrontend.java

示例4: checkCredentialsAndSetup

import org.apache.flink.core.fs.FileSystem; //导入方法依赖的package包/类
@BeforeClass
public static void checkCredentialsAndSetup() throws IOException {
	// check whether credentials exist
	Assume.assumeTrue("AWS S3 bucket not configured, skipping test...", BUCKET != null);
	Assume.assumeTrue("AWS S3 access key not configured, skipping test...", ACCESS_KEY != null);
	Assume.assumeTrue("AWS S3 secret key not configured, skipping test...", SECRET_KEY != null);

	// initialize configuration with valid credentials
	final Configuration conf = new Configuration();
	conf.setString("s3.access.key", ACCESS_KEY);
	conf.setString("s3.secret.key", SECRET_KEY);
	FileSystem.initialize(conf);

	// check for uniqueness of the test directory
	final Path directory = new Path("s3://" + BUCKET + '/' + TEST_DATA_DIR);
	final FileSystem fs = directory.getFileSystem();

	// directory must not yet exist
	assertFalse(fs.exists(directory));

	// reset configuration
	FileSystem.initialize(new Configuration());

	skipTest = false;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:26,代码来源:HadoopS3FileSystemITCase.java

示例5: cleanUp

import org.apache.flink.core.fs.FileSystem; //导入方法依赖的package包/类
@AfterClass
public static void cleanUp() throws IOException {
	if (!skipTest) {
		// initialize configuration with valid credentials
		final Configuration conf = new Configuration();
		conf.setString("s3.access.key", ACCESS_KEY);
		conf.setString("s3.secret.key", SECRET_KEY);
		FileSystem.initialize(conf);

		final Path directory = new Path("s3://" + BUCKET + '/' + TEST_DATA_DIR);
		final FileSystem fs = directory.getFileSystem();

		// clean up
		fs.delete(directory, true);

		// now directory must be gone
		assertFalse(fs.exists(directory));

		// reset configuration
		FileSystem.initialize(new Configuration());
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:23,代码来源:HadoopS3FileSystemITCase.java

示例6: testDefaultFsParameterLoading

import org.apache.flink.core.fs.FileSystem; //导入方法依赖的package包/类
@Test
public void testDefaultFsParameterLoading() throws Exception {
	try {
		final File tmpDir = temporaryFolder.newFolder();
		final File confFile = new File(tmpDir, GlobalConfiguration.FLINK_CONF_FILENAME);

		final URI defaultFS = new URI("otherFS", null, "localhost", 1234, null, null, null);

		final PrintWriter pw1 = new PrintWriter(confFile);
		pw1.println("fs.default-scheme: " + defaultFS);
		pw1.close();

		String[] args = new String[] {"--configDir:" + tmpDir};
		TaskManager.parseArgsAndLoadConfig(args);

		assertEquals(defaultFS, FileSystem.getDefaultFsUri());
	}
	finally {
		// reset FS settings
		FileSystem.initialize(new Configuration());
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:23,代码来源:TaskManagerConfigurationTest.java

示例7: testExplicitlySetToLocal

import org.apache.flink.core.fs.FileSystem; //导入方法依赖的package包/类
@Test
public void testExplicitlySetToLocal() throws Exception {
	final Configuration conf = new Configuration();
	conf.setString(CoreOptions.DEFAULT_FILESYSTEM_SCHEME, LocalFileSystem.getLocalFsURI().toString());
	FileSystem.initialize(conf);

	URI justPath = new URI(tempFolder.newFile().toURI().getPath());
	assertNull(justPath.getScheme());

	FileSystem fs = FileSystem.get(justPath);
	assertEquals("file", fs.getUri().getScheme());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:13,代码来源:FilesystemSchemeConfigTest.java

示例8: checkCredentialsAndSetup

import org.apache.flink.core.fs.FileSystem; //导入方法依赖的package包/类
@BeforeClass
public static void checkCredentialsAndSetup() throws IOException {
	// check whether credentials exist
	Assume.assumeTrue("AWS S3 bucket not configured, skipping test...", BUCKET != null);
	Assume.assumeTrue("AWS S3 access key not configured, skipping test...", ACCESS_KEY != null);
	Assume.assumeTrue("AWS S3 secret key not configured, skipping test...", SECRET_KEY != null);

	// initialize configuration with valid credentials
	final Configuration conf = new Configuration();
	conf.setString("s3.access.key", ACCESS_KEY);
	conf.setString("s3.secret.key", SECRET_KEY);
	FileSystem.initialize(conf);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:14,代码来源:HadoopS3FileSystemBehaviorITCase.java

示例9: testSimpleFileWriteAndRead

import org.apache.flink.core.fs.FileSystem; //导入方法依赖的package包/类
@Test
public void testSimpleFileWriteAndRead() throws Exception {
	final Configuration conf = new Configuration();
	conf.setString("s3.access.key", ACCESS_KEY);
	conf.setString("s3.secret.key", SECRET_KEY);

	final String testLine = "Hello Upload!";

	FileSystem.initialize(conf);

	final Path path = new Path("s3://" + BUCKET + '/' + TEST_DATA_DIR + "/test.txt");
	final FileSystem fs = path.getFileSystem();

	try {
		try (FSDataOutputStream out = fs.create(path, WriteMode.OVERWRITE);
				OutputStreamWriter writer = new OutputStreamWriter(out, StandardCharsets.UTF_8)) {
			writer.write(testLine);
		}

		try (FSDataInputStream in = fs.open(path);
				InputStreamReader ir = new InputStreamReader(in, StandardCharsets.UTF_8);
				BufferedReader reader = new BufferedReader(ir)) {
			String line = reader.readLine();
			assertEquals(testLine, line);
		}
	}
	finally {
		fs.delete(path, false);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:31,代码来源:HadoopS3FileSystemITCase.java

示例10: configureFileSystems

import org.apache.flink.core.fs.FileSystem; //导入方法依赖的package包/类
protected void configureFileSystems(Configuration configuration) throws Exception {
	LOG.info("Install default filesystem.");

	try {
		FileSystem.initialize(configuration);
	} catch (IOException e) {
		throw new IOException("Error while setting the default " +
			"filesystem scheme from configuration.", e);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:11,代码来源:ClusterEntrypoint.java

示例11: testConfigPropagation

import org.apache.flink.core.fs.FileSystem; //导入方法依赖的package包/类
@Test
public void testConfigPropagation() throws Exception{
	final Configuration conf = new Configuration();
	conf.setString("s3.access-key", "test_access_key_id");
	conf.setString("s3.secret-key", "test_secret_access_key");

	FileSystem.initialize(conf);

	FileSystem fs = FileSystem.get(new URI("s3://test"));
	validateBasicCredentials(fs);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:12,代码来源:PrestoS3FileSystemTest.java

示例12: testConfigPropagationWithPrestoPrefix

import org.apache.flink.core.fs.FileSystem; //导入方法依赖的package包/类
@Test
public void testConfigPropagationWithPrestoPrefix() throws Exception{
	final Configuration conf = new Configuration();
	conf.setString("presto.s3.access-key", "test_access_key_id");
	conf.setString("presto.s3.secret-key", "test_secret_access_key");

	FileSystem.initialize(conf);

	FileSystem fs = FileSystem.get(new URI("s3://test"));
	validateBasicCredentials(fs);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:12,代码来源:PrestoS3FileSystemTest.java

示例13: testConfigPropagationAlternateStyle

import org.apache.flink.core.fs.FileSystem; //导入方法依赖的package包/类
@Test
public void testConfigPropagationAlternateStyle() throws Exception{
	final Configuration conf = new Configuration();
	conf.setString("s3.access.key", "test_access_key_id");
	conf.setString("s3.secret.key", "test_secret_access_key");

	FileSystem.initialize(conf);

	FileSystem fs = FileSystem.get(new URI("s3://test"));
	validateBasicCredentials(fs);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:12,代码来源:PrestoS3FileSystemTest.java

示例14: run

import org.apache.flink.core.fs.FileSystem; //导入方法依赖的package包/类
/**
 * The instance entry point for the Mesos AppMaster. Obtains user group
 * information and calls the main work method {@link #runPrivileged(Configuration, Configuration)} as a
 * privileged action.
 *
 * @param args The command line arguments.
 * @return The process exit code.
 */
protected int run(final String[] args) {
	try {
		LOG.debug("All environment variables: {}", ENV);

		// loading all config values here has the advantage that the program fails fast, if any
		// configuration problem occurs

		CommandLineParser parser = new PosixParser();
		CommandLine cmd = parser.parse(ALL_OPTIONS, args);

		final Configuration dynamicProperties = BootstrapTools.parseDynamicProperties(cmd);
		final Configuration config = MesosEntrypointUtils.loadConfiguration(dynamicProperties, LOG);

		// configure the filesystems
		try {
			FileSystem.initialize(config);
		} catch (IOException e) {
			throw new IOException("Error while configuring the filesystems.", e);
		}

		// configure security
		SecurityConfiguration sc = new SecurityConfiguration(config);
		SecurityUtils.install(sc);

		// run the actual work in the installed security context
		return SecurityUtils.getInstalledContext().runSecured(new Callable<Integer>() {
			@Override
			public Integer call() throws Exception {
				return runPrivileged(config, dynamicProperties);
			}
		});
	}
	catch (Throwable t) {
		// make sure that everything whatever ends up in the log
		LOG.error("Mesos AppMaster initialization failed", t);
		return INIT_ERROR_EXIT_CODE;
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:47,代码来源:MesosApplicationMasterRunner.java

示例15: clearFsSettings

import org.apache.flink.core.fs.FileSystem; //导入方法依赖的package包/类
@After
public void clearFsSettings() throws IOException {
	FileSystem.initialize(new Configuration());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:5,代码来源:FilesystemSchemeConfigTest.java


注:本文中的org.apache.flink.core.fs.FileSystem.initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。