alshabib

add iterator support to SQueue

Change-Id: I83df62326e54368e40fa15df522c05ba2dc67ff6
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
15 */ 15 */
16 package org.onlab.onos.store.hz; 16 package org.onlab.onos.store.hz;
17 17
18 +import com.google.common.collect.Lists;
18 import com.hazelcast.core.IQueue; 19 import com.hazelcast.core.IQueue;
19 import com.hazelcast.core.ItemListener; 20 import com.hazelcast.core.ItemListener;
20 import com.hazelcast.monitor.LocalQueueStats; 21 import com.hazelcast.monitor.LocalQueueStats;
...@@ -22,6 +23,7 @@ import org.onlab.onos.store.serializers.StoreSerializer; ...@@ -22,6 +23,7 @@ import org.onlab.onos.store.serializers.StoreSerializer;
22 23
23 import java.util.Collection; 24 import java.util.Collection;
24 import java.util.Iterator; 25 import java.util.Iterator;
26 +import java.util.List;
25 import java.util.concurrent.TimeUnit; 27 import java.util.concurrent.TimeUnit;
26 28
27 import static com.google.common.base.Preconditions.checkNotNull; 29 import static com.google.common.base.Preconditions.checkNotNull;
...@@ -145,7 +147,9 @@ public class SQueue<T> implements IQueue<T> { ...@@ -145,7 +147,9 @@ public class SQueue<T> implements IQueue<T> {
145 147
146 @Override 148 @Override
147 public Iterator<T> iterator() { 149 public Iterator<T> iterator() {
148 - throw new UnsupportedOperationException(); 150 + List<T> list = Lists.newArrayList();
151 + q.forEach(elem -> list.add(deserialize(elem)));
152 + return list.iterator();
149 } 153 }
150 154
151 @Override 155 @Override
......
...@@ -47,6 +47,7 @@ import java.util.Collections; ...@@ -47,6 +47,7 @@ import java.util.Collections;
47 import java.util.Map; 47 import java.util.Map;
48 import java.util.Set; 48 import java.util.Set;
49 49
50 +
50 import static com.google.common.base.Preconditions.checkNotNull; 51 import static com.google.common.base.Preconditions.checkNotNull;
51 import static com.google.common.base.Preconditions.checkState; 52 import static com.google.common.base.Preconditions.checkState;
52 import static org.slf4j.LoggerFactory.getLogger; 53 import static org.slf4j.LoggerFactory.getLogger;
......