public static BlobStoreFixture getMemoryBlobStore() { return new BlobStoreFixture("MEM") { private MemoryBlobStore mbs = new MemoryBlobStore(); @Override public BlobStore setUp() { return mbs; } @Override public void tearDown() { } @Override public long size() { throw new UnsupportedOperationException("Implementation pending"); } }; }
@Override public void call() throws Exception { int i = id.getAndIncrement(); ByteArrayOutputStream out = new ByteArrayOutputStream(); IOUtils.writeLong(out, i); out.write(EMPTY); byte[] data = out.toByteArray(); String id = store.writeBlob(new ByteArrayInputStream(data)); Assert.assertEquals(58, store.getBlobLength(id)); byte[] test = out.toByteArray(); Assert.assertEquals(8, store.readBlob(id, 0, test, 0, 8)); Assert.assertTrue(Arrays.equals(data, test)); } });
@Override public InputStream getInputStream(String blobId) throws IOException { reads.add(blobId); return super.getInputStream(blobId); } };
@Override public void setUp() throws Exception { store = new MemoryBlobStore(); store.setBlockSize(128); ((MemoryBlobStore) store).setBlockSizeMin(48); }
MemoryBlobStore bs = new MemoryBlobStore(); bs.setBlockSizeMin(48); BlobFactory factory = in -> new BlobStoreBlob(bs, bs.writeBlob(in));
@Override public String writeBlob(InputStream in) throws IOException { writeCount++; return super.writeBlob(in); } }
@Override public void startMark() throws IOException { mark = true; old = map; map = new HashMap<BlockId, byte[]>(); markInUse(); }
@Override public int readBlob(String s, long l, byte[] bytes, int i, int i1) throws IOException { return bs.readBlob(mapId(s), l, bytes, i, i1); }
@Override public long getBlobLength(String s) throws IOException { return bs.getBlobLength(mapId(s)); }
@Before public void setUp() throws Exception { store.setBlockSizeMin(50); }
@Test public void clonedNSWithSharedDS() throws Exception { MemoryBlobStore bs = new MemoryBlobStore(); bs.setBlockSizeMin(48); new ActiveDeletedBlobCollectorMBeanImpl(ActiveDeletedBlobCollectorFactory.NOOP, wb, dns1, indexPathService, asyncIndexInfoService, new MemoryBlobStore(), sameThreadExecutor()); bean.clock = clock;
@Override public String writeBlob(InputStream in) throws IOException { if (fail) { throw new IOException("Failing on demand"); } return super.writeBlob(in); }
@Override public void startMark() throws IOException { mark = true; old = map; map = new HashMap<BlockId, byte[]>(); markInUse(); }
public static BlobStoreFixture getMemoryBlobStore() { return new BlobStoreFixture("MEM") { private MemoryBlobStore mbs = new MemoryBlobStore(); @Override public BlobStore setUp() { return mbs; } @Override public void tearDown() { } @Override public long size() { throw new UnsupportedOperationException("Implementation pending"); } }; }
@Override public String writeBlob(InputStream in) throws IOException { //Avoid expensive digest calculation as all content is 0 byte. So memorize //the id if same content is passed if (blobId == null) { data = IOUtils.toByteArray(in); blobId = super.writeBlob(new ByteArrayInputStream(data)); return blobId; } else { byte[] bytes = IOUtils.toByteArray(in); if (Arrays.equals(data, bytes)) { return blobId; } return super.writeBlob(new ByteArrayInputStream(bytes)); } }
@Override public void startMark() throws IOException { mark = true; old = map; map = new HashMap<BlockId, byte[]>(); markInUse(); }
@Override public InputStream getInputStream(String s) throws IOException { return bs.getInputStream(mapId(s)); }
public BlobStore getBlobStore() { if (blobStore == null) { blobStore = new MemoryBlobStore(); configureBlobStore(blobStore); } return blobStore; }
@Override public String writeBlob(InputStream inputStream) throws IOException { String in = bs.writeBlob(inputStream); String out = generateId(); ids.put(out, in); return out; }
public BlobStore getBlobStore() { if (blobStore == null) { blobStore = new MemoryBlobStore(); configureBlobStore(blobStore); } return blobStore; }