コード例 #1
0
ファイル: PingHandler.java プロジェクト: uladz/cosbench
    private void setSysTime(long ctrTime) throws IOException {
    	DateFormat dateTimeFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	String dt = dateTimeFmt.format(new Date(ctrTime))
    	String[] cmd = {"date", "-s", dt};
    	String osType = System.getProperty("os.name").toLowerCase();
    	if (osType.contains("linux")) {
    		LOGGER.debug("setting system time {} as {} on driver {}", ctrTime, dt, driver.getDriverInfo().getName());
    		Runtime.getRuntime().exec(cmd);
		} else {
			LOGGER.warn("os type on driver {} is {}!", 
					driver.getDriverInfo().getName(), osType);
		}
	}
コード例 #2
0
ファイル: PingHandler.java プロジェクト: uladz/cosbench
 @Override
 protected Response process(HttpServletRequest req, HttpServletResponse res)
 		throws Exception {
 	Scanner scanner = new Scanner(req.getInputStream());
 	setSysTime(getControllerTime(scanner));
 	
 	PingResponse response = new PingResponse();
     DriverInfo info = driver.getDriverInfo();
     response.setName(info.getName());
     response.setAddress(info.getUrl());
     response.setTimeStamp(String.valueOf(System.currentTimeMillis()));
     return response;
 }