Package org.akubraproject

Examples of org.akubraproject.Blob


    final String body = "value";

    // create-delete in one txn
    doInTxn(new ConAction() {
        public void run(BlobStoreConnection con) throws Exception {
          Blob b = getBlob(con, id, null);
          createBlob(con, b, null);
          deleteBlob(con, b);
        }
    }, true);

    // create-delete-create in one txn
    doInTxn(new ConAction() {
        public void run(BlobStoreConnection con) throws Exception {
          Blob b = getBlob(con, id, null);
          createBlob(con, b, null);
          deleteBlob(con, b);
          createBlob(con, b, null);
        }
    }, true);

    // delete-create-delete in one txn
    doInTxn(new ConAction() {
        public void run(BlobStoreConnection con) throws Exception {
          Blob b = getBlob(con, id, "");
          deleteBlob(con, b);
          createBlob(con, b, null);
          deleteBlob(con, b);
        }
    }, true);

    // create-delete-create-delete in one txn
    doInTxn(new ConAction() {
        public void run(BlobStoreConnection con) throws Exception {
          Blob b = getBlob(con, id, null);
          createBlob(con, b, null);
          deleteBlob(con, b);
          createBlob(con, b, null);
          deleteBlob(con, b);
        }
    }, true);

    // create-update-delete-create-update-delete in one txn
    doInTxn(new ConAction() {
        public void run(BlobStoreConnection con) throws Exception {
          Blob b = getBlob(con, id, null);
          createBlob(con, b, body);
          deleteBlob(con, b);
          createBlob(con, b, body);
          deleteBlob(con, b);
        }
    }, true);

    // create in one, delete in another
    createBlob(id, body, true);
    deleteBlob(id, body, true);

    // create in one, delete + create in another
    createBlob(id, body, true);

    doInTxn(new ConAction() {
        public void run(BlobStoreConnection con) throws Exception {
          Blob b = getBlob(con, id, body);
          deleteBlob(con, b);
          createBlob(con, b, null);
        }
    }, true);

    // delete + create + update in one
    doInTxn(new ConAction() {
        public void run(BlobStoreConnection con) throws Exception {
          Blob b = getBlob(con, id, "");
          deleteBlob(con, b);
          createBlob(con, b, body);
        }
    }, true);

    // update + delete + create + update in one
    doInTxn(new ConAction() {
        public void run(BlobStoreConnection con) throws Exception {
          Blob b = getBlob(con, id, body);
          setBlob(con, b, "foo");
          deleteBlob(con, b);
          createBlob(con, b, body);
        }
    }, true);

    // delete + create + update + delete in one
    doInTxn(new ConAction() {
        public void run(BlobStoreConnection con) throws Exception {
          Blob b = getBlob(con, id, body);
          deleteBlob(con, b);
          createBlob(con, b, body);
          deleteBlob(con, b);
        }
    }, true);

    // create-move-delete in one txn
    doInTxn(new ConAction() {
        public void run(BlobStoreConnection con) throws Exception {
          Blob b  = getBlob(con, id, null);
          Blob b2 = getBlob(con, id2, null);

          createBlob(con, b, null);
          moveBlob(con, b, id2, "");
          deleteBlob(con, b2);
        }
    }, true);

    // create in one, move-delete in another txn
    createBlob(id, body, true);

    doInTxn(new ConAction() {
        public void run(BlobStoreConnection con) throws Exception {
          Blob b  = getBlob(con, id, body);
          Blob b2 = getBlob(con, id2, null);

          moveBlob(con, b, id2, body);
          deleteBlob(con, b2);
        }
    }, true);

    // create-move-delete-create-move in one txn
    doInTxn(new ConAction() {
        public void run(BlobStoreConnection con) throws Exception {
          Blob b  = getBlob(con, id, null);
          Blob b2 = getBlob(con, id2, null);

          createBlob(con, b, null);
          moveBlob(con, b, id2, "");
          deleteBlob(con, b2);
          createBlob(con, b2, null);
          moveBlob(con, b2, id, "");
          setBlob(con, b, body);
        }
    }, true);

    // move-delete-create-move-again-yada-yada...
    doInTxn(new ConAction() {
        public void run(BlobStoreConnection con) throws Exception {
          Blob b  = getBlob(con, id, body);
          Blob b2 = getBlob(con, id2, null);

          moveBlob(con, b, id2, body);
          deleteBlob(con, b2);
          createBlob(con, b, null);
          moveBlob(con, b, id2, "");
View Full Code Here


    createBlob(id1, body1, true);

    // create a set of actions
    ConAction createNoBody = new ConAction() {
            public void run(BlobStoreConnection con) throws Exception {
              Blob b = getBlob(con, id2, null);
              createBlob(con, b, null);
            }
        };

    ConAction createWithBody = new ConAction() {
            public void run(BlobStoreConnection con) throws Exception {
              Blob b = getBlob(con, id2, null);
              createBlob(con, b, body2);
            }
        };

    ConAction delete1 = new ConAction() {
            public void run(BlobStoreConnection con) throws Exception {
              Blob b = getBlob(con, id1, body1);
              deleteBlob(con, b);
            }
        };

    ConAction modify1 = new ConAction() {
            public void run(BlobStoreConnection con) throws Exception {
              Blob b = getBlob(con, id1, body1);
              setBlob(con, b, body11);
            }
        };

    ConAction rename12 = new ConAction() {
            public void run(BlobStoreConnection con) throws Exception {
              Blob b1 = getBlob(con, id1, body1);
              moveBlob(con, b1, id2, body1);
            }
        };

    // test create-create conflict
View Full Code Here

          getBlob(con, id2, null);
          getBlob(con, id3, null);
          getBlob(con, id4, null);

          // create another blob and modify
          Blob b = getBlob(con, id2, null);
          createBlob(con, b, body1);
          setBlob(con, b, body2);

          // create a new blob and verify we don't see it but others see it
          boolean[] failed = new boolean[] { false };

          doInThread(new ERunnable() {
            @Override
            public void erun() throws Exception {
              createBlob(id3, body3, true);
            }
          }, failed).join();
          assertFalse(failed[0]);

          doInThread(new ERunnable() {
            @Override
            public void erun() throws Exception {
              getBlob(id1, body1, true);
              getBlob(id2, null, true);
              getBlob(id3, body3, true);
              getBlob(id4, null, true);
            }
          }, failed).join();
          assertFalse(failed[0]);

          getBlob(con, id1, body1);
          getBlob(con, id2, body2);
          getBlob(con, id3, null);
          getBlob(con, id4, null);

          // delete the new blob
          doInThread(new ERunnable() {
            @Override
            public void erun() throws Exception {
              deleteBlob(id3, body3, true);
            }
          }, failed).join();
          assertFalse(failed[0]);

          doInThread(new ERunnable() {
            @Override
            public void erun() throws Exception {
              getBlob(id1, body1, true);
              getBlob(id2, null, true);
              getBlob(id3, null, true);
              getBlob(id4, null, true);
            }
          }, failed).join();
          assertFalse(failed[0]);

          getBlob(con, id1, body1);
          getBlob(con, id2, body2);
          getBlob(con, id3, null);
          getBlob(con, id4, null);

          // delete the first blob
          doInThread(new ERunnable() {
            @Override
            public void erun() throws Exception {
              deleteBlob(id1, body1, true);
            }
          }, failed).join();
          assertFalse(failed[0]);

          doInThread(new ERunnable() {
            @Override
            public void erun() throws Exception {
              getBlob(id1, null, true);
              getBlob(id2, null, true);
              getBlob(id3, null, true);
              getBlob(id4, null, true);
            }
          }, failed).join();
          assertFalse(failed[0]);

          getBlob(con, id1, body1);
          getBlob(con, id2, body2);
          getBlob(con, id3, null);
          getBlob(con, id4, null);

          // re-create the first blob, but with different content
          doInThread(new ERunnable() {
            @Override
            public void erun() throws Exception {
              createBlob(id1, body22, true);
            }
          }, failed).join();
          assertFalse(failed[0]);

          doInThread(new ERunnable() {
            @Override
            public void erun() throws Exception {
              getBlob(id1, body22, true);
              getBlob(id2, null, true);
              getBlob(id3, null, true);
              getBlob(id4, null, true);
            }
          }, failed).join();
          assertFalse(failed[0]);

          getBlob(con, id1, body1);
          getBlob(con, id2, body2);
          getBlob(con, id3, null);
          getBlob(con, id4, null);

          // step through, making sure we don't see anything from active transactions
          final boolean[] cv = new boolean[1];
          Thread t = doInThread(new ERunnable() {
            @Override
            public void erun() throws Exception {
              doInTxn(new ConAction() {
                public void run(BlobStoreConnection c2) throws Exception {
                  Blob b = getBlob(c2, id4, null);
                  createBlob(c2, b, body4);

                  notifyAndWait(cv, true);

                  deleteBlob(c2, b);
View Full Code Here

                waitFor(cv, cvVal, 0);

                notifyAndWait(cv, !cvVal);

                for (int idx = 0; idx < 2; idx++ ) {
                  Blob b = getBlob(con, ids[idx], null);
                  createBlob(con, b, null);

                  for (int idx2 = 0; idx2 < 2; idx2++ )
                    getBlob(con, oids[idx2], false);

                  notifyAndWait(cv, !cvVal);

                  setBlob(con, b, bodies[idx]);

                  notifyAndWait(cv, !cvVal);
                }
              }
          }, true);

          notifyAndWait(cv, !cvVal);

          // exchange the two blobs
          doInTxn(new ConAction() {
              public void run(final BlobStoreConnection con) throws Exception {
                getBlob(con, id1, body1);
                getBlob(con, id2, body2);
                getBlob(con, id3, body3);
                getBlob(con, id4, body4);

                notifyAndWait(cv, !cvVal);

                URI[][] seq = new URI[][] {
                  { ids[0], tid },
                  { ids[1], ids[0] },
                  { tid, ids[1] },
                };

                for (int idx = 0; idx < seq.length; idx++ ) {
                  Blob bs = getBlob(con, seq[idx][0], true);
                  moveBlob(con, bs, seq[idx][1], null);

                  notifyAndWait(cv, !cvVal);
                }
              }
          }, true);

          notifyAndWait(cv, !cvVal);

          // delete the two blobs
          doInTxn(new ConAction() {
              public void run(final BlobStoreConnection con) throws Exception {
                getBlob(con, id1, body2);
                getBlob(con, id2, body1);
                getBlob(con, id3, body4);
                getBlob(con, id4, body3);

                notifyAndWait(cv, !cvVal);

                for (int idx = 0; idx < 2; idx++ ) {
                  Blob b = getBlob(con, ids[idx], bodies[1 - idx]);
                  deleteBlob(con, b);

                  for (int idx2 = 0; idx2 < 2; idx2++ )
                    getBlob(con, oids[idx2], obodies[1 - idx2]);
View Full Code Here

      final int start = b * 1000;

      doInTxn(new ConAction() {
        public void run(BlobStoreConnection con) throws Exception {
          for (int idx = start; idx < start + 1000; idx++) {
            Blob b = con.getBlob(URI.create("urn:blobStressTestFiller" + idx), null);
            setBody(b, "v" + idx);
          }
        }
      }, true);
    }

    long t1 = System.currentTimeMillis();

    // set up
    Thread[] writers = new Thread[numWriters];
    Thread[] readers = new Thread[numReaders];
    boolean[] failed = new boolean[] { false };

    final boolean[] testDone = new boolean[] { false };
    final int[]     lowIds   = new int[numWriters];
    final int[]     highId   = new int[] { 0 };

    // start/run the writers
    for (int t = 0; t < writers.length; t++) {
      final int tid   = t;
      final int start = t * numRounds * numObjects;

      writers[t] = doInThread(new ERunnable() {
        @Override
        public void erun() throws Exception {
          for (int r = 0; r < numRounds; r++) {
            final int off = start + r * numObjects;

            doInTxn(new ConAction() {
              public void run(BlobStoreConnection con) throws Exception {
                for (int o = 0; o < numObjects; o++) {
                  int    idx = off + o;
                  URI    id  = URI.create("urn:blobStressTest" + idx);
                  String val = "v" + idx;

                  Blob b = getBlob(con, id, null);
                  createBlob(con, b, val);
                }
              }
            }, true);

            synchronized (testDone) {
              highId[0] = Math.max(highId[0], off + numObjects);
            }

            doInTxn(new ConAction() {
              public void run(BlobStoreConnection con) throws Exception {
                for (int o = 0; o < numObjects; o++) {
                  int    idx = off + o;
                  URI    id  = URI.create("urn:blobStressTest" + idx);
                  String val = "v" + idx;

                  Blob b = getBlob(con, id, val);
                  deleteBlob(con, b);
                }
              }
            }, true);

            synchronized (testDone) {
              lowIds[tid] = off + numObjects;
            }
          }
        }
      }, failed);
    }

    // start/run the readers
    for (int t = 0; t < readers.length; t++) {
      readers[t] = doInThread(new ERunnable() {
        @Override
        public void erun() throws Exception {
          final Random rng   = new Random();
          final int[]  found = new int[] { 0 };

          while (true) {
            final int low, high;
            synchronized (testDone) {
              if (testDone[0])
                break;

              high = highId[0];

              int tmp = Integer.MAX_VALUE;
              for (int id : lowIds)
                tmp = Math.min(tmp, id);
              low = tmp;
            }

            if (low == high) {
              Thread.yield();
              continue;
            }

            doInTxn(new ConAction() {
              public void run(BlobStoreConnection con) throws Exception {
                for (int o = 0; o < numObjects; o++) {
                  int    idx = rng.nextInt(high - low) + low;
                  URI    id  = URI.create("urn:blobStressTest" + idx);
                  String val = "v" + idx;

                  Blob b = con.getBlob(id, null);
                  if (b.exists()) {
                    assertEquals(getBody(b), val);
                    found[0]++;
                  }
                }
              }
View Full Code Here

  }

  @Override
  public Blob getBlob(URI blobId, Map<String, String> hints)
      throws IOException, UnsupportedIdException, UnsupportedOperationException {
    Blob internalBlob;
    if (blobId == null)
      internalBlob = delegate.getBlob(null, hints);
    else
      internalBlob = delegate.getBlob(mapper.getInternalId(blobId), hints);
    return new IdMappingBlob(this, internalBlob, mapper);
View Full Code Here

  }

  @Override
  public Blob getBlob(InputStream content, long estimatedSize, Map<String, String> hints)
      throws IOException, UnsupportedOperationException {
    Blob internalBlob = delegate.getBlob(content, estimatedSize, hints);
    return new IdMappingBlob(this, internalBlob, mapper);
  }
View Full Code Here

  }

  @Override
  public Blob moveTo(URI blobId, Map<String, String> hints) throws DuplicateBlobException,
      IOException, MissingBlobException, NullPointerException, IllegalArgumentException {
    Blob internalBlob;
    if (blobId == null)
      internalBlob = delegate.moveTo(null, hints);
    else
      internalBlob = delegate.moveTo(mapper.getInternalId(blobId), hints);
    return new IdMappingBlob(owner, internalBlob, mapper);
View Full Code Here

  public RepeatStatus execute(StepContribution contribution,
      ChunkContext chunkContext) throws Exception {
    String guid = FedoraURI.getGuidFromPid(pid);

    BasicDownloadRequest request = new BasicDownloadRequest();
    Blob blob = lowLevelStorage.getBlob(FedoraURI.getPidFromGuid(guid),
        "FULL_OCR");
    request.setBlob(blob);
    request.setContentType(ContentType.OCR);
    String[] pageUris = PID_EXTRACTOR.getPageURIs(guid, "");
    request.setPageURIs(pageUris);
View Full Code Here

  public RepeatStatus execute(StepContribution contribution,
      ChunkContext chunkContext) throws Exception {
    String guid = FedoraURI.getGuidFromPid(pid);

    BasicDownloadRequest request = new BasicDownloadRequest();
    Blob blob = lowLevelStorage.getBlob(FedoraURI.getPidFromGuid(guid),
        "FULL_JPG");
    request.setBlob(blob);
    request.setContentType(ContentType.JPEG);
    request.setResolution(new Resolution("medium"));
    String[] pageUris = PID_EXTRACTOR.getPageURIs(guid, "");
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.