Search in sources :

Example 1 with Profile

use of com.att.aro.core.configuration.pojo.Profile in project VideoOptimzer by attdevsupport.

the class ProfileFactoryImpl method createBaseData.

private void createBaseData(Profile profile, Properties properties) {
    Profile pro = profile;
    pro.setCarrier(readString(properties, ProfileLTE.CARRIER, "AT&T"));
    pro.setUserInputTh(readDouble(properties, Profile.USER_INPUT_TH, pro.getUserInputTh()));
    pro.setPowerGpsActive(readDouble(properties, Profile.POWER_GPS_ACTIVE, pro.getPowerGpsActive()));
    pro.setPowerGpsStandby(readDouble(properties, Profile.POWER_GPS_STANDBY, pro.getPowerGpsStandby()));
    pro.setPowerCameraOn(readDouble(properties, Profile.POWER_CAMERA_ON, pro.getPowerCameraOn()));
    pro.setPowerBluetoothActive(readDouble(properties, Profile.POWER_BLUETOOTH_ACTIVE, pro.getPowerBluetoothActive()));
    pro.setPowerBluetoothStandby(readDouble(properties, Profile.POWER_BLUETOOTH_STANDBY, pro.getPowerBluetoothStandby()));
    pro.setPowerScreenOn(readDouble(properties, Profile.POWER_SCREEN_ON, pro.getPowerScreenOn()));
    pro.setBurstTh(readDouble(properties, Profile.BURST_TH, pro.getBurstTh()));
    pro.setLongBurstTh(readDouble(properties, Profile.LONG_BURST_TH, pro.getLongBurstTh()));
    pro.setPeriodMinCycle(readDouble(properties, Profile.PERIOD_MIN_CYCLE, pro.getPeriodMinCycle()));
    pro.setPeriodCycleTol(readDouble(properties, Profile.PERIOD_CYCLE_TOL, pro.getPeriodCycleTol()));
    pro.setPeriodMinSamples(readInt(properties, Profile.PERIOD_MIN_SAMPLES, pro.getPeriodMinSamples()));
    pro.setLargeBurstDuration(readDouble(properties, Profile.LARGE_BURST_DURATION, pro.getLargeBurstDuration()));
    pro.setLargeBurstSize(readInt(properties, Profile.LARGE_BURST_SIZE, pro.getLargeBurstSize()));
    pro.setCloseSpacedBurstThreshold(readDouble(properties, Profile.CLOSE_SPACED_BURSTS, pro.getCloseSpacedBurstThreshold()));
    pro.setThroughputWindow(readDouble(properties, Profile.W_THROUGHPUT, pro.getThroughputWindow()));
    pro.setInit(true);
}
Also used : Profile(com.att.aro.core.configuration.pojo.Profile)

Example 2 with Profile

use of com.att.aro.core.configuration.pojo.Profile in project VideoOptimzer by attdevsupport.

the class ProfileFactoryImpl method setBaseData.

