Search in sources :

Example 1 with CpuActivityList

use of com.att.aro.core.peripheral.pojo.CpuActivityList in project VideoOptimzer by attdevsupport.

the class CpuActivityReaderImpl method readData.

@Override
public CpuActivityList readData(String directory, double startTime) {
    String cpuFileName = TraceDataConst.FileName.CPU_FILE;
    CpuActivityList cpuActivityList = new CpuActivityList();
    LOGGER.trace("Reading CPU file...");
    String filepath = directory + Util.FILE_SEPARATOR + cpuFileName;
    if (!filereader.fileExist(filepath)) {
        LOGGER.warn("cpu file not found: " + cpuFileName);
        return cpuActivityList;
    }
    String[] lines;
    try {
        lines = filereader.readAllLine(filepath);
    } catch (IOException e) {
        LOGGER.error("Failed to read CPU activity file: " + filepath);
        return cpuActivityList;
    }
    for (String line : lines) {
        if (!line.trim().isEmpty()) {
            CpuActivity cpuact = cpuActivityParser.parseCpuLine(line, startTime);
            cpuActivityList.add(cpuact);
        }
    }
    return cpuActivityList;
}
Also used : CpuActivityList(com.att.aro.core.peripheral.pojo.CpuActivityList) IOException(java.io.IOException) CpuActivity(com.att.aro.core.peripheral.pojo.CpuActivity)

Example 2 with CpuActivityList

use of com.att.aro.core.peripheral.pojo.CpuActivityList in project VideoOptimzer by attdevsupport.

the class CpuActivityReaderImplTest method readData_IOException.

@Test
public void readData_IOException() throws IOException {
    reader = (CpuActivityReaderImpl) context.getBean(ICpuActivityReader.class);
    IFileManager filereader = Mockito.mock(IFileManager.class);
    Mockito.when(filereader.fileExist(Mockito.anyString())).thenReturn(true);
    Mockito.when(filereader.readAllLine(Mockito.anyString())).thenThrow(new IOException("test exception"));
    reader.setFileReader(filereader);
    CpuActivityList info = reader.readData("/", 0.0);
    assertTrue(info.getCpuActivities().size() == 0);
}
Also used : CpuActivityList(com.att.aro.core.peripheral.pojo.CpuActivityList) IOException(java.io.IOException) IFileManager(com.att.aro.core.fileio.IFileManager) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 3 with CpuActivityList

use of com.att.aro.core.peripheral.pojo.CpuActivityList in project VideoOptimzer by attdevsupport.

the class TraceDataReaderImpl method readFileUtil.

/**
 * some of the trace files read here
 *
 * Parses the user event trace
 *
 * @throws IOException
 *
 *             Reads the screen rotations information contained in the
 *             "screen_rotations" file found inside the trace directory and adds
 *             them to the user events list.
 * @throws IOException
 *             Reads the CPU trace information from the CPU file.
 *
 * @throws IOException
 *             Method to read the GPS data from the trace file and store it in
 *             the gpsInfos list. It also updates the active duration for GPS.
 *             Method to read the Bluetooth data from the trace file and store
 *             it in the bluetoothInfos list. It also updates the active
 *             duration for Bluetooth.
 *
 * @throws IOException
 *             Method to read the Camera data from the trace file and store it
 *             in the cameraInfos list. It also updates the active duration for
 *             Camera.
 *
 *             Method to read the WIFI data from the trace file and store it in
 *             the wifiInfos list. It also updates the active duration for Wifi.
 *
 *             Method to read the Screen State data from the trace file and
 *             store it in the ScreenStateInfos list.
 *
 *             Method to read the Battery data from the trace file and store it
 *             in the batteryInfos list.
 *
 *             Method to read the alarm event from the trace file and store it
 *             in the alarmInfos list.
 *
 *             Reads the Radio data from the file and stores it in the
 *             RadioInfo.
 * @param result
 */
