Search in sources :

Example 1 with OutPara

use of com.tencent.wstt.gt.OutPara in project GT by Tencent.

the class OutParaManagerInternal method register.

public void register(String ParaName, String alias, Object... extras) {
    if (null == ParaName || null == alias) {
        return;
    }
    if (alias.length() > 4) {
        alias = alias.substring(0, 3) + ".";
    }
    OutPara Para = new OutPara();
    Para.setKey(ParaName);
    Para.setAlias(alias);
    Para.setRegistering(true);
    Para.setDisplayProperty(OutPara.DISPLAY_NORMAL);
    if (null != extras && extras.length > 0) {
        if (extras[0] instanceof Boolean) {
            boolean isGlobal = Boolean.TRUE.equals(extras[0]);
            Para.setGlobal(isGlobal);
        }
    }
    temp.add(Para);
}
Also used : OutPara(com.tencent.wstt.gt.OutPara)

Example 2 with OutPara

use of com.tencent.wstt.gt.OutPara in project GT by Tencent.

the class GTParamListBaseAdapter method getItemViewType.

@Override
public int getItemViewType(int position) {
    AidlEntry o = list.get(position);
    String key = "";
    if (o instanceof OutPara) {
        key = ((OutPara) o).getKey();
    } else {
        key = ((InPara) o).getKey();
    }
    int result = TYPE_SWITCH_ITEM;
    if (key.equals(ParamConst.PROMPT_TITLE) || key.equals(ParamConst.PROMPT_INIT_TITLE)) {
        result = TYPE_PROMPT_ITEM;
    } else if (key.equals(ParamConst.DIVID_TITLE)) {
        result = TYPE_DIVIDE_ITEM;
    } else if (key.equals(ParamConst.PROMPT_DISABLE_TITLE)) {
        result = TYPE_DISABLE_ITEM;
    } else {
        result = TYPE_SWITCH_ITEM;
    }
    return result;
}
Also used : AidlEntry(com.tencent.wstt.gt.AidlEntry) OutPara(com.tencent.wstt.gt.OutPara)

Example 3 with OutPara

use of com.tencent.wstt.gt.OutPara in project GT by Tencent.

