SEBA-989-Instance coordination and state distribution mechanism in IgmpStatisticsManager

Change-Id: Ibf3f3a2c5c91c010ef909692eea913f95ee7a92e
diff --git a/api/src/main/java/org/opencord/igmpproxy/IgmpLeadershipService.java b/api/src/main/java/org/opencord/igmpproxy/IgmpLeadershipService.java
index 1b8d0fe..c3563a4 100644
--- a/api/src/main/java/org/opencord/igmpproxy/IgmpLeadershipService.java
+++ b/api/src/main/java/org/opencord/igmpproxy/IgmpLeadershipService.java
@@ -15,6 +15,8 @@
  */
 package org.opencord.igmpproxy;
 
+import org.onosproject.cluster.Leadership;
+import org.onosproject.cluster.NodeId;
 import org.onosproject.net.DeviceId;
 
 /**
@@ -28,4 +30,34 @@
      * @return if it is leadership of this device, return true
      */
     boolean isLocalLeader(DeviceId deviceId);
+
+    /**
+     * Gets local node id.
+     *
+     * @return node id
+     */
+    NodeId getLocalNodeId();
+
+    /**
+     * Gets leader for topic.
+     *
+     * @param topic topic name
+     * @return leader of topic
+     */
+    NodeId getLeader(String topic);
+
+    /**
+     * Enters a leadership contest.
+     *
+     * @param topic leadership topic
+     * @return {@code Leadership} future
+     */
+    Leadership runForLeadership(String topic);
+
+    /**
+     * Withdraws from a leadership contest.
+     *
+     * @param topic leadership topic
+     */
+    void withdraw(String topic);
 }
diff --git a/api/src/main/java/org/opencord/igmpproxy/IgmpStatisticType.java b/api/src/main/java/org/opencord/igmpproxy/IgmpStatisticType.java
new file mode 100644
index 0000000..0a94569
--- /dev/null
+++ b/api/src/main/java/org/opencord/igmpproxy/IgmpStatisticType.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.opencord.igmpproxy;
+
+/**
+ * Types of igmp-statistics.
+ */
+public enum IgmpStatisticType {
+    /**
+     * Join request.
+     */
+    IGMP_JOIN_REQ,
+    /**
+     * Success re-join.
+     */
+    IGMP_SUCCESS_JOIN_RE_JOIN_REQ,
+    /**
+     * Fail join request.
+     */
+    IGMP_FAIL_JOIN_REQ,
+    /**
+     * Leave request.
+     */
+    IGMP_LEAVE_REQ,
+    /**
+     * Igmp disconnect.
+     */
+    IGMP_DISCONNECT,
+    /**
+     * Igmp v3 membership query.
+     */
+    IGMP_V3_MEMBERSHIP_QUERY,
+    /**
+     * Igmp v1 membership report.
+     */
+    IGMP_V1_MEMBERSHIP_REPORT,
+    /**
+     * Igmp v2 membeship report.
+     */
+    IGMP_V2_MEMBERSHIP_REPORT,
+    /**
+     * Igmp v3 membeship report.
+     */
+    IGMP_V3_MEMBERSHIP_REPORT,
+    /**
+     * Igmp v2 leave group.
+     */
+    IGMP_V2_LEAVE_GROUP,
+    /**
+     * Received total message.
+     */
+    TOTAL_MSG_RECEIVED,
+    /**
+     * Received igmp-message.
+     */
+    IGMP_MSG_RECEIVED,
+    /**
+     * Received invalid igmp-message.
+     */
+    INVALID_IGMP_MSG_RECEIVED,
+    /**
+     * Unknown igmp rx packets counter.
+     */
+    UNKNOWN_IGMP_TYPE_PACKETS_RX_COUNTER,
+    /**
+     * Wrong mode rx counter reports.
+     */
+    REPORTS_RX_WITH_WRONG_MODE_COUNTER,
+    /**
+     * Insuff permission access counter of fail join request.
+     */
+    FAIL_JOIN_REQ_INSUFF_PERMISSION_ACCESS_COUNTER,
+    /**
+     * Unknown mcast ip counter of fail join.
+     */
+    FAIL_JOIN_REQ_UNKNOWN_MULTICAST_IP_COUNTER,
+    /**
+     * Unconfigured group counter.
+     */
+    UNCONFIGURED_GROUP_COUNTER,
+    /**
+     * Valid igmp packet counter.
+     */
+    VALID_IGMP_PACKET_COUNTER,
+    /**
+     * Igmp channel join counter.
+     */
+    IGMP_CHANNEL_JOIN_COUNTER,
+    /**
+     * Current grp number counter.
+     */
+    CURRENT_GRP_NUMBER_COUNTER,
+    /**
+     * Igmp valid checksum counter.
+     */
+    IGMP_VALID_CHECKSUM_COUNTER,
+    /**
+     * Invalid igmp length.
+     */
+    INVALID_IGMP_LENGTH,
+    /**
+     * Igmp general membership query.
+     */
+    IGMP_GENERAL_MEMBERSHIP_QUERY,
+    /**
+     * Igmp grp specific membership query.
+     */
+    IGMP_GRP_SPECIFIC_MEMBERSHIP_QUERY,
+    /**
+     * Igmp grp and src spesific membership query.
+     */
+    IGMP_GRP_AND_SRC_SPESIFIC_MEMBERSHIP_QUERY;
+}
diff --git a/api/src/main/java/org/opencord/igmpproxy/IgmpStatistics.java b/api/src/main/java/org/opencord/igmpproxy/IgmpStatistics.java
index f330e9f..d101d60 100644
--- a/api/src/main/java/org/opencord/igmpproxy/IgmpStatistics.java
+++ b/api/src/main/java/org/opencord/igmpproxy/IgmpStatistics.java
@@ -15,14 +15,18 @@
  */
 package org.opencord.igmpproxy;
 
