diff options
4 files changed, 52 insertions, 52 deletions
diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/MessageUtil.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/MessageUtil.java index d7a4dd8..21c6246 100644 --- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/MessageUtil.java +++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/MessageUtil.java @@ -23,47 +23,47 @@ public class MessageUtil { public static final int MSG_BUF_SIZE = 8096; public static Msg putLoginMsg(String user, String passwd) { - String body = String.format(Msg.reqLoginAlarm, user, passwd, "msg"); - return new Msg(body, MsgType.reqLoginAlarm); + String body = String.format(Msg.REQ_LOGIN_ALARM, user, passwd, "msg"); + return new Msg(body, MsgType.REQ_LOGIN_ALARM); } public static Msg putLoginFtp(String user, String passwd) { - String body = String.format(Msg.reqLoginAlarm, user, passwd, "ftp"); - return new Msg(body, MsgType.reqLoginAlarm); + String body = String.format(Msg.REQ_LOGIN_ALARM, user, passwd, "ftp"); + return new Msg(body, MsgType.REQ_LOGIN_ALARM); } public static Msg putSyncMsg(int reqId, int alarmSeq) { - String body = String.format(Msg.syncAlarmMessageMsg, reqId, alarmSeq); - return new Msg(body, MsgType.reqSyncAlarmMsg); + String body = String.format(Msg.SYNC_ALARM_MESSAGE, reqId, alarmSeq); + return new Msg(body, MsgType.REQ_SYNC_ALARM_MSG); } public static Msg putHeartBeatMsg(int reqId) { - String body = String.format(Msg.reqHeartBeat, reqId); - return new Msg(body, MsgType.reqHeartBeat); + String body = String.format(Msg.REQ_HEARTBEAT, reqId); + return new Msg(body, MsgType.REQ_HEARTBEAT); } public static Msg reqSyncAlarmFile(int reqId, String startTime, String endTime) { - String body = String.format(Msg.syncActiveAlarmFileMsg, reqId, startTime, endTime); - return new Msg(body, MsgType.reqSyncAlarmFile); + String body = String.format(Msg.SYNC_ACTIVE_ALARM_FILE_MSG, reqId, startTime, endTime); + return new Msg(body, MsgType.REQ_SYNC_ALARM_FILE); } public static Msg reqSyncAlarmFileByAlarmSeq(int reqId, int alarmSeq) { - String body = String.format(Msg.syncAlarmMessageByalarmSeq, reqId, alarmSeq); - return new Msg(body, MsgType.reqSyncAlarmFile); + String body = String.format(Msg.SYNC_ALARM_MESSAGE_BY_ALARM_SEQ, reqId, alarmSeq); + return new Msg(body, MsgType.REQ_SYNC_ALARM_FILE); } public static Msg reqSyncAlarmFileByTime(int reqId, String startTime, String endTime) { - String body = String.format(Msg.syncAlarmFileMsg, reqId, startTime, endTime); - return new Msg(body, MsgType.reqSyncAlarmFile); + String body = String.format(Msg.SYNC_ALARM_FILE_MSG, reqId, startTime, endTime); + return new Msg(body, MsgType.REQ_SYNC_ALARM_FILE); } public static Msg closeConnAlarmMsg() { - String body = String.format(Msg.disconnectMsg); - return new Msg(body, MsgType.closeConnAlarm); + String body = String.format(Msg.DISCONNECT_MSG); + return new Msg(body, MsgType.CLOSE_CONN_ALARM); } public static Msg readOneMsg(BufferedInputStream is) throws IOException { @@ -76,8 +76,8 @@ public class MessageUtil { DataInputStream ois = new DataInputStream(bais)){ dis.readFully(inputB); short startSign = ois.readShort(); - if (startSign != Msg.StartSign) { - throw new IOException("start sign is [" + Msg.StartSign + if (startSign != Msg.START_SIGN) { + throw new IOException("start sign is [" + Msg.START_SIGN + "],not is [" + startSign + "]"); } int msgType = ois.readByte(); @@ -100,7 +100,7 @@ public class MessageUtil { try( ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream(9); DataOutputStream oos = new DataOutputStream(byteOutStream)){ - oos.writeShort(Msg.StartSign); + oos.writeShort(Msg.START_SIGN); oos.writeByte(msg.getMsgType().value); oos.writeInt(Msg.creatMsgTimeStamp()); oos.writeShort(msg.getBodyLenNow()); diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/Msg.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/Msg.java index 3245625..8badd74 100644 --- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/Msg.java +++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/Msg.java @@ -21,14 +21,14 @@ import java.io.UnsupportedEncodingException; public class Msg { - public final static String reqLoginAlarm = "reqLoginAlarm;user=%s;key=%s;type=%s"; - public final static String reqHeartBeat = "reqHeartBeat;reqId=%s"; - public final static String disconnectMsg = "closeConnAlarm"; - public final static String syncAlarmMessageMsg = "reqSyncAlarmMsg;reqID=%s;alarmSeq=%s"; - public final static String syncAlarmMessageByalarmSeq = "reqSyncAlarmFile;reqID=%s;alarmSeq=%s;syncSource=1"; - public final static String syncActiveAlarmFileMsg = "reqSyncAlarmFile;reqID=%s;startTime=%s;endTime=%s;syncSource=0"; - public final static String syncAlarmFileMsg = "reqSyncAlarmFile;reqID=%s;startTime=%s;endTime=%s;syncSource=1"; - public final static short StartSign = (short) 0xffff; + public static final String REQ_LOGIN_ALARM = "reqLoginAlarm;user=%s;key=%s;type=%s"; + public static final String REQ_HEARTBEAT = "reqHeartBeat;reqId=%s"; + public static final String DISCONNECT_MSG= "closeConnAlarm"; + public static final String SYNC_ALARM_MESSAGE = "reqSyncAlarmMsg;reqID=%s;alarmSeq=%s"; + public static final String SYNC_ALARM_MESSAGE_BY_ALARM_SEQ = "reqSyncAlarmFile;reqID=%s;alarmSeq=%s;syncSource=1"; + public static final String SYNC_ACTIVE_ALARM_FILE_MSG = "reqSyncAlarmFile;reqID=%s;startTime=%s;endTime=%s;syncSource=0"; + public static final String SYNC_ALARM_FILE_MSG = "reqSyncAlarmFile;reqID=%s;startTime=%s;endTime=%s;syncSource=1"; + public static final short START_SIGN = (short) 0xffff; private MsgType msgType; private int timeStamp = 0; private int lenOfBody = 0; @@ -46,7 +46,7 @@ public class Msg { return (int) System.currentTimeMillis() / 1000; } - public void newBodyfromBytes(byte b[]) throws UnsupportedEncodingException { + public void newBodyfromBytes(byte[] b) throws UnsupportedEncodingException { this.body = new String(b, Constant.ENCODING_UTF8); } @@ -92,7 +92,7 @@ public class Msg { public String toString(boolean isRead) { StringBuilder sb = new StringBuilder(); - sb.append("StartSign[").append(StartSign).append("]msgType[").append(msgType.value).append("]timeStamp["); + sb.append("START_SIGN[").append(START_SIGN).append("]msgType[").append(msgType.value).append("]timeStamp["); if (isRead) { sb.append(timeStamp).append("]lenOfBody[").append(lenOfBody); } else { diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/MsgType.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/MsgType.java index fdf4b5e..f022e99 100644 --- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/MsgType.java +++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/MsgType.java @@ -17,27 +17,27 @@ package org.onap.vfc.nfvo.emsdriver.collector.alarm; public enum MsgType { - reqLoginAlarm("reqLoginAlarm", 1, "all"), - ackLoginAlarm("ackLoginAlarm", 2, "all"), - reqSyncAlarmMsg("reqSyncAlarmMsg", 3, "msg"), - ackSyncAlarmMsg("ackSyncAlarmMsg", 4, "msg"), - reqSyncAlarmFile("reqSyncAlarmFile", 5, "file"), - ackSyncAlarmFile("ackSyncAlarmFile", 6, "file"), - ackSyncAlarmFileResult("ackSyncAlarmFileResult", 7, "file"), - reqHeartBeat("reqHeartBeat", 8, "all"), - ackHeartBeat("ackHeartBeat", 9, "all"), - closeConnAlarm("closeConnAlarm", 10, "all"), - realTimeAlarm("realTimeAlarm", 0, "all"), - undefined("undefined", -1, "all"); + REQ_LOGIN_ALARM("reqLoginAlarm", 1, "all"), + ACK_LOGIN_ALARM("ackLoginAlarm", 2, "all"), + REQ_SYNC_ALARM_MSG("reqSyncAlarmMsg", 3, "msg"), + ACK_SYNC_ALARM_MSG("ackSyncAlarmMsg", 4, "msg"), + REQ_SYNC_ALARM_FILE("reqSyncAlarmFile", 5, "file"), + ACK_SYNC_ALARM_FILE("ackSyncAlarmFile", 6, "file"), + ACK_SYNC_ALARM_FILE_RESULT("ackSyncAlarmFileResult", 7, "file"), + REQ_HEARTBEAT("reqHeartBeat", 8, "all"), + ACK_HEARTBEAT("ackHeartBeat", 9, "all"), + CLOSE_CONN_ALARM("closeConnAlarm", 10, "all"), + REALTIME_ALARM("realTimeAlarm", 0, "all"), + UNDEFINED("undefined", -1, "all"); public int value = -1; - public String name = null; - public String type = null; + public String name; + public String type; - MsgType(String name, int value, String type) { - this.name = name; - this.value = value; - this.type = type; + MsgType(String inName, int inValue, String inType) { + this.name = inName; + this.value = inValue; + this.type = inType; } public static MsgType getMsgTypeValue(int msgTypeValue) { @@ -47,7 +47,7 @@ public enum MsgType { return msgType; } } - return undefined; + return UNDEFINED; } public static MsgType getMsgTypeName(String msgTypeName) { @@ -57,7 +57,7 @@ public enum MsgType { return msgType; } } - return undefined; + return UNDEFINED; } @Override diff --git a/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/AlarmSocketServer.java b/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/AlarmSocketServer.java index dbdb3cd..68665c7 100644 --- a/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/AlarmSocketServer.java +++ b/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/AlarmSocketServer.java @@ -55,16 +55,16 @@ public class AlarmSocketServer { if (len > 0) { String restlu = new String(b, 0, len); if (restlu.contains("reqLoginAlarm")) { - Msg msg = new Msg("ackLoginAlarm;result=succ;resDesc= ", MsgType.ackLoginAlarm); + Msg msg = new Msg("ackLoginAlarm;result=succ;resDesc= ", MsgType.ACK_LOGIN_ALARM); MessageUtil.writeMsg(msg, dos); } if (restlu.contains("reqHeartBeat")) { - Msg msg = new Msg("ackHeartBeat;result=succ;resDesc= ", MsgType.ackHeartBeat); + Msg msg = new Msg("ackHeartBeat;result=succ;resDesc= ", MsgType.ACK_HEARTBEAT); MessageUtil.writeMsg(msg, dos); } - Msg msg = new Msg("realTimeAlarm;result=succ;resDesc= ", MsgType.realTimeAlarm); + Msg msg = new Msg("realTimeAlarm;result=succ;resDesc= ", MsgType.REALTIME_ALARM); MessageUtil.writeMsg(msg, dos); |