2 * Copyright (c) 2016, 2017 Ericsson India Global Services Pvt Ltd. 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
8 package org.opendaylight.genius.fcapsapp.performancecounter;
10 import java.util.HashMap;
11 import java.util.HashSet;
13 import javax.inject.Inject;
14 import javax.inject.Singleton;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
19 public class NodeUpdateCounter {
21 private static final Logger LOG = LoggerFactory.getLogger(NodeUpdateCounter.class);
22 private String nodeListEFSCountStr;
23 private static HashSet<String> dpnList = new HashSet<>();
24 public final PMAgent agent;
25 private final Map<String, String> countersMap = new HashMap<>();
28 public NodeUpdateCounter(final PMAgent agent) {
32 public void nodeAddedNotification(String node, String hostName) {
34 sendNodeUpdation(dpnList.size(), hostName);
37 public void nodeRemovedNotification(String node, String hostName) {
39 sendNodeUpdation(dpnList.size(), hostName);
42 private void sendNodeUpdation(Integer count, String hostName) {
44 if (hostName != null) {
45 nodeListEFSCountStr = "Node_" + hostName + "_NumberOfEFS";
46 LOG.debug("NumberOfEFS: {} dpnList.size {}", nodeListEFSCountStr, count);
48 countersMap.put("NumberOfEFS:" + nodeListEFSCountStr, "" + count);
49 agent.connectToPMAgent(countersMap);
51 LOG.error("Hostname is null upon NumberOfEFS counter");
55 public boolean isDpnConnectedLocal(String node) {
56 return dpnList.contains(node);