Search in sources :

Example 1 with MetaDataModel

use of com.att.aro.core.tracemetadata.pojo.MetaDataModel in project VideoOptimzer by attdevsupport.

the class MetaDataReadWrite method readData.

@Override
public MetaDataModel readData(String tracePath) {
    File jsonFile = filemanager.createFile(tracePath, JSON_FILE);
    if (jsonFile.exists()) {
        try {
            String jsonDataString = filemanager.readAllData(jsonFile.toString());
            metaData = mapper.readValue(jsonDataString, MetaDataModel.class);
            jsonDataSaved = serialize(metaData);
        } catch (Exception e) {
            LOG.debug("failed to load time-range data: " + e.getMessage());
        }
    } else {
        metaData = null;
    }
    return metaData;
}
Also used : MetaDataModel(com.att.aro.core.tracemetadata.pojo.MetaDataModel) File(java.io.File) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 2 with MetaDataModel

use of com.att.aro.core.tracemetadata.pojo.MetaDataModel in project VideoOptimzer by attdevsupport.

the class ARODataCollectorMenu method chooseDevice.

private IAroDevice chooseDevice(IAroDevices aroDevices, List<IDataCollector> collectors) {
    ArrayList<IAroDevice> deviceList = aroDevices.getDeviceList();
    IAroDevice device = null;
    int delayTimeDL = 0;
    int throttleDL = 0;
    int throttleUL = 0;
    boolean throttleDLEnable = false;
    boolean throttleULEnable = false;
    boolean profileBoolean = false;
    String traceFolderName = "";
    String profileLocation = "";
    if (((MainFrame) parent).getPreviousOptions() != null) {
        previousOptions = ((MainFrame) parent).getPreviousOptions();
    }
    metaDataModel = new MetaDataModel();
    DataCollectorSelectNStartDialog dialog = new DataCollectorSelectNStartDialog(((MainFrame) parent).getJFrame(), parent, deviceList, traceFolderName, collectors, true, previousOptions, metaDataModel);
    if (dialog.getResponse()) {
        device = dialog.getDevice();
        traceFolderName = dialog.getTraceFolder();
        device.setCollector(dialog.getCollectorOption());
        /*debug purpose*/
        delayTimeDL = dialog.getDeviceOptionPanel().getAttenuatorModel().getDelayDS();
        dialog.getDeviceOptionPanel().getAttenuatorModel().getDelayUS();
        throttleDL = dialog.getDeviceOptionPanel().getAttenuatorModel().getThrottleDL();
        throttleUL = dialog.getDeviceOptionPanel().getAttenuatorModel().getThrottleUL();
        throttleDLEnable = dialog.getDeviceOptionPanel().getAttenuatorModel().isThrottleDLEnabled();
        throttleULEnable = dialog.getDeviceOptionPanel().getAttenuatorModel().isThrottleULEnabled();
        profileLocation = dialog.getDeviceOptionPanel().getAttenuatorModel().getLocalPath();
        profileBoolean = dialog.getDeviceOptionPanel().getAttenuatorModel().isLoadProfile();
        LOG.info("set U delay: " + delayTimeDL + ", set D delay: " + delayTimeDL + ", set U throttle: " + throttleUL + ", set D throttle: " + throttleDL + ", set profile: " + profileBoolean + ", set profileLocation: " + profileLocation);
        if (device.isPlatform(IAroDevice.Platform.iOS)) {
            IDataCollector iosCollector = findIOSCollector(collectors);
            if ((throttleDLEnable || throttleULEnable) && !NetworkUtil.isNetworkUp(SharedNetIF)) {
                MessageDialogFactory.getInstance().showInformationDialog(((MainFrame) parent).getJFrame(), ResourceBundleHelper.getMessageString("dlog.collector.option.attenuator.attenuation.finalwarning"), ResourceBundleHelper.getMessageString("dlog.collector.option.attenuator.attenuation.noshared"));
                return null;
            }
            if (!checkSetSuPassword(iosCollector)) {
                return null;
            } else {
                LOG.info("pw validated");
            }
        }
        String traceFolderPath = (device.getPlatform().equals(IAroDevice.Platform.Android)) ? Util.getAROTraceDirAndroid() + System.getProperty("file.separator") + traceFolderName : Util.getAROTraceDirIOS() + System.getProperty("file.separator") + traceFolderName;
        String currentPath = ((MainFrame) parent).getTracePath();
        if (fileManager.directoryExistAndNotEmpty(traceFolderPath)) {
            int result = folderExistsDialog();
            if (result == JOptionPane.OK_OPTION) {
                if (traceFolderPath.equals(currentPath)) {
                    new MessageDialogFactory().showErrorDialog(null, ResourceBundleHelper.getMessageString("viewer.contentUnwritable"));
                    return null;
                }
                File mountPoint = fileManager.createFile(traceFolderPath, IOSCollectorImpl.IOSAPP_MOUNT);
                if (fileManager.createFile(traceFolderPath, IOSCollectorImpl.IOSAPP_MOUNT).exists() && device.getPlatform().equals(IAroDevice.Platform.iOS)) {
                    IExternalProcessRunner runner = new ExternalProcessRunnerImpl();
                    String results = runner.executeCmd(String.format("umount %s;rmdir %s", mountPoint, mountPoint));
                    if (!results.isEmpty()) {
                        new MessageDialogFactory().showErrorDialog(null, traceFolderPath + "/" + IOSCollectorImpl.IOSAPP_MOUNT + " is BUSY");
                        return null;
                    } else {
                        int count = 0;
                        while (fileManager.directoryExistAndNotEmpty(mountPoint.toString())) {
                            if (++count > 5) {
                                new MessageDialogFactory().showErrorDialog(null, traceFolderPath + "/" + IOSCollectorImpl.IOSAPP_MOUNT + " will not release, please detach the iOS device and delete the foldere manually");
                                return null;
                            }
                            try {
                                Thread.sleep(1000);
                            } catch (InterruptedException e) {
                                Log.error("sleep interrupted");
                            }
                        }
                    }
                }
                fileManager.deleteFolderContents(traceFolderPath);
            } else {
                return null;
            }
        }
        Hashtable<String, Object> extras = prepareStartCollectorExtras(device, traceFolderName, dialog);
        updateMetaData(device, traceFolderName, dialog);
        extras.put("DIALOG_SIZE", dialog.getBaseSize());
        if (dialog.getDeviceOptionPanel().getLabeledExpandedOptionFields().isVisible()) {
            extras.put("MetaDataExpanded", true);
        }
        ((MainFrame) parent).startCollector(device, traceFolderName, extras, metaDataModel);
    } else {
        traceFolderName = null;
    }
    dialog.dispose();
    return device;
}
Also used : MetaDataModel(com.att.aro.core.tracemetadata.pojo.MetaDataModel) MainFrame(com.att.aro.ui.view.MainFrame) IExternalProcessRunner(com.att.aro.core.commandline.IExternalProcessRunner) IAroDevice(com.att.aro.core.mobiledevice.pojo.IAroDevice) DataCollectorSelectNStartDialog(com.att.aro.ui.commonui.DataCollectorSelectNStartDialog) MessageDialogFactory(com.att.aro.ui.commonui.MessageDialogFactory) IDataCollector(com.att.aro.core.datacollector.IDataCollector) File(java.io.File) ExternalProcessRunnerImpl(com.att.aro.core.commandline.impl.ExternalProcessRunnerImpl)

