CPD Results

The following document contains the results of PMD's CPD 4.2.5.

Duplications

FileLine
com\trendmicro\grid\acl\ds\cache\ViewChangedLoggingListener.java36
net\sf\tinyjee\cache\ViewChangedLoggingListener.java20
@Listener
public class ViewChangedLoggingListener {

	private static final Logger log = LoggerFactory.getLogger(ViewChangedLoggingListener.class);

	/**
	 * Is called whenever the view is changed.
	 *
	 * @param event the event describing the change.
	 */
	@ViewChanged
	public void viewChanged(ViewChangedEvent event) {
		Set<String> joined, gone,
				actualView = toString(event.getNewMembers()),
				prevView = toString(event.getOldMembers());
		(joined = new LinkedHashSet<String>(actualView)).removeAll(prevView);
		(gone = new LinkedHashSet<String>(prevView)).removeAll(actualView);

		log.info("TMACL-01940:The cache cluster view changed:\n" +
				"{} joined and {} is gone resulting in\n" +
				"{}.\n" +
				"(local-address={}, view-id={}, is-merge={})", new Object[]{
				joined, gone, actualView,
				event.getLocalAddress(), event.getViewId(), event.isMergeView()
		});
	}

	private static Set<String> toString(List<Address> addresses) {
		Set<String> strings = new TreeSet<String>();
		if (addresses != null) {
			for (Address address : addresses)
				strings.add(String.valueOf(address));
		}
		return strings;
	}
}