Package org.akubraproject

Examples of org.akubraproject.Blob


    assertFalse(con.getBlob(b.getId(), null).exists());
  }

  protected Blob moveBlob(BlobStoreConnection con, Blob ob, URI nbId, String body)
      throws Exception {
    Blob nb = ob.moveTo(nbId, null);
    assertNotNull(nb);
    assertEquals(nb.getId(), nbId);
    assertEquals(nb.getConnection(), con);
    assertTrue(nb.exists());
    assertFalse(ob.exists());
    assertFalse(con.getBlob(ob.getId(), null).exists());
    assertTrue(con.getBlob(nbId, null).exists());

    if (body != null) {
View Full Code Here


   */

  protected void createBlob(final URI id, final String val, boolean commit) throws Exception {
    runTests(new ConAction() {
        public void run(BlobStoreConnection con) throws Exception {
          Blob b = getBlob(con, id, null);
          createBlob(con, b, val);
        }
    }, commit);
  }
View Full Code Here

  protected void deleteBlob(final URI id, final String body, final boolean commit)
      throws Exception {
    runTests(new ConAction() {
        public void run(BlobStoreConnection con) throws Exception {
          Blob b = getBlob(con, id, body);
          deleteBlob(con, b);
        }
    }, commit);
  }
View Full Code Here

  }

  protected void setBlob(final URI id, final String val, boolean commit) throws Exception {
    runTests(new ConAction() {
        public void run(BlobStoreConnection con) throws Exception {
          Blob b = getBlob(con, id, true);
          setBlob(con, b, val);
        }
    }, commit);
  }
View Full Code Here

  protected void renameBlob(final URI oldId, final URI newId, final String val, boolean commit)
      throws Exception {
    runTests(new ConAction() {
        public void run(BlobStoreConnection con) throws Exception {
          Blob ob = getBlob(con, oldId, val);
          Blob nb = getBlob(con, newId, null);
          moveBlob(con, ob, nb.getId(), val);
        }
    }, commit);
  }
View Full Code Here

  /**
   * Cross checks getBlob returned with backing stores.
   */
  @Test
  public void testGetBlobURIMapOfStringString() throws IOException {
    Blob b1 = con.getBlob(null, s1Hint);
    Blob b2 = con.getBlob(null, s2Hint);
    Blob b3 = store1.openConnection(null, null).getBlob(b1.getId(), s1Hint);
    Blob b4 = store2.openConnection(null, null).getBlob(b2.getId(), s2Hint);

    b1.openOutputStream(0, true).close();
    b2.openOutputStream(0, true).close();

    assertTrue(b3.exists());
    assertTrue(b4.exists());
    b1.delete();
    b2.delete();
    assertFalse(b3.exists());
    assertFalse(b4.exists());
  }
View Full Code Here

    for (Iterator<URI> it = con.listBlobIds(null); it.hasNext();)
      con.getBlob(it.next(), null).delete();

    assertFalse(con.listBlobIds(null).hasNext());

    Blob b1 = con.getBlob(null, s1Hint);
    Blob b2 = con.getBlob(null, s2Hint);

    b1.openOutputStream(0, true).close();
    b2.openOutputStream(0, true).close();

    Set<Blob> blobs = new HashSet<Blob>();

    for (Iterator<URI> it = con.listBlobIds(null); it.hasNext();)
      blobs.add(con.getBlob(it.next(), null));
View Full Code Here

  /**
   * Tests renames across blob stores.
   */
  @Test
  public void testMoveTo() throws IOException {
    Blob b1 = con.getBlob(null, s1Hint);
    Blob b2 = con.getBlob(null, s2Hint);
    Blob b3 = store1.openConnection(null, null).getBlob(b1.getId(), s1Hint);
    Blob b4 = store2.openConnection(null, null).getBlob(b2.getId(), s2Hint);

    b1.openOutputStream(0, true).close();
    b2.openOutputStream(0, true).close();

    assertTrue(b3.exists());
    assertTrue(b4.exists());
    b2.delete();
    assertFalse(b2.exists());
    assertFalse(b4.exists());

    assertEquals(b2, b1.moveTo(b2.getId(), s2Hint));

    assertFalse(b1.exists());
    assertFalse(b3.exists());
    assertTrue(b2.exists());
    assertTrue(b4.exists());

    try {
      b1.moveTo(b2.getId(), s2Hint);
      fail("Did not get expected MissingBlobException");
    } catch (MissingBlobException mbe) {
    }

    assertFalse(b1.exists());
    assertFalse(b3.exists());
    assertTrue(b2.exists());
    assertTrue(b4.exists());

    b1.openOutputStream(0, true).close();
    assertTrue(b1.exists());
    assertTrue(b3.exists());

    try {
      b1.moveTo(b2.getId(), s2Hint);
      fail("Did not get expected DuplicateBlobException");
    } catch (DuplicateBlobException dbe) {
    }

    assertTrue(b1.exists());
    assertTrue(b3.exists());
    assertTrue(b2.exists());
    assertTrue(b4.exists());
  }
View Full Code Here

    if (blobId != null)
      validateId(blobId);
    else
      blobId = (URI) createBlob(null, hints)[0];

    Blob b = blobCache.get(blobId);
    if (b == null)
      blobCache.put(blobId, b = new TxnBlob(blobId, hints));

    return b;
  }
View Full Code Here

      throw new UnsupportedOperationException("id-generation is not currently supported");

    if (logger.isDebugEnabled())
      logger.debug("creating blob '" + blobId + "' (" + this + ")");

    Blob res = bStoreCon.getBlob(blobId , hints);
    if (res.exists()) {
      if (logger.isDebugEnabled())
        logger.debug("duplicate id - retrying with generated id");
      res = bStoreCon.getBlob(null, hints);
    }

    boolean added = false;
    try {
      addNameEntry(blobId, res.getId());
      addBlob(blobId, res.getId());
      added = true;
    } finally {
      if (!added) {
        try {
          res.delete();
        } catch (Throwable t) {
          logger.warn("Error removing created blob during exception handling: lower-blob-id = '" +
                      res.getId() + "'", t);
        }
      }
    }

    if (logger.isDebugEnabled())
      logger.debug("created blob '" + blobId + "' with underlying id '" + res.getId() + "' (" +
                   this + ")");

    return new Object[] { blobId, res };
  }
View Full Code Here

TOP

Related Classes of org.akubraproject.Blob

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.