the class GTParamOutListAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ParamConst.ViewHolderDrag_nopic switch_drag = null;
    final OutPara ov = (OutPara) list.get(position);
    final String key = ov.getKey();
    String value = ov.getFreezValue();
    // 已记录历史数据个数的获取
    TagTimeEntry tte = OpPerfBridge.getProfilerData(key);
    int his_count = 0;
    if (tte != null) {
        if (tte.hasChild()) {
            his_count = tte.getChildren()[0].getRecordSize();
        } else {
            his_count = tte.getRecordSize();
        }
    }
    final String alias = ov.getAlias();
    final int type = getItemViewType(position);
    /*
		 * 根据每行UI的类型进行UI模型准备与数据准备
		 */
    int disable_pos = OpUIManager.getOutListDisableTitlePosition();
    switch(type) {
        case TYPE_PROMPT_ITEM:
            convertView = PROMPT_ITEM_convertView;
            break;
        case TYPE_DIVIDE_ITEM:
            convertView = DIVIDE_ITEM_convertView;
            break;
        case TYPE_DISABLE_ITEM:
            convertView = DISABLE_ITEM_convertView;
            break;
        case TYPE_SWITCH_ITEM:
            if (convertView == null) {
                convertView = mInflater.inflate(R.layout.gt_outlistrow_value, null);
                switch_drag = new ParamConst.ViewHolderDrag_nopic();
                switch_drag.tv_key = (TextView) convertView.findViewById(R.id.draglist_key);
                switch_drag.tv_alias = (TextView) convertView.findViewById(R.id.draglist_shotkey);
                switch_drag.tv_value = (TextView) convertView.findViewById(R.id.draglist_value);
                switch_drag.tv_listview_bottom_border = (TextView) convertView.findViewById(R.id.listrow_bottom_border);
                switch_drag.tv_his_data = (TextView) convertView.findViewById(R.id.data_flag);
                switch_drag.tv_listrowbg = (TextView) convertView.findViewById(R.id.listrow_bg);
                switch_drag.cb = (CheckBox) convertView.findViewById(R.id.cb_tick);
            } else {
                switch_drag = (ParamConst.ViewHolderDrag_nopic) convertView.getTag();
            }
            if (ov.isAlert()) {
                switch_drag.tv_listrowbg.setBackgroundColor(context.getResources().getColor(R.color.orange));
                switch_drag.tv_listrowbg.getBackground().setAlpha(80);
            } else {
                switch_drag.tv_listrowbg.setBackgroundColor(Color.TRANSPARENT);
            }
            if (OpUIManager.gw_running) {
                switch_drag.cb.setClickable(false);
                switch_drag.cb.setEnabled(false);
            } else {
                switch_drag.cb.setEnabled(true);
                switch_drag.cb.setClickable(true);
            }
            switch_drag.cb.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    if (!ov.isMonitor()) {
                        /*
						 * 当ov的数据长度大于15万条时,提示用户先保存和清除
						 */
                        TagTimeEntry tte = OpPerfBridge.getProfilerData(ov.getKey());
                        if (ov.hasMonitorOnce && null != tte) {
                            int size = 0;
                            if (tte.hasChild()) {
                                size = tte.getChildren()[0].getRecordSize();
                            } else {
                                size = tte.getRecordSize();
                            }
                            if (size >= GTMemoryDaemonThread.singleLimit) {
                                ToastUtil.ShowLongToast(context, "OutPara " + ov.getAlias() + " has more than " + GTMemoryDaemonThread.singleLimit + " records." + "You should save and clear records first.");
                                return;
                            }
                        }
                        ov.setMonitor(true);
                        OpUIManager.list_change = true;
                        // 如果是第一次启动监视,需要初始化出参对应的性能数据对象
                        if (!ov.hasMonitorOnce) {
                            OpPerfBridge.registMonitor(ov);
                        }
                    } else {
                        ov.setMonitor(false);
                        OpUIManager.list_change = true;
                        OpPerfBridge.endProfier(ov);
                    }
                }
            });
            if (position > disable_pos) {
                switch_drag.tv_key.setTextColor(Color.GRAY);
                switch_drag.tv_alias.setTextColor(Color.GRAY);
                switch_drag.tv_value.setTextColor(Color.GRAY);
                switch_drag.cb.setChecked(ov.isMonitor());
                switch_drag.cb.setEnabled(false);
                switch_drag.cb.setVisibility(View.GONE);
            } else {
                switch_drag.cb.setVisibility(View.VISIBLE);
            }
            convertView.setTag(switch_drag);
            break;
    }
    // 数据修改部分
    switch(type) {
        case TYPE_PROMPT_ITEM:
            if (((OutPara) list.get(1)).getKey().equals(ParamConst.DIVID_TITLE)) {
                PROMPT_ITEM_title.setText(ParamConst.PROMPT_INIT_TITLE);
            } else {
                PROMPT_ITEM_title.setText(ParamConst.PROMPT_TITLE);
            }
            break;
        case TYPE_DIVIDE_ITEM:
            if (position > 1) {
                DIVIDE_ITEM_top_border.setVisibility(View.VISIBLE);
            } else {
                DIVIDE_ITEM_top_border.setVisibility(View.GONE);
            }
            break;
        case TYPE_SWITCH_ITEM:
            switch_drag.tv_key.setText(key);
            switch_drag.tv_alias.setText(alias);
            switch_drag.tv_value.setText(value);
            if (his_count <= 0) {
                switch_drag.tv_his_data.setVisibility(View.GONE);
            } else if (his_count < 100) {
                switch_drag.tv_his_data.setText(Integer.toString(his_count));
                switch_drag.tv_his_data.setVisibility(View.VISIBLE);
            } else {
                switch_drag.tv_his_data.setText("99+");
                switch_drag.tv_his_data.setVisibility(View.VISIBLE);
            }
            if (position == (list.size() - 1)) {
                switch_drag.tv_listview_bottom_border.setVisibility(View.VISIBLE);
            } else {
                switch_drag.tv_listview_bottom_border.setVisibility(View.GONE);
            }
            if (position > disable_pos) {
                switch_drag.tv_key.setTextColor(Color.GRAY);
                switch_drag.tv_alias.setTextColor(Color.GRAY);
                switch_drag.tv_value.setTextColor(Color.GRAY);
            } else {
                switch_drag.tv_key.setTextColor(Color.WHITE);
                switch_drag.tv_alias.setTextColor(Color.WHITE);
                switch_drag.tv_value.setTextColor(Color.WHITE);
            }
            switch_drag.cb.setChecked(ov.isMonitor());
            break;
        case TYPE_DISABLE_ITEM:
            if (2 == position || position > 1 && ((OutPara) list.get(position - 1)).getKey().equals(ParamConst.DIVID_TITLE)) {
                DISABLE_ITEM_top_border.setVisibility(View.GONE);
            } else {
                DISABLE_ITEM_top_border.setVisibility(View.VISIBLE);
            }
            break;
    }
    return convertView;
}
Also used : TagTimeEntry(com.tencent.wstt.gt.ui.model.TagTimeEntry) OutPara(com.tencent.wstt.gt.OutPara) TextView(android.widget.TextView) View(android.view.View) ParamConst(com.tencent.wstt.gt.manager.ParamConst)

