Sho SHIMIZU
Committed by Ray Milkey

Return immediately when the given BatchWrite is empty

This revision aims to remove empty check of BatchWrite in the caller
side of this method

Change-Id: Ic0d659a6da221a052ad135eba18a783caa81ec42
......@@ -112,6 +112,7 @@ public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> {
/**
* Execute writes in a batch.
* If the specified BatchWrite is empty, write will not be executed.
*
* @param batch BatchWrite to execute
* @return failed operations
......
......@@ -54,6 +54,7 @@ import org.onlab.util.KryoNamespace;
import org.slf4j.Logger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
......@@ -416,6 +417,9 @@ public class DistributedIntentStore
@Override
public List<Operation> batchWrite(BatchWrite batch) {
if (batch.isEmpty()) {
return Collections.emptyList();
}
List<Operation> failed = new ArrayList<>();
final Builder builder = BatchWriteRequest.newBuilder();
......
......@@ -54,6 +54,7 @@ import org.onlab.util.KryoNamespace;
import org.slf4j.Logger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
......@@ -394,6 +395,10 @@ public class HazelcastIntentStore
@Override
public List<Operation> batchWrite(BatchWrite batch) {
if (batch.isEmpty()) {
return Collections.emptyList();
}
// Hazelcast version will never fail for conditional failure now.
List<Operation> failed = new ArrayList<>();
......
......@@ -33,6 +33,7 @@ import org.onosproject.net.intent.BatchWrite.Operation;
import org.onosproject.store.AbstractStore;
import org.slf4j.Logger;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
......@@ -154,6 +155,10 @@ public class SimpleIntentStore
*/
@Override
public List<Operation> batchWrite(BatchWrite batch) {
if (batch.isEmpty()) {
return Collections.emptyList();
}
List<Operation> failed = Lists.newArrayList();
for (Operation op : batch.operations()) {
switch (op.type()) {
......