@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 onFailure(AsyncUploadResult result) { DataIdentifier identifier = result.getIdentifier(); File file = result.getFile(); String fileName = getFileName(identifier); if (result.getException() != null) { LOG.warn("Async Upload failed. Dataidentifer [ " + identifier + "], file [" + file.getAbsolutePath() + "]", result.getException()); } else { LOG.warn("Async Upload failed. Dataidentifer [ " + identifier
@Override public void onAbort(AsyncUploadResult result) { DataIdentifier identifier = result.getIdentifier(); File file = result.getFile(); String fileName = getFileName(identifier); try { // remove from failed upload map if any. uploadRetryMap.remove(identifier); asyncWriteCache.remove(fileName); LOG.info( "Async Upload Aborted. Dataidentifer [{}], file [{}] removed from AsyncCache.", identifier, file.getAbsolutePath()); } catch (IOException ie) { LOG.warn("Cannot remove pending file upload. Dataidentifer [ " + identifier + "], file [" + file.getAbsolutePath() + "]", ie); } }
private void write(final DataIdentifier identifier, final File file, final boolean async, final AsyncUploadCallback callback) throws DataStoreException { log("write " + identifier + " " + file.length()); byte[] buffer = new byte[(int) file.length()]; try { if (async && callback == null) { throw new IllegalArgumentException( "callback parameter cannot be null"); } DataInputStream din = new DataInputStream(new FileInputStream(file)); din.readFully(buffer); din.close(); data.put(identifier, buffer); timeMap.put(identifier, System.currentTimeMillis()); } catch (IOException e) { if (async) { callback.onAbort(new AsyncUploadResult(identifier, file)); } throw new DataStoreException(e); } if (async) { callback.onSuccess(new AsyncUploadResult(identifier, file)); } }
@Override public void onAbort(AsyncUploadResult result) { DataIdentifier identifier = result.getIdentifier(); File file = result.getFile(); String fileName = getFileName(identifier); try { // remove from failed upload map if any. uploadRetryMap.remove(identifier); asyncWriteCache.remove(fileName); LOG.info( "Async Upload Aborted. Dataidentifer [{}], file [{}] removed from AsyncCache.", identifier, file.getAbsolutePath()); } catch (IOException ie) { LOG.warn("Cannot remove pending file upload. Dataidentifer [ " + identifier + "], file [" + file.getAbsolutePath() + "]", ie); } }
@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 onFailure(AsyncUploadResult result) { DataIdentifier identifier = result.getIdentifier(); File file = result.getFile(); String fileName = getFileName(identifier); if (result.getException() != null) { LOG.warn("Async Upload failed. Dataidentifer [ " + identifier + "], file [" + file.getAbsolutePath() + "]", result.getException()); } else { LOG.warn("Async Upload failed. Dataidentifer [ " + identifier
@Override public void onAbort(AsyncUploadResult result) { DataIdentifier identifier = result.getIdentifier(); File file = result.getFile(); String fileName = getFileName(identifier); try { // remove from failed upload map if any. uploadRetryMap.remove(identifier); asyncWriteCache.remove(fileName); LOG.info( "Async Upload Aborted. Dataidentifer [{}], file [{}] removed from AsyncCache.", identifier, file.getAbsolutePath()); } catch (IOException ie) { LOG.warn("Cannot remove pending file upload. Dataidentifer [ " + identifier + "], file [" + file.getAbsolutePath() + "]", ie); } }
@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 onFailure(AsyncUploadResult result) { DataIdentifier identifier = result.getIdentifier(); File file = result.getFile(); String fileName = getFileName(identifier); if (result.getException() != null) { LOG.warn("Async Upload failed. Dataidentifer [ " + identifier + "], file [" + file.getAbsolutePath() + "]", result.getException()); } else { LOG.warn("Async Upload failed. Dataidentifer [ " + identifier
@Override public void onSuccess(AsyncUploadResult result) { DataIdentifier identifier = result.getIdentifier(); File file = result.getFile(); String fileName = getFileName(identifier); try { LOG.debug("Upload completed for [{}]", identifier); // remove from failed upload map if any. uploadRetryMap.remove(identifier); AsyncUploadCacheResult cachedResult = asyncWriteCache.remove(fileName); if (cachedResult.doRequiresDelete()) { // added record already marked for delete deleteRecord(identifier); } else { // async upload took lot of time. // getRecord to touch if required. getRecord(identifier); } } catch (IOException ie) { LOG.warn("Cannot remove pending file upload. Dataidentifer [ " + identifier + "], file [" + file.getAbsolutePath() + "]", ie); } catch (DataStoreException dse) { LOG.warn("Cannot remove pending file upload. Dataidentifer [ " + identifier + "], file [" + file.getAbsolutePath() + "]", dse); } }
public void progressChanged(ProgressEvent progressEvent) { switch (progressEvent.getEventCode()) { case ProgressEvent.COMPLETED_EVENT_CODE: callback.onSuccess(new AsyncUploadResult(identifier, file)); break; case ProgressEvent.FAILED_EVENT_CODE: AsyncUploadResult result = new AsyncUploadResult( identifier, file); try { AmazonClientException e = upload.waitForException(); if (e != null) { result.setException(e); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } callback.onFailure(result); break; default: break; } } }
@Override public void onSuccess(AsyncUploadResult result) { DataIdentifier identifier = result.getIdentifier(); File file = result.getFile(); String fileName = getFileName(identifier); try { LOG.debug("Upload completed for [{}]", identifier); // remove from failed upload map if any. uploadRetryMap.remove(identifier); AsyncUploadCacheResult cachedResult = asyncWriteCache.remove(fileName); if (cachedResult.doRequiresDelete()) { // added record already marked for delete deleteRecord(identifier); } else { // async upload took lot of time. // getRecord to touch if required. getRecord(identifier); } } catch (IOException ie) { LOG.warn("Cannot remove pending file upload. Dataidentifer [ " + identifier + "], file [" + file.getAbsolutePath() + "]", ie); } catch (DataStoreException dse) { LOG.warn("Cannot remove pending file upload. Dataidentifer [ " + identifier + "], file [" + file.getAbsolutePath() + "]", dse); } }
public void progressChanged(ProgressEvent progressEvent) { switch (progressEvent.getEventCode()) { case ProgressEvent.COMPLETED_EVENT_CODE: callback.onSuccess(new AsyncUploadResult(identifier, file)); break; case ProgressEvent.FAILED_EVENT_CODE: AsyncUploadResult result = new AsyncUploadResult( identifier, file); try { AmazonClientException e = upload.waitForException(); if (e != null) { result.setException(e); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } callback.onFailure(result); break; default: break; } } }
@Override public void onSuccess(AsyncUploadResult result) { DataIdentifier identifier = result.getIdentifier(); File file = result.getFile(); String fileName = getFileName(identifier); try { LOG.debug("Upload completed for [{}]", identifier); // remove from failed upload map if any. uploadRetryMap.remove(identifier); AsyncUploadCacheResult cachedResult = asyncWriteCache.remove(fileName); if (cachedResult.doRequiresDelete()) { // added record already marked for delete deleteRecord(identifier); } else { // async upload took lot of time. // getRecord to touch if required. getRecord(identifier); } } catch (IOException ie) { LOG.warn("Cannot remove pending file upload. Dataidentifer [ " + identifier + "], file [" + file.getAbsolutePath() + "]", ie); } catch (DataStoreException dse) { LOG.warn("Cannot remove pending file upload. Dataidentifer [ " + identifier + "], file [" + file.getAbsolutePath() + "]", dse); } }
LOG.debug("lastModified of [{}] updated successfully.", identifier); if (callback != null) { callback.onSuccess(new AsyncUploadResult(identifier, file)); AsyncUploadResult asyncUpRes= new AsyncUploadResult(identifier, file); asyncUpRes.setException(e2); if (callback != null) { callback.onAbort(asyncUpRes); LOG.debug("synchronous upload to identifier [{}] completed.", identifier); if (callback != null) { callback.onSuccess(new AsyncUploadResult( identifier, file)); AsyncUploadResult asyncUpRes= new AsyncUploadResult(identifier, file); asyncUpRes.setException(e2); if (callback != null) { callback.onAbort(asyncUpRes);
LOG.debug("lastModified of [{}] updated successfully.", identifier); if (callback != null) { callback.onSuccess(new AsyncUploadResult(identifier, file)); AsyncUploadResult asyncUpRes= new AsyncUploadResult(identifier, file); asyncUpRes.setException(e2); if (callback != null) { callback.onAbort(asyncUpRes); LOG.debug("synchronous upload to identifier [{}] completed.", identifier); if (callback != null) { callback.onSuccess(new AsyncUploadResult( identifier, file)); AsyncUploadResult asyncUpRes= new AsyncUploadResult(identifier, file); asyncUpRes.setException(e2); if (callback != null) { callback.onAbort(asyncUpRes);
asyncUpRes = new AsyncUploadResult(identifier, file); asyncUpRes.setException(e2); callback.onFailure(asyncUpRes);