Example 4 with OutPara

use of com.tencent.wstt.gt.OutPara in project GT by Tencent.

the class GTAUTFragment method registerOutpara.

/**
	 * 注册选中应用的指定性能出参,2.1.1版本开始支持指定进程
	 * @param type 指定的性能参数类型
	 * @param designatedPid 指定进程的pid
	 * @return 返回指定pid进程在出参记录中的序号
	 */
public static List<OutPara> registerOutpara(int type, int designatedPid) {
    List<OutPara> result = new ArrayList<OutPara>();
    OpUIManager.list_change = true;
    cb_status[type] = true;
    if (!AUTManager.appstatus.equals("running")) {
        return result;
    }
    List<String> registOutList = new ArrayList<String>();
    AUTManager.registOpTable.put(cb_alias[type], registOutList);
    if (AUTManager.pIds != null) {
        String[] tempPids = AUTManager.pIds;
        if (// 指定pid的情况
        designatedPid >= 0) {
            tempPids = new String[1];
            for (int i = 0; i < AUTManager.pIds.length; i++) {
                if (AUTManager.pIds[i].equals(Integer.toString(designatedPid))) {
                    tempPids[0] = AUTManager.pIds[i];
                    break;
                }
            }
        }
        for (int i = 0; i < tempPids.length; i++) {
            // 出参的前缀
            String preOpName;
            String key;
            String alias;
            if (type == AUTManager.SEQ_NET) {
                preOpName = cb_key[type] + ":";
                key = preOpName + AUTManager.pkn;
                alias = cb_alias[type];
            } else {
                preOpName = cb_key[type] + i + ":";
                key = preOpName + AUTManager.pNames[i];
                alias = cb_alias[type] + i;
            }
            Client autClient = ClientManager.getInstance().getAUTClient();
            autClient.registerOutPara(key, alias);
            // FIXME 默认设置为已采集,应和上一步合并
            autClient.setOutparaMonitor(key, true);
            registOutList.add(key);
            OutPara op = autClient.getOutPara(key);
            result.add(op);
            // 对应的统计对象
            switch(type) {
                case AUTManager.SEQ_CPU:
                    OpPerfBridge.startProfier(op, Functions.PERF_DIGITAL_CPU, "Process CPU occupy", "%");
                    // 设置CPU记录对象
                    CpuUtils.cpuInfoMap.put(key, new CpuUtils());
                    break;
                case AUTManager.SEQ_JIF:
                    // 需要有对应的CPU记录对象,JIF才可用
                    String keyCpu = cb_key[AUTManager.SEQ_CPU] + i + ":" + AUTManager.pNames[i];
                    if (null == CpuUtils.cpuInfoMap.get(keyCpu)) {
                        // 设置CPU记录对象
                        CpuUtils.cpuInfoMap.put(keyCpu, new CpuUtils());
                    }
                    OpPerfBridge.startProfier(op, Functions.PERF_DIGITAL_NORMAL, "", "");
                    break;
                case AUTManager.SEQ_NET:
                    String[] subKeys = { "transmitted", "received" };
                    int[] funIds = { Functions.PERF_DIGITAL_MULT, Functions.PERF_DIGITAL_MULT };
                    OpPerfBridge.startProfier(op, subKeys, funIds, "", "KB");
                    NetUtils mNetUtils = new NetUtils(AUTManager.pkn.toString());
                    NetUtils.netInfoMap.put(AUTManager.pkn, mNetUtils);
                    break;
                case AUTManager.SEQ_PSS:
                    String[] subKeys_pss = { "total", "dalvik", "native" };
                    int[] funIds_pss = { Functions.PERF_DIGITAL_MULT_MEM, Functions.PERF_DIGITAL_MULT_MEM, Functions.PERF_DIGITAL_MULT_MEM };
                    OpPerfBridge.startProfier(op, subKeys_pss, funIds_pss, "", "MB");
                    break;
                case AUTManager.SEQ_PD:
                    String[] subKeys_pd = { "total", "dalvik", "native" };
                    int[] funIds_pd = { Functions.PERF_DIGITAL_MULT_MEM, Functions.PERF_DIGITAL_MULT_MEM, Functions.PERF_DIGITAL_MULT_MEM };
                    OpPerfBridge.startProfier(op, subKeys_pd, funIds_pd, "", "MB");
                    break;
            }
        }
    }
    return result;
}
Also used : NetUtils(com.tencent.wstt.gt.api.utils.NetUtils) OutPara(com.tencent.wstt.gt.OutPara) ArrayList(java.util.ArrayList) CpuUtils(com.tencent.wstt.gt.api.utils.CpuUtils) CommonString(com.tencent.wstt.gt.utils.CommonString) Client(com.tencent.wstt.gt.manager.Client)