+import org.slf4j.Logger;
+
 import java.util.concurrent.atomic.AtomicLong;
 
+import static org.slf4j.LoggerFactory.getLogger;
+
 /**
- *
  * Records metrics for IgmpProxy application.
- *
  */
 public class IgmpStatistics {
+    private final Logger log = getLogger(getClass());
+    private static final long RESET_VALUE = 0L;
 
     //Total number of join requests
     private AtomicLong igmpJoinReq = new AtomicLong();
@@ -77,212 +81,239 @@
     //Total number of group and source specific IGMP membership query messages received
     private AtomicLong igmpGrpAndSrcSpecificMembershipQuery = new AtomicLong();
 
-    public Long getIgmpJoinReq() {
-        return igmpJoinReq.get();
+    public void setStats(IgmpStatistics current) {
+        igmpJoinReq.set(current.igmpJoinReq.get());
+        igmpSuccessJoinRejoinReq.set(current.igmpSuccessJoinRejoinReq.get());
+        igmpFailJoinReq.set(current.igmpFailJoinReq.get());
+        igmpLeaveReq.set(current.igmpLeaveReq.get());
+        igmpDisconnect.set(current.igmpDisconnect.get());
+        igmpv3MembershipQuery.set(current.igmpv3MembershipQuery.get());
+        igmpv1MembershipReport.set(current.igmpv1MembershipReport.get());
+        igmpv3MembershipReport.set(current.igmpv3MembershipReport.get());
+        igmpv2MembershipReport.set(current.igmpv2MembershipReport.get());
+        igmpv2LeaveGroup.set(current.igmpv2LeaveGroup.get());
+        totalMsgReceived.set(current.totalMsgReceived.get());
+        igmpMsgReceived.set(current.igmpMsgReceived.get());
+        invalidIgmpMsgReceived.set(current.invalidIgmpMsgReceived.get());
+        unknownIgmpTypePacketsRxCounter.set(current.unknownIgmpTypePacketsRxCounter.get());
+        reportsRxWithWrongModeCounter.set(current.reportsRxWithWrongModeCounter.get());
+        failJoinReqInsuffPermissionAccessCounter.set(current.failJoinReqInsuffPermissionAccessCounter.get());
+        failJoinReqUnknownMulticastIpCounter.set(current.failJoinReqUnknownMulticastIpCounter.get());
+        unconfiguredGroupCounter.set(current.unconfiguredGroupCounter.get());
+        validIgmpPacketCounter.set(current.validIgmpPacketCounter.get());
+        igmpChannelJoinCounter.set(current.igmpChannelJoinCounter.get());
+        currentGrpNumCounter.set(current.currentGrpNumCounter.get());
+        igmpValidChecksumCounter.set(current.igmpValidChecksumCounter.get());
+        invalidIgmpLength.set(current.invalidIgmpLength.get());
+        igmpGeneralMembershipQuery.set(current.igmpGeneralMembershipQuery.get());
+        igmpGrpSpecificMembershipQuery.set(current.igmpGrpSpecificMembershipQuery.get());
+        igmpGrpAndSrcSpecificMembershipQuery.set(current.igmpGrpAndSrcSpecificMembershipQuery.get());
     }
 
-    public Long getIgmpSuccessJoinRejoinReq() {
-        return igmpSuccessJoinRejoinReq.get();
+    public void resetAll() {
+        igmpJoinReq.set(RESET_VALUE);
+        igmpLeaveReq.set(RESET_VALUE);
+        igmpDisconnect.set(RESET_VALUE);
+        totalMsgReceived.set(RESET_VALUE);
+        igmpv2LeaveGroup.set(RESET_VALUE);
+        invalidIgmpLength.set(RESET_VALUE);
+        igmpv3MembershipQuery.set(RESET_VALUE);
+        igmpChannelJoinCounter.set(RESET_VALUE);
+        igmpv1MembershipReport.set(RESET_VALUE);
+        igmpv2MembershipReport.set(RESET_VALUE);
+        igmpv3MembershipReport.set(RESET_VALUE);
+        invalidIgmpMsgReceived.set(RESET_VALUE);
+        validIgmpPacketCounter.set(RESET_VALUE);
+        currentGrpNumCounter.set(RESET_VALUE);
+        igmpFailJoinReq.set(RESET_VALUE);
+        unconfiguredGroupCounter.set(RESET_VALUE);
+        igmpValidChecksumCounter.set(RESET_VALUE);
+        igmpGeneralMembershipQuery.set(RESET_VALUE);
+        igmpSuccessJoinRejoinReq.set(RESET_VALUE);
+        igmpGrpSpecificMembershipQuery.set(RESET_VALUE);
+        reportsRxWithWrongModeCounter.set(RESET_VALUE);
+        unknownIgmpTypePacketsRxCounter.set(RESET_VALUE);
+        failJoinReqUnknownMulticastIpCounter.set(RESET_VALUE);
+        igmpGrpAndSrcSpecificMembershipQuery.set(RESET_VALUE);
+        failJoinReqInsuffPermissionAccessCounter.set(RESET_VALUE);
     }
 
-    public Long getIgmpFailJoinReq() {
-        return igmpFailJoinReq.get();
+    public void increaseStat(IgmpStatisticType type) {
+        switch (type) {
+            case IGMP_JOIN_REQ:
+                igmpJoinReq.incrementAndGet();
+                break;
+            case IGMP_LEAVE_REQ:
+                igmpLeaveReq.incrementAndGet();
+                break;
+            case IGMP_DISCONNECT:
+                igmpDisconnect.incrementAndGet();
+                break;
+            case IGMP_MSG_RECEIVED:
+                break;
+            case TOTAL_MSG_RECEIVED:
+                totalMsgReceived.incrementAndGet();
+                break;
+            case IGMP_V2_LEAVE_GROUP:
+                igmpv2LeaveGroup.incrementAndGet();
+                igmpMsgReceived.incrementAndGet();
+                break;
+            case INVALID_IGMP_LENGTH:
+                invalidIgmpLength.incrementAndGet();
+                break;
+            case IGMP_V3_MEMBERSHIP_QUERY:
+                igmpv3MembershipQuery.incrementAndGet();
+                igmpMsgReceived.incrementAndGet();
+                break;
+            case IGMP_CHANNEL_JOIN_COUNTER:
+                igmpChannelJoinCounter.incrementAndGet();
+                break;
+            case IGMP_V1_MEMBERSHIP_REPORT:
+                igmpv1MembershipReport.incrementAndGet();
+                igmpMsgReceived.incrementAndGet();
+                break;
+            case IGMP_V2_MEMBERSHIP_REPORT:
+                igmpv2MembershipReport.incrementAndGet();
+                igmpMsgReceived.incrementAndGet();
+                break;
+            case IGMP_V3_MEMBERSHIP_REPORT:
+                igmpv3MembershipReport.incrementAndGet();
+                igmpMsgReceived.incrementAndGet();
+                break;
+            case INVALID_IGMP_MSG_RECEIVED:
+                invalidIgmpMsgReceived.incrementAndGet();
+                break;
+            case VALID_IGMP_PACKET_COUNTER:
+                validIgmpPacketCounter.incrementAndGet();
+                break;
+            case CURRENT_GRP_NUMBER_COUNTER:
+                currentGrpNumCounter.incrementAndGet();
+                break;
+            case IGMP_FAIL_JOIN_REQ:
+                igmpFailJoinReq.incrementAndGet();
+                break;
+            case UNCONFIGURED_GROUP_COUNTER:
+                unconfiguredGroupCounter.incrementAndGet();
+                break;
+            case IGMP_VALID_CHECKSUM_COUNTER:
+                igmpValidChecksumCounter.incrementAndGet();
+                break;
+            case IGMP_GENERAL_MEMBERSHIP_QUERY:
+                igmpGeneralMembershipQuery.incrementAndGet();
+                break;
+            case IGMP_SUCCESS_JOIN_RE_JOIN_REQ:
+                igmpSuccessJoinRejoinReq.incrementAndGet();
+                break;
+            case IGMP_GRP_SPECIFIC_MEMBERSHIP_QUERY:
+                igmpGrpSpecificMembershipQuery.incrementAndGet();
+                break;
+            case REPORTS_RX_WITH_WRONG_MODE_COUNTER:
+                reportsRxWithWrongModeCounter.incrementAndGet();
+                break;
+            case UNKNOWN_IGMP_TYPE_PACKETS_RX_COUNTER:
+                unknownIgmpTypePacketsRxCounter.incrementAndGet();
+                break;
+            case FAIL_JOIN_REQ_UNKNOWN_MULTICAST_IP_COUNTER:
+                failJoinReqUnknownMulticastIpCounter.incrementAndGet();
+                break;
+            case IGMP_GRP_AND_SRC_SPESIFIC_MEMBERSHIP_QUERY:
+                igmpGrpAndSrcSpecificMembershipQuery.incrementAndGet();
+                break;
+            case FAIL_JOIN_REQ_INSUFF_PERMISSION_ACCESS_COUNTER:
+                failJoinReqInsuffPermissionAccessCounter.incrementAndGet();
+                break;
+            default:
+                log.warn("Unhandled statistic type. {}", type);
+                break;
+        }
     }
 
-    public Long getIgmpLeaveReq() {
-        return igmpLeaveReq.get();
+    public Long getStat(IgmpStatisticType type) {
+        Long value;
+        switch (type) {
+            case IGMP_JOIN_REQ:
+                value = igmpJoinReq.get();
+                break;
+            case IGMP_LEAVE_REQ:
+                value = igmpLeaveReq.get();
+                break;
+            case IGMP_DISCONNECT:
+                value = igmpDisconnect.get();
+                break;
+            case IGMP_MSG_RECEIVED:
+                value = igmpMsgReceived.get();
+                break;
+            case TOTAL_MSG_RECEIVED:
+                value = totalMsgReceived.get();
+                break;
+            case IGMP_V2_LEAVE_GROUP:
+                value = igmpv2LeaveGroup.get();
+                break;
+            case INVALID_IGMP_LENGTH:
+                value = invalidIgmpLength.get();
+                break;
+            case IGMP_V3_MEMBERSHIP_QUERY:
+                value = igmpv3MembershipQuery.get();
+                break;
+            case IGMP_CHANNEL_JOIN_COUNTER:
+                value = igmpChannelJoinCounter.get();
+                break;
+            case IGMP_V1_MEMBERSHIP_REPORT:
+                value = igmpv1MembershipReport.get();
+                break;
+            case IGMP_V2_MEMBERSHIP_REPORT:
+                value = igmpv2MembershipReport.get();
+                break;
+            case IGMP_V3_MEMBERSHIP_REPORT:
+                value = igmpv3MembershipReport.get();
+                break;
+            case INVALID_IGMP_MSG_RECEIVED:
+                value = invalidIgmpMsgReceived.get();
+                break;
+            case VALID_IGMP_PACKET_COUNTER:
+                value = validIgmpPacketCounter.get();
+                break;
+            case CURRENT_GRP_NUMBER_COUNTER:
+                value = currentGrpNumCounter.get();
+                break;
+            case IGMP_FAIL_JOIN_REQ:
+                value = igmpFailJoinReq.get();
+                break;
+            case UNCONFIGURED_GROUP_COUNTER:
+                value = unconfiguredGroupCounter.get();
+                break;
+            case IGMP_VALID_CHECKSUM_COUNTER:
+                value = igmpValidChecksumCounter.get();
+                break;
+            case IGMP_GENERAL_MEMBERSHIP_QUERY:
+                value = igmpGeneralMembershipQuery.get();
+                break;
+            case IGMP_SUCCESS_JOIN_RE_JOIN_REQ:
+                value = igmpSuccessJoinRejoinReq.get();
+                break;
+            case IGMP_GRP_SPECIFIC_MEMBERSHIP_QUERY:
+                value = igmpGrpSpecificMembershipQuery.get();
+                break;
+            case REPORTS_RX_WITH_WRONG_MODE_COUNTER:
+                value = reportsRxWithWrongModeCounter.get();
+                break;
+            case UNKNOWN_IGMP_TYPE_PACKETS_RX_COUNTER:
+                value = unknownIgmpTypePacketsRxCounter.get();
+                break;
+            case FAIL_JOIN_REQ_UNKNOWN_MULTICAST_IP_COUNTER:
+                value = failJoinReqUnknownMulticastIpCounter.get();
+                break;
+            case IGMP_GRP_AND_SRC_SPESIFIC_MEMBERSHIP_QUERY:
+                value = igmpGrpAndSrcSpecificMembershipQuery.get();
+                break;
+            case FAIL_JOIN_REQ_INSUFF_PERMISSION_ACCESS_COUNTER:
+                value = failJoinReqInsuffPermissionAccessCounter.get();
+                break;
+            default:
+                value = null;
+                log.warn("Unhandled statistic type. {}", type);
+                break;
+        }
+        return value;
     }
-
-    public Long getIgmpDisconnect() {
-        return igmpDisconnect.get();
-    }
-
-    public Long getIgmpv3MembershipQuery() {
-        return igmpv3MembershipQuery.get();
-    }
-
-    public Long getIgmpv1MemershipReport() {
-        return igmpv1MembershipReport.get();
-    }
-
-    public Long getIgmpv3MembershipReport() {
-        return igmpv3MembershipReport.get();
-    }
-
-    public Long getIgmpv2MembershipReport() {
-        return igmpv2MembershipReport.get();
-    }
-
-    public Long getIgmpv2LeaveGroup() {
-        return igmpv2LeaveGroup.get();
-    }
-
-    public Long getTotalMsgReceived() {
-        return totalMsgReceived.get();
-    }
-
-    public Long getIgmpMsgReceived() {
-        return igmpMsgReceived.get();
-    }
-
-    public Long getInvalidIgmpMsgReceived() {
-        return invalidIgmpMsgReceived.get();
-    }
-
-    public void increaseIgmpJoinReq() {
-        igmpJoinReq.incrementAndGet();
-    }
-
-    public void increaseIgmpSuccessJoinRejoinReq() {
-        igmpSuccessJoinRejoinReq.incrementAndGet();
-    }
-
-    public void increaseIgmpFailJoinReq() {
-        igmpFailJoinReq.incrementAndGet();
-    }
-
-    public void increaseIgmpLeaveReq() {
-        igmpLeaveReq.incrementAndGet();
-    }
-
-    public void increaseIgmpDisconnect() {
-        igmpDisconnect.incrementAndGet();
-    }
-
-    public void increaseIgmpv3MembershipQuery() {
-        igmpv3MembershipQuery.incrementAndGet();
-        igmpMsgReceived.incrementAndGet();
-    }
-
-    public void increaseIgmpv2MembershipReport() {
-        igmpv2MembershipReport.incrementAndGet();
-        igmpMsgReceived.incrementAndGet();
-    }
-
-    public void increaseIgmpv1MembershipReport() {
-        igmpv1MembershipReport.incrementAndGet();
-        igmpMsgReceived.incrementAndGet();
-    }
-
-    public void increaseIgmpv3MembershipReport() {
-        igmpv3MembershipReport.incrementAndGet();
-        igmpMsgReceived.incrementAndGet();
-    }
-
-    public void increaseIgmpv2LeaveGroup() {
-        igmpv2LeaveGroup.incrementAndGet();
-        igmpMsgReceived.incrementAndGet();
-    }
-
-    public void increaseInvalidIgmpMsgReceived() {
-        invalidIgmpMsgReceived.incrementAndGet();
-    }
-
-    public void increaseTotalMsgReceived() {
-        totalMsgReceived.incrementAndGet();
-    }
-
-    public Long getValidIgmpPacketCounter() {
-        return validIgmpPacketCounter.get();
-    }
-
-    public void increaseValidIgmpPacketCounter() {
-        validIgmpPacketCounter.incrementAndGet();
-    }
-
-    public Long getCurrentGrpNumCounter() {
-        return currentGrpNumCounter.get();
-    }
-
-    public void increaseCurrentGrpNumCounter() {
-        currentGrpNumCounter.incrementAndGet();
-    }
-
-    public Long getIgmpChannelJoinCounter() {
-        return igmpChannelJoinCounter.get();
-    }
-    public Long getIgmpValidChecksumCounter() {
-        return igmpValidChecksumCounter.get();
-    }
-
-    public void increaseIgmpChannelJoinCounter() {
-        igmpChannelJoinCounter.incrementAndGet();
-    }
-
-    public void increaseIgmpValidChecksumCounter() {
-        igmpValidChecksumCounter.incrementAndGet();
-    }
-
-    public Long getUnconfiguredGroupCounter() {
-        return unconfiguredGroupCounter.get();
-    }
-
-    public void increaseUnconfiguredGroupCounter() {
-        unconfiguredGroupCounter.incrementAndGet();
-    }
-
-    public Long getFailJoinReqUnknownMulticastIpCounter() {
-        return failJoinReqUnknownMulticastIpCounter.get();
-    }
-
-    public void increaseFailJoinReqUnknownMulticastIpCounter() {
-        failJoinReqUnknownMulticastIpCounter.incrementAndGet();
-    }
-
-    public Long getFailJoinReqInsuffPermissionAccessCounter() {
-        return failJoinReqInsuffPermissionAccessCounter.get();
-    }
-
-    public void increaseFailJoinReqInsuffPermissionAccessCounter() {
-        failJoinReqInsuffPermissionAccessCounter.incrementAndGet();
-    }
-
-    public Long getReportsRxWithWrongModeCounter() {
-        return reportsRxWithWrongModeCounter.get();
-    }
-
-    public Long getUnknownIgmpTypePacketsRxCounter() {
-        return unknownIgmpTypePacketsRxCounter.get();
-    }
-
-    public void increaseUnknownIgmpTypePacketsRxCounter() {
-        unknownIgmpTypePacketsRxCounter.incrementAndGet();
-    }
-
-    public void increaseReportsRxWithWrongModeCounter() {
-        reportsRxWithWrongModeCounter.incrementAndGet();
-    }
-
-    public Long getInvalidIgmpLength() {
-        return invalidIgmpLength.get();
-    }
-
-    public void increaseInvalidIgmpLength() {
-        invalidIgmpLength.incrementAndGet();
-    }
-
-    public Long getIgmpGeneralMembershipQuery() {
-        return igmpGeneralMembershipQuery.get();
-    }
-
-    public Long getIgmpGrpSpecificMembershipQuery() {
-        return igmpGrpSpecificMembershipQuery.get();
-    }
-
-    public Long getIgmpGrpAndSrcSpecificMembershipQuery() {
-        return igmpGrpAndSrcSpecificMembershipQuery.get();
-    }
-
-    public void increaseIgmpGeneralMembershipQuery() {
-        igmpGeneralMembershipQuery.incrementAndGet();
-    }
-
-    public void increaseIgmpGrpSpecificMembershipQuery() {
-        igmpGrpSpecificMembershipQuery.incrementAndGet();
-    }
-
-    public void increaseIgmpGrpAndSrcSpecificMembershipQuery() {
-        igmpGrpAndSrcSpecificMembershipQuery.incrementAndGet();
-    }
-
 }
diff --git a/api/src/main/java/org/opencord/igmpproxy/IgmpStatisticsService.java b/api/src/main/java/org/opencord/igmpproxy/IgmpStatisticsService.java
index 3574ad5..2a5b228 100644
--- a/api/src/main/java/org/opencord/igmpproxy/IgmpStatisticsService.java
+++ b/api/src/main/java/org/opencord/igmpproxy/IgmpStatisticsService.java
@@ -23,11 +23,25 @@
  */
 public interface IgmpStatisticsService extends
         ListenerService<IgmpStatisticsEvent, IgmpStatisticsEventListener> {
+
     /**
-     * Returns IgmpStatistics object.
+     * Increases statistic-value for given type.
      *
-     * @return IgmpStatistics
-    */
-    public IgmpStatistics getIgmpStats();
+     * @param type type of igmp-statistic.
+     */
+    void increaseStat(IgmpStatisticType type);
+
+    /**
+     * Resets all statistic-values.
+     */
+    void resetAllStats();
+
+    /**
+     * Get statistic-value for given type.
+     *
+     * @param type type of igmp-statistic
+     * @return value of statistic
+     */
+    Long getStat(IgmpStatisticType type);
 
 }