--- src/main/java/com/munjaon/server/config/DataSourceConfig.java
+++ src/main/java/com/munjaon/server/config/DataSourceConfig.java
... | ... | @@ -27,7 +27,7 @@ |
| 27 | 27 |
|
| 28 | 28 |
@Primary |
| 29 | 29 |
@Bean(name = "datasource") |
| 30 |
- @ConfigurationProperties(prefix = "spring.datasource.hikari") |
|
| 30 |
+ @ConfigurationProperties(prefix = "spring.datasource.server") |
|
| 31 | 31 |
public DataSource dataSource() {
|
| 32 | 32 |
return DataSourceBuilder.create().type(HikariDataSource.class).build(); |
| 33 | 33 |
} |
--- src/main/java/com/munjaon/server/config/RunnerConfiguration.java
+++ src/main/java/com/munjaon/server/config/RunnerConfiguration.java
... | ... | @@ -277,4 +277,17 @@ |
| 277 | 277 |
} |
| 278 | 278 |
return args -> System.out.println("Runner Bean ReporterQueue #4");
|
| 279 | 279 |
} |
| 280 |
+ |
|
| 281 |
+ @Bean |
|
| 282 |
+ @Order(5) |
|
| 283 |
+ public CommandLineRunner getRunnerBeanForMonitor() {
|
|
| 284 |
+ try {
|
|
| 285 |
+ String serviceName = "HEALTH"; |
|
| 286 |
+ HealthCheckServer healthCheckServer = new HealthCheckServer(serviceName); |
|
| 287 |
+ healthCheckServer.start(); |
|
| 288 |
+ } catch (Exception e) {
|
|
| 289 |
+ throw new RuntimeException(e); |
|
| 290 |
+ } |
|
| 291 |
+ return args -> System.out.println("Runner Bean Monitor #5");
|
|
| 292 |
+ } |
|
| 280 | 293 |
} |
--- src/main/java/com/munjaon/server/queue/config/QueueConstants.java
+++ src/main/java/com/munjaon/server/queue/config/QueueConstants.java
... | ... | @@ -1,5 +1,9 @@ |
| 1 | 1 |
package com.munjaon.server.queue.config; |
| 2 | 2 |
|
| 3 |
+import com.munjaon.server.server.packet.common.Packet; |
|
| 4 |
+ |
|
| 5 |
+import java.io.UnsupportedEncodingException; |
|
| 6 |
+ |
|
| 3 | 7 |
public final class QueueConstants {
|
| 4 | 8 |
/** Queue File Header Length - [Create Date:10 Byte, Push Count:10 Byte] */ |
| 5 | 9 |
public static final int QUEUE_HEADER_LENGTH = 20; |
... | ... | @@ -78,7 +82,7 @@ |
| 78 | 82 |
// 큐에 저장하기전에 바이트를 채울 문자 |
| 79 | 83 |
public static final byte SET_DEFAULT_BYTE = (byte) 0x00; |
| 80 | 84 |
|
| 81 |
- public static String getString(byte[] srcArray) {
|
|
| 85 |
+ public static String getString(byte[] srcArray) throws UnsupportedEncodingException {
|
|
| 82 | 86 |
if (srcArray == null) {
|
| 83 | 87 |
return null; |
| 84 | 88 |
} |
... | ... | @@ -101,6 +105,6 @@ |
| 101 | 105 |
} |
| 102 | 106 |
} |
| 103 | 107 |
|
| 104 |
- return destArray == null ? null : new String(destArray); |
|
| 108 |
+ return destArray == null ? null : new String(destArray, Packet.AGENT_CHARACTER_SET); |
|
| 105 | 109 |
} |
| 106 | 110 |
} |
--- src/main/java/com/munjaon/server/queue/pool/KakaoAlarmReadQueue.java
+++ src/main/java/com/munjaon/server/queue/pool/KakaoAlarmReadQueue.java
... | ... | @@ -6,6 +6,7 @@ |
| 6 | 6 |
import com.munjaon.server.queue.dto.QueueInfo; |
| 7 | 7 |
import com.munjaon.server.util.MessageUtil; |
| 8 | 8 |
|
| 9 |
+import java.io.UnsupportedEncodingException; |
|
| 9 | 10 |
import java.nio.ByteBuffer; |
| 10 | 11 |
|
| 11 | 12 |
public class KakaoAlarmReadQueue extends ReadQueue {
|
... | ... | @@ -21,7 +22,7 @@ |
| 21 | 22 |
} |
| 22 | 23 |
|
| 23 | 24 |
@Override |
| 24 |
- void getBytesForExtendMessage(BasicMessageDto messageDto) {
|
|
| 25 |
+ void getBytesForExtendMessage(BasicMessageDto messageDto) throws UnsupportedEncodingException {
|
|
| 25 | 26 |
MessageUtil.getBytesForKakaoMessage(this.dataBuffer, messageDto); |
| 26 | 27 |
} |
| 27 | 28 |
|
--- src/main/java/com/munjaon/server/queue/pool/KakaoAlarmWriteQueue.java
+++ src/main/java/com/munjaon/server/queue/pool/KakaoAlarmWriteQueue.java
... | ... | @@ -7,6 +7,7 @@ |
| 7 | 7 |
import com.munjaon.server.queue.dto.QueueInfo; |
| 8 | 8 |
import com.munjaon.server.util.MessageUtil; |
| 9 | 9 |
|
| 10 |
+import java.io.UnsupportedEncodingException; |
|
| 10 | 11 |
import java.nio.ByteBuffer; |
| 11 | 12 |
|
| 12 | 13 |
public class KakaoAlarmWriteQueue extends WriteQueue {
|
... | ... | @@ -17,7 +18,7 @@ |
| 17 | 18 |
} |
| 18 | 19 |
|
| 19 | 20 |
@Override |
| 20 |
- public int isValidateMessageForExtend(BasicMessageDto messageDto) {
|
|
| 21 |
+ public int isValidateMessageForExtend(BasicMessageDto messageDto) throws UnsupportedEncodingException {
|
|
| 21 | 22 |
/* 13. 제목 */ |
| 22 | 23 |
if (MessageUtil.isEmptyForMessage(messageDto.getUserSubject(), true) || MessageUtil.isOverByteForMessage(messageDto.getUserSubject(), KakaoBodyConfig.SUBJECT_BYTE_LENGTH, false)) {
|
| 23 | 24 |
return ServiceCode.MSG_ERROR_MEDIA_SUBJECT.getCode(); |
--- src/main/java/com/munjaon/server/queue/pool/KakaoFriendReadQueue.java
+++ src/main/java/com/munjaon/server/queue/pool/KakaoFriendReadQueue.java
... | ... | @@ -6,6 +6,7 @@ |
| 6 | 6 |
import com.munjaon.server.queue.dto.QueueInfo; |
| 7 | 7 |
import com.munjaon.server.util.MessageUtil; |
| 8 | 8 |
|
| 9 |
+import java.io.UnsupportedEncodingException; |
|
| 9 | 10 |
import java.nio.ByteBuffer; |
| 10 | 11 |
|
| 11 | 12 |
public class KakaoFriendReadQueue extends ReadQueue {
|
... | ... | @@ -21,7 +22,7 @@ |
| 21 | 22 |
} |
| 22 | 23 |
|
| 23 | 24 |
@Override |
| 24 |
- void getBytesForExtendMessage(BasicMessageDto messageDto) {
|
|
| 25 |
+ void getBytesForExtendMessage(BasicMessageDto messageDto) throws UnsupportedEncodingException {
|
|
| 25 | 26 |
MessageUtil.getBytesForKakaoMessage(this.dataBuffer, messageDto); |
| 26 | 27 |
} |
| 27 | 28 |
|
--- src/main/java/com/munjaon/server/queue/pool/KakaoFriendWriteQueue.java
+++ src/main/java/com/munjaon/server/queue/pool/KakaoFriendWriteQueue.java
... | ... | @@ -7,6 +7,7 @@ |
| 7 | 7 |
import com.munjaon.server.queue.dto.QueueInfo; |
| 8 | 8 |
import com.munjaon.server.util.MessageUtil; |
| 9 | 9 |
|
| 10 |
+import java.io.UnsupportedEncodingException; |
|
| 10 | 11 |
import java.nio.ByteBuffer; |
| 11 | 12 |
|
| 12 | 13 |
public class KakaoFriendWriteQueue extends WriteQueue {
|
... | ... | @@ -17,7 +18,7 @@ |
| 17 | 18 |
} |
| 18 | 19 |
|
| 19 | 20 |
@Override |
| 20 |
- public int isValidateMessageForExtend(BasicMessageDto messageDto) {
|
|
| 21 |
+ public int isValidateMessageForExtend(BasicMessageDto messageDto) throws UnsupportedEncodingException {
|
|
| 21 | 22 |
/* 13. 제목 */ |
| 22 | 23 |
if (MessageUtil.isEmptyForMessage(messageDto.getUserSubject(), true) || MessageUtil.isOverByteForMessage(messageDto.getUserSubject(), KakaoBodyConfig.SUBJECT_BYTE_LENGTH, false)) {
|
| 23 | 24 |
return ServiceCode.MSG_ERROR_MEDIA_SUBJECT.getCode(); |
--- src/main/java/com/munjaon/server/queue/pool/LmsReadQueue.java
+++ src/main/java/com/munjaon/server/queue/pool/LmsReadQueue.java
... | ... | @@ -6,6 +6,7 @@ |
| 6 | 6 |
import com.munjaon.server.queue.dto.QueueInfo; |
| 7 | 7 |
import com.munjaon.server.util.MessageUtil; |
| 8 | 8 |
|
| 9 |
+import java.io.UnsupportedEncodingException; |
|
| 9 | 10 |
import java.nio.ByteBuffer; |
| 10 | 11 |
|
| 11 | 12 |
public class LmsReadQueue extends ReadQueue {
|
... | ... | @@ -21,7 +22,7 @@ |
| 21 | 22 |
} |
| 22 | 23 |
|
| 23 | 24 |
@Override |
| 24 |
- void getBytesForExtendMessage(BasicMessageDto messageDto) {
|
|
| 25 |
+ void getBytesForExtendMessage(BasicMessageDto messageDto) throws UnsupportedEncodingException {
|
|
| 25 | 26 |
MessageUtil.getBytesForMediaMessage(this.dataBuffer, messageDto); |
| 26 | 27 |
} |
| 27 | 28 |
|
--- src/main/java/com/munjaon/server/queue/pool/LmsWriteQueue.java
+++ src/main/java/com/munjaon/server/queue/pool/LmsWriteQueue.java
... | ... | @@ -7,6 +7,7 @@ |
| 7 | 7 |
import com.munjaon.server.queue.dto.QueueInfo; |
| 8 | 8 |
import com.munjaon.server.util.MessageUtil; |
| 9 | 9 |
|
| 10 |
+import java.io.UnsupportedEncodingException; |
|
| 10 | 11 |
import java.nio.ByteBuffer; |
| 11 | 12 |
|
| 12 | 13 |
public class LmsWriteQueue extends WriteQueue {
|
... | ... | @@ -17,7 +18,7 @@ |
| 17 | 18 |
} |
| 18 | 19 |
|
| 19 | 20 |
@Override |
| 20 |
- public int isValidateMessageForExtend(BasicMessageDto messageDto) {
|
|
| 21 |
+ public int isValidateMessageForExtend(BasicMessageDto messageDto) throws UnsupportedEncodingException {
|
|
| 21 | 22 |
/* 13. 제목 */ |
| 22 | 23 |
if (MessageUtil.isEmptyForMessage(messageDto.getUserSubject(), true) || MessageUtil.isOverByteForMessage(messageDto.getUserSubject(), MediaBodyConfig.SUBJECT_BYTE_LENGTH, false)) {
|
| 23 | 24 |
return ServiceCode.MSG_ERROR_MEDIA_SUBJECT.getCode(); |
--- src/main/java/com/munjaon/server/queue/pool/MmsReadQueue.java
+++ src/main/java/com/munjaon/server/queue/pool/MmsReadQueue.java
... | ... | @@ -6,6 +6,7 @@ |
| 6 | 6 |
import com.munjaon.server.queue.dto.QueueInfo; |
| 7 | 7 |
import com.munjaon.server.util.MessageUtil; |
| 8 | 8 |
|
| 9 |
+import java.io.UnsupportedEncodingException; |
|
| 9 | 10 |
import java.nio.ByteBuffer; |
| 10 | 11 |
|
| 11 | 12 |
public class MmsReadQueue extends ReadQueue {
|
... | ... | @@ -21,7 +22,7 @@ |
| 21 | 22 |
} |
| 22 | 23 |
|
| 23 | 24 |
@Override |
| 24 |
- void getBytesForExtendMessage(BasicMessageDto messageDto) {
|
|
| 25 |
+ void getBytesForExtendMessage(BasicMessageDto messageDto) throws UnsupportedEncodingException {
|
|
| 25 | 26 |
MessageUtil.getBytesForMediaMessage(this.dataBuffer, messageDto); |
| 26 | 27 |
MessageUtil.getBytesForMmsMessage(this.dataBuffer, messageDto); |
| 27 | 28 |
} |
--- src/main/java/com/munjaon/server/queue/pool/MmsWriteQueue.java
+++ src/main/java/com/munjaon/server/queue/pool/MmsWriteQueue.java
... | ... | @@ -7,6 +7,7 @@ |
| 7 | 7 |
import com.munjaon.server.queue.dto.QueueInfo; |
| 8 | 8 |
import com.munjaon.server.util.MessageUtil; |
| 9 | 9 |
|
| 10 |
+import java.io.UnsupportedEncodingException; |
|
| 10 | 11 |
import java.nio.ByteBuffer; |
| 11 | 12 |
|
| 12 | 13 |
public class MmsWriteQueue extends WriteQueue {
|
... | ... | @@ -17,7 +18,7 @@ |
| 17 | 18 |
} |
| 18 | 19 |
|
| 19 | 20 |
@Override |
| 20 |
- public int isValidateMessageForExtend(BasicMessageDto messageDto) {
|
|
| 21 |
+ public int isValidateMessageForExtend(BasicMessageDto messageDto) throws UnsupportedEncodingException {
|
|
| 21 | 22 |
/* 13. 제목 */ |
| 22 | 23 |
if (MessageUtil.isEmptyForMessage(messageDto.getUserSubject(), true) || MessageUtil.isOverByteForMessage(messageDto.getUserSubject(), MediaBodyConfig.SUBJECT_BYTE_LENGTH, false)) {
|
| 23 | 24 |
return ServiceCode.MSG_ERROR_MEDIA_SUBJECT.getCode(); |
--- src/main/java/com/munjaon/server/queue/pool/ReadQueue.java
+++ src/main/java/com/munjaon/server/queue/pool/ReadQueue.java
... | ... | @@ -14,10 +14,7 @@ |
| 14 | 14 |
import org.jdom2.output.Format; |
| 15 | 15 |
import org.jdom2.output.XMLOutputter; |
| 16 | 16 |
|
| 17 |
-import java.io.File; |
|
| 18 |
-import java.io.FileOutputStream; |
|
| 19 |
-import java.io.IOException; |
|
| 20 |
-import java.io.RandomAccessFile; |
|
| 17 |
+import java.io.*; |
|
| 21 | 18 |
import java.nio.ByteBuffer; |
| 22 | 19 |
import java.nio.channels.FileChannel; |
| 23 | 20 |
import java.time.LocalDateTime; |
... | ... | @@ -206,6 +203,6 @@ |
| 206 | 203 |
} |
| 207 | 204 |
|
| 208 | 205 |
abstract void popBuffer() throws Exception; |
| 209 |
- abstract void getBytesForExtendMessage(BasicMessageDto messageDto); |
|
| 206 |
+ abstract void getBytesForExtendMessage(BasicMessageDto messageDto) throws UnsupportedEncodingException; |
|
| 210 | 207 |
abstract void initDataBuffer(); |
| 211 | 208 |
} |
--- src/main/java/com/munjaon/server/queue/pool/ReportQueue.java
+++ src/main/java/com/munjaon/server/queue/pool/ReportQueue.java
... | ... | @@ -4,6 +4,7 @@ |
| 4 | 4 |
import com.munjaon.server.queue.config.QueueConstants; |
| 5 | 5 |
import com.munjaon.server.queue.config.ReportConfig; |
| 6 | 6 |
import com.munjaon.server.server.dto.ReportDto; |
| 7 |
+import com.munjaon.server.server.packet.common.Packet; |
|
| 7 | 8 |
import com.munjaon.server.util.FileUtil; |
| 8 | 9 |
import com.munjaon.server.util.MessageUtil; |
| 9 | 10 |
import lombok.Getter; |
... | ... | @@ -151,11 +152,11 @@ |
| 151 | 152 |
private void writeHeader() throws Exception {
|
| 152 | 153 |
initHeadBuffer(); |
| 153 | 154 |
this.channel.position(ReportConfig.USER_ID_POSITION); |
| 154 |
- this.headBuffer.put(this.userId.getBytes()); |
|
| 155 |
+ this.headBuffer.put(this.userId.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 155 | 156 |
this.headBuffer.position(ReportConfig.WRITE_COUNT_POSITION); |
| 156 |
- this.headBuffer.put(Integer.toString(this.writeCounter).getBytes()); |
|
| 157 |
+ this.headBuffer.put(Integer.toString(this.writeCounter).getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 157 | 158 |
this.headBuffer.position(ReportConfig.READ_COUNT_POSITION); |
| 158 |
- this.headBuffer.put(Integer.toString(this.readCounter).getBytes()); |
|
| 159 |
+ this.headBuffer.put(Integer.toString(this.readCounter).getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 159 | 160 |
this.headBuffer.flip(); |
| 160 | 161 |
this.channel.write(this.headBuffer); |
| 161 | 162 |
} |
--- src/main/java/com/munjaon/server/queue/pool/SerialQueue.java
+++ src/main/java/com/munjaon/server/queue/pool/SerialQueue.java
... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 |
package com.munjaon.server.queue.pool; |
| 2 | 2 |
|
| 3 | 3 |
import com.munjaon.server.queue.config.QueueConstants; |
| 4 |
+import com.munjaon.server.server.packet.common.Packet; |
|
| 4 | 5 |
import com.munjaon.server.server.service.PropertyLoader; |
| 5 | 6 |
import com.munjaon.server.util.FileUtil; |
| 6 | 7 |
import lombok.Getter; |
... | ... | @@ -94,7 +95,7 @@ |
| 94 | 95 |
try {
|
| 95 | 96 |
initDataBuffer(); |
| 96 | 97 |
this.channel.position(0); |
| 97 |
- this.dataBuffer.put(String.valueOf(serialNo).getBytes()); |
|
| 98 |
+ this.dataBuffer.put(String.valueOf(serialNo).getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 98 | 99 |
this.dataBuffer.flip(); |
| 99 | 100 |
this.channel.write(this.dataBuffer); |
| 100 | 101 |
} catch(Exception e) {
|
--- src/main/java/com/munjaon/server/queue/pool/SmsReadQueue.java
+++ src/main/java/com/munjaon/server/queue/pool/SmsReadQueue.java
... | ... | @@ -6,6 +6,7 @@ |
| 6 | 6 |
import com.munjaon.server.queue.dto.QueueInfo; |
| 7 | 7 |
import com.munjaon.server.util.MessageUtil; |
| 8 | 8 |
|
| 9 |
+import java.io.UnsupportedEncodingException; |
|
| 9 | 10 |
import java.nio.ByteBuffer; |
| 10 | 11 |
|
| 11 | 12 |
public class SmsReadQueue extends ReadQueue {
|
... | ... | @@ -21,7 +22,7 @@ |
| 21 | 22 |
} |
| 22 | 23 |
|
| 23 | 24 |
@Override |
| 24 |
- void getBytesForExtendMessage(BasicMessageDto messageDto) {
|
|
| 25 |
+ void getBytesForExtendMessage(BasicMessageDto messageDto) throws UnsupportedEncodingException {
|
|
| 25 | 26 |
MessageUtil.getBytesForSmsMessage(this.dataBuffer, messageDto); |
| 26 | 27 |
} |
| 27 | 28 |
|
--- src/main/java/com/munjaon/server/queue/pool/SmsWriteQueue.java
+++ src/main/java/com/munjaon/server/queue/pool/SmsWriteQueue.java
... | ... | @@ -7,6 +7,7 @@ |
| 7 | 7 |
import com.munjaon.server.queue.dto.QueueInfo; |
| 8 | 8 |
import com.munjaon.server.util.MessageUtil; |
| 9 | 9 |
|
| 10 |
+import java.io.UnsupportedEncodingException; |
|
| 10 | 11 |
import java.nio.ByteBuffer; |
| 11 | 12 |
|
| 12 | 13 |
public class SmsWriteQueue extends WriteQueue {
|
... | ... | @@ -17,7 +18,7 @@ |
| 17 | 18 |
} |
| 18 | 19 |
|
| 19 | 20 |
@Override |
| 20 |
- public int isValidateMessageForExtend(BasicMessageDto messageDto) {
|
|
| 21 |
+ public int isValidateMessageForExtend(BasicMessageDto messageDto) throws UnsupportedEncodingException {
|
|
| 21 | 22 |
/* 13. 메시지 */ |
| 22 | 23 |
if (MessageUtil.isEmptyForMessage(messageDto.getUserMessage(), true) || MessageUtil.isOverByteForMessage(messageDto.getUserMessage(), SmsBodyConfig.SMS_MSG_BYTE_LENGTH, false)) {
|
| 23 | 24 |
return ServiceCode.MSG_ERROR_SMS_MESSAGE.getCode(); |
--- src/main/java/com/munjaon/server/queue/pool/WriteQueue.java
+++ src/main/java/com/munjaon/server/queue/pool/WriteQueue.java
... | ... | @@ -6,6 +6,7 @@ |
| 6 | 6 |
import com.munjaon.server.queue.config.QueueHeaderConfig; |
| 7 | 7 |
import com.munjaon.server.queue.dto.BasicMessageDto; |
| 8 | 8 |
import com.munjaon.server.queue.dto.QueueInfo; |
| 9 |
+import com.munjaon.server.server.packet.common.Packet; |
|
| 9 | 10 |
import com.munjaon.server.util.FileUtil; |
| 10 | 11 |
import com.munjaon.server.util.JobFileFactory; |
| 11 | 12 |
import com.munjaon.server.util.MessageUtil; |
... | ... | @@ -14,6 +15,7 @@ |
| 14 | 15 |
import java.io.File; |
| 15 | 16 |
import java.io.IOException; |
| 16 | 17 |
import java.io.RandomAccessFile; |
| 18 |
+import java.io.UnsupportedEncodingException; |
|
| 17 | 19 |
import java.nio.ByteBuffer; |
| 18 | 20 |
import java.nio.channels.FileChannel; |
| 19 | 21 |
import java.time.LocalDateTime; |
... | ... | @@ -108,9 +110,9 @@ |
| 108 | 110 |
try {
|
| 109 | 111 |
initHeaderBuffer(); |
| 110 | 112 |
this.channel.position(QueueHeaderConfig.CREATE_DATE_POSITION); |
| 111 |
- this.headerBuffer.put(this.createDate.getBytes()); |
|
| 113 |
+ this.headerBuffer.put(this.createDate.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 112 | 114 |
this.headerBuffer.position(QueueHeaderConfig.PUSH_COUNT_POSITION); |
| 113 |
- this.headerBuffer.put(Integer.toString(this.pushCounter).getBytes()); |
|
| 115 |
+ this.headerBuffer.put(Integer.toString(this.pushCounter).getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 114 | 116 |
this.headerBuffer.flip(); |
| 115 | 117 |
this.channel.write(this.headerBuffer); |
| 116 | 118 |
} catch(Exception e) {
|
... | ... | @@ -175,7 +177,7 @@ |
| 175 | 177 |
return this.queueInfo.getQueueName(); |
| 176 | 178 |
} |
| 177 | 179 |
|
| 178 |
- protected int isValidateMessage(BasicMessageDto messageDto) {
|
|
| 180 |
+ protected int isValidateMessage(BasicMessageDto messageDto) throws UnsupportedEncodingException {
|
|
| 179 | 181 |
int result = isValidateMessageForCommon(messageDto); |
| 180 | 182 |
if (result != ServiceCode.OK.getCode()) {
|
| 181 | 183 |
return result; |
... | ... | @@ -184,7 +186,7 @@ |
| 184 | 186 |
return isValidateMessageForExtend(messageDto); |
| 185 | 187 |
} |
| 186 | 188 |
|
| 187 |
- protected int isValidateMessageForCommon(BasicMessageDto messageDto) {
|
|
| 189 |
+ protected int isValidateMessageForCommon(BasicMessageDto messageDto) throws UnsupportedEncodingException {
|
|
| 188 | 190 |
/* 1. 사용자 아이디 */ |
| 189 | 191 |
if (MessageUtil.isEmptyForMessage(messageDto.getUserId(), true) || MessageUtil.isOverByteForMessage(messageDto.getUserId(), BodyCommonConfig.USERID_BYTE_LENGTH, true)) {
|
| 190 | 192 |
return ServiceCode.MSG_ERROR_USERID.getCode(); |
... | ... | @@ -237,7 +239,7 @@ |
| 237 | 239 |
return ServiceCode.OK.getCode(); |
| 238 | 240 |
} |
| 239 | 241 |
|
| 240 |
- public abstract int isValidateMessageForExtend(BasicMessageDto messageDto); |
|
| 242 |
+ public abstract int isValidateMessageForExtend(BasicMessageDto messageDto) throws UnsupportedEncodingException; |
|
| 241 | 243 |
public abstract void pushMessageToBuffer(BasicMessageDto messageDto) throws Exception; |
| 242 | 244 |
public abstract void initDataBuffer(); |
| 243 | 245 |
} |
--- src/main/java/com/munjaon/server/server/packet/common/Bind.java
+++ src/main/java/com/munjaon/server/server/packet/common/Bind.java
... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 |
package com.munjaon.server.server.packet.common; |
| 2 | 2 |
|
| 3 |
+import java.io.UnsupportedEncodingException; |
|
| 3 | 4 |
import java.nio.ByteBuffer; |
| 4 | 5 |
|
| 5 | 6 |
public final class Bind {
|
... | ... | @@ -18,37 +19,37 @@ |
| 18 | 19 |
|
| 19 | 20 |
public static final String ENCRYPTION = "0"; |
| 20 | 21 |
|
| 21 |
- public static ByteBuffer makeBindBuffer(String id, String pwd) {
|
|
| 22 |
+ public static ByteBuffer makeBindBuffer(String id, String pwd) throws UnsupportedEncodingException {
|
|
| 22 | 23 |
ByteBuffer buffer = ByteBuffer.allocate(Header.HEADER_LENGTH + BIND_BODY_LENGTH); |
| 23 | 24 |
Packet.setDefaultByte(buffer); |
| 24 | 25 |
Header.putHeader(buffer, Header.COMMAND_BIND, BIND_BODY_LENGTH); |
| 25 | 26 |
/* ID */ |
| 26 | 27 |
if (id != null) {
|
| 27 |
- buffer.put(BIND_ID_POSITION, id.getBytes()); |
|
| 28 |
+ buffer.put(BIND_ID_POSITION, id.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 28 | 29 |
} |
| 29 | 30 |
/* PWD */ |
| 30 | 31 |
if (pwd != null) {
|
| 31 |
- buffer.put(BIND_PWD_POSITION, pwd.getBytes()); |
|
| 32 |
+ buffer.put(BIND_PWD_POSITION, pwd.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 32 | 33 |
} |
| 33 | 34 |
/* ENCRYPTION */ |
| 34 |
- buffer.put(BIND_ENCRYPTION_POSITION, ENCRYPTION.getBytes()); |
|
| 35 |
+ buffer.put(BIND_ENCRYPTION_POSITION, ENCRYPTION.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 35 | 36 |
|
| 36 | 37 |
return buffer; |
| 37 | 38 |
} |
| 38 | 39 |
|
| 39 |
- public static ByteBuffer makeBindAckBuffer(String resultCode) {
|
|
| 40 |
+ public static ByteBuffer makeBindAckBuffer(String resultCode) throws UnsupportedEncodingException {
|
|
| 40 | 41 |
ByteBuffer buffer = ByteBuffer.allocate(Header.HEADER_LENGTH + BIND_ACK_BODY_LENGTH); |
| 41 | 42 |
Packet.setDefaultByte(buffer); |
| 42 | 43 |
Header.putHeader(buffer, Header.COMMAND_BIND_ACK, BIND_ACK_BODY_LENGTH); |
| 43 | 44 |
/* resultCode */ |
| 44 | 45 |
if (resultCode != null) {
|
| 45 |
- buffer.put(BIND_ACK_RESULT_CODE_POSITION, resultCode.getBytes()); |
|
| 46 |
+ buffer.put(BIND_ACK_RESULT_CODE_POSITION, resultCode.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 46 | 47 |
} |
| 47 | 48 |
|
| 48 | 49 |
return buffer; |
| 49 | 50 |
} |
| 50 | 51 |
|
| 51 |
- public static String getBindId(final ByteBuffer buffer) {
|
|
| 52 |
+ public static String getBindId(final ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 52 | 53 |
if (buffer == null) {
|
| 53 | 54 |
return null; |
| 54 | 55 |
} |
... | ... | @@ -60,7 +61,7 @@ |
| 60 | 61 |
return Packet.getString(destArray); |
| 61 | 62 |
} |
| 62 | 63 |
|
| 63 |
- public static String getBindPwd(final ByteBuffer buffer) {
|
|
| 64 |
+ public static String getBindPwd(final ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 64 | 65 |
if (buffer == null) {
|
| 65 | 66 |
return null; |
| 66 | 67 |
} |
... | ... | @@ -72,7 +73,7 @@ |
| 72 | 73 |
return Packet.getString(destArray); |
| 73 | 74 |
} |
| 74 | 75 |
|
| 75 |
- public static String getBindEncryption(final ByteBuffer buffer) {
|
|
| 76 |
+ public static String getBindEncryption(final ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 76 | 77 |
if (buffer == null) {
|
| 77 | 78 |
return null; |
| 78 | 79 |
} |
... | ... | @@ -84,7 +85,7 @@ |
| 84 | 85 |
return Packet.getString(destArray); |
| 85 | 86 |
} |
| 86 | 87 |
|
| 87 |
- public static String getBindAckResultCode(final ByteBuffer buffer) {
|
|
| 88 |
+ public static String getBindAckResultCode(final ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 88 | 89 |
if (buffer == null) {
|
| 89 | 90 |
return null; |
| 90 | 91 |
} |
--- src/main/java/com/munjaon/server/server/packet/common/CommonMessage.java
+++ src/main/java/com/munjaon/server/server/packet/common/CommonMessage.java
... | ... | @@ -2,6 +2,7 @@ |
| 2 | 2 |
|
| 3 | 3 |
import com.munjaon.server.util.CommonUtil; |
| 4 | 4 |
|
| 5 |
+import java.io.UnsupportedEncodingException; |
|
| 5 | 6 |
import java.nio.ByteBuffer; |
| 6 | 7 |
|
| 7 | 8 |
public final class CommonMessage {
|
... | ... | @@ -33,13 +34,13 @@ |
| 33 | 34 |
public static final int DELIVER_ACK_RESULT_LENGTH = 1; |
| 34 | 35 |
public static final int DELIVER_ACK_RESULT_POSITION = DELIVER_ACK_MESSAGE_ID_POSITION + DELIVER_ACK_MESSAGE_ID_LENGTH; |
| 35 | 36 |
|
| 36 |
- public static void putMessageIdForDeliver(ByteBuffer buffer, String messageId) {
|
|
| 37 |
+ public static void putMessageIdForDeliver(ByteBuffer buffer, String messageId) throws UnsupportedEncodingException {
|
|
| 37 | 38 |
if (buffer == null || messageId == null) {
|
| 38 | 39 |
return; |
| 39 | 40 |
} |
| 40 |
- buffer.put(DELIVER_MESSAGE_ID_POSITION, messageId.getBytes()); |
|
| 41 |
+ buffer.put(DELIVER_MESSAGE_ID_POSITION, messageId.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 41 | 42 |
} |
| 42 |
- public static String getMessageIdForDeliver(ByteBuffer buffer) {
|
|
| 43 |
+ public static String getMessageIdForDeliver(ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 43 | 44 |
if (buffer == null) {
|
| 44 | 45 |
return null; |
| 45 | 46 |
} |
... | ... | @@ -51,14 +52,14 @@ |
| 51 | 52 |
return Packet.getString(destArray); |
| 52 | 53 |
} |
| 53 | 54 |
|
| 54 |
- public static void putSenderForDeliver(ByteBuffer buffer, String sender) {
|
|
| 55 |
+ public static void putSenderForDeliver(ByteBuffer buffer, String sender) throws UnsupportedEncodingException {
|
|
| 55 | 56 |
if (buffer == null || sender == null) {
|
| 56 | 57 |
return; |
| 57 | 58 |
} |
| 58 | 59 |
sender = CommonUtil.cutString(CommonUtil.doNumber(sender), DELIVER_SENDER_LENGTH); |
| 59 |
- buffer.put(DELIVER_SENDER_POSITION, sender.getBytes()); |
|
| 60 |
+ buffer.put(DELIVER_SENDER_POSITION, sender.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 60 | 61 |
} |
| 61 |
- public static String getSenderForDeliver(ByteBuffer buffer) {
|
|
| 62 |
+ public static String getSenderForDeliver(ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 62 | 63 |
if (buffer == null) {
|
| 63 | 64 |
return null; |
| 64 | 65 |
} |
... | ... | @@ -70,14 +71,14 @@ |
| 70 | 71 |
return Packet.getString(destArray); |
| 71 | 72 |
} |
| 72 | 73 |
|
| 73 |
- public static void putReceiverForDeliver(ByteBuffer buffer, String receiver) {
|
|
| 74 |
+ public static void putReceiverForDeliver(ByteBuffer buffer, String receiver) throws UnsupportedEncodingException {
|
|
| 74 | 75 |
if (buffer == null || receiver == null) {
|
| 75 | 76 |
return; |
| 76 | 77 |
} |
| 77 | 78 |
receiver = CommonUtil.cutString(CommonUtil.doNumber(receiver), DELIVER_RECEIVER_LENGTH); |
| 78 |
- buffer.put(DELIVER_RECEIVER_POSITION, receiver.getBytes()); |
|
| 79 |
+ buffer.put(DELIVER_RECEIVER_POSITION, receiver.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 79 | 80 |
} |
| 80 |
- public static String getReceiverForDeliver(ByteBuffer buffer) {
|
|
| 81 |
+ public static String getReceiverForDeliver(ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 81 | 82 |
if (buffer == null) {
|
| 82 | 83 |
return null; |
| 83 | 84 |
} |
... | ... | @@ -89,13 +90,13 @@ |
| 89 | 90 |
return Packet.getString(destArray); |
| 90 | 91 |
} |
| 91 | 92 |
|
| 92 |
- public static void putReserveTimeForDeliver(ByteBuffer buffer, String reserveTime) {
|
|
| 93 |
+ public static void putReserveTimeForDeliver(ByteBuffer buffer, String reserveTime) throws UnsupportedEncodingException {
|
|
| 93 | 94 |
if (buffer == null || reserveTime == null) {
|
| 94 | 95 |
return; |
| 95 | 96 |
} |
| 96 |
- buffer.put(DELIVER_RESERVE_TIME_POSITION, reserveTime.getBytes()); |
|
| 97 |
+ buffer.put(DELIVER_RESERVE_TIME_POSITION, reserveTime.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 97 | 98 |
} |
| 98 |
- public static String getReserveTimeForDeliver(ByteBuffer buffer) {
|
|
| 99 |
+ public static String getReserveTimeForDeliver(ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 99 | 100 |
if (buffer == null) {
|
| 100 | 101 |
return null; |
| 101 | 102 |
} |
... | ... | @@ -107,13 +108,13 @@ |
| 107 | 108 |
return Packet.getString(destArray); |
| 108 | 109 |
} |
| 109 | 110 |
|
| 110 |
- public static void putRequestTimeForDeliver(ByteBuffer buffer, String requestTime) {
|
|
| 111 |
+ public static void putRequestTimeForDeliver(ByteBuffer buffer, String requestTime) throws UnsupportedEncodingException {
|
|
| 111 | 112 |
if (buffer == null || requestTime == null) {
|
| 112 | 113 |
return; |
| 113 | 114 |
} |
| 114 |
- buffer.put(DELIVER_REQUEST_TIME_POSITION, requestTime.getBytes()); |
|
| 115 |
+ buffer.put(DELIVER_REQUEST_TIME_POSITION, requestTime.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 115 | 116 |
} |
| 116 |
- public static String getRequestTimeForDeliver(ByteBuffer buffer) {
|
|
| 117 |
+ public static String getRequestTimeForDeliver(ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 117 | 118 |
if (buffer == null) {
|
| 118 | 119 |
return null; |
| 119 | 120 |
} |
... | ... | @@ -125,13 +126,13 @@ |
| 125 | 126 |
return Packet.getString(destArray); |
| 126 | 127 |
} |
| 127 | 128 |
|
| 128 |
- public static void putMsgTypeForDeliver(ByteBuffer buffer, String msgType) {
|
|
| 129 |
+ public static void putMsgTypeForDeliver(ByteBuffer buffer, String msgType) throws UnsupportedEncodingException {
|
|
| 129 | 130 |
if (buffer == null || msgType == null) {
|
| 130 | 131 |
return; |
| 131 | 132 |
} |
| 132 |
- buffer.put(DELIVER_MSG_TYPE_POSITION, msgType.getBytes()); |
|
| 133 |
+ buffer.put(DELIVER_MSG_TYPE_POSITION, msgType.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 133 | 134 |
} |
| 134 |
- public static String getMsgTypeForDeliver(ByteBuffer buffer) {
|
|
| 135 |
+ public static String getMsgTypeForDeliver(ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 135 | 136 |
if (buffer == null) {
|
| 136 | 137 |
return null; |
| 137 | 138 |
} |
... | ... | @@ -144,13 +145,13 @@ |
| 144 | 145 |
} |
| 145 | 146 |
|
| 146 | 147 |
|
| 147 |
- public static void putMessageIdForDeliverAck(ByteBuffer buffer, String messageId) {
|
|
| 148 |
+ public static void putMessageIdForDeliverAck(ByteBuffer buffer, String messageId) throws UnsupportedEncodingException {
|
|
| 148 | 149 |
if (buffer == null || messageId == null) {
|
| 149 | 150 |
return; |
| 150 | 151 |
} |
| 151 |
- buffer.put(DELIVER_ACK_MESSAGE_ID_POSITION, messageId.getBytes()); |
|
| 152 |
+ buffer.put(DELIVER_ACK_MESSAGE_ID_POSITION, messageId.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 152 | 153 |
} |
| 153 |
- public static String getMessageIdForDeliverAck(ByteBuffer buffer) {
|
|
| 154 |
+ public static String getMessageIdForDeliverAck(ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 154 | 155 |
if (buffer == null) {
|
| 155 | 156 |
return null; |
| 156 | 157 |
} |
... | ... | @@ -162,13 +163,13 @@ |
| 162 | 163 |
return Packet.getString(destArray); |
| 163 | 164 |
} |
| 164 | 165 |
|
| 165 |
- public static void putResultForDeliverAck(ByteBuffer buffer, String result) {
|
|
| 166 |
+ public static void putResultForDeliverAck(ByteBuffer buffer, String result) throws UnsupportedEncodingException {
|
|
| 166 | 167 |
if (buffer == null || result == null) {
|
| 167 | 168 |
return; |
| 168 | 169 |
} |
| 169 |
- buffer.put(DELIVER_ACK_RESULT_POSITION, result.getBytes()); |
|
| 170 |
+ buffer.put(DELIVER_ACK_RESULT_POSITION, result.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 170 | 171 |
} |
| 171 |
- public static String getResultForDeliverAck(ByteBuffer buffer) {
|
|
| 172 |
+ public static String getResultForDeliverAck(ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 172 | 173 |
if (buffer == null) {
|
| 173 | 174 |
return null; |
| 174 | 175 |
} |
--- src/main/java/com/munjaon/server/server/packet/common/Header.java
+++ src/main/java/com/munjaon/server/server/packet/common/Header.java
... | ... | @@ -2,6 +2,7 @@ |
| 2 | 2 |
|
| 3 | 3 |
import com.munjaon.server.util.ByteUtil; |
| 4 | 4 |
|
| 5 |
+import java.io.UnsupportedEncodingException; |
|
| 5 | 6 |
import java.nio.ByteBuffer; |
| 6 | 7 |
|
| 7 | 8 |
public final class Header {
|
... | ... | @@ -39,13 +40,13 @@ |
| 39 | 40 |
public static final int BODY_REPORT_LENGTH = 58; |
| 40 | 41 |
public static final int BODY_REPORT_ACK_LENGTH = 1; |
| 41 | 42 |
|
| 42 |
- public static void putVersion(final ByteBuffer buffer) {
|
|
| 43 |
+ public static void putVersion(final ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 43 | 44 |
if (buffer == null) {
|
| 44 | 45 |
return; |
| 45 | 46 |
} |
| 46 |
- buffer.put(VERSION_POSITION, VERSION.getBytes()); |
|
| 47 |
+ buffer.put(VERSION_POSITION, VERSION.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 47 | 48 |
} |
| 48 |
- public static String getVersion(final ByteBuffer buffer) {
|
|
| 49 |
+ public static String getVersion(final ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 49 | 50 |
if (buffer == null) {
|
| 50 | 51 |
return null; |
| 51 | 52 |
} |
... | ... | @@ -58,13 +59,13 @@ |
| 58 | 59 |
// return new String(destArray); |
| 59 | 60 |
} |
| 60 | 61 |
|
| 61 |
- public static void putCommand(final ByteBuffer buffer, String command) {
|
|
| 62 |
+ public static void putCommand(final ByteBuffer buffer, String command) throws UnsupportedEncodingException {
|
|
| 62 | 63 |
if (buffer == null) {
|
| 63 | 64 |
return; |
| 64 | 65 |
} |
| 65 |
- buffer.put(COMMAND_POSITION, command.getBytes()); |
|
| 66 |
+ buffer.put(COMMAND_POSITION, command.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 66 | 67 |
} |
| 67 |
- public static String getCommand(final ByteBuffer buffer) {
|
|
| 68 |
+ public static String getCommand(final ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 68 | 69 |
if (buffer == null) {
|
| 69 | 70 |
return null; |
| 70 | 71 |
} |
... | ... | @@ -76,10 +77,10 @@ |
| 76 | 77 |
return Packet.getString(destArray); |
| 77 | 78 |
} |
| 78 | 79 |
|
| 79 |
- public static void putBodyLength(final ByteBuffer buffer, int bodyLength) {
|
|
| 80 |
+ public static void putBodyLength(final ByteBuffer buffer, int bodyLength) throws UnsupportedEncodingException {
|
|
| 80 | 81 |
putBodyLength(buffer, Integer.toString(bodyLength)); |
| 81 | 82 |
} |
| 82 |
- public static String getBodyLength(final ByteBuffer buffer) {
|
|
| 83 |
+ public static String getBodyLength(final ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 83 | 84 |
if (buffer == null) {
|
| 84 | 85 |
return null; |
| 85 | 86 |
} |
... | ... | @@ -92,16 +93,16 @@ |
| 92 | 93 |
return Packet.getString(destArray); |
| 93 | 94 |
} |
| 94 | 95 |
|
| 95 |
- public static void putBodyLength(final ByteBuffer buffer, String bodyLength) {
|
|
| 96 |
+ public static void putBodyLength(final ByteBuffer buffer, String bodyLength) throws UnsupportedEncodingException {
|
|
| 96 | 97 |
if (buffer == null) {
|
| 97 | 98 |
return; |
| 98 | 99 |
} |
| 99 |
- buffer.put(BODY_POSITION, bodyLength.getBytes()); |
|
| 100 |
+ buffer.put(BODY_POSITION, bodyLength.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 100 | 101 |
} |
| 101 |
- public static void putHeader(final ByteBuffer buffer, String command, int bodyLength) {
|
|
| 102 |
+ public static void putHeader(final ByteBuffer buffer, String command, int bodyLength) throws UnsupportedEncodingException {
|
|
| 102 | 103 |
putHeader(buffer, command, Integer.toString(bodyLength)); |
| 103 | 104 |
} |
| 104 |
- public static void putHeader(final ByteBuffer buffer, String command, String bodyLength) {
|
|
| 105 |
+ public static void putHeader(final ByteBuffer buffer, String command, String bodyLength) throws UnsupportedEncodingException {
|
|
| 105 | 106 |
putVersion(buffer); |
| 106 | 107 |
putCommand(buffer, command); |
| 107 | 108 |
putBodyLength(buffer, bodyLength); |
--- src/main/java/com/munjaon/server/server/packet/common/KakaoMessage.java
+++ src/main/java/com/munjaon/server/server/packet/common/KakaoMessage.java
... | ... | @@ -2,6 +2,7 @@ |
| 2 | 2 |
|
| 3 | 3 |
import com.munjaon.server.util.CommonUtil; |
| 4 | 4 |
|
| 5 |
+import java.io.UnsupportedEncodingException; |
|
| 5 | 6 |
import java.nio.ByteBuffer; |
| 6 | 7 |
|
| 7 | 8 |
public final class KakaoMessage {
|
... | ... | @@ -30,14 +31,14 @@ |
| 30 | 31 |
public static final int DELIVER_KAKAO_TEMPLATE_CODE_LENGTH = 64; |
| 31 | 32 |
public static final int DELIVER_KAKAO_TEMPLATE_CODE_POSITION = DELIVER_KAKAO_SENDER_KEY_POSITION + DELIVER_KAKAO_SENDER_KEY_LENGTH; |
| 32 | 33 |
|
| 33 |
- public static void putSubjectForDeliver(ByteBuffer buffer, String subject) {
|
|
| 34 |
+ public static void putSubjectForDeliver(ByteBuffer buffer, String subject) throws UnsupportedEncodingException {
|
|
| 34 | 35 |
if (buffer == null || subject == null) {
|
| 35 | 36 |
return; |
| 36 | 37 |
} |
| 37 | 38 |
subject = CommonUtil.cutString(subject, DELIVER_SUBJECT_LENGTH); |
| 38 |
- buffer.put(DELIVER_SUBJECT_POSITION, subject.getBytes()); |
|
| 39 |
+ buffer.put(DELIVER_SUBJECT_POSITION, subject.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 39 | 40 |
} |
| 40 |
- public static String getSubjectForDeliver(ByteBuffer buffer) {
|
|
| 41 |
+ public static String getSubjectForDeliver(ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 41 | 42 |
if (buffer == null) {
|
| 42 | 43 |
return null; |
| 43 | 44 |
} |
... | ... | @@ -49,14 +50,14 @@ |
| 49 | 50 |
return Packet.getString(destArray); |
| 50 | 51 |
} |
| 51 | 52 |
|
| 52 |
- public static void putMessageForDeliver(ByteBuffer buffer, String message) {
|
|
| 53 |
+ public static void putMessageForDeliver(ByteBuffer buffer, String message) throws UnsupportedEncodingException {
|
|
| 53 | 54 |
if (buffer == null || message == null) {
|
| 54 | 55 |
return; |
| 55 | 56 |
} |
| 56 | 57 |
message = CommonUtil.cutString(message, DELIVER_MESSAGE_LENGTH); |
| 57 |
- buffer.put(DELIVER_MESSAGE_POSITION, message.getBytes()); |
|
| 58 |
+ buffer.put(DELIVER_MESSAGE_POSITION, message.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 58 | 59 |
} |
| 59 |
- public static String getMessageForDeliver(ByteBuffer buffer) {
|
|
| 60 |
+ public static String getMessageForDeliver(ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 60 | 61 |
if (buffer == null) {
|
| 61 | 62 |
return null; |
| 62 | 63 |
} |
... | ... | @@ -67,14 +68,14 @@ |
| 67 | 68 |
|
| 68 | 69 |
return Packet.getString(destArray); |
| 69 | 70 |
} |
| 70 |
- public static void putKakaoSenderKeyForDeliver(ByteBuffer buffer, String kakaoSenderKey) {
|
|
| 71 |
+ public static void putKakaoSenderKeyForDeliver(ByteBuffer buffer, String kakaoSenderKey) throws UnsupportedEncodingException {
|
|
| 71 | 72 |
if (buffer == null || kakaoSenderKey == null) {
|
| 72 | 73 |
return; |
| 73 | 74 |
} |
| 74 | 75 |
kakaoSenderKey = CommonUtil.cutString(kakaoSenderKey, DELIVER_KAKAO_SENDER_KEY_LENGTH); |
| 75 |
- buffer.put(DELIVER_KAKAO_SENDER_KEY_POSITION, kakaoSenderKey.getBytes()); |
|
| 76 |
+ buffer.put(DELIVER_KAKAO_SENDER_KEY_POSITION, kakaoSenderKey.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 76 | 77 |
} |
| 77 |
- public static String getKakaoSenderKeyForDeliver(ByteBuffer buffer) {
|
|
| 78 |
+ public static String getKakaoSenderKeyForDeliver(ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 78 | 79 |
if (buffer == null) {
|
| 79 | 80 |
return null; |
| 80 | 81 |
} |
... | ... | @@ -85,14 +86,14 @@ |
| 85 | 86 |
|
| 86 | 87 |
return Packet.getString(destArray); |
| 87 | 88 |
} |
| 88 |
- public static void putKakaoTemplateCodeForDeliver(ByteBuffer buffer, String kakaoTemplateCode) {
|
|
| 89 |
+ public static void putKakaoTemplateCodeForDeliver(ByteBuffer buffer, String kakaoTemplateCode) throws UnsupportedEncodingException {
|
|
| 89 | 90 |
if (buffer == null || kakaoTemplateCode == null) {
|
| 90 | 91 |
return; |
| 91 | 92 |
} |
| 92 | 93 |
kakaoTemplateCode = CommonUtil.cutString(kakaoTemplateCode, DELIVER_KAKAO_TEMPLATE_CODE_LENGTH); |
| 93 |
- buffer.put(DELIVER_KAKAO_TEMPLATE_CODE_POSITION, kakaoTemplateCode.getBytes()); |
|
| 94 |
+ buffer.put(DELIVER_KAKAO_TEMPLATE_CODE_POSITION, kakaoTemplateCode.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 94 | 95 |
} |
| 95 |
- public static String getKakaoTemplateCodeForDeliver(ByteBuffer buffer) {
|
|
| 96 |
+ public static String getKakaoTemplateCodeForDeliver(ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 96 | 97 |
if (buffer == null) {
|
| 97 | 98 |
return null; |
| 98 | 99 |
} |
... | ... | @@ -104,7 +105,7 @@ |
| 104 | 105 |
return Packet.getString(destArray); |
| 105 | 106 |
} |
| 106 | 107 |
|
| 107 |
- public static String getFileNameForDeliver(ByteBuffer buffer) {
|
|
| 108 |
+ public static String getFileNameForDeliver(ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 108 | 109 |
if (buffer == null) {
|
| 109 | 110 |
return null; |
| 110 | 111 |
} |
... | ... | @@ -116,7 +117,7 @@ |
| 116 | 117 |
return Packet.getString(destArray); |
| 117 | 118 |
} |
| 118 | 119 |
|
| 119 |
- public static String getFileSizeForDeliver(ByteBuffer buffer) {
|
|
| 120 |
+ public static String getFileSizeForDeliver(ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 120 | 121 |
if (buffer == null) {
|
| 121 | 122 |
return null; |
| 122 | 123 |
} |
... | ... | @@ -128,12 +129,12 @@ |
| 128 | 129 |
return Packet.getString(destArray); |
| 129 | 130 |
} |
| 130 | 131 |
|
| 131 |
- public static ByteBuffer makeDeliverAckBuffer(String msgId, String status) {
|
|
| 132 |
+ public static ByteBuffer makeDeliverAckBuffer(String msgId, String status) throws UnsupportedEncodingException {
|
|
| 132 | 133 |
ByteBuffer buffer = ByteBuffer.allocate(Header.HEADER_LENGTH + DELIVER_KAKAO_ACK_BODY_LENGTH); |
| 133 | 134 |
Packet.setDefaultByte(buffer); |
| 134 | 135 |
Header.putHeader(buffer, Header.COMMAND_DELIVER_ACK, DELIVER_KAKAO_ACK_BODY_LENGTH); |
| 135 |
- buffer.put(CommonMessage.DELIVER_ACK_MESSAGE_ID_POSITION, msgId.getBytes()); |
|
| 136 |
- buffer.put(CommonMessage.DELIVER_ACK_RESULT_POSITION, status.getBytes()); |
|
| 136 |
+ buffer.put(CommonMessage.DELIVER_ACK_MESSAGE_ID_POSITION, msgId.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 137 |
+ buffer.put(CommonMessage.DELIVER_ACK_RESULT_POSITION, status.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 137 | 138 |
|
| 138 | 139 |
return buffer; |
| 139 | 140 |
} |
--- src/main/java/com/munjaon/server/server/packet/common/LinkCheck.java
+++ src/main/java/com/munjaon/server/server/packet/common/LinkCheck.java
... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 |
package com.munjaon.server.server.packet.common; |
| 2 | 2 |
|
| 3 |
+import java.io.UnsupportedEncodingException; |
|
| 3 | 4 |
import java.nio.ByteBuffer; |
| 4 | 5 |
|
| 5 | 6 |
public final class LinkCheck {
|
... | ... | @@ -11,20 +12,20 @@ |
| 11 | 12 |
public static String LINK_CHECK_VALUE = "100"; |
| 12 | 13 |
public static String LINK_CHECK_ACK_VALUE = "100"; |
| 13 | 14 |
|
| 14 |
- public static ByteBuffer makeLinkCheckBuffer() {
|
|
| 15 |
+ public static ByteBuffer makeLinkCheckBuffer() throws UnsupportedEncodingException {
|
|
| 15 | 16 |
ByteBuffer buffer = ByteBuffer.allocate(Header.HEADER_LENGTH + LINK_CHECK_BODY_LENGTH); |
| 16 | 17 |
Packet.setDefaultByte(buffer); |
| 17 | 18 |
Header.putHeader(buffer, Header.COMMAND_LINK_CHECK, LINK_CHECK_BODY_LENGTH); |
| 18 |
- buffer.put(LINK_CHECK_BODY_POSITION, LINK_CHECK_VALUE.getBytes()); |
|
| 19 |
+ buffer.put(LINK_CHECK_BODY_POSITION, LINK_CHECK_VALUE.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 19 | 20 |
|
| 20 | 21 |
return buffer; |
| 21 | 22 |
} |
| 22 | 23 |
|
| 23 |
- public static ByteBuffer makeLinkCheckAckBuffer() {
|
|
| 24 |
+ public static ByteBuffer makeLinkCheckAckBuffer() throws UnsupportedEncodingException {
|
|
| 24 | 25 |
ByteBuffer buffer = ByteBuffer.allocate(Header.HEADER_LENGTH + LINK_CHECK_ACK_BODY_LENGTH); |
| 25 | 26 |
Packet.setDefaultByte(buffer); |
| 26 | 27 |
Header.putHeader(buffer, Header.COMMAND_LINK_CHECK_ACK, LINK_CHECK_ACK_BODY_LENGTH); |
| 27 |
- buffer.put(LINK_CHECK_ACK_BODY_POSITION, LINK_CHECK_ACK_VALUE.getBytes()); |
|
| 28 |
+ buffer.put(LINK_CHECK_ACK_BODY_POSITION, LINK_CHECK_ACK_VALUE.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 28 | 29 |
|
| 29 | 30 |
return buffer; |
| 30 | 31 |
} |
--- src/main/java/com/munjaon/server/server/packet/common/LmsMessage.java
+++ src/main/java/com/munjaon/server/server/packet/common/LmsMessage.java
... | ... | @@ -2,6 +2,7 @@ |
| 2 | 2 |
|
| 3 | 3 |
import com.munjaon.server.util.CommonUtil; |
| 4 | 4 |
|
| 5 |
+import java.io.UnsupportedEncodingException; |
|
| 5 | 6 |
import java.nio.ByteBuffer; |
| 6 | 7 |
|
| 7 | 8 |
public final class LmsMessage {
|
... | ... | @@ -16,14 +17,14 @@ |
| 16 | 17 |
public static final int DELIVER_MESSAGE_LENGTH = 2000; |
| 17 | 18 |
public static final int DELIVER_MESSAGE_POSITION = DELIVER_SUBJECT_POSITION + DELIVER_SUBJECT_LENGTH; |
| 18 | 19 |
|
| 19 |
- public static void putSubjectForDeliver(ByteBuffer buffer, String subject) {
|
|
| 20 |
+ public static void putSubjectForDeliver(ByteBuffer buffer, String subject) throws UnsupportedEncodingException {
|
|
| 20 | 21 |
if (buffer == null || subject == null) {
|
| 21 | 22 |
return; |
| 22 | 23 |
} |
| 23 | 24 |
subject = CommonUtil.cutString(subject, DELIVER_SUBJECT_LENGTH); |
| 24 |
- buffer.put(DELIVER_SUBJECT_POSITION, subject.getBytes()); |
|
| 25 |
+ buffer.put(DELIVER_SUBJECT_POSITION, subject.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 25 | 26 |
} |
| 26 |
- public static String getSubjectForDeliver(ByteBuffer buffer) {
|
|
| 27 |
+ public static String getSubjectForDeliver(ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 27 | 28 |
if (buffer == null) {
|
| 28 | 29 |
return null; |
| 29 | 30 |
} |
... | ... | @@ -35,14 +36,14 @@ |
| 35 | 36 |
return Packet.getString(destArray); |
| 36 | 37 |
} |
| 37 | 38 |
|
| 38 |
- public static void putMessageForDeliver(ByteBuffer buffer, String message) {
|
|
| 39 |
+ public static void putMessageForDeliver(ByteBuffer buffer, String message) throws UnsupportedEncodingException {
|
|
| 39 | 40 |
if (buffer == null || message == null) {
|
| 40 | 41 |
return; |
| 41 | 42 |
} |
| 42 | 43 |
message = CommonUtil.cutString(message, DELIVER_MESSAGE_LENGTH); |
| 43 |
- buffer.put(DELIVER_MESSAGE_POSITION, message.getBytes()); |
|
| 44 |
+ buffer.put(DELIVER_MESSAGE_POSITION, message.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 44 | 45 |
} |
| 45 |
- public static String getMessageForDeliver(ByteBuffer buffer) {
|
|
| 46 |
+ public static String getMessageForDeliver(ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 46 | 47 |
if (buffer == null) {
|
| 47 | 48 |
return null; |
| 48 | 49 |
} |
... | ... | @@ -54,12 +55,12 @@ |
| 54 | 55 |
return Packet.getString(destArray); |
| 55 | 56 |
} |
| 56 | 57 |
|
| 57 |
- public static ByteBuffer makeDeliverAckBuffer(String msgId, String status) {
|
|
| 58 |
+ public static ByteBuffer makeDeliverAckBuffer(String msgId, String status) throws UnsupportedEncodingException {
|
|
| 58 | 59 |
ByteBuffer buffer = ByteBuffer.allocate(Header.HEADER_LENGTH + DELIVER_LMS_ACK_BODY_LENGTH); |
| 59 | 60 |
Packet.setDefaultByte(buffer); |
| 60 | 61 |
Header.putHeader(buffer, Header.COMMAND_DELIVER_ACK, DELIVER_LMS_ACK_BODY_LENGTH); |
| 61 |
- buffer.put(CommonMessage.DELIVER_ACK_MESSAGE_ID_POSITION, msgId.getBytes()); |
|
| 62 |
- buffer.put(CommonMessage.DELIVER_ACK_RESULT_POSITION, status.getBytes()); |
|
| 62 |
+ buffer.put(CommonMessage.DELIVER_ACK_MESSAGE_ID_POSITION, msgId.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 63 |
+ buffer.put(CommonMessage.DELIVER_ACK_RESULT_POSITION, status.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 63 | 64 |
|
| 64 | 65 |
return buffer; |
| 65 | 66 |
} |
--- src/main/java/com/munjaon/server/server/packet/common/MmsMessage.java
+++ src/main/java/com/munjaon/server/server/packet/common/MmsMessage.java
... | ... | @@ -2,6 +2,7 @@ |
| 2 | 2 |
|
| 3 | 3 |
import com.munjaon.server.util.CommonUtil; |
| 4 | 4 |
|
| 5 |
+import java.io.UnsupportedEncodingException; |
|
| 5 | 6 |
import java.nio.ByteBuffer; |
| 6 | 7 |
|
| 7 | 8 |
public final class MmsMessage {
|
... | ... | @@ -27,14 +28,14 @@ |
| 27 | 28 |
public static final int DELIVER_MMS_FILESIZE_LENGTH = 8; |
| 28 | 29 |
public static final int DELIVER_MMS_FILESIZE_POSITION = DELIVER_MMS_FILENAME_POSITION + DELIVER_MMS_FILENAME_LENGTH; |
| 29 | 30 |
|
| 30 |
- public static void putSubjectForDeliver(ByteBuffer buffer, String subject) {
|
|
| 31 |
+ public static void putSubjectForDeliver(ByteBuffer buffer, String subject) throws UnsupportedEncodingException {
|
|
| 31 | 32 |
if (buffer == null || subject == null) {
|
| 32 | 33 |
return; |
| 33 | 34 |
} |
| 34 | 35 |
subject = CommonUtil.cutString(subject, DELIVER_SUBJECT_LENGTH); |
| 35 |
- buffer.put(DELIVER_SUBJECT_POSITION, subject.getBytes()); |
|
| 36 |
+ buffer.put(DELIVER_SUBJECT_POSITION, subject.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 36 | 37 |
} |
| 37 |
- public static String getSubjectForDeliver(ByteBuffer buffer) {
|
|
| 38 |
+ public static String getSubjectForDeliver(ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 38 | 39 |
if (buffer == null) {
|
| 39 | 40 |
return null; |
| 40 | 41 |
} |
... | ... | @@ -46,14 +47,14 @@ |
| 46 | 47 |
return Packet.getString(destArray); |
| 47 | 48 |
} |
| 48 | 49 |
|
| 49 |
- public static void putMessageForDeliver(ByteBuffer buffer, String message) {
|
|
| 50 |
+ public static void putMessageForDeliver(ByteBuffer buffer, String message) throws UnsupportedEncodingException {
|
|
| 50 | 51 |
if (buffer == null || message == null) {
|
| 51 | 52 |
return; |
| 52 | 53 |
} |
| 53 | 54 |
message = CommonUtil.cutString(message, DELIVER_MESSAGE_LENGTH); |
| 54 |
- buffer.put(DELIVER_MESSAGE_POSITION, message.getBytes()); |
|
| 55 |
+ buffer.put(DELIVER_MESSAGE_POSITION, message.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 55 | 56 |
} |
| 56 |
- public static String getMessageForDeliver(ByteBuffer buffer) {
|
|
| 57 |
+ public static String getMessageForDeliver(ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 57 | 58 |
if (buffer == null) {
|
| 58 | 59 |
return null; |
| 59 | 60 |
} |
... | ... | @@ -65,17 +66,17 @@ |
| 65 | 66 |
return Packet.getString(destArray); |
| 66 | 67 |
} |
| 67 | 68 |
|
| 68 |
- public static void putFileCountForDeliver(ByteBuffer buffer, int fileCount) {
|
|
| 69 |
+ public static void putFileCountForDeliver(ByteBuffer buffer, int fileCount) throws UnsupportedEncodingException {
|
|
| 69 | 70 |
putFileCountForDeliver(buffer, Integer.toString(fileCount)); |
| 70 | 71 |
} |
| 71 | 72 |
|
| 72 |
- public static void putFileCountForDeliver(ByteBuffer buffer, String fileCount) {
|
|
| 73 |
+ public static void putFileCountForDeliver(ByteBuffer buffer, String fileCount) throws UnsupportedEncodingException {
|
|
| 73 | 74 |
if (buffer == null || fileCount == null) {
|
| 74 | 75 |
return; |
| 75 | 76 |
} |
| 76 |
- buffer.put(DELIVER_FILECOUNT_POSITION, fileCount.getBytes()); |
|
| 77 |
+ buffer.put(DELIVER_FILECOUNT_POSITION, fileCount.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 77 | 78 |
} |
| 78 |
- public static String getFileCountForDeliver(ByteBuffer buffer) {
|
|
| 79 |
+ public static String getFileCountForDeliver(ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 79 | 80 |
if (buffer == null) {
|
| 80 | 81 |
return null; |
| 81 | 82 |
} |
... | ... | @@ -87,7 +88,7 @@ |
| 87 | 88 |
return Packet.getString(destArray); |
| 88 | 89 |
} |
| 89 | 90 |
|
| 90 |
- public static String getFileNameForDeliver(ByteBuffer buffer) {
|
|
| 91 |
+ public static String getFileNameForDeliver(ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 91 | 92 |
if (buffer == null) {
|
| 92 | 93 |
return null; |
| 93 | 94 |
} |
... | ... | @@ -99,7 +100,7 @@ |
| 99 | 100 |
return Packet.getString(destArray); |
| 100 | 101 |
} |
| 101 | 102 |
|
| 102 |
- public static String getFileSizeForDeliver(ByteBuffer buffer) {
|
|
| 103 |
+ public static String getFileSizeForDeliver(ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 103 | 104 |
if (buffer == null) {
|
| 104 | 105 |
return null; |
| 105 | 106 |
} |
... | ... | @@ -111,12 +112,12 @@ |
| 111 | 112 |
return Packet.getString(destArray); |
| 112 | 113 |
} |
| 113 | 114 |
|
| 114 |
- public static ByteBuffer makeDeliverAckBuffer(String msgId, String status) {
|
|
| 115 |
+ public static ByteBuffer makeDeliverAckBuffer(String msgId, String status) throws UnsupportedEncodingException {
|
|
| 115 | 116 |
ByteBuffer buffer = ByteBuffer.allocate(Header.HEADER_LENGTH + DELIVER_MMS_ACK_BODY_LENGTH); |
| 116 | 117 |
Packet.setDefaultByte(buffer); |
| 117 | 118 |
Header.putHeader(buffer, Header.COMMAND_DELIVER_ACK, DELIVER_MMS_ACK_BODY_LENGTH); |
| 118 |
- buffer.put(CommonMessage.DELIVER_ACK_MESSAGE_ID_POSITION, msgId.getBytes()); |
|
| 119 |
- buffer.put(CommonMessage.DELIVER_ACK_RESULT_POSITION, status.getBytes()); |
|
| 119 |
+ buffer.put(CommonMessage.DELIVER_ACK_MESSAGE_ID_POSITION, msgId.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 120 |
+ buffer.put(CommonMessage.DELIVER_ACK_RESULT_POSITION, status.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 120 | 121 |
|
| 121 | 122 |
return buffer; |
| 122 | 123 |
} |
--- src/main/java/com/munjaon/server/server/packet/common/Packet.java
+++ src/main/java/com/munjaon/server/server/packet/common/Packet.java
... | ... | @@ -1,8 +1,10 @@ |
| 1 | 1 |
package com.munjaon.server.server.packet.common; |
| 2 | 2 |
|
| 3 |
+import java.io.UnsupportedEncodingException; |
|
| 3 | 4 |
import java.nio.ByteBuffer; |
| 4 | 5 |
|
| 5 | 6 |
public final class Packet {
|
| 7 |
+ public static final String AGENT_CHARACTER_SET = "EUC-KR"; |
|
| 6 | 8 |
public static final byte SET_DEFAULT_BYTE = (byte) 0x00; |
| 7 | 9 |
/* LinkCheck 전송 체크 시간 간격 */ |
| 8 | 10 |
public static final long LINK_CHECK_CYCLE = 10000L; |
... | ... | @@ -18,7 +20,7 @@ |
| 18 | 20 |
} |
| 19 | 21 |
} |
| 20 | 22 |
|
| 21 |
- public static String getString(byte[] srcArray) {
|
|
| 23 |
+ public static String getString(byte[] srcArray) throws UnsupportedEncodingException {
|
|
| 22 | 24 |
if (srcArray == null) {
|
| 23 | 25 |
return null; |
| 24 | 26 |
} |
... | ... | @@ -41,7 +43,7 @@ |
| 41 | 43 |
} |
| 42 | 44 |
} |
| 43 | 45 |
|
| 44 |
- return destArray == null ? null : new String(destArray); |
|
| 46 |
+ return destArray == null ? null : new String(destArray, Packet.AGENT_CHARACTER_SET); |
|
| 45 | 47 |
} |
| 46 | 48 |
|
| 47 | 49 |
public static void mergeBuffers(ByteBuffer dest, ByteBuffer srcHead, ByteBuffer srcBody) {
|
--- src/main/java/com/munjaon/server/server/packet/common/Report.java
+++ src/main/java/com/munjaon/server/server/packet/common/Report.java
... | ... | @@ -2,6 +2,7 @@ |
| 2 | 2 |
|
| 3 | 3 |
import com.munjaon.server.server.dto.ReportDto; |
| 4 | 4 |
|
| 5 |
+import java.io.UnsupportedEncodingException; |
|
| 5 | 6 |
import java.nio.ByteBuffer; |
| 6 | 7 |
|
| 7 | 8 |
public final class Report {
|
... | ... | @@ -34,7 +35,7 @@ |
| 34 | 35 |
|
| 35 | 36 |
public static final int REPORT_ACK_BODY_LENGTH = REPORT_ACK_RESULT_POSITION + REPORT_ACK_RESULT_LENGTH; |
| 36 | 37 |
|
| 37 |
- public static void putReport(final ByteBuffer buffer, final ReportDto reportDto) {
|
|
| 38 |
+ public static void putReport(final ByteBuffer buffer, final ReportDto reportDto) throws UnsupportedEncodingException {
|
|
| 38 | 39 |
if (reportDto == null) {
|
| 39 | 40 |
return; |
| 40 | 41 |
} |
... | ... | @@ -44,14 +45,14 @@ |
| 44 | 45 |
putTelecom(buffer, reportDto.getRsltNet()); |
| 45 | 46 |
putResult(buffer, reportDto.getRsltCode()); |
| 46 | 47 |
} |
| 47 |
- public static void putMsgId(final ByteBuffer buffer, String msgId) {
|
|
| 48 |
+ public static void putMsgId(final ByteBuffer buffer, String msgId) throws UnsupportedEncodingException {
|
|
| 48 | 49 |
if (buffer == null || msgId == null) {
|
| 49 | 50 |
return; |
| 50 | 51 |
} |
| 51 |
- buffer.put(REPORT_MSG_ID_POSITION, msgId.getBytes()); |
|
| 52 |
+ buffer.put(REPORT_MSG_ID_POSITION, msgId.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 52 | 53 |
} |
| 53 | 54 |
|
| 54 |
- public static String getMsgId(final ByteBuffer buffer) {
|
|
| 55 |
+ public static String getMsgId(final ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 55 | 56 |
if (buffer == null) {
|
| 56 | 57 |
return null; |
| 57 | 58 |
} |
... | ... | @@ -63,14 +64,14 @@ |
| 63 | 64 |
return Packet.getString(destArray); |
| 64 | 65 |
} |
| 65 | 66 |
|
| 66 |
- public static void putAgentCode(final ByteBuffer buffer, String agentCode) {
|
|
| 67 |
+ public static void putAgentCode(final ByteBuffer buffer, String agentCode) throws UnsupportedEncodingException {
|
|
| 67 | 68 |
if (buffer == null || agentCode == null) {
|
| 68 | 69 |
return; |
| 69 | 70 |
} |
| 70 |
- buffer.put(REPORT_AGENT_CODE_POSITION, agentCode.getBytes()); |
|
| 71 |
+ buffer.put(REPORT_AGENT_CODE_POSITION, agentCode.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 71 | 72 |
} |
| 72 | 73 |
|
| 73 |
- public static String getAgentCode(final ByteBuffer buffer) {
|
|
| 74 |
+ public static String getAgentCode(final ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 74 | 75 |
if (buffer == null) {
|
| 75 | 76 |
return null; |
| 76 | 77 |
} |
... | ... | @@ -82,14 +83,14 @@ |
| 82 | 83 |
return Packet.getString(destArray); |
| 83 | 84 |
} |
| 84 | 85 |
|
| 85 |
- public static void putSendTime(final ByteBuffer buffer, String sendTime) {
|
|
| 86 |
+ public static void putSendTime(final ByteBuffer buffer, String sendTime) throws UnsupportedEncodingException {
|
|
| 86 | 87 |
if (buffer == null || sendTime == null) {
|
| 87 | 88 |
return; |
| 88 | 89 |
} |
| 89 |
- buffer.put(REPORT_SEND_TIME_POSITION, sendTime.getBytes()); |
|
| 90 |
+ buffer.put(REPORT_SEND_TIME_POSITION, sendTime.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 90 | 91 |
} |
| 91 | 92 |
|
| 92 |
- public static String getSendTime(final ByteBuffer buffer) {
|
|
| 93 |
+ public static String getSendTime(final ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 93 | 94 |
if (buffer == null) {
|
| 94 | 95 |
return null; |
| 95 | 96 |
} |
... | ... | @@ -101,14 +102,14 @@ |
| 101 | 102 |
return Packet.getString(destArray); |
| 102 | 103 |
} |
| 103 | 104 |
|
| 104 |
- public static void putTelecom(final ByteBuffer buffer, String telecom) {
|
|
| 105 |
+ public static void putTelecom(final ByteBuffer buffer, String telecom) throws UnsupportedEncodingException {
|
|
| 105 | 106 |
if (buffer == null || telecom == null) {
|
| 106 | 107 |
return; |
| 107 | 108 |
} |
| 108 |
- buffer.put(REPORT_TELECOM_POSITION, telecom.getBytes()); |
|
| 109 |
+ buffer.put(REPORT_TELECOM_POSITION, telecom.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 109 | 110 |
} |
| 110 | 111 |
|
| 111 |
- public static String getTelecom(final ByteBuffer buffer) {
|
|
| 112 |
+ public static String getTelecom(final ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 112 | 113 |
if (buffer == null) {
|
| 113 | 114 |
return null; |
| 114 | 115 |
} |
... | ... | @@ -120,14 +121,14 @@ |
| 120 | 121 |
return Packet.getString(destArray); |
| 121 | 122 |
} |
| 122 | 123 |
|
| 123 |
- public static void putResult(final ByteBuffer buffer, String result) {
|
|
| 124 |
+ public static void putResult(final ByteBuffer buffer, String result) throws UnsupportedEncodingException {
|
|
| 124 | 125 |
if (buffer == null || result == null) {
|
| 125 | 126 |
return; |
| 126 | 127 |
} |
| 127 |
- buffer.put(REPORT_RESULT_POSITION, result.getBytes()); |
|
| 128 |
+ buffer.put(REPORT_RESULT_POSITION, result.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 128 | 129 |
} |
| 129 | 130 |
|
| 130 |
- public static String getResult(final ByteBuffer buffer) {
|
|
| 131 |
+ public static String getResult(final ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 131 | 132 |
if (buffer == null) {
|
| 132 | 133 |
return null; |
| 133 | 134 |
} |
... | ... | @@ -139,14 +140,14 @@ |
| 139 | 140 |
return Packet.getString(destArray); |
| 140 | 141 |
} |
| 141 | 142 |
|
| 142 |
- public static void putResultAck(final ByteBuffer buffer, String result) {
|
|
| 143 |
+ public static void putResultAck(final ByteBuffer buffer, String result) throws UnsupportedEncodingException {
|
|
| 143 | 144 |
if (buffer == null || result == null) {
|
| 144 | 145 |
return; |
| 145 | 146 |
} |
| 146 |
- buffer.put(REPORT_ACK_RESULT_POSITION, result.getBytes()); |
|
| 147 |
+ buffer.put(REPORT_ACK_RESULT_POSITION, result.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 147 | 148 |
} |
| 148 | 149 |
|
| 149 |
- public static String getResultAck(final ByteBuffer buffer) {
|
|
| 150 |
+ public static String getResultAck(final ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 150 | 151 |
if (buffer == null) {
|
| 151 | 152 |
return null; |
| 152 | 153 |
} |
--- src/main/java/com/munjaon/server/server/packet/common/SmsMessage.java
+++ src/main/java/com/munjaon/server/server/packet/common/SmsMessage.java
... | ... | @@ -2,6 +2,7 @@ |
| 2 | 2 |
|
| 3 | 3 |
import com.munjaon.server.util.CommonUtil; |
| 4 | 4 |
|
| 5 |
+import java.io.UnsupportedEncodingException; |
|
| 5 | 6 |
import java.nio.ByteBuffer; |
| 6 | 7 |
|
| 7 | 8 |
public final class SmsMessage {
|
... | ... | @@ -13,14 +14,14 @@ |
| 13 | 14 |
public static final int DELIVER_MESSAGE_LENGTH = 160; |
| 14 | 15 |
public static final int DELIVER_MESSAGE_POSITION = CommonMessage.DELIVER_MSG_TYPE_POSITION + CommonMessage.DELIVER_MSG_TYPE_LENGTH; |
| 15 | 16 |
|
| 16 |
- public static void putMessageForDeliver(ByteBuffer buffer, String message) {
|
|
| 17 |
+ public static void putMessageForDeliver(ByteBuffer buffer, String message) throws UnsupportedEncodingException {
|
|
| 17 | 18 |
if (buffer == null || message == null) {
|
| 18 | 19 |
return; |
| 19 | 20 |
} |
| 20 | 21 |
message = CommonUtil.cutString(message, DELIVER_MESSAGE_LENGTH); |
| 21 |
- buffer.put(DELIVER_MESSAGE_POSITION, message.getBytes()); |
|
| 22 |
+ buffer.put(DELIVER_MESSAGE_POSITION, message.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 22 | 23 |
} |
| 23 |
- public static String getMessageForDeliver(ByteBuffer buffer) {
|
|
| 24 |
+ public static String getMessageForDeliver(ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 24 | 25 |
if (buffer == null) {
|
| 25 | 26 |
return null; |
| 26 | 27 |
} |
... | ... | @@ -32,12 +33,12 @@ |
| 32 | 33 |
return Packet.getString(destArray); |
| 33 | 34 |
} |
| 34 | 35 |
|
| 35 |
- public static ByteBuffer makeDeliverAckBuffer(String msgId, String status) {
|
|
| 36 |
+ public static ByteBuffer makeDeliverAckBuffer(String msgId, String status) throws UnsupportedEncodingException {
|
|
| 36 | 37 |
ByteBuffer buffer = ByteBuffer.allocate(Header.HEADER_LENGTH + DELIVER_SMS_ACK_BODY_LENGTH); |
| 37 | 38 |
Packet.setDefaultByte(buffer); |
| 38 | 39 |
Header.putHeader(buffer, Header.COMMAND_DELIVER_ACK, DELIVER_SMS_ACK_BODY_LENGTH); |
| 39 |
- buffer.put(CommonMessage.DELIVER_ACK_MESSAGE_ID_POSITION, msgId.getBytes()); |
|
| 40 |
- buffer.put(CommonMessage.DELIVER_ACK_RESULT_POSITION, status.getBytes()); |
|
| 40 |
+ buffer.put(CommonMessage.DELIVER_ACK_MESSAGE_ID_POSITION, msgId.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 41 |
+ buffer.put(CommonMessage.DELIVER_ACK_RESULT_POSITION, status.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 41 | 42 |
|
| 42 | 43 |
return buffer; |
| 43 | 44 |
} |
--- src/main/java/com/munjaon/server/server/service/CollectBackServerService.java
+++ src/main/java/com/munjaon/server/server/service/CollectBackServerService.java
... | ... | @@ -13,6 +13,7 @@ |
| 13 | 13 |
import org.json.simple.JSONObject; |
| 14 | 14 |
|
| 15 | 15 |
import java.io.IOException; |
| 16 |
+import java.io.UnsupportedEncodingException; |
|
| 16 | 17 |
import java.net.InetSocketAddress; |
| 17 | 18 |
import java.net.Socket; |
| 18 | 19 |
import java.net.SocketAddress; |
... | ... | @@ -339,7 +340,7 @@ |
| 339 | 340 |
e.printStackTrace(); |
| 340 | 341 |
} |
| 341 | 342 |
} |
| 342 |
- private HeaderDto getHeader(SocketChannel channel) {
|
|
| 343 |
+ private HeaderDto getHeader(SocketChannel channel) throws UnsupportedEncodingException {
|
|
| 343 | 344 |
HeaderDto headerDto = HeaderDto.builder().build(); |
| 344 | 345 |
int size = -1; |
| 345 | 346 |
ByteBuffer buffer = ByteBuffer.allocate(Header.HEADER_LENGTH); |
--- src/main/java/com/munjaon/server/server/service/CollectServer.java
+++ src/main/java/com/munjaon/server/server/service/CollectServer.java
... | ... | @@ -191,6 +191,8 @@ |
| 191 | 191 |
saveSystemLog("[CLIENT USER IS DISCONNECT : " + userDto.toString() + "]");
|
| 192 | 192 |
collectUserQueue.removeUser(this.serviceType, userDto.getUserId()); |
| 193 | 193 |
key.attach(null); |
| 194 |
+ /* 모니터링 로그 */ |
|
| 195 |
+ HealthCheckServer.saveMonitorLog("[COLLECT SERVER][SERVICE TYPE : " + this.serviceType + "][ID : " + userDto.getUserId() + "][EXPIRE CONNECT USER]");
|
|
| 194 | 196 |
} |
| 195 | 197 |
// 소켓 채널 닫기 |
| 196 | 198 |
channel.close(); |
+++ src/main/java/com/munjaon/server/server/service/HealthCheckServer.java
... | ... | @@ -0,0 +1,222 @@ |
| 1 | +package com.munjaon.server.server.service; | |
| 2 | + | |
| 3 | +import com.slack.api.Slack; | |
| 4 | +import org.json.simple.JSONObject; | |
| 5 | + | |
| 6 | +import java.io.IOException; | |
| 7 | +import java.net.InetSocketAddress; | |
| 8 | +import java.nio.channels.SocketChannel; | |
| 9 | +import java.util.ArrayList; | |
| 10 | +import java.util.List; | |
| 11 | + | |
| 12 | +public class HealthCheckServer extends Service { | |
| 13 | + private static List<String> monitorLog = new ArrayList<>(); | |
| 14 | + /** Lock Object */ | |
| 15 | + private static final Object msgMonitor = new Object(); | |
| 16 | + | |
| 17 | + /** 설정 모니터링(10초단위로 체크한다.) */ | |
| 18 | + private long CONFIG_CHECK_TIME = 0; | |
| 19 | + private String slackYn; | |
| 20 | + private String slackUrl; | |
| 21 | + private int serverCycle; | |
| 22 | + | |
| 23 | + private long LAST_QUEUE_CHECK_TIME = 0; | |
| 24 | + private long LAST_SERVER_CHECK_TIME = 0; | |
| 25 | + | |
| 26 | + public HealthCheckServer(String serviceName) { | |
| 27 | + super(serviceName); | |
| 28 | + } | |
| 29 | + | |
| 30 | + public static void saveMonitorLog(String log) { | |
| 31 | + if (log == null) { | |
| 32 | + return; | |
| 33 | + } | |
| 34 | + synchronized(msgMonitor){ | |
| 35 | + monitorLog.add(log); | |
| 36 | + } | |
| 37 | + } | |
| 38 | + | |
| 39 | + public static boolean isEmptyMonitorLog() { | |
| 40 | + synchronized(msgMonitor){ | |
| 41 | + return monitorLog.isEmpty(); | |
| 42 | + } | |
| 43 | + } | |
| 44 | + | |
| 45 | + public static String popMonitorLog() { | |
| 46 | + synchronized(msgMonitor){ | |
| 47 | + return monitorLog.remove(0); | |
| 48 | + } | |
| 49 | + } | |
| 50 | + | |
| 51 | + @Override | |
| 52 | + public void checkReady() { | |
| 53 | + this.IS_READY_YN = true; | |
| 54 | + } | |
| 55 | + | |
| 56 | + @Override | |
| 57 | + public void initResources() { | |
| 58 | + | |
| 59 | + } | |
| 60 | + | |
| 61 | + @Override | |
| 62 | + public void releaseResources() { | |
| 63 | + | |
| 64 | + } | |
| 65 | + | |
| 66 | + @Override | |
| 67 | + public void doService() { | |
| 68 | + saveSystemLog("HEALTH_CHECK_SERVER : SERVER SERVICE STARTED ... ..."); | |
| 69 | + while (isRun()) { | |
| 70 | + try { | |
| 71 | + Thread.sleep(5000); | |
| 72 | + loadMonitorConfig(); | |
| 73 | + serverMonitor(); | |
| 74 | + sendMonitorLog(); | |
| 75 | + } catch (Exception e) { | |
| 76 | + saveSystemLog(e.toString()); | |
| 77 | + } | |
| 78 | + } | |
| 79 | + saveSystemLog("HEALTH_CHECK_SERVER : SERVER SERVICE STOPPED ... ..."); | |
| 80 | + } | |
| 81 | + | |
| 82 | + private void loadMonitorConfig() { | |
| 83 | + if (System.currentTimeMillis() - CONFIG_CHECK_TIME < 10000) { | |
| 84 | + return; | |
| 85 | + } | |
| 86 | + slackYn = getProp("SLACK_FLAG"); | |
| 87 | + slackUrl = getProp("SLACK_URL"); | |
| 88 | + serverCycle = Integer.parseInt(getProp("SERVER_CYCLE")) * 60000; | |
| 89 | + CONFIG_CHECK_TIME = System.currentTimeMillis(); | |
| 90 | + } | |
| 91 | + | |
| 92 | + public void sendMonitorLog() { | |
| 93 | + Slack slack = Slack.getInstance(); | |
| 94 | + try { | |
| 95 | + while (true) { | |
| 96 | + if (isEmptyMonitorLog()) { | |
| 97 | + break; | |
| 98 | + } | |
| 99 | + | |
| 100 | + String msg = popMonitorLog(); | |
| 101 | + if (msg == null) { | |
| 102 | + break; | |
| 103 | + } | |
| 104 | + | |
| 105 | + saveSystemLog(msg); | |
| 106 | + if ("Y".equals(slackYn)) { | |
| 107 | + JSONObject payload = new JSONObject(); | |
| 108 | + payload.put("text", msg); | |
| 109 | + slack.send(slackUrl, String.valueOf(payload)); | |
| 110 | + } | |
| 111 | + } | |
| 112 | + Thread.sleep(3000); | |
| 113 | + } catch (IOException | InterruptedException e) { | |
| 114 | + saveSystemLog(e); | |
| 115 | + } finally { | |
| 116 | + if (slack != null) { | |
| 117 | + try { | |
| 118 | + slack.close(); | |
| 119 | + } catch (Exception e) { | |
| 120 | + | |
| 121 | + } | |
| 122 | + } | |
| 123 | + } | |
| 124 | + } | |
| 125 | + | |
| 126 | + public void serverMonitor() { | |
| 127 | + if (System.currentTimeMillis() - LAST_SERVER_CHECK_TIME < serverCycle) { | |
| 128 | + return; | |
| 129 | + } | |
| 130 | + boolean isConnected = false; | |
| 131 | + int port; | |
| 132 | + | |
| 133 | + /* 1. SMS */ | |
| 134 | + port = Integer.parseInt(getProp("SMS_COLLECTOR", "SERVICE_PORT")); | |
| 135 | + isConnected = connectTest(port); | |
| 136 | + if (isConnected) { | |
| 137 | + saveMonitorLog("[SMS SERVER is Connectable]"); | |
| 138 | + } else { | |
| 139 | + saveMonitorLog("[SMS SERVER is Shutdown]"); | |
| 140 | + } | |
| 141 | + /* 2. LMS */ | |
| 142 | + port = Integer.parseInt(getProp("LMS_COLLECTOR", "SERVICE_PORT")); | |
| 143 | + isConnected = connectTest(port); | |
| 144 | + if (isConnected) { | |
| 145 | + saveMonitorLog("[LMS SERVER is Connectable]"); | |
| 146 | + } else { | |
| 147 | + saveMonitorLog("[LMS SERVER is Shutdown]"); | |
| 148 | + } | |
| 149 | + /* 3. MMS */ | |
| 150 | + port = Integer.parseInt(getProp("MMS_COLLECTOR", "SERVICE_PORT")); | |
| 151 | + isConnected = connectTest(port); | |
| 152 | + if (isConnected) { | |
| 153 | + saveMonitorLog("[MMS SERVER is Connectable]"); | |
| 154 | + } else { | |
| 155 | + saveMonitorLog("[MMS SERVER is Shutdown]"); | |
| 156 | + } | |
| 157 | + /* 4. 알림톡 */ | |
| 158 | + port = Integer.parseInt(getProp("KAT_COLLECTOR", "SERVICE_PORT")); | |
| 159 | + isConnected = connectTest(port); | |
| 160 | + if (isConnected) { | |
| 161 | + saveMonitorLog("[KAT SERVER is Connectable]"); | |
| 162 | + } else { | |
| 163 | + saveMonitorLog("[KAT SERVER is Shutdown]"); | |
| 164 | + } | |
| 165 | + /* 5. 친구톡 */ | |
| 166 | + port = Integer.parseInt(getProp("KFT_COLLECTOR", "SERVICE_PORT")); | |
| 167 | + isConnected = connectTest(port); | |
| 168 | + if (isConnected) { | |
| 169 | + saveMonitorLog("[KFT SERVER is Connectable]"); | |
| 170 | + } else { | |
| 171 | + saveMonitorLog("[KFT SERVER is Shutdown]"); | |
| 172 | + } | |
| 173 | + /* 6. 리포트 */ | |
| 174 | + port = Integer.parseInt(getProp("REPORTER", "SERVICE_PORT")); | |
| 175 | + isConnected = connectTest(port); | |
| 176 | + if (isConnected) { | |
| 177 | + saveMonitorLog("[REPORT SERVER is Connectable]"); | |
| 178 | + } else { | |
| 179 | + saveMonitorLog("[REPORT SERVER is Shutdown]"); | |
| 180 | + } | |
| 181 | + | |
| 182 | + LAST_SERVER_CHECK_TIME = System.currentTimeMillis(); | |
| 183 | + } | |
| 184 | + | |
| 185 | + private boolean connectTest(int port) { | |
| 186 | + boolean isConnected = false; | |
| 187 | + SocketChannel socketChannel = null; | |
| 188 | + try { | |
| 189 | + socketChannel = SocketChannel.open(new InetSocketAddress(port)); | |
| 190 | + socketChannel.configureBlocking(false); | |
| 191 | + | |
| 192 | + long connectStartTime = System.currentTimeMillis(); | |
| 193 | + while (true) { | |
| 194 | + if (socketChannel.finishConnect()) { | |
| 195 | + isConnected = true; | |
| 196 | + break; | |
| 197 | + } | |
| 198 | + if (System.currentTimeMillis() - connectStartTime > 3000) { | |
| 199 | + break; | |
| 200 | + } | |
| 201 | + } | |
| 202 | + } catch (IOException e) { | |
| 203 | + saveSystemLog("Connect Fail to [PORT : " + port + "]"); | |
| 204 | + saveSystemLog("ERROR [" + e.getMessage() + "]"); | |
| 205 | + } finally { | |
| 206 | + if (socketChannel != null) { | |
| 207 | + try { | |
| 208 | + socketChannel.close(); | |
| 209 | + } catch (IOException e) { | |
| 210 | + | |
| 211 | + } | |
| 212 | + } | |
| 213 | + } | |
| 214 | + | |
| 215 | + return isConnected; | |
| 216 | + } | |
| 217 | + | |
| 218 | + @Override | |
| 219 | + public JSONObject monitorService() { | |
| 220 | + return null; | |
| 221 | + } | |
| 222 | +} |
--- src/main/java/com/munjaon/server/server/service/QueueServerService.java
+++ src/main/java/com/munjaon/server/server/service/QueueServerService.java
... | ... | @@ -25,6 +25,9 @@ |
| 25 | 25 |
private long QUEUE_INIT_CHECK_TIME = 0; |
| 26 | 26 |
/** Commit 누적 카운트 */ |
| 27 | 27 |
private long SUM_COMMIT_COUNT = 0; |
| 28 |
+ /** 큐모니터링 체크 사이클 */ |
|
| 29 |
+ private int QUEUE_MONITOR_CYCLE; |
|
| 30 |
+ private long QUEUE_MONITOR_CHECK_TIME = 0; |
|
| 28 | 31 |
SerialQueuePool queueInstance = SerialQueuePool.getInstance(); |
| 29 | 32 |
/* 쓰기큐 */ |
| 30 | 33 |
private WriteQueue writeQueue; |
... | ... | @@ -49,6 +52,8 @@ |
| 49 | 52 |
QUEUE_MODE = QUEUE_MODE.toUpperCase(); |
| 50 | 53 |
// 읽은 시간 업데이트 |
| 51 | 54 |
QUEUE_MODE_CHECK_TIME = System.currentTimeMillis(); |
| 55 |
+ // 큐모니터링 체크 사이클 |
|
| 56 |
+ QUEUE_MONITOR_CYCLE = Integer.parseInt(getProp("HEALTH", "QUEUE_CYCLE")) * 60000;
|
|
| 52 | 57 |
} |
| 53 | 58 |
} |
| 54 | 59 |
|
... | ... | @@ -254,6 +259,7 @@ |
| 254 | 259 |
checkMode(); |
| 255 | 260 |
checkQueue(); |
| 256 | 261 |
messageService(); |
| 262 |
+ monitorService(); |
|
| 257 | 263 |
} catch (Exception e) {
|
| 258 | 264 |
throw new RuntimeException(e); |
| 259 | 265 |
} |
... | ... | @@ -262,6 +268,11 @@ |
| 262 | 268 |
|
| 263 | 269 |
@Override |
| 264 | 270 |
public JSONObject monitorService() {
|
| 271 |
+ if (System.currentTimeMillis() - QUEUE_MONITOR_CHECK_TIME < QUEUE_MONITOR_CYCLE) {
|
|
| 272 |
+ return null; |
|
| 273 |
+ } |
|
| 274 |
+ HealthCheckServer.saveMonitorLog("[QUEUE MONITOR][" + getName() + "] [WRITE POSITION : " + writeQueue.getPushCounter() + "][READ POSITION : " + readQueue.getPopCounter() + "]");
|
|
| 275 |
+ QUEUE_MONITOR_CHECK_TIME = System.currentTimeMillis(); |
|
| 265 | 276 |
return null; |
| 266 | 277 |
} |
| 267 | 278 |
} |
--- src/main/java/com/munjaon/server/server/service/ReportServer.java
+++ src/main/java/com/munjaon/server/server/service/ReportServer.java
... | ... | @@ -3,6 +3,9 @@ |
| 3 | 3 |
import com.munjaon.server.queue.pool.ReportQueue; |
| 4 | 4 |
import com.munjaon.server.server.dto.ReportUserDto; |
| 5 | 5 |
import com.munjaon.server.server.queue.ReportUserQueue; |
| 6 |
+import com.munjaon.server.server.task.ReportBindTask; |
|
| 7 |
+import com.munjaon.server.server.task.ReportLinkCheckTask; |
|
| 8 |
+import com.munjaon.server.server.task.ReportResultTask; |
|
| 6 | 9 |
import com.munjaon.server.server.task.ReportServerTask; |
| 7 | 10 |
import org.json.simple.JSONObject; |
| 8 | 11 |
|
... | ... | @@ -81,7 +84,7 @@ |
| 81 | 84 |
saveSystemLog("REPORT_SERVER : SERVER SERVICE STARTED ... ...");
|
| 82 | 85 |
while (isRun()) {
|
| 83 | 86 |
try {
|
| 84 |
- execInterest(); |
|
| 87 |
+ bindInterest(); |
|
| 85 | 88 |
checkInterest(); |
| 86 | 89 |
} catch (Exception e) {
|
| 87 | 90 |
saveSystemLog(e.toString()); |
... | ... | @@ -99,15 +102,60 @@ |
| 99 | 102 |
if (reportUserDto == null) {
|
| 100 | 103 |
continue; |
| 101 | 104 |
} |
| 105 |
+ |
|
| 106 |
+ if (reportUserDto.isLogin()) {
|
|
| 107 |
+ if (reportUserDto.isAlive() == 2) {
|
|
| 108 |
+ if (reportUserDto.isRunningMode()) {
|
|
| 109 |
+ continue; |
|
| 110 |
+ } |
|
| 111 |
+ /* 로그인이 된경우 Link Check를 위해 실행 */ |
|
| 112 |
+ reportUserDto.setRunningMode(true); |
|
| 113 |
+ /* 사용자별 Link Check Thread 실행 */ |
|
| 114 |
+ new ReportLinkCheckTask(key, getName(), logger).run(); |
|
| 115 |
+ } else {
|
|
| 116 |
+ ReportQueue reportQueue = reportUserDto.getReportQueue(); |
|
| 117 |
+ if (reportQueue != null && reportQueue.isRemainReport()) {
|
|
| 118 |
+ if (reportUserDto.isRunningMode()) {
|
|
| 119 |
+ continue; |
|
| 120 |
+ } |
|
| 121 |
+ reportUserDto.setRunningMode(true); |
|
| 122 |
+ /* 사용자별 Report Thread 실행 */ |
|
| 123 |
+ new ReportResultTask(key, getName(), logger).start(); |
|
| 124 |
+ } |
|
| 125 |
+ } |
|
| 126 |
+ } else {
|
|
| 127 |
+ if (reportUserDto.isRunningMode()) {
|
|
| 128 |
+ continue; |
|
| 129 |
+ } |
|
| 130 |
+ if (reportUserDto.isAlive() == 1) { // 로그인이 완료되지 않은 경우
|
|
| 131 |
+ expireConnectUser(key); |
|
| 132 |
+ } |
|
| 133 |
+ } |
|
| 134 |
+ } |
|
| 135 |
+ } |
|
| 136 |
+ } |
|
| 137 |
+ |
|
| 138 |
+ private void checkInterest_bak() throws IOException, InterruptedException {
|
|
| 139 |
+ Iterator<SelectionKey> keys = selector.keys().iterator(); |
|
| 140 |
+ while (keys.hasNext()) {
|
|
| 141 |
+ SelectionKey key = keys.next(); |
|
| 142 |
+ if (key.isValid()) {
|
|
| 143 |
+ ReportUserDto reportUserDto = (ReportUserDto) key.attachment(); |
|
| 144 |
+ if (reportUserDto == null) {
|
|
| 145 |
+ continue; |
|
| 146 |
+ } |
|
| 102 | 147 |
if (reportUserDto.isAlive() == 1) { // 로그인이 완료되지 않은 경우
|
| 103 | 148 |
expireConnectUser(key); |
| 104 | 149 |
} else if (reportUserDto.isAlive() == 2) {
|
| 105 | 150 |
if (reportUserDto.isRunningMode()) {
|
| 106 | 151 |
continue; |
| 107 | 152 |
} |
| 108 |
- reportUserDto.setRunningMode(true); |
|
| 109 |
- /* 사용자별 Report Thread 실행 */ |
|
| 110 |
- new ReportServerTask(selector, key, getName(), logger).run(); |
|
| 153 |
+ /* 로그인이 된경우 Link Check를 위해 실행 */ |
|
| 154 |
+ if (reportUserDto.isLogin()) {
|
|
| 155 |
+ reportUserDto.setRunningMode(true); |
|
| 156 |
+ /* 사용자별 Report Thread 실행 */ |
|
| 157 |
+ new ReportServerTask(selector, key, getName(), logger).run(); |
|
| 158 |
+ } |
|
| 111 | 159 |
} else {
|
| 112 | 160 |
ReportQueue reportQueue = reportUserDto.getReportQueue(); |
| 113 | 161 |
if (reportUserDto.isLogin() && reportQueue != null && reportQueue.isRemainReport()) {
|
... | ... | @@ -125,12 +173,44 @@ |
| 125 | 173 |
} |
| 126 | 174 |
} |
| 127 | 175 |
|
| 176 |
+ private void bindInterest() throws IOException {
|
|
| 177 |
+ if (selector.select(300) == 0) {
|
|
| 178 |
+ return ; |
|
| 179 |
+ } |
|
| 180 |
+ Iterator<SelectionKey> keys = selector.selectedKeys().iterator(); |
|
| 181 |
+ while (keys.hasNext()) {
|
|
| 182 |
+ SelectionKey key = keys.next(); |
|
| 183 |
+ /* 키 셋에서 제거. */ |
|
| 184 |
+ keys.remove(); |
|
| 185 |
+ |
|
| 186 |
+ if (key.isValid()) {
|
|
| 187 |
+ if (key.isAcceptable()) { // 접속일 경우..
|
|
| 188 |
+ saveSystemLog("CONNECTION IS ACCEPTABLE ... ...");
|
|
| 189 |
+ accept(selector, key); |
|
| 190 |
+ } else if (key.isReadable()) { // 수신일 경우..
|
|
| 191 |
+ ReportUserDto reportUserDto = (ReportUserDto) key.attachment(); |
|
| 192 |
+ if (reportUserDto == null) {
|
|
| 193 |
+ continue; |
|
| 194 |
+ } |
|
| 195 |
+ if (reportUserDto.isRunningMode()) {
|
|
| 196 |
+ continue; |
|
| 197 |
+ } |
|
| 198 |
+ if (reportUserDto.isLogin()) {
|
|
| 199 |
+ continue; |
|
| 200 |
+ } |
|
| 201 |
+ reportUserDto.setRunningMode(true); |
|
| 202 |
+ /* 사용자별 Report Thread 실행 */ |
|
| 203 |
+ new ReportBindTask(key, getName(), logger).start(); |
|
| 204 |
+ } |
|
| 205 |
+ } |
|
| 206 |
+ } |
|
| 207 |
+ } |
|
| 208 |
+ |
|
| 128 | 209 |
private void execInterest() throws IOException {
|
| 129 | 210 |
if (selector.select(1000) == 0) {
|
| 130 | 211 |
return ; |
| 131 | 212 |
} |
| 132 | 213 |
Iterator<SelectionKey> keys = selector.selectedKeys().iterator(); |
| 133 |
- List<Future<ReportUserDto>> list = new ArrayList<>(); |
|
| 134 | 214 |
while (keys.hasNext()) {
|
| 135 | 215 |
SelectionKey key = keys.next(); |
| 136 | 216 |
/* 키 셋에서 제거. */ |
... | ... | @@ -186,6 +266,8 @@ |
| 186 | 266 |
reportUserQueue.removeUser(userDto.getUserId()); |
| 187 | 267 |
// connectUserMap.remove(userDto.getUserId()); |
| 188 | 268 |
key.attach(null); |
| 269 |
+ /* 모니터링 로그 */ |
|
| 270 |
+ HealthCheckServer.saveMonitorLog("[REPORT SERVER][ID : " + userDto.getUserId() + "][EXPIRE CONNECT USER]");
|
|
| 189 | 271 |
} |
| 190 | 272 |
// 소켓 채널 닫기 |
| 191 | 273 |
channel.close(); |
--- src/main/java/com/munjaon/server/server/task/CollectReadTask.java
+++ src/main/java/com/munjaon/server/server/task/CollectReadTask.java
... | ... | @@ -12,6 +12,7 @@ |
| 12 | 12 |
|
| 13 | 13 |
import java.io.File; |
| 14 | 14 |
import java.io.IOException; |
| 15 |
+import java.io.UnsupportedEncodingException; |
|
| 15 | 16 |
import java.nio.ByteBuffer; |
| 16 | 17 |
import java.nio.channels.SelectionKey; |
| 17 | 18 |
import java.nio.channels.Selector; |
... | ... | @@ -136,7 +137,7 @@ |
| 136 | 137 |
return false; |
| 137 | 138 |
} |
| 138 | 139 |
|
| 139 |
- public BasicMessageDto recvCommonMessage(ByteBuffer deliverBuffer) {
|
|
| 140 |
+ public BasicMessageDto recvCommonMessage(ByteBuffer deliverBuffer) throws UnsupportedEncodingException {
|
|
| 140 | 141 |
if (deliverBuffer == null) {
|
| 141 | 142 |
return null; |
| 142 | 143 |
} |
--- src/main/java/com/munjaon/server/server/task/CollectServerTask.java
+++ src/main/java/com/munjaon/server/server/task/CollectServerTask.java
... | ... | @@ -9,11 +9,13 @@ |
| 9 | 9 |
import com.munjaon.server.server.dto.ConnectUserDto; |
| 10 | 10 |
import com.munjaon.server.server.packet.common.*; |
| 11 | 11 |
import com.munjaon.server.server.queue.CollectUserQueue; |
| 12 |
+import com.munjaon.server.server.service.HealthCheckServer; |
|
| 12 | 13 |
import com.munjaon.server.server.service.PropertyLoader; |
| 13 | 14 |
import com.munjaon.server.util.*; |
| 14 | 15 |
|
| 15 | 16 |
import java.io.File; |
| 16 | 17 |
import java.io.IOException; |
| 18 |
+import java.io.UnsupportedEncodingException; |
|
| 17 | 19 |
import java.nio.ByteBuffer; |
| 18 | 20 |
import java.nio.channels.SelectionKey; |
| 19 | 21 |
import java.nio.channels.Selector; |
... | ... | @@ -131,8 +133,8 @@ |
| 131 | 133 |
/* 2. Packet Timeout Check */ |
| 132 | 134 |
if (checkTimeOut()) {
|
| 133 | 135 |
saveSystemLog(printTaskLog() + "[checkTimeOut : Expired ... ... ... ... ... ... ...]"); |
| 134 |
- saveSystemLog(printTaskLog() + "[### End ### ### ### ### ### ### ###]"); |
|
| 135 | 136 |
expireConnectUser(); |
| 137 |
+ saveSystemLog(printTaskLog() + "[### End ### ### ### ### ### ### ###]"); |
|
| 136 | 138 |
break; |
| 137 | 139 |
} |
| 138 | 140 |
/* 3. HeadBuffer 읽기 */ |
... | ... | @@ -232,7 +234,7 @@ |
| 232 | 234 |
return false; |
| 233 | 235 |
} |
| 234 | 236 |
|
| 235 |
- public BasicMessageDto recvCommonMessage(ByteBuffer deliverBuffer) {
|
|
| 237 |
+ public BasicMessageDto recvCommonMessage(ByteBuffer deliverBuffer) throws UnsupportedEncodingException {
|
|
| 236 | 238 |
if (deliverBuffer == null) {
|
| 237 | 239 |
return null; |
| 238 | 240 |
} |
... | ... | @@ -557,8 +559,6 @@ |
| 557 | 559 |
connectUserDto.setUserId(id); |
| 558 | 560 |
connectUserDto.setLogin(true); |
| 559 | 561 |
connectUserDto.setMemberDto(memberDto); |
| 560 |
- /* 사용자 Pool에 저장 */ |
|
| 561 |
- collectUserQueue.putUser(this.serviceType, connectUserDto); |
|
| 562 | 562 |
/* 세션통신 시간 업데이트 */ |
| 563 | 563 |
connectUserDto.updateLastTrafficTime(); |
| 564 | 564 |
} |
... | ... | @@ -570,11 +570,17 @@ |
| 570 | 570 |
try {
|
| 571 | 571 |
saveSystemLog(printTaskLog() + "[BIND RESULT : " + resultCode + "]"); |
| 572 | 572 |
channel.write(Bind.makeBindAckBuffer(resultCode)); |
| 573 |
- if ("00".equals(resultCode) == false) {
|
|
| 573 |
+ if ("00".equals(resultCode)) {
|
|
| 574 |
+ /* BIND 성공인 경우 사용자 Pool에 저장 */ |
|
| 575 |
+ collectUserQueue.putUser(this.serviceType, connectUserDto); |
|
| 576 |
+ } else {
|
|
| 574 | 577 |
expireConnectUser(); |
| 575 | 578 |
} |
| 579 |
+ /* 모니터링 로그 */ |
|
| 580 |
+ HealthCheckServer.saveMonitorLog("[COLLECT SERVER][SERVICE TYPE : " + this.serviceType + "][ID : " + connectUserDto.getUserId() + "][BIND RESULT : " + resultCode + "]");
|
|
| 576 | 581 |
} catch (IOException e) {
|
| 577 |
- e.printStackTrace(); |
|
| 582 |
+ saveSystemLog(e); |
|
| 583 |
+ throw new RuntimeException(e); |
|
| 578 | 584 |
} |
| 579 | 585 |
} |
| 580 | 586 |
|
... | ... | @@ -641,6 +647,8 @@ |
| 641 | 647 |
if (connectUserDto != null) {
|
| 642 | 648 |
if (connectUserDto.getUserId() != null) {
|
| 643 | 649 |
collectUserQueue.removeUser(connectUserDto.getServiceType(), connectUserDto.getUserId()); |
| 650 |
+ /* 모니터링 로그 */ |
|
| 651 |
+ HealthCheckServer.saveMonitorLog("[COLLECT SERVER][SERVICE TYPE : " + this.serviceType + "][ID : " + connectUserDto.getUserId() + "][EXPIRE CONNECT USER]");
|
|
| 644 | 652 |
} |
| 645 | 653 |
key.attach(null); |
| 646 | 654 |
} |
+++ src/main/java/com/munjaon/server/server/task/ReportBindTask.java
... | ... | @@ -0,0 +1,143 @@ |
| 1 | +package com.munjaon.server.server.task; | |
| 2 | + | |
| 3 | +import com.munjaon.server.cache.dto.MemberDto; | |
| 4 | +import com.munjaon.server.cache.enums.CacheService; | |
| 5 | +import com.munjaon.server.cache.service.MemberService; | |
| 6 | +import com.munjaon.server.queue.pool.ReportQueue; | |
| 7 | +import com.munjaon.server.server.config.ServerConfig; | |
| 8 | +import com.munjaon.server.server.packet.common.Bind; | |
| 9 | +import com.munjaon.server.server.packet.common.Header; | |
| 10 | +import com.munjaon.server.server.packet.common.Packet; | |
| 11 | +import com.munjaon.server.server.service.HealthCheckServer; | |
| 12 | +import com.munjaon.server.util.LogUtil; | |
| 13 | + | |
| 14 | +import java.io.IOException; | |
| 15 | +import java.nio.ByteBuffer; | |
| 16 | +import java.nio.channels.SelectionKey; | |
| 17 | + | |
| 18 | +public class ReportBindTask extends ReportTask { | |
| 19 | + public ReportBindTask(SelectionKey key, String serviceName, LogUtil logger) { | |
| 20 | + super(key, serviceName, "BIND_TASK", logger); | |
| 21 | + } | |
| 22 | + | |
| 23 | + @Override | |
| 24 | + public void doService() throws Exception { | |
| 25 | + SEND_CYCLE_CHECK_TIME = System.currentTimeMillis(); | |
| 26 | + while(true) { | |
| 27 | + /* 1. Head 읽기 */ | |
| 28 | + int size = readHeader(); | |
| 29 | + /* 2. Body 읽기 */ | |
| 30 | + if (size > 0) { | |
| 31 | + String command = Header.getCommand(this.headBuffer); | |
| 32 | + if (Integer.parseInt(command) == 1) { | |
| 33 | + recvBind(headBuffer); | |
| 34 | + } else { | |
| 35 | + expireConnectUser(); | |
| 36 | + } | |
| 37 | + /* 패킷 수신한 경우 무조건 루프를 빠져나간다 */ | |
| 38 | + break; | |
| 39 | + } | |
| 40 | + /* 3초 이내에 로그인 실패시 종료 */ | |
| 41 | + if (System.currentTimeMillis() - SEND_CYCLE_CHECK_TIME > ServerConfig.LIMIT_BIND_TIMEOUT) { | |
| 42 | + expireConnectUser(); | |
| 43 | + break; | |
| 44 | + } | |
| 45 | + } | |
| 46 | + /* 세션 만료 여부 */ | |
| 47 | + this.isExpiredYn = true; | |
| 48 | + } | |
| 49 | + | |
| 50 | + private void recvBind(ByteBuffer headBuffer) { | |
| 51 | + String resultCode = "00"; | |
| 52 | + try { | |
| 53 | + ByteBuffer bindBuffer = ByteBuffer.allocate(Header.HEADER_LENGTH + Bind.BIND_BODY_LENGTH); | |
| 54 | + ByteBuffer bodyBuffer = ByteBuffer.allocate(Bind.BIND_BODY_LENGTH); | |
| 55 | + channel.read(bodyBuffer); | |
| 56 | + Packet.mergeBuffers(bindBuffer, headBuffer, bodyBuffer); | |
| 57 | + | |
| 58 | + String id = Bind.getBindId(bindBuffer); | |
| 59 | + String pwd = Bind.getBindPwd(bindBuffer); | |
| 60 | + | |
| 61 | + MemberService svc = (MemberService) CacheService.LOGIN_SERVICE.getService(); | |
| 62 | + MemberDto memberDto = null; | |
| 63 | + if (svc != null) { | |
| 64 | + memberDto = svc.get(id); | |
| 65 | + } | |
| 66 | + saveSystemLog("[" + this.taskName + "][BIND REQUEST] [ID : " + id + ", PWD : " + pwd + "]"); | |
| 67 | + /* Bind Check */ | |
| 68 | + resultCode = checkBind(memberDto, id, pwd); | |
| 69 | + | |
| 70 | + /* 접속 IP 체크 */ | |
| 71 | + if ("00".equals(resultCode)) { | |
| 72 | + boolean isPermit = false; | |
| 73 | + if (memberDto.getIpLimitYn() == null || "Y".equals(memberDto.getIpLimitYn())) { | |
| 74 | + saveSystemLog("[" + this.taskName + "][REMOTE IP : " + reportUserDto.getRemoteIP() + "]"); | |
| 75 | + saveSystemLog("[" + this.taskName + "][ALLOW IP BASIC : " + memberDto.getAllowIpBasic() + "]"); | |
| 76 | + saveSystemLog("[" + this.taskName + "][ALLOW IP EXTEND : " + memberDto.getAllowIpExtend() + "]"); | |
| 77 | + if (memberDto.getAllowIpBasic() != null && reportUserDto.getRemoteIP().equals(memberDto.getAllowIpBasic())) { | |
| 78 | + isPermit = true; | |
| 79 | + } | |
| 80 | + if (memberDto.getAllowIpExtend() != null && reportUserDto.getRemoteIP().equals(memberDto.getAllowIpExtend())) { | |
| 81 | + isPermit = true; | |
| 82 | + } | |
| 83 | + } else { | |
| 84 | + isPermit = true; | |
| 85 | + } | |
| 86 | + if (isPermit) { | |
| 87 | + resultCode = "00"; | |
| 88 | + } else { | |
| 89 | + resultCode = "40"; | |
| 90 | + } | |
| 91 | + } | |
| 92 | + | |
| 93 | + /* BIND 성공인 경우 사용자 정보 저장 */ | |
| 94 | + if ("00".equals(resultCode)) { | |
| 95 | + reportUserDto.setUserId(id); | |
| 96 | + reportUserDto.setLogin(true); | |
| 97 | + reportUserDto.setMemberDto(memberDto); | |
| 98 | + /* 리포트 큐 생성 */ | |
| 99 | + ReportQueue reportQueue = new ReportQueue(reportUserDto.getQueuePath(), reportUserDto.getUserId()); | |
| 100 | + reportUserDto.setReportQueue(reportQueue); | |
| 101 | + /* 세션통신 시간 업데이트 */ | |
| 102 | + reportUserDto.updateLastTrafficTime(); | |
| 103 | + } | |
| 104 | + } catch (Exception e) { | |
| 105 | + resultCode = "10"; | |
| 106 | + saveSystemLog(e); | |
| 107 | + } | |
| 108 | + | |
| 109 | + try { | |
| 110 | + saveSystemLog("[" + this.taskName + "][BIND RESULT : " + resultCode + "]"); | |
| 111 | + channel.write(Bind.makeBindAckBuffer(resultCode)); | |
| 112 | + if ("00".equals(resultCode)) { | |
| 113 | + /* BIND 성공인 경우 사용자 Pool에 저장 */ | |
| 114 | + reportUserQueue.putUser(reportUserDto); | |
| 115 | + } else { | |
| 116 | + expireConnectUser(); | |
| 117 | + } | |
| 118 | + /* 모니터링 로그 */ | |
| 119 | + HealthCheckServer.saveMonitorLog("[REPORT SERVER][ID : " + reportUserDto.getUserId() + "][BIND RESULT : " + resultCode + "]"); | |
| 120 | + } catch (IOException e) { | |
| 121 | + saveSystemLog(e); | |
| 122 | + throw new RuntimeException(e); | |
| 123 | + } | |
| 124 | + } | |
| 125 | + | |
| 126 | + private String checkBind(MemberDto memberDto, String id, String pwd) { | |
| 127 | + if (id == null || pwd == null) { | |
| 128 | + return "50"; | |
| 129 | + } | |
| 130 | + if (reportUserQueue.isExist(id)) { | |
| 131 | + return "60"; | |
| 132 | + } | |
| 133 | + if (memberDto == null || !pwd.equals(memberDto.getAccessKey())) { | |
| 134 | + return "20"; | |
| 135 | + } | |
| 136 | + /* 회원 사용 상태 */ | |
| 137 | + if (memberDto.getMberSttus() == null || "N".equals(memberDto.getMberSttus())) { | |
| 138 | + return "30"; | |
| 139 | + } | |
| 140 | + | |
| 141 | + return "00"; | |
| 142 | + } | |
| 143 | +} |
+++ src/main/java/com/munjaon/server/server/task/ReportLinkCheckTask.java
... | ... | @@ -0,0 +1,80 @@ |
| 1 | +package com.munjaon.server.server.task; | |
| 2 | + | |
| 3 | +import com.munjaon.server.server.config.ServerConfig; | |
| 4 | +import com.munjaon.server.server.packet.common.Header; | |
| 5 | +import com.munjaon.server.server.packet.common.LinkCheck; | |
| 6 | +import com.munjaon.server.util.LogUtil; | |
| 7 | + | |
| 8 | +import java.io.IOException; | |
| 9 | +import java.nio.ByteBuffer; | |
| 10 | +import java.nio.channels.SelectionKey; | |
| 11 | + | |
| 12 | +public class ReportLinkCheckTask extends ReportTask { | |
| 13 | + /* Packet을 전송했는지 여부 */ | |
| 14 | + private boolean isPacketSendYn; | |
| 15 | + | |
| 16 | + public ReportLinkCheckTask(SelectionKey key, String serviceName, LogUtil logger) { | |
| 17 | + super(key, serviceName, "LINK_CHECK_TASK", logger); | |
| 18 | + } | |
| 19 | + | |
| 20 | + @Override | |
| 21 | + public void doService() throws Exception { | |
| 22 | + sendInterest(); | |
| 23 | + recvInterest(); | |
| 24 | + /* 세션 만료 여부 */ | |
| 25 | + this.isExpiredYn = true; | |
| 26 | + } | |
| 27 | + | |
| 28 | + private void sendInterest() throws Exception { | |
| 29 | + if (isPacketSendYn) { | |
| 30 | + return; | |
| 31 | + } | |
| 32 | + | |
| 33 | + if (reportUserDto.isAlive() == 2) { | |
| 34 | + channel.write(LinkCheck.makeLinkCheckBuffer()); | |
| 35 | + saveSystemLog("[" + this.taskName + "][ID : " + this.reportUserDto.getUserId() + "][SEND LINK CHECK ... ... ... ... ... ... ...]"); | |
| 36 | + /* 패킷 전송 시간 체크위한 설정(3초간 유지) */ | |
| 37 | + SEND_CYCLE_CHECK_TIME = System.currentTimeMillis(); | |
| 38 | + /* Packet 전송했는지 여부 */ | |
| 39 | + isPacketSendYn = true; | |
| 40 | + } | |
| 41 | + } | |
| 42 | + | |
| 43 | + private void recvInterest() throws IOException, InterruptedException { | |
| 44 | + while (isPacketSendYn) { | |
| 45 | + /* 1. Head 읽기 */ | |
| 46 | + ByteBuffer headBuffer = ByteBuffer.allocate(Header.HEADER_LENGTH); | |
| 47 | + int size = channel.read(headBuffer); | |
| 48 | + if (size > 0) { | |
| 49 | + String command = Header.getCommand(headBuffer); | |
| 50 | + switch (Integer.parseInt(command)) { | |
| 51 | + case 8 : recvLinkCheck(); break; | |
| 52 | + default: saveSystemLog("[" + this.taskName + "][ID : " + this.reportUserDto.getUserId() + "][INVALID REQUEST][command : " + command + "]"); | |
| 53 | + expireConnectUser(); break; | |
| 54 | + } | |
| 55 | + } else if (size == 0) { | |
| 56 | + Thread.sleep(1); | |
| 57 | + if (System.currentTimeMillis() - SEND_CYCLE_CHECK_TIME >= ServerConfig.REPORT_EXEC_CYCLE_TIME) { | |
| 58 | + saveSystemLog("[" + this.taskName + "][ID : " + this.reportUserDto.getUserId() + "][SEND_CYCLE_CHECK_TIME IS OVER : 3000ms]"); | |
| 59 | + expireConnectUser(); | |
| 60 | + this.isExpiredYn = true; | |
| 61 | + break; | |
| 62 | + } | |
| 63 | + } else { | |
| 64 | + saveSystemLog("[" + this.taskName + "][ID : " + this.reportUserDto.getUserId() + "][recvInterest : size is zero]"); | |
| 65 | + expireConnectUser(); | |
| 66 | + throw new IOException("[ID : " + this.reportUserDto.getUserId() + "][recvInterest : size is zero]"); | |
| 67 | + } | |
| 68 | + } | |
| 69 | + } | |
| 70 | + | |
| 71 | + private void recvLinkCheck() throws IOException { | |
| 72 | + ByteBuffer bodyBuffer = ByteBuffer.allocate(LinkCheck.LINK_CHECK_ACK_BODY_LENGTH); | |
| 73 | + int size = channel.read(bodyBuffer); | |
| 74 | + if (size > 0) { | |
| 75 | + saveSystemLog("[" + this.taskName + "][ID : " + this.reportUserDto.getUserId() + "][RECEIVE LINK CHECK ACK ... ... ... ... ... ... ...]"); | |
| 76 | + reportUserDto.updateLastTrafficTime(); | |
| 77 | + this.isPacketSendYn = false; | |
| 78 | + } | |
| 79 | + } | |
| 80 | +} |
+++ src/main/java/com/munjaon/server/server/task/ReportResultTask.java
... | ... | @@ -0,0 +1,104 @@ |
| 1 | +package com.munjaon.server.server.task; | |
| 2 | + | |
| 3 | +import com.munjaon.server.queue.pool.ReportQueue; | |
| 4 | +import com.munjaon.server.server.config.ServerConfig; | |
| 5 | +import com.munjaon.server.server.dto.ReportDto; | |
| 6 | +import com.munjaon.server.server.packet.common.Header; | |
| 7 | +import com.munjaon.server.server.packet.common.Packet; | |
| 8 | +import com.munjaon.server.server.packet.common.Report; | |
| 9 | +import com.munjaon.server.util.LogUtil; | |
| 10 | + | |
| 11 | +import java.io.IOException; | |
| 12 | +import java.nio.ByteBuffer; | |
| 13 | +import java.nio.channels.SelectionKey; | |
| 14 | + | |
| 15 | +public class ReportResultTask extends ReportTask { | |
| 16 | + /* Packet을 전송했는지 여부 */ | |
| 17 | + private boolean isPacketSendYn; | |
| 18 | + private final ReportQueue reportQueue; | |
| 19 | + private ReportDto reportDto; // 전송 리포트 | |
| 20 | + | |
| 21 | + public ReportResultTask(SelectionKey key, String serviceName, LogUtil logger) { | |
| 22 | + super(key, serviceName, "RESULT_TASK", logger); | |
| 23 | + | |
| 24 | + this.reportQueue = reportUserDto.getReportQueue(); | |
| 25 | + } | |
| 26 | + | |
| 27 | + @Override | |
| 28 | + public void doService() throws Exception { | |
| 29 | + sendInterest(); | |
| 30 | + recvInterest(); | |
| 31 | + /* 세션 만료 여부 */ | |
| 32 | + if (System.currentTimeMillis() - this.reportUserDto.getLastTrafficTime() >= ServerConfig.REPORT_EXEC_CYCLE_TIME) { | |
| 33 | + this.isExpiredYn = true; | |
| 34 | + } | |
| 35 | + } | |
| 36 | + | |
| 37 | + private void recvInterest() throws Exception { | |
| 38 | + while (isPacketSendYn) { | |
| 39 | + /* 1. Head 읽기 */ | |
| 40 | + ByteBuffer headBuffer = ByteBuffer.allocate(Header.HEADER_LENGTH); | |
| 41 | + int size = channel.read(headBuffer); | |
| 42 | + if (size > 0) { | |
| 43 | + String command = Header.getCommand(headBuffer); | |
| 44 | + switch (Integer.parseInt(command)) { | |
| 45 | + case 6 : recvReport(); break; | |
| 46 | + default: saveSystemLog("[" + this.taskName + "][ID : " + this.reportUserDto.getUserId() + "][INVALID REQUEST][command : " + command + "]"); | |
| 47 | + expireConnectUser(); break; | |
| 48 | + } | |
| 49 | + } else if (size == 0) { | |
| 50 | + Thread.sleep(1); | |
| 51 | + if (System.currentTimeMillis() - SEND_CYCLE_CHECK_TIME >= ServerConfig.REPORT_EXEC_CYCLE_TIME) { | |
| 52 | + saveSystemLog("[" + this.taskName + "][ID : " + this.reportUserDto.getUserId() + "][SEND_CYCLE_CHECK_TIME IS OVER : 3000ms]"); | |
| 53 | + expireConnectUser(); | |
| 54 | + this.isExpiredYn = true; | |
| 55 | + break; | |
| 56 | + } | |
| 57 | + } else { | |
| 58 | + saveSystemLog("[" + this.taskName + "][ID : " + this.reportUserDto.getUserId() + "][recvInterest : size is zero]"); | |
| 59 | + expireConnectUser(); | |
| 60 | + throw new IOException("[ID : " + this.reportUserDto.getUserId() + "][recvInterest : size is zero]"); | |
| 61 | + } | |
| 62 | + } | |
| 63 | + } | |
| 64 | + | |
| 65 | + private void recvReport() throws Exception { | |
| 66 | + ByteBuffer bodyBuffer = ByteBuffer.allocate(Report.REPORT_ACK_BODY_LENGTH); | |
| 67 | + int size = channel.read(bodyBuffer); | |
| 68 | + if (size != Report.REPORT_ACK_BODY_LENGTH) { | |
| 69 | + return; | |
| 70 | + } | |
| 71 | + | |
| 72 | + saveSystemLog("[" + this.taskName + "][ID : " + this.reportUserDto.getUserId() + "][RECEIVE REPORT ACK ... ... ... ... ... ... ...]"); | |
| 73 | + ReportQueue reportQueue = reportUserDto.getReportQueue(); | |
| 74 | + reportUserDto.updateLastTrafficTime(); | |
| 75 | + this.isPacketSendYn = false; | |
| 76 | + if (reportQueue != null && this.reportDto != null) { | |
| 77 | + saveSystemLog("[" + this.taskName + "][ID : " + this.reportUserDto.getUserId() + "][RECEIVE REPORT : " + this.reportDto.toString() + "]"); | |
| 78 | + reportQueue.addReadCounter(); | |
| 79 | + } | |
| 80 | + } | |
| 81 | + | |
| 82 | + private void sendInterest() throws Exception { | |
| 83 | + if (isPacketSendYn) { | |
| 84 | + return; | |
| 85 | + } | |
| 86 | + | |
| 87 | + if (this.reportQueue != null && this.reportQueue.isRemainReport()) { | |
| 88 | + this.reportDto = this.reportQueue.popReportFromQueue(); | |
| 89 | + if (reportDto == null) { | |
| 90 | + return; | |
| 91 | + } | |
| 92 | + saveSystemLog("[" + this.taskName + "][ID : " + this.reportUserDto.getUserId() + "][REPORT SEND : " + reportDto.toString() + "]"); | |
| 93 | + ByteBuffer reportBuffer = ByteBuffer.allocate(Header.HEADER_LENGTH + Report.REPORT_BODY_LENGTH); | |
| 94 | + Packet.setDefaultByte(reportBuffer); | |
| 95 | + Header.putHeader(reportBuffer, Header.COMMAND_REPORT, Report.REPORT_BODY_LENGTH); | |
| 96 | + Report.putReport(reportBuffer, reportDto); | |
| 97 | + channel.write(reportBuffer); | |
| 98 | + /* 패킷 전송 시간 체크위한 설정(3초간 유지) */ | |
| 99 | + SEND_CYCLE_CHECK_TIME = System.currentTimeMillis(); | |
| 100 | + /* Packet 전송했는지 여부 */ | |
| 101 | + isPacketSendYn = true; | |
| 102 | + } | |
| 103 | + } | |
| 104 | +} |
--- src/main/java/com/munjaon/server/server/task/ReportServerTask.java
+++ src/main/java/com/munjaon/server/server/task/ReportServerTask.java
... | ... | @@ -9,10 +9,12 @@ |
| 9 | 9 |
import com.munjaon.server.server.dto.ReportUserDto; |
| 10 | 10 |
import com.munjaon.server.server.packet.common.*; |
| 11 | 11 |
import com.munjaon.server.server.queue.ReportUserQueue; |
| 12 |
+import com.munjaon.server.server.service.HealthCheckServer; |
|
| 12 | 13 |
import com.munjaon.server.server.service.PropertyLoader; |
| 13 | 14 |
import com.munjaon.server.util.LogUtil; |
| 14 | 15 |
|
| 15 | 16 |
import java.io.IOException; |
| 17 |
+import java.io.UnsupportedEncodingException; |
|
| 16 | 18 |
import java.nio.ByteBuffer; |
| 17 | 19 |
import java.nio.channels.SelectionKey; |
| 18 | 20 |
import java.nio.channels.Selector; |
... | ... | @@ -38,6 +40,7 @@ |
| 38 | 40 |
private boolean IS_RUN_YN; |
| 39 | 41 |
private long RUN_FLAG_CHECK_TIME; |
| 40 | 42 |
private long SEND_CYCLE_CHECK_TIME; |
| 43 |
+ private long LAST_PACKET_SEND_TIME = System.currentTimeMillis(); // 패킷 송수신 시간을 체크하기 위한 변수(최대 3초간 요청이 없는 경우 Thread 종료) |
|
| 41 | 44 |
private boolean IS_ERROR = false; |
| 42 | 45 |
|
| 43 | 46 |
/* 세션이 만료되었는지 체크 */ |
... | ... | @@ -114,8 +117,8 @@ |
| 114 | 117 |
/* 2. Packet Timeout Check */ |
| 115 | 118 |
if (checkTimeOut()) {
|
| 116 | 119 |
saveSystemLog(printTaskLog() + "[checkTimeOut : Expired ... ... ... ... ... ... ...]"); |
| 117 |
- saveSystemLog(printTaskLog() + "[### End ### ### ### ### ### ### ###]"); |
|
| 118 | 120 |
expireConnectUser(); |
| 121 |
+ saveSystemLog(printTaskLog() + "[### End ### ### ### ### ### ### ###]"); |
|
| 119 | 122 |
break; |
| 120 | 123 |
} |
| 121 | 124 |
|
... | ... | @@ -124,7 +127,7 @@ |
| 124 | 127 |
/* RUN Flag 체크 */ |
| 125 | 128 |
reloadRunFlag(); |
| 126 | 129 |
/* 쓰레드 완료 시점 체크 */ |
| 127 |
- if (System.currentTimeMillis() - SEND_CYCLE_CHECK_TIME > ServerConfig.REPORT_EXEC_CYCLE_TIME) {
|
|
| 130 |
+ if (System.currentTimeMillis() - LAST_PACKET_SEND_TIME > ServerConfig.REPORT_EXEC_CYCLE_TIME) {
|
|
| 128 | 131 |
break; |
| 129 | 132 |
} |
| 130 | 133 |
} |
... | ... | @@ -171,7 +174,7 @@ |
| 171 | 174 |
return size; |
| 172 | 175 |
} |
| 173 | 176 |
|
| 174 |
- private void bindInterest() {
|
|
| 177 |
+ private void bindInterest() throws UnsupportedEncodingException {
|
|
| 175 | 178 |
if (reportUserDto.isLogin()) {
|
| 176 | 179 |
return; |
| 177 | 180 |
} |
... | ... | @@ -241,6 +244,7 @@ |
| 241 | 244 |
} |
| 242 | 245 |
} |
| 243 | 246 |
|
| 247 |
+ /* BIND 성공인 경우 사용자 정보 저장 */ |
|
| 244 | 248 |
if ("00".equals(resultCode)) {
|
| 245 | 249 |
reportUserDto.setUserId(id); |
| 246 | 250 |
reportUserDto.setLogin(true); |
... | ... | @@ -248,8 +252,6 @@ |
| 248 | 252 |
/* 리포트 큐 생성 */ |
| 249 | 253 |
ReportQueue reportQueue = new ReportQueue(reportUserDto.getQueuePath(), reportUserDto.getUserId()); |
| 250 | 254 |
reportUserDto.setReportQueue(reportQueue); |
| 251 |
- /* 사용자 Pool에 저장 */ |
|
| 252 |
- reportUserQueue.putUser(reportUserDto); |
|
| 253 | 255 |
/* 세션통신 시간 업데이트 */ |
| 254 | 256 |
reportUserDto.updateLastTrafficTime(); |
| 255 | 257 |
} |
... | ... | @@ -261,11 +263,17 @@ |
| 261 | 263 |
try {
|
| 262 | 264 |
saveSystemLog(printTaskLog() + "[BIND RESULT : " + resultCode + "]"); |
| 263 | 265 |
channel.write(Bind.makeBindAckBuffer(resultCode)); |
| 264 |
- if (!"00".equals(resultCode)) {
|
|
| 266 |
+ if ("00".equals(resultCode)) {
|
|
| 267 |
+ /* BIND 성공인 경우 사용자 Pool에 저장 */ |
|
| 268 |
+ reportUserQueue.putUser(reportUserDto); |
|
| 269 |
+ } else {
|
|
| 265 | 270 |
expireConnectUser(); |
| 266 | 271 |
} |
| 272 |
+ /* 모니터링 로그 */ |
|
| 273 |
+ HealthCheckServer.saveMonitorLog("[REPORT SERVER][ID : " + reportUserDto.getUserId() + "][BIND RESULT : " + resultCode + "]");
|
|
| 267 | 274 |
} catch (IOException e) {
|
| 268 | 275 |
saveSystemLog(e); |
| 276 |
+ throw new RuntimeException(e); |
|
| 269 | 277 |
} |
| 270 | 278 |
} |
| 271 | 279 |
|
... | ... | @@ -297,12 +305,16 @@ |
| 297 | 305 |
switch (Integer.parseInt(command)) {
|
| 298 | 306 |
case 6 : recvReport(channel); break; |
| 299 | 307 |
case 8 : recvLinkCheck(channel); break; |
| 300 |
- default: saveSystemLog(printTaskLog() + "[INVALID REQUEST][command : " + command + ";"); |
|
| 308 |
+ default: saveSystemLog(printTaskLog() + "[INVALID REQUEST][command : " + command + "]"); |
|
| 301 | 309 |
expireConnectUser(); break; |
| 302 | 310 |
} |
| 311 |
+ /* 마지막 패킷 수신시간 체크 */ |
|
| 312 |
+ LAST_PACKET_SEND_TIME = System.currentTimeMillis(); |
|
| 303 | 313 |
} else if (size == 0) {
|
| 304 | 314 |
Thread.sleep(1); |
| 305 | 315 |
if (System.currentTimeMillis() - SEND_CYCLE_CHECK_TIME >= ServerConfig.REPORT_EXEC_CYCLE_TIME) {
|
| 316 |
+ saveSystemLog(printTaskLog() + "[SEND_CYCLE_CHECK_TIME IS OVER : 3000ms]"); |
|
| 317 |
+ expireConnectUser(); |
|
| 306 | 318 |
this.isExpiredYn = true; |
| 307 | 319 |
break; |
| 308 | 320 |
} |
... | ... | @@ -318,7 +330,7 @@ |
| 318 | 330 |
ByteBuffer bodyBuffer = ByteBuffer.allocate(LinkCheck.LINK_CHECK_ACK_BODY_LENGTH); |
| 319 | 331 |
int size = channel.read(bodyBuffer); |
| 320 | 332 |
if (size > 0) {
|
| 321 |
- saveSystemLog(printTaskLog() + "[RECEIVER LINK CHECK ACK ... ... ... ... ... ... ...]"); |
|
| 333 |
+ saveSystemLog(printTaskLog() + "[RECEIVE LINK CHECK ACK ... ... ... ... ... ... ...]"); |
|
| 322 | 334 |
reportUserDto.updateLastTrafficTime(); |
| 323 | 335 |
this.isPacketSendYn = false; |
| 324 | 336 |
} |
... | ... | @@ -347,6 +359,7 @@ |
| 347 | 359 |
} |
| 348 | 360 |
if (reportUserDto.isAlive() == 2) {
|
| 349 | 361 |
channel.write(LinkCheck.makeLinkCheckBuffer()); |
| 362 |
+ saveSystemLog(printTaskLog() + "[SEND LINK CHECK ... ... ... ... ... ... ...]"); |
|
| 350 | 363 |
SEND_CYCLE_CHECK_TIME = System.currentTimeMillis(); |
| 351 | 364 |
/* Packet 전송했는지 여부 */ |
| 352 | 365 |
isPacketSendYn = true; |
... | ... | @@ -381,6 +394,8 @@ |
| 381 | 394 |
reportUserQueue.removeUser(reportUserDto.getUserId()); |
| 382 | 395 |
} |
| 383 | 396 |
key.attach(null); |
| 397 |
+ /* 모니터링 로그 */ |
|
| 398 |
+ HealthCheckServer.saveMonitorLog("[REPORT SERVER][ID : " + reportUserDto.getUserId() + "][EXPIRE CONNECT USER]");
|
|
| 384 | 399 |
} |
| 385 | 400 |
/* 세션 만료 여부 */ |
| 386 | 401 |
this.isExpiredYn = true; |
+++ src/main/java/com/munjaon/server/server/task/ReportTask.java
... | ... | @@ -0,0 +1,173 @@ |
| 1 | +package com.munjaon.server.server.task; | |
| 2 | + | |
| 3 | +import com.munjaon.server.server.config.ServerConfig; | |
| 4 | +import com.munjaon.server.server.dto.ReportUserDto; | |
| 5 | +import com.munjaon.server.server.packet.common.Header; | |
| 6 | +import com.munjaon.server.server.packet.common.Packet; | |
| 7 | +import com.munjaon.server.server.queue.ReportUserQueue; | |
| 8 | +import com.munjaon.server.server.service.HealthCheckServer; | |
| 9 | +import com.munjaon.server.server.service.PropertyLoader; | |
| 10 | +import com.munjaon.server.util.LogUtil; | |
| 11 | + | |
| 12 | +import java.io.IOException; | |
| 13 | +import java.nio.ByteBuffer; | |
| 14 | +import java.nio.channels.SelectionKey; | |
| 15 | +import java.nio.channels.SocketChannel; | |
| 16 | +import java.text.SimpleDateFormat; | |
| 17 | +import java.time.LocalDateTime; | |
| 18 | +import java.time.format.DateTimeFormatter; | |
| 19 | + | |
| 20 | +public abstract class ReportTask extends Thread { | |
| 21 | + public static final SimpleDateFormat sdf = new SimpleDateFormat("[MM-dd HH:mm:ss]"); | |
| 22 | + public static final String LOG_DATE_FORMAT = "[MM-dd HH:mm:ss]"; | |
| 23 | + | |
| 24 | + protected final SelectionKey key; | |
| 25 | + protected final SocketChannel channel; | |
| 26 | + protected final ReportUserQueue reportUserQueue = ReportUserQueue.getInstance(); | |
| 27 | + protected final ReportUserDto reportUserDto; | |
| 28 | + protected final String serviceName; | |
| 29 | + protected final String taskName; | |
| 30 | + protected final LogUtil logger; | |
| 31 | + | |
| 32 | + protected boolean IS_ERROR = false; | |
| 33 | + /* 세션이 만료되었는지 체크 */ | |
| 34 | + protected boolean isExpiredYn; | |
| 35 | + /* 클라이언트 요청 데이터 수신 */ | |
| 36 | + protected final ByteBuffer headBuffer = ByteBuffer.allocateDirect(Header.HEADER_LENGTH); | |
| 37 | + | |
| 38 | + private boolean IS_SERVER_RUN; // 서버가 구동중인지 여부 | |
| 39 | + private boolean IS_RUN_YN; | |
| 40 | + private long RUN_FLAG_CHECK_TIME; | |
| 41 | + protected long SEND_CYCLE_CHECK_TIME; | |
| 42 | + | |
| 43 | + public ReportTask(SelectionKey key, String serviceName, String taskName, LogUtil logger) { | |
| 44 | + this.key = key; | |
| 45 | + this.channel = (SocketChannel) key.channel(); | |
| 46 | + this.reportUserDto = (ReportUserDto) key.attachment(); | |
| 47 | + this.reportUserDto.setRunningMode(true); | |
| 48 | + this.serviceName = serviceName; | |
| 49 | + this.taskName = taskName; | |
| 50 | + this.logger = logger; | |
| 51 | + } | |
| 52 | + | |
| 53 | + @Override | |
| 54 | + public void run() { | |
| 55 | + if (this.reportUserDto.isLogin()) { | |
| 56 | + saveSystemLog("[" + this.taskName + "][ID : " + this.reportUserDto.getUserId() + "][### Start ### ### ### ### ### ### ###]"); | |
| 57 | + } else { | |
| 58 | + saveSystemLog("[" + this.taskName + "][### Start ### ### ### ### ### ### ###]"); | |
| 59 | + } | |
| 60 | + | |
| 61 | + /* 최초 RUN Flag 체크 */ | |
| 62 | + reloadRunFlag(); | |
| 63 | + try { | |
| 64 | + while (isRun()) { | |
| 65 | + /* 만료 여부 체크 */ | |
| 66 | + if (isExpiredYn) { | |
| 67 | + break; | |
| 68 | + } | |
| 69 | + | |
| 70 | + doService(); | |
| 71 | + /* RUN Flag 체크 */ | |
| 72 | + reloadRunFlag(); | |
| 73 | + } | |
| 74 | + } catch (Exception e) { | |
| 75 | + this.IS_ERROR = true; | |
| 76 | + saveSystemLog(e); | |
| 77 | + } | |
| 78 | + /* 중요 : 사용자 Thread 실행모드 Off */ | |
| 79 | + reportUserDto.setRunningMode(false); | |
| 80 | + /* 에러가 발생한 경우 세션을 종료힌다. */ | |
| 81 | + if (IS_ERROR) { | |
| 82 | + expireConnectUser(); | |
| 83 | + } | |
| 84 | + | |
| 85 | + if (this.reportUserDto.isLogin()) { | |
| 86 | + saveSystemLog("[" + this.taskName + "][ID : " + this.reportUserDto.getUserId() + "][### End ### ### ### ### ### ### ###]"); | |
| 87 | + } else { | |
| 88 | + saveSystemLog("[" + this.taskName + "][### End ### ### ### ### ### ### ###]"); | |
| 89 | + } | |
| 90 | + } | |
| 91 | + | |
| 92 | + protected void reloadRunFlag() { | |
| 93 | + if (System.currentTimeMillis() - RUN_FLAG_CHECK_TIME > ServerConfig.INTERVAL_PROPERTY_RELOAD_TIME) { | |
| 94 | + this.IS_RUN_YN = getProp("RUN_FLAG") != null && "Y".equals(getProp("RUN_FLAG")); | |
| 95 | + this.IS_SERVER_RUN = getProp("server", "run") != null && "Y".equals(getProp("server", "run")); | |
| 96 | + RUN_FLAG_CHECK_TIME = System.currentTimeMillis(); | |
| 97 | + } | |
| 98 | + } | |
| 99 | + | |
| 100 | + protected void initHeaderBuffer() { | |
| 101 | + this.headBuffer.clear(); | |
| 102 | + for (int loopCnt = 0; loopCnt < Header.HEADER_LENGTH; loopCnt++) { | |
| 103 | + this.headBuffer.put(Packet.SET_DEFAULT_BYTE); | |
| 104 | + } | |
| 105 | + this.headBuffer.position(0); | |
| 106 | + } | |
| 107 | + | |
| 108 | + protected int readHeader() throws IOException { | |
| 109 | + initHeaderBuffer(); | |
| 110 | + | |
| 111 | + return channel.read(headBuffer); | |
| 112 | + } | |
| 113 | + | |
| 114 | + protected void expireConnectUser() { | |
| 115 | + if (key == null || !key.isValid()) { | |
| 116 | + return; | |
| 117 | + } | |
| 118 | + try { | |
| 119 | + saveSystemLog("[" + this.taskName + "][Expire connect user: " + reportUserDto + "]"); | |
| 120 | + if (reportUserDto != null) { | |
| 121 | + if (reportUserDto.getUserId() != null) { | |
| 122 | + reportUserQueue.removeUser(reportUserDto.getUserId()); | |
| 123 | + } | |
| 124 | + key.attach(null); | |
| 125 | + /* 모니터링 로그 */ | |
| 126 | + HealthCheckServer.saveMonitorLog("[REPORT SERVER][ID : " + reportUserDto.getUserId() + "][EXPIRE CONNECT USER]"); | |
| 127 | + } | |
| 128 | + /* 세션 만료 여부 */ | |
| 129 | + this.isExpiredYn = true; | |
| 130 | + // 소켓 채널 닫기 | |
| 131 | + channel.close(); | |
| 132 | + // 키 닫기 | |
| 133 | + key.cancel(); | |
| 134 | + } catch (IOException e) { | |
| 135 | + saveSystemLog(e); | |
| 136 | + } | |
| 137 | + } | |
| 138 | + | |
| 139 | + protected boolean isRun() { | |
| 140 | + return IS_SERVER_RUN && IS_RUN_YN; | |
| 141 | + } | |
| 142 | + | |
| 143 | + protected String getProp(String name) { | |
| 144 | + return getProp(this.serviceName, name); | |
| 145 | + } | |
| 146 | + | |
| 147 | + protected static String getProp(String svc, String name) { | |
| 148 | + return PropertyLoader.getProp(svc, name); | |
| 149 | + } | |
| 150 | + | |
| 151 | + protected void saveSystemLog(Object obj) { | |
| 152 | + saveLog(obj, true); | |
| 153 | + } | |
| 154 | + | |
| 155 | + protected void saveLog(Object obj) { | |
| 156 | + saveLog(obj, false); | |
| 157 | + } | |
| 158 | + | |
| 159 | + protected void saveLog(Object obj, boolean isConsoleOutput) { | |
| 160 | + if (isConsoleOutput) { | |
| 161 | + System.out.println(LocalDateTime.now().format(DateTimeFormatter.ofPattern(LOG_DATE_FORMAT)) + " {{" + this.serviceName + "}} " + obj); | |
| 162 | + } | |
| 163 | + | |
| 164 | + if (logger == null) { | |
| 165 | + return; | |
| 166 | + } | |
| 167 | + | |
| 168 | + logger.log(obj); | |
| 169 | + } | |
| 170 | + | |
| 171 | + /* 서비스 */ | |
| 172 | + public abstract void doService() throws Exception; | |
| 173 | +} |
--- src/main/java/com/munjaon/server/server/task/SendReadTask.java
+++ src/main/java/com/munjaon/server/server/task/SendReadTask.java
... | ... | @@ -12,6 +12,7 @@ |
| 12 | 12 |
|
| 13 | 13 |
import java.io.File; |
| 14 | 14 |
import java.io.IOException; |
| 15 |
+import java.io.UnsupportedEncodingException; |
|
| 15 | 16 |
import java.nio.ByteBuffer; |
| 16 | 17 |
import java.nio.channels.SelectionKey; |
| 17 | 18 |
import java.nio.channels.Selector; |
... | ... | @@ -129,7 +130,7 @@ |
| 129 | 130 |
return false; |
| 130 | 131 |
} |
| 131 | 132 |
|
| 132 |
- public BasicMessageDto recvCommonMessage(ByteBuffer deliverBuffer) {
|
|
| 133 |
+ public BasicMessageDto recvCommonMessage(ByteBuffer deliverBuffer) throws UnsupportedEncodingException {
|
|
| 133 | 134 |
if (deliverBuffer == null) {
|
| 134 | 135 |
return null; |
| 135 | 136 |
} |
--- src/main/java/com/munjaon/server/util/ByteUtil.java
+++ src/main/java/com/munjaon/server/util/ByteUtil.java
... | ... | @@ -5,6 +5,10 @@ |
| 5 | 5 |
|
| 6 | 6 |
package com.munjaon.server.util; |
| 7 | 7 |
|
| 8 |
+import com.munjaon.server.server.packet.common.Packet; |
|
| 9 |
+ |
|
| 10 |
+import java.io.UnsupportedEncodingException; |
|
| 11 |
+ |
|
| 8 | 12 |
/** |
| 9 | 13 |
* bytes 관련 유틸리티 클래스 |
| 10 | 14 |
* @author JDS |
... | ... | @@ -130,10 +134,10 @@ |
| 130 | 134 |
return src[offset]; |
| 131 | 135 |
} |
| 132 | 136 |
|
| 133 |
- public static byte[] getBytes(String data) {
|
|
| 137 |
+ public static byte[] getBytes(String data) throws UnsupportedEncodingException {
|
|
| 134 | 138 |
byte[] b = null; |
| 135 | 139 |
|
| 136 |
- b = data.getBytes(); |
|
| 140 |
+ b = data.getBytes(Packet.AGENT_CHARACTER_SET); |
|
| 137 | 141 |
|
| 138 | 142 |
return (b); |
| 139 | 143 |
} |
... | ... | @@ -171,8 +175,8 @@ |
| 171 | 175 |
return dest; |
| 172 | 176 |
} |
| 173 | 177 |
|
| 174 |
- public static void setBytes(byte[] dest, int offset, String s) {
|
|
| 175 |
- setBytes(dest, offset, s.getBytes()); |
|
| 178 |
+ public static void setBytes(byte[] dest, int offset, String s) throws UnsupportedEncodingException {
|
|
| 179 |
+ setBytes(dest, offset, s.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 176 | 180 |
} |
| 177 | 181 |
|
| 178 | 182 |
public static byte[] setBytes(byte dest[], int offset, byte src[]) {
|
--- src/main/java/com/munjaon/server/util/CommonUtil.java
+++ src/main/java/com/munjaon/server/util/CommonUtil.java
... | ... | @@ -1,5 +1,8 @@ |
| 1 | 1 |
package com.munjaon.server.util; |
| 2 | 2 |
|
| 3 |
+import com.munjaon.server.server.packet.common.Packet; |
|
| 4 |
+ |
|
| 5 |
+import java.io.UnsupportedEncodingException; |
|
| 3 | 6 |
import java.text.SimpleDateFormat; |
| 4 | 7 |
import java.text.ParseException; |
| 5 | 8 |
import java.util.Calendar; |
... | ... | @@ -69,12 +72,11 @@ |
| 69 | 72 |
return isValid; |
| 70 | 73 |
} |
| 71 | 74 |
// 해당 길이만큼 문자열을 자르는 함수 |
| 72 |
- public static String cutString(String str, int limit) |
|
| 73 |
- {
|
|
| 75 |
+ public static String cutString(String str, int limit) throws UnsupportedEncodingException {
|
|
| 74 | 76 |
int len = str.length(); |
| 75 | 77 |
int sumLength=0; |
| 76 | 78 |
String cutString = null; |
| 77 |
- byte[] toByte = str.getBytes(); |
|
| 79 |
+ byte[] toByte = str.getBytes(Packet.AGENT_CHARACTER_SET); |
|
| 78 | 80 |
|
| 79 | 81 |
if(limit < 2) |
| 80 | 82 |
return ""; |
--- src/main/java/com/munjaon/server/util/MessageUtil.java
+++ src/main/java/com/munjaon/server/util/MessageUtil.java
... | ... | @@ -4,7 +4,9 @@ |
| 4 | 4 |
import com.munjaon.server.queue.config.*; |
| 5 | 5 |
import com.munjaon.server.queue.dto.BasicMessageDto; |
| 6 | 6 |
import com.munjaon.server.server.dto.ReportDto; |
| 7 |
+import com.munjaon.server.server.packet.common.Packet; |
|
| 7 | 8 |
|
| 9 |
+import java.io.UnsupportedEncodingException; |
|
| 8 | 10 |
import java.nio.ByteBuffer; |
| 9 | 11 |
import java.time.LocalDateTime; |
| 10 | 12 |
import java.time.format.DateTimeFormatter; |
... | ... | @@ -100,15 +102,15 @@ |
| 100 | 102 |
return isEmptyForMessage(obj, false); |
| 101 | 103 |
} |
| 102 | 104 |
|
| 103 |
- public static boolean isOverByteForMessage(String obj, int limitCount, boolean trimFlag) {
|
|
| 105 |
+ public static boolean isOverByteForMessage(String obj, int limitCount, boolean trimFlag) throws UnsupportedEncodingException {
|
|
| 104 | 106 |
if (isEmptyForMessage(obj, trimFlag)) {
|
| 105 | 107 |
return true; |
| 106 | 108 |
} |
| 107 | 109 |
|
| 108 |
- return obj.getBytes().length > limitCount; |
|
| 110 |
+ return obj.getBytes(Packet.AGENT_CHARACTER_SET).length > limitCount; |
|
| 109 | 111 |
} |
| 110 | 112 |
|
| 111 |
- public static boolean isOverByteForMessage(String obj, int limitCount) {
|
|
| 113 |
+ public static boolean isOverByteForMessage(String obj, int limitCount) throws UnsupportedEncodingException {
|
|
| 112 | 114 |
return isOverByteForMessage(obj, limitCount, false); |
| 113 | 115 |
} |
| 114 | 116 |
|
... | ... | @@ -120,49 +122,49 @@ |
| 120 | 122 |
return popCounter < 0 ? QueueHeaderConfig.QUEUE_HEADER_LENGTH : (QueueHeaderConfig.QUEUE_HEADER_LENGTH + popCounter * dataByteLength); |
| 121 | 123 |
} |
| 122 | 124 |
|
| 123 |
- public static void setBytesForCommonMessage(ByteBuffer buffer, BasicMessageDto messageDto) {
|
|
| 125 |
+ public static void setBytesForCommonMessage(ByteBuffer buffer, BasicMessageDto messageDto) throws UnsupportedEncodingException {
|
|
| 124 | 126 |
/* 1. 사용자 아이디 */ |
| 125 | 127 |
buffer.position(BodyCommonConfig.USERID_BYTE_POSITION); |
| 126 |
- buffer.put(messageDto.getUserId().getBytes()); |
|
| 128 |
+ buffer.put(messageDto.getUserId().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 127 | 129 |
/* 2. 요금제(선불 : P / 후불 : A) */ |
| 128 | 130 |
buffer.position(BodyCommonConfig.FEETYPE_BYTE_POSITION); |
| 129 |
- buffer.put(messageDto.getFeeType().getBytes()); |
|
| 131 |
+ buffer.put(messageDto.getFeeType().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 130 | 132 |
/* 3. 단가 */ |
| 131 | 133 |
buffer.position(BodyCommonConfig.UNITCOST_BYTE_POSITION); |
| 132 |
- buffer.put(messageDto.getUnitCost().getBytes()); |
|
| 134 |
+ buffer.put(messageDto.getUnitCost().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 133 | 135 |
/* 4. MSG Group ID */ |
| 134 | 136 |
buffer.position(BodyCommonConfig.MSGGROUPID_BYTE_POSITION); |
| 135 |
- buffer.put(messageDto.getMsgGroupID().getBytes()); |
|
| 137 |
+ buffer.put(messageDto.getMsgGroupID().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 136 | 138 |
/* 5. MSG ID */ |
| 137 | 139 |
buffer.position(BodyCommonConfig.MSGID_BYTE_POSITION); |
| 138 |
- buffer.put(messageDto.getUserMsgID().getBytes()); |
|
| 140 |
+ buffer.put(messageDto.getUserMsgID().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 139 | 141 |
/* 6. Service Type */ |
| 140 | 142 |
buffer.position(BodyCommonConfig.SERVICETYPE_BYTE_POSITION); |
| 141 |
- buffer.put(messageDto.getServiceType().getBytes()); |
|
| 143 |
+ buffer.put(messageDto.getServiceType().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 142 | 144 |
/* 7. 메시지 전송 결과 >> 성공 : 0 / 필터링 : 기타값 */ |
| 143 | 145 |
buffer.position(BodyCommonConfig.SENDSTATUS_BYTE_POSITION); |
| 144 |
- buffer.put(messageDto.getSendStatus().getBytes()); |
|
| 146 |
+ buffer.put(messageDto.getSendStatus().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 145 | 147 |
/* 8. 회신번호 */ |
| 146 | 148 |
buffer.position(BodyCommonConfig.SENDER_BYTE_POSITION); |
| 147 |
- buffer.put(messageDto.getUserSender().getBytes()); |
|
| 149 |
+ buffer.put(messageDto.getUserSender().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 148 | 150 |
/* 9. 수신번호 */ |
| 149 | 151 |
buffer.position(BodyCommonConfig.RECEIVER_BYTE_POSITION); |
| 150 |
- buffer.put(messageDto.getUserReceiver().getBytes()); |
|
| 152 |
+ buffer.put(messageDto.getUserReceiver().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 151 | 153 |
/* 10. 예약시간 */ |
| 152 | 154 |
buffer.position(BodyCommonConfig.RESERVEDT_BYTE_POSITION); |
| 153 |
- buffer.put(messageDto.getReserveDt().getBytes()); |
|
| 155 |
+ buffer.put(messageDto.getReserveDt().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 154 | 156 |
/* 11. 요청시간 */ |
| 155 | 157 |
buffer.position(BodyCommonConfig.REQUESTDT_BYTE_POSITION); |
| 156 |
- buffer.put(messageDto.getRequestDt().getBytes()); |
|
| 158 |
+ buffer.put(messageDto.getRequestDt().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 157 | 159 |
/* 12. 원격 주소 */ |
| 158 | 160 |
buffer.position(BodyCommonConfig.REMOTEIP_BYTE_POSITION); |
| 159 |
- buffer.put(messageDto.getRemoteIP().getBytes()); |
|
| 161 |
+ buffer.put(messageDto.getRemoteIP().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 160 | 162 |
/* 13. 발송망 */ |
| 161 | 163 |
buffer.position(BodyCommonConfig.AGENT_CODE_BYTE_POSITION); |
| 162 |
- buffer.put(messageDto.getRouterSeq().getBytes()); |
|
| 164 |
+ buffer.put(messageDto.getRouterSeq().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 163 | 165 |
} |
| 164 | 166 |
|
| 165 |
- public static void getBytesForCommonMessage(ByteBuffer buffer, BasicMessageDto messageDto) {
|
|
| 167 |
+ public static void getBytesForCommonMessage(ByteBuffer buffer, BasicMessageDto messageDto) throws UnsupportedEncodingException {
|
|
| 166 | 168 |
byte[] destArray = null; |
| 167 | 169 |
if (buffer == null || messageDto == null) {
|
| 168 | 170 |
return; |
... | ... | @@ -242,13 +244,13 @@ |
| 242 | 244 |
// messageDto.setRouterSeq(new String(destArray)); |
| 243 | 245 |
} |
| 244 | 246 |
|
| 245 |
- public static void setBytesForSmsMessage(ByteBuffer buffer, BasicMessageDto messageDto) {
|
|
| 247 |
+ public static void setBytesForSmsMessage(ByteBuffer buffer, BasicMessageDto messageDto) throws UnsupportedEncodingException {
|
|
| 246 | 248 |
/* 14. 메시지 */ |
| 247 | 249 |
buffer.position(SmsBodyConfig.SMS_MSG_BYTE_POSITION); |
| 248 |
- buffer.put(messageDto.getUserMessage().getBytes()); |
|
| 250 |
+ buffer.put(messageDto.getUserMessage().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 249 | 251 |
} |
| 250 | 252 |
|
| 251 |
- public static void getBytesForSmsMessage(ByteBuffer buffer, BasicMessageDto messageDto) {
|
|
| 253 |
+ public static void getBytesForSmsMessage(ByteBuffer buffer, BasicMessageDto messageDto) throws UnsupportedEncodingException {
|
|
| 252 | 254 |
byte[] destArray = null; |
| 253 | 255 |
if (buffer == null || messageDto == null) {
|
| 254 | 256 |
return; |
... | ... | @@ -261,34 +263,34 @@ |
| 261 | 263 |
// messageDto.setUserMessage(new String(destArray)); |
| 262 | 264 |
} |
| 263 | 265 |
|
| 264 |
- public static void setBytesForMediaMessage(ByteBuffer buffer, BasicMessageDto messageDto) {
|
|
| 266 |
+ public static void setBytesForMediaMessage(ByteBuffer buffer, BasicMessageDto messageDto) throws UnsupportedEncodingException {
|
|
| 265 | 267 |
/* 14. 제목 */ |
| 266 | 268 |
buffer.position(MediaBodyConfig.SUBJECT_BYTE_POSITION); |
| 267 |
- buffer.put(messageDto.getUserSubject().getBytes()); |
|
| 269 |
+ buffer.put(messageDto.getUserSubject().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 268 | 270 |
/* 15. 메시지 */ |
| 269 | 271 |
buffer.position(MediaBodyConfig.MEDIA_MSG_BYTE_POSITION); |
| 270 |
- buffer.put(messageDto.getUserMessage().getBytes()); |
|
| 272 |
+ buffer.put(messageDto.getUserMessage().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 271 | 273 |
} |
| 272 | 274 |
|
| 273 |
- public static void setBytesForKakaoMessage(ByteBuffer buffer, BasicMessageDto messageDto) {
|
|
| 275 |
+ public static void setBytesForKakaoMessage(ByteBuffer buffer, BasicMessageDto messageDto) throws UnsupportedEncodingException {
|
|
| 274 | 276 |
/* 14. 제목 */ |
| 275 | 277 |
buffer.position(KakaoBodyConfig.SUBJECT_BYTE_POSITION); |
| 276 |
- buffer.put(messageDto.getUserSubject().getBytes()); |
|
| 278 |
+ buffer.put(messageDto.getUserSubject().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 277 | 279 |
/* 15. 메시지 */ |
| 278 | 280 |
buffer.position(KakaoBodyConfig.MEDIA_MSG_BYTE_POSITION); |
| 279 |
- buffer.put(messageDto.getUserMessage().getBytes()); |
|
| 281 |
+ buffer.put(messageDto.getUserMessage().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 280 | 282 |
/* 16. KAKAO_SENDER_KEY */ |
| 281 | 283 |
buffer.position(KakaoBodyConfig.KAKAO_SENDER_KEY_BYTE_POSITION); |
| 282 |
- buffer.put(messageDto.getKakaoSenderKey().getBytes()); |
|
| 284 |
+ buffer.put(messageDto.getKakaoSenderKey().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 283 | 285 |
/* 17. KAKAO_TEMPLATE_CODE */ |
| 284 | 286 |
buffer.position(KakaoBodyConfig.KAKAO_TEMPLATE_CODE_BYTE_POSITION); |
| 285 |
- buffer.put(messageDto.getKakaoTemplateCode().getBytes()); |
|
| 287 |
+ buffer.put(messageDto.getKakaoTemplateCode().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 286 | 288 |
/* 18. KAKAO_JSON_FILE */ |
| 287 | 289 |
buffer.position(KakaoBodyConfig.FILENAME_JSON_BYTE_POSITION); |
| 288 |
- buffer.put(messageDto.getKakaoJsonFile().getBytes()); |
|
| 290 |
+ buffer.put(messageDto.getKakaoJsonFile().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 289 | 291 |
} |
| 290 | 292 |
|
| 291 |
- public static void getBytesForKakaoMessage(ByteBuffer buffer, BasicMessageDto messageDto) {
|
|
| 293 |
+ public static void getBytesForKakaoMessage(ByteBuffer buffer, BasicMessageDto messageDto) throws UnsupportedEncodingException {
|
|
| 292 | 294 |
byte[] destArray = null; |
| 293 | 295 |
if (buffer == null || messageDto == null) {
|
| 294 | 296 |
return; |
... | ... | @@ -325,7 +327,7 @@ |
| 325 | 327 |
// messageDto.setUserSubject(new String(destArray)); |
| 326 | 328 |
} |
| 327 | 329 |
|
| 328 |
- public static void getBytesForMediaMessage(ByteBuffer buffer, BasicMessageDto messageDto) {
|
|
| 330 |
+ public static void getBytesForMediaMessage(ByteBuffer buffer, BasicMessageDto messageDto) throws UnsupportedEncodingException {
|
|
| 329 | 331 |
byte[] destArray = null; |
| 330 | 332 |
if (buffer == null || messageDto == null) {
|
| 331 | 333 |
return; |
... | ... | @@ -344,28 +346,28 @@ |
| 344 | 346 |
// messageDto.setUserMessage(new String(destArray)); |
| 345 | 347 |
} |
| 346 | 348 |
|
| 347 |
- public static void setBytesForMmsMessage(ByteBuffer buffer, BasicMessageDto messageDto) {
|
|
| 349 |
+ public static void setBytesForMmsMessage(ByteBuffer buffer, BasicMessageDto messageDto) throws UnsupportedEncodingException {
|
|
| 348 | 350 |
/* 16. 파일카운트 */ |
| 349 | 351 |
buffer.position(MediaBodyConfig.FILECNT_BYTE_POSITION); |
| 350 |
- buffer.put(Integer.toString(messageDto.getUserFileCnt()).getBytes()); |
|
| 352 |
+ buffer.put(Integer.toString(messageDto.getUserFileCnt()).getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 351 | 353 |
/* 17. 파일명 #1 */ |
| 352 | 354 |
buffer.position(MediaBodyConfig.FILENAME_ONE_BYTE_POSITION); |
| 353 | 355 |
if (messageDto.getUserFileName01() != null) {
|
| 354 |
- buffer.put(messageDto.getUserFileName01().getBytes()); |
|
| 356 |
+ buffer.put(messageDto.getUserFileName01().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 355 | 357 |
} |
| 356 | 358 |
/* 18. 파일명 #2 */ |
| 357 | 359 |
buffer.position(MediaBodyConfig.FILENAME_TWO_BYTE_POSITION); |
| 358 | 360 |
if (messageDto.getUserFileName02() != null) {
|
| 359 |
- buffer.put(messageDto.getUserFileName02().getBytes()); |
|
| 361 |
+ buffer.put(messageDto.getUserFileName02().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 360 | 362 |
} |
| 361 | 363 |
/* 19. 파일명 #3 */ |
| 362 | 364 |
buffer.position(MediaBodyConfig.FILENAME_THREE_BYTE_POSITION); |
| 363 | 365 |
if (messageDto.getUserFileName03() != null) {
|
| 364 |
- buffer.put(messageDto.getUserFileName03().getBytes()); |
|
| 366 |
+ buffer.put(messageDto.getUserFileName03().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 365 | 367 |
} |
| 366 | 368 |
} |
| 367 | 369 |
|
| 368 |
- public static void getBytesForMmsMessage(ByteBuffer buffer, BasicMessageDto messageDto) {
|
|
| 370 |
+ public static void getBytesForMmsMessage(ByteBuffer buffer, BasicMessageDto messageDto) throws UnsupportedEncodingException {
|
|
| 369 | 371 |
byte[] destArray = null; |
| 370 | 372 |
if (buffer == null || messageDto == null) {
|
| 371 | 373 |
return; |
... | ... | @@ -443,7 +445,7 @@ |
| 443 | 445 |
return pushCounter < 0 ? ReportConfig.HEAD_LENGTH : (ReportConfig.HEAD_LENGTH + pushCounter * dataByteLength); |
| 444 | 446 |
} |
| 445 | 447 |
|
| 446 |
- public static void setBytesForReport(ByteBuffer buffer, ReportDto reportDto) {
|
|
| 448 |
+ public static void setBytesForReport(ByteBuffer buffer, ReportDto reportDto) throws UnsupportedEncodingException {
|
|
| 447 | 449 |
if (buffer == null || reportDto == null) {
|
| 448 | 450 |
return; |
| 449 | 451 |
} |
... | ... | @@ -451,22 +453,22 @@ |
| 451 | 453 |
byte[] destArray = null; |
| 452 | 454 |
/* MSG_ID (Length : 20 / Position : 0) */ |
| 453 | 455 |
buffer.position(ReportConfig.MSG_ID_POSITION); |
| 454 |
- buffer.put(reportDto.getAgentMsgId().getBytes()); |
|
| 456 |
+ buffer.put(reportDto.getAgentMsgId().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 455 | 457 |
/* AGENT_CODE (Length : 2 / Position : 20) */ |
| 456 | 458 |
buffer.position(ReportConfig.AGENT_CODE_POSITION); |
| 457 |
- buffer.put(reportDto.getAgentCode().getBytes()); |
|
| 459 |
+ buffer.put(reportDto.getAgentCode().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 458 | 460 |
/* SEND_TIME (Length : 14 / Position : 22) */ |
| 459 | 461 |
buffer.position(ReportConfig.SEND_TIME_POSITION); |
| 460 |
- buffer.put(reportDto.getRsltDate().getBytes()); |
|
| 462 |
+ buffer.put(reportDto.getRsltDate().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 461 | 463 |
/* TELECOM (Length : 3 / Position : 36) */ |
| 462 | 464 |
buffer.position(ReportConfig.TELECOM_POSITION); |
| 463 |
- buffer.put(reportDto.getRsltNet().getBytes()); |
|
| 465 |
+ buffer.put(reportDto.getRsltNet().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 464 | 466 |
/* RESULT (Length : 5 / Position : 39) */ |
| 465 | 467 |
buffer.position(ReportConfig.RESULT_POSITION); |
| 466 |
- buffer.put(reportDto.getRsltCode().getBytes()); |
|
| 468 |
+ buffer.put(reportDto.getRsltCode().getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 467 | 469 |
} |
| 468 | 470 |
|
| 469 |
- public static ReportDto getReportFromBuffer(ByteBuffer buffer) {
|
|
| 471 |
+ public static ReportDto getReportFromBuffer(ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 470 | 472 |
if (buffer == null) {
|
| 471 | 473 |
return null; |
| 472 | 474 |
} |
--- src/main/resources/dev/application-dev.yml
+++ src/main/resources/dev/application-dev.yml
... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 |
spring: |
| 2 | 2 |
datasource: |
| 3 |
- hikari: |
|
| 3 |
+ server: |
|
| 4 | 4 |
driver-class-name: org.mariadb.jdbc.Driver |
| 5 | 5 |
url: jdbc:mariadb://192.168.0.125:3306/mjon_agent_back |
| 6 | 6 |
jdbc-url: jdbc:mariadb://192.168.0.125:3306/mjon_agent_back |
--- src/main/resources/local/application-local.yml
+++ src/main/resources/local/application-local.yml
... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 |
spring: |
| 2 | 2 |
datasource: |
| 3 |
- hikari: |
|
| 3 |
+ server: |
|
| 4 | 4 |
driver-class-name: org.mariadb.jdbc.Driver |
| 5 | 5 |
url: jdbc:mariadb://localhost:3306/mjon |
| 6 | 6 |
jdbc-url: jdbc:mariadb://localhost:3306/mjon |
--- src/main/resources/prod/application-prod.yml
+++ src/main/resources/prod/application-prod.yml
... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 |
spring: |
| 2 | 2 |
datasource: |
| 3 |
- hikari: |
|
| 3 |
+ server: |
|
| 4 | 4 |
driver-class-name: org.mariadb.jdbc.Driver |
| 5 | 5 |
url: jdbc:mariadb://119.193.215.98:3306/mjon_agent |
| 6 | 6 |
jdbc-url: jdbc:mariadb://119.193.215.98:3306/mjon_agent |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?