Example 5 with OutPara

use of com.tencent.wstt.gt.OutPara in project GT by Tencent.

the class DataCacheController method setOutPara.

/**
	 * 只有在Connecting态才应该走缓存,Connected态应直接送队列,这个是直接送队列
	 */
public void setOutPara(String paraName, Object value, boolean isGlobal) {
    OutPara outPara = new OutPara();
    outPara.setKey(paraName);
    if (value == null) {
        value = "";
    }
    outPara.setValue(value.toString());
    outPara.setGlobal(isGlobal);
    paraTaskCache.add(outPara);
}
Also used : OutPara(com.tencent.wstt.gt.OutPara)

Aggregations

OutPara (com.tencent.wstt.gt.OutPara)30 Client (com.tencent.wstt.gt.manager.Client)4 ArrayList (java.util.ArrayList)4 TagTimeEntry (com.tencent.wstt.gt.ui.model.TagTimeEntry)3 CommonString (com.tencent.wstt.gt.utils.CommonString)3 NetUtils (com.tencent.wstt.gt.api.utils.NetUtils)2 ParamConst (com.tencent.wstt.gt.manager.ParamConst)2 Intent (android.content.Intent)1 Message (android.os.Message)1 View (android.view.View)1 TextView (android.widget.TextView)1 AidlEntry (com.tencent.wstt.gt.AidlEntry)1 InPara (com.tencent.wstt.gt.InPara)1 GTMainActivity (com.tencent.wstt.gt.activity.GTMainActivity)1 CpuUtils (com.tencent.wstt.gt.api.utils.CpuUtils)1 GWSaveEntry (com.tencent.wstt.gt.log.GWSaveEntry)1