国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

RPC工程 supervisord系統(tǒng)管理服務(wù)器進(jìn)程

2019-11-08 03:23:29
字體:
供稿:網(wǎng)友

設(shè)計(jì)實(shí)現(xiàn)方式: 抽象工廠模式+xml+HTTP流響應(yīng)方式

描述:管理服務(wù)器上的進(jìn)程狀態(tài)信息,進(jìn)程關(guān)閉,開啟,日志信息等

調(diào)用代碼測(cè)試類:

200并發(fā)籬柵壓測(cè)final static String api = "http://115.29.163.148:9001/RPC2";    final static String userName = "zhubo";    final static String passWord = "123456";    final static String namespace = "supervisor";    //初始化    static XmlRpcFactory xmlRpcFactory = null;    public static void main(String[] args) throws InterruptedException {                xmlRpcFactory = new SimpleXMLRpcFactory();        int size = 200;        CyclicBarrier cb = new CyclicBarrier(size);        ExecutorService service = Executors.newFixedThreadPool(size);        System.out.PRintln(new Date());        for(int i =0;i<size;i++){            service.execute(new rpcThread(cb));        }        service.shutdown();        //調(diào)用API        while(true){            if(!service.isTerminated()){                Thread.sleep(1000);            }else{                System.out.println(new Date());                break;            }        }      //監(jiān)控請(qǐng)求成功,失敗,異常記錄     for(SimpleXMLPRC rpc :SimpleXMLRpcFactory.getRegistries()) {            Map<String, Set<XmlRpcCount>>  maprpc = rpc.getCounter();            System.out.println(maprpc.get(Constants.SUCCESS).size());            //System.out.println(JSON.toJSONString(maprpc.get(Constants.SUCCESS)));//成功            System.out.println(JSON.toJSONString(maprpc.get(Constants.FAILURE)));//失敗            System.out.println(JSON.toJSONString(maprpc.get(Constants.ERROR)));//異常            AtomicInteger atomicInteger = new AtomicInteger(0);            for(XmlRpcCount xmlRpcCount :maprpc.get(Constants.SUCCESS)){                atomicInteger.incrementAndGet();                System.out.println(atomicInteger.get()+"---"+JSON.toJSONString(xmlRpcCount));            }        }            }    static  class  rpcThread implements Runnable{        private CyclicBarrier cb;        public rpcThread( CyclicBarrier cb ){            this.cb = cb;        }        @Override        public void run() {            try {                cb.await();            } catch (InterruptedException e) {                // TODO Auto-generated catch block                e.printStackTrace();            } catch (BrokenBarrierException e) {                // TODO Auto-generated catch block                e.printStackTrace();            }            // TODO Auto-generated method stub            SimpleXMLPRC simpleXMLPRC =(SimpleXMLPRC) xmlRpcFactory.getXmlRpc(api, userName, password, namespace);            simpleXMLPRC.getAPIVersion();            com.yuntai.yw.supervisord.tools.Process process = simpleXMLPRC.getProcessInfo("dubbo:hs-med-service-queue");        }            }

JSON樣板數(shù)據(jù)

{"description":"pid 31164, uptime 0:00:05","exitStatus":0,"group":"dubbo","logFile":"/tmp/supervisor/hs-med-service-queue.log","name":"hs-med-service-queue","pid":31164,"start":"1484534147","stateName":"RUNNING","stdoutFile":"/tmp/supervisor/hs-med-service-queue.log","stop":"1484534146"}

進(jìn)程Process類

字段

類型描述
nameString名稱
groupString組名
descriptionString描述信息
startString啟動(dòng)時(shí)間戳
stopString結(jié)束時(shí)間戳
nowString當(dāng)前時(shí)間戳
statusString狀態(tài)
statusNameString狀態(tài)名稱
exitStatusint退出狀態(tài)
logFileString日志文件內(nèi)容
stdoutFileString日志文件內(nèi)容
pidint進(jìn)程Pid

API:

方法API參數(shù)說明
public String getAPIVersion(); 獲取api版本號(hào)
public XmlRpc namespace(String namespace);namespace 空間(默認(rèn)supervisor)根據(jù)namespace獲取調(diào)用實(shí)例
public XmlRpc proxy(String host, int port);host 請(qǐng)求url 及port端口根據(jù)url及端口  獲取調(diào)用實(shí)例
public XmlRpc auth(String username, String password);用戶名   密碼鑒權(quán)實(shí)例
public String getSupervisorVersion(); 安裝在服務(wù)器上的supervisor版本號(hào)
public String getIdentification(); 實(shí)例名一般為空間namespace名(服務(wù)器上配置)
public Map<String, Object> getState(); 服務(wù)器上的supervisor服務(wù)狀態(tài)
public int getPID(); 服務(wù)器上的supervisor服務(wù)的進(jìn)程id
public String readLog(int offset, int length) ;日志開始位置 及長(zhǎng)度日志內(nèi)容
public boolean clearLog(); 清除supervisor服務(wù)日志文件
public boolean shutdown(); 關(guān)閉supervisor服務(wù)
public boolean restart(); 重啟supervisor服務(wù)
public Process getProcessInfo(String processName);supervisor管理下的進(jìn)程名進(jìn)程信息
public Object[] getAllProcessInfo(); 獲取所有進(jìn)程信息
public boolean startProcess(String processName, boolean waitToStart);進(jìn)程名  是否等待啟動(dòng)服務(wù)器上進(jìn)程名
public Object[] startAllProcesses(boolean waitToStart);是否等待啟動(dòng)服務(wù)器上所有進(jìn)程
public boolean startProcessGroup(String groupName, boolean waitToStart);組名  是否等待根據(jù)組名 啟動(dòng)各個(gè)進(jìn)程
public boolean stopProcess(String processName, boolean waitToStop);進(jìn)程名  是否等待關(guān)閉服務(wù)器上進(jìn)程名
public boolean stopProcessGroup(String groupName, boolean waitToStop) ;組名  是否等待根據(jù)組名 關(guān)閉各個(gè)進(jìn)程
public Object[] stopAllProcesses(boolean waitToStop) ;是否等待關(guān)閉服務(wù)器上所有進(jìn)程

資源地址:http://download.csdn.net/detail/pajiakuo/9756525


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 江安县| 贡山| 烟台市| 洞口县| 兴文县| 涟源市| 阿鲁科尔沁旗| 尼木县| 开化县| 久治县| 洛扎县| 廉江市| 新竹县| 苏州市| 龙山县| 鄂伦春自治旗| 合肥市| 祁阳县| 富源县| 迁西县| 鄂托克旗| 平原县| 无棣县| 鄂尔多斯市| 山东省| 泉州市| 酉阳| 英吉沙县| 吉林市| 海伦市| 清远市| 崇文区| 芜湖市| 阳山县| 银川市| 焉耆| 横峰县| 黔江区| 衡山县| 福安市| 高雄市|