Package org.akubraproject

Examples of org.akubraproject.BlobStoreConnection


    if (!isTransactional)
      return;

    // no operations, commit then close
    tm.begin();
    BlobStoreConnection con = store.openConnection(tm.getTransaction(), null);
    tm.commit();
    con.close();
    assertTrue(con.isClosed());

    // no operations, roll back then close
    tm.begin();
    con = store.openConnection(tm.getTransaction(), null);
    tm.rollback();
    con.close();
    assertTrue(con.isClosed());

    // one operation, commit then close
    tm.begin();
    con = store.openConnection(tm.getTransaction(), null);
    Blob b = getBlob(con, id, null);
    createBlob(con, b, null);
    tm.commit();
    con.close();
    assertTrue(con.isClosed());

    // one operation, roll back then close
    tm.begin();
    con = store.openConnection(tm.getTransaction(), null);
    b = getBlob(con, id, "");
    deleteBlob(con, b);
    tm.rollback();
    con.close();
    assertTrue(con.isClosed());

    // clean up
    deleteBlob(id, "", true);
    assertNoBlobs(getPrefixFor("blobCloseConn"));
  }
View Full Code Here


    final Map<String, String> hints = new HashMap<String, String>();
    hints.put(FSBlobStore.WILL_NOT_SYNC, "true");

    shouldFail(new Action() {
      public void run(Transaction txn) throws Exception {
        BlobStoreConnection con = store.openConnection(txn, hints);
        con.sync();
      }
    }, UnsupportedOperationException.class, null);

    shouldFail(new Action() {
      public void run(Transaction txn) throws Exception {
        BlobStoreConnection con = store.openConnection(txn, hints);

        Blob b = getBlob(con, createId("blobConSync3"), null);
        createBlob(con, b, "foos");
        b = moveBlob(con, b, createId("blobConSync4"), "foos");
        deleteBlob(con, b);

        con.sync();
      }
    }, UnsupportedOperationException.class, null);

    // test will-not-sync hint = false
    hints.put(FSBlobStore.WILL_NOT_SYNC, "false");

    runTests(new Action() {
      public void run(Transaction txn) throws Exception {
        BlobStoreConnection con = store.openConnection(txn, hints);
        con.sync();
        con.close();
      }
    });
  }
View Full Code Here

                                  boolean delegateCanCanonicalize)
      throws Exception {
    IdMapper mapper = new MockIdMapper();
    BlobStore store = new IdMappingBlobStore(URI.create("urn:test-store"),
        new MemBlobStore(), mapper);
    BlobStoreConnection connection = store.openConnection(null, null);
    Blob delegate = connection.getBlob(blobId, null);
    OutputStream out = delegate.openOutputStream(-1, false);
    IOUtils.copy(new StringReader(blobId.toString()), out);
    out.close();
    if (!delegateCanCanonicalize)
      delegate = new BlobWrapper(delegate) {
View Full Code Here

    private static long add(BlobStore store,
                            String key,
                            InputStream content, Map<String, String> hints)
            throws ObjectAlreadyInLowlevelStorageException {
        BlobStoreConnection connection = null;
        try {
            URI blobId = getBlobId(key);
            connection = getConnection(store, hints);
            Blob blob = getBlob(connection, blobId, hints);
            OutputStream out = openOutputStream(blob, -1, false);
View Full Code Here

    }

    private static void remove(BlobStore store,
                               String key)
            throws ObjectNotInLowlevelStorageException {
        BlobStoreConnection connection = null;
        try {
            URI blobId = getBlobId(key);
            connection = getConnection(store, null);
            Blob blob = getBlob(connection, blobId, null);
            if (exists(blob)) {
View Full Code Here

                                String key,
                                InputStream content,
                                boolean forceSafeOverwrite,
                                Map<String, String> hints)
            throws LowlevelStorageException {
        BlobStoreConnection connection = null;
        try {
            URI blobId = getBlobId(key);
            connection = getConnection(store, hints);
            Blob blob = getBlob(connection, blobId, null);
            if (exists(blob)) {
View Full Code Here

            closeConnection(connection);
        }
    }

    private static Iterator<String> list(BlobStore store) {
        BlobStoreConnection connection = null;
        boolean successful = false;
        try {
            connection = getConnection(store, null);
            Iterator<URI> blobIds = listBlobIds(connection);
            successful = true;
View Full Code Here

     * Overwrites the content of the given blob in a way that guarantees the
     * original content is not destroyed until the replacement is successfully
     * put in its place.
     */
    private static void safeOverwrite(Blob origBlob, InputStream content) {
        BlobStoreConnection connection = origBlob.getConnection();
        String origId = origBlob.getId().toString();

        // write new content to origId/new
        Blob newBlob = null;
        try {
            newBlob = connection.getBlob(new URI(origId + "/new"), null);
            copy(content, newBlob.openOutputStream(-1, false));
        } catch (Throwable th) {
            // any error or exception here is an unrecoverable fault
            throw new FaultException(th);
        }
View Full Code Here

    }

    private static InputStream retrieve(BlobStore store,
                                        String key)
            throws ObjectNotInLowlevelStorageException {
        BlobStoreConnection connection = null;
        InputStream content = null;
        boolean successful = false;
        try {
            URI blobId = getBlobId(key);
            connection = getConnection(store, null);
View Full Code Here

    }

    private static long getSize(BlobStore store,
                                        String key)
            throws ObjectNotInLowlevelStorageException {
        BlobStoreConnection connection = null;
        boolean successful = false;
        try {
            URI blobId = getBlobId(key);
            connection = getConnection(store, null);
            Blob blob = getBlob(connection, blobId, null);
View Full Code Here

TOP

Related Classes of org.akubraproject.BlobStoreConnection

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.