use the right hop for more than one sf
[netvirt.git] / vpnservice / fcapsapplication / fcapsapplication-impl / src / main / java / org / opendaylight / netvirt / fcapsapp / performancecounter / NodeUpdateCounter.java
1 /*
2  * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.netvirt.fcapsapp.performancecounter;
9
10
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;
17 import java.util.Map;
18
19 public class NodeUpdateCounter {
20
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>();
26
27     public NodeUpdateCounter() {
28     }
29
30     public void nodeAddedNotification(String sNode,String hostName) {
31         dpnList.add(sNode);
32         sendNodeUpdation(dpnList.size(),hostName);
33     }
34
35     public void nodeRemovedNotification(String sNode,String hostName) {
36         dpnList.remove(sNode);
37         sendNodeUpdation(dpnList.size(), hostName);
38     }
39
40     private void sendNodeUpdation(Integer count,String hostName) {
41
42         if (hostName != null) {
43             nodeListEFSCountStr = "Node_" + hostName + "_NumberOfEFS";
44             LOG.debug("NumberOfEFS:" + nodeListEFSCountStr + " dpnList.size " + count);
45
46             counter_map.put("NumberOfEFS:" + nodeListEFSCountStr, "" + count);
47             pmagent.connectToPMAgent(counter_map);
48         } else
49             LOG.error("Hostname is null upon NumberOfEFS counter");
50     }
51
52     public boolean isDpnConnectedLocal(String sNode) {
53         if (dpnList.contains(sNode))
54             return true;
55         return false;
56     }
57 }