Example 3 with MetaDataModel

use of com.att.aro.core.tracemetadata.pojo.MetaDataModel in project VideoOptimzer by attdevsupport.

the class MetaDataHelper method initMetaData.

@Override
public MetaDataModel initMetaData(String tracePath, String traceDesc, String traceType, String targetedApp, String appProducer) {
    metaData = new MetaDataModel();
    metaData.setDescription(traceDesc);
    metaData.setTargetedApp(targetedApp);
    metaData.setTraceType(traceType);
    metaData.setApplicationProducer(appProducer);
    try {
        metaDataReadWrite.save(filemanager.createFile(tracePath), metaData);
    } catch (Exception e) {
        LOG.error("Faild to save metadata", e);
    }
    return metaData;
}
Also used : MetaDataModel(com.att.aro.core.tracemetadata.pojo.MetaDataModel)

Example 4 with MetaDataModel

use of com.att.aro.core.tracemetadata.pojo.MetaDataModel in project VideoOptimzer by attdevsupport.

the class MetaDataHelper method initMetaData.

@Override
public MetaDataModel initMetaData(PacketAnalyzerResult result) {
    String tracePath = result.getTraceresult().getTraceDirectory();
    if ((metaData = metaDataReadWrite.readData(tracePath)) == null) {
        metaData = new MetaDataModel();
    } else {
        // metadata.json file did not exist
        int pos = tracePath.lastIndexOf(Util.FILE_SEPARATOR);
        String description = pos > 0 ? tracePath.substring(pos + 1) : tracePath;
        if (!filemanager.createFile(tracePath, METADATA_FILE).exists()) {
            metaData = new MetaDataModel();
            metaData.setDescription(description);
            metaData.setTraceType(UNKNOWN);
            metaData.setTargetedApp(UNKNOWN);
            metaData.setApplicationProducer(UNKNOWN);
        } else {
            try {
                metaData = loadMetaData(tracePath);
            } catch (Exception e) {
                LOG.error("error reading data from BufferedReader", e);
            }
        }
        try {
            if (updateMetaData(result)) {
                saveJSON(tracePath);
            }
        } catch (Exception e) {
            LOG.error("error saving metadata", e);
        }
    }
    return metaData;
}
Also used : MetaDataModel(com.att.aro.core.tracemetadata.pojo.MetaDataModel)