private void setBaseData(Profile profile, Properties properties) {
    Profile prof = profile;
    Properties props = properties;
    props.setProperty(Profile.CARRIER, prof.getCarrier());
    props.setProperty(Profile.DEVICE, prof.getDevice());
    props.setProperty(Profile.PROFILE_TYPE, prof.getProfileType().name());
    props.setProperty(Profile.USER_INPUT_TH, String.valueOf(prof.getUserInputTh()));
    props.setProperty(Profile.POWER_GPS_ACTIVE, String.valueOf(prof.getPowerGpsActive()));
    props.setProperty(Profile.POWER_GPS_STANDBY, String.valueOf(prof.getPowerGpsStandby()));
    props.setProperty(Profile.POWER_CAMERA_ON, String.valueOf(prof.getPowerCameraOn()));
    props.setProperty(Profile.POWER_BLUETOOTH_ACTIVE, String.valueOf(prof.getPowerBluetoothActive()));
    props.setProperty(Profile.POWER_BLUETOOTH_STANDBY, String.valueOf(prof.getPowerBluetoothStandby()));
    props.setProperty(Profile.POWER_SCREEN_ON, String.valueOf(prof.getPowerScreenOn()));
    props.setProperty(Profile.BURST_TH, String.valueOf(prof.getBurstTh()));
    props.setProperty(Profile.LONG_BURST_TH, String.valueOf(prof.getLongBurstTh()));
    props.setProperty(Profile.PERIOD_MIN_CYCLE, String.valueOf(prof.getPeriodMinCycle()));
    props.setProperty(Profile.PERIOD_CYCLE_TOL, String.valueOf(prof.getPeriodCycleTol()));
    props.setProperty(Profile.PERIOD_MIN_SAMPLES, String.valueOf(prof.getPeriodMinSamples()));
    props.setProperty(Profile.LARGE_BURST_DURATION, String.valueOf(prof.getLargeBurstDuration()));
    props.setProperty(Profile.LARGE_BURST_SIZE, String.valueOf(prof.getLargeBurstSize()));
    props.setProperty(Profile.CLOSE_SPACED_BURSTS, String.valueOf(prof.getCloseSpacedBurstThreshold()));
    props.setProperty(Profile.W_THROUGHPUT, String.valueOf(prof.getThroughputWindow()));
}
Also used : Properties(java.util.Properties) Profile(com.att.aro.core.configuration.pojo.Profile)

Example 3 with Profile

use of com.att.aro.core.configuration.pojo.Profile in project VideoOptimzer by attdevsupport.

the class EnergyModelFactoryImplTest method create_Test.

