Package org.apache.flink.core.fs

Examples of org.apache.flink.core.fs.Path


   
    String tmpFilePath = tmpOutPath.toURI().toString();

    // check success if file exists
    DummyFileOutputFormat dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.PARONLY);

    dfof.configure(new Configuration());
   
    boolean exception = false;
    try {
      dfof.open(0, 1);
      dfof.close();
    } catch (Exception e) {
      exception = true;
    }
    Assert.assertTrue(!exception);
    Assert.assertTrue(tmpOutPath.exists() && tmpOutPath.isFile());

    // check success if directory exists
    tmpOutPath.delete();
    Assert.assertTrue("Directory could not be created.", tmpOutPath.mkdir());

    dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.PARONLY);

    dfof.configure(new Configuration());
   
    exception = false;
    try {
      dfof.open(0, 1);
      dfof.close();
    } catch (Exception e) {
      exception = true;
    }
    Assert.assertTrue(!exception);
    Assert.assertTrue(tmpOutPath.exists() && tmpOutPath.isFile());
   
    // check success
    tmpOutPath.delete();
   
    dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.PARONLY);

    dfof.configure(new Configuration());
   
    exception = false;
    try {
      dfof.open(0, 1);
      dfof.close();
    } catch (Exception e) {
      exception = true;
    }
    Assert.assertTrue(!exception);
    Assert.assertTrue(tmpOutPath.exists() && tmpOutPath.isFile());
   
    // ----------- test again with always directory mode
   
    // check success if file exists
    dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.ALWAYS);

    dfof.configure(new Configuration());
   
    exception = false;
    try {
      dfof.open(0, 1);
      dfof.close();
    } catch (Exception e) {
      exception = true;
    }
    Assert.assertTrue(!exception);
    Assert.assertTrue(tmpOutPath.exists() && tmpOutPath.isDirectory());
    Assert.assertTrue(tmpOutFile.exists() && tmpOutFile.isFile());

    // check success if directory exists
    tmpOutFile.delete();
    tmpOutPath.delete();
    Assert.assertTrue("Directory could not be created.", tmpOutPath.mkdir());

    dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.ALWAYS);

    dfof.configure(new Configuration());
   
    exception = false;
    try {
      dfof.open(0, 1);
      dfof.close();
    } catch (Exception e) {
      exception = true;
    }
    Assert.assertTrue(!exception);
    Assert.assertTrue(tmpOutPath.exists() && tmpOutPath.isDirectory());
    Assert.assertTrue(tmpOutFile.exists() && tmpOutFile.isFile());
   
    // check success if file in directory exists
    dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.ALWAYS);

    dfof.configure(new Configuration());
   
    exception = false;
    try {
      dfof.open(0, 1);
      dfof.close();
    } catch (Exception e) {
      exception = true;
    }
    Assert.assertTrue(!exception);
    Assert.assertTrue(tmpOutPath.exists() && tmpOutPath.isDirectory());
    Assert.assertTrue(tmpOutFile.exists() && tmpOutFile.isFile());
   
    // check success if no file exists
    // delete existing files
    tmpOutFile.delete();
    tmpOutPath.delete();
   
    dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.ALWAYS);

    dfof.configure(new Configuration());
   
View Full Code Here


   
    String tmpFilePath = tmpOutPath.toURI().toString();

    // check success if file exists
    DummyFileOutputFormat dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.PARONLY);

    dfof.configure(new Configuration());
   
    boolean exception = false;
    try {
      dfof.open(0, 2);
      dfof.close();
    } catch (Exception e) {
      exception = true;
    }
    Assert.assertTrue(!exception);
    Assert.assertTrue(tmpOutPath.exists() && tmpOutPath.isDirectory());
    Assert.assertTrue(tmpOutFile.exists() && tmpOutFile.isFile());

    // check success if directory exists
    tmpOutFile.delete();
    tmpOutPath.delete();
    Assert.assertTrue("Directory could not be created.", tmpOutPath.mkdir());

    dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.PARONLY);

    dfof.configure(new Configuration());
   
    exception = false;
    try {
      dfof.open(0, 2);
      dfof.close();
    } catch (Exception e) {
      exception = true;
    }
    Assert.assertTrue(!exception);
    Assert.assertTrue(tmpOutPath.exists() && tmpOutPath.isDirectory());
    Assert.assertTrue(tmpOutFile.exists() && tmpOutFile.isFile());
   
    // check success if file in directory exists
    dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.PARONLY);

    dfof.configure(new Configuration());
   
    exception = false;
    try {
      dfof.open(0, 2);
      dfof.close();
    } catch (Exception e) {
      exception = true;
    }
    Assert.assertTrue(!exception);
    Assert.assertTrue(tmpOutPath.exists() && tmpOutPath.isDirectory());
    Assert.assertTrue(tmpOutFile.exists() && tmpOutFile.isFile());
   
    // check success if no file exists
    // delete existing files
    (new File(tmpOutPath.getAbsoluteFile()+"/1")).delete();
    tmpOutPath.delete();
   
    dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.PARONLY);

    dfof.configure(new Configuration());
   
View Full Code Here

    Arrays.sort(inputSplits, new InputSplitSorter());

    int splitIndex = 0;
    for (int fileIndex = 0; fileIndex < this.degreeOfParallelism; fileIndex++) {
      List<FileInputSplit> sameFileSplits = new ArrayList<FileInputSplit>();
      Path lastPath = inputSplits[splitIndex].getPath();
      for (; splitIndex < inputSplits.length; splitIndex++) {
        if (!inputSplits[splitIndex].getPath().equals(lastPath)) {
          break;
        }
        sameFileSplits.add(inputSplits[splitIndex]);
View Full Code Here

    if (!testActivated()) {
      return;
    }

    final String bucketName = getRandomName();
    final Path bucketPath = new Path(S3_BASE_URI + bucketName + Path.SEPARATOR);

    try {

      final FileSystem fs = bucketPath.getFileSystem();

      // Create directory
      fs.mkdirs(bucketPath);

      // Check if directory is correctly displayed in file system hierarchy
      final FileStatus[] content = fs.listStatus(new Path(S3_BASE_URI));
      boolean entryFound = false;
      for (final FileStatus entry : content) {
        if (bucketPath.equals(entry.getPath())) {
          entryFound = true;
          break;
        }
      }

      if (!entryFound) {
        fail("Cannot find entry " + bucketName + " in directory " + S3_BASE_URI);
      }

      // Check the concrete directory file status
      try {
        final FileStatus directoryFileStatus = fs.getFileStatus(bucketPath);
        assertTrue(directoryFileStatus.isDir());
        assertEquals(0L, directoryFileStatus.getAccessTime());
        assertTrue(directoryFileStatus.getModificationTime() > 0L);

      } catch (FileNotFoundException e) {
        fail(e.getMessage());
      }

      // Delete the bucket
      fs.delete(bucketPath, true);

      // Make sure the bucket no longer exists
      try {
        fs.getFileStatus(bucketPath);
        fail("Expected FileNotFoundException for " + bucketPath.toUri());
      } catch (FileNotFoundException e) {
        // This is an expected exception
      }

    } catch (IOException ioe) {
View Full Code Here

    final String dirName = getRandomName();
    final String subdirName = getRandomName();
    final String subsubdirName = getRandomName();
    final String fileName = getRandomName();
    final Path dir = new Path(S3_BASE_URI + dirName + Path.SEPARATOR);
    final Path subdir = new Path(S3_BASE_URI + dirName + Path.SEPARATOR + subdirName + Path.SEPARATOR);
    final Path subsubdir = new Path(S3_BASE_URI + dirName + Path.SEPARATOR + subdirName + Path.SEPARATOR
      + subsubdirName + Path.SEPARATOR);
    final Path file = new Path(S3_BASE_URI + dirName + Path.SEPARATOR + subdirName + Path.SEPARATOR + fileName);

    try {

      final FileSystem fs = dir.getFileSystem();
View Full Code Here

      return;
    }

    final String dirName = getRandomName();
    final String fileName = getRandomName();
    final Path dir = new Path(S3_BASE_URI + dirName + Path.SEPARATOR);
    final Path file = new Path(S3_BASE_URI + dirName + Path.SEPARATOR + fileName);

    try {

      final FileSystem fs = dir.getFileSystem();
View Full Code Here

      return;
    }

    final String bucketName = getRandomName();
    final String objectName = getRandomName();
    final Path bucketPath = new Path(S3_BASE_URI + bucketName + Path.SEPARATOR);
    final Path objectPath = new Path(S3_BASE_URI + bucketName + Path.SEPARATOR + objectName);

    FileSystem fs = bucketPath.getFileSystem();

    // Create test bucket
    fs.mkdirs(bucketPath);
View Full Code Here

      try {
        JobWithJars.checkJarFile(file);
      } catch (IOException e) {
        throw new RuntimeException("Problem with jar file " + file.getAbsolutePath(), e);
      }
      jobGraph.addJar(new Path(file.getAbsolutePath()));
    }

    Configuration configuration = jobGraph.getJobConfiguration();
    Client client = new Client(new InetSocketAddress(host, port), configuration, getClass().getClassLoader());
View Full Code Here

    final long splitLength = inFile.length() / noSplits;
    long pos = 0;

    for (int i = 0; i < noSplits - 1; i++) {
      tmp[i] = new FileInputSplit(i, new Path(path), pos, splitLength, hosts);
      pos += splitLength;
    }

    tmp[noSplits - 1] = new FileInputSplit(noSplits - 1, new Path(path), pos, inFile.length() - pos, hosts);

    this.inputSplits = tmp;
  }
View Full Code Here

    if (path.length() == 0) {
      throw new InvalidProgramException("File path of FileDataSink is empty string.");
    }
   
    try {
      Path p = new Path(path);
      String scheme = p.toUri().getScheme();
     
      if (scheme == null) {
        throw new InvalidProgramException("File path \"" + path + "\" of FileDataSink has no file system scheme (like 'file:// or hdfs://').");
      }
    } catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.apache.flink.core.fs.Path

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.