Search in sources :

Example 11 with Path

use of org.apache.flink.core.fs.Path in project flink by apache.

the class PythonPlanBinder method prepareFiles.

//=====Setup========================================================================================================
/**
	 * Copies all files to a common directory (FLINK_PYTHON_FILE_PATH). This allows us to distribute it as one big
	 * package, and resolves PYTHONPATH issues.
	 *
	 * @param filePaths
	 * @throws IOException
	 * @throws URISyntaxException
	 */
private void prepareFiles(String tempFilePath, String... filePaths) throws IOException, URISyntaxException {
    //Flink python package
    clearPath(tempFilePath);
    FileCache.copy(new Path(FULL_PATH), new Path(tempFilePath), false);
    //plan file		
    copyFile(filePaths[0], tempFilePath, FLINK_PYTHON_PLAN_NAME);
    //additional files/folders
    for (int x = 1; x < filePaths.length; x++) {
        copyFile(filePaths[x], tempFilePath, null);
    }
}
Also used : Path(org.apache.flink.core.fs.Path) DatasizeHint(org.apache.flink.python.api.PythonOperationInfo.DatasizeHint)

Example 12 with Path

use of org.apache.flink.core.fs.Path in project flink by apache.

the class FsCheckpointStreamFactory method createCheckpointStateOutputStream.

@Override
public FsCheckpointStateOutputStream createCheckpointStateOutputStream(long checkpointID, long timestamp) throws Exception {
    checkFileSystemInitialized();
    Path checkpointDir = createCheckpointDirPath(checkpointDirectory, checkpointID);
    int bufferSize = Math.max(DEFAULT_WRITE_BUFFER_SIZE, fileStateThreshold);
    return new FsCheckpointStateOutputStream(checkpointDir, filesystem, bufferSize, fileStateThreshold);
}
Also used : Path(org.apache.flink.core.fs.Path)

Example 13 with Path

use of org.apache.flink.core.fs.Path in project flink by apache.

the class FsStateBackendFactory method createFromConfig.

@Override
public FsStateBackend createFromConfig(Configuration config) throws IllegalConfigurationException {
    final String checkpointDirURI = config.getString(CHECKPOINT_DIRECTORY_URI_CONF_KEY, null);
    final int memoryThreshold = config.getInteger(MEMORY_THRESHOLD_CONF_KEY, FsStateBackend.DEFAULT_FILE_STATE_THRESHOLD);
    if (checkpointDirURI == null) {
        throw new IllegalConfigurationException("Cannot create the file system state backend: The configuration does not specify the " + "checkpoint directory '" + CHECKPOINT_DIRECTORY_URI_CONF_KEY + '\'');
    }
    try {
        Path path = new Path(checkpointDirURI);
        return new FsStateBackend(path.toUri(), memoryThreshold);
    } catch (IOException | IllegalArgumentException e) {
        throw new IllegalConfigurationException("Invalid configuration for the state backend", e);
    }
}
Also used : Path(org.apache.flink.core.fs.Path) IllegalConfigurationException(org.apache.flink.configuration.IllegalConfigurationException) IOException(java.io.IOException)

Example 14 with Path

use of org.apache.flink.core.fs.Path in project flink by apache.

the class HDFSCopyUtilitiesTest method testCopyToLocal.

/**
	 * This test verifies that a hadoop configuration is correctly read in the external
	 * process copying tools.
	 */
@Test
public void testCopyToLocal() throws Exception {
    File testFolder = tempFolder.newFolder();
    File originalFile = new File(testFolder, "original");
    File copyFile = new File(testFolder, "copy");
    try (DataOutputStream out = new DataOutputStream(new FileOutputStream(originalFile))) {
        out.writeUTF("Hello there, 42!");
    }
    HDFSCopyToLocal.copyToLocal(new Path("file://" + originalFile.getAbsolutePath()).toUri(), copyFile);
    try (DataInputStream in = new DataInputStream(new FileInputStream(copyFile))) {
        assertTrue(in.readUTF().equals("Hello there, 42!"));
    }
}
Also used : Path(org.apache.flink.core.fs.Path) DataOutputStream(java.io.DataOutputStream) FileOutputStream(java.io.FileOutputStream) DataInputStream(java.io.DataInputStream) File(java.io.File) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 15 with Path

use of org.apache.flink.core.fs.Path in project flink by apache.

the class ListStateDescriptorTest method testValueStateDescriptorLazySerializer.

@Test
public void testValueStateDescriptorLazySerializer() throws Exception {
    // some different registered value
    ExecutionConfig cfg = new ExecutionConfig();
    cfg.registerKryoType(TaskInfo.class);
    ListStateDescriptor<Path> descr = new ListStateDescriptor<Path>("testName", Path.class);
    try {
        descr.getSerializer();
        fail("should cause an exception");
    } catch (IllegalStateException ignored) {
    }
    descr.initializeSerializerUnlessSet(cfg);
    assertNotNull(descr.getSerializer());
    assertTrue(descr.getSerializer() instanceof ListSerializer);
    assertNotNull(descr.getElementSerializer());
    assertTrue(descr.getElementSerializer() instanceof KryoSerializer);
    assertTrue(((KryoSerializer<?>) descr.getElementSerializer()).getKryo().getRegistration(TaskInfo.class).getId() > 0);
}
Also used : Path(org.apache.flink.core.fs.Path) TaskInfo(org.apache.flink.api.common.TaskInfo) ListSerializer(org.apache.flink.api.common.typeutils.base.ListSerializer) ExecutionConfig(org.apache.flink.api.common.ExecutionConfig) KryoSerializer(org.apache.flink.api.java.typeutils.runtime.kryo.KryoSerializer) Test(org.junit.Test)

Aggregations

Path (org.apache.flink.core.fs.Path)590 Test (org.junit.Test)320 File (java.io.File)178 Configuration (org.apache.flink.configuration.Configuration)101 IOException (java.io.IOException)91 FileSystem (org.apache.flink.core.fs.FileSystem)87 FileInputSplit (org.apache.flink.core.fs.FileInputSplit)72 ArrayList (java.util.ArrayList)64 HashMap (java.util.HashMap)40 FileOutputStream (java.io.FileOutputStream)38 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)36 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)35 List (java.util.List)33 Map (java.util.Map)29 JobID (org.apache.flink.api.common.JobID)29 OutputStreamWriter (java.io.OutputStreamWriter)27 FSDataOutputStream (org.apache.flink.core.fs.FSDataOutputStream)27 FileStatus (org.apache.flink.core.fs.FileStatus)26 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)25 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)21