checkDataIntegrity

git-svn-id: svn://home0/checkDataIntegrity@3075 71dcc7fd-b1f2-4e5d-bb8e-274146e81173
This commit is contained in:
(no author)
2023-05-31 19:22:38 +00:00
parent 2490594a27
commit 99d9a8e412
3 changed files with 29 additions and 27 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -81,38 +81,40 @@ public class Main {
.stream() .stream()
.parallel() .parallel()
.forEach(p0 -> { .forEach(p0 -> {
final long cnt = count.incrementAndGet(); try {
if (cnt % 1000 == 0) { final long cnt = count.incrementAndGet();
System.out.println(cnt); if (cnt % 1000 == 0) {
} System.out.println(cnt);
}
final String rel = p0.toString().substring(path0.length());
final Path p1 = Path.of(path1 + rel); final String rel = p0.toString().substring(path0.length());
final Path p1 = Path.of(path1 + rel);
final byte[] buf0 = bufs0.get();
final byte[] buf1 = bufs1.get(); final byte[] buf0 = bufs0.get();
try (InputStream inputStream0 = new BufferedInputStream(new FileInputStream(p0.toFile()), 65536); InputStream inputStream1 = new BufferedInputStream(new FileInputStream(p1.toFile()), 65536)) { final byte[] buf1 = bufs1.get();
int len0, len1; try (InputStream inputStream0 = new BufferedInputStream(new FileInputStream(p0.toFile()), 65536); InputStream inputStream1 = new BufferedInputStream(new FileInputStream(p1.toFile()), 65536)) {
do { int len0, len1;
len0 = inputStream0.read(buf0); do {
len1 = inputStream1.read(buf1); len0 = inputStream0.read(buf0);
if (len0 != len1) { len1 = inputStream1.read(buf1);
System.out.println(rel + ": Length mismatch"); if (len0 != len1) {
countErr.incrementAndGet(); System.out.println(rel + ": Length mismatch");
break; countErr.incrementAndGet();
} break;
if (len0 > -1 && !Arrays.equals(buf0, 0, len0, buf1, 0, len1)) { }
System.out.println(rel + ": Data mismatch"); if (len0 > -1 && !Arrays.equals(buf0, 0, len0, buf1, 0, len1)) {
countErr.incrementAndGet(); System.out.println(rel + ": Data mismatch");
break; countErr.incrementAndGet();
} break;
} while (len0 > -1); }
} while (len0 > -1);
}
} }
catch (NoSuchFileException | FileNotFoundException | InvalidPathException ex) { catch (NoSuchFileException | FileNotFoundException | InvalidPathException ex) {
// System.out.println(rel + ": NoSuchFileException"); // System.out.println(rel + ": NoSuchFileException");
} }
catch (final Exception ex) { catch (final Exception ex) {
System.out.println(rel + ": Exception: " + ex.getClass().getName() + " " + ex.getMessage()); System.out.println(p0 + ": Exception: " + ex.getClass().getName() + " " + ex.getMessage());
countErr.incrementAndGet(); countErr.incrementAndGet();
} }
}); });