@Override public void close() throws DataStoreException { delegate.close(); cache.invalidateAll(); closeQuietly(tracker); }
@Override public void close() throws DataStoreException { delegate.close(); cache.invalidateAll(); closeQuietly(tracker); }
@Override public void close() throws DataStoreException { delegate.close(); cache.invalidateAll(); closeQuietly(tracker); }
@Override public void close() throws DataStoreException { existingMappings.clear(); saveNewMappingsToFile(); if (delegate != null) { delegate.close(); } }
@Override public void close() throws DataStoreException { existingMappings.clear(); saveNewMappingsToFile(); if (delegate != null) { delegate.close(); } }
@After public void tearDown() { try { ds.close(); } catch (DataStoreException e) { LOG.info("Error in close ds", e); } }
/** * Method to validate mixed scenario use of {@link DataStore}. */ protected void doTestSingleThread() throws Exception { ds = createDataStore(); doTestMultiThreaded(ds, 1); ds.close(); }
/** * Method to validate mixed scenario use of {@link DataStore} in * multi-threaded concurrent environment. */ protected void doTestMultiThreaded() throws Exception { ds = createDataStore(); doTestMultiThreaded(ds, 4); ds.close(); }
/** * Test robustness of {@link AsyncUploadCache} corruption. */ public void testAsyncUploadCacheCorruption() { try { ds = createDataStore(); File pendingUploads = new File(dataStoreDir + "/" + PENDIND_UPLOAD_FILE); FileOutputStream fos = new FileOutputStream(pendingUploads); IOUtils.write("garbage-data", fos); fos.close(); File tobeDeletedFile = new File(dataStoreDir + "/" + TO_BE_DELETED_UPLOAD_FILE); fos = new FileOutputStream(tobeDeletedFile); IOUtils.write("garbage-data", fos); fos.close(); ds.close(); doAddRecordTest(); } catch (Exception e) { LOG.error("error:", e); fail(e.getMessage()); } } }
@Override public void dispose(DataStore dataStore) { if (dataStore == null) { return; } try { dataStore.close(); } catch (DataStoreException e) { log.warn("Issue while disposing DataStore", e); } CloudBlobContainer container = containers.get(dataStore); if (container != null) { log.info("Removing Azure test blob container {}", container.getName()); try { // For Azure, you can just delete the container and all // blobs it in will also be deleted container.delete(); } catch (StorageException e) { log.warn("Unable to delete Azure Blob container {}", container.getName()); } containers.remove(dataStore); } } }
/** * Test if record can be accessed via * {@link DataStore#getRecordFromReference(String)} */ protected void doReferenceTest() throws Exception { ds = createDataStore(); byte[] data = new byte[dataLength]; randomGen.nextBytes(data); String reference; DataRecord record = ds.addRecord(new ByteArrayInputStream(data)); reference = record.getReference(); assertReference(data, reference, ds); ds.close(); }
/** * Test {@link DataStore#addRecord(InputStream)} and assert length of added * record. */ protected void doAddRecordTest() throws Exception { ds = createDataStore(); byte[] data = new byte[dataLength]; randomGen.nextBytes(data); DataRecord rec = ds.addRecord(new ByteArrayInputStream(data)); assertEquals(data.length, rec.getLength()); assertRecord(data, rec); ds.close(); }
/** * Test {@link DataStore#getAllIdentifiers()} and asserts all identifiers * are returned. */ protected void doGetAllIdentifiersTest() throws Exception { ds = createDataStore(); List<DataIdentifier> list = new ArrayList<DataIdentifier>(); Random random = randomGen; byte[] data = new byte[dataLength]; random.nextBytes(data); DataRecord rec = ds.addRecord(new ByteArrayInputStream(data)); list.add(rec.getIdentifier()); data = new byte[dataLength]; random.nextBytes(data); rec = ds.addRecord(new ByteArrayInputStream(data)); list.add(rec.getIdentifier()); data = new byte[dataLength]; random.nextBytes(data); rec = ds.addRecord(new ByteArrayInputStream(data)); list.add(rec.getIdentifier()); Iterator<DataIdentifier> itr = ds.getAllIdentifiers(); while (itr.hasNext()) { assertTrue("record found on list", list.remove(itr.next())); } assertEquals(0, list.size()); ds.close(); }
void doTest(DataStore store) throws Exception { this.store = store; Random r = new Random(); concurrentGcLoopStart(); int len = 100; if (getTestScale() > 1) { len = 1000; } for (int i = 0; i < len && gcException == null; i++) { LOG.info("test " + i); byte[] data = new byte[3]; r.nextBytes(data); DataRecord rec = store.addRecord(new ByteArrayInputStream(data)); LOG.debug(" added " + rec.getIdentifier()); if (r.nextBoolean()) { LOG.debug(" added " + rec.getIdentifier() + " -> keep reference"); ids.add(rec.getIdentifier()); store.getRecord(rec.getIdentifier()); } if (r.nextInt(100) == 0) { LOG.debug("clear i: " + i); ids.clear(); } } concurrentGcLoopStop(); store.close(); }
/** * Test {@link DataStore#getRecord(DataIdentifier)} and assert length and * inputstream. */ protected void doGetRecordTest() throws Exception { ds = createDataStore(); byte[] data = new byte[dataLength]; randomGen.nextBytes(data); DataRecord rec = ds.addRecord(new ByteArrayInputStream(data)); rec = ds.getRecord(rec.getIdentifier()); assertEquals(data.length, rec.getLength()); assertRecord(data, rec); ds.close(); }
/** * Test {@link MultiDataStoreAware#deleteRecord(DataIdentifier)}. */ protected void doDeleteRecordTest() throws Exception { ds = createDataStore(); Random random = randomGen; byte[] data1 = new byte[dataLength]; random.nextBytes(data1); DataRecord rec1 = ds.addRecord(new ByteArrayInputStream(data1)); byte[] data2 = new byte[dataLength]; random.nextBytes(data2); DataRecord rec2 = ds.addRecord(new ByteArrayInputStream(data2)); byte[] data3 = new byte[dataLength]; random.nextBytes(data3); DataRecord rec3 = ds.addRecord(new ByteArrayInputStream(data3)); ((MultiDataStoreAware)ds).deleteRecord(rec2.getIdentifier()); assertNull("rec2 should be null", ds.getRecordIfStored(rec2.getIdentifier())); assertEquals(new ByteArrayInputStream(data1), ds.getRecord(rec1.getIdentifier()).getStream()); assertEquals(new ByteArrayInputStream(data3), ds.getRecord(rec3.getIdentifier()).getStream()); ds.close(); }
assertEquals("rec3 touched", true, rec3.getLastModified() > updateTime); assertEquals("rec4 touched", true, rec4.getLastModified() > updateTime); ds.close();
if (dataStore != null && dataStore instanceof S3DataStore) { try { dataStore.close(); } catch (DataStoreException e) { log.warn("Issue while disposing DataStore", e);