@Override public void addMetadataRecord(InputStream stream, String name) throws DataStoreException { if (delegate instanceof SharedDataStore) { ((SharedDataStore) delegate).addMetadataRecord(stream, name); } }
@Override public void addMetadataRecord(InputStream stream, String name) throws DataStoreException { if (delegate instanceof SharedDataStore) { ((SharedDataStore) delegate).addMetadataRecord(stream, name); } }
@Override public void addMetadataRecord(File f, String name) throws DataStoreException { if (delegate instanceof SharedDataStore) { ((SharedDataStore) delegate).addMetadataRecord(f, name); } }
@Override public void addMetadataRecord(File f, String name) throws DataStoreException { if (delegate instanceof SharedDataStore) { ((SharedDataStore) delegate).addMetadataRecord(f, name); } }
@Override public void addMetadataRecord(InputStream stream, String name) throws DataStoreException { if (delegate instanceof SharedDataStore) { ((SharedDataStore) delegate).addMetadataRecord(stream, name); } }
@Override public void addMetadataRecord(File f, String name) throws DataStoreException { if (delegate instanceof SharedDataStore) { ((SharedDataStore) delegate).addMetadataRecord(f, name); } }
@Override public void addMarkedStartMarker(GarbageCollectableBlobStore blobStore, String repoId, String uniqueSuffix) { try { ((SharedDataStore) blobStore).addMetadataRecord(new ByteArrayInputStream(new byte[0]), SharedStoreRecordType.MARKED_START_MARKER .getNameFromIdPrefix(repoId, uniqueSuffix)); } catch (DataStoreException e) { LOG.debug("Error creating marked time marker for repo : {}", repoId); } } },
@Override public void addMarkedStartMarker(GarbageCollectableBlobStore blobStore, String repoId) { try { ((SharedDataStore) blobStore).addMetadataRecord(new ByteArrayInputStream(new byte[0]), SharedStoreRecordType.MARKED_START_MARKER .getNameFromId(repoId)); } catch (DataStoreException e) { LOG.debug("Error creating marked time marker for repo : {}", repoId); } } },
@Override public void addMarkedStartMarker(GarbageCollectableBlobStore blobStore, String repoId, String uniqueSuffix) { try { ((SharedDataStore) blobStore).addMetadataRecord(new ByteArrayInputStream(new byte[0]), SharedStoreRecordType.MARKED_START_MARKER .getNameFromIdPrefix(repoId, uniqueSuffix)); } catch (DataStoreException e) { LOG.debug("Error creating marked time marker for repo : {}", repoId); } } },
/** * Adds the marked references to the blob store root. Default NOOP * * @param blobStore the blob store * @param fs the fs * @param repoId the repo id * @throws DataStoreException the data store exception * @throws IOException Signals that an I/O exception has occurred. */ @Override void addMarked(GarbageCollectableBlobStore blobStore, GarbageCollectorFileState fs, String repoId) throws DataStoreException, IOException { ((SharedDataStore) blobStore) .addMetadataRecord(fs.getMarkedRefs(), SharedStoreRecordType.REFERENCES.getNameFromId(repoId)); }
/** * Adds the marked references to the blob store root. Default NOOP * * @param blobStore the blob store * @param fs the fs * @param repoId the repo id * @param uniqueSuffix the unique session suffix * @throws DataStoreException the data store exception * @throws IOException Signals that an I/O exception has occurred. */ @Override void addMarked(GarbageCollectableBlobStore blobStore, GarbageCollectorFileState fs, String repoId, String uniqueSuffix) throws DataStoreException, IOException { boolean exists = ((SharedDataStore) blobStore) .metadataRecordExists(SharedStoreRecordType.REFERENCES.getNameFromId(repoId)); if (exists) { LOG.info("References for repository id {} already exists. Creating a duplicate one. " + "Please check for inadvertent sharing of repository id by different repositories", repoId); } ((SharedDataStore) blobStore).addMetadataRecord(fs.getMarkedRefs(), SharedStoreRecordType.REFERENCES .getNameFromIdPrefix(repoId, uniqueSuffix)); }
@Test public void testBackendAddMetadataRecordNullInputStreamThrowsNullPointerException() throws DataStoreException { expectedEx.expect(IllegalArgumentException.class); expectedEx.expectMessage("input should not be null"); SharedDataStore fds = dataStore; fds.addMetadataRecord((InputStream)null, "name"); }
@Test public void testBackendAddMetadataRecordNullFileThrowsNullPointerException() throws DataStoreException { expectedEx.expect(IllegalArgumentException.class); expectedEx.expectMessage("input should not be null"); SharedDataStore fds = dataStore; fds.addMetadataRecord((File)null, "name"); }
@Test public void testBackendAddMetadataRecordFileNotFoundThrowsDataStoreException() throws IOException { SharedDataStore fds = dataStore; File testFile = folder.newFile(); copyInputStreamToFile(randomStream(0, 10), testFile); testFile.delete(); try { fds.addMetadataRecord(testFile, "name"); fail(); } catch (DataStoreException e) { assertTrue(e.getCause() instanceof FileNotFoundException); } }
public Cluster(File root, GarbageCollectableBlobStore blobStore, NodeStore nodeStore, int seed) throws Exception { this.root = root; this.nodeStore = nodeStore; this.blobStore = blobStore; if (SharedDataStoreUtils.isShared(blobStore)) { repoId = ClusterRepositoryInfo.getOrCreateId(nodeStore); ((SharedDataStore) blobStore).addMetadataRecord( new ByteArrayInputStream(new byte[0]), REPOSITORY.getNameFromId(repoId)); } referenceRetriever = ((MemoryBlobStoreNodeStore) nodeStore).getBlobReferenceRetriever(); startReferenceTime = clock.getTime(); log.info("Reference time {}", startReferenceTime); scheduledExecutor = Executors.newSingleThreadScheduledExecutor(); executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(10); statsProvider = new DefaultStatisticsProvider(scheduledExecutor); blobStoreState = setUp(nodeStore, blobStore, 10, 5, 100, seed); }
@Test public void testBackendDeleteMetadataRecord() throws DataStoreException { SharedDataStore fds = dataStore; fds.addMetadataRecord(randomStream(0, 10), "name"); for (String name : Lists.newArrayList("", null)) { if (Strings.isNullOrEmpty(name)) { try { fds.deleteMetadataRecord(name); } catch (IllegalArgumentException e) { } } else { fds.deleteMetadataRecord(name); fail(); } } assertTrue(fds.deleteMetadataRecord("name")); }
@Test public void testBackendMetadataRecordExists() throws DataStoreException { SharedDataStore fds = dataStore; fds.addMetadataRecord(randomStream(0, 10), "name"); for (String name : Lists.newArrayList("invalid", "", null)) { if (Strings.isNullOrEmpty(name)) { try { fds.metadataRecordExists(name); } catch (IllegalArgumentException e) { } } else { assertFalse(fds.metadataRecordExists(name)); } } assertTrue(fds.metadataRecordExists("name")); } }
@Test public void testBackendGetMetadataRecordInvalidName() throws DataStoreException { SharedDataStore fds = dataStore; fds.addMetadataRecord(randomStream(0, 10), "testRecord"); assertNull(fds.getMetadataRecord("invalid")); for (String name : Lists.newArrayList("", null)) { try { fds.getMetadataRecord(name); fail("Expect to throw"); } catch(Exception e) {} } fds.deleteMetadataRecord("testRecord"); }
private MarkSweepGarbageCollector init(int blobGcMaxAgeInSecs, ThreadPoolExecutor executor, String root) throws Exception { DocumentNodeStore store = mk.getNodeStore(); String repoId = null; if (SharedDataStoreUtils.isShared(store.getBlobStore())) { repoId = ClusterRepositoryInfo.getOrCreateId(store); ((SharedDataStore) store.getBlobStore()).addMetadataRecord( new ByteArrayInputStream(new byte[0]), REPOSITORY.getNameFromId(repoId)); } if (Strings.isNullOrEmpty(root)) { root = folder.newFolder().getAbsolutePath(); } MarkSweepGarbageCollector gc = new MarkSweepGarbageCollector( new DocumentBlobReferenceRetriever(store), (GarbageCollectableBlobStore) store.getBlobStore(), executor, root, 5, blobGcMaxAgeInSecs, repoId); return gc; }
private MarkSweepGarbageCollector init(long blobGcMaxAgeInSecs, ThreadPoolExecutor executor, String root) throws Exception { String repoId = null; if (SharedDataStoreUtils.isShared(store.getBlobStore())) { repoId = ClusterRepositoryInfo.getOrCreateId(nodeStore); ((SharedDataStore) store.getBlobStore()).addMetadataRecord( new ByteArrayInputStream(new byte[0]), REPOSITORY.getNameFromId(repoId)); } MarkSweepGarbageCollector gc = new MarkSweepGarbageCollector(new SegmentBlobReferenceRetriever(store), (GarbageCollectableBlobStore) store.getBlobStore(), executor, root, 2048, blobGcMaxAgeInSecs, repoId); return gc; }