target
stringlengths
20
113k
src_fm
stringlengths
11
86.3k
src_fm_fc
stringlengths
21
86.4k
src_fm_fc_co
stringlengths
30
86.4k
src_fm_fc_ms
stringlengths
42
86.8k
src_fm_fc_ms_ff
stringlengths
43
86.8k
@Test public void testMarkAsNoFilterExists() throws Exception { List<Path> files = createTempTestFiles(1); Path file = files.get(0); when(imageRepository.getByPath(file)).thenReturn(new ImageRecord(file.toString(), TEST_HASH)); dupOp.markAs(file, TAG_FOO); verify(filterRepository).store(fooFilter); }
public void markAs(Result result, Tag tag) { try { markAs(result.getImageRecord(), tag); } catch (RepositoryException e) { logger.warn(FILTER_ADD_FAILED_MESSAGE, result.getImageRecord().getPath(), e.getMessage()); } }
DuplicateOperations { public void markAs(Result result, Tag tag) { try { markAs(result.getImageRecord(), tag); } catch (RepositoryException e) { logger.warn(FILTER_ADD_FAILED_MESSAGE, result.getImageRecord().getPath(), e.getMessage()); } } }
DuplicateOperations { public void markAs(Result result, Tag tag) { try { markAs(result.getImageRecord(), tag); } catch (RepositoryException e) { logger.warn(FILTER_ADD_FAILED_MESSAGE, result.getImageRecord().getPath(), e.getMessage()); } } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); }
DuplicateOperations { public void markAs(Result result, Tag tag) { try { markAs(result.getImageRecord(), tag); } catch (RepositoryException e) { logger.warn(FILTER_ADD_FAILED_MESSAGE, result.getImageRecord().getPath(), e.getMessage()); } } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); void moveToDnw(Path path); void deleteAll(Collection<Result> records); void remove(Collection<ImageRecord> records); void deleteFile(Result result); void deleteFile(Path path); void markAll(Collection<Result> records, Tag tag); void markDnwAndDelete(Collection<Result> records); void markAs(Result result, Tag tag); void markAs(Path path, Tag tag); void markAs(ImageRecord image, Tag tag); void markDirectoryAs(Path directory, Tag tag); void markDirectoryAndChildrenAs(Path rootDirectory, Tag tag); List<ImageRecord> findMissingFiles(Path directory); void ignore(Result result); List<Tag> getFilterTags(); }
DuplicateOperations { public void markAs(Result result, Tag tag) { try { markAs(result.getImageRecord(), tag); } catch (RepositoryException e) { logger.warn(FILTER_ADD_FAILED_MESSAGE, result.getImageRecord().getPath(), e.getMessage()); } } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); void moveToDnw(Path path); void deleteAll(Collection<Result> records); void remove(Collection<ImageRecord> records); void deleteFile(Result result); void deleteFile(Path path); void markAll(Collection<Result> records, Tag tag); void markDnwAndDelete(Collection<Result> records); void markAs(Result result, Tag tag); void markAs(Path path, Tag tag); void markAs(ImageRecord image, Tag tag); void markDirectoryAs(Path directory, Tag tag); void markDirectoryAndChildrenAs(Path rootDirectory, Tag tag); List<ImageRecord> findMissingFiles(Path directory); void ignore(Result result); List<Tag> getFilterTags(); }
@Test public void testMarkAsDBerror() throws Exception { List<Path> files = createTempTestFiles(1); Path file = files.get(0); when(imageRepository.getByPath(file)).thenThrow(new RepositoryException("This is a test")); dupOp.markAs(file, TAG_FOO); verify(filterRepository, never()).store(any(FilterRecord.class)); }
public void markAs(Result result, Tag tag) { try { markAs(result.getImageRecord(), tag); } catch (RepositoryException e) { logger.warn(FILTER_ADD_FAILED_MESSAGE, result.getImageRecord().getPath(), e.getMessage()); } }
DuplicateOperations { public void markAs(Result result, Tag tag) { try { markAs(result.getImageRecord(), tag); } catch (RepositoryException e) { logger.warn(FILTER_ADD_FAILED_MESSAGE, result.getImageRecord().getPath(), e.getMessage()); } } }
DuplicateOperations { public void markAs(Result result, Tag tag) { try { markAs(result.getImageRecord(), tag); } catch (RepositoryException e) { logger.warn(FILTER_ADD_FAILED_MESSAGE, result.getImageRecord().getPath(), e.getMessage()); } } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); }
DuplicateOperations { public void markAs(Result result, Tag tag) { try { markAs(result.getImageRecord(), tag); } catch (RepositoryException e) { logger.warn(FILTER_ADD_FAILED_MESSAGE, result.getImageRecord().getPath(), e.getMessage()); } } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); void moveToDnw(Path path); void deleteAll(Collection<Result> records); void remove(Collection<ImageRecord> records); void deleteFile(Result result); void deleteFile(Path path); void markAll(Collection<Result> records, Tag tag); void markDnwAndDelete(Collection<Result> records); void markAs(Result result, Tag tag); void markAs(Path path, Tag tag); void markAs(ImageRecord image, Tag tag); void markDirectoryAs(Path directory, Tag tag); void markDirectoryAndChildrenAs(Path rootDirectory, Tag tag); List<ImageRecord> findMissingFiles(Path directory); void ignore(Result result); List<Tag> getFilterTags(); }
DuplicateOperations { public void markAs(Result result, Tag tag) { try { markAs(result.getImageRecord(), tag); } catch (RepositoryException e) { logger.warn(FILTER_ADD_FAILED_MESSAGE, result.getImageRecord().getPath(), e.getMessage()); } } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); void moveToDnw(Path path); void deleteAll(Collection<Result> records); void remove(Collection<ImageRecord> records); void deleteFile(Result result); void deleteFile(Path path); void markAll(Collection<Result> records, Tag tag); void markDnwAndDelete(Collection<Result> records); void markAs(Result result, Tag tag); void markAs(Path path, Tag tag); void markAs(ImageRecord image, Tag tag); void markDirectoryAs(Path directory, Tag tag); void markDirectoryAndChildrenAs(Path rootDirectory, Tag tag); List<ImageRecord> findMissingFiles(Path directory); void ignore(Result result); List<Tag> getFilterTags(); }
@Test public void testMarkAsFilterExists() throws Exception { List<Path> files = createTempTestFiles(1); Path file = files.get(0); when(imageRepository.getByPath(file)).thenReturn(new ImageRecord(file.toString(), 42)); dupOp.markAs(file, TAG_FOO); verify(filterRepository).store(new FilterRecord(42, TAG_FOO)); }
public void markAs(Result result, Tag tag) { try { markAs(result.getImageRecord(), tag); } catch (RepositoryException e) { logger.warn(FILTER_ADD_FAILED_MESSAGE, result.getImageRecord().getPath(), e.getMessage()); } }
DuplicateOperations { public void markAs(Result result, Tag tag) { try { markAs(result.getImageRecord(), tag); } catch (RepositoryException e) { logger.warn(FILTER_ADD_FAILED_MESSAGE, result.getImageRecord().getPath(), e.getMessage()); } } }
DuplicateOperations { public void markAs(Result result, Tag tag) { try { markAs(result.getImageRecord(), tag); } catch (RepositoryException e) { logger.warn(FILTER_ADD_FAILED_MESSAGE, result.getImageRecord().getPath(), e.getMessage()); } } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); }
DuplicateOperations { public void markAs(Result result, Tag tag) { try { markAs(result.getImageRecord(), tag); } catch (RepositoryException e) { logger.warn(FILTER_ADD_FAILED_MESSAGE, result.getImageRecord().getPath(), e.getMessage()); } } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); void moveToDnw(Path path); void deleteAll(Collection<Result> records); void remove(Collection<ImageRecord> records); void deleteFile(Result result); void deleteFile(Path path); void markAll(Collection<Result> records, Tag tag); void markDnwAndDelete(Collection<Result> records); void markAs(Result result, Tag tag); void markAs(Path path, Tag tag); void markAs(ImageRecord image, Tag tag); void markDirectoryAs(Path directory, Tag tag); void markDirectoryAndChildrenAs(Path rootDirectory, Tag tag); List<ImageRecord> findMissingFiles(Path directory); void ignore(Result result); List<Tag> getFilterTags(); }
DuplicateOperations { public void markAs(Result result, Tag tag) { try { markAs(result.getImageRecord(), tag); } catch (RepositoryException e) { logger.warn(FILTER_ADD_FAILED_MESSAGE, result.getImageRecord().getPath(), e.getMessage()); } } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); void moveToDnw(Path path); void deleteAll(Collection<Result> records); void remove(Collection<ImageRecord> records); void deleteFile(Result result); void deleteFile(Path path); void markAll(Collection<Result> records, Tag tag); void markDnwAndDelete(Collection<Result> records); void markAs(Result result, Tag tag); void markAs(Path path, Tag tag); void markAs(ImageRecord image, Tag tag); void markDirectoryAs(Path directory, Tag tag); void markDirectoryAndChildrenAs(Path rootDirectory, Tag tag); List<ImageRecord> findMissingFiles(Path directory); void ignore(Result result); List<Tag> getFilterTags(); }
@Test public void testMarkDirectory() throws Exception { createTempTestFiles(3); dupOp.markDirectoryAs(tempDirectory, TAG_FOO); verify(imageRepository, times(3)).getByPath(any(Path.class)); verify(filterRepository, never()).store(any(FilterRecord.class)); }
public void markDirectoryAs(Path directory, Tag tag) { if (!isDirectory(directory)) { logger.warn("Directory {} not valid, aborting.", directory); return; } try { int addCount = 0; Iterator<Path> iter = Files.newDirectoryStream(directory).iterator(); while (iter.hasNext()) { Path current = iter.next(); if (Files.isRegularFile(current)) { markAs(current, tag); addCount++; } } logger.info("Added {} images from {} to filter list", addCount, directory); } catch (IOException e) { logger.error("Failed to add images to filter list, {}", e); } }
DuplicateOperations { public void markDirectoryAs(Path directory, Tag tag) { if (!isDirectory(directory)) { logger.warn("Directory {} not valid, aborting.", directory); return; } try { int addCount = 0; Iterator<Path> iter = Files.newDirectoryStream(directory).iterator(); while (iter.hasNext()) { Path current = iter.next(); if (Files.isRegularFile(current)) { markAs(current, tag); addCount++; } } logger.info("Added {} images from {} to filter list", addCount, directory); } catch (IOException e) { logger.error("Failed to add images to filter list, {}", e); } } }
DuplicateOperations { public void markDirectoryAs(Path directory, Tag tag) { if (!isDirectory(directory)) { logger.warn("Directory {} not valid, aborting.", directory); return; } try { int addCount = 0; Iterator<Path> iter = Files.newDirectoryStream(directory).iterator(); while (iter.hasNext()) { Path current = iter.next(); if (Files.isRegularFile(current)) { markAs(current, tag); addCount++; } } logger.info("Added {} images from {} to filter list", addCount, directory); } catch (IOException e) { logger.error("Failed to add images to filter list, {}", e); } } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); }
DuplicateOperations { public void markDirectoryAs(Path directory, Tag tag) { if (!isDirectory(directory)) { logger.warn("Directory {} not valid, aborting.", directory); return; } try { int addCount = 0; Iterator<Path> iter = Files.newDirectoryStream(directory).iterator(); while (iter.hasNext()) { Path current = iter.next(); if (Files.isRegularFile(current)) { markAs(current, tag); addCount++; } } logger.info("Added {} images from {} to filter list", addCount, directory); } catch (IOException e) { logger.error("Failed to add images to filter list, {}", e); } } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); void moveToDnw(Path path); void deleteAll(Collection<Result> records); void remove(Collection<ImageRecord> records); void deleteFile(Result result); void deleteFile(Path path); void markAll(Collection<Result> records, Tag tag); void markDnwAndDelete(Collection<Result> records); void markAs(Result result, Tag tag); void markAs(Path path, Tag tag); void markAs(ImageRecord image, Tag tag); void markDirectoryAs(Path directory, Tag tag); void markDirectoryAndChildrenAs(Path rootDirectory, Tag tag); List<ImageRecord> findMissingFiles(Path directory); void ignore(Result result); List<Tag> getFilterTags(); }
DuplicateOperations { public void markDirectoryAs(Path directory, Tag tag) { if (!isDirectory(directory)) { logger.warn("Directory {} not valid, aborting.", directory); return; } try { int addCount = 0; Iterator<Path> iter = Files.newDirectoryStream(directory).iterator(); while (iter.hasNext()) { Path current = iter.next(); if (Files.isRegularFile(current)) { markAs(current, tag); addCount++; } } logger.info("Added {} images from {} to filter list", addCount, directory); } catch (IOException e) { logger.error("Failed to add images to filter list, {}", e); } } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); void moveToDnw(Path path); void deleteAll(Collection<Result> records); void remove(Collection<ImageRecord> records); void deleteFile(Result result); void deleteFile(Path path); void markAll(Collection<Result> records, Tag tag); void markDnwAndDelete(Collection<Result> records); void markAs(Result result, Tag tag); void markAs(Path path, Tag tag); void markAs(ImageRecord image, Tag tag); void markDirectoryAs(Path directory, Tag tag); void markDirectoryAndChildrenAs(Path rootDirectory, Tag tag); List<ImageRecord> findMissingFiles(Path directory); void ignore(Result result); List<Tag> getFilterTags(); }
@Test public void testMarkDirectoryNotAdirectory() throws Exception { List<Path> files = createTempTestFiles(3); Path file = files.get(0); dupOp.markDirectoryAs(file, TAG_FOO); verify(imageRepository, never()).getByPath(any(Path.class)); verify(filterRepository, never()).store(any(FilterRecord.class)); }
public void markDirectoryAs(Path directory, Tag tag) { if (!isDirectory(directory)) { logger.warn("Directory {} not valid, aborting.", directory); return; } try { int addCount = 0; Iterator<Path> iter = Files.newDirectoryStream(directory).iterator(); while (iter.hasNext()) { Path current = iter.next(); if (Files.isRegularFile(current)) { markAs(current, tag); addCount++; } } logger.info("Added {} images from {} to filter list", addCount, directory); } catch (IOException e) { logger.error("Failed to add images to filter list, {}", e); } }
DuplicateOperations { public void markDirectoryAs(Path directory, Tag tag) { if (!isDirectory(directory)) { logger.warn("Directory {} not valid, aborting.", directory); return; } try { int addCount = 0; Iterator<Path> iter = Files.newDirectoryStream(directory).iterator(); while (iter.hasNext()) { Path current = iter.next(); if (Files.isRegularFile(current)) { markAs(current, tag); addCount++; } } logger.info("Added {} images from {} to filter list", addCount, directory); } catch (IOException e) { logger.error("Failed to add images to filter list, {}", e); } } }
DuplicateOperations { public void markDirectoryAs(Path directory, Tag tag) { if (!isDirectory(directory)) { logger.warn("Directory {} not valid, aborting.", directory); return; } try { int addCount = 0; Iterator<Path> iter = Files.newDirectoryStream(directory).iterator(); while (iter.hasNext()) { Path current = iter.next(); if (Files.isRegularFile(current)) { markAs(current, tag); addCount++; } } logger.info("Added {} images from {} to filter list", addCount, directory); } catch (IOException e) { logger.error("Failed to add images to filter list, {}", e); } } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); }
DuplicateOperations { public void markDirectoryAs(Path directory, Tag tag) { if (!isDirectory(directory)) { logger.warn("Directory {} not valid, aborting.", directory); return; } try { int addCount = 0; Iterator<Path> iter = Files.newDirectoryStream(directory).iterator(); while (iter.hasNext()) { Path current = iter.next(); if (Files.isRegularFile(current)) { markAs(current, tag); addCount++; } } logger.info("Added {} images from {} to filter list", addCount, directory); } catch (IOException e) { logger.error("Failed to add images to filter list, {}", e); } } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); void moveToDnw(Path path); void deleteAll(Collection<Result> records); void remove(Collection<ImageRecord> records); void deleteFile(Result result); void deleteFile(Path path); void markAll(Collection<Result> records, Tag tag); void markDnwAndDelete(Collection<Result> records); void markAs(Result result, Tag tag); void markAs(Path path, Tag tag); void markAs(ImageRecord image, Tag tag); void markDirectoryAs(Path directory, Tag tag); void markDirectoryAndChildrenAs(Path rootDirectory, Tag tag); List<ImageRecord> findMissingFiles(Path directory); void ignore(Result result); List<Tag> getFilterTags(); }
DuplicateOperations { public void markDirectoryAs(Path directory, Tag tag) { if (!isDirectory(directory)) { logger.warn("Directory {} not valid, aborting.", directory); return; } try { int addCount = 0; Iterator<Path> iter = Files.newDirectoryStream(directory).iterator(); while (iter.hasNext()) { Path current = iter.next(); if (Files.isRegularFile(current)) { markAs(current, tag); addCount++; } } logger.info("Added {} images from {} to filter list", addCount, directory); } catch (IOException e) { logger.error("Failed to add images to filter list, {}", e); } } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); void moveToDnw(Path path); void deleteAll(Collection<Result> records); void remove(Collection<ImageRecord> records); void deleteFile(Result result); void deleteFile(Path path); void markAll(Collection<Result> records, Tag tag); void markDnwAndDelete(Collection<Result> records); void markAs(Result result, Tag tag); void markAs(Path path, Tag tag); void markAs(ImageRecord image, Tag tag); void markDirectoryAs(Path directory, Tag tag); void markDirectoryAndChildrenAs(Path rootDirectory, Tag tag); List<ImageRecord> findMissingFiles(Path directory); void ignore(Result result); List<Tag> getFilterTags(); }
@Test public void testMarkDirectoryDirectoryIsNull() throws Exception { createTempTestFiles(3); dupOp.markDirectoryAs(null, TAG_FOO); verify(imageRepository, never()).getByPath(any(Path.class)); verify(filterRepository, never()).store(any(FilterRecord.class)); }
public void markDirectoryAs(Path directory, Tag tag) { if (!isDirectory(directory)) { logger.warn("Directory {} not valid, aborting.", directory); return; } try { int addCount = 0; Iterator<Path> iter = Files.newDirectoryStream(directory).iterator(); while (iter.hasNext()) { Path current = iter.next(); if (Files.isRegularFile(current)) { markAs(current, tag); addCount++; } } logger.info("Added {} images from {} to filter list", addCount, directory); } catch (IOException e) { logger.error("Failed to add images to filter list, {}", e); } }
DuplicateOperations { public void markDirectoryAs(Path directory, Tag tag) { if (!isDirectory(directory)) { logger.warn("Directory {} not valid, aborting.", directory); return; } try { int addCount = 0; Iterator<Path> iter = Files.newDirectoryStream(directory).iterator(); while (iter.hasNext()) { Path current = iter.next(); if (Files.isRegularFile(current)) { markAs(current, tag); addCount++; } } logger.info("Added {} images from {} to filter list", addCount, directory); } catch (IOException e) { logger.error("Failed to add images to filter list, {}", e); } } }
DuplicateOperations { public void markDirectoryAs(Path directory, Tag tag) { if (!isDirectory(directory)) { logger.warn("Directory {} not valid, aborting.", directory); return; } try { int addCount = 0; Iterator<Path> iter = Files.newDirectoryStream(directory).iterator(); while (iter.hasNext()) { Path current = iter.next(); if (Files.isRegularFile(current)) { markAs(current, tag); addCount++; } } logger.info("Added {} images from {} to filter list", addCount, directory); } catch (IOException e) { logger.error("Failed to add images to filter list, {}", e); } } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); }
DuplicateOperations { public void markDirectoryAs(Path directory, Tag tag) { if (!isDirectory(directory)) { logger.warn("Directory {} not valid, aborting.", directory); return; } try { int addCount = 0; Iterator<Path> iter = Files.newDirectoryStream(directory).iterator(); while (iter.hasNext()) { Path current = iter.next(); if (Files.isRegularFile(current)) { markAs(current, tag); addCount++; } } logger.info("Added {} images from {} to filter list", addCount, directory); } catch (IOException e) { logger.error("Failed to add images to filter list, {}", e); } } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); void moveToDnw(Path path); void deleteAll(Collection<Result> records); void remove(Collection<ImageRecord> records); void deleteFile(Result result); void deleteFile(Path path); void markAll(Collection<Result> records, Tag tag); void markDnwAndDelete(Collection<Result> records); void markAs(Result result, Tag tag); void markAs(Path path, Tag tag); void markAs(ImageRecord image, Tag tag); void markDirectoryAs(Path directory, Tag tag); void markDirectoryAndChildrenAs(Path rootDirectory, Tag tag); List<ImageRecord> findMissingFiles(Path directory); void ignore(Result result); List<Tag> getFilterTags(); }
DuplicateOperations { public void markDirectoryAs(Path directory, Tag tag) { if (!isDirectory(directory)) { logger.warn("Directory {} not valid, aborting.", directory); return; } try { int addCount = 0; Iterator<Path> iter = Files.newDirectoryStream(directory).iterator(); while (iter.hasNext()) { Path current = iter.next(); if (Files.isRegularFile(current)) { markAs(current, tag); addCount++; } } logger.info("Added {} images from {} to filter list", addCount, directory); } catch (IOException e) { logger.error("Failed to add images to filter list, {}", e); } } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); void moveToDnw(Path path); void deleteAll(Collection<Result> records); void remove(Collection<ImageRecord> records); void deleteFile(Result result); void deleteFile(Path path); void markAll(Collection<Result> records, Tag tag); void markDnwAndDelete(Collection<Result> records); void markAs(Result result, Tag tag); void markAs(Path path, Tag tag); void markAs(ImageRecord image, Tag tag); void markDirectoryAs(Path directory, Tag tag); void markDirectoryAndChildrenAs(Path rootDirectory, Tag tag); List<ImageRecord> findMissingFiles(Path directory); void ignore(Result result); List<Tag> getFilterTags(); }
@Test public void testAreAttributesValidHashAndTimestampBefore() throws Exception { ExtendedAttribute.setExtendedAttribute(tempFile, testHashFullName, Long.toString(TEST_VALUE)); long timestamp = Files.getLastModifiedTime(tempFile).toMillis(); timestamp -= TimeUnit.MILLISECONDS.convert(1, TimeUnit.HOURS); ExtendedAttribute.setExtendedAttribute(tempFile, timestampFullName, Long.toString(timestamp)); assertThat(cut.areAttributesValid(tempFile), is(false)); }
public boolean areAttributesValid(Path path) { try { return ExtendedAttribute.isExtendedAttributeSet(path, hashFQN) && verifyTimestamp(path); } catch (IOException e) { LOGGER.error("Failed to check hash for {} ({})", path, e.toString()); } return false; }
HashAttribute { public boolean areAttributesValid(Path path) { try { return ExtendedAttribute.isExtendedAttributeSet(path, hashFQN) && verifyTimestamp(path); } catch (IOException e) { LOGGER.error("Failed to check hash for {} ({})", path, e.toString()); } return false; } }
HashAttribute { public boolean areAttributesValid(Path path) { try { return ExtendedAttribute.isExtendedAttributeSet(path, hashFQN) && verifyTimestamp(path); } catch (IOException e) { LOGGER.error("Failed to check hash for {} ({})", path, e.toString()); } return false; } HashAttribute(String hashName); }
HashAttribute { public boolean areAttributesValid(Path path) { try { return ExtendedAttribute.isExtendedAttributeSet(path, hashFQN) && verifyTimestamp(path); } catch (IOException e) { LOGGER.error("Failed to check hash for {} ({})", path, e.toString()); } return false; } HashAttribute(String hashName); boolean areAttributesValid(Path path); long readHash(Path path); void writeHash(Path path, long hash); void markCorrupted(Path path); boolean isCorrupted(Path path); String getHashFQN(); String getTimestampFQN(); String getCorruptNameFQN(); }
HashAttribute { public boolean areAttributesValid(Path path) { try { return ExtendedAttribute.isExtendedAttributeSet(path, hashFQN) && verifyTimestamp(path); } catch (IOException e) { LOGGER.error("Failed to check hash for {} ({})", path, e.toString()); } return false; } HashAttribute(String hashName); boolean areAttributesValid(Path path); long readHash(Path path); void writeHash(Path path, long hash); void markCorrupted(Path path); boolean isCorrupted(Path path); String getHashFQN(); String getTimestampFQN(); String getCorruptNameFQN(); }
@Test public void testMarkDirectoryDirectoryNonExistantDirectory() throws Exception { createTempTestFiles(3); dupOp.markDirectoryAs(tempDirectory.resolve("foobar"), TAG_FOO); verify(imageRepository, never()).getByPath(any(Path.class)); verify(filterRepository, never()).store(any(FilterRecord.class)); }
public void markDirectoryAs(Path directory, Tag tag) { if (!isDirectory(directory)) { logger.warn("Directory {} not valid, aborting.", directory); return; } try { int addCount = 0; Iterator<Path> iter = Files.newDirectoryStream(directory).iterator(); while (iter.hasNext()) { Path current = iter.next(); if (Files.isRegularFile(current)) { markAs(current, tag); addCount++; } } logger.info("Added {} images from {} to filter list", addCount, directory); } catch (IOException e) { logger.error("Failed to add images to filter list, {}", e); } }
DuplicateOperations { public void markDirectoryAs(Path directory, Tag tag) { if (!isDirectory(directory)) { logger.warn("Directory {} not valid, aborting.", directory); return; } try { int addCount = 0; Iterator<Path> iter = Files.newDirectoryStream(directory).iterator(); while (iter.hasNext()) { Path current = iter.next(); if (Files.isRegularFile(current)) { markAs(current, tag); addCount++; } } logger.info("Added {} images from {} to filter list", addCount, directory); } catch (IOException e) { logger.error("Failed to add images to filter list, {}", e); } } }
DuplicateOperations { public void markDirectoryAs(Path directory, Tag tag) { if (!isDirectory(directory)) { logger.warn("Directory {} not valid, aborting.", directory); return; } try { int addCount = 0; Iterator<Path> iter = Files.newDirectoryStream(directory).iterator(); while (iter.hasNext()) { Path current = iter.next(); if (Files.isRegularFile(current)) { markAs(current, tag); addCount++; } } logger.info("Added {} images from {} to filter list", addCount, directory); } catch (IOException e) { logger.error("Failed to add images to filter list, {}", e); } } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); }
DuplicateOperations { public void markDirectoryAs(Path directory, Tag tag) { if (!isDirectory(directory)) { logger.warn("Directory {} not valid, aborting.", directory); return; } try { int addCount = 0; Iterator<Path> iter = Files.newDirectoryStream(directory).iterator(); while (iter.hasNext()) { Path current = iter.next(); if (Files.isRegularFile(current)) { markAs(current, tag); addCount++; } } logger.info("Added {} images from {} to filter list", addCount, directory); } catch (IOException e) { logger.error("Failed to add images to filter list, {}", e); } } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); void moveToDnw(Path path); void deleteAll(Collection<Result> records); void remove(Collection<ImageRecord> records); void deleteFile(Result result); void deleteFile(Path path); void markAll(Collection<Result> records, Tag tag); void markDnwAndDelete(Collection<Result> records); void markAs(Result result, Tag tag); void markAs(Path path, Tag tag); void markAs(ImageRecord image, Tag tag); void markDirectoryAs(Path directory, Tag tag); void markDirectoryAndChildrenAs(Path rootDirectory, Tag tag); List<ImageRecord> findMissingFiles(Path directory); void ignore(Result result); List<Tag> getFilterTags(); }
DuplicateOperations { public void markDirectoryAs(Path directory, Tag tag) { if (!isDirectory(directory)) { logger.warn("Directory {} not valid, aborting.", directory); return; } try { int addCount = 0; Iterator<Path> iter = Files.newDirectoryStream(directory).iterator(); while (iter.hasNext()) { Path current = iter.next(); if (Files.isRegularFile(current)) { markAs(current, tag); addCount++; } } logger.info("Added {} images from {} to filter list", addCount, directory); } catch (IOException e) { logger.error("Failed to add images to filter list, {}", e); } } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); void moveToDnw(Path path); void deleteAll(Collection<Result> records); void remove(Collection<ImageRecord> records); void deleteFile(Result result); void deleteFile(Path path); void markAll(Collection<Result> records, Tag tag); void markDnwAndDelete(Collection<Result> records); void markAs(Result result, Tag tag); void markAs(Path path, Tag tag); void markAs(ImageRecord image, Tag tag); void markDirectoryAs(Path directory, Tag tag); void markDirectoryAndChildrenAs(Path rootDirectory, Tag tag); List<ImageRecord> findMissingFiles(Path directory); void ignore(Result result); List<Tag> getFilterTags(); }
@Test public void testMarkAll() throws Exception { LinkedList<Result> records = new LinkedList<>(); records.add(new Result(resultGroup, new ImageRecord(TAG_FOO.getTag(), 0))); records.add(new Result(resultGroup, new ImageRecord(TAG_BAR.getTag(), 1))); dupOp.markAll(records, TAG_ALL); verify(filterRepository).store(new FilterRecord(0, TAG_ALL)); verify(filterRepository).store(new FilterRecord(1, TAG_ALL)); }
public void markAll(Collection<Result> records, Tag tag) { for (Result result : records) { ImageRecord record = result.getImageRecord(); try { markAs(record, tag); logger.info("Adding pHash {} to filter, tag {}, source file {}", record.getpHash(), tag, record.getPath()); } catch (RepositoryException e) { logger.warn("Failed to add tag for {}: {}", record.getPath(), e.toString()); } } }
DuplicateOperations { public void markAll(Collection<Result> records, Tag tag) { for (Result result : records) { ImageRecord record = result.getImageRecord(); try { markAs(record, tag); logger.info("Adding pHash {} to filter, tag {}, source file {}", record.getpHash(), tag, record.getPath()); } catch (RepositoryException e) { logger.warn("Failed to add tag for {}: {}", record.getPath(), e.toString()); } } } }
DuplicateOperations { public void markAll(Collection<Result> records, Tag tag) { for (Result result : records) { ImageRecord record = result.getImageRecord(); try { markAs(record, tag); logger.info("Adding pHash {} to filter, tag {}, source file {}", record.getpHash(), tag, record.getPath()); } catch (RepositoryException e) { logger.warn("Failed to add tag for {}: {}", record.getPath(), e.toString()); } } } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); }
DuplicateOperations { public void markAll(Collection<Result> records, Tag tag) { for (Result result : records) { ImageRecord record = result.getImageRecord(); try { markAs(record, tag); logger.info("Adding pHash {} to filter, tag {}, source file {}", record.getpHash(), tag, record.getPath()); } catch (RepositoryException e) { logger.warn("Failed to add tag for {}: {}", record.getPath(), e.toString()); } } } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); void moveToDnw(Path path); void deleteAll(Collection<Result> records); void remove(Collection<ImageRecord> records); void deleteFile(Result result); void deleteFile(Path path); void markAll(Collection<Result> records, Tag tag); void markDnwAndDelete(Collection<Result> records); void markAs(Result result, Tag tag); void markAs(Path path, Tag tag); void markAs(ImageRecord image, Tag tag); void markDirectoryAs(Path directory, Tag tag); void markDirectoryAndChildrenAs(Path rootDirectory, Tag tag); List<ImageRecord> findMissingFiles(Path directory); void ignore(Result result); List<Tag> getFilterTags(); }
DuplicateOperations { public void markAll(Collection<Result> records, Tag tag) { for (Result result : records) { ImageRecord record = result.getImageRecord(); try { markAs(record, tag); logger.info("Adding pHash {} to filter, tag {}, source file {}", record.getpHash(), tag, record.getPath()); } catch (RepositoryException e) { logger.warn("Failed to add tag for {}: {}", record.getPath(), e.toString()); } } } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); void moveToDnw(Path path); void deleteAll(Collection<Result> records); void remove(Collection<ImageRecord> records); void deleteFile(Result result); void deleteFile(Path path); void markAll(Collection<Result> records, Tag tag); void markDnwAndDelete(Collection<Result> records); void markAs(Result result, Tag tag); void markAs(Path path, Tag tag); void markAs(ImageRecord image, Tag tag); void markDirectoryAs(Path directory, Tag tag); void markDirectoryAndChildrenAs(Path rootDirectory, Tag tag); List<ImageRecord> findMissingFiles(Path directory); void ignore(Result result); List<Tag> getFilterTags(); }
@Test public void testFindMissingFiles() throws Exception { Path testFile = Files.createTempFile(tempDirectory, "findmissingfilestest", null); ImageRecord missingRecord = new ImageRecord(testFile.getParent().resolve("foo").toString(), 0); when(imageRepository.startsWithPath(tempDirectory)) .thenReturn(Arrays.asList(new ImageRecord(testFile.toString(), 0), missingRecord)); List<ImageRecord> missing = dupOp.findMissingFiles(tempDirectory); assertThat(missing, containsInAnyOrder(missingRecord)); }
public List<ImageRecord> findMissingFiles(Path directory) { if (!isDirectory(directory)) { logger.error("Directory is null or missing, aborting"); return Collections.emptyList(); } if (!Files.exists(directory)) { logger.warn("Directory {} does not exist.", directory); } List<ImageRecord> records = Collections.emptyList(); try { records = imageRepository.startsWithPath(directory); } catch (RepositoryException e) { logger.error("Failed to get records from database: {}", e.toString()); } LinkedList<ImageRecord> toPrune = new LinkedList<>(); for (ImageRecord ir : records) { Path path = fileSystem.getPath(ir.getPath()); if (!Files.exists(path)) { toPrune.add(ir); } } logger.info("Found {} non-existant records", toPrune.size()); return toPrune; }
DuplicateOperations { public List<ImageRecord> findMissingFiles(Path directory) { if (!isDirectory(directory)) { logger.error("Directory is null or missing, aborting"); return Collections.emptyList(); } if (!Files.exists(directory)) { logger.warn("Directory {} does not exist.", directory); } List<ImageRecord> records = Collections.emptyList(); try { records = imageRepository.startsWithPath(directory); } catch (RepositoryException e) { logger.error("Failed to get records from database: {}", e.toString()); } LinkedList<ImageRecord> toPrune = new LinkedList<>(); for (ImageRecord ir : records) { Path path = fileSystem.getPath(ir.getPath()); if (!Files.exists(path)) { toPrune.add(ir); } } logger.info("Found {} non-existant records", toPrune.size()); return toPrune; } }
DuplicateOperations { public List<ImageRecord> findMissingFiles(Path directory) { if (!isDirectory(directory)) { logger.error("Directory is null or missing, aborting"); return Collections.emptyList(); } if (!Files.exists(directory)) { logger.warn("Directory {} does not exist.", directory); } List<ImageRecord> records = Collections.emptyList(); try { records = imageRepository.startsWithPath(directory); } catch (RepositoryException e) { logger.error("Failed to get records from database: {}", e.toString()); } LinkedList<ImageRecord> toPrune = new LinkedList<>(); for (ImageRecord ir : records) { Path path = fileSystem.getPath(ir.getPath()); if (!Files.exists(path)) { toPrune.add(ir); } } logger.info("Found {} non-existant records", toPrune.size()); return toPrune; } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); }
DuplicateOperations { public List<ImageRecord> findMissingFiles(Path directory) { if (!isDirectory(directory)) { logger.error("Directory is null or missing, aborting"); return Collections.emptyList(); } if (!Files.exists(directory)) { logger.warn("Directory {} does not exist.", directory); } List<ImageRecord> records = Collections.emptyList(); try { records = imageRepository.startsWithPath(directory); } catch (RepositoryException e) { logger.error("Failed to get records from database: {}", e.toString()); } LinkedList<ImageRecord> toPrune = new LinkedList<>(); for (ImageRecord ir : records) { Path path = fileSystem.getPath(ir.getPath()); if (!Files.exists(path)) { toPrune.add(ir); } } logger.info("Found {} non-existant records", toPrune.size()); return toPrune; } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); void moveToDnw(Path path); void deleteAll(Collection<Result> records); void remove(Collection<ImageRecord> records); void deleteFile(Result result); void deleteFile(Path path); void markAll(Collection<Result> records, Tag tag); void markDnwAndDelete(Collection<Result> records); void markAs(Result result, Tag tag); void markAs(Path path, Tag tag); void markAs(ImageRecord image, Tag tag); void markDirectoryAs(Path directory, Tag tag); void markDirectoryAndChildrenAs(Path rootDirectory, Tag tag); List<ImageRecord> findMissingFiles(Path directory); void ignore(Result result); List<Tag> getFilterTags(); }
DuplicateOperations { public List<ImageRecord> findMissingFiles(Path directory) { if (!isDirectory(directory)) { logger.error("Directory is null or missing, aborting"); return Collections.emptyList(); } if (!Files.exists(directory)) { logger.warn("Directory {} does not exist.", directory); } List<ImageRecord> records = Collections.emptyList(); try { records = imageRepository.startsWithPath(directory); } catch (RepositoryException e) { logger.error("Failed to get records from database: {}", e.toString()); } LinkedList<ImageRecord> toPrune = new LinkedList<>(); for (ImageRecord ir : records) { Path path = fileSystem.getPath(ir.getPath()); if (!Files.exists(path)) { toPrune.add(ir); } } logger.info("Found {} non-existant records", toPrune.size()); return toPrune; } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); void moveToDnw(Path path); void deleteAll(Collection<Result> records); void remove(Collection<ImageRecord> records); void deleteFile(Result result); void deleteFile(Path path); void markAll(Collection<Result> records, Tag tag); void markDnwAndDelete(Collection<Result> records); void markAs(Result result, Tag tag); void markAs(Path path, Tag tag); void markAs(ImageRecord image, Tag tag); void markDirectoryAs(Path directory, Tag tag); void markDirectoryAndChildrenAs(Path rootDirectory, Tag tag); List<ImageRecord> findMissingFiles(Path directory); void ignore(Result result); List<Tag> getFilterTags(); }
@Test public void testIgnoreImage() throws Exception { dupOp.ignore(result); verify(ignoreRepository).store(new IgnoreRecord(result.getImageRecord())); }
public void ignore(Result result) { logger.info("Ignoring {}", result); try { ignoreRepository.store(new IgnoreRecord(result.getImageRecord())); } catch (RepositoryException e) { logger.error("Failed to store ignored image: {}, cause: {}", e.toString(), e.getCause().toString()); } }
DuplicateOperations { public void ignore(Result result) { logger.info("Ignoring {}", result); try { ignoreRepository.store(new IgnoreRecord(result.getImageRecord())); } catch (RepositoryException e) { logger.error("Failed to store ignored image: {}, cause: {}", e.toString(), e.getCause().toString()); } } }
DuplicateOperations { public void ignore(Result result) { logger.info("Ignoring {}", result); try { ignoreRepository.store(new IgnoreRecord(result.getImageRecord())); } catch (RepositoryException e) { logger.error("Failed to store ignored image: {}, cause: {}", e.toString(), e.getCause().toString()); } } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); }
DuplicateOperations { public void ignore(Result result) { logger.info("Ignoring {}", result); try { ignoreRepository.store(new IgnoreRecord(result.getImageRecord())); } catch (RepositoryException e) { logger.error("Failed to store ignored image: {}, cause: {}", e.toString(), e.getCause().toString()); } } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); void moveToDnw(Path path); void deleteAll(Collection<Result> records); void remove(Collection<ImageRecord> records); void deleteFile(Result result); void deleteFile(Path path); void markAll(Collection<Result> records, Tag tag); void markDnwAndDelete(Collection<Result> records); void markAs(Result result, Tag tag); void markAs(Path path, Tag tag); void markAs(ImageRecord image, Tag tag); void markDirectoryAs(Path directory, Tag tag); void markDirectoryAndChildrenAs(Path rootDirectory, Tag tag); List<ImageRecord> findMissingFiles(Path directory); void ignore(Result result); List<Tag> getFilterTags(); }
DuplicateOperations { public void ignore(Result result) { logger.info("Ignoring {}", result); try { ignoreRepository.store(new IgnoreRecord(result.getImageRecord())); } catch (RepositoryException e) { logger.error("Failed to store ignored image: {}, cause: {}", e.toString(), e.getCause().toString()); } } @Inject DuplicateOperations(FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); DuplicateOperations(FileSystem fileSystem, FilterRepository filterRepository, TagRepository tagRepository, ImageRepository imageRepository, IgnoreRepository ignoreRepository); void moveToDnw(Path path); void deleteAll(Collection<Result> records); void remove(Collection<ImageRecord> records); void deleteFile(Result result); void deleteFile(Path path); void markAll(Collection<Result> records, Tag tag); void markDnwAndDelete(Collection<Result> records); void markAs(Result result, Tag tag); void markAs(Path path, Tag tag); void markAs(ImageRecord image, Tag tag); void markDirectoryAs(Path directory, Tag tag); void markDirectoryAndChildrenAs(Path rootDirectory, Tag tag); List<ImageRecord> findMissingFiles(Path directory); void ignore(Result result); List<Tag> getFilterTags(); }
@Test public void testGetHammingDistance() throws Exception { assertThat(CompareHammingDistance.getHammingDistance(2L, 3L), is(1)); }
protected static int getHammingDistance(long a, long b) { long xor = a ^ b; int distance = Long.bitCount(xor); return distance; }
CompareHammingDistance implements Distance<Long> { protected static int getHammingDistance(long a, long b) { long xor = a ^ b; int distance = Long.bitCount(xor); return distance; } }
CompareHammingDistance implements Distance<Long> { protected static int getHammingDistance(long a, long b) { long xor = a ^ b; int distance = Long.bitCount(xor); return distance; } }
CompareHammingDistance implements Distance<Long> { protected static int getHammingDistance(long a, long b) { long xor = a ^ b; int distance = Long.bitCount(xor); return distance; } @Override double eval(Long e1, Long e2); }
CompareHammingDistance implements Distance<Long> { protected static int getHammingDistance(long a, long b) { long xor = a ^ b; int distance = Long.bitCount(xor); return distance; } @Override double eval(Long e1, Long e2); }
@Test public void testGetHammingDistance2() throws Exception { assertThat(CompareHammingDistance.getHammingDistance(2L, 4L), is(2)); }
protected static int getHammingDistance(long a, long b) { long xor = a ^ b; int distance = Long.bitCount(xor); return distance; }
CompareHammingDistance implements Distance<Long> { protected static int getHammingDistance(long a, long b) { long xor = a ^ b; int distance = Long.bitCount(xor); return distance; } }
CompareHammingDistance implements Distance<Long> { protected static int getHammingDistance(long a, long b) { long xor = a ^ b; int distance = Long.bitCount(xor); return distance; } }
CompareHammingDistance implements Distance<Long> { protected static int getHammingDistance(long a, long b) { long xor = a ^ b; int distance = Long.bitCount(xor); return distance; } @Override double eval(Long e1, Long e2); }
CompareHammingDistance implements Distance<Long> { protected static int getHammingDistance(long a, long b) { long xor = a ^ b; int distance = Long.bitCount(xor); return distance; } @Override double eval(Long e1, Long e2); }
@Test public void testGetHammingDistance3() throws Exception { assertThat(CompareHammingDistance.getHammingDistance(3L, 5L), is(2)); }
protected static int getHammingDistance(long a, long b) { long xor = a ^ b; int distance = Long.bitCount(xor); return distance; }
CompareHammingDistance implements Distance<Long> { protected static int getHammingDistance(long a, long b) { long xor = a ^ b; int distance = Long.bitCount(xor); return distance; } }
CompareHammingDistance implements Distance<Long> { protected static int getHammingDistance(long a, long b) { long xor = a ^ b; int distance = Long.bitCount(xor); return distance; } }
CompareHammingDistance implements Distance<Long> { protected static int getHammingDistance(long a, long b) { long xor = a ^ b; int distance = Long.bitCount(xor); return distance; } @Override double eval(Long e1, Long e2); }
CompareHammingDistance implements Distance<Long> { protected static int getHammingDistance(long a, long b) { long xor = a ^ b; int distance = Long.bitCount(xor); return distance; } @Override double eval(Long e1, Long e2); }
@Test public void testEvalDistanceAxiom1() throws Exception { assertThat(chd.eval(a, c), is(0.0)); assertThat(a, is(c)); }
@Override public double eval(Long e1, Long e2) { int distance = getHammingDistance(e1, e2); return distance; }
CompareHammingDistance implements Distance<Long> { @Override public double eval(Long e1, Long e2) { int distance = getHammingDistance(e1, e2); return distance; } }
CompareHammingDistance implements Distance<Long> { @Override public double eval(Long e1, Long e2) { int distance = getHammingDistance(e1, e2); return distance; } }
CompareHammingDistance implements Distance<Long> { @Override public double eval(Long e1, Long e2) { int distance = getHammingDistance(e1, e2); return distance; } @Override double eval(Long e1, Long e2); }
CompareHammingDistance implements Distance<Long> { @Override public double eval(Long e1, Long e2) { int distance = getHammingDistance(e1, e2); return distance; } @Override double eval(Long e1, Long e2); }
@Test public void testEvalDistanceAxiom2() throws Exception { double ab, ba; ab = chd.eval(a, b); ba = chd.eval(b, a); assertThat(ab, is(ba)); }
@Override public double eval(Long e1, Long e2) { int distance = getHammingDistance(e1, e2); return distance; }
CompareHammingDistance implements Distance<Long> { @Override public double eval(Long e1, Long e2) { int distance = getHammingDistance(e1, e2); return distance; } }
CompareHammingDistance implements Distance<Long> { @Override public double eval(Long e1, Long e2) { int distance = getHammingDistance(e1, e2); return distance; } }
CompareHammingDistance implements Distance<Long> { @Override public double eval(Long e1, Long e2) { int distance = getHammingDistance(e1, e2); return distance; } @Override double eval(Long e1, Long e2); }
CompareHammingDistance implements Distance<Long> { @Override public double eval(Long e1, Long e2) { int distance = getHammingDistance(e1, e2); return distance; } @Override double eval(Long e1, Long e2); }
@Test public void testEvalDistanceAxiom3() throws Exception { double ad, ab, bd; ab = chd.eval(a, b); ad = chd.eval(a, d); bd = chd.eval(b, d); assertThat(ad, is(lessThanOrEqualTo(ab + bd))); }
@Override public double eval(Long e1, Long e2) { int distance = getHammingDistance(e1, e2); return distance; }
CompareHammingDistance implements Distance<Long> { @Override public double eval(Long e1, Long e2) { int distance = getHammingDistance(e1, e2); return distance; } }
CompareHammingDistance implements Distance<Long> { @Override public double eval(Long e1, Long e2) { int distance = getHammingDistance(e1, e2); return distance; } }
CompareHammingDistance implements Distance<Long> { @Override public double eval(Long e1, Long e2) { int distance = getHammingDistance(e1, e2); return distance; } @Override double eval(Long e1, Long e2); }
CompareHammingDistance implements Distance<Long> { @Override public double eval(Long e1, Long e2) { int distance = getHammingDistance(e1, e2); return distance; } @Override double eval(Long e1, Long e2); }
@Test public void testAreAttributesValidHashAndTimestampOK() throws Exception { ExtendedAttribute.setExtendedAttribute(tempFile, testHashFullName, Long.toString(TEST_VALUE)); long timestamp = Files.getLastModifiedTime(tempFile).toMillis(); ExtendedAttribute.setExtendedAttribute(tempFile, timestampFullName, Long.toString(timestamp)); assertThat(cut.areAttributesValid(tempFile), is(true)); }
public boolean areAttributesValid(Path path) { try { return ExtendedAttribute.isExtendedAttributeSet(path, hashFQN) && verifyTimestamp(path); } catch (IOException e) { LOGGER.error("Failed to check hash for {} ({})", path, e.toString()); } return false; }
HashAttribute { public boolean areAttributesValid(Path path) { try { return ExtendedAttribute.isExtendedAttributeSet(path, hashFQN) && verifyTimestamp(path); } catch (IOException e) { LOGGER.error("Failed to check hash for {} ({})", path, e.toString()); } return false; } }
HashAttribute { public boolean areAttributesValid(Path path) { try { return ExtendedAttribute.isExtendedAttributeSet(path, hashFQN) && verifyTimestamp(path); } catch (IOException e) { LOGGER.error("Failed to check hash for {} ({})", path, e.toString()); } return false; } HashAttribute(String hashName); }
HashAttribute { public boolean areAttributesValid(Path path) { try { return ExtendedAttribute.isExtendedAttributeSet(path, hashFQN) && verifyTimestamp(path); } catch (IOException e) { LOGGER.error("Failed to check hash for {} ({})", path, e.toString()); } return false; } HashAttribute(String hashName); boolean areAttributesValid(Path path); long readHash(Path path); void writeHash(Path path, long hash); void markCorrupted(Path path); boolean isCorrupted(Path path); String getHashFQN(); String getTimestampFQN(); String getCorruptNameFQN(); }
HashAttribute { public boolean areAttributesValid(Path path) { try { return ExtendedAttribute.isExtendedAttributeSet(path, hashFQN) && verifyTimestamp(path); } catch (IOException e) { LOGGER.error("Failed to check hash for {} ({})", path, e.toString()); } return false; } HashAttribute(String hashName); boolean areAttributesValid(Path path); long readHash(Path path); void writeHash(Path path, long hash); void markCorrupted(Path path); boolean isCorrupted(Path path); String getHashFQN(); String getTimestampFQN(); String getCorruptNameFQN(); }
@Test public void testIsNoWorkersMode() throws Exception { assertThat(SimilarImage.isNoWorkersMode(noWorkersArgs), is(true)); }
protected static boolean isNoWorkersMode(Namespace args) { return args.getBoolean("no_workers"); }
SimilarImage { protected static boolean isNoWorkersMode(Namespace args) { return args.getBoolean("no_workers"); } }
SimilarImage { protected static boolean isNoWorkersMode(Namespace args) { return args.getBoolean("no_workers"); } }
SimilarImage { protected static boolean isNoWorkersMode(Namespace args) { return args.getBoolean("no_workers"); } static void main(String[] args); void init(boolean noWorkers); }
SimilarImage { protected static boolean isNoWorkersMode(Namespace args) { return args.getBoolean("no_workers"); } static void main(String[] args); void init(boolean noWorkers); }
@Test public void testIsLocalMode() throws Exception { assertThat(SimilarImage.isNoWorkersMode(localModeArgs), is(false)); }
protected static boolean isNoWorkersMode(Namespace args) { return args.getBoolean("no_workers"); }
SimilarImage { protected static boolean isNoWorkersMode(Namespace args) { return args.getBoolean("no_workers"); } }
SimilarImage { protected static boolean isNoWorkersMode(Namespace args) { return args.getBoolean("no_workers"); } }
SimilarImage { protected static boolean isNoWorkersMode(Namespace args) { return args.getBoolean("no_workers"); } static void main(String[] args); void init(boolean noWorkers); }
SimilarImage { protected static boolean isNoWorkersMode(Namespace args) { return args.getBoolean("no_workers"); } static void main(String[] args); void init(boolean noWorkers); }
@Test public void testGetPath() throws Exception { assertThat(imageInfo.getPath(), is(testImage)); }
public Path getPath() { return path; }
ImageInfo { public Path getPath() { return path; } }
ImageInfo { public Path getPath() { return path; } ImageInfo(Path path, long pHash); }
ImageInfo { public Path getPath() { return path; } ImageInfo(Path path, long pHash); Path getPath(); Dimension getDimension(); long getSize(); long getpHash(); double getSizePerPixel(); }
ImageInfo { public Path getPath() { return path; } ImageInfo(Path path, long pHash); Path getPath(); Dimension getDimension(); long getSize(); long getpHash(); double getSizePerPixel(); }
@Test public void testGetPathInvalidImage() throws Exception { assertThat(imageInfoInvalid.getPath(), is(invalidImage)); }
public Path getPath() { return path; }
ImageInfo { public Path getPath() { return path; } }
ImageInfo { public Path getPath() { return path; } ImageInfo(Path path, long pHash); }
ImageInfo { public Path getPath() { return path; } ImageInfo(Path path, long pHash); Path getPath(); Dimension getDimension(); long getSize(); long getpHash(); double getSizePerPixel(); }
ImageInfo { public Path getPath() { return path; } ImageInfo(Path path, long pHash); Path getPath(); Dimension getDimension(); long getSize(); long getpHash(); double getSizePerPixel(); }
@Test public void testGetDimension() throws Exception { assertThat(imageInfo.getDimension(), is(new Dimension(40, 40))); }
public Dimension getDimension() { return dimension; }
ImageInfo { public Dimension getDimension() { return dimension; } }
ImageInfo { public Dimension getDimension() { return dimension; } ImageInfo(Path path, long pHash); }
ImageInfo { public Dimension getDimension() { return dimension; } ImageInfo(Path path, long pHash); Path getPath(); Dimension getDimension(); long getSize(); long getpHash(); double getSizePerPixel(); }
ImageInfo { public Dimension getDimension() { return dimension; } ImageInfo(Path path, long pHash); Path getPath(); Dimension getDimension(); long getSize(); long getpHash(); double getSizePerPixel(); }
@Test public void testGetDimensionInvalidImage() throws Exception { assertThat(imageInfoInvalid.getDimension(), is(new Dimension(0, 0))); }
public Dimension getDimension() { return dimension; }
ImageInfo { public Dimension getDimension() { return dimension; } }
ImageInfo { public Dimension getDimension() { return dimension; } ImageInfo(Path path, long pHash); }
ImageInfo { public Dimension getDimension() { return dimension; } ImageInfo(Path path, long pHash); Path getPath(); Dimension getDimension(); long getSize(); long getpHash(); double getSizePerPixel(); }
ImageInfo { public Dimension getDimension() { return dimension; } ImageInfo(Path path, long pHash); Path getPath(); Dimension getDimension(); long getSize(); long getpHash(); double getSizePerPixel(); }
@Test public void testGetSize() throws Exception { assertThat(imageInfo.getSize(), is(1782L)); }
public long getSize() { return size; }
ImageInfo { public long getSize() { return size; } }
ImageInfo { public long getSize() { return size; } ImageInfo(Path path, long pHash); }
ImageInfo { public long getSize() { return size; } ImageInfo(Path path, long pHash); Path getPath(); Dimension getDimension(); long getSize(); long getpHash(); double getSizePerPixel(); }
ImageInfo { public long getSize() { return size; } ImageInfo(Path path, long pHash); Path getPath(); Dimension getDimension(); long getSize(); long getpHash(); double getSizePerPixel(); }
@Test public void testGetSizeInvalidImage() throws Exception { assertThat(imageInfoInvalid.getSize(), is(-1L)); }
public long getSize() { return size; }
ImageInfo { public long getSize() { return size; } }
ImageInfo { public long getSize() { return size; } ImageInfo(Path path, long pHash); }
ImageInfo { public long getSize() { return size; } ImageInfo(Path path, long pHash); Path getPath(); Dimension getDimension(); long getSize(); long getpHash(); double getSizePerPixel(); }
ImageInfo { public long getSize() { return size; } ImageInfo(Path path, long pHash); Path getPath(); Dimension getDimension(); long getSize(); long getpHash(); double getSizePerPixel(); }
@Test public void testGetSizeInvalidFile() throws Exception { ImageInfo info = new ImageInfo(Paths.get("foo"), 2); assertThat(info.getSize(), is(-1L)); }
public long getSize() { return size; }
ImageInfo { public long getSize() { return size; } }
ImageInfo { public long getSize() { return size; } ImageInfo(Path path, long pHash); }
ImageInfo { public long getSize() { return size; } ImageInfo(Path path, long pHash); Path getPath(); Dimension getDimension(); long getSize(); long getpHash(); double getSizePerPixel(); }
ImageInfo { public long getSize() { return size; } ImageInfo(Path path, long pHash); Path getPath(); Dimension getDimension(); long getSize(); long getpHash(); double getSizePerPixel(); }
@Test public void testGetpHash() throws Exception { assertThat(imageInfo.getpHash(), is(42L)); }
public long getpHash() { return pHash; }
ImageInfo { public long getpHash() { return pHash; } }
ImageInfo { public long getpHash() { return pHash; } ImageInfo(Path path, long pHash); }
ImageInfo { public long getpHash() { return pHash; } ImageInfo(Path path, long pHash); Path getPath(); Dimension getDimension(); long getSize(); long getpHash(); double getSizePerPixel(); }
ImageInfo { public long getpHash() { return pHash; } ImageInfo(Path path, long pHash); Path getPath(); Dimension getDimension(); long getSize(); long getpHash(); double getSizePerPixel(); }
@Test(expected = InvalidAttributeValueException.class) public void testReadHashInvalidFile() throws Exception { cut.readHash(fs.getPath(INVALID_FILE_PATH)); }
public long readHash(Path path) throws InvalidAttributeValueException, IOException { if (!areAttributesValid(path)) { throw new InvalidAttributeValueException("The required attributes are not set or invalid"); } String encodedHash = ExtendedAttribute.readExtendedAttributeAsString(path, hashFQN); return Long.parseUnsignedLong(encodedHash, HEXADECIMAL_RADIX); }
HashAttribute { public long readHash(Path path) throws InvalidAttributeValueException, IOException { if (!areAttributesValid(path)) { throw new InvalidAttributeValueException("The required attributes are not set or invalid"); } String encodedHash = ExtendedAttribute.readExtendedAttributeAsString(path, hashFQN); return Long.parseUnsignedLong(encodedHash, HEXADECIMAL_RADIX); } }
HashAttribute { public long readHash(Path path) throws InvalidAttributeValueException, IOException { if (!areAttributesValid(path)) { throw new InvalidAttributeValueException("The required attributes are not set or invalid"); } String encodedHash = ExtendedAttribute.readExtendedAttributeAsString(path, hashFQN); return Long.parseUnsignedLong(encodedHash, HEXADECIMAL_RADIX); } HashAttribute(String hashName); }
HashAttribute { public long readHash(Path path) throws InvalidAttributeValueException, IOException { if (!areAttributesValid(path)) { throw new InvalidAttributeValueException("The required attributes are not set or invalid"); } String encodedHash = ExtendedAttribute.readExtendedAttributeAsString(path, hashFQN); return Long.parseUnsignedLong(encodedHash, HEXADECIMAL_RADIX); } HashAttribute(String hashName); boolean areAttributesValid(Path path); long readHash(Path path); void writeHash(Path path, long hash); void markCorrupted(Path path); boolean isCorrupted(Path path); String getHashFQN(); String getTimestampFQN(); String getCorruptNameFQN(); }
HashAttribute { public long readHash(Path path) throws InvalidAttributeValueException, IOException { if (!areAttributesValid(path)) { throw new InvalidAttributeValueException("The required attributes are not set or invalid"); } String encodedHash = ExtendedAttribute.readExtendedAttributeAsString(path, hashFQN); return Long.parseUnsignedLong(encodedHash, HEXADECIMAL_RADIX); } HashAttribute(String hashName); boolean areAttributesValid(Path path); long readHash(Path path); void writeHash(Path path, long hash); void markCorrupted(Path path); boolean isCorrupted(Path path); String getHashFQN(); String getTimestampFQN(); String getCorruptNameFQN(); }
@Test public void testGetpHashInvalidImage() throws Exception { assertThat(imageInfoInvalid.getpHash(), is(0L)); }
public long getpHash() { return pHash; }
ImageInfo { public long getpHash() { return pHash; } }
ImageInfo { public long getpHash() { return pHash; } ImageInfo(Path path, long pHash); }
ImageInfo { public long getpHash() { return pHash; } ImageInfo(Path path, long pHash); Path getPath(); Dimension getDimension(); long getSize(); long getpHash(); double getSizePerPixel(); }
ImageInfo { public long getpHash() { return pHash; } ImageInfo(Path path, long pHash); Path getPath(); Dimension getDimension(); long getSize(); long getpHash(); double getSizePerPixel(); }
@Test public void testGetpHashInvalidFile() throws Exception { ImageInfo info = new ImageInfo(Paths.get("foo"), 2); assertThat(info.getpHash(), is(2L)); }
public long getpHash() { return pHash; }
ImageInfo { public long getpHash() { return pHash; } }
ImageInfo { public long getpHash() { return pHash; } ImageInfo(Path path, long pHash); }
ImageInfo { public long getpHash() { return pHash; } ImageInfo(Path path, long pHash); Path getPath(); Dimension getDimension(); long getSize(); long getpHash(); double getSizePerPixel(); }
ImageInfo { public long getpHash() { return pHash; } ImageInfo(Path path, long pHash); Path getPath(); Dimension getDimension(); long getSize(); long getpHash(); double getSizePerPixel(); }
@Test public void testGetSizePerPixel() throws Exception { assertThat(imageInfo.getSizePerPixel(), is(1.11375)); }
public double getSizePerPixel() { return sizePerPixel; }
ImageInfo { public double getSizePerPixel() { return sizePerPixel; } }
ImageInfo { public double getSizePerPixel() { return sizePerPixel; } ImageInfo(Path path, long pHash); }
ImageInfo { public double getSizePerPixel() { return sizePerPixel; } ImageInfo(Path path, long pHash); Path getPath(); Dimension getDimension(); long getSize(); long getpHash(); double getSizePerPixel(); }
ImageInfo { public double getSizePerPixel() { return sizePerPixel; } ImageInfo(Path path, long pHash); Path getPath(); Dimension getDimension(); long getSize(); long getpHash(); double getSizePerPixel(); }
@Test public void testGetSizePerPixelInvalidImage() throws Exception { assertThat(imageInfoInvalid.getSizePerPixel(), is(0.0)); }
public double getSizePerPixel() { return sizePerPixel; }
ImageInfo { public double getSizePerPixel() { return sizePerPixel; } }
ImageInfo { public double getSizePerPixel() { return sizePerPixel; } ImageInfo(Path path, long pHash); }
ImageInfo { public double getSizePerPixel() { return sizePerPixel; } ImageInfo(Path path, long pHash); Path getPath(); Dimension getDimension(); long getSize(); long getpHash(); double getSizePerPixel(); }
ImageInfo { public double getSizePerPixel() { return sizePerPixel; } ImageInfo(Path path, long pHash); Path getPath(); Dimension getDimension(); long getSize(); long getpHash(); double getSizePerPixel(); }
@Test public void testSetView() throws Exception { cut.setView(ignoredImageView); verify(ignoredImageView, timeout(CONCURRENT_TIMEOUT)).pack(); }
public void setView(IgnoredImageView view) { this.view = view; refreshList(); }
IgnoredImagePresenter { public void setView(IgnoredImageView view) { this.view = view; refreshList(); } }
IgnoredImagePresenter { public void setView(IgnoredImageView view) { this.view = view; refreshList(); } IgnoredImagePresenter(IgnoreRepository ignoreRepository); }
IgnoredImagePresenter { public void setView(IgnoredImageView view) { this.view = view; refreshList(); } IgnoredImagePresenter(IgnoreRepository ignoreRepository); void setView(IgnoredImageView view); DefaultListModel<IgnoreRecord> getModel(); void refreshList(); void removeIgnoredImages(List<IgnoreRecord> toRemove); }
IgnoredImagePresenter { public void setView(IgnoredImageView view) { this.view = view; refreshList(); } IgnoredImagePresenter(IgnoreRepository ignoreRepository); void setView(IgnoredImageView view); DefaultListModel<IgnoreRecord> getModel(); void refreshList(); void removeIgnoredImages(List<IgnoreRecord> toRemove); }
@Test public void testGetModel() throws Exception { assertThat(cut.getModel(), is(not(nullValue()))); }
public DefaultListModel<IgnoreRecord> getModel() { return model; }
IgnoredImagePresenter { public DefaultListModel<IgnoreRecord> getModel() { return model; } }
IgnoredImagePresenter { public DefaultListModel<IgnoreRecord> getModel() { return model; } IgnoredImagePresenter(IgnoreRepository ignoreRepository); }
IgnoredImagePresenter { public DefaultListModel<IgnoreRecord> getModel() { return model; } IgnoredImagePresenter(IgnoreRepository ignoreRepository); void setView(IgnoredImageView view); DefaultListModel<IgnoreRecord> getModel(); void refreshList(); void removeIgnoredImages(List<IgnoreRecord> toRemove); }
IgnoredImagePresenter { public DefaultListModel<IgnoreRecord> getModel() { return model; } IgnoredImagePresenter(IgnoreRepository ignoreRepository); void setView(IgnoredImageView view); DefaultListModel<IgnoreRecord> getModel(); void refreshList(); void removeIgnoredImages(List<IgnoreRecord> toRemove); }
@Test public void testRefreshList() throws Exception { cut.setView(ignoredImageView); cut.refreshList(); Awaitility.await().atMost(CONCURRENT_TIMEOUT, TimeUnit.MILLISECONDS).until(() -> cut.getModel().getSize(), is(2)); }
public void refreshList() { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { model.clear(); try { ignoreRepository.getAll().forEach(new Consumer<IgnoreRecord>() { @Override public void accept(IgnoreRecord t) { model.addElement(t); } }); } catch (RepositoryException e) { LOGGER.error("Failed to load ignored image list: {} cause:{}", e.getCause()); } view.pack(); } }); }
IgnoredImagePresenter { public void refreshList() { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { model.clear(); try { ignoreRepository.getAll().forEach(new Consumer<IgnoreRecord>() { @Override public void accept(IgnoreRecord t) { model.addElement(t); } }); } catch (RepositoryException e) { LOGGER.error("Failed to load ignored image list: {} cause:{}", e.getCause()); } view.pack(); } }); } }
IgnoredImagePresenter { public void refreshList() { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { model.clear(); try { ignoreRepository.getAll().forEach(new Consumer<IgnoreRecord>() { @Override public void accept(IgnoreRecord t) { model.addElement(t); } }); } catch (RepositoryException e) { LOGGER.error("Failed to load ignored image list: {} cause:{}", e.getCause()); } view.pack(); } }); } IgnoredImagePresenter(IgnoreRepository ignoreRepository); }
IgnoredImagePresenter { public void refreshList() { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { model.clear(); try { ignoreRepository.getAll().forEach(new Consumer<IgnoreRecord>() { @Override public void accept(IgnoreRecord t) { model.addElement(t); } }); } catch (RepositoryException e) { LOGGER.error("Failed to load ignored image list: {} cause:{}", e.getCause()); } view.pack(); } }); } IgnoredImagePresenter(IgnoreRepository ignoreRepository); void setView(IgnoredImageView view); DefaultListModel<IgnoreRecord> getModel(); void refreshList(); void removeIgnoredImages(List<IgnoreRecord> toRemove); }
IgnoredImagePresenter { public void refreshList() { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { model.clear(); try { ignoreRepository.getAll().forEach(new Consumer<IgnoreRecord>() { @Override public void accept(IgnoreRecord t) { model.addElement(t); } }); } catch (RepositoryException e) { LOGGER.error("Failed to load ignored image list: {} cause:{}", e.getCause()); } view.pack(); } }); } IgnoredImagePresenter(IgnoreRepository ignoreRepository); void setView(IgnoredImageView view); DefaultListModel<IgnoreRecord> getModel(); void refreshList(); void removeIgnoredImages(List<IgnoreRecord> toRemove); }
@Test public void testRemoveIgnoredImages() throws Exception { cut.removeIgnoredImages(Arrays.asList(ignoreA)); verify(ignoreRepository).remove(ignoreA); }
public void removeIgnoredImages(List<IgnoreRecord> toRemove) { LOGGER.info("Removing {} ignored images", toRemove.size()); toRemove.forEach(this::removeIgnoredImage); }
IgnoredImagePresenter { public void removeIgnoredImages(List<IgnoreRecord> toRemove) { LOGGER.info("Removing {} ignored images", toRemove.size()); toRemove.forEach(this::removeIgnoredImage); } }
IgnoredImagePresenter { public void removeIgnoredImages(List<IgnoreRecord> toRemove) { LOGGER.info("Removing {} ignored images", toRemove.size()); toRemove.forEach(this::removeIgnoredImage); } IgnoredImagePresenter(IgnoreRepository ignoreRepository); }
IgnoredImagePresenter { public void removeIgnoredImages(List<IgnoreRecord> toRemove) { LOGGER.info("Removing {} ignored images", toRemove.size()); toRemove.forEach(this::removeIgnoredImage); } IgnoredImagePresenter(IgnoreRepository ignoreRepository); void setView(IgnoredImageView view); DefaultListModel<IgnoreRecord> getModel(); void refreshList(); void removeIgnoredImages(List<IgnoreRecord> toRemove); }
IgnoredImagePresenter { public void removeIgnoredImages(List<IgnoreRecord> toRemove) { LOGGER.info("Removing {} ignored images", toRemove.size()); toRemove.forEach(this::removeIgnoredImage); } IgnoredImagePresenter(IgnoreRepository ignoreRepository); void setView(IgnoredImageView view); DefaultListModel<IgnoreRecord> getModel(); void refreshList(); void removeIgnoredImages(List<IgnoreRecord> toRemove); }
@Test public void testRemoveIgnoredImagesWithRepositoryError() throws Exception { Mockito.doThrow(new RepositoryException("")).when(ignoreRepository).remove(ignoreA); cut.removeIgnoredImages(Arrays.asList(ignoreA, ignoreB)); verify(ignoreRepository, times(2)).remove(any()); }
public void removeIgnoredImages(List<IgnoreRecord> toRemove) { LOGGER.info("Removing {} ignored images", toRemove.size()); toRemove.forEach(this::removeIgnoredImage); }
IgnoredImagePresenter { public void removeIgnoredImages(List<IgnoreRecord> toRemove) { LOGGER.info("Removing {} ignored images", toRemove.size()); toRemove.forEach(this::removeIgnoredImage); } }
IgnoredImagePresenter { public void removeIgnoredImages(List<IgnoreRecord> toRemove) { LOGGER.info("Removing {} ignored images", toRemove.size()); toRemove.forEach(this::removeIgnoredImage); } IgnoredImagePresenter(IgnoreRepository ignoreRepository); }
IgnoredImagePresenter { public void removeIgnoredImages(List<IgnoreRecord> toRemove) { LOGGER.info("Removing {} ignored images", toRemove.size()); toRemove.forEach(this::removeIgnoredImage); } IgnoredImagePresenter(IgnoreRepository ignoreRepository); void setView(IgnoredImageView view); DefaultListModel<IgnoreRecord> getModel(); void refreshList(); void removeIgnoredImages(List<IgnoreRecord> toRemove); }
IgnoredImagePresenter { public void removeIgnoredImages(List<IgnoreRecord> toRemove) { LOGGER.info("Removing {} ignored images", toRemove.size()); toRemove.forEach(this::removeIgnoredImage); } IgnoredImagePresenter(IgnoreRepository ignoreRepository); void setView(IgnoredImageView view); DefaultListModel<IgnoreRecord> getModel(); void refreshList(); void removeIgnoredImages(List<IgnoreRecord> toRemove); }
@Test public void testLoadImage() throws Exception { assertThat(cut.load(key), is(notNullValue())); }
@Override public BufferedImage load(Result key) throws Exception { BufferedImage bi = ImageUtil.loadImage(Paths.get(key.getImageRecord().getPath())); return Scalr.resize(bi, Method.AUTOMATIC, THUMBNAIL_SIZE); }
ThumbnailCacheLoader extends CacheLoader<Result, BufferedImage> { @Override public BufferedImage load(Result key) throws Exception { BufferedImage bi = ImageUtil.loadImage(Paths.get(key.getImageRecord().getPath())); return Scalr.resize(bi, Method.AUTOMATIC, THUMBNAIL_SIZE); } }
ThumbnailCacheLoader extends CacheLoader<Result, BufferedImage> { @Override public BufferedImage load(Result key) throws Exception { BufferedImage bi = ImageUtil.loadImage(Paths.get(key.getImageRecord().getPath())); return Scalr.resize(bi, Method.AUTOMATIC, THUMBNAIL_SIZE); } }
ThumbnailCacheLoader extends CacheLoader<Result, BufferedImage> { @Override public BufferedImage load(Result key) throws Exception { BufferedImage bi = ImageUtil.loadImage(Paths.get(key.getImageRecord().getPath())); return Scalr.resize(bi, Method.AUTOMATIC, THUMBNAIL_SIZE); } @Override BufferedImage load(Result key); }
ThumbnailCacheLoader extends CacheLoader<Result, BufferedImage> { @Override public BufferedImage load(Result key) throws Exception { BufferedImage bi = ImageUtil.loadImage(Paths.get(key.getImageRecord().getPath())); return Scalr.resize(bi, Method.AUTOMATIC, THUMBNAIL_SIZE); } @Override BufferedImage load(Result key); }
@Test public void testGetHashFQN() throws Exception { assertThat(cut.getHashFQN(), is(ExtendedAttribute.createName("hash", TEST_HASH_NAME))); }
public String getHashFQN() { return hashFQN; }
HashAttribute { public String getHashFQN() { return hashFQN; } }
HashAttribute { public String getHashFQN() { return hashFQN; } HashAttribute(String hashName); }
HashAttribute { public String getHashFQN() { return hashFQN; } HashAttribute(String hashName); boolean areAttributesValid(Path path); long readHash(Path path); void writeHash(Path path, long hash); void markCorrupted(Path path); boolean isCorrupted(Path path); String getHashFQN(); String getTimestampFQN(); String getCorruptNameFQN(); }
HashAttribute { public String getHashFQN() { return hashFQN; } HashAttribute(String hashName); boolean areAttributesValid(Path path); long readHash(Path path); void writeHash(Path path, long hash); void markCorrupted(Path path); boolean isCorrupted(Path path); String getHashFQN(); String getTimestampFQN(); String getCorruptNameFQN(); }
@Test(expected = NoSuchFileException.class) public void testLoadInvalidPath() throws Exception { assertThat(cut.load(invalidImagePath), is(notNullValue())); }
@Override public BufferedImage load(Result key) throws Exception { BufferedImage bi = ImageUtil.loadImage(Paths.get(key.getImageRecord().getPath())); return Scalr.resize(bi, Method.AUTOMATIC, THUMBNAIL_SIZE); }
ThumbnailCacheLoader extends CacheLoader<Result, BufferedImage> { @Override public BufferedImage load(Result key) throws Exception { BufferedImage bi = ImageUtil.loadImage(Paths.get(key.getImageRecord().getPath())); return Scalr.resize(bi, Method.AUTOMATIC, THUMBNAIL_SIZE); } }
ThumbnailCacheLoader extends CacheLoader<Result, BufferedImage> { @Override public BufferedImage load(Result key) throws Exception { BufferedImage bi = ImageUtil.loadImage(Paths.get(key.getImageRecord().getPath())); return Scalr.resize(bi, Method.AUTOMATIC, THUMBNAIL_SIZE); } }
ThumbnailCacheLoader extends CacheLoader<Result, BufferedImage> { @Override public BufferedImage load(Result key) throws Exception { BufferedImage bi = ImageUtil.loadImage(Paths.get(key.getImageRecord().getPath())); return Scalr.resize(bi, Method.AUTOMATIC, THUMBNAIL_SIZE); } @Override BufferedImage load(Result key); }
ThumbnailCacheLoader extends CacheLoader<Result, BufferedImage> { @Override public BufferedImage load(Result key) throws Exception { BufferedImage bi = ImageUtil.loadImage(Paths.get(key.getImageRecord().getPath())); return Scalr.resize(bi, Method.AUTOMATIC, THUMBNAIL_SIZE); } @Override BufferedImage load(Result key); }
@Test public void testGetImagePath() throws Exception { assertThat(duplicateEntryController.getImagePath(), is(Paths.get(testImage.toString()))); }
public Path getImagePath() { return imageInfo.getPath(); }
ResultPresenter { public Path getImagePath() { return imageInfo.getPath(); } }
ResultPresenter { public Path getImagePath() { return imageInfo.getPath(); } ResultPresenter(Result result, LoadingCache<Result, BufferedImage> thumbnailCache); }
ResultPresenter { public Path getImagePath() { return imageInfo.getPath(); } ResultPresenter(Result result, LoadingCache<Result, BufferedImage> thumbnailCache); Path getImagePath(); void displayFullImage(); void setView(ResultView view); }
ResultPresenter { public Path getImagePath() { return imageInfo.getPath(); } ResultPresenter(Result result, LoadingCache<Result, BufferedImage> thumbnailCache); Path getImagePath(); void displayFullImage(); void setView(ResultView view); }
@Test public void testSetView() throws Exception { verify(view).setImage(any(JLabel.class)); verify(view).createLable(eq("Path: " + testImage.toString())); verify(view).createLable(eq("Size: 1 kb")); verify(view).createLable(eq("Dimension: 40x40")); verify(view).createLable(eq("pHash: 42")); verify(view).createLable(eq("Size per Pixel: 1.11375")); }
public void setView(ResultView view) { this.view = view; loadThumbnail(); addImageInfo(); }
ResultPresenter { public void setView(ResultView view) { this.view = view; loadThumbnail(); addImageInfo(); } }
ResultPresenter { public void setView(ResultView view) { this.view = view; loadThumbnail(); addImageInfo(); } ResultPresenter(Result result, LoadingCache<Result, BufferedImage> thumbnailCache); }
ResultPresenter { public void setView(ResultView view) { this.view = view; loadThumbnail(); addImageInfo(); } ResultPresenter(Result result, LoadingCache<Result, BufferedImage> thumbnailCache); Path getImagePath(); void displayFullImage(); void setView(ResultView view); }
ResultPresenter { public void setView(ResultView view) { this.view = view; loadThumbnail(); addImageInfo(); } ResultPresenter(Result result, LoadingCache<Result, BufferedImage> thumbnailCache); Path getImagePath(); void displayFullImage(); void setView(ResultView view); }
@Test public void testDisplayFullImage() throws Exception { duplicateEntryController.displayFullImage(); verify(view).displayFullImage(any(JLabel.class), eq(testImage)); }
public void displayFullImage() { JLabel largeImage = new JLabel("No Image"); try { BufferedImage bi = ImageUtil.loadImage(getImagePath()); largeImage = imageAsLabel(bi); } catch (Exception e) { LOGGER.warn("Unable to load full image {} - {}", getImagePath(), e.getMessage()); } view.displayFullImage(largeImage, getImagePath()); }
ResultPresenter { public void displayFullImage() { JLabel largeImage = new JLabel("No Image"); try { BufferedImage bi = ImageUtil.loadImage(getImagePath()); largeImage = imageAsLabel(bi); } catch (Exception e) { LOGGER.warn("Unable to load full image {} - {}", getImagePath(), e.getMessage()); } view.displayFullImage(largeImage, getImagePath()); } }
ResultPresenter { public void displayFullImage() { JLabel largeImage = new JLabel("No Image"); try { BufferedImage bi = ImageUtil.loadImage(getImagePath()); largeImage = imageAsLabel(bi); } catch (Exception e) { LOGGER.warn("Unable to load full image {} - {}", getImagePath(), e.getMessage()); } view.displayFullImage(largeImage, getImagePath()); } ResultPresenter(Result result, LoadingCache<Result, BufferedImage> thumbnailCache); }
ResultPresenter { public void displayFullImage() { JLabel largeImage = new JLabel("No Image"); try { BufferedImage bi = ImageUtil.loadImage(getImagePath()); largeImage = imageAsLabel(bi); } catch (Exception e) { LOGGER.warn("Unable to load full image {} - {}", getImagePath(), e.getMessage()); } view.displayFullImage(largeImage, getImagePath()); } ResultPresenter(Result result, LoadingCache<Result, BufferedImage> thumbnailCache); Path getImagePath(); void displayFullImage(); void setView(ResultView view); }
ResultPresenter { public void displayFullImage() { JLabel largeImage = new JLabel("No Image"); try { BufferedImage bi = ImageUtil.loadImage(getImagePath()); largeImage = imageAsLabel(bi); } catch (Exception e) { LOGGER.warn("Unable to load full image {} - {}", getImagePath(), e.getMessage()); } view.displayFullImage(largeImage, getImagePath()); } ResultPresenter(Result result, LoadingCache<Result, BufferedImage> thumbnailCache); Path getImagePath(); void displayFullImage(); void setView(ResultView view); }
@Test public void testProcessedFileFoundCountForNonImage() throws Exception { cut.visitFile(pathNonImage, null); assertThat(foundFiles.getCount(), is(0L)); }
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (!imageFileFilter.accept(file)) { return FileVisitResult.CONTINUE; } foundFiles.inc(); filesPerSecond.mark(); if (hashAttribute.isCorrupted(file)) { failedFiles.inc(); } else if (hashAttribute.areAttributesValid(file)) { processedFiles.inc(); } return FileVisitResult.CONTINUE; }
ProgressVisitor extends SimpleFileVisitor<Path> { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (!imageFileFilter.accept(file)) { return FileVisitResult.CONTINUE; } foundFiles.inc(); filesPerSecond.mark(); if (hashAttribute.isCorrupted(file)) { failedFiles.inc(); } else if (hashAttribute.areAttributesValid(file)) { processedFiles.inc(); } return FileVisitResult.CONTINUE; } }
ProgressVisitor extends SimpleFileVisitor<Path> { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (!imageFileFilter.accept(file)) { return FileVisitResult.CONTINUE; } foundFiles.inc(); filesPerSecond.mark(); if (hashAttribute.isCorrupted(file)) { failedFiles.inc(); } else if (hashAttribute.areAttributesValid(file)) { processedFiles.inc(); } return FileVisitResult.CONTINUE; } ProgressVisitor(MetricRegistry metrics, HashAttribute hashAttribute); }
ProgressVisitor extends SimpleFileVisitor<Path> { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (!imageFileFilter.accept(file)) { return FileVisitResult.CONTINUE; } foundFiles.inc(); filesPerSecond.mark(); if (hashAttribute.isCorrupted(file)) { failedFiles.inc(); } else if (hashAttribute.areAttributesValid(file)) { processedFiles.inc(); } return FileVisitResult.CONTINUE; } ProgressVisitor(MetricRegistry metrics, HashAttribute hashAttribute); @Override FileVisitResult visitFile(Path file, BasicFileAttributes attrs); }
ProgressVisitor extends SimpleFileVisitor<Path> { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (!imageFileFilter.accept(file)) { return FileVisitResult.CONTINUE; } foundFiles.inc(); filesPerSecond.mark(); if (hashAttribute.isCorrupted(file)) { failedFiles.inc(); } else if (hashAttribute.areAttributesValid(file)) { processedFiles.inc(); } return FileVisitResult.CONTINUE; } ProgressVisitor(MetricRegistry metrics, HashAttribute hashAttribute); @Override FileVisitResult visitFile(Path file, BasicFileAttributes attrs); }
@Test(expected = ArgumentParserException.class) public void testParseArgsInvalidOption() throws Exception { cut.parseArgs(new String[] { LOCAL_SUBCOMMAND, "--foo" }); }
public void parseArgs(String[] args) throws ArgumentParserException { Namespace parsedArgs = parser.parseArgs(args); if (parsedArgs.get("subcommand") == Subcommand.local) { localCommand(parsedArgs); } if (parsedArgs.get("subcommand") == Subcommand.node) { nodeCommand(parsedArgs); } }
ArgumentPasrser { public void parseArgs(String[] args) throws ArgumentParserException { Namespace parsedArgs = parser.parseArgs(args); if (parsedArgs.get("subcommand") == Subcommand.local) { localCommand(parsedArgs); } if (parsedArgs.get("subcommand") == Subcommand.node) { nodeCommand(parsedArgs); } } }
ArgumentPasrser { public void parseArgs(String[] args) throws ArgumentParserException { Namespace parsedArgs = parser.parseArgs(args); if (parsedArgs.get("subcommand") == Subcommand.local) { localCommand(parsedArgs); } if (parsedArgs.get("subcommand") == Subcommand.node) { nodeCommand(parsedArgs); } } ArgumentPasrser(FileVisitor<Path> visitor); }
ArgumentPasrser { public void parseArgs(String[] args) throws ArgumentParserException { Namespace parsedArgs = parser.parseArgs(args); if (parsedArgs.get("subcommand") == Subcommand.local) { localCommand(parsedArgs); } if (parsedArgs.get("subcommand") == Subcommand.node) { nodeCommand(parsedArgs); } } ArgumentPasrser(FileVisitor<Path> visitor); void parseArgs(String[] args); }
ArgumentPasrser { public void parseArgs(String[] args) throws ArgumentParserException { Namespace parsedArgs = parser.parseArgs(args); if (parsedArgs.get("subcommand") == Subcommand.local) { localCommand(parsedArgs); } if (parsedArgs.get("subcommand") == Subcommand.node) { nodeCommand(parsedArgs); } } ArgumentPasrser(FileVisitor<Path> visitor); void parseArgs(String[] args); }
@Test public void testParseArgsUpdateOption() throws Exception { cut.parseArgs(new String[] { LOCAL_SUBCOMMAND, "--update", "foo" }); }
public void parseArgs(String[] args) throws ArgumentParserException { Namespace parsedArgs = parser.parseArgs(args); if (parsedArgs.get("subcommand") == Subcommand.local) { localCommand(parsedArgs); } if (parsedArgs.get("subcommand") == Subcommand.node) { nodeCommand(parsedArgs); } }
ArgumentPasrser { public void parseArgs(String[] args) throws ArgumentParserException { Namespace parsedArgs = parser.parseArgs(args); if (parsedArgs.get("subcommand") == Subcommand.local) { localCommand(parsedArgs); } if (parsedArgs.get("subcommand") == Subcommand.node) { nodeCommand(parsedArgs); } } }
ArgumentPasrser { public void parseArgs(String[] args) throws ArgumentParserException { Namespace parsedArgs = parser.parseArgs(args); if (parsedArgs.get("subcommand") == Subcommand.local) { localCommand(parsedArgs); } if (parsedArgs.get("subcommand") == Subcommand.node) { nodeCommand(parsedArgs); } } ArgumentPasrser(FileVisitor<Path> visitor); }
ArgumentPasrser { public void parseArgs(String[] args) throws ArgumentParserException { Namespace parsedArgs = parser.parseArgs(args); if (parsedArgs.get("subcommand") == Subcommand.local) { localCommand(parsedArgs); } if (parsedArgs.get("subcommand") == Subcommand.node) { nodeCommand(parsedArgs); } } ArgumentPasrser(FileVisitor<Path> visitor); void parseArgs(String[] args); }
ArgumentPasrser { public void parseArgs(String[] args) throws ArgumentParserException { Namespace parsedArgs = parser.parseArgs(args); if (parsedArgs.get("subcommand") == Subcommand.local) { localCommand(parsedArgs); } if (parsedArgs.get("subcommand") == Subcommand.node) { nodeCommand(parsedArgs); } } ArgumentPasrser(FileVisitor<Path> visitor); void parseArgs(String[] args); }
@Test public void testParseArgsNodeOption() throws Exception { cut.parseArgs(new String[] { NODE_SUBCOMMAND, "--port", "123" }); }
public void parseArgs(String[] args) throws ArgumentParserException { Namespace parsedArgs = parser.parseArgs(args); if (parsedArgs.get("subcommand") == Subcommand.local) { localCommand(parsedArgs); } if (parsedArgs.get("subcommand") == Subcommand.node) { nodeCommand(parsedArgs); } }
ArgumentPasrser { public void parseArgs(String[] args) throws ArgumentParserException { Namespace parsedArgs = parser.parseArgs(args); if (parsedArgs.get("subcommand") == Subcommand.local) { localCommand(parsedArgs); } if (parsedArgs.get("subcommand") == Subcommand.node) { nodeCommand(parsedArgs); } } }
ArgumentPasrser { public void parseArgs(String[] args) throws ArgumentParserException { Namespace parsedArgs = parser.parseArgs(args); if (parsedArgs.get("subcommand") == Subcommand.local) { localCommand(parsedArgs); } if (parsedArgs.get("subcommand") == Subcommand.node) { nodeCommand(parsedArgs); } } ArgumentPasrser(FileVisitor<Path> visitor); }
ArgumentPasrser { public void parseArgs(String[] args) throws ArgumentParserException { Namespace parsedArgs = parser.parseArgs(args); if (parsedArgs.get("subcommand") == Subcommand.local) { localCommand(parsedArgs); } if (parsedArgs.get("subcommand") == Subcommand.node) { nodeCommand(parsedArgs); } } ArgumentPasrser(FileVisitor<Path> visitor); void parseArgs(String[] args); }
ArgumentPasrser { public void parseArgs(String[] args) throws ArgumentParserException { Namespace parsedArgs = parser.parseArgs(args); if (parsedArgs.get("subcommand") == Subcommand.local) { localCommand(parsedArgs); } if (parsedArgs.get("subcommand") == Subcommand.node) { nodeCommand(parsedArgs); } } ArgumentPasrser(FileVisitor<Path> visitor); void parseArgs(String[] args); }
@Test public void testTotalProgressPercent() throws Exception { assertThat(cut.totalProgressPercent(), closeTo(TOTAL_PROGRESS_PERCENT, ALLOWED_COMAPRE_ERROR)); }
public double totalProgressPercent() { if (foundFiles.getCount() == 0) { return 0; } else { return (PERCENT_100 / foundFiles.getCount()) * (processedFiles.getCount() + failedFiles.getCount()); } }
ProgressCalc { public double totalProgressPercent() { if (foundFiles.getCount() == 0) { return 0; } else { return (PERCENT_100 / foundFiles.getCount()) * (processedFiles.getCount() + failedFiles.getCount()); } } }
ProgressCalc { public double totalProgressPercent() { if (foundFiles.getCount() == 0) { return 0; } else { return (PERCENT_100 / foundFiles.getCount()) * (processedFiles.getCount() + failedFiles.getCount()); } } ProgressCalc(MetricRegistry metrics); }
ProgressCalc { public double totalProgressPercent() { if (foundFiles.getCount() == 0) { return 0; } else { return (PERCENT_100 / foundFiles.getCount()) * (processedFiles.getCount() + failedFiles.getCount()); } } ProgressCalc(MetricRegistry metrics); double totalProgressPercent(); double corruptPercent(); @Override String toString(); }
ProgressCalc { public double totalProgressPercent() { if (foundFiles.getCount() == 0) { return 0; } else { return (PERCENT_100 / foundFiles.getCount()) * (processedFiles.getCount() + failedFiles.getCount()); } } ProgressCalc(MetricRegistry metrics); double totalProgressPercent(); double corruptPercent(); @Override String toString(); static final String METRIC_NAME_FOUND; static final String METRIC_NAME_PROCESSED; static final String METRIC_NAME_FAILED; static final String METRIC_NAME_FILES_PER_SECOND; }
@Test public void testTotalProgressPercentWithNoFiles() throws Exception { setCounter(ProgressCalc.METRIC_NAME_FOUND, 0); setCounter(ProgressCalc.METRIC_NAME_PROCESSED, 0); assertThat(cut.totalProgressPercent(), is(0.0)); }
public double totalProgressPercent() { if (foundFiles.getCount() == 0) { return 0; } else { return (PERCENT_100 / foundFiles.getCount()) * (processedFiles.getCount() + failedFiles.getCount()); } }
ProgressCalc { public double totalProgressPercent() { if (foundFiles.getCount() == 0) { return 0; } else { return (PERCENT_100 / foundFiles.getCount()) * (processedFiles.getCount() + failedFiles.getCount()); } } }
ProgressCalc { public double totalProgressPercent() { if (foundFiles.getCount() == 0) { return 0; } else { return (PERCENT_100 / foundFiles.getCount()) * (processedFiles.getCount() + failedFiles.getCount()); } } ProgressCalc(MetricRegistry metrics); }
ProgressCalc { public double totalProgressPercent() { if (foundFiles.getCount() == 0) { return 0; } else { return (PERCENT_100 / foundFiles.getCount()) * (processedFiles.getCount() + failedFiles.getCount()); } } ProgressCalc(MetricRegistry metrics); double totalProgressPercent(); double corruptPercent(); @Override String toString(); }
ProgressCalc { public double totalProgressPercent() { if (foundFiles.getCount() == 0) { return 0; } else { return (PERCENT_100 / foundFiles.getCount()) * (processedFiles.getCount() + failedFiles.getCount()); } } ProgressCalc(MetricRegistry metrics); double totalProgressPercent(); double corruptPercent(); @Override String toString(); static final String METRIC_NAME_FOUND; static final String METRIC_NAME_PROCESSED; static final String METRIC_NAME_FAILED; static final String METRIC_NAME_FILES_PER_SECOND; }
@Test public void testGetTimestampFQN() throws Exception { assertThat(cut.getTimestampFQN(), is(ExtendedAttribute.createName("timestamp", TEST_HASH_NAME))); }
public String getTimestampFQN() { return timestampFQN; }
HashAttribute { public String getTimestampFQN() { return timestampFQN; } }
HashAttribute { public String getTimestampFQN() { return timestampFQN; } HashAttribute(String hashName); }
HashAttribute { public String getTimestampFQN() { return timestampFQN; } HashAttribute(String hashName); boolean areAttributesValid(Path path); long readHash(Path path); void writeHash(Path path, long hash); void markCorrupted(Path path); boolean isCorrupted(Path path); String getHashFQN(); String getTimestampFQN(); String getCorruptNameFQN(); }
HashAttribute { public String getTimestampFQN() { return timestampFQN; } HashAttribute(String hashName); boolean areAttributesValid(Path path); long readHash(Path path); void writeHash(Path path, long hash); void markCorrupted(Path path); boolean isCorrupted(Path path); String getHashFQN(); String getTimestampFQN(); String getCorruptNameFQN(); }
@Test public void testCorruptPercent() throws Exception { assertThat(cut.corruptPercent(), closeTo(CORRUPT_PERCENT, ALLOWED_COMAPRE_ERROR)); }
public double corruptPercent() { if (foundFiles.getCount() == 0) { return 0; } else { return (PERCENT_100 / foundFiles.getCount()) * failedFiles.getCount(); } }
ProgressCalc { public double corruptPercent() { if (foundFiles.getCount() == 0) { return 0; } else { return (PERCENT_100 / foundFiles.getCount()) * failedFiles.getCount(); } } }
ProgressCalc { public double corruptPercent() { if (foundFiles.getCount() == 0) { return 0; } else { return (PERCENT_100 / foundFiles.getCount()) * failedFiles.getCount(); } } ProgressCalc(MetricRegistry metrics); }
ProgressCalc { public double corruptPercent() { if (foundFiles.getCount() == 0) { return 0; } else { return (PERCENT_100 / foundFiles.getCount()) * failedFiles.getCount(); } } ProgressCalc(MetricRegistry metrics); double totalProgressPercent(); double corruptPercent(); @Override String toString(); }
ProgressCalc { public double corruptPercent() { if (foundFiles.getCount() == 0) { return 0; } else { return (PERCENT_100 / foundFiles.getCount()) * failedFiles.getCount(); } } ProgressCalc(MetricRegistry metrics); double totalProgressPercent(); double corruptPercent(); @Override String toString(); static final String METRIC_NAME_FOUND; static final String METRIC_NAME_PROCESSED; static final String METRIC_NAME_FAILED; static final String METRIC_NAME_FILES_PER_SECOND; }
@Test public void testCorruptPercentWithNoFiles() throws Exception { setCounter(ProgressCalc.METRIC_NAME_FOUND, 0); setCounter(ProgressCalc.METRIC_NAME_FAILED, 0); assertThat(cut.corruptPercent(), is(0.0)); }
public double corruptPercent() { if (foundFiles.getCount() == 0) { return 0; } else { return (PERCENT_100 / foundFiles.getCount()) * failedFiles.getCount(); } }
ProgressCalc { public double corruptPercent() { if (foundFiles.getCount() == 0) { return 0; } else { return (PERCENT_100 / foundFiles.getCount()) * failedFiles.getCount(); } } }
ProgressCalc { public double corruptPercent() { if (foundFiles.getCount() == 0) { return 0; } else { return (PERCENT_100 / foundFiles.getCount()) * failedFiles.getCount(); } } ProgressCalc(MetricRegistry metrics); }
ProgressCalc { public double corruptPercent() { if (foundFiles.getCount() == 0) { return 0; } else { return (PERCENT_100 / foundFiles.getCount()) * failedFiles.getCount(); } } ProgressCalc(MetricRegistry metrics); double totalProgressPercent(); double corruptPercent(); @Override String toString(); }
ProgressCalc { public double corruptPercent() { if (foundFiles.getCount() == 0) { return 0; } else { return (PERCENT_100 / foundFiles.getCount()) * failedFiles.getCount(); } } ProgressCalc(MetricRegistry metrics); double totalProgressPercent(); double corruptPercent(); @Override String toString(); static final String METRIC_NAME_FOUND; static final String METRIC_NAME_PROCESSED; static final String METRIC_NAME_FAILED; static final String METRIC_NAME_FILES_PER_SECOND; }
@Test public void testToString() throws Exception { assertThat(cut.toString(), is("Total progress: 23.81%, corrupt images: 9.52%, files per second processed: 0.00")); }
@Override public String toString() { return String.format("Total progress: %.2f%%, corrupt images: %.2f%%, files per second processed: %.2f", totalProgressPercent(), corruptPercent(), filesPerSecond.getMeanRate()); }
ProgressCalc { @Override public String toString() { return String.format("Total progress: %.2f%%, corrupt images: %.2f%%, files per second processed: %.2f", totalProgressPercent(), corruptPercent(), filesPerSecond.getMeanRate()); } }
ProgressCalc { @Override public String toString() { return String.format("Total progress: %.2f%%, corrupt images: %.2f%%, files per second processed: %.2f", totalProgressPercent(), corruptPercent(), filesPerSecond.getMeanRate()); } ProgressCalc(MetricRegistry metrics); }
ProgressCalc { @Override public String toString() { return String.format("Total progress: %.2f%%, corrupt images: %.2f%%, files per second processed: %.2f", totalProgressPercent(), corruptPercent(), filesPerSecond.getMeanRate()); } ProgressCalc(MetricRegistry metrics); double totalProgressPercent(); double corruptPercent(); @Override String toString(); }
ProgressCalc { @Override public String toString() { return String.format("Total progress: %.2f%%, corrupt images: %.2f%%, files per second processed: %.2f", totalProgressPercent(), corruptPercent(), filesPerSecond.getMeanRate()); } ProgressCalc(MetricRegistry metrics); double totalProgressPercent(); double corruptPercent(); @Override String toString(); static final String METRIC_NAME_FOUND; static final String METRIC_NAME_PROCESSED; static final String METRIC_NAME_FAILED; static final String METRIC_NAME_FILES_PER_SECOND; }
@Test public void testHashRequestMessageTrackingId() throws Exception { ClientMessage result = cut.hashRequestMessage(IMAGE_DATA, UUID); UUID id = new UUID(result.getBodyBuffer().readLong(), result.getBodyBuffer().readLong()); assertThat(id, is(UUID)); }
public ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid) { ClientMessage message = session.createMessage(true); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); message.getBodyBuffer().writeBytes(resizedImage); return message; }
MessageFactory { public ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid) { ClientMessage message = session.createMessage(true); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); message.getBodyBuffer().writeBytes(resizedImage); return message; } }
MessageFactory { public ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid) { ClientMessage message = session.createMessage(true); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); message.getBodyBuffer().writeBytes(resizedImage); return message; } MessageFactory(ClientSession session); }
MessageFactory { public ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid) { ClientMessage message = session.createMessage(true); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); message.getBodyBuffer().writeBytes(resizedImage); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
MessageFactory { public ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid) { ClientMessage message = session.createMessage(true); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); message.getBodyBuffer().writeBytes(resizedImage); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
@Test public void testHashRequestMessageImageData() throws Exception { ClientMessage result = cut.hashRequestMessage(IMAGE_DATA, UUID); result.getBodyBuffer().readLong(); result.getBodyBuffer().readLong(); byte[] data = new byte[IMAGE_DATA.length]; result.getBodyBuffer().readBytes(data); assertArrayEquals(data, IMAGE_DATA); }
public ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid) { ClientMessage message = session.createMessage(true); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); message.getBodyBuffer().writeBytes(resizedImage); return message; }
MessageFactory { public ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid) { ClientMessage message = session.createMessage(true); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); message.getBodyBuffer().writeBytes(resizedImage); return message; } }
MessageFactory { public ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid) { ClientMessage message = session.createMessage(true); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); message.getBodyBuffer().writeBytes(resizedImage); return message; } MessageFactory(ClientSession session); }
MessageFactory { public ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid) { ClientMessage message = session.createMessage(true); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); message.getBodyBuffer().writeBytes(resizedImage); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
MessageFactory { public ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid) { ClientMessage message = session.createMessage(true); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); message.getBodyBuffer().writeBytes(resizedImage); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
@Test public void testHashRequestMessageImageSize() throws Exception { ClientMessage result = cut.hashRequestMessage(IMAGE_DATA, UUID); result.getBodyBuffer().readLong(); result.getBodyBuffer().readLong(); byte[] data = new byte[result.getBodySize()]; result.getBodyBuffer().readBytes(data); assertArrayEquals(data, IMAGE_DATA); }
public ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid) { ClientMessage message = session.createMessage(true); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); message.getBodyBuffer().writeBytes(resizedImage); return message; }
MessageFactory { public ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid) { ClientMessage message = session.createMessage(true); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); message.getBodyBuffer().writeBytes(resizedImage); return message; } }
MessageFactory { public ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid) { ClientMessage message = session.createMessage(true); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); message.getBodyBuffer().writeBytes(resizedImage); return message; } MessageFactory(ClientSession session); }
MessageFactory { public ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid) { ClientMessage message = session.createMessage(true); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); message.getBodyBuffer().writeBytes(resizedImage); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
MessageFactory { public ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid) { ClientMessage message = session.createMessage(true); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); message.getBodyBuffer().writeBytes(resizedImage); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
@Test public void testResultMessageTask() throws Exception { ClientMessage result = cut.resultMessage(HASH, UUID.getMostSignificantBits(), UUID.getLeastSignificantBits()); assertThat(result.getStringProperty(MessageProperty.task.toString()), is(TaskType.result.toString())); }
public ClientMessage resultMessage(long hash, long most, long least) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.result); ActiveMQBuffer buffer = message.getBodyBuffer(); buffer.writeLong(most); buffer.writeLong(least); buffer.writeLong(hash); return message; }
MessageFactory { public ClientMessage resultMessage(long hash, long most, long least) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.result); ActiveMQBuffer buffer = message.getBodyBuffer(); buffer.writeLong(most); buffer.writeLong(least); buffer.writeLong(hash); return message; } }
MessageFactory { public ClientMessage resultMessage(long hash, long most, long least) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.result); ActiveMQBuffer buffer = message.getBodyBuffer(); buffer.writeLong(most); buffer.writeLong(least); buffer.writeLong(hash); return message; } MessageFactory(ClientSession session); }
MessageFactory { public ClientMessage resultMessage(long hash, long most, long least) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.result); ActiveMQBuffer buffer = message.getBodyBuffer(); buffer.writeLong(most); buffer.writeLong(least); buffer.writeLong(hash); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
MessageFactory { public ClientMessage resultMessage(long hash, long most, long least) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.result); ActiveMQBuffer buffer = message.getBodyBuffer(); buffer.writeLong(most); buffer.writeLong(least); buffer.writeLong(hash); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
@Test public void testResultMessageUuid() throws Exception { ClientMessage result = cut.resultMessage(HASH, UUID.getMostSignificantBits(), UUID.getLeastSignificantBits()); UUID id = new UUID(result.getBodyBuffer().readLong(), result.getBodyBuffer().readLong()); assertThat(id, is(UUID)); }
public ClientMessage resultMessage(long hash, long most, long least) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.result); ActiveMQBuffer buffer = message.getBodyBuffer(); buffer.writeLong(most); buffer.writeLong(least); buffer.writeLong(hash); return message; }
MessageFactory { public ClientMessage resultMessage(long hash, long most, long least) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.result); ActiveMQBuffer buffer = message.getBodyBuffer(); buffer.writeLong(most); buffer.writeLong(least); buffer.writeLong(hash); return message; } }
MessageFactory { public ClientMessage resultMessage(long hash, long most, long least) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.result); ActiveMQBuffer buffer = message.getBodyBuffer(); buffer.writeLong(most); buffer.writeLong(least); buffer.writeLong(hash); return message; } MessageFactory(ClientSession session); }
MessageFactory { public ClientMessage resultMessage(long hash, long most, long least) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.result); ActiveMQBuffer buffer = message.getBodyBuffer(); buffer.writeLong(most); buffer.writeLong(least); buffer.writeLong(hash); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
MessageFactory { public ClientMessage resultMessage(long hash, long most, long least) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.result); ActiveMQBuffer buffer = message.getBodyBuffer(); buffer.writeLong(most); buffer.writeLong(least); buffer.writeLong(hash); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
@Test public void testResultMessageHash() throws Exception { ClientMessage result = cut.resultMessage(HASH, UUID.getMostSignificantBits(), UUID.getLeastSignificantBits()); result.getBodyBuffer().readLong(); result.getBodyBuffer().readLong(); long hash = result.getBodyBuffer().readLong(); assertThat(hash, is(HASH)); }
public ClientMessage resultMessage(long hash, long most, long least) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.result); ActiveMQBuffer buffer = message.getBodyBuffer(); buffer.writeLong(most); buffer.writeLong(least); buffer.writeLong(hash); return message; }
MessageFactory { public ClientMessage resultMessage(long hash, long most, long least) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.result); ActiveMQBuffer buffer = message.getBodyBuffer(); buffer.writeLong(most); buffer.writeLong(least); buffer.writeLong(hash); return message; } }
MessageFactory { public ClientMessage resultMessage(long hash, long most, long least) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.result); ActiveMQBuffer buffer = message.getBodyBuffer(); buffer.writeLong(most); buffer.writeLong(least); buffer.writeLong(hash); return message; } MessageFactory(ClientSession session); }
MessageFactory { public ClientMessage resultMessage(long hash, long most, long least) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.result); ActiveMQBuffer buffer = message.getBodyBuffer(); buffer.writeLong(most); buffer.writeLong(least); buffer.writeLong(hash); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
MessageFactory { public ClientMessage resultMessage(long hash, long most, long least) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.result); ActiveMQBuffer buffer = message.getBodyBuffer(); buffer.writeLong(most); buffer.writeLong(least); buffer.writeLong(hash); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
@Test public void testPendingImageQuery() throws Exception { ClientMessage result = cut.pendingImageQuery(); assertThat(result.getStringProperty(MessageFactory.MessageProperty.repository_query.toString()), is(MessageFactory.QueryType.pending.toString())); }
public ClientMessage pendingImageQuery() { ClientMessage message = session.createMessage(false); message.putStringProperty(MessageProperty.repository_query.toString(), QueryType.pending.toString()); return message; }
MessageFactory { public ClientMessage pendingImageQuery() { ClientMessage message = session.createMessage(false); message.putStringProperty(MessageProperty.repository_query.toString(), QueryType.pending.toString()); return message; } }
MessageFactory { public ClientMessage pendingImageQuery() { ClientMessage message = session.createMessage(false); message.putStringProperty(MessageProperty.repository_query.toString(), QueryType.pending.toString()); return message; } MessageFactory(ClientSession session); }
MessageFactory { public ClientMessage pendingImageQuery() { ClientMessage message = session.createMessage(false); message.putStringProperty(MessageProperty.repository_query.toString(), QueryType.pending.toString()); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
MessageFactory { public ClientMessage pendingImageQuery() { ClientMessage message = session.createMessage(false); message.putStringProperty(MessageProperty.repository_query.toString(), QueryType.pending.toString()); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
@Test public void testMarkCorrupted() throws Exception { cut.markCorrupted(tempFile); assertThat(ExtendedAttribute.isExtendedAttributeSet(tempFile, cut.getCorruptNameFQN()), is(true)); }
public void markCorrupted(Path path) throws IOException { ExtendedAttribute.setExtendedAttribute(path, corruptNameFQN, ""); }
HashAttribute { public void markCorrupted(Path path) throws IOException { ExtendedAttribute.setExtendedAttribute(path, corruptNameFQN, ""); } }
HashAttribute { public void markCorrupted(Path path) throws IOException { ExtendedAttribute.setExtendedAttribute(path, corruptNameFQN, ""); } HashAttribute(String hashName); }
HashAttribute { public void markCorrupted(Path path) throws IOException { ExtendedAttribute.setExtendedAttribute(path, corruptNameFQN, ""); } HashAttribute(String hashName); boolean areAttributesValid(Path path); long readHash(Path path); void writeHash(Path path, long hash); void markCorrupted(Path path); boolean isCorrupted(Path path); String getHashFQN(); String getTimestampFQN(); String getCorruptNameFQN(); }
HashAttribute { public void markCorrupted(Path path) throws IOException { ExtendedAttribute.setExtendedAttribute(path, corruptNameFQN, ""); } HashAttribute(String hashName); boolean areAttributesValid(Path path); long readHash(Path path); void writeHash(Path path, long hash); void markCorrupted(Path path); boolean isCorrupted(Path path); String getHashFQN(); String getTimestampFQN(); String getCorruptNameFQN(); }
@Test public void testTransformDCT2() throws Exception { double[] result = cut.transformDCT(Doubles.concat(testMatrix2)); assertArrayEquals(EXPECTED2, Doubles.concat(result), 0.1); }
public synchronized double[] transformDCT(double[] matrix) { for (int i = 0; i < matrixArea; i++) { this.matrix[i] = matrix[i]; } execute(range); return Doubles.concat(result); }
DCTKernel extends Kernel { public synchronized double[] transformDCT(double[] matrix) { for (int i = 0; i < matrixArea; i++) { this.matrix[i] = matrix[i]; } execute(range); return Doubles.concat(result); } }
DCTKernel extends Kernel { public synchronized double[] transformDCT(double[] matrix) { for (int i = 0; i < matrixArea; i++) { this.matrix[i] = matrix[i]; } execute(range); return Doubles.concat(result); } DCTKernel(); DCTKernel(int matrixSize); }
DCTKernel extends Kernel { public synchronized double[] transformDCT(double[] matrix) { for (int i = 0; i < matrixArea; i++) { this.matrix[i] = matrix[i]; } execute(range); return Doubles.concat(result); } DCTKernel(); DCTKernel(int matrixSize); void setDevice(Device device); @Override void run(); synchronized double[] transformDCT(double[] matrix); }
DCTKernel extends Kernel { public synchronized double[] transformDCT(double[] matrix) { for (int i = 0; i < matrixArea; i++) { this.matrix[i] = matrix[i]; } execute(range); return Doubles.concat(result); } DCTKernel(); DCTKernel(int matrixSize); void setDevice(Device device); @Override void run(); synchronized double[] transformDCT(double[] matrix); static final int DEFAULT_MATRIX_SIZE; }
@Test public void testPendingImageResponse() throws Exception { ClientMessage result = cut.pendingImageResponse(Arrays.asList(new PendingHashImage(PATH, UUID))); assertThat(result.getBodySize(), is(EXPECTED_MESSAGE_SIZE)); }
public ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages) throws IOException { List<String> pendingPaths = new LinkedList<String>(); for (PendingHashImage p : pendingImages) { pendingPaths.add(p.getPath()); } try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos)) { ClientMessage message = session.createMessage(false); oos.writeObject(pendingPaths); message.writeBodyBufferBytes(baos.toByteArray()); return message; } }
MessageFactory { public ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages) throws IOException { List<String> pendingPaths = new LinkedList<String>(); for (PendingHashImage p : pendingImages) { pendingPaths.add(p.getPath()); } try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos)) { ClientMessage message = session.createMessage(false); oos.writeObject(pendingPaths); message.writeBodyBufferBytes(baos.toByteArray()); return message; } } }
MessageFactory { public ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages) throws IOException { List<String> pendingPaths = new LinkedList<String>(); for (PendingHashImage p : pendingImages) { pendingPaths.add(p.getPath()); } try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos)) { ClientMessage message = session.createMessage(false); oos.writeObject(pendingPaths); message.writeBodyBufferBytes(baos.toByteArray()); return message; } } MessageFactory(ClientSession session); }
MessageFactory { public ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages) throws IOException { List<String> pendingPaths = new LinkedList<String>(); for (PendingHashImage p : pendingImages) { pendingPaths.add(p.getPath()); } try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos)) { ClientMessage message = session.createMessage(false); oos.writeObject(pendingPaths); message.writeBodyBufferBytes(baos.toByteArray()); return message; } } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
MessageFactory { public ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages) throws IOException { List<String> pendingPaths = new LinkedList<String>(); for (PendingHashImage p : pendingImages) { pendingPaths.add(p.getPath()); } try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos)) { ClientMessage message = session.createMessage(false); oos.writeObject(pendingPaths); message.writeBodyBufferBytes(baos.toByteArray()); return message; } } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
@Test public void testCorruptMessagePath() throws Exception { ClientMessage result = cut.corruptMessage(PATH); assertThat(result.getStringProperty(MessageProperty.path.toString()), is(PATH.toString())); }
public ClientMessage corruptMessage(Path path) { ClientMessage message = session.createMessage(true); message.putStringProperty(MessageProperty.path.toString(), path.toString()); message.putStringProperty(MessageProperty.task.toString(), TaskType.corr.toString()); return message; }
MessageFactory { public ClientMessage corruptMessage(Path path) { ClientMessage message = session.createMessage(true); message.putStringProperty(MessageProperty.path.toString(), path.toString()); message.putStringProperty(MessageProperty.task.toString(), TaskType.corr.toString()); return message; } }
MessageFactory { public ClientMessage corruptMessage(Path path) { ClientMessage message = session.createMessage(true); message.putStringProperty(MessageProperty.path.toString(), path.toString()); message.putStringProperty(MessageProperty.task.toString(), TaskType.corr.toString()); return message; } MessageFactory(ClientSession session); }
MessageFactory { public ClientMessage corruptMessage(Path path) { ClientMessage message = session.createMessage(true); message.putStringProperty(MessageProperty.path.toString(), path.toString()); message.putStringProperty(MessageProperty.task.toString(), TaskType.corr.toString()); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
MessageFactory { public ClientMessage corruptMessage(Path path) { ClientMessage message = session.createMessage(true); message.putStringProperty(MessageProperty.path.toString(), path.toString()); message.putStringProperty(MessageProperty.task.toString(), TaskType.corr.toString()); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
@Test public void testCorruptMessageTask() throws Exception { ClientMessage result = cut.corruptMessage(PATH); assertThat(result.getStringProperty(MessageProperty.task.toString()), is(TaskType.corr.toString())); }
public ClientMessage corruptMessage(Path path) { ClientMessage message = session.createMessage(true); message.putStringProperty(MessageProperty.path.toString(), path.toString()); message.putStringProperty(MessageProperty.task.toString(), TaskType.corr.toString()); return message; }
MessageFactory { public ClientMessage corruptMessage(Path path) { ClientMessage message = session.createMessage(true); message.putStringProperty(MessageProperty.path.toString(), path.toString()); message.putStringProperty(MessageProperty.task.toString(), TaskType.corr.toString()); return message; } }
MessageFactory { public ClientMessage corruptMessage(Path path) { ClientMessage message = session.createMessage(true); message.putStringProperty(MessageProperty.path.toString(), path.toString()); message.putStringProperty(MessageProperty.task.toString(), TaskType.corr.toString()); return message; } MessageFactory(ClientSession session); }
MessageFactory { public ClientMessage corruptMessage(Path path) { ClientMessage message = session.createMessage(true); message.putStringProperty(MessageProperty.path.toString(), path.toString()); message.putStringProperty(MessageProperty.task.toString(), TaskType.corr.toString()); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
MessageFactory { public ClientMessage corruptMessage(Path path) { ClientMessage message = session.createMessage(true); message.putStringProperty(MessageProperty.path.toString(), path.toString()); message.putStringProperty(MessageProperty.task.toString(), TaskType.corr.toString()); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
@Test public void testEaUpdatePath() throws Exception { ClientMessage result = cut.eaUpdate(PATH, HASH); assertThat(result.getStringProperty(MessageProperty.path.toString()), is(PATH.toString())); }
public ClientMessage eaUpdate(Path path, long hash) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.eaupdate); setPath(message, path); message.getBodyBuffer().writeLong(hash); return message; }
MessageFactory { public ClientMessage eaUpdate(Path path, long hash) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.eaupdate); setPath(message, path); message.getBodyBuffer().writeLong(hash); return message; } }
MessageFactory { public ClientMessage eaUpdate(Path path, long hash) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.eaupdate); setPath(message, path); message.getBodyBuffer().writeLong(hash); return message; } MessageFactory(ClientSession session); }
MessageFactory { public ClientMessage eaUpdate(Path path, long hash) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.eaupdate); setPath(message, path); message.getBodyBuffer().writeLong(hash); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
MessageFactory { public ClientMessage eaUpdate(Path path, long hash) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.eaupdate); setPath(message, path); message.getBodyBuffer().writeLong(hash); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
@Test public void testEaUpdateHash() throws Exception { ClientMessage result = cut.eaUpdate(PATH, HASH); assertThat(result.getBodyBuffer().readLong(), is(HASH)); }
public ClientMessage eaUpdate(Path path, long hash) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.eaupdate); setPath(message, path); message.getBodyBuffer().writeLong(hash); return message; }
MessageFactory { public ClientMessage eaUpdate(Path path, long hash) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.eaupdate); setPath(message, path); message.getBodyBuffer().writeLong(hash); return message; } }
MessageFactory { public ClientMessage eaUpdate(Path path, long hash) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.eaupdate); setPath(message, path); message.getBodyBuffer().writeLong(hash); return message; } MessageFactory(ClientSession session); }
MessageFactory { public ClientMessage eaUpdate(Path path, long hash) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.eaupdate); setPath(message, path); message.getBodyBuffer().writeLong(hash); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
MessageFactory { public ClientMessage eaUpdate(Path path, long hash) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.eaupdate); setPath(message, path); message.getBodyBuffer().writeLong(hash); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
@Test public void testEaUpdateTask() throws Exception { ClientMessage result = cut.eaUpdate(PATH, HASH); assertThat(result.getStringProperty(MessageProperty.task.toString()), is(TaskType.eaupdate.toString())); }
public ClientMessage eaUpdate(Path path, long hash) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.eaupdate); setPath(message, path); message.getBodyBuffer().writeLong(hash); return message; }
MessageFactory { public ClientMessage eaUpdate(Path path, long hash) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.eaupdate); setPath(message, path); message.getBodyBuffer().writeLong(hash); return message; } }
MessageFactory { public ClientMessage eaUpdate(Path path, long hash) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.eaupdate); setPath(message, path); message.getBodyBuffer().writeLong(hash); return message; } MessageFactory(ClientSession session); }
MessageFactory { public ClientMessage eaUpdate(Path path, long hash) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.eaupdate); setPath(message, path); message.getBodyBuffer().writeLong(hash); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
MessageFactory { public ClientMessage eaUpdate(Path path, long hash) { ClientMessage message = session.createMessage(true); setTaskType(message, TaskType.eaupdate); setPath(message, path); message.getBodyBuffer().writeLong(hash); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
@Test public void testResizeRequestPath() throws Exception { ClientMessage result = cut.resizeRequest(PATH, is); assertThat(result.getStringProperty(MessageProperty.path.toString()), is(PATH.toString())); }
public ClientMessage resizeRequest(Path path, InputStream is) throws IOException { ClientMessage message = session.createMessage(true); copyInputStreamToMessage(is, message); setTaskType(message, TaskType.hash); setPath(message, path); return message; }
MessageFactory { public ClientMessage resizeRequest(Path path, InputStream is) throws IOException { ClientMessage message = session.createMessage(true); copyInputStreamToMessage(is, message); setTaskType(message, TaskType.hash); setPath(message, path); return message; } }
MessageFactory { public ClientMessage resizeRequest(Path path, InputStream is) throws IOException { ClientMessage message = session.createMessage(true); copyInputStreamToMessage(is, message); setTaskType(message, TaskType.hash); setPath(message, path); return message; } MessageFactory(ClientSession session); }
MessageFactory { public ClientMessage resizeRequest(Path path, InputStream is) throws IOException { ClientMessage message = session.createMessage(true); copyInputStreamToMessage(is, message); setTaskType(message, TaskType.hash); setPath(message, path); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
MessageFactory { public ClientMessage resizeRequest(Path path, InputStream is) throws IOException { ClientMessage message = session.createMessage(true); copyInputStreamToMessage(is, message); setTaskType(message, TaskType.hash); setPath(message, path); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
@Test public void testResizeRequestTask() throws Exception { ClientMessage result = cut.resizeRequest(PATH, is); assertThat(result.getStringProperty(MessageProperty.task.toString()), is(TaskType.hash.toString())); }
public ClientMessage resizeRequest(Path path, InputStream is) throws IOException { ClientMessage message = session.createMessage(true); copyInputStreamToMessage(is, message); setTaskType(message, TaskType.hash); setPath(message, path); return message; }
MessageFactory { public ClientMessage resizeRequest(Path path, InputStream is) throws IOException { ClientMessage message = session.createMessage(true); copyInputStreamToMessage(is, message); setTaskType(message, TaskType.hash); setPath(message, path); return message; } }
MessageFactory { public ClientMessage resizeRequest(Path path, InputStream is) throws IOException { ClientMessage message = session.createMessage(true); copyInputStreamToMessage(is, message); setTaskType(message, TaskType.hash); setPath(message, path); return message; } MessageFactory(ClientSession session); }
MessageFactory { public ClientMessage resizeRequest(Path path, InputStream is) throws IOException { ClientMessage message = session.createMessage(true); copyInputStreamToMessage(is, message); setTaskType(message, TaskType.hash); setPath(message, path); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
MessageFactory { public ClientMessage resizeRequest(Path path, InputStream is) throws IOException { ClientMessage message = session.createMessage(true); copyInputStreamToMessage(is, message); setTaskType(message, TaskType.hash); setPath(message, path); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
@Test public void testTrackPathPathProperty() throws Exception { ClientMessage result = cut.trackPath(PATH, UUID); assertThat(result.getStringProperty(MessageProperty.path.toString()), is(PATH.toString())); }
public ClientMessage trackPath(Path path, UUID uuid) { ClientMessage message = session.createMessage(false); setTaskType(message, TaskType.track); setPath(message, path); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); return message; }
MessageFactory { public ClientMessage trackPath(Path path, UUID uuid) { ClientMessage message = session.createMessage(false); setTaskType(message, TaskType.track); setPath(message, path); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); return message; } }
MessageFactory { public ClientMessage trackPath(Path path, UUID uuid) { ClientMessage message = session.createMessage(false); setTaskType(message, TaskType.track); setPath(message, path); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); return message; } MessageFactory(ClientSession session); }
MessageFactory { public ClientMessage trackPath(Path path, UUID uuid) { ClientMessage message = session.createMessage(false); setTaskType(message, TaskType.track); setPath(message, path); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
MessageFactory { public ClientMessage trackPath(Path path, UUID uuid) { ClientMessage message = session.createMessage(false); setTaskType(message, TaskType.track); setPath(message, path); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
@Test public void testTrackPathTaskProperty() throws Exception { ClientMessage result = cut.trackPath(PATH, UUID); assertThat(result.getStringProperty(MessageProperty.task.toString()), is(TaskType.track.toString())); }
public ClientMessage trackPath(Path path, UUID uuid) { ClientMessage message = session.createMessage(false); setTaskType(message, TaskType.track); setPath(message, path); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); return message; }
MessageFactory { public ClientMessage trackPath(Path path, UUID uuid) { ClientMessage message = session.createMessage(false); setTaskType(message, TaskType.track); setPath(message, path); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); return message; } }
MessageFactory { public ClientMessage trackPath(Path path, UUID uuid) { ClientMessage message = session.createMessage(false); setTaskType(message, TaskType.track); setPath(message, path); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); return message; } MessageFactory(ClientSession session); }
MessageFactory { public ClientMessage trackPath(Path path, UUID uuid) { ClientMessage message = session.createMessage(false); setTaskType(message, TaskType.track); setPath(message, path); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
MessageFactory { public ClientMessage trackPath(Path path, UUID uuid) { ClientMessage message = session.createMessage(false); setTaskType(message, TaskType.track); setPath(message, path); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
@Test public void testGetCorruptNameFQN() throws Exception { assertThat(cut.getCorruptNameFQN(), is(ExtendedAttribute.createName("corrupt"))); }
public String getCorruptNameFQN() { return corruptNameFQN; }
HashAttribute { public String getCorruptNameFQN() { return corruptNameFQN; } }
HashAttribute { public String getCorruptNameFQN() { return corruptNameFQN; } HashAttribute(String hashName); }
HashAttribute { public String getCorruptNameFQN() { return corruptNameFQN; } HashAttribute(String hashName); boolean areAttributesValid(Path path); long readHash(Path path); void writeHash(Path path, long hash); void markCorrupted(Path path); boolean isCorrupted(Path path); String getHashFQN(); String getTimestampFQN(); String getCorruptNameFQN(); }
HashAttribute { public String getCorruptNameFQN() { return corruptNameFQN; } HashAttribute(String hashName); boolean areAttributesValid(Path path); long readHash(Path path); void writeHash(Path path, long hash); void markCorrupted(Path path); boolean isCorrupted(Path path); String getHashFQN(); String getTimestampFQN(); String getCorruptNameFQN(); }
@Test public void testTrackPathMessageBody() throws Exception { ClientMessage result = cut.trackPath(PATH, UUID); long most = result.getBodyBuffer().readLong(); long least = result.getBodyBuffer().readLong(); assertThat(new UUID(most, least), is(UUID)); }
public ClientMessage trackPath(Path path, UUID uuid) { ClientMessage message = session.createMessage(false); setTaskType(message, TaskType.track); setPath(message, path); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); return message; }
MessageFactory { public ClientMessage trackPath(Path path, UUID uuid) { ClientMessage message = session.createMessage(false); setTaskType(message, TaskType.track); setPath(message, path); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); return message; } }
MessageFactory { public ClientMessage trackPath(Path path, UUID uuid) { ClientMessage message = session.createMessage(false); setTaskType(message, TaskType.track); setPath(message, path); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); return message; } MessageFactory(ClientSession session); }
MessageFactory { public ClientMessage trackPath(Path path, UUID uuid) { ClientMessage message = session.createMessage(false); setTaskType(message, TaskType.track); setPath(message, path); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
MessageFactory { public ClientMessage trackPath(Path path, UUID uuid) { ClientMessage message = session.createMessage(false); setTaskType(message, TaskType.track); setPath(message, path); message.getBodyBuffer().writeLong(uuid.getMostSignificantBits()); message.getBodyBuffer().writeLong(uuid.getLeastSignificantBits()); return message; } MessageFactory(ClientSession session); ClientMessage hashRequestMessage(byte[] resizedImage, UUID uuid); ClientMessage resultMessage(long hash, long most, long least); ClientMessage corruptMessage(Path path); ClientMessage pendingImageQuery(); ClientMessage pendingImageResponse(List<PendingHashImage> pendingImages); ClientMessage trackPath(Path path, UUID uuid); ClientMessage eaUpdate(Path path, long hash); ClientMessage resizeRequest(Path path, InputStream is); }
@Test public void testOnDrainInTransaction() throws Exception { cut.onDrain(messages); verify(transactionManager).callInTransaction(any()); }
@Override public void onDrain(List<ClientMessage> messages) { try { transactionManager.callInTransaction(new Callable<Void>() { @Override public Void call() throws Exception { onCall(messages); return null; } }); } catch (SQLException e) { LOGGER.warn("Failed to store {} messages: {}", messages.size(), e.toString(), e.getCause()); try { session.rollback(); } catch (ActiveMQException mqException) { String message = "Failed to rollback message transaction"; LOGGER.error(message, mqException); throw new RuntimeException(message, mqException); } } }
QueueToDatabaseTransaction implements CollectedMessageConsumer { @Override public void onDrain(List<ClientMessage> messages) { try { transactionManager.callInTransaction(new Callable<Void>() { @Override public Void call() throws Exception { onCall(messages); return null; } }); } catch (SQLException e) { LOGGER.warn("Failed to store {} messages: {}", messages.size(), e.toString(), e.getCause()); try { session.rollback(); } catch (ActiveMQException mqException) { String message = "Failed to rollback message transaction"; LOGGER.error(message, mqException); throw new RuntimeException(message, mqException); } } } }
QueueToDatabaseTransaction implements CollectedMessageConsumer { @Override public void onDrain(List<ClientMessage> messages) { try { transactionManager.callInTransaction(new Callable<Void>() { @Override public Void call() throws Exception { onCall(messages); return null; } }); } catch (SQLException e) { LOGGER.warn("Failed to store {} messages: {}", messages.size(), e.toString(), e.getCause()); try { session.rollback(); } catch (ActiveMQException mqException) { String message = "Failed to rollback message transaction"; LOGGER.error(message, mqException); throw new RuntimeException(message, mqException); } } } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { @Override public void onDrain(List<ClientMessage> messages) { try { transactionManager.callInTransaction(new Callable<Void>() { @Override public Void call() throws Exception { onCall(messages); return null; } }); } catch (SQLException e) { LOGGER.warn("Failed to store {} messages: {}", messages.size(), e.toString(), e.getCause()); try { session.rollback(); } catch (ActiveMQException mqException) { String message = "Failed to rollback message transaction"; LOGGER.error(message, mqException); throw new RuntimeException(message, mqException); } } } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Override void onDrain(List<ClientMessage> messages); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { @Override public void onDrain(List<ClientMessage> messages) { try { transactionManager.callInTransaction(new Callable<Void>() { @Override public Void call() throws Exception { onCall(messages); return null; } }); } catch (SQLException e) { LOGGER.warn("Failed to store {} messages: {}", messages.size(), e.toString(), e.getCause()); try { session.rollback(); } catch (ActiveMQException mqException) { String message = "Failed to rollback message transaction"; LOGGER.error(message, mqException); throw new RuntimeException(message, mqException); } } } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Override void onDrain(List<ClientMessage> messages); static final String METRIC_NAME_PENDING_MESSAGES_MISSING; static final String METRIC_NAME_PENDING_MESSAGES; static final String METRIC_NAME_PROCESSED_IMAGES; }
@Test public void testMessageRollbackOnDatabaseFailure() throws Exception { when(transactionManager.callInTransaction(any())) .thenThrow(new SQLException(EXCEPTION_MESSAGE)); cut.onDrain(messages); verify(session).rollback(); }
@Override public void onDrain(List<ClientMessage> messages) { try { transactionManager.callInTransaction(new Callable<Void>() { @Override public Void call() throws Exception { onCall(messages); return null; } }); } catch (SQLException e) { LOGGER.warn("Failed to store {} messages: {}", messages.size(), e.toString(), e.getCause()); try { session.rollback(); } catch (ActiveMQException mqException) { String message = "Failed to rollback message transaction"; LOGGER.error(message, mqException); throw new RuntimeException(message, mqException); } } }
QueueToDatabaseTransaction implements CollectedMessageConsumer { @Override public void onDrain(List<ClientMessage> messages) { try { transactionManager.callInTransaction(new Callable<Void>() { @Override public Void call() throws Exception { onCall(messages); return null; } }); } catch (SQLException e) { LOGGER.warn("Failed to store {} messages: {}", messages.size(), e.toString(), e.getCause()); try { session.rollback(); } catch (ActiveMQException mqException) { String message = "Failed to rollback message transaction"; LOGGER.error(message, mqException); throw new RuntimeException(message, mqException); } } } }
QueueToDatabaseTransaction implements CollectedMessageConsumer { @Override public void onDrain(List<ClientMessage> messages) { try { transactionManager.callInTransaction(new Callable<Void>() { @Override public Void call() throws Exception { onCall(messages); return null; } }); } catch (SQLException e) { LOGGER.warn("Failed to store {} messages: {}", messages.size(), e.toString(), e.getCause()); try { session.rollback(); } catch (ActiveMQException mqException) { String message = "Failed to rollback message transaction"; LOGGER.error(message, mqException); throw new RuntimeException(message, mqException); } } } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { @Override public void onDrain(List<ClientMessage> messages) { try { transactionManager.callInTransaction(new Callable<Void>() { @Override public Void call() throws Exception { onCall(messages); return null; } }); } catch (SQLException e) { LOGGER.warn("Failed to store {} messages: {}", messages.size(), e.toString(), e.getCause()); try { session.rollback(); } catch (ActiveMQException mqException) { String message = "Failed to rollback message transaction"; LOGGER.error(message, mqException); throw new RuntimeException(message, mqException); } } } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Override void onDrain(List<ClientMessage> messages); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { @Override public void onDrain(List<ClientMessage> messages) { try { transactionManager.callInTransaction(new Callable<Void>() { @Override public Void call() throws Exception { onCall(messages); return null; } }); } catch (SQLException e) { LOGGER.warn("Failed to store {} messages: {}", messages.size(), e.toString(), e.getCause()); try { session.rollback(); } catch (ActiveMQException mqException) { String message = "Failed to rollback message transaction"; LOGGER.error(message, mqException); throw new RuntimeException(message, mqException); } } } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Override void onDrain(List<ClientMessage> messages); static final String METRIC_NAME_PENDING_MESSAGES_MISSING; static final String METRIC_NAME_PENDING_MESSAGES; static final String METRIC_NAME_PROCESSED_IMAGES; }
@Test(expected = RuntimeException.class) public void testMessageRollbackFailure() throws Exception { when(transactionManager.callInTransaction(any())).thenThrow(new SQLException(EXCEPTION_MESSAGE)); Mockito.doThrow(new ActiveMQException()).when(session).rollback(); cut.onDrain(messages); }
@Override public void onDrain(List<ClientMessage> messages) { try { transactionManager.callInTransaction(new Callable<Void>() { @Override public Void call() throws Exception { onCall(messages); return null; } }); } catch (SQLException e) { LOGGER.warn("Failed to store {} messages: {}", messages.size(), e.toString(), e.getCause()); try { session.rollback(); } catch (ActiveMQException mqException) { String message = "Failed to rollback message transaction"; LOGGER.error(message, mqException); throw new RuntimeException(message, mqException); } } }
QueueToDatabaseTransaction implements CollectedMessageConsumer { @Override public void onDrain(List<ClientMessage> messages) { try { transactionManager.callInTransaction(new Callable<Void>() { @Override public Void call() throws Exception { onCall(messages); return null; } }); } catch (SQLException e) { LOGGER.warn("Failed to store {} messages: {}", messages.size(), e.toString(), e.getCause()); try { session.rollback(); } catch (ActiveMQException mqException) { String message = "Failed to rollback message transaction"; LOGGER.error(message, mqException); throw new RuntimeException(message, mqException); } } } }
QueueToDatabaseTransaction implements CollectedMessageConsumer { @Override public void onDrain(List<ClientMessage> messages) { try { transactionManager.callInTransaction(new Callable<Void>() { @Override public Void call() throws Exception { onCall(messages); return null; } }); } catch (SQLException e) { LOGGER.warn("Failed to store {} messages: {}", messages.size(), e.toString(), e.getCause()); try { session.rollback(); } catch (ActiveMQException mqException) { String message = "Failed to rollback message transaction"; LOGGER.error(message, mqException); throw new RuntimeException(message, mqException); } } } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { @Override public void onDrain(List<ClientMessage> messages) { try { transactionManager.callInTransaction(new Callable<Void>() { @Override public Void call() throws Exception { onCall(messages); return null; } }); } catch (SQLException e) { LOGGER.warn("Failed to store {} messages: {}", messages.size(), e.toString(), e.getCause()); try { session.rollback(); } catch (ActiveMQException mqException) { String message = "Failed to rollback message transaction"; LOGGER.error(message, mqException); throw new RuntimeException(message, mqException); } } } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Override void onDrain(List<ClientMessage> messages); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { @Override public void onDrain(List<ClientMessage> messages) { try { transactionManager.callInTransaction(new Callable<Void>() { @Override public Void call() throws Exception { onCall(messages); return null; } }); } catch (SQLException e) { LOGGER.warn("Failed to store {} messages: {}", messages.size(), e.toString(), e.getCause()); try { session.rollback(); } catch (ActiveMQException mqException) { String message = "Failed to rollback message transaction"; LOGGER.error(message, mqException); throw new RuntimeException(message, mqException); } } } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Override void onDrain(List<ClientMessage> messages); static final String METRIC_NAME_PENDING_MESSAGES_MISSING; static final String METRIC_NAME_PENDING_MESSAGES; static final String METRIC_NAME_PROCESSED_IMAGES; }
@Test public void testOnCallMessageAcknowledge() throws Exception { cut.onCall(messages); verify(message, times(TEST_MESSAGE_SIZE)).acknowledge(); }
protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Override void onDrain(List<ClientMessage> messages); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Override void onDrain(List<ClientMessage> messages); static final String METRIC_NAME_PENDING_MESSAGES_MISSING; static final String METRIC_NAME_PENDING_MESSAGES; static final String METRIC_NAME_PROCESSED_IMAGES; }
@Test public void testOnCallPendingQuery() throws Exception { cut.onCall(messages); verify(pendingRepository).getByUUID(UUID_MOST, UUID_LEAST); }
protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Override void onDrain(List<ClientMessage> messages); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Override void onDrain(List<ClientMessage> messages); static final String METRIC_NAME_PENDING_MESSAGES_MISSING; static final String METRIC_NAME_PENDING_MESSAGES; static final String METRIC_NAME_PROCESSED_IMAGES; }
@Test public void testOnCallPendingMessageMissing() throws Exception { when(pendingRepository.getByUUID(UUID_MOST, UUID_LEAST)).thenReturn(null); cut.onCall(messages); assertThat( metrics.getCounters().get(QueueToDatabaseTransaction.METRIC_NAME_PENDING_MESSAGES_MISSING).getCount(), is((long) TEST_MESSAGE_SIZE)); }
protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Override void onDrain(List<ClientMessage> messages); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Override void onDrain(List<ClientMessage> messages); static final String METRIC_NAME_PENDING_MESSAGES_MISSING; static final String METRIC_NAME_PENDING_MESSAGES; static final String METRIC_NAME_PROCESSED_IMAGES; }
@Test public void testOnCallPendingMessagesDecrement() throws Exception { cut.onCall(messages); assertThat(metrics.getCounters().get(QueueToDatabaseTransaction.METRIC_NAME_PENDING_MESSAGES).getCount(), is(-1L)); }
protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Override void onDrain(List<ClientMessage> messages); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Override void onDrain(List<ClientMessage> messages); static final String METRIC_NAME_PENDING_MESSAGES_MISSING; static final String METRIC_NAME_PENDING_MESSAGES; static final String METRIC_NAME_PROCESSED_IMAGES; }
@Test public void testOnCallProcessedMessagesIncrement() throws Exception { cut.onCall(messages); assertThat(metrics.getMeters().get(QueueToDatabaseTransaction.METRIC_NAME_PROCESSED_IMAGES).getCount(), is(1L)); }
protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Override void onDrain(List<ClientMessage> messages); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Override void onDrain(List<ClientMessage> messages); static final String METRIC_NAME_PENDING_MESSAGES_MISSING; static final String METRIC_NAME_PENDING_MESSAGES; static final String METRIC_NAME_PROCESSED_IMAGES; }
@Test public void testOnCallResultStored() throws Exception { cut.onCall(messages); verify(imageRepository).store(eq(new ImageRecord(PATH, HASH))); }
protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Override void onDrain(List<ClientMessage> messages); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Override void onDrain(List<ClientMessage> messages); static final String METRIC_NAME_PENDING_MESSAGES_MISSING; static final String METRIC_NAME_PENDING_MESSAGES; static final String METRIC_NAME_PROCESSED_IMAGES; }
@Test public void testIsCorruptedNotSet() throws Exception { assertThat(cut.isCorrupted(tempFile), is(false)); }
public boolean isCorrupted(Path path) throws IOException { return ExtendedAttribute.isExtendedAttributeSet(path, corruptNameFQN); }
HashAttribute { public boolean isCorrupted(Path path) throws IOException { return ExtendedAttribute.isExtendedAttributeSet(path, corruptNameFQN); } }
HashAttribute { public boolean isCorrupted(Path path) throws IOException { return ExtendedAttribute.isExtendedAttributeSet(path, corruptNameFQN); } HashAttribute(String hashName); }
HashAttribute { public boolean isCorrupted(Path path) throws IOException { return ExtendedAttribute.isExtendedAttributeSet(path, corruptNameFQN); } HashAttribute(String hashName); boolean areAttributesValid(Path path); long readHash(Path path); void writeHash(Path path, long hash); void markCorrupted(Path path); boolean isCorrupted(Path path); String getHashFQN(); String getTimestampFQN(); String getCorruptNameFQN(); }
HashAttribute { public boolean isCorrupted(Path path) throws IOException { return ExtendedAttribute.isExtendedAttributeSet(path, corruptNameFQN); } HashAttribute(String hashName); boolean areAttributesValid(Path path); long readHash(Path path); void writeHash(Path path, long hash); void markCorrupted(Path path); boolean isCorrupted(Path path); String getHashFQN(); String getTimestampFQN(); String getCorruptNameFQN(); }
@Test public void testOnCallPendingRemoved() throws Exception { cut.onCall(messages); verify(pendingRepository).remove(new PendingHashImage(PATH, UUID_MOST, UUID_LEAST)); }
protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Override void onDrain(List<ClientMessage> messages); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Override void onDrain(List<ClientMessage> messages); static final String METRIC_NAME_PENDING_MESSAGES_MISSING; static final String METRIC_NAME_PENDING_MESSAGES; static final String METRIC_NAME_PROCESSED_IMAGES; }
@Test public void testOnCallEAupdateSent() throws Exception { cut.onCall(messages); verify(producer).send(sendMessage); }
protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Override void onDrain(List<ClientMessage> messages); }
QueueToDatabaseTransaction implements CollectedMessageConsumer { protected void onCall(List<ClientMessage> messages) throws RepositoryException, ActiveMQException { for (ClientMessage message : messages) { processMessage(message); message.acknowledge(); } session.commit(); } QueueToDatabaseTransaction(ClientSession transactedSession, TransactionManager transactionManager, String eaQueueName, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Inject QueueToDatabaseTransaction(@Named("transacted") ClientSession transactedSession, TransactionManager transactionManager, PendingHashImageRepository pendingRepository, ImageRepository imageRepository, MetricRegistry metrics); @Override void onDrain(List<ClientMessage> messages); static final String METRIC_NAME_PENDING_MESSAGES_MISSING; static final String METRIC_NAME_PENDING_MESSAGES; static final String METRIC_NAME_PROCESSED_IMAGES; }
@Test public void testValidImageNotCorrupt() throws Exception { producer.send(message); await().atMost(MESSAGE_TIMEOUT).until(hashRequests::size, is(1)); ClientMessage response = hashRequests.get(0); assertThat(response.containsProperty(MessageProperty.task.toString()), is(false)); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); @Override void onMessage(ClientMessage message); @Override void stop(); @Override String toString(); }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); @Override void onMessage(ClientMessage message); @Override void stop(); @Override String toString(); static final String METRIC_NAME_RESIZE_MESSAGES; static final String METRIC_NAME_RESIZE_DURATION; static final String METRIC_NAME_PENDING_CACHE_HIT; static final String METRIC_NAME_PENDING_CACHE_MISS; static final String METRIC_NAME_IMAGE_SIZE; static final String METRIC_NAME_BUFFER_RESIZE; }
@Test public void testValidImageTrackSent() throws Exception { producer.send(message); await().atMost(MESSAGE_TIMEOUT).until(results::size, is(1)); ClientMessage response = results.get(0); assertThat(response.getStringProperty(MessageProperty.task.toString()), is(TaskType.track.toString())); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); @Override void onMessage(ClientMessage message); @Override void stop(); @Override String toString(); }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); @Override void onMessage(ClientMessage message); @Override void stop(); @Override String toString(); static final String METRIC_NAME_RESIZE_MESSAGES; static final String METRIC_NAME_RESIZE_DURATION; static final String METRIC_NAME_PENDING_CACHE_HIT; static final String METRIC_NAME_PENDING_CACHE_MISS; static final String METRIC_NAME_IMAGE_SIZE; static final String METRIC_NAME_BUFFER_RESIZE; }
@Test public void testCorruptImageDataTaskProperty() throws Exception { when(resizer.resize(nullable(BufferedImage.class))).thenThrow(new IIOException("")); producer.send(message); await().atMost(MESSAGE_TIMEOUT).until(eaUpdates::size, is(1)); ClientMessage response = eaUpdates.get(0); assertThat(response.getStringProperty(MessageProperty.task.toString()), is(TaskType.corr.toString())); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); @Override void onMessage(ClientMessage message); @Override void stop(); @Override String toString(); }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); @Override void onMessage(ClientMessage message); @Override void stop(); @Override String toString(); static final String METRIC_NAME_RESIZE_MESSAGES; static final String METRIC_NAME_RESIZE_DURATION; static final String METRIC_NAME_PENDING_CACHE_HIT; static final String METRIC_NAME_PENDING_CACHE_MISS; static final String METRIC_NAME_IMAGE_SIZE; static final String METRIC_NAME_BUFFER_RESIZE; }
@Test public void testCorruptImageDataPathProperty() throws Exception { when(resizer.resize(nullable(BufferedImage.class))).thenThrow(new IIOException("")); producer.send(message); await().atMost(MESSAGE_TIMEOUT).until(eaUpdates::size, is(1)); ClientMessage response = eaUpdates.get(0); assertThat(response.getStringProperty(MessageProperty.path.toString()), is(PATH_NEW)); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); @Override void onMessage(ClientMessage message); @Override void stop(); @Override String toString(); }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); @Override void onMessage(ClientMessage message); @Override void stop(); @Override String toString(); static final String METRIC_NAME_RESIZE_MESSAGES; static final String METRIC_NAME_RESIZE_DURATION; static final String METRIC_NAME_PENDING_CACHE_HIT; static final String METRIC_NAME_PENDING_CACHE_MISS; static final String METRIC_NAME_IMAGE_SIZE; static final String METRIC_NAME_BUFFER_RESIZE; }
@Test public void testGIFerrorUnknownBlock() throws Exception { when(resizer.resize(nullable(BufferedImage.class))).thenThrow(new IOException("Unknown block")); producer.send(message); await().atMost(MESSAGE_TIMEOUT).until(eaUpdates::size, is(1)); ClientMessage response = eaUpdates.get(0); assertThat(response.getStringProperty(MessageProperty.task.toString()), is(TaskType.corr.toString())); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); @Override void onMessage(ClientMessage message); @Override void stop(); @Override String toString(); }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); @Override void onMessage(ClientMessage message); @Override void stop(); @Override String toString(); static final String METRIC_NAME_RESIZE_MESSAGES; static final String METRIC_NAME_RESIZE_DURATION; static final String METRIC_NAME_PENDING_CACHE_HIT; static final String METRIC_NAME_PENDING_CACHE_MISS; static final String METRIC_NAME_IMAGE_SIZE; static final String METRIC_NAME_BUFFER_RESIZE; }
@Test public void testGIFerrorInvalidHeader() throws Exception { when(resizer.resize(nullable(BufferedImage.class))).thenThrow(new IOException("Invalid GIF header")); producer.send(message); await().atMost(MESSAGE_TIMEOUT).until(eaUpdates::size, is(1)); ClientMessage response = eaUpdates.get(0); assertThat(response.getStringProperty(MessageProperty.task.toString()), is(TaskType.corr.toString())); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); @Override void onMessage(ClientMessage message); @Override void stop(); @Override String toString(); }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); @Override void onMessage(ClientMessage message); @Override void stop(); @Override String toString(); static final String METRIC_NAME_RESIZE_MESSAGES; static final String METRIC_NAME_RESIZE_DURATION; static final String METRIC_NAME_PENDING_CACHE_HIT; static final String METRIC_NAME_PENDING_CACHE_MISS; static final String METRIC_NAME_IMAGE_SIZE; static final String METRIC_NAME_BUFFER_RESIZE; }
@Test public void testBufferResize() throws Exception { for (byte i = 0; i < BUFFER_TEST_DATA_SIZE; i++) { message.getBodyBuffer().writeByte(i); } cut.allocateNewBuffer(1); producer.send(message); await().atMost(MESSAGE_TIMEOUT).until(() -> metrics.getCounters().get(ResizerNode.METRIC_NAME_BUFFER_RESIZE).getCount(), is(1L)); }
protected void allocateNewBuffer(int messageSize) { messageBuffer = ByteBuffer.allocateDirect(calcNewBufferSize(messageSize)); }
ResizerNode implements MessageHandler, Node { protected void allocateNewBuffer(int messageSize) { messageBuffer = ByteBuffer.allocateDirect(calcNewBufferSize(messageSize)); } }
ResizerNode implements MessageHandler, Node { protected void allocateNewBuffer(int messageSize) { messageBuffer = ByteBuffer.allocateDirect(calcNewBufferSize(messageSize)); } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); }
ResizerNode implements MessageHandler, Node { protected void allocateNewBuffer(int messageSize) { messageBuffer = ByteBuffer.allocateDirect(calcNewBufferSize(messageSize)); } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); @Override void onMessage(ClientMessage message); @Override void stop(); @Override String toString(); }
ResizerNode implements MessageHandler, Node { protected void allocateNewBuffer(int messageSize) { messageBuffer = ByteBuffer.allocateDirect(calcNewBufferSize(messageSize)); } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); @Override void onMessage(ClientMessage message); @Override void stop(); @Override String toString(); static final String METRIC_NAME_RESIZE_MESSAGES; static final String METRIC_NAME_RESIZE_DURATION; static final String METRIC_NAME_PENDING_CACHE_HIT; static final String METRIC_NAME_PENDING_CACHE_MISS; static final String METRIC_NAME_IMAGE_SIZE; static final String METRIC_NAME_BUFFER_RESIZE; }
@Test public void testImageSizeHistogramCount() throws Exception { message = new MessageFactory(session).resizeRequest(Paths.get(PATH_NEW), is); for (byte i = 0; i < BUFFER_TEST_DATA_SIZE; i++) { message.getBodyBuffer().writeByte(i); } cut.onMessage(message); assertThat(metrics.getHistograms().get(ResizerNode.METRIC_NAME_IMAGE_SIZE).getCount(), is(1L)); }
@Override public void onMessage(ClientMessage message) { String pathPropterty = null; resizeRequests.mark(); Context resizeTimeContext = resizeDuration.time(); try { pathPropterty = message.getStringProperty(MessageProperty.path.toString()); LOGGER.debug("Resize request for image {}", pathPropterty); if (pendingCache.getIfPresent(pathPropterty) != null) { LOGGER.trace("{} found in cache, skipping...", pathPropterty); pendingCacheHit.mark(); return; } else { pendingCacheMiss.mark(); } checkBufferCapacity(message.getBodySize()); messageBuffer.limit(message.getBodySize()); imageSize.update(message.getBodySize()); messageBuffer.rewind(); message.getBodyBuffer().readBytes(messageBuffer); messageBuffer.rewind(); Path path = Paths.get(pathPropterty); Path filename = path.getFileName(); InputStream is = new ByteBufferInputstream(messageBuffer); if (filename != null && filename.toString().toLowerCase().endsWith(".gif")) { GifImage gi = GifDecoder.read(is); is = new ByteArrayInputStream(ImageUtil.imageToBytes(gi.getFrame(0))); } BufferedImage originalImage = ImageIO.read(is); byte[] resizedImageData = resizer.resize(originalImage); UUID uuid = UUID.randomUUID(); ClientMessage trackMessage = messageFactory.trackPath(path, uuid); producer.send(QueueAddress.RESULT.toString(), trackMessage); LOGGER.trace("Sent tracking message for {} with UUID {}", pathPropterty, uuid); ClientMessage response = messageFactory.hashRequestMessage(resizedImageData, uuid); LOGGER.trace("Sending hash request with id {} instead of path {}", uuid, path); producer.send(response); pendingCache.put(pathPropterty, DUMMY); resizeTimeContext.stop(); } catch (ActiveMQException e) { LOGGER.error("Failed to send message: {}", e.toString()); } catch (IIOException | ArrayIndexOutOfBoundsException ie) { markImageCorrupt(pathPropterty); } catch (IOException e) { if (isImageError(e.getMessage())) { markImageCorrupt(pathPropterty); } else { LOGGER.error("Failed to process image: {}", e.toString()); } } catch (Exception e) { LOGGER.error("Unhandled exception: {}", e.toString()); LOGGER.debug("", e); } }
ResizerNode implements MessageHandler, Node { @Override public void onMessage(ClientMessage message) { String pathPropterty = null; resizeRequests.mark(); Context resizeTimeContext = resizeDuration.time(); try { pathPropterty = message.getStringProperty(MessageProperty.path.toString()); LOGGER.debug("Resize request for image {}", pathPropterty); if (pendingCache.getIfPresent(pathPropterty) != null) { LOGGER.trace("{} found in cache, skipping...", pathPropterty); pendingCacheHit.mark(); return; } else { pendingCacheMiss.mark(); } checkBufferCapacity(message.getBodySize()); messageBuffer.limit(message.getBodySize()); imageSize.update(message.getBodySize()); messageBuffer.rewind(); message.getBodyBuffer().readBytes(messageBuffer); messageBuffer.rewind(); Path path = Paths.get(pathPropterty); Path filename = path.getFileName(); InputStream is = new ByteBufferInputstream(messageBuffer); if (filename != null && filename.toString().toLowerCase().endsWith(".gif")) { GifImage gi = GifDecoder.read(is); is = new ByteArrayInputStream(ImageUtil.imageToBytes(gi.getFrame(0))); } BufferedImage originalImage = ImageIO.read(is); byte[] resizedImageData = resizer.resize(originalImage); UUID uuid = UUID.randomUUID(); ClientMessage trackMessage = messageFactory.trackPath(path, uuid); producer.send(QueueAddress.RESULT.toString(), trackMessage); LOGGER.trace("Sent tracking message for {} with UUID {}", pathPropterty, uuid); ClientMessage response = messageFactory.hashRequestMessage(resizedImageData, uuid); LOGGER.trace("Sending hash request with id {} instead of path {}", uuid, path); producer.send(response); pendingCache.put(pathPropterty, DUMMY); resizeTimeContext.stop(); } catch (ActiveMQException e) { LOGGER.error("Failed to send message: {}", e.toString()); } catch (IIOException | ArrayIndexOutOfBoundsException ie) { markImageCorrupt(pathPropterty); } catch (IOException e) { if (isImageError(e.getMessage())) { markImageCorrupt(pathPropterty); } else { LOGGER.error("Failed to process image: {}", e.toString()); } } catch (Exception e) { LOGGER.error("Unhandled exception: {}", e.toString()); LOGGER.debug("", e); } } }
ResizerNode implements MessageHandler, Node { @Override public void onMessage(ClientMessage message) { String pathPropterty = null; resizeRequests.mark(); Context resizeTimeContext = resizeDuration.time(); try { pathPropterty = message.getStringProperty(MessageProperty.path.toString()); LOGGER.debug("Resize request for image {}", pathPropterty); if (pendingCache.getIfPresent(pathPropterty) != null) { LOGGER.trace("{} found in cache, skipping...", pathPropterty); pendingCacheHit.mark(); return; } else { pendingCacheMiss.mark(); } checkBufferCapacity(message.getBodySize()); messageBuffer.limit(message.getBodySize()); imageSize.update(message.getBodySize()); messageBuffer.rewind(); message.getBodyBuffer().readBytes(messageBuffer); messageBuffer.rewind(); Path path = Paths.get(pathPropterty); Path filename = path.getFileName(); InputStream is = new ByteBufferInputstream(messageBuffer); if (filename != null && filename.toString().toLowerCase().endsWith(".gif")) { GifImage gi = GifDecoder.read(is); is = new ByteArrayInputStream(ImageUtil.imageToBytes(gi.getFrame(0))); } BufferedImage originalImage = ImageIO.read(is); byte[] resizedImageData = resizer.resize(originalImage); UUID uuid = UUID.randomUUID(); ClientMessage trackMessage = messageFactory.trackPath(path, uuid); producer.send(QueueAddress.RESULT.toString(), trackMessage); LOGGER.trace("Sent tracking message for {} with UUID {}", pathPropterty, uuid); ClientMessage response = messageFactory.hashRequestMessage(resizedImageData, uuid); LOGGER.trace("Sending hash request with id {} instead of path {}", uuid, path); producer.send(response); pendingCache.put(pathPropterty, DUMMY); resizeTimeContext.stop(); } catch (ActiveMQException e) { LOGGER.error("Failed to send message: {}", e.toString()); } catch (IIOException | ArrayIndexOutOfBoundsException ie) { markImageCorrupt(pathPropterty); } catch (IOException e) { if (isImageError(e.getMessage())) { markImageCorrupt(pathPropterty); } else { LOGGER.error("Failed to process image: {}", e.toString()); } } catch (Exception e) { LOGGER.error("Unhandled exception: {}", e.toString()); LOGGER.debug("", e); } } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); }
ResizerNode implements MessageHandler, Node { @Override public void onMessage(ClientMessage message) { String pathPropterty = null; resizeRequests.mark(); Context resizeTimeContext = resizeDuration.time(); try { pathPropterty = message.getStringProperty(MessageProperty.path.toString()); LOGGER.debug("Resize request for image {}", pathPropterty); if (pendingCache.getIfPresent(pathPropterty) != null) { LOGGER.trace("{} found in cache, skipping...", pathPropterty); pendingCacheHit.mark(); return; } else { pendingCacheMiss.mark(); } checkBufferCapacity(message.getBodySize()); messageBuffer.limit(message.getBodySize()); imageSize.update(message.getBodySize()); messageBuffer.rewind(); message.getBodyBuffer().readBytes(messageBuffer); messageBuffer.rewind(); Path path = Paths.get(pathPropterty); Path filename = path.getFileName(); InputStream is = new ByteBufferInputstream(messageBuffer); if (filename != null && filename.toString().toLowerCase().endsWith(".gif")) { GifImage gi = GifDecoder.read(is); is = new ByteArrayInputStream(ImageUtil.imageToBytes(gi.getFrame(0))); } BufferedImage originalImage = ImageIO.read(is); byte[] resizedImageData = resizer.resize(originalImage); UUID uuid = UUID.randomUUID(); ClientMessage trackMessage = messageFactory.trackPath(path, uuid); producer.send(QueueAddress.RESULT.toString(), trackMessage); LOGGER.trace("Sent tracking message for {} with UUID {}", pathPropterty, uuid); ClientMessage response = messageFactory.hashRequestMessage(resizedImageData, uuid); LOGGER.trace("Sending hash request with id {} instead of path {}", uuid, path); producer.send(response); pendingCache.put(pathPropterty, DUMMY); resizeTimeContext.stop(); } catch (ActiveMQException e) { LOGGER.error("Failed to send message: {}", e.toString()); } catch (IIOException | ArrayIndexOutOfBoundsException ie) { markImageCorrupt(pathPropterty); } catch (IOException e) { if (isImageError(e.getMessage())) { markImageCorrupt(pathPropterty); } else { LOGGER.error("Failed to process image: {}", e.toString()); } } catch (Exception e) { LOGGER.error("Unhandled exception: {}", e.toString()); LOGGER.debug("", e); } } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); @Override void onMessage(ClientMessage message); @Override void stop(); @Override String toString(); }
ResizerNode implements MessageHandler, Node { @Override public void onMessage(ClientMessage message) { String pathPropterty = null; resizeRequests.mark(); Context resizeTimeContext = resizeDuration.time(); try { pathPropterty = message.getStringProperty(MessageProperty.path.toString()); LOGGER.debug("Resize request for image {}", pathPropterty); if (pendingCache.getIfPresent(pathPropterty) != null) { LOGGER.trace("{} found in cache, skipping...", pathPropterty); pendingCacheHit.mark(); return; } else { pendingCacheMiss.mark(); } checkBufferCapacity(message.getBodySize()); messageBuffer.limit(message.getBodySize()); imageSize.update(message.getBodySize()); messageBuffer.rewind(); message.getBodyBuffer().readBytes(messageBuffer); messageBuffer.rewind(); Path path = Paths.get(pathPropterty); Path filename = path.getFileName(); InputStream is = new ByteBufferInputstream(messageBuffer); if (filename != null && filename.toString().toLowerCase().endsWith(".gif")) { GifImage gi = GifDecoder.read(is); is = new ByteArrayInputStream(ImageUtil.imageToBytes(gi.getFrame(0))); } BufferedImage originalImage = ImageIO.read(is); byte[] resizedImageData = resizer.resize(originalImage); UUID uuid = UUID.randomUUID(); ClientMessage trackMessage = messageFactory.trackPath(path, uuid); producer.send(QueueAddress.RESULT.toString(), trackMessage); LOGGER.trace("Sent tracking message for {} with UUID {}", pathPropterty, uuid); ClientMessage response = messageFactory.hashRequestMessage(resizedImageData, uuid); LOGGER.trace("Sending hash request with id {} instead of path {}", uuid, path); producer.send(response); pendingCache.put(pathPropterty, DUMMY); resizeTimeContext.stop(); } catch (ActiveMQException e) { LOGGER.error("Failed to send message: {}", e.toString()); } catch (IIOException | ArrayIndexOutOfBoundsException ie) { markImageCorrupt(pathPropterty); } catch (IOException e) { if (isImageError(e.getMessage())) { markImageCorrupt(pathPropterty); } else { LOGGER.error("Failed to process image: {}", e.toString()); } } catch (Exception e) { LOGGER.error("Unhandled exception: {}", e.toString()); LOGGER.debug("", e); } } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); @Override void onMessage(ClientMessage message); @Override void stop(); @Override String toString(); static final String METRIC_NAME_RESIZE_MESSAGES; static final String METRIC_NAME_RESIZE_DURATION; static final String METRIC_NAME_PENDING_CACHE_HIT; static final String METRIC_NAME_PENDING_CACHE_MISS; static final String METRIC_NAME_IMAGE_SIZE; static final String METRIC_NAME_BUFFER_RESIZE; }
@Test public void testReadFirstByte() throws Exception { assertThat(input.read(), is(2)); }
@Override public int read() throws IOException { if (buffer.hasRemaining()) { return buffer.get() & 0xFF; } else { return -1; } }
ByteBufferInputstream extends InputStream { @Override public int read() throws IOException { if (buffer.hasRemaining()) { return buffer.get() & 0xFF; } else { return -1; } } }
ByteBufferInputstream extends InputStream { @Override public int read() throws IOException { if (buffer.hasRemaining()) { return buffer.get() & 0xFF; } else { return -1; } } ByteBufferInputstream(ByteBuffer buffer); }
ByteBufferInputstream extends InputStream { @Override public int read() throws IOException { if (buffer.hasRemaining()) { return buffer.get() & 0xFF; } else { return -1; } } ByteBufferInputstream(ByteBuffer buffer); @Override int read(); @Override int available(); }
ByteBufferInputstream extends InputStream { @Override public int read() throws IOException { if (buffer.hasRemaining()) { return buffer.get() & 0xFF; } else { return -1; } } ByteBufferInputstream(ByteBuffer buffer); @Override int read(); @Override int available(); }
@Test public void testImageSizeHistogramSize() throws Exception { message = new MessageFactory(session).resizeRequest(Paths.get(PATH_NEW), is); for (byte i = 0; i < BUFFER_TEST_DATA_SIZE; i++) { message.getBodyBuffer().writeByte(i); } cut.onMessage(message); assertThat(metrics.getHistograms().get(ResizerNode.METRIC_NAME_IMAGE_SIZE).getSnapshot().getMean(), is((double) BUFFER_TEST_DATA_SIZE)); }
@Override public void onMessage(ClientMessage message) { String pathPropterty = null; resizeRequests.mark(); Context resizeTimeContext = resizeDuration.time(); try { pathPropterty = message.getStringProperty(MessageProperty.path.toString()); LOGGER.debug("Resize request for image {}", pathPropterty); if (pendingCache.getIfPresent(pathPropterty) != null) { LOGGER.trace("{} found in cache, skipping...", pathPropterty); pendingCacheHit.mark(); return; } else { pendingCacheMiss.mark(); } checkBufferCapacity(message.getBodySize()); messageBuffer.limit(message.getBodySize()); imageSize.update(message.getBodySize()); messageBuffer.rewind(); message.getBodyBuffer().readBytes(messageBuffer); messageBuffer.rewind(); Path path = Paths.get(pathPropterty); Path filename = path.getFileName(); InputStream is = new ByteBufferInputstream(messageBuffer); if (filename != null && filename.toString().toLowerCase().endsWith(".gif")) { GifImage gi = GifDecoder.read(is); is = new ByteArrayInputStream(ImageUtil.imageToBytes(gi.getFrame(0))); } BufferedImage originalImage = ImageIO.read(is); byte[] resizedImageData = resizer.resize(originalImage); UUID uuid = UUID.randomUUID(); ClientMessage trackMessage = messageFactory.trackPath(path, uuid); producer.send(QueueAddress.RESULT.toString(), trackMessage); LOGGER.trace("Sent tracking message for {} with UUID {}", pathPropterty, uuid); ClientMessage response = messageFactory.hashRequestMessage(resizedImageData, uuid); LOGGER.trace("Sending hash request with id {} instead of path {}", uuid, path); producer.send(response); pendingCache.put(pathPropterty, DUMMY); resizeTimeContext.stop(); } catch (ActiveMQException e) { LOGGER.error("Failed to send message: {}", e.toString()); } catch (IIOException | ArrayIndexOutOfBoundsException ie) { markImageCorrupt(pathPropterty); } catch (IOException e) { if (isImageError(e.getMessage())) { markImageCorrupt(pathPropterty); } else { LOGGER.error("Failed to process image: {}", e.toString()); } } catch (Exception e) { LOGGER.error("Unhandled exception: {}", e.toString()); LOGGER.debug("", e); } }
ResizerNode implements MessageHandler, Node { @Override public void onMessage(ClientMessage message) { String pathPropterty = null; resizeRequests.mark(); Context resizeTimeContext = resizeDuration.time(); try { pathPropterty = message.getStringProperty(MessageProperty.path.toString()); LOGGER.debug("Resize request for image {}", pathPropterty); if (pendingCache.getIfPresent(pathPropterty) != null) { LOGGER.trace("{} found in cache, skipping...", pathPropterty); pendingCacheHit.mark(); return; } else { pendingCacheMiss.mark(); } checkBufferCapacity(message.getBodySize()); messageBuffer.limit(message.getBodySize()); imageSize.update(message.getBodySize()); messageBuffer.rewind(); message.getBodyBuffer().readBytes(messageBuffer); messageBuffer.rewind(); Path path = Paths.get(pathPropterty); Path filename = path.getFileName(); InputStream is = new ByteBufferInputstream(messageBuffer); if (filename != null && filename.toString().toLowerCase().endsWith(".gif")) { GifImage gi = GifDecoder.read(is); is = new ByteArrayInputStream(ImageUtil.imageToBytes(gi.getFrame(0))); } BufferedImage originalImage = ImageIO.read(is); byte[] resizedImageData = resizer.resize(originalImage); UUID uuid = UUID.randomUUID(); ClientMessage trackMessage = messageFactory.trackPath(path, uuid); producer.send(QueueAddress.RESULT.toString(), trackMessage); LOGGER.trace("Sent tracking message for {} with UUID {}", pathPropterty, uuid); ClientMessage response = messageFactory.hashRequestMessage(resizedImageData, uuid); LOGGER.trace("Sending hash request with id {} instead of path {}", uuid, path); producer.send(response); pendingCache.put(pathPropterty, DUMMY); resizeTimeContext.stop(); } catch (ActiveMQException e) { LOGGER.error("Failed to send message: {}", e.toString()); } catch (IIOException | ArrayIndexOutOfBoundsException ie) { markImageCorrupt(pathPropterty); } catch (IOException e) { if (isImageError(e.getMessage())) { markImageCorrupt(pathPropterty); } else { LOGGER.error("Failed to process image: {}", e.toString()); } } catch (Exception e) { LOGGER.error("Unhandled exception: {}", e.toString()); LOGGER.debug("", e); } } }
ResizerNode implements MessageHandler, Node { @Override public void onMessage(ClientMessage message) { String pathPropterty = null; resizeRequests.mark(); Context resizeTimeContext = resizeDuration.time(); try { pathPropterty = message.getStringProperty(MessageProperty.path.toString()); LOGGER.debug("Resize request for image {}", pathPropterty); if (pendingCache.getIfPresent(pathPropterty) != null) { LOGGER.trace("{} found in cache, skipping...", pathPropterty); pendingCacheHit.mark(); return; } else { pendingCacheMiss.mark(); } checkBufferCapacity(message.getBodySize()); messageBuffer.limit(message.getBodySize()); imageSize.update(message.getBodySize()); messageBuffer.rewind(); message.getBodyBuffer().readBytes(messageBuffer); messageBuffer.rewind(); Path path = Paths.get(pathPropterty); Path filename = path.getFileName(); InputStream is = new ByteBufferInputstream(messageBuffer); if (filename != null && filename.toString().toLowerCase().endsWith(".gif")) { GifImage gi = GifDecoder.read(is); is = new ByteArrayInputStream(ImageUtil.imageToBytes(gi.getFrame(0))); } BufferedImage originalImage = ImageIO.read(is); byte[] resizedImageData = resizer.resize(originalImage); UUID uuid = UUID.randomUUID(); ClientMessage trackMessage = messageFactory.trackPath(path, uuid); producer.send(QueueAddress.RESULT.toString(), trackMessage); LOGGER.trace("Sent tracking message for {} with UUID {}", pathPropterty, uuid); ClientMessage response = messageFactory.hashRequestMessage(resizedImageData, uuid); LOGGER.trace("Sending hash request with id {} instead of path {}", uuid, path); producer.send(response); pendingCache.put(pathPropterty, DUMMY); resizeTimeContext.stop(); } catch (ActiveMQException e) { LOGGER.error("Failed to send message: {}", e.toString()); } catch (IIOException | ArrayIndexOutOfBoundsException ie) { markImageCorrupt(pathPropterty); } catch (IOException e) { if (isImageError(e.getMessage())) { markImageCorrupt(pathPropterty); } else { LOGGER.error("Failed to process image: {}", e.toString()); } } catch (Exception e) { LOGGER.error("Unhandled exception: {}", e.toString()); LOGGER.debug("", e); } } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); }
ResizerNode implements MessageHandler, Node { @Override public void onMessage(ClientMessage message) { String pathPropterty = null; resizeRequests.mark(); Context resizeTimeContext = resizeDuration.time(); try { pathPropterty = message.getStringProperty(MessageProperty.path.toString()); LOGGER.debug("Resize request for image {}", pathPropterty); if (pendingCache.getIfPresent(pathPropterty) != null) { LOGGER.trace("{} found in cache, skipping...", pathPropterty); pendingCacheHit.mark(); return; } else { pendingCacheMiss.mark(); } checkBufferCapacity(message.getBodySize()); messageBuffer.limit(message.getBodySize()); imageSize.update(message.getBodySize()); messageBuffer.rewind(); message.getBodyBuffer().readBytes(messageBuffer); messageBuffer.rewind(); Path path = Paths.get(pathPropterty); Path filename = path.getFileName(); InputStream is = new ByteBufferInputstream(messageBuffer); if (filename != null && filename.toString().toLowerCase().endsWith(".gif")) { GifImage gi = GifDecoder.read(is); is = new ByteArrayInputStream(ImageUtil.imageToBytes(gi.getFrame(0))); } BufferedImage originalImage = ImageIO.read(is); byte[] resizedImageData = resizer.resize(originalImage); UUID uuid = UUID.randomUUID(); ClientMessage trackMessage = messageFactory.trackPath(path, uuid); producer.send(QueueAddress.RESULT.toString(), trackMessage); LOGGER.trace("Sent tracking message for {} with UUID {}", pathPropterty, uuid); ClientMessage response = messageFactory.hashRequestMessage(resizedImageData, uuid); LOGGER.trace("Sending hash request with id {} instead of path {}", uuid, path); producer.send(response); pendingCache.put(pathPropterty, DUMMY); resizeTimeContext.stop(); } catch (ActiveMQException e) { LOGGER.error("Failed to send message: {}", e.toString()); } catch (IIOException | ArrayIndexOutOfBoundsException ie) { markImageCorrupt(pathPropterty); } catch (IOException e) { if (isImageError(e.getMessage())) { markImageCorrupt(pathPropterty); } else { LOGGER.error("Failed to process image: {}", e.toString()); } } catch (Exception e) { LOGGER.error("Unhandled exception: {}", e.toString()); LOGGER.debug("", e); } } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); @Override void onMessage(ClientMessage message); @Override void stop(); @Override String toString(); }
ResizerNode implements MessageHandler, Node { @Override public void onMessage(ClientMessage message) { String pathPropterty = null; resizeRequests.mark(); Context resizeTimeContext = resizeDuration.time(); try { pathPropterty = message.getStringProperty(MessageProperty.path.toString()); LOGGER.debug("Resize request for image {}", pathPropterty); if (pendingCache.getIfPresent(pathPropterty) != null) { LOGGER.trace("{} found in cache, skipping...", pathPropterty); pendingCacheHit.mark(); return; } else { pendingCacheMiss.mark(); } checkBufferCapacity(message.getBodySize()); messageBuffer.limit(message.getBodySize()); imageSize.update(message.getBodySize()); messageBuffer.rewind(); message.getBodyBuffer().readBytes(messageBuffer); messageBuffer.rewind(); Path path = Paths.get(pathPropterty); Path filename = path.getFileName(); InputStream is = new ByteBufferInputstream(messageBuffer); if (filename != null && filename.toString().toLowerCase().endsWith(".gif")) { GifImage gi = GifDecoder.read(is); is = new ByteArrayInputStream(ImageUtil.imageToBytes(gi.getFrame(0))); } BufferedImage originalImage = ImageIO.read(is); byte[] resizedImageData = resizer.resize(originalImage); UUID uuid = UUID.randomUUID(); ClientMessage trackMessage = messageFactory.trackPath(path, uuid); producer.send(QueueAddress.RESULT.toString(), trackMessage); LOGGER.trace("Sent tracking message for {} with UUID {}", pathPropterty, uuid); ClientMessage response = messageFactory.hashRequestMessage(resizedImageData, uuid); LOGGER.trace("Sending hash request with id {} instead of path {}", uuid, path); producer.send(response); pendingCache.put(pathPropterty, DUMMY); resizeTimeContext.stop(); } catch (ActiveMQException e) { LOGGER.error("Failed to send message: {}", e.toString()); } catch (IIOException | ArrayIndexOutOfBoundsException ie) { markImageCorrupt(pathPropterty); } catch (IOException e) { if (isImageError(e.getMessage())) { markImageCorrupt(pathPropterty); } else { LOGGER.error("Failed to process image: {}", e.toString()); } } catch (Exception e) { LOGGER.error("Unhandled exception: {}", e.toString()); LOGGER.debug("", e); } } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); @Override void onMessage(ClientMessage message); @Override void stop(); @Override String toString(); static final String METRIC_NAME_RESIZE_MESSAGES; static final String METRIC_NAME_RESIZE_DURATION; static final String METRIC_NAME_PENDING_CACHE_HIT; static final String METRIC_NAME_PENDING_CACHE_MISS; static final String METRIC_NAME_IMAGE_SIZE; static final String METRIC_NAME_BUFFER_RESIZE; }
@Test public void testToStringStart() throws Exception { assertThat(cut.toString(), startsWith("ResizerNode {")); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); @Override void onMessage(ClientMessage message); @Override void stop(); @Override String toString(); }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); @Override void onMessage(ClientMessage message); @Override void stop(); @Override String toString(); static final String METRIC_NAME_RESIZE_MESSAGES; static final String METRIC_NAME_RESIZE_DURATION; static final String METRIC_NAME_PENDING_CACHE_HIT; static final String METRIC_NAME_PENDING_CACHE_MISS; static final String METRIC_NAME_IMAGE_SIZE; static final String METRIC_NAME_BUFFER_RESIZE; }
@Test public void testToStringEnd() throws Exception { assertThat(cut.toString(), endsWith("}")); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); @Override void onMessage(ClientMessage message); @Override void stop(); @Override String toString(); }
ResizerNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(ResizerNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } @Inject ResizerNode(ClientSession session, ImageResizer resizer, MetricRegistry metrics); protected ResizerNode(ClientSession session, ImageResizer resizer, String requestAddress, String resultAddress, QueryMessage queryMessage, MetricRegistry metrics); @Override void onMessage(ClientMessage message); @Override void stop(); @Override String toString(); static final String METRIC_NAME_RESIZE_MESSAGES; static final String METRIC_NAME_RESIZE_DURATION; static final String METRIC_NAME_PENDING_CACHE_HIT; static final String METRIC_NAME_PENDING_CACHE_MISS; static final String METRIC_NAME_IMAGE_SIZE; static final String METRIC_NAME_BUFFER_RESIZE; }
@Test public void testAddMessageAboveThreshold() throws Exception { addNumberOfMessages(MESSAGE_THRESHOLD); verify(collector).onDrain(anyListOf(ClientMessage.class)); }
private void onDrain() { ImmutableList<ClientMessage> immutable; LOGGER.trace("Draining {} collected messsages...", collectedMessages.size()); synchronized (collectedMessages) { immutable = ImmutableList.copyOf(collectedMessages); collectedMessages.clear(); } for (CollectedMessageConsumer drain : consumers) { drain.onDrain(immutable); } }
MessageCollector { private void onDrain() { ImmutableList<ClientMessage> immutable; LOGGER.trace("Draining {} collected messsages...", collectedMessages.size()); synchronized (collectedMessages) { immutable = ImmutableList.copyOf(collectedMessages); collectedMessages.clear(); } for (CollectedMessageConsumer drain : consumers) { drain.onDrain(immutable); } } }
MessageCollector { private void onDrain() { ImmutableList<ClientMessage> immutable; LOGGER.trace("Draining {} collected messsages...", collectedMessages.size()); synchronized (collectedMessages) { immutable = ImmutableList.copyOf(collectedMessages); collectedMessages.clear(); } for (CollectedMessageConsumer drain : consumers) { drain.onDrain(immutable); } } MessageCollector(int collectedMessageThreshold, CollectedMessageConsumer... consumers); }
MessageCollector { private void onDrain() { ImmutableList<ClientMessage> immutable; LOGGER.trace("Draining {} collected messsages...", collectedMessages.size()); synchronized (collectedMessages) { immutable = ImmutableList.copyOf(collectedMessages); collectedMessages.clear(); } for (CollectedMessageConsumer drain : consumers) { drain.onDrain(immutable); } } MessageCollector(int collectedMessageThreshold, CollectedMessageConsumer... consumers); void addMessage(ClientMessage message); void drain(); }
MessageCollector { private void onDrain() { ImmutableList<ClientMessage> immutable; LOGGER.trace("Draining {} collected messsages...", collectedMessages.size()); synchronized (collectedMessages) { immutable = ImmutableList.copyOf(collectedMessages); collectedMessages.clear(); } for (CollectedMessageConsumer drain : consumers) { drain.onDrain(immutable); } } MessageCollector(int collectedMessageThreshold, CollectedMessageConsumer... consumers); void addMessage(ClientMessage message); void drain(); }