public void readFileUtil(TraceDirectoryResult result) {
    NetworkTypeObject obj = networktypereader.readData(result.getTraceDirectory(), result.getPcapTime0(), result.getTraceDuration());
    if (obj != null) {
        result.setNetworkTypeInfos(obj.getNetworkTypeInfos());
        result.setNetworkTypesList(obj.getNetworkTypesList());
    }
    CollectOptions collectOptions = collectOptionsReader.readData(result.getTraceDirectory());
    result.setCollectOptions(collectOptions);
    List<UserEvent> userEvents = usereventreader.readData(result.getTraceDirectory(), result.getEventTime0(), result.getPcapTime0());
    result.setUserEvents(userEvents);
    List<UserEvent> list = this.screenrotationreader.readData(result.getTraceDirectory(), result.getPcapTime0());
    result.setScreenRotationCounter(list.size());
    result.getUserEvents().addAll(list);
    List<TemperatureEvent> temperatureEvents = cputemperaturereader.readData(result.getTraceDirectory(), result.getPcapTime0());
    result.setTemperatureInfos(temperatureEvents);
    List<LocationEvent> locationEvents = locationreader.readData(result.getTraceDirectory(), result.getPcapTime0());
    result.setLocationEventInfos(locationEvents);
    CpuActivityList cpuActivityList = cpureader.readData(result.getTraceDirectory(), result.getPcapTime0());
    result.setCpuActivityList(cpuActivityList);
    List<GpsInfo> gpsInfos = gpsreader.readData(result.getTraceDirectory(), result.getPcapTime0(), result.getTraceDuration());
    result.setGpsInfos(gpsInfos);
    result.setGpsActiveDuration(gpsreader.getGpsActiveDuration());
    List<BluetoothInfo> bluetoothInfos = bluetoothreader.readData(result.getTraceDirectory(), result.getPcapTime0(), result.getTraceDuration());
    result.setBluetoothInfos(bluetoothInfos);
    result.setBluetoothActiveDuration(bluetoothreader.getBluetoothActiveDuration());
    List<WifiInfo> wifiInfos = wifireader.readData(result.getTraceDirectory(), result.getPcapTime0(), result.getTraceDuration());
    result.setWifiInfos(wifiInfos);
    result.setWifiActiveDuration(wifireader.getWifiActiveDuration());
    List<CameraInfo> cameraInfos = camerareader.readData(result.getTraceDirectory(), result.getPcapTime0(), result.getTraceDuration());
    result.setCameraInfos(cameraInfos);
    result.setCameraActiveDuration(camerareader.getActiveDuration());
    List<ThermalStatusInfo> thermalStatusInfos = new ThermalStatusReaderImpl(filereader).readData(result.getTraceDirectory(), result.getPcapTime0(), result.getTraceDuration());
    result.setThermalstatusInfos(thermalStatusInfos);
    List<ScreenStateInfo> screenStateInfos = screenstatereader.readData(result.getTraceDirectory(), result.getPcapTime0(), result.getTraceDuration());
    result.setScreenStateInfos(screenStateInfos);
    List<BatteryInfo> batteryInfos = batteryinforeader.readData(result.getTraceDirectory(), result.getPcapTime0());
    result.setBatteryInfos(batteryInfos);
    // alarm info from kernel log file
    List<AlarmInfo> alarmInfos = alarminforeader.readData(result.getTraceDirectory(), result.getDumpsysEpochTimestamp(), result.getDumpsysElapsedTimestamp(), result.getTraceDateTime());
    result.setAlarmInfos(alarmInfos);
    List<RadioInfo> radioInfos = radioinforeader.readData(result.getTraceDirectory(), result.getPcapTime0());
    result.setRadioInfos(radioInfos);
    VideoStreamStartupData videoStreamStartupData = videoStartupReader.readData(result.getTraceDirectory());
    result.setVideoStartupData(videoStreamStartupData);
    result.setMetaData(metaDataReadWrite.readData(result.getTraceDirectory()));
}
Also used : CpuActivityList(com.att.aro.core.peripheral.pojo.CpuActivityList) NetworkTypeObject(com.att.aro.core.peripheral.pojo.NetworkTypeObject) BatteryInfo(com.att.aro.core.peripheral.pojo.BatteryInfo) ScreenStateInfo(com.att.aro.core.peripheral.pojo.ScreenStateInfo) CameraInfo(com.att.aro.core.peripheral.pojo.CameraInfo) LocationEvent(com.att.aro.core.peripheral.pojo.LocationEvent) BluetoothInfo(com.att.aro.core.peripheral.pojo.BluetoothInfo) TemperatureEvent(com.att.aro.core.peripheral.pojo.TemperatureEvent) VideoStreamStartupData(com.att.aro.core.peripheral.pojo.VideoStreamStartupData) GpsInfo(com.att.aro.core.peripheral.pojo.GpsInfo) ThermalStatusInfo(com.att.aro.core.peripheral.pojo.ThermalStatusInfo) UserEvent(com.att.aro.core.peripheral.pojo.UserEvent) WifiInfo(com.att.aro.core.peripheral.pojo.WifiInfo) RadioInfo(com.att.aro.core.peripheral.pojo.RadioInfo) CollectOptions(com.att.aro.core.peripheral.pojo.CollectOptions) AlarmInfo(com.att.aro.core.peripheral.pojo.AlarmInfo) ThermalStatusReaderImpl(com.att.aro.core.peripheral.impl.ThermalStatusReaderImpl)