@Test
public void create_Test() {
    Date date = new Date();
    Profile profile = Mockito.mock(Profile.class);
    Mockito.when(profile.getPowerGpsActive()).thenReturn(1.0);
    GpsInfo gpsInfo01 = Mockito.mock(GpsInfo.class);
    Mockito.when(gpsInfo01.getBeginTimeStamp()).thenReturn(date.getTime() + 0.0);
    Mockito.when(gpsInfo01.getEndTimeStamp()).thenReturn(date.getTime() + 1000.0);
    Mockito.when(gpsInfo01.getGpsState()).thenReturn(GpsState.GPS_ACTIVE);
    GpsInfo gpsInfo02 = Mockito.mock(GpsInfo.class);
    Mockito.when(profile.getPowerGpsStandby()).thenReturn(0.5);
    Mockito.when(gpsInfo02.getBeginTimeStamp()).thenReturn(date.getTime() + 0.0);
    Mockito.when(gpsInfo02.getEndTimeStamp()).thenReturn(date.getTime() + 1000.0);
    Mockito.when(gpsInfo02.getGpsState()).thenReturn(GpsState.GPS_STANDBY);
    List<GpsInfo> gpsList = new ArrayList<GpsInfo>();
    gpsList.add(gpsInfo01);
    gpsList.add(gpsInfo02);
    CameraInfo cameraInfo01 = Mockito.mock(CameraInfo.class);
    Mockito.when(cameraInfo01.getBeginTimeStamp()).thenReturn(date.getTime() + 0.0);
    Mockito.when(cameraInfo01.getEndTimeStamp()).thenReturn(date.getTime() + 1000.0);
    Mockito.when(cameraInfo01.getCameraState()).thenReturn(CameraState.CAMERA_ON);
    Mockito.when(profile.getPowerCameraOn()).thenReturn(0.3);
    List<CameraInfo> cameraList = new ArrayList<CameraInfo>();
    cameraList.add(cameraInfo01);
    BluetoothInfo bluetoothInfo01 = Mockito.mock(BluetoothInfo.class);
    Mockito.when(bluetoothInfo01.getBeginTimeStamp()).thenReturn(date.getTime() + 0.0);
    Mockito.when(bluetoothInfo01.getEndTimeStamp()).thenReturn(date.getTime() + 1000.0);
    Mockito.when(bluetoothInfo01.getBluetoothState()).thenReturn(BluetoothState.BLUETOOTH_CONNECTED);
    BluetoothInfo bluetoothInfo02 = Mockito.mock(BluetoothInfo.class);
    Mockito.when(bluetoothInfo02.getBeginTimeStamp()).thenReturn(date.getTime() + 0.0);
    Mockito.when(bluetoothInfo02.getEndTimeStamp()).thenReturn(date.getTime() + 1000.0);
    Mockito.when(bluetoothInfo02.getBluetoothState()).thenReturn(BluetoothState.BLUETOOTH_DISCONNECTED);
    List<BluetoothInfo> bluetoothList = new ArrayList<BluetoothInfo>();
    bluetoothList.add(bluetoothInfo01);
    bluetoothList.add(bluetoothInfo02);
    Mockito.when(profile.getPowerBluetoothActive()).thenReturn(1.0);
    Mockito.when(profile.getPowerBluetoothStandby()).thenReturn(0.5);
    ScreenStateInfo screenStateInfo01 = Mockito.mock(ScreenStateInfo.class);
    Mockito.when(screenStateInfo01.getBeginTimeStamp()).thenReturn(date.getTime() + 0.0);
    Mockito.when(screenStateInfo01.getEndTimeStamp()).thenReturn(date.getTime() + 1000.0);
    Mockito.when(screenStateInfo01.getScreenState()).thenReturn(ScreenState.SCREEN_ON);
    List<ScreenStateInfo> screenStateList = new ArrayList<ScreenStateInfo>();
    screenStateList.add(screenStateInfo01);
    Mockito.when(profile.getPowerScreenOn()).thenReturn(0.3);
    EnergyModel model = eMdlFctr.create(profile, 0.0, gpsList, cameraList, bluetoothList, screenStateList);
    assertEquals(1000.0, model.getGpsActiveEnergy(), 0.0);
    assertEquals(500.0, model.getGpsStandbyEnergy(), 0.0);
    assertEquals(1500.0, model.getTotalGpsEnergy(), 0.0);
    assertEquals(300.0, model.getTotalCameraEnergy(), 0.0);
    assertEquals(1000.0, model.getBluetoothActiveEnergy(), 0.0);
    assertEquals(500.0, model.getBluetoothStandbyEnergy(), 0.0);
    assertEquals(1500.0, model.getTotalBluetoothEnergy(), 0.0);
    assertEquals(300.0, model.getTotalScreenEnergy(), 0.0);
}
Also used : BluetoothInfo(com.att.aro.core.peripheral.pojo.BluetoothInfo) EnergyModel(com.att.aro.core.packetanalysis.pojo.EnergyModel) GpsInfo(com.att.aro.core.peripheral.pojo.GpsInfo) ArrayList(java.util.ArrayList) ScreenStateInfo(com.att.aro.core.peripheral.pojo.ScreenStateInfo) CameraInfo(com.att.aro.core.peripheral.pojo.CameraInfo) Date(java.util.Date) Profile(com.att.aro.core.configuration.pojo.Profile) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 4 with Profile

use of com.att.aro.core.configuration.pojo.Profile in project VideoOptimzer by attdevsupport.

the class SelectProfileDialog method getOkButton.

/**
 * Initializes and returns the "OK" button on the selection dialog.
 */
