Examples of BlobId


Examples of com.socrata.datasync.deltaimporter2.BlobId

   @Test
    public void testDeserializationReturnIds() throws IOException {

        String typicalBlobJson = "{\"blobId\":\"xxxx-xxxx\"}";
        BlobId id1 = mapper.readValue(typicalBlobJson, BlobId.class);
        TestCase.assertEquals("xxxx-xxxx", id1.blobId);

        String typicalJobJson = "{\"jobId\":\"yyyyyy\"}";
        JobId id2 = mapper.readValue(typicalJobJson, JobId.class);
        TestCase.assertEquals("yyyyyy", id2.jobId);

        String emptyJson = "{}";
        BlobId id3 = mapper.readValue(emptyJson, BlobId.class);
        JobId id4 = mapper.readValue(emptyJson, JobId.class);
        TestCase.assertNull(id3.blobId);
        TestCase.assertNull(id4.jobId);

        String extraStuffJson = "{\"blobId\":\"some-4by4\", \"junk\":0}";
        BlobId id5 = mapper.readValue(extraStuffJson, BlobId.class);
        TestCase.assertEquals("some-4by4", id5.blobId);
    }
View Full Code Here

Examples of org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore.BlobId

    }

    @Test
    public void testEncodedBlobId() throws Exception{
        BlobId blobId = new BlobId("abc"+BlobId.SEP+"123");
        assertEquals("abc", blobId.blobId);
        assertEquals(123, blobId.length);

        blobId = new BlobId("abc"+BlobId.SEP+"abc"+BlobId.SEP+"123");
        assertEquals("abc"+BlobId.SEP+"abc", blobId.blobId);
        assertEquals(123, blobId.length);

        blobId = new BlobId("abc",123);
        assertEquals("abc"+BlobId.SEP+"123", blobId.encodedValue());

        assertTrue(BlobId.isEncoded("abc"+BlobId.SEP+"123"));
        assertFalse(BlobId.isEncoded("abc"));
    }
View Full Code Here

Examples of org.sonatype.nexus.blobstore.api.BlobId

      TestWorker r = new TestWorker(testWorkers.size(), startingGun, failureHasOccurred, numberOfIterations,
          new TestTask()
          {
            @Override
            public void run() throws Exception {
              final BlobId blobId = blobIdsInTheStore.peek();

              log("Attempting to read " + blobId);

              if (blobId == null) {
                return;
              }

              final Blob blob = underTest.get(blobId);
              if (blob == null) {
                log("Attempted to obtain blob, but it was deleted:" + blobId);
                return;
              }

              try (InputStream inputStream = blob.getInputStream()) {
                readContentAndValidateMetrics(blobId, inputStream, blob.getMetrics());
              }
              catch (BlobStoreException e) {
                // This is normal operation if another thread deletes your blob after you obtain a Blob reference
                log("Concurrent deletion suspected while calling blob.getInputStream().", e);
              }
            }
          }
      );
      testWorkers.add(r);
    }

    for (int i = 0; i < numberOfDeleters; i++) {
      testWorkers
          .add(new TestWorker(testWorkers.size(), startingGun, failureHasOccurred, numberOfIterations, new TestTask()
          {
            @Override
            public void run() throws Exception {
              final BlobId blobId = blobIdsInTheStore.poll();
              if (blobId == null) {
                log("deleter: null blob id");
                return;
              }
              underTest.delete(blobId);
            }
          }));
    }

    // Shufflers pull blob IDs off the front of the queue and stick them on the back, to make the blobID queue a bit less orderly
    for (int i = 0; i < numberOfShufflers; i++) {
      testWorkers.add(
          new TestWorker(testWorkers.size(), startingGun, failureHasOccurred, numberOfIterations, new TestTask()
          {
            @Override
            public void run() throws Exception {
              final BlobId blobId = blobIdsInTheStore.poll();
              if (blobId != null) {
                blobIdsInTheStore.add(blobId);
              }
            }
          }));
View Full Code Here

Examples of org.sonatype.nexus.blobstore.api.BlobId

  }

  @Test
  public void stateTracking() throws Exception {
    BlobMetadata md = new BlobMetadata(BlobState.CREATING, ImmutableMap.of("foo", "bar"));
    BlobId id = underTest.add(md);
    log("Added: {} -> {}", id, md);

    // states should only contain CREATING
    assertThat(findWithState(BlobState.CREATING), contains(id));
    assertThat(findWithState(BlobState.ALIVE), emptyIterable());
View Full Code Here

Examples of org.sonatype.nexus.blobstore.api.BlobId

    BlobMetadata md = new BlobMetadata(BlobState.CREATING, ImmutableMap.of("foo", "bar"));
    log(md);

    // add a record
    log("add");
    BlobId id = underTest.add(md);
    log(id);

    dumpStates();

    // update a record
View Full Code Here

Examples of org.sonatype.nexus.blobstore.api.BlobId

  }

  private Blob getLocalBlob(ODocument assetDocument) {
    Map<String, String> blobRefs = assetDocument.field(P_BLOB_REFS);
    checkState(blobRefs.containsKey(localBlobStoreId), "Local blobRef does not exist for that asset");
    BlobId blobId = new BlobId(blobRefs.get(localBlobStoreId));
    Blob blob = blobStore.get(new BlobId(blobRefs.get(localBlobStoreId)));
    checkState(blob != null, "Blob not found in local store: %", blobId.asUniqueString());
    return blob;
  }
View Full Code Here

Examples of org.sonatype.nexus.blobstore.api.BlobId

  /**
   * Generate a new blob identifier.
   */
  private BlobId newId(final DB db) {
    long id = idSequence(db).incrementAndGet();
    return new BlobId(String.format("%016x", id));
  }
View Full Code Here

Examples of org.sonatype.nexus.blobstore.api.BlobId

    return database.execute(new Fun.Function1<BlobId, DB>()
    {
      @Override
      public BlobId run(final DB db) {
        BlobId id = newId(db);
        log.trace("Add: {}={}", id, record);

        MetadataRecord prev = entries(db).put(id, record);
        checkState(prev == null, "Duplicate blob-id: %s", id);
View Full Code Here

Examples of org.sonatype.nexus.blobstore.api.BlobId

    checkNotNull(headers);

    checkArgument(headers.containsKey(BLOB_NAME_HEADER), "Missing header: %s", BLOB_NAME_HEADER);
    checkArgument(headers.containsKey(CREATED_BY_HEADER), "Missing header: %s", CREATED_BY_HEADER);

    BlobId blobId = null;

    try {
      // If the storing of bytes fails, we record a reminder to clean up afterwards
      final BlobMetadata metadata = new BlobMetadata(BlobState.CREATING, headers);
      blobId = metadataStore.add(metadata);
View Full Code Here

Examples of org.sonatype.nexus.blobstore.api.BlobId

    underTest.create(inputStream, headers);
  }

  @Test
  public void successfulCreation() throws Exception {
    final BlobId fakeId = new BlobId("testId");
    final long contentSize = 200L;
    final String fakeSHA1 = "3757y5abc234cfgg";
    final InputStream inputStream = mock(InputStream.class);
    final ImmutableMap<String, String> headers = ImmutableMap.of(
        BlobStore.BLOB_NAME_HEADER, "my blob",
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.