Example 4 with CpuActivityList

use of com.att.aro.core.peripheral.pojo.CpuActivityList in project VideoOptimzer by attdevsupport.

the class FilterProcessesDialog method oKButtonAction.

/**
 * Actions performed when OK button is clicked.
 */
private void oKButtonAction() {
    CpuActivityList cpuAList = ((MainFrame) parent).getController().getTheModel().getAnalyzerResult().getTraceresult().getCpuActivityList();
    cpuAList.setProcessSelection(filteredProcessSelection);
    cpuAList.recalculateTotalCpu();
    PacketAnalyzerResult tempresult = ((MainFrame) parent).getController().getTheModel().getAnalyzerResult();
    BurstCollectionAnalysisData bd = burstAnalysis.analyze(tempresult.getTraceresult().getAllpackets(), tempresult.getProfile(), tempresult.getStatistic().getPacketSizeToCountMap(), tempresult.getStatemachine().getStaterangelist(), tempresult.getTraceresult().getUserEvents(), cpuAList.getCpuActivities(), tempresult.getSessionlist());
    ((MainFrame) parent).getController().getTheModel().getAnalyzerResult().setBurstCollectionAnalysisData(bd);
    ((MainFrame) parent).refresh();
    callerMenuItem.setEnabled(true);
    dispose();
}
Also used : CpuActivityList(com.att.aro.core.peripheral.pojo.CpuActivityList) BurstCollectionAnalysisData(com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) MainFrame(com.att.aro.ui.view.MainFrame)

Example 5 with CpuActivityList

use of com.att.aro.core.peripheral.pojo.CpuActivityList in project VideoOptimzer by attdevsupport.

the class PacketAnalyzerImplTest method Test_analyzeTraceFile_returnIsPacketAnalyzerResult.

