Do not duplicate candidate list
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / entityownership / selectionstrategy / LastCandidateSelectionStrategy.java
index db5d56b9dcb72002d20fa513dae8ec15446b4d71..73236c234c25ac34ed635f385bb17e25b1f2079e 100644 (file)
@@ -8,19 +8,17 @@
 
 package org.opendaylight.controller.cluster.datastore.entityownership.selectionstrategy;
 
-import java.util.ArrayList;
+import com.google.common.collect.Iterables;
 import java.util.Collection;
-import java.util.List;
+import java.util.Map;
 
-public class LastCandidateSelectionStrategy implements EntityOwnerSelectionStrategy {
-    @Override
-    public long selectionDelayInMillis() {
-        return 500;
+public class LastCandidateSelectionStrategy extends AbstractEntityOwnerSelectionStrategy {
+    public LastCandidateSelectionStrategy(final long selectionDelayInMillis) {
+        super(selectionDelayInMillis);
     }
 
     @Override
-    public String newOwner(Collection<String> viableCandidates) {
-        List<String> candidates = new ArrayList<>(viableCandidates);
-        return candidates.get(candidates.size()-1);
+    public String newOwner(final Collection<String> viableCandidates, final Map<String, Long> statistics) {
+        return Iterables.getLast(viableCandidates);
     }
 }