Index: jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/CachingDataStore.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/CachingDataStore.java (revision 1760712) +++ jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/CachingDataStore.java (revision ) @@ -196,6 +196,12 @@ private int uploadRetries = 3; /** + * The number of upload failures before it aborts migration + */ + + private int migrateFailuresCount = 40; + + /** * The local file system cache. */ private LocalCache cache; @@ -1221,6 +1227,10 @@ this.recLengthCacheSize = recLengthCacheSize; } + public void setMigrateFailuresCount(int migrateFailuresCount) { + this.migrateFailuresCount = migrateFailuresCount; + } + public Backend getBackend() { return backend; } @@ -1239,6 +1249,8 @@ volatile AtomicBoolean exceptionRaised = new AtomicBoolean(); + volatile AtomicInteger currFailCount = new AtomicInteger(); + DataStoreException exception; final int threads; @@ -1263,6 +1275,7 @@ } synchronized void setException(DataStoreException exception) { + currFailCount.incrementAndGet(); exceptionRaised.getAndSet(true); this.exception = exception; } @@ -1272,9 +1285,9 @@ } void logProgress() { - LOG.info("Uploaded: [{}/{}] files, [{}/{}] size data", + LOG.info("Uploaded: [{}/{}] files, [{}/{}] size data, failed files [{}]", new Object[] { currentCount, files.size(), currentSize, - totalSize }); + totalSize, currFailCount }); } void upload() throws DataStoreException { @@ -1306,7 +1319,7 @@ try { // Wait until all threads are finish - while (!isExceptionRaised() + while ((!isExceptionRaised() || currFailCount.get() < migrateFailuresCount) && !executor.awaitTermination(15, TimeUnit.SECONDS)) { logProgress(); } @@ -1315,7 +1328,7 @@ } long endTime = System.currentTimeMillis(); LOG.info( - "Uploaded: [{}/{}] files, [{}/{}] size data, time taken = [{}] sec", + "Uploaded: [{}/{}] files, [{}/{}] size data, time taken = [{}] sec, failureCount = [{}]", new Object[] { currentCount, files.size(), currentSize, totalSize, ((endTime - startTime) / 1000) }); if (isExceptionRaised()) { @@ -1361,10 +1374,6 @@ long uploadSize = 0; try { for (File f : files) { - - if (filesUploader.isExceptionRaised()) { - break; - } String name = f.getName(); LOG.debug("upload file [{}] ",name); if (!name.startsWith(TMP) && !name.endsWith(DS_STORE) @@ -1387,9 +1396,9 @@ filesUploader.addCurrentCount(uploadCount); filesUploader.addCurrentSize(uploadSize); } catch (DataStoreException e) { - if (!filesUploader.isExceptionRaised()) { - filesUploader.setException(e); + filesUploader.setException(e); - } + LOG.warn("failed to upload file to backend", e.getMessage()); + LOG.debug("failed to upload file to backend", e); } }