2 * Copyright (c) 2016 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.netvirt.fcapsapp.performancecounter;
11 import org.slf4j.Logger;
12 import org.slf4j.LoggerFactory;
13 import java.lang.Integer;
14 import java.lang.String;
15 import java.util.HashMap;
16 import java.util.HashSet;
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<String>();
24 public static final PMAgent pmagent = new PMAgent();
25 Map<String, String> counter_map = new HashMap<String, String>();
27 public NodeUpdateCounter() {
30 public void nodeAddedNotification(String sNode,String hostName) {
32 sendNodeUpdation(dpnList.size(),hostName);
35 public void nodeRemovedNotification(String sNode,String hostName) {
36 dpnList.remove(sNode);
37 sendNodeUpdation(dpnList.size(), hostName);
40 private void sendNodeUpdation(Integer count,String hostName) {
42 if (hostName != null) {
43 nodeListEFSCountStr = "Node_" + hostName + "_NumberOfEFS";
44 LOG.debug("NumberOfEFS:" + nodeListEFSCountStr + " dpnList.size " + count);
46 counter_map.put("NumberOfEFS:" + nodeListEFSCountStr, "" + count);
47 pmagent.connectToPMAgent(counter_map);
49 LOG.error("Hostname is null upon NumberOfEFS counter");
52 public boolean isDpnConnectedLocal(String sNode) {
53 if (dpnList.contains(sNode))