private JButton getOkButton() {
    if (okButton == null) {
        okButton = new JButton();
        okButton.setText(ResourceBundleHelper.getMessageString("Button.ok"));
        okButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
                String filename = getFilenameTextField().getText();
                Profile profile = jProfilesTable.getSelectedItem();
                if (profile == null) {
                    if (filename == null || filename.trim().length() == 0) {
                        LOGGER.debug(ResourceBundleHelper.getMessageString("profile.noselection"));
                        MessageDialogFactory.getInstance().showErrorDialog(SelectProfileDialog.this, ResourceBundleHelper.getMessageString("profile.noselection"));
                    } else {
                        try {
                            File file = new File(filename);
                            selectedProfile = ProfileManager.getInstance().getProfile(file);
                            profile = selectedProfile;
                            profile.setName(file.getPath());
                            parent.updateProfile(profile);
                            dispose();
                        } catch (FileNotFoundException fnfException) {
                            LOGGER.debug(fnfException.getMessage(), fnfException);
                            MessageDialogFactory.getInstance().showErrorDialog(SelectProfileDialog.this, ResourceBundleHelper.getMessageString("profile.filenotfound"));
                        } catch (IOException ioException) {
                            String message = "Unable to load device profile file: " + filename;
                            LOGGER.debug(message, ioException);
                            MessageDialogFactory.getInstance().showErrorDialog(SelectProfileDialog.this, ioException.getMessage());
                        } catch (ProfileException profileException) {
                            LOGGER.debug(profileException.getMessage(), profileException);
                            MessageDialogFactory.getInstance().showErrorDialog(SelectProfileDialog.this, MessageFormat.format(ResourceBundleHelper.getMessageString("configuration.parseerror"), profileException.getMessage()));
                        } catch (IllegalArgumentException illegalArgException) {
                            LOGGER.debug(illegalArgException.getMessage(), illegalArgException);
                            MessageDialogFactory.getInstance().showErrorDialog(SelectProfileDialog.this, ResourceBundleHelper.getMessageString("profile.invalid"));
                        }
                    }
                } else {
                    SelectProfileDialog.this.selectedProfile = profile;
                    parent.updateProfile(profile);
                    SelectProfileDialog.this.dispose();
                }
            }
        });
        getRootPane().setDefaultButton(okButton);
    }
    return okButton;
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) File(java.io.File) Profile(com.att.aro.core.configuration.pojo.Profile)

Example 5 with Profile

use of com.att.aro.core.configuration.pojo.Profile in project VideoOptimzer by attdevsupport.

the class PacketAnalyzerImpl method finalResult.