@Test
@Ignore
public void Test_analyzeTraceFile_returnIsPacketAnalyzerResult() throws Exception {
    iPacketAnalyzer.setProfileFactory(profilefactory);
    InetAddress iAdr = Mockito.mock(InetAddress.class);
    InetAddress iAdr1 = Mockito.mock(InetAddress.class);
    Mockito.when(iAdr.getAddress()).thenReturn(new byte[] { 89, 10, 1, 1 });
    Mockito.when(iAdr1.getAddress()).thenReturn(new byte[] { 72, 12, 13, 1 });
    Set<InetAddress> inetSet = new HashSet<InetAddress>();
    inetSet.add(iAdr);
    inetSet.add(iAdr1);
    DomainNameSystem dns = Mockito.mock(DomainNameSystem.class);
    Mockito.when(dns.getIpAddresses()).thenReturn(inetSet);
    Mockito.when(dns.getDomainName()).thenReturn("www.att.com");
    UDPPacket udpPacket = Mockito.mock(UDPPacket.class);
    Mockito.when(udpPacket.isDNSPacket()).thenReturn(true);
    Mockito.when(udpPacket.getDns()).thenReturn(dns);
    Mockito.when(udpPacket.getSourcePort()).thenReturn(83);
    Mockito.when(udpPacket.getDestinationPort()).thenReturn(84);
    Mockito.when(udpPacket.getDestinationIPAddress()).thenReturn(iAdr);
    PacketInfo packetInfo1 = Mockito.mock(PacketInfo.class);
    Mockito.when(packetInfo1.getPacket()).thenReturn(udpPacket);
    Mockito.when(packetInfo1.getDir()).thenReturn(PacketDirection.UPLINK);
    Mockito.when(packetInfo1.getPayloadLen()).thenReturn(0);
    Mockito.when(packetInfo1.getLen()).thenReturn(10);
    Mockito.when(packetInfo1.getAppName()).thenReturn("Test1");
    Mockito.when(packetInfo1.getTcpFlagString()).thenReturn("TestString");
    Mockito.when(packetInfo1.getTimeStamp()).thenReturn(500d);
    InetAddress iAdr2 = Mockito.mock(InetAddress.class);
    Mockito.when(iAdr2.getAddress()).thenReturn(new byte[] { 95, 10, 1, 1 });
    TCPPacket tcpPacket = Mockito.mock(TCPPacket.class);
    Mockito.when(tcpPacket.getSourcePort()).thenReturn(81);
    Mockito.when(tcpPacket.getDestinationPort()).thenReturn(82);
    Mockito.when(tcpPacket.getDestinationIPAddress()).thenReturn(iAdr2);
    Mockito.when(tcpPacket.isSYN()).thenReturn(true);
    Mockito.when(tcpPacket.isFIN()).thenReturn(true);
    Mockito.when(tcpPacket.isRST()).thenReturn(true);
    Mockito.when(tcpPacket.getTimeStamp()).thenReturn(1000d);
    PacketInfo packetInfo2 = Mockito.mock(PacketInfo.class);
    Mockito.when(packetInfo2.getPacket()).thenReturn(tcpPacket);
    Mockito.when(packetInfo2.getDir()).thenReturn(PacketDirection.UPLINK);
    Mockito.when(packetInfo2.getTcpInfo()).thenReturn(TcpInfo.TCP_ESTABLISH);
    Mockito.when(packetInfo2.getPayloadLen()).thenReturn(0);
    Mockito.when(packetInfo2.getLen()).thenReturn(15);
    Mockito.when(packetInfo2.getAppName()).thenReturn("Test2");
    Mockito.when(packetInfo2.getTcpFlagString()).thenReturn("Test2String");
    Mockito.when(packetInfo2.getTimeStamp()).thenReturn(10d);
    TCPPacket tcpPacket2 = Mockito.mock(TCPPacket.class);
    Mockito.when(tcpPacket2.getSourcePort()).thenReturn(95);
    Mockito.when(tcpPacket2.getDestinationPort()).thenReturn(99);
    Mockito.when(tcpPacket2.getDestinationIPAddress()).thenReturn(iAdr2);
    Mockito.when(tcpPacket2.isSYN()).thenReturn(true);
    Mockito.when(tcpPacket2.isFIN()).thenReturn(true);
    Mockito.when(tcpPacket2.isRST()).thenReturn(false);
    Mockito.when(tcpPacket2.getTimeStamp()).thenReturn(50d);
    Inet4Address address = (Inet4Address) InetAddress.getByName("192.168.1.4");
    PacketInfo packetInfo3 = Mockito.mock(PacketInfo.class);
    Mockito.when(packetInfo3.getPacket()).thenReturn(tcpPacket2);
    Mockito.when(packetInfo3.getDir()).thenReturn(PacketDirection.UPLINK);
    Mockito.when(packetInfo3.getTcpInfo()).thenReturn(TcpInfo.TCP_ESTABLISH);
    Mockito.when(packetInfo3.getPayloadLen()).thenReturn(0);
    Mockito.when(packetInfo3.getLen()).thenReturn(15);
    Mockito.when(packetInfo3.getAppName()).thenReturn("Test2");
    Mockito.when(packetInfo3.getTcpFlagString()).thenReturn("Test2String");
    Mockito.when(packetInfo3.getTimeStamp()).thenReturn(10d);
    Mockito.when(packetInfo3.getRemoteIPAddress()).thenReturn(address);
    List<PacketInfo> packetsList = new ArrayList<PacketInfo>();
    // Adding UDP Packet to the list
    packetsList.add(packetInfo1);
    packetsList.add(packetInfo2);
    packetsList.add(packetInfo3);
    TraceFileResult mockTraceResult = mock(TraceFileResult.class);
    List<PacketInfo> filteredPackets = new ArrayList<PacketInfo>();
    filteredPackets.add(mock(PacketInfo.class));
    when(mockTraceResult.getAllpackets()).thenReturn(packetsList);
    CpuActivityList cpuList = new CpuActivityList();
    cpuList.add(new CpuActivity());
    when(mockTraceResult.getCpuActivityList()).thenReturn(cpuList);
    when(tracereader.readTraceFile(any(String.class))).thenReturn(mockTraceResult);
    when(mockTraceResult.getTraceResultType()).thenReturn(TraceResultType.TRACE_FILE);
    ProfileLTE profileLTE = new ProfileLTE();
    when(profilefactory.createLTEdefault()).thenReturn(profileLTE);
    AnalysisFilter filter = mock(AnalysisFilter.class);
    filter.setIpv4Sel(false);
    filter.setIpv6Sel(false);
    filter.setUdpSel(false);
    iPacketAnalyzer.setEnergyModelFactory(energymodelfactory);
    iPacketAnalyzer.setBurstCollectionAnalayzer(burstcollectionanalyzer);
    iPacketAnalyzer.setRrcStateMachineFactory(statemachinefactory);
    RrcStateMachineLTE rrcstate = mock(RrcStateMachineLTE.class);
    EnergyModel energymodel = mock(EnergyModel.class);
    List<RrcStateRange> rrcstatelist = new ArrayList<RrcStateRange>();
    when(statemachinefactory.create(any(List.class), any(Profile.class), any(double.class), any(double.class), any(double.class), any(TimeRange.class))).thenReturn(rrcstate);
    when(rrcstate.getStaterangelist()).thenReturn(rrcstatelist);
    when(rrcstate.getTotalRRCEnergy()).thenReturn(1.0);
    when(energymodelfactory.create(any(Profile.class), any(double.class), any(List.class), any(List.class), any(List.class), any(List.class))).thenReturn(energymodel);
    BurstCollectionAnalysisData burstvalue = mock(BurstCollectionAnalysisData.class);
    when(burstcollectionanalyzer.analyze(any(List.class), any(Profile.class), any(Map.class), any(List.class), any(List.class), any(List.class), any(List.class))).thenReturn(burstvalue);
    // when(pktTimeUtil.getTimeRangeResult(any(AbstractTraceResult.class), any(AnalysisFilter.class)))
    // .thenReturn(value);
    PacketAnalyzerResult testResult = iPacketAnalyzer.analyzeTraceFile("", null, filter);
    assertSame(false, testResult.getFilter().isIpv4Sel());
}
Also used : CpuActivityList(com.att.aro.core.peripheral.pojo.CpuActivityList) DomainNameSystem(com.att.aro.core.packetreader.pojo.DomainNameSystem) AnalysisFilter(com.att.aro.core.packetanalysis.pojo.AnalysisFilter) ArrayList(java.util.ArrayList) RrcStateRange(com.att.aro.core.packetanalysis.pojo.RrcStateRange) ProfileLTE(com.att.aro.core.configuration.pojo.ProfileLTE) UDPPacket(com.att.aro.core.packetreader.pojo.UDPPacket) Profile(com.att.aro.core.configuration.pojo.Profile) RrcStateMachineLTE(com.att.aro.core.packetanalysis.pojo.RrcStateMachineLTE) List(java.util.List) CpuActivityList(com.att.aro.core.peripheral.pojo.CpuActivityList) ArrayList(java.util.ArrayList) CpuActivity(com.att.aro.core.peripheral.pojo.CpuActivity) HashSet(java.util.HashSet) Inet4Address(java.net.Inet4Address) EnergyModel(com.att.aro.core.packetanalysis.pojo.EnergyModel) TimeRange(com.att.aro.core.packetanalysis.pojo.TimeRange) TCPPacket(com.att.aro.core.packetreader.pojo.TCPPacket) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) BurstCollectionAnalysisData(com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) InetAddress(java.net.InetAddress) TraceFileResult(com.att.aro.core.packetanalysis.pojo.TraceFileResult) Map(java.util.Map) Ignore(org.junit.Ignore) BaseTest(com.att.aro.core.BaseTest) Test(org.junit.Test)

