Commit d5f2060ffc1f1387bd13e1c2c0b773d1907b7e90
1 parent
4df235e6
new queue stats export: date/voip/web/mail
Showing
4 changed files
with
49 additions
and
26 deletions
src/main/java/net/floodlightcontroller/pelstats/PELStats.java
| ... | ... | @@ -74,7 +74,8 @@ public class PELStats implements IFloodlightModule, IOFMessageListener, RestAPIP |
| 74 | 74 | public static ConcurrentHashMap<IOFSwitch,List<double[]>> cacStatsMap; |
| 75 | 75 | public static ConcurrentHashMap<IOFSwitch,Boolean> cacEnabledMap; |
| 76 | 76 | |
| 77 | - public static ConcurrentHashMap<IOFSwitch, int[]> queueInfos; | |
| 77 | + public static ConcurrentHashMap<IOFSwitch, List<double[]>> queueStatsMap; | |
| 78 | + public static ConcurrentHashMap<IOFSwitch, int[]> queueInfosMap; | |
| 78 | 79 | public static ConcurrentHashMap<IOFSwitch, List<Integer>> portsCallsMap; |
| 79 | 80 | |
| 80 | 81 | private double previousMos=-1; |
| ... | ... | @@ -143,21 +144,21 @@ public class PELStats implements IFloodlightModule, IOFMessageListener, RestAPIP |
| 143 | 144 | int[] SwitchRTPPorts = ((StatisticVoIP_SIP)srb.getStatistic()).getRTPPorts(); |
| 144 | 145 | |
| 145 | 146 | //System.out.println("@PELStats: \tqueueInfos:"+queueInfos.get(sw).get(0)+" "+queueInfos.get(sw).get(1)+" "+queueInfos.get(sw).get(2)+" "); |
| 146 | - if(queueInfos.get(sw)[2]==1 || queueInfos.get(sw)[2]==3){ //if we want to delete or modify existing queue | |
| 147 | + if(queueInfosMap.get(sw)[2]==1 || queueInfosMap.get(sw)[2]==3){ //if we want to delete or modify existing queue | |
| 147 | 148 | //System.out.println("@PELStats: \tModification or deletion"); |
| 148 | 149 | for (int port : portsCallsMap.get(sw)) |
| 149 | 150 | { |
| 150 | 151 | //System.out.println("@PELStats: \tport modification or deletion: "+port); |
| 151 | 152 | sendOFFlowMod(sw,port); |
| 152 | 153 | } |
| 153 | - if(queueInfos.get(sw)[2]==3){ //If we deleted the queue | |
| 154 | + if(queueInfosMap.get(sw)[2]==3){ //If we deleted the queue | |
| 154 | 155 | portsCallsMap.put(sw, new ArrayList<Integer>()); |
| 155 | 156 | } |
| 156 | 157 | |
| 157 | 158 | |
| 158 | 159 | } |
| 159 | 160 | //System.out.println("@PELStats: \tintermission"); |
| 160 | - if (queueInfos.get(sw)[2]!=3 && SwitchRTPPorts!=null) { | |
| 161 | + if (queueInfosMap.get(sw)[2]!=3 && SwitchRTPPorts!=null) { | |
| 161 | 162 | //System.out.println("@PELStats: \tModification or addition"); |
| 162 | 163 | for (int port:SwitchRTPPorts){ //For each calls of the switch |
| 163 | 164 | //System.out.println("@PELStats: \tModification or addition for port: "+port); |
| ... | ... | @@ -260,14 +261,20 @@ public class PELStats implements IFloodlightModule, IOFMessageListener, RestAPIP |
| 260 | 261 | } |
| 261 | 262 | if (srb.getStatistic().getType()==8){ |
| 262 | 263 | if(cacStatsMap.get(sw)!=null){ |
| 263 | - ArrayList<double[]> cacStats = new ArrayList<double[]>(cacStatsMap.get(sw)); | |
| 264 | + /*ArrayList<double[]> cacStats = new ArrayList<double[]>(cacStatsMap.get(sw)); | |
| 264 | 265 | double[] stats =cacStats.get(cacStats.size()-1); |
| 265 | 266 | double[] bw=((StatisticVoIP_Queue)srb.getStatistic()).getBandwidth(); |
| 266 | 267 | stats[4]=bw[0]; |
| 267 | 268 | stats[5]=bw[1]; |
| 268 | 269 | stats[6]=bw[2]; |
| 269 | 270 | cacStats.set(cacStats.size()-1, stats); |
| 270 | - cacStatsMap.put(sw,cacStats); | |
| 271 | + cacStatsMap.put(sw,cacStats);*/ | |
| 272 | + | |
| 273 | + | |
| 274 | + ArrayList<double[]> queueStats =new ArrayList<double[]>(queueStatsMap.get(sw)); | |
| 275 | + double[] stats= ((StatisticVoIP_Queue)srb.getStatistic()).getBandwidth(); | |
| 276 | + queueStats.add(stats); | |
| 277 | + queueStatsMap.put(sw, queueStats); | |
| 271 | 278 | } |
| 272 | 279 | } |
| 273 | 280 | |
| ... | ... | @@ -314,7 +321,7 @@ public class PELStats implements IFloodlightModule, IOFMessageListener, RestAPIP |
| 314 | 321 | OFmatch= new OFMatch(); |
| 315 | 322 | enqueue= new OFActionEnqueue(); |
| 316 | 323 | |
| 317 | - OFmessage.setCommand((short)queueInfos.get(sw)[2]); | |
| 324 | + OFmessage.setCommand((short)queueInfosMap.get(sw)[2]); | |
| 318 | 325 | OFmessage.setCookie(0); |
| 319 | 326 | OFmessage.setIdleTimeout((short) 0); |
| 320 | 327 | OFmessage.setHardTimeout((short)0); |
| ... | ... | @@ -339,7 +346,7 @@ public class PELStats implements IFloodlightModule, IOFMessageListener, RestAPIP |
| 339 | 346 | OFmessage.setMatch(OFmatch); |
| 340 | 347 | |
| 341 | 348 | List<OFAction> actions= new ArrayList<OFAction>(1); |
| 342 | - enqueue=new OFActionEnqueue((short)2,queueInfos.get(sw)[0]); | |
| 349 | + enqueue=new OFActionEnqueue((short)2,queueInfosMap.get(sw)[0]); | |
| 343 | 350 | actions.add(enqueue); |
| 344 | 351 | |
| 345 | 352 | OFmessage.setActions(actions); |
| ... | ... | @@ -361,7 +368,7 @@ public class PELStats implements IFloodlightModule, IOFMessageListener, RestAPIP |
| 361 | 368 | OFmatch= new OFMatch(); |
| 362 | 369 | enqueue= new OFActionEnqueue(); |
| 363 | 370 | |
| 364 | - OFmessage.setCommand((short)queueInfos.get(sw)[2]); | |
| 371 | + OFmessage.setCommand((short)queueInfosMap.get(sw)[2]); | |
| 365 | 372 | OFmessage.setCookie(0); |
| 366 | 373 | OFmessage.setIdleTimeout((short) 0); |
| 367 | 374 | OFmessage.setHardTimeout((short)0); |
| ... | ... | @@ -386,7 +393,7 @@ public class PELStats implements IFloodlightModule, IOFMessageListener, RestAPIP |
| 386 | 393 | OFmessage.setMatch(OFmatch); |
| 387 | 394 | |
| 388 | 395 | actions= new ArrayList<OFAction>(1); |
| 389 | - enqueue=new OFActionEnqueue((short)1,queueInfos.get(sw)[0]); | |
| 396 | + enqueue=new OFActionEnqueue((short)1,queueInfosMap.get(sw)[0]); | |
| 390 | 397 | actions.add(enqueue); |
| 391 | 398 | |
| 392 | 399 | OFmessage.setActions(actions); |
| ... | ... | @@ -410,7 +417,7 @@ public class PELStats implements IFloodlightModule, IOFMessageListener, RestAPIP |
| 410 | 417 | OFmatch= new OFMatch(); |
| 411 | 418 | enqueue= new OFActionEnqueue(); |
| 412 | 419 | |
| 413 | - OFmessage.setCommand((short)queueInfos.get(sw)[2]); | |
| 420 | + OFmessage.setCommand((short)queueInfosMap.get(sw)[2]); | |
| 414 | 421 | OFmessage.setCookie(0); |
| 415 | 422 | OFmessage.setIdleTimeout((short) 0); |
| 416 | 423 | OFmessage.setHardTimeout((short)0); |
| ... | ... | @@ -432,7 +439,7 @@ public class PELStats implements IFloodlightModule, IOFMessageListener, RestAPIP |
| 432 | 439 | OFmessage.setMatch(OFmatch); |
| 433 | 440 | |
| 434 | 441 | actions= new ArrayList<OFAction>(1); |
| 435 | - enqueue=new OFActionEnqueue((short)2,queueInfos.get(sw)[0]); | |
| 442 | + enqueue=new OFActionEnqueue((short)2,queueInfosMap.get(sw)[0]); | |
| 436 | 443 | actions.add(enqueue); |
| 437 | 444 | |
| 438 | 445 | OFmessage.setActions(actions); |
| ... | ... | @@ -453,7 +460,7 @@ public class PELStats implements IFloodlightModule, IOFMessageListener, RestAPIP |
| 453 | 460 | OFmatch= new OFMatch(); |
| 454 | 461 | enqueue= new OFActionEnqueue(); |
| 455 | 462 | |
| 456 | - OFmessage.setCommand((short)queueInfos.get(sw)[2]); | |
| 463 | + OFmessage.setCommand((short)queueInfosMap.get(sw)[2]); | |
| 457 | 464 | OFmessage.setCookie(0); |
| 458 | 465 | OFmessage.setIdleTimeout((short) 0); |
| 459 | 466 | OFmessage.setHardTimeout((short)0); |
| ... | ... | @@ -475,7 +482,7 @@ public class PELStats implements IFloodlightModule, IOFMessageListener, RestAPIP |
| 475 | 482 | OFmessage.setMatch(OFmatch); |
| 476 | 483 | |
| 477 | 484 | actions= new ArrayList<OFAction>(1); |
| 478 | - enqueue=new OFActionEnqueue((short)1,queueInfos.get(sw)[0]); | |
| 485 | + enqueue=new OFActionEnqueue((short)1,queueInfosMap.get(sw)[0]); | |
| 479 | 486 | actions.add(enqueue); |
| 480 | 487 | |
| 481 | 488 | OFmessage.setActions(actions); |
| ... | ... | @@ -706,7 +713,7 @@ public class PELStats implements IFloodlightModule, IOFMessageListener, RestAPIP |
| 706 | 713 | PelVendorExtension.initialize(); |
| 707 | 714 | PELStats.enabledStatistics = new ConcurrentHashMap<IOFSwitch, List<Integer>>(); |
| 708 | 715 | PELStats.portsCallsMap=new ConcurrentHashMap<IOFSwitch, List<Integer>>(); |
| 709 | - PELStats.queueInfos=new ConcurrentHashMap<IOFSwitch, int[]>(); | |
| 716 | + PELStats.queueInfosMap=new ConcurrentHashMap<IOFSwitch, int[]>(); | |
| 710 | 717 | PELStats.callStatsMap=new ConcurrentHashMap<Integer, List<double[]>>() ; |
| 711 | 718 | PELStats.voipStatsMap=new ConcurrentHashMap<IOFSwitch, List<double[][]>>() ; |
| 712 | 719 | PELStats.cacStatsMap=new ConcurrentHashMap<IOFSwitch, List<double[]>>() ; | ... | ... |
src/main/java/net/floodlightcontroller/pelstats/rest/RESTExportStats.java
| ... | ... | @@ -167,16 +167,31 @@ public class RESTExportStats extends ServerResource{ |
| 167 | 167 | else if (type==8){ |
| 168 | 168 | out = new PrintWriter("BandwidthStatsExport.txt"); |
| 169 | 169 | if (idVoip==0){//export stats for all switches |
| 170 | - for (Map.Entry<IOFSwitch, List<double[]>> entry : PELStats.cacStatsMap.entrySet()){ | |
| 171 | - //out.println("Switch:\t"+entry.getKey()); | |
| 172 | - //out.println("Number of calls\tBandwidth\tVoIP Bandwidth"); | |
| 170 | + /*for (Map.Entry<IOFSwitch, List<double[]>> entry : PELStats.cacStatsMap.entrySet()){ | |
| 171 | + out.println("Switch:\t"+entry.getKey()); | |
| 172 | + out.println("Number of calls\tBandwidth\tVoIP Bandwidth"); | |
| 173 | 173 | for (double[] list:PELStats.cacStatsMap.get(entry.getKey())){ |
| 174 | 174 | if(list[1]!=0)out.println(list[0]+"\t"+list[3]+"\t"+list[4]+"\t"+list[5]+"\t"+list[6]); |
| 175 | 175 | // date total bw voip bw web bw mail bw |
| 176 | 176 | } |
| 177 | 177 | out.println("\n"); |
| 178 | + }//*/ | |
| 179 | + | |
| 180 | + for (Map.Entry<IOFSwitch, List<double[]>> entry : PELStats.queueStatsMap.entrySet()){ | |
| 181 | + out.println("Switch:\t"+entry.getKey()); | |
| 182 | + out.println("Number of calls\tBandwidth\tVoIP Bandwidth"); | |
| 183 | + for (double[] list:PELStats.cacStatsMap.get(entry.getKey())){ | |
| 184 | + out.println(list[0]+"\t"+list[1]+"\t"+list[2]+"\t"+list[3]); | |
| 185 | + // date voip bw web bw mail bw | |
| 186 | + } | |
| 187 | + out.println("\n"); | |
| 178 | 188 | } |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 179 | 193 | System.out.println("-> stats export successful"); |
| 194 | + | |
| 180 | 195 | } |
| 181 | 196 | |
| 182 | 197 | //System.out.println("-> stats export successful"); | ... | ... |
src/main/java/net/floodlightcontroller/pelstats/rest/RESTQueue.java
| ... | ... | @@ -218,14 +218,14 @@ public class RESTQueue extends ServerResource{ |
| 218 | 218 | |
| 219 | 219 | |
| 220 | 220 | int[] queuesInfos =new int[9]; |
| 221 | - if(PELStats.queueInfos.get(mySwitch)!=null){ | |
| 222 | - queuesInfos=PELStats.queueInfos.get(mySwitch); | |
| 221 | + if(PELStats.queueInfosMap.get(mySwitch)!=null){ | |
| 222 | + queuesInfos=PELStats.queueInfosMap.get(mySwitch); | |
| 223 | 223 | } |
| 224 | 224 | queuesInfos[0+3*(protocol-1)]=idQueue; |
| 225 | 225 | queuesInfos[0+3*(protocol-1)]=priority; |
| 226 | 226 | queuesInfos[0+3*(protocol-1)]=action; |
| 227 | 227 | |
| 228 | - PELStats.queueInfos.put(mySwitch, queuesInfos); | |
| 228 | + PELStats.queueInfosMap.put(mySwitch, queuesInfos); | |
| 229 | 229 | |
| 230 | 230 | if (action==3 && protocol==1){ |
| 231 | 231 | for (int port : PELStats.portsCallsMap.get(mySwitch)) | ... | ... |
src/main/java/org/openflow/protocol/Pel/statistics/StatisticVoIP_Queue.java
| ... | ... | @@ -2,6 +2,7 @@ package org.openflow.protocol.Pel.statistics; |
| 2 | 2 | |
| 3 | 3 | import java.nio.ByteBuffer; |
| 4 | 4 | import java.text.DecimalFormat; |
| 5 | +import java.util.Date; | |
| 5 | 6 | |
| 6 | 7 | public class StatisticVoIP_Queue extends Statistic{ |
| 7 | 8 | private int nbQueues; |
| ... | ... | @@ -45,17 +46,17 @@ public class StatisticVoIP_Queue extends Statistic{ |
| 45 | 46 | |
| 46 | 47 | } |
| 47 | 48 | public double[] getBandwidth(){ |
| 48 | - double[] bw = new double[3]; | |
| 49 | - | |
| 49 | + double[] bw = new double[4]; | |
| 50 | + bw[0]=new Date().getTime(); | |
| 50 | 51 | for (int i=0;i<nbQueues;i++){ |
| 51 | 52 | if (protocol[i]==1){ |
| 52 | - bw[0]+=bandwidth[i]; | |
| 53 | + bw[1]+=bandwidth[i]; | |
| 53 | 54 | } |
| 54 | 55 | else if (protocol[i]==2){ |
| 55 | - bw[1]+=bandwidth[i]; | |
| 56 | + bw[2]+=bandwidth[i]; | |
| 56 | 57 | } |
| 57 | 58 | else if (protocol[i]==3){ |
| 58 | - bw[2]+=bandwidth[i]; | |
| 59 | + bw[3]+=bandwidth[i]; | |
| 59 | 60 | } |
| 60 | 61 | |
| 61 | 62 | } | ... | ... |