BlobId(DataRecord dr) { this.blobId = dr.getIdentifier().toString(); long len; try { len = dr.getLength(); } catch (DataStoreException e) { //Cannot determine length len = -1; } this.length = len; }
/** * Derive file name from identifier. */ private static String getFileName(DataIdentifier identifier) { String name = identifier.toString(); return getFileName(name); }
/** * Checks if the given object is a data record with the same identifier * as this one. * * @param object other object * @return <code>true</code> if the other object is a data record and has * the same identifier as this one, <code>false</code> otherwise */ public boolean equals(Object object) { return (object instanceof DataRecord) && identifier.equals(((DataRecord) object).getIdentifier()); }
public void testFile() throws Exception { FileDataStore store = new FileDataStore(); store.setPath(TEST_DIR + "/fs"); store.init(TEST_DIR + "/fs"); store.setMinRecordLength(0); doTest(store); }
@Override public void run() { try { write(identifier, src); callback.onSuccess(new AsyncUploadResult(identifier, src)); } catch (DataStoreException dse) { AsyncUploadResult res = new AsyncUploadResult(identifier, src); res.setException(dse); callback.onFailure(res); } } });
@Override public void run() { try { touch(identifier, minModifiedDate); callback.onSuccess(new AsyncTouchResult(identifier)); } catch (DataStoreException e) { AsyncTouchResult result = new AsyncTouchResult( identifier); result.setException(e); callback.onFailure(result); } } });
public void deleteFromCache(DataIdentifier identifier) throws DataStoreException { try { // order is important here recLenCache.remove(identifier); String fileName = getFileName(identifier); asyncWriteCache.delete(fileName); cache.delete(fileName); } catch (IOException ioe) { throw new DataStoreException(ioe); } }
public DataRecord getRecord(DataIdentifier identifier) throws DataStoreException { DataRecord record = getRecordIfStored(identifier); if (record != null) { return record; } else { throw new DataStoreException( "Record " + identifier + " does not exist"); } }
/** * 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(); }
/** * Return the inputstream from from cache, or null if not in the cache. * * @param fileName name of file. * @return stream or null. */ public InputStream getIfStored(String fileName) throws IOException { File file = getFileIfStored(fileName); return file == null ? null : new LazyFileInputStream(file); }
BlobId(DataRecord dr) { this.blobId = dr.getIdentifier().toString(); long len; try { len = dr.getLength(); } catch (DataStoreException e) { //Cannot determine length len = -1; } this.length = len; }
/** * Checks if the given object is a data record with the same identifier * as this one. * * @param object other object * @return <code>true</code> if the other object is a data record and has * the same identifier as this one, <code>false</code> otherwise */ public boolean equals(Object object) { return (object instanceof DataRecord) && identifier.equals(((DataRecord) object).getIdentifier()); }
@Override public void run() { try { write(identifier, src); callback.onSuccess(new AsyncUploadResult(identifier, src)); } catch (DataStoreException dse) { AsyncUploadResult res = new AsyncUploadResult(identifier, src); res.setException(dse); callback.onFailure(res); } } });
/** * Derive file name from identifier. */ private static String getFileName(DataIdentifier identifier) { String name = identifier.toString(); return getFileName(name); }
public DataRecord getRecord(DataIdentifier identifier) throws DataStoreException { DataRecord record = getRecordIfStored(identifier); if (record != null) { return record; } else { throw new DataStoreException( "Record " + identifier + " does not exist"); } }
/** * Method to validate mixed scenario use of {@link DataStore}. */ protected void doTestSingleThread() throws Exception { ds = createDataStore(); doTestMultiThreaded(ds, 1); ds.close(); }
/** * Return the inputstream from from cache, or null if not in the cache. * * @param fileName name of file. * @return stream or null. */ public InputStream getIfStored(String fileName) throws IOException { File file = getFileIfStored(fileName); return file == null ? null : new LazyFileInputStream(file); }
/** * Checks if the given object is a data record with the same identifier * as this one. * * @param object other object * @return <code>true</code> if the other object is a data record and has * the same identifier as this one, <code>false</code> otherwise */ public boolean equals(Object object) { return (object instanceof DataRecord) && identifier.equals(((DataRecord) object).getIdentifier()); }
public DataRecord getRecord(DataIdentifier identifier) throws DataStoreException { DataRecord record = getRecordIfStored(identifier); if (record != null) { return record; } else { throw new DataStoreException( "Record " + identifier + " does not exist"); } }
/** * Checks if the given object is a data record with the same identifier * as this one. * * @param object other object * @return <code>true</code> if the other object is a data record and has * the same identifier as this one, <code>false</code> otherwise */ public boolean equals(Object object) { return (object instanceof DataRecord) && identifier.equals(((DataRecord) object).getIdentifier()); }