2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowplugin.impl.registry.meter;
11 import com.google.common.annotations.VisibleForTesting;
12 import java.util.ArrayList;
13 import java.util.Collections;
14 import java.util.List;
15 import java.util.function.Consumer;
16 import org.opendaylight.openflowplugin.api.openflow.registry.meter.DeviceMeterRegistry;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
19 public class DeviceMeterRegistryImpl implements DeviceMeterRegistry {
21 private final List<MeterId> meterIds = Collections.synchronizedList(new ArrayList<>());
22 private final List<MeterId> marks = Collections.synchronizedList(new ArrayList<>());
25 public void store(final MeterId meterId) {
26 meterIds.add(meterId);
30 public void addMark(final MeterId meterId) {
35 public boolean hasMark(final MeterId meterId) {
36 return marks.contains(meterId);
40 public void processMarks() {
41 meterIds.removeAll(marks);
46 public void forEach(final Consumer<MeterId> consumer) {
47 synchronized (meterIds) {
48 meterIds.forEach(consumer);
54 return meterIds.size();
64 List<MeterId> getAllMeterIds() {