protected PacketAnalyzerResult finalResult(AbstractTraceResult result, Profile profile, AnalysisFilter filter) {
    PacketAnalyzerResult data = new PacketAnalyzerResult();
    if (filter == null) {
        double endTime = result.getAllpackets().size() > 0 ? Math.max(result.getAllpackets().get(result.getAllpackets().size() - 1).getTimeStamp(), result.getTraceDuration()) : 0.0;
        result.setTimeRange(new TimeRange("Full", TimeRange.TimeRangeType.FULL, 0.0, endTime));
    } else {
        result.setTimeRange(filter.getTimeRange());
    }
    // List of packets included in analysis (application filtered)
    List<PacketInfo> filteredPackets;
    Profile aProfile = profile;
    if (aProfile == null) {
        // if the user doesn't load any profile.....
        aProfile = profilefactory.createLTEdefault();
        aProfile.setName("AT&T LTE");
    }
    // for the situation, filter out all no-ip packets and caused the allpackets is empty, need to refactor
    if (result != null && result.getAllpackets() != null && result.getAllpackets().size() == 0) {
        data.setTraceresult(result);
        return data;
    }
    /* Purpose of this code block is to finish building out the filter, if needed, for TimeRange analysis
		 * 
		 * This code block is excuted when:
		 *  1: time-range.json exists in trace folder
		 *  	a: and the json contains an entry with RangeType.AUTO
		 *  2: A TimeRange object was created and launched in TimeRangeEditorDialog
		 *  
		 *  AroController will have created an AnalysisFilter and so filter will not be null
		 *  
		 */
    try {
        if ((filter != null && filter.getTimeRange() != null && filter.getTimeRange().getPath() != null) || result.getAllAppNames().size() == 1) {
            String app = TraceDataReaderImpl.UNKNOWN_APPNAME;
            if (filter != null && filter.getAppSelections() != null && filter.getAppSelections().containsKey(app) && filter.getAppSelections().get(app).getIPAddressSelections().isEmpty()) {
                LOGGER.debug("AUTO Time Range analysis: add all found appIps to " + app + ", then store in the filter");
                ApplicationSelection appSelection = new ApplicationSelection(app, result.getAppIps().get(app));
                filter.getAppSelections().put(app, appSelection);
            }
        }
    } catch (Exception e) {
        LOGGER.error("Error handling TimeRange JSON data", e);
    }
    TimeRange timeRange = null;
    boolean isCSI = false;
    filteredPackets = new ArrayList<PacketInfo>();
    if (filter == null) {
        if (result != null) {
            filteredPackets = result.getAllpackets();
        }
    } else {
        // do the filter
        if (filter.isCSI() && filter.getManifestFilePath() != null) {
            isCSI = true;
        }
        timeRange = filter.getTimeRange();
        if (result != null) {
            filteredPackets = filterPackets(filter, result.getAllpackets());
        }
    }
    // Fix for Sev 2 Time Range Analysis Issue - DE187848
    if (result != null) {
        result.setAllpackets(filteredPackets);
        SessionManagerImpl sessionMangerImpl = (SessionManagerImpl) sessionmanager;
        sessionMangerImpl.setPcapTimeOffset(result.getPcapTimeOffset());
        // for iOS trace
        sessionmanager.setiOSSecureTracePath(result.getTraceDirectory());
        // Check if secure trace path exists
        if (result instanceof TraceDirectoryResult) {
            File file = new File(((SessionManagerImpl) sessionmanager).getTracePath());
            if (file.exists()) {
                ((TraceDirectoryResult) result).setSecureTrace(true);
            }
        }
    }
    Statistic stat = this.getStatistic(filteredPackets);
    List<Session> sessionList = sessionmanager.processPacketsAndAssembleSessions(filteredPackets);
    generateGetRequestMapAndPopulateLatencyStat(sessionList, stat);
    if (result != null && stat.getAppName() != null && stat.getAppName().size() == 1 && stat.getAppName().contains(TraceDataReaderImpl.UNKNOWN_APPNAME)) {
        stat.setAppName(new HashSet<String>(result.getAppInfos()));
    }
    // get Unanalyzed HTTPS bytes
    boolean isSecureTrace = result instanceof TraceDirectoryResult ? ((TraceDirectoryResult) result).isSecureTrace() : false;
    if (isSecureTrace) {
        stat.setTotalHTTPSBytesNotAnalyzed(getHttpsBytesNotAnalyzed(sessionList));
    } else {
        stat.setTotalHTTPSBytesNotAnalyzed(stat.getTotalHTTPSByte());
    }
    // stat is used to get some info for RrcStateMachine etc
    if (result != null) {
        LOGGER.debug("Starting pre processing in PAI");
        AbstractRrcStateMachine statemachine = statemachinefactory.create(filteredPackets, aProfile, stat.getPacketDuration(), result.getTraceDuration(), stat.getTotalByte(), timeRange);
        EnergyModel energymodel = energymodelfactory.create(aProfile, statemachine.getTotalRRCEnergy(), result.getGpsInfos(), result.getCameraInfos(), result.getBluetoothInfos(), result.getScreenStateInfos());
        BurstCollectionAnalysisData burstcollectiondata = burstcollectionanalyzer.analyze(filteredPackets, aProfile, stat.getPacketSizeToCountMap(), statemachine.getStaterangelist(), result.getUserEvents(), result.getCpuActivityList().getCpuActivities(), sessionList);
        data.clearBPResults();
        try {
            List<BestPracticeType> videoBPList = BestPracticeType.getByCategory(BestPracticeType.Category.VIDEO);
            data.setStreamingVideoData(videoTrafficCollector.clearData());
            if (CollectionUtils.containsAny(SettingsUtil.retrieveBestPractices(), videoBPList)) {
                if (isCSI || csiDataHelper.doesCSIFileExist(result.getTraceDirectory())) {
                    data.setStreamingVideoData(videoTrafficInferencer.inferVideoData(result, sessionList, (filter != null && filter.getManifestFilePath() != null) ? filter.getManifestFilePath() : result.getTraceDirectory()));
                } else {
                    data.setStreamingVideoData(videoTrafficCollector.collect(result, sessionList, requestMap));
                }
            }
        } catch (Exception ex) {
            LOGGER.error("Error in Video usage analysis :", ex);
            // Guarantee that StreamingVideoData is empty
            data.setStreamingVideoData(videoTrafficCollector.clearData());
            data.getStreamingVideoData().setFinished(true);
        }
        try {
            List<BestPracticeType> imageBPList = new ArrayList<>();
            imageBPList.add(BestPracticeType.IMAGE_MDATA);
            imageBPList.add(BestPracticeType.IMAGE_CMPRS);
            imageBPList.add(BestPracticeType.IMAGE_FORMAT);
            imageBPList.add(BestPracticeType.IMAGE_COMPARE);
            if (CollectionUtils.containsAny(SettingsUtil.retrieveBestPractices(), imageBPList)) {
                imageExtractor.execute(result, sessionList, requestMap);
            }
        } catch (Exception ex) {
            LOGGER.error("Error in Image extraction:" + ex.getMessage(), ex);
        }
        htmlExtractor.execute(result, sessionList, requestMap);
        // Calculate time range analysis
        double beginTime = 0.0d;
        double endTime = 0.0d;
        if (filter != null && filter.getTimeRange() != null) {
            beginTime = filter.getTimeRange().getBeginTime();
            endTime = filter.getTimeRange().getEndTime();
        } else {
            endTime = result.getTraceDuration();
        }
        data.setBurstCollectionAnalysisData(burstcollectiondata);
        data.setEnergyModel(energymodel);
        data.setSessionlist(sessionList);
        data.setStatemachine(statemachine);
        data.setStatistic(stat);
        data.setTraceresult(result);
        data.setProfile(aProfile);
        data.setFilter(filter);
        data.setDeviceKeywords(result.getDeviceKeywordInfos());
        data.setTimeRangeAnalysis(new TimeRangeAnalysis(beginTime, endTime, data));
    }
    return data;
}
Also used : ApplicationSelection(com.att.aro.core.packetanalysis.pojo.ApplicationSelection) ArrayList(java.util.ArrayList) BestPracticeType(com.att.aro.core.bestpractice.pojo.BestPracticeType) Profile(com.att.aro.core.configuration.pojo.Profile) Statistic(com.att.aro.core.packetanalysis.pojo.Statistic) TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) AbstractRrcStateMachine(com.att.aro.core.packetanalysis.pojo.AbstractRrcStateMachine) EnergyModel(com.att.aro.core.packetanalysis.pojo.EnergyModel) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) TimeRange(com.att.aro.core.packetanalysis.pojo.TimeRange) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) BurstCollectionAnalysisData(com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) File(java.io.File) Session(com.att.aro.core.packetanalysis.pojo.Session)

Aggregations

Profile (com.att.aro.core.configuration.pojo.Profile)21 IOException (java.io.IOException)7 File (java.io.File)4 IProfileFactory (com.att.aro.core.configuration.IProfileFactory)3 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)3 RRCState (com.att.aro.core.packetanalysis.pojo.RRCState)3 RrcStateRange (com.att.aro.core.packetanalysis.pojo.RrcStateRange)3 MessageDialogFactory (com.att.aro.ui.commonui.MessageDialogFactory)3 ArrayList (java.util.ArrayList)3 Properties (java.util.Properties)3 TableCellEditor (javax.swing.table.TableCellEditor)3 ProfileLTE (com.att.aro.core.configuration.pojo.ProfileLTE)2 ProfileType (com.att.aro.core.configuration.pojo.ProfileType)2 EnergyModel (com.att.aro.core.packetanalysis.pojo.EnergyModel)2 TimeRange (com.att.aro.core.packetanalysis.pojo.TimeRange)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 FileNotFoundException (java.io.FileNotFoundException)2 BaseTest (com.att.aro.core.BaseTest)1 BestPracticeType (com.att.aro.core.bestpractice.pojo.BestPracticeType)1