/** * マップを取得する。 * * @param mapId Target mapId * @return 取得結果 */ public ResponseDto getById(final long mapId) { ResponseDto responseDto = new ResponseDto(); try { MapInfo mapInfo = mapInfoDao_.selectById(mapId); if (mapInfo == null) { String errorMessage = MessageUtil.getMessage("WEWD0164", new Object[] {}); responseDto.setMessage(errorMessage); responseDto.setResult(ResponseConstants.RESULT_FAIL); return responseDto; } Map<String, String> convertData = this.convertDataMap(mapInfo); responseDto.setResult(ResponseConstants.RESULT_SUCCESS); responseDto.setData(convertData); return responseDto; } catch (PersistenceException pEx) { Throwable cause = pEx.getCause(); if (cause instanceof SQLException) { SQLException sqlEx = (SQLException) cause; LOGGER.log(LogMessageCodes.SQL_EXCEPTION, sqlEx, sqlEx.getMessage()); } else { LOGGER.log(LogMessageCodes.SQL_EXCEPTION, pEx, pEx.getMessage()); } String errorMessage = MessageUtil.getMessage("WEWD0165", new Object[] {}); responseDto.setMessage(errorMessage); responseDto.setResult(ResponseConstants.RESULT_FAIL); return responseDto; } }
/** * マップを削除する。 * * @param mapId マップID * @return 削除結果 */ public ResponseDto removeMapById(final long mapId) { int count = 0; ResponseDto responseDto = new ResponseDto(); try { count = mapInfoDao_.deleteById(mapId); if (count == 0) { String errorMessage = MessageUtil.getMessage("WEWD0166", new Object[] {}); responseDto.setMessage(errorMessage); responseDto.setResult(ResponseConstants.RESULT_FAIL); return responseDto; } responseDto.setResult(ResponseConstants.RESULT_SUCCESS); return responseDto; } catch (PersistenceException pEx) { Throwable cause = pEx.getCause(); if (cause instanceof SQLException) { SQLException sqlEx = (SQLException) cause; LOGGER.log(LogMessageCodes.SQL_EXCEPTION, sqlEx, sqlEx.getMessage()); } else { LOGGER.log(LogMessageCodes.SQL_EXCEPTION, pEx, pEx.getMessage()); } String errorMessage = MessageUtil.getMessage("WEWD0167", new Object[] {}); responseDto.setMessage(errorMessage); responseDto.setResult(ResponseConstants.RESULT_FAIL); return responseDto; } }
/** * マップを更新する。 * * @param mapInfo マップ情報 * @return 更新結果電文 */ public ResponseDto update(final MapInfo mapInfo) { // 最終更新日時を設定 mapInfo.lastUpdate = new Timestamp(Calendar.getInstance().getTimeInMillis()); int count = 0; ResponseDto responseDto = new ResponseDto(); try { count = mapInfoDao_.update(mapInfo); if (count > 0) { responseDto.setResult(ResponseConstants.RESULT_SUCCESS); } else { String errorMessage = MessageUtil.getMessage("WEWD0162", new Object[] {}); responseDto.setResult(ResponseConstants.RESULT_FAIL); responseDto.setMessage(errorMessage); } return responseDto; } catch (PersistenceException pEx) { Throwable cause = pEx.getCause(); if (cause instanceof SQLException) { SQLException sqlEx = (SQLException) cause; LOGGER.log(LogMessageCodes.SQL_EXCEPTION, sqlEx, sqlEx.getMessage()); } else { LOGGER.log(LogMessageCodes.SQL_EXCEPTION, pEx, pEx.getMessage()); } String errorMessage = MessageUtil.getMessage("WEWD0163", new Object[] {}); responseDto.setMessage(errorMessage); responseDto.setResult(ResponseConstants.RESULT_FAIL); return responseDto; } }
/** * agentId、logFileNameを指定して、JavelinLogを取得する。 * * @param agentId AgentId * @param logFileName JVNファイル名 * @return JavelinLogオブジェクト */ public static JavelinLog getJavelinLog(final String agentId, final String logFileName) { // パラメータチェック if (agentId == null) { LOGGER.log(LogMessageCodes.UNKNOWN_AGENT_ID); return null; } if (logFileName == null) { LOGGER.log(LogMessageCodes.UNKNOWN_FILE_NAME); return null; } // DB名を特定する DatabaseManager dbMmanager = DatabaseManager.getInstance(); String dbName = dbMmanager.getDataBaseName(Integer.valueOf(agentId)); if (dbName == null) { LOGGER.log(LogMessageCodes.FAIL_READ_DB_NAME); return null; } try { // Javalinログを取得する JavelinLog jvnLog = JavelinLogDao.selectByLogFileNameWithBinary(dbName, logFileName); return jvnLog; } catch (SQLException ex) { LOGGER.log(LogMessageCodes.SQL_EXCEPTION); return null; } }
/** クローズ処理を行う。 */ public void close() { try { this.event_.close(); } catch (IOException ex) { LOGGER.log(LogMessageCodes.COMET_ERROR, ex); } catch (IllegalStateException ex) { LOGGER.log(LogMessageCodes.COMET_ERROR, ex); } }
/** * マップを取得する。 * * @param name マップ名 * @return 取得結果 */ public List<MapInfo> getByName(final String name) { try { return mapInfoDao_.selectByName(name); } catch (PersistenceException pEx) { Throwable cause = pEx.getCause(); if (cause instanceof SQLException) { SQLException sqlEx = (SQLException) cause; LOGGER.log(LogMessageCodes.SQL_EXCEPTION, sqlEx, sqlEx.getMessage()); } else { LOGGER.log(LogMessageCodes.SQL_EXCEPTION, pEx, pEx.getMessage()); } return new ArrayList<MapInfo>(); } }
/** * マップを登録する。 * * @param mapInfo 登録するマップ情報 * @return 登録結果電文 */ public ResponseDto insert(final MapInfo mapInfo) { ResponseDto responseDto = new ResponseDto(); if (getByName(mapInfo.name).size() > 0) { String errorMessage = MessageUtil.getMessage("WEWD0160", new Object[] {}); responseDto.setMessage(errorMessage); responseDto.setResult(ResponseConstants.RESULT_FAIL); return responseDto; } // 最終更新日時を設定 mapInfo.lastUpdate = new Timestamp(Calendar.getInstance().getTimeInMillis()); int count = 0; try { count = mapInfoDao_.insert(mapInfo); if (count > 0) { responseDto.setResult(ResponseConstants.RESULT_SUCCESS); } else { String errorMessage = MessageUtil.getMessage("WEWD0161", new Object[] {}); responseDto.setResult(ResponseConstants.RESULT_FAIL); responseDto.setMessage(errorMessage); } return responseDto; } catch (DuplicateKeyException dkEx) { LOGGER.log(LogMessageCodes.SQL_EXCEPTION, dkEx, dkEx.getMessage()); String errorMessage = MessageUtil.getMessage("WEWD0160", new Object[] {}); responseDto.setMessage(errorMessage); responseDto.setResult(ResponseConstants.RESULT_FAIL); return responseDto; } }
/** * {@inheritDoc} * * @param reportContainer */ @Override protected Object getReportPlotData( ReportSearchCondition cond, ReportProcessReturnContainer reportContainer) { // 検索条件を取得する。 String database = cond.getDatabases().get(0); Timestamp startTime = cond.getStartDate(); Timestamp endTime = cond.getEndDate(); // DBからデータを検索する。 List<ItemData> commonsPoolSizeData = null; try { commonsPoolSizeData = GraphItemAccessUtil.findItemData( database, Constants.ITEMNAME_POOL_SIZE, CompressOperator.SIMPLE_AVERAGE, startTime, endTime); } catch (SQLException ex) { LOGGER.log( LogIdConstants.EXCEPTION_IN_READING, ex, ReporterConfigAccessor.getReportName(getReportType())); return null; } return commonsPoolSizeData; }
/** * レスポンスが有効かどうかを返します。 * * @return レスポンスが有効な場合はtrue、そうでない場合はfalse */ public boolean isValidResponse() { boolean valid = true; try { this.event_.getHttpServletResponse(); } catch (Exception ex) { LOGGER.log(LogMessageCodes.COMET_ERROR, ex); valid = false; } return valid; }
/** * agentId、logFileNameを指定して、JavelinLogを取得する。 * * @param agentId AgentId * @param logFileName JVNファイル名 * @param logFileLineNumber ログファイルの行数 * @return JavelinLog(文字列) */ public static String getJavelinLogString( final String agentId, final String logFileName, final int logFileLineNumber) { JavelinLog javelinLog = getJavelinLog(agentId, logFileName); if (javelinLog == null || javelinLog.javelinLog == null) { return null; } // JavelinLogを取得する BufferedReader reader = new BufferedReader(new InputStreamReader(javelinLog.javelinLog)); StringBuilder sb = new StringBuilder(); String line; int lineNum = 0; try { while ((line = reader.readLine()) != null) { lineNum++; // 開始行以下であれば、読み込まない if (lineNum < logFileLineNumber) { continue; } // 1Event分読み込んだら終了する if (EVENT_INFO_END.equals(line)) { sb.append(line).append("\n"); break; } // Eventを読み込む sb.append(line).append("\n"); } return sb.toString(); } catch (IOException ex) { LOGGER.log(LogMessageCodes.COMMUNICATION_ERROR, ex); } finally { try { reader.close(); } catch (IOException ex) { LOGGER.log(LogMessageCodes.COMMUNICATION_ERROR, ex); } } return null; }
/** * 全てのマップデータを返す。 * * @return マップデータ */ public List<Map<String, String>> getAllMap() { List<MapInfo> mapList = null; try { mapList = mapInfoDao_.selectAll(); } catch (PersistenceException pe) { Throwable cause = pe.getCause(); if (cause instanceof SQLException) { SQLException sqlEx = (SQLException) cause; LOGGER.log(LogMessageCodes.SQL_EXCEPTION, sqlEx, sqlEx.getMessage()); } LOGGER.log(LogMessageCodes.SQL_EXCEPTION); return new ArrayList<Map<String, String>>(); } List<Map<String, String>> resultList = new ArrayList<Map<String, String>>(); for (MapInfo mapInfo : mapList) { Map<String, String> dataMap = this.convertDataMap(mapInfo); resultList.add(dataMap); } return resultList; }
/** * 指定した期間Jvnファイルを取得し、計測情報として変換する処理をします。 * * @param request {@link HttpServletRequest}オブジェクト * @param response {@link HttpServletResponse}オブジェクト */ public void process(HttpServletRequest request, HttpServletResponse response) { String clientId = request.getParameter(EventConstants.CLIENT_ID); String agentIds = request.getParameter(EventConstants.AGENT_IDS); String alarmLevelStr = request.getParameter(EventConstants.ALARM_LEVEL); String spanStr = request.getParameter(EventConstants.SPAN); String alarmCntStr = request.getParameter(EventConstants.ALARM_COUNT); if (clientId == null) { LOGGER.log(LogMessageCodes.NO_CLIENT_ID); return; } List<Integer> agentIdList = RequestUtil.getAgentIdList(agentIds); if (agentIdList == null || agentIdList.size() == 0) { LOGGER.log(LogMessageCodes.UNKNOWN_AGENT_ID, agentIds); return; } int alarmLevel = EventUtil.getAlarmLevel(alarmLevelStr); int alarmCount = EventUtil.getAlarmCount(alarmCntStr); Date[] spanArray = RequestUtil.getSpanList(spanStr); if (spanArray == null || spanArray.length == 0) { LOGGER.log(LogMessageCodes.UNKNOWN_SPAN, spanStr); return; } if (spanStr == null) { LOGGER.log(LogMessageCodes.UNKNOWN_SPAN); return; } // 検索 Timestamp startTime = new Timestamp(spanArray[0].getTime()); Timestamp endTime = new Timestamp(spanArray[1].getTime()); DatabaseManager dbMmanager = DatabaseManager.getInstance(); JvnFileEntryJudge judge = new JvnFileEntryJudge(); List<AlarmNotifyEntity> entityList = new ArrayList<AlarmNotifyEntity>(); List<WarningUnit> warningUnitList = new ArrayList<WarningUnit>(); for (Integer agentId : agentIdList) { try { String dbName = dbMmanager.getDataBaseName(agentId.intValue()); if (dbName == null) { LOGGER.log(LogMessageCodes.FAIL_READ_DB_NAME); continue; } List<JavelinLog> jvnLogList = JavelinLogDao.selectByTermWithLog(dbName, startTime, endTime); warningUnitList.addAll(judge.judge(jvnLogList, true, true)); createAlarmEntity(warningUnitList, alarmLevel, agentId.intValue(), entityList); } catch (SQLException ex) { LOGGER.log(LogMessageCodes.SQL_EXCEPTION); return; } } Collections.sort(entityList, new AlarmEntityComparator()); if (entityList.size() >= alarmCount) { entityList = entityList.subList(0, alarmCount); } if (entityList != null && entityList.size() > 0) { ResponseUtil.sendMessageOfJSONCode(response, entityList, clientId); } }