Aggregations

CpuActivityList (com.att.aro.core.peripheral.pojo.CpuActivityList)7 BaseTest (com.att.aro.core.BaseTest)4 Test (org.junit.Test)4 PacketAnalyzerResult (com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult)3 CpuActivity (com.att.aro.core.peripheral.pojo.CpuActivity)3 ProfileLTE (com.att.aro.core.configuration.pojo.ProfileLTE)2 IFileManager (com.att.aro.core.fileio.IFileManager)2 AnalysisFilter (com.att.aro.core.packetanalysis.pojo.AnalysisFilter)2 BurstCollectionAnalysisData (com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData)2 IOException (java.io.IOException)2 Profile (com.att.aro.core.configuration.pojo.Profile)1 EnergyModel (com.att.aro.core.packetanalysis.pojo.EnergyModel)1 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)1 RrcStateMachineLTE (com.att.aro.core.packetanalysis.pojo.RrcStateMachineLTE)1 RrcStateRange (com.att.aro.core.packetanalysis.pojo.RrcStateRange)1 TimeRange (com.att.aro.core.packetanalysis.pojo.TimeRange)1 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)1 TraceFileResult (com.att.aro.core.packetanalysis.pojo.TraceFileResult)1 DomainNameSystem (com.att.aro.core.packetreader.pojo.DomainNameSystem)1 TCPPacket (com.att.aro.core.packetreader.pojo.TCPPacket)1