Example 5 with MetaDataModel

use of com.att.aro.core.tracemetadata.pojo.MetaDataModel in project VideoOptimzer by attdevsupport.

the class PacketAnalyzerImplTest method Test_analyzeTraceDirectory_returnIsPacketAnalyzerResult.

@Test
public void Test_analyzeTraceDirectory_returnIsPacketAnalyzerResult() throws Exception {
    iPacketAnalyzer.setEnergyModelFactory(energymodelfactory);
    iPacketAnalyzer.setBurstCollectionAnalayzer(burstcollectionanalyzer);
    iPacketAnalyzer.setRrcStateMachineFactory(statemachinefactory);
    iPacketAnalyzer.setProfileFactory(profilefactory);
    TraceDirectoryResult mockTraceDirResult = mock(TraceDirectoryResult.class);
    MetaDataHelper metaDataHelper = mock(MetaDataHelper.class);
    MetaDataModel metaDataModel = new MetaDataModel();
    AnalysisFilter filter = mock(AnalysisFilter.class);
    filter.setIpv4Sel(true);
    filter.setIpv6Sel(true);
    filter.setUdpSel(true);
    CpuActivityList cpuList = new CpuActivityList();
    cpuList.add(new CpuActivity());
    when(mockTraceDirResult.getCpuActivityList()).thenReturn(cpuList);
    when(tracereader.readTraceDirectory(any(String.class))).thenReturn(mockTraceDirResult);
    when(metaDataHelper.initMetaData(any(PacketAnalyzerResult.class))).thenReturn(metaDataModel);
    ProfileLTE profileLTE = new ProfileLTE();
    when(profilefactory.createLTEdefault()).thenReturn(profileLTE);
    PacketAnalyzerResult testResult = iPacketAnalyzer.analyzeTraceDirectory("", profileLTE, filter);
    assertEquals(null, testResult.getSessionlist());
}
Also used : CpuActivityList(com.att.aro.core.peripheral.pojo.CpuActivityList) AnalysisFilter(com.att.aro.core.packetanalysis.pojo.AnalysisFilter) MetaDataModel(com.att.aro.core.tracemetadata.pojo.MetaDataModel) TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) MetaDataHelper(com.att.aro.core.tracemetadata.impl.MetaDataHelper) ProfileLTE(com.att.aro.core.configuration.pojo.ProfileLTE) CpuActivity(com.att.aro.core.peripheral.pojo.CpuActivity) BaseTest(com.att.aro.core.BaseTest) Test(org.junit.Test)

Aggregations

MetaDataModel (com.att.aro.core.tracemetadata.pojo.MetaDataModel)5 File (java.io.File)2 BaseTest (com.att.aro.core.BaseTest)1 IExternalProcessRunner (com.att.aro.core.commandline.IExternalProcessRunner)1 ExternalProcessRunnerImpl (com.att.aro.core.commandline.impl.ExternalProcessRunnerImpl)1 ProfileLTE (com.att.aro.core.configuration.pojo.ProfileLTE)1 IDataCollector (com.att.aro.core.datacollector.IDataCollector)1 IAroDevice (com.att.aro.core.mobiledevice.pojo.IAroDevice)1 AnalysisFilter (com.att.aro.core.packetanalysis.pojo.AnalysisFilter)1 PacketAnalyzerResult (com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult)1 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)1 CpuActivity (com.att.aro.core.peripheral.pojo.CpuActivity)1 CpuActivityList (com.att.aro.core.peripheral.pojo.CpuActivityList)1 MetaDataHelper (com.att.aro.core.tracemetadata.impl.MetaDataHelper)1 DataCollectorSelectNStartDialog (com.att.aro.ui.commonui.DataCollectorSelectNStartDialog)1 MessageDialogFactory (com.att.aro.ui.commonui.MessageDialogFactory)1 MainFrame (com.att.aro.ui.view.MainFrame)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 Test (org.junit.Test)1