public OutputStream getOutput(String pathname, boolean append, int chunk_size)
      throws IOException {
    GridFile file = (GridFile) getFile(pathname, chunk_size);
    if (!file.createNewFile()) throw new IOException("creation of " + pathname + " failed");

    return new GridOutputStream(file, append, data, chunk_size);
  }
Exemple #2
0
  public void testDeleteRemovesAllChunks() throws Exception {
    assertEquals(numberOfChunksInCache(), 0);
    assertEquals(numberOfMetadataEntries(), 0);

    writeToFile("delete.txt", "delete me", 100);

    GridFile file = (GridFile) fs.getFile("delete.txt");
    boolean deleted = file.delete();
    assertTrue(deleted);
    assertFalse(file.exists());
    assertEquals(numberOfChunksInCache(), 0);
    assertEquals(numberOfMetadataEntries(), 0);
  }
Exemple #3
0
  public void testWriteAcrossMultipleChunksWithNonDefaultChunkSizeAfterFileIsExplicitlyCreated()
      throws Exception {
    GridFile file = (GridFile) fs.getFile("multipleChunks.txt", 20); // chunkSize = 20
    file.createNewFile();

    writeToFile(
        "multipleChunks.txt",
        "This text spans multiple chunks, because each chunk is only 20 bytes long.",
        10); // chunkSize = 10 (but it is ignored, because the file was already created with
    // chunkSize = 20

    String text = getContents("multipleChunks.txt");
    assertEquals(
        text, "This text spans multiple chunks, because each chunk is only 20 bytes long.");
  }
 GridInputStream(GridFile file, Cache<String, byte[]> cache, int chunk_size)
     throws FileNotFoundException {
   this.file = file;
   this.name = file.getPath();
   this.cache = cache;
   this.chunk_size = chunk_size;
 }
 public InputStream getInput(String pathname) throws FileNotFoundException {
   GridFile file = (GridFile) getFile(pathname);
   if (!file.exists()) throw new FileNotFoundException(pathname);
   return new GridInputStream(file, data, default_chunk_size);
 }
 public OutputStream getOutput(GridFile file) throws IOException {
   if (!file.createNewFile()) throw new IOException("creation of " + file + " failed");
   return new GridOutputStream(file, false, data, default_chunk_size);
 }
Exemple #7
0
 private String getChunkKey(int chunkNumber) {
   return getChunkKey(file.getAbsolutePath(), chunkNumber);
 }
Exemple #8
0
 public int getChunkSize() {
   return file.getChunkSize();
 }