Ver Fonte

logging file add

shjung há 10 meses atrás
pai
commit
4310a27505

+ 1 - 1
pom.xml

@@ -115,7 +115,7 @@
                 </configuration>
             </plugin>
         </plugins>
-        <finalName>${artifactId}</finalName>
+        <finalName>${project.artifactId}</finalName>
     </build>
 
 </project>

+ 0 - 85
src/main/java/com/sig/app/common/kafka/KafkaProducerFactory.java

@@ -1,85 +0,0 @@
-package com.sig.app.common.kafka;
-
-import org.apache.kafka.clients.producer.ProducerConfig;
-import org.springframework.kafka.core.DefaultKafkaProducerFactory;
-import org.springframework.kafka.core.KafkaTemplate;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-public class KafkaProducerFactory {
-
-    public static <K,V> KafkaTemplate<K, V> createByteArrayTemplate(String bootstrapServers, List<Map<String, String>> props) {
-        Map<String, Object> configs = new HashMap<>();
-        configs.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
-        configs.put("enable.idempotence", false);
-        configs.put(ProducerConfig.ACKS_CONFIG, "0");
-        configs.put(ProducerConfig.RETRIES_CONFIG, 0);
-        configs.put(ProducerConfig.LINGER_MS_CONFIG, 1);
-        configs.put(ProducerConfig.REQUEST_TIMEOUT_MS_CONFIG, 3000);
-        configs.put(ProducerConfig.DELIVERY_TIMEOUT_MS_CONFIG, 4000);
-        //configs.put("queue.buffering.max.messages", 10000000);
-        //configs.put("queue.buffering.max.kbytes", 2147483647);
-        //configs.put("queue.buffering.max.ms", 0);
-        //configs.put("api.version.request", false);
-        configs.put(ProducerConfig.TRANSACTION_TIMEOUT_CONFIG, 5000);
-        configs.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, org.apache.kafka.common.serialization.StringSerializer.class);
-        configs.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, org.apache.kafka.common.serialization.ByteArraySerializer.class);
-
-        for (Map<String, String> prop : props) {
-            for (Map.Entry<String, String> elem : prop.entrySet()) {
-                String key = elem.getKey();
-                String val = elem.getValue();
-                if (val != null) {
-                    if (val.equals("true") || val.equals("false")) {
-                        configs.put(key, val.equals("true"));
-                    } else {
-                        configs.put(key, val);
-                    }
-                }
-            }
-        }
-
-        DefaultKafkaProducerFactory<K, V> defaultKafkaProducerFactory = new DefaultKafkaProducerFactory<>(configs);
-        return new KafkaTemplate<>(defaultKafkaProducerFactory);
-    }
-
-    public static <K,V> KafkaTemplate<K, V> createProducerTemplate(Map<String, Object> props) {
-        DefaultKafkaProducerFactory<K, V> defaultKafkaProducerFactory = new DefaultKafkaProducerFactory<>(props);
-        return new KafkaTemplate<>(defaultKafkaProducerFactory);
-    }
-
-    public static Properties getProperties(String bootstrapServers, List<Map<String, String>> props) {
-        Properties properties  = new Properties();
-        properties.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
-        properties.put("enable.idempotence", false);
-        properties.put(ProducerConfig.ACKS_CONFIG, "0");
-        properties.put(ProducerConfig.RETRIES_CONFIG, 0);
-        properties.put(ProducerConfig.LINGER_MS_CONFIG, 1);
-        properties.put(ProducerConfig.REQUEST_TIMEOUT_MS_CONFIG, 3000);
-        properties.put(ProducerConfig.DELIVERY_TIMEOUT_MS_CONFIG, 4000);
-        //properties.put("queue.buffering.max.messages", 10000000);
-        //properties.put("queue.buffering.max.kbytes", 2147483647);
-        //properties.put("queue.buffering.max.ms", 0);
-        //properties.put("api.version.request", false);
-        properties.put("transaction.timeout.ms", 5000);
-        properties.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, org.apache.kafka.common.serialization.StringSerializer.class);
-        properties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, org.apache.kafka.common.serialization.ByteArraySerializer.class);
-        for (Map<String, String> prop : props) {
-            for (Map.Entry<String, String> elem : prop.entrySet()) {
-                String key = elem.getKey();
-                String val = elem.getValue();
-                if (val != null) {
-                    if (val.equals("true") || val.equals("false")) {
-                        properties.put(key, val.equals("true"));
-                    } else {
-                        properties.put(key, val);
-                    }
-                }
-            }
-        }
-        return properties ;
-    }
-}

+ 0 - 252
src/main/java/com/sig/app/common/utils/CRC16.java

@@ -1,252 +0,0 @@
-package com.sig.app.common.utils;
-
-/**
- * CRC16_CCITT: Polynomial x16+x12+x5+1 (0x1021), initial value 0x0000, low bit first, high bit after, result is exclusive to 0x0000
- * CRC16_CCITT_FALSE: Polynomial x16+x12+x5+1 (0x1021), initial value 0xFFFF, low bit is after, high bit is first, result is exclusive to 0x0000
- * CRC16_XMODEM: Polynomial x16+x12+x5+1 (0x1021), initial value 0x0000, low bit after, high bit first, result is XOR0
- * CRC16_X25: Polynomial x16+x12+x5+1 (0x1021), initial value 0xffff, low bit first, high bit after, result is XORIF 0xFFFF
- * CRC16_MODBUS: Polynomial x16+x15+x2+1 (0x8005), initial value 0xFFFF, low bit first, high bit after, result is X2000000 exclusive OR
- * CRC16_IBM: Polynomial x16+x15+x2+1 (0x8005), initial value 0x0000, low bit first, high bit after, result is XOR0
- * CRC16_MAXIM: Polynomial x16+x15+x2+1 (0x8005), initial value 0x0000, low bit first, high bit after, result is XORIF 0xFFFF
- * CRC16_USB: Polynomial x16+x15+x2+1 (0x8005), initial value 0xFFFF, low bit first, high bit after, result is XORIF 0xFFFF
- * <p>
- * (1), preset a 16-bit register to hexadecimal FFFF (that is, all 1), call this register a CRC register;
- * (2), the first 8-bit binary data (the first byte of the communication information frame) is different from the lower 8 bits of the 16-bit CRC register, the result is placed in the CRC register, the upper eight bits of data are not Change
- * (3), shift the contents of the CRC register one bit to the right (toward the low position) to fill the highest bit with 0, and check the shifted out bit after the right shift;
- * (4) If the shift bit is 0: repeat step 3 (shift one bit right again); if the shift bit is 1, the CRC register is XORed with the polynomial A001 (1010 0000 0000 0001);
- * (5), repeat steps 3 and 4 until the right shift 8 times, so that the entire 8-bit data is processed;
- * (6), repeat steps 2 to 5, and worker the next byte of the communication information frame;
- * (7), after all the bytes of the communication information frame are calculated according to the above steps, the high and low bytes of the obtained 16-bit CRC register are exchanged;
- * (8), the final CRC register content is: CRC code.
- * <p>
- * The polynomial 0xA001 in the above calculation step is the result of 0x8005 bitwise reversal.
- * 0x8408 is the result of 0x1021 bitwise reversal.
- * Online verification tool
- * http://www.ip33.com/crc.html
- * https://blog.csdn.net/htmlxx/article/details/17369105
- * <p>
- * Author:Water
- * Time:2018/11/19 0019 15:03
- */
-public class CRC16 {
-
-    /**
-     * CRC16_CCITT: Polynomial x16+x12+x5+1 (0x1021), initial value 0x0000, low bit first, high bit after, result is exclusive to 0x0000
-     * 0x8408 is the result of 0x1021 bitwise reversal.
-     *
-     * @param buffer
-     * @return
-     */
-    public static int CRC16_CCITT(byte[] buffer) {
-        int wCRCin = 0x0000;
-        int wCPoly = 0x8408;
-        for (byte b : buffer) {
-            wCRCin ^= ((int) b & 0x00ff);
-            for (int j = 0; j < 8; j++) {
-                if ((wCRCin & 0x0001) != 0) {
-                    wCRCin >>= 1;
-                    wCRCin ^= wCPoly;
-                } else {
-                    wCRCin >>= 1;
-                }
-            }
-        }
-//        wCRCin=(wCRCin<<8)|(wCRCin>>8);
-//        wCRCin &= 0xffff;
-        return wCRCin ^= 0x0000;
-
-    }
-
-    /**
-     * CRC-CCITT (0xFFFF)
-     * CRC16_CCITT_FALSE: Polynomial x16+x12+x5+1 (0x1021), initial value 0xFFFF, low bit is after, high bit is first, result is exclusive to 0x0000
-     *
-     * @param buffer
-     * @return
-     */
-    public static int CRC16_CCITT_FALSE(byte[] buffer) {
-        int wCRCin = 0xffff;
-        int wCPoly = 0x1021;
-        for (byte b : buffer) {
-            for (int i = 0; i < 8; i++) {
-                boolean bit = ((b >> (7 - i) & 1) == 1);
-                boolean c15 = ((wCRCin >> 15 & 1) == 1);
-                wCRCin <<= 1;
-                if (c15 ^ bit)
-                    wCRCin ^= wCPoly;
-            }
-        }
-        wCRCin &= 0xffff;
-        return wCRCin ^= 0x0000;
-    }
-
-    /**
-     * CRC-CCITT (XModem)
-     * CRC16_XMODEM: Polynomial x16+x12+x5+1 (0x1021), initial value 0x0000, low bit after, high bit first, result is XOR0
-     *
-     * @param buffer
-     * @return
-     */
-    public static int CRC16_XMODEM(byte[] buffer) {
-        int wCRCin = 0x0000; // initial value 65535
-        int wCPoly = 0x1021; // 0001 0000 0010 0001 (0, 5, 12)
-        for (byte b : buffer) {
-            for (int i = 0; i < 8; i++) {
-                boolean bit = ((b >> (7 - i) & 1) == 1);
-                boolean c15 = ((wCRCin >> 15 & 1) == 1);
-                wCRCin <<= 1;
-                if (c15 ^ bit)
-                    wCRCin ^= wCPoly;
-            }
-        }
-        wCRCin &= 0xffff;
-        return wCRCin ^= 0x0000;
-    }
-
-
-    /**
-     * CRC16_X25: Polynomial x16+x12+x5+1 (0x1021), initial value 0xffff, low bit first, high bit after, result is XORIF 0xFFFF
-     * 0x8408 is the result of 0x1021 bitwise reversal.
-     *
-     * @param buffer
-     * @return
-     */
-    public static int CRC16_X25(byte[] buffer) {
-        int wCRCin = 0xffff;
-        int wCPoly = 0x8408;
-        for (byte b : buffer) {
-            wCRCin ^= ((int) b & 0x00ff);
-            for (int j = 0; j < 8; j++) {
-                if ((wCRCin & 0x0001) != 0) {
-                    wCRCin >>= 1;
-                    wCRCin ^= wCPoly;
-                } else {
-                    wCRCin >>= 1;
-                }
-            }
-        }
-        return wCRCin ^= 0xffff;
-    }
-
-    /**
-     * CRC-16 (Modbus)
-     * CRC16_MODBUS: Polynomial x16+x15+x2+1 (0x8005), initial value 0xFFFF, low bit first, high bit after, result is X2000000 exclusive OR
-     * 0xA001 is the result of 0x8005 bitwise reversal
-     *
-     * @param buffer
-     * @return
-     */
-    public static int CRC16_MODBUS(byte[] buffer) {
-        int wCRCin = 0xffff;
-        int POLYNOMIAL = 0xa001;
-        for (byte b : buffer) {
-            wCRCin ^= ((int) b & 0x00ff);
-            for (int j = 0; j < 8; j++) {
-                if ((wCRCin & 0x0001) != 0) {
-                    wCRCin >>= 1;
-                    wCRCin ^= POLYNOMIAL;
-                } else {
-                    wCRCin >>= 1;
-                }
-            }
-        }
-        return wCRCin ^= 0x0000;
-    }
-
-    /**
-     * CRC-16
-     * CRC16_IBM: Polynomial x16+x15+x2+1 (0x8005), initial value 0x0000, low bit first, high bit after, result is XOR0
-     * 0xA001 is the result of 0x8005 bitwise reversal
-     *
-     * @param buffer
-     * @return
-     */
-    public static int CRC16_IBM(byte[] buffer) {
-        int wCRCin = 0x0000;
-        int wCPoly = 0xa001;
-        for (byte b : buffer) {
-            wCRCin ^= ((int) b & 0x00ff);
-            for (int j = 0; j < 8; j++) {
-                if ((wCRCin & 0x0001) != 0) {
-                    wCRCin >>= 1;
-                    wCRCin ^= wCPoly;
-                } else {
-                    wCRCin >>= 1;
-                }
-            }
-        }
-        return wCRCin ^= 0x0000;
-    }
-
-    /**
-     * CRC16_MAXIM: Polynomial x16+x15+x2+1 (0x8005), initial value 0x0000, low bit first, high bit after, result is XORIF 0xFFFF
-     * 0xA001 is the result of 0x8005 bitwise reversal
-     *
-     * @param buffer
-     * @return
-     */
-    public static int CRC16_MAXIM(byte[] buffer) {
-        int wCRCin = 0x0000;
-        int wCPoly = 0xa001;
-        for (byte b : buffer) {
-            wCRCin ^= ((int) b & 0x00ff);
-            for (int j = 0; j < 8; j++) {
-                if ((wCRCin & 0x0001) != 0) {
-                    wCRCin >>= 1;
-                    wCRCin ^= wCPoly;
-                } else {
-                    wCRCin >>= 1;
-                }
-            }
-        }
-        return wCRCin ^= 0xffff;
-    }
-
-    /**
-     * CRC16_USB: Polynomial x16+x15+x2+1 (0x8005), initial value 0xFFFF, low bit first, high bit after, result is XORIF 0xFFFF
-     * 0xA001 is the result of 0x8005 bitwise reversal
-     *
-     * @param buffer
-     * @return
-     */
-    public static int CRC16_USB(byte[] buffer) {
-        int wCRCin = 0xFFFF;
-        int wCPoly = 0xa001;
-        for (byte b : buffer) {
-            wCRCin ^= ((int) b & 0x00ff);
-            for (int j = 0; j < 8; j++) {
-                if ((wCRCin & 0x0001) != 0) {
-                    wCRCin >>= 1;
-                    wCRCin ^= wCPoly;
-                } else {
-                    wCRCin >>= 1;
-                }
-            }
-        }
-        return wCRCin ^= 0xffff;
-    }
-
-    /**
-     * CRC16_DNP: Polynomial x16+x13+x12+x11+x10+x8+x6+x5+x2+1 (0x3D65), initial value 0x0000, low bit first, high bit after, result is XORIF 0xFFFF
-     * 0xA6BC is the result of 0x3D65 bitwise reversal
-     *
-     * @param buffer
-     * @return
-     */
-    public static int CRC16_DNP(byte[] buffer) {
-        int wCRCin = 0x0000;
-        int wCPoly = 0xA6BC;
-        for (byte b : buffer) {
-            wCRCin ^= ((int) b & 0x00ff);
-            for (int j = 0; j < 8; j++) {
-                if ((wCRCin & 0x0001) != 0) {
-                    wCRCin >>= 1;
-                    wCRCin ^= wCPoly;
-                } else {
-                    wCRCin >>= 1;
-                }
-            }
-        }
-        return wCRCin ^= 0xffff;
-    }
-}

+ 0 - 83
src/main/java/com/sig/app/common/utils/CRC16Utils.java

@@ -1,83 +0,0 @@
-package com.sig.app.common.utils;
-
-public class CRC16Utils {
-    private static final int CRC16_ccitt_table[] = {
-        0x0000, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF,
-        0x8C48, 0x9DC1, 0xAF5A, 0xBED3, 0xCA6C, 0xDBE5, 0xE97E, 0xF8F7,
-        0x1081, 0x0108, 0x3393, 0x221A, 0x56A5, 0x472C, 0x75B7, 0x643E,
-        0x9CC9, 0x8D40, 0xBFDB, 0xAE52, 0xDAED, 0xCB64, 0xF9FF, 0xE876,
-        0x2102, 0x308B, 0x0210, 0x1399, 0x6726, 0x76AF, 0x4434, 0x55BD,
-        0xAD4A, 0xBCC3, 0x8E58, 0x9FD1, 0xEB6E, 0xFAE7, 0xC87C, 0xD9F5,
-        0x3183, 0x200A, 0x1291, 0x0318, 0x77A7, 0x662E, 0x54B5, 0x453C,
-        0xBDCB, 0xAC42, 0x9ED9, 0x8F50, 0xFBEF, 0xEA66, 0xD8FD, 0xC974,
-        0x4204, 0x538D, 0x6116, 0x709F, 0x0420, 0x15A9, 0x2732, 0x36BB,
-        0xCE4C, 0xDFC5, 0xED5E, 0xFCD7, 0x8868, 0x99E1, 0xAB7A, 0xBAF3,
-        0x5285, 0x430C, 0x7197, 0x601E, 0x14A1, 0x0528, 0x37B3, 0x263A,
-        0xDECD, 0xCF44, 0xFDDF, 0xEC56, 0x98E9, 0x8960, 0xBBFB, 0xAA72,
-        0x6306, 0x728F, 0x4014, 0x519D, 0x2522, 0x34AB, 0x0630, 0x17B9,
-        0xEF4E, 0xFEC7, 0xCC5C, 0xDDD5, 0xA96A, 0xB8E3, 0x8A78, 0x9BF1,
-        0x7387, 0x620E, 0x5095, 0x411C, 0x35A3, 0x242A, 0x16B1, 0x0738,
-        0xFFCF, 0xEE46, 0xDCDD, 0xCD54, 0xB9EB, 0xA862, 0x9AF9, 0x8B70,
-        0x8408, 0x9581, 0xA71A, 0xB693, 0xC22C, 0xD3A5, 0xE13E, 0xF0B7,
-        0x0840, 0x19C9, 0x2B52, 0x3ADB, 0x4E64, 0x5FED, 0x6D76, 0x7CFF,
-        0x9489, 0x8500, 0xB79B, 0xA612, 0xD2AD, 0xC324, 0xF1BF, 0xE036,
-        0x18C1, 0x0948, 0x3BD3, 0x2A5A, 0x5EE5, 0x4F6C, 0x7DF7, 0x6C7E,
-        0xA50A, 0xB483, 0x8618, 0x9791, 0xE32E, 0xF2A7, 0xC03C, 0xD1B5,
-        0x2942, 0x38CB, 0x0A50, 0x1BD9, 0x6F66, 0x7EEF, 0x4C74, 0x5DFD,
-        0xB58B, 0xA402, 0x9699, 0x8710, 0xF3AF, 0xE226, 0xD0BD, 0xC134,
-        0x39C3, 0x284A, 0x1AD1, 0x0B58, 0x7FE7, 0x6E6E, 0x5CF5, 0x4D7C,
-        0xC60C, 0xD785, 0xE51E, 0xF497, 0x8028, 0x91A1, 0xA33A, 0xB2B3,
-        0x4A44, 0x5BCD, 0x6956, 0x78DF, 0x0C60, 0x1DE9, 0x2F72, 0x3EFB,
-        0xD68D, 0xC704, 0xF59F, 0xE416, 0x90A9, 0x8120, 0xB3BB, 0xA232,
-        0x5AC5, 0x4B4C, 0x79D7, 0x685E, 0x1CE1, 0x0D68, 0x3FF3, 0x2E7A,
-        0xE70E, 0xF687, 0xC41C, 0xD595, 0xA12A, 0xB0A3, 0x8238, 0x93B1,
-        0x6B46, 0x7ACF, 0x4854, 0x59DD, 0x2D62, 0x3CEB, 0x0E70, 0x1FF9,
-        0xF78F, 0xE606, 0xD49D, 0xC514, 0xB1AB, 0xA022, 0x92B9, 0x8330,
-        0x7BC7, 0x6A4E, 0x58D5, 0x495C, 0x3DE3, 0x2C6A, 0x1EF1, 0x0F78
-    };
-
-    public static int CRC16_CCITT_FALSE(byte[] bytes, int start, int length) {
-        int crc = 0xffff; // initial value
-        int polynomial = 0x1021; // poly value
-        for (int index = start; index < length; index++) {
-            byte b = bytes[index];
-            for (int i = 0; i < 8; i++) {
-                boolean bit = ((b >> (7 - i) & 1) == 1);
-                boolean c15 = ((crc >> 15 & 1) == 1);
-                crc <<= 1;
-                if (c15 ^ bit)
-                    crc ^= polynomial;
-            }
-        }
-        crc &= 0xffff;
-        return crc;
-    }
-
-    public static int CRC16_CCITT(byte[] bytes, int start, int length) {
-        int crc = 0x0000; // initial value
-        int polynomial = 0x8408;// poly value reversed 0x1021;
-
-        int i, j;
-        for (i = start; i < length; i++) {
-            crc ^= ((int) bytes[i] & 0x000000ff);
-            for (j = 0; j < 8; j++) {
-                if ((crc & 0x00000001) != 0) {
-                    crc >>= 1;
-                    crc ^= polynomial;
-                } else {
-                    crc >>= 1;
-                }
-            }
-        }
-        return crc;
-    }
-    //static int CRC16_ccitt_false(byte [] data, int start, int length) {
-    public static int CRC16_ccitt_cvim(byte [] data, int start, int length) {
-        int crc16 = 0xFFFF;
-        for (int ii = start; ii < length+start; ii++) {
-            crc16 =  CRC16_ccitt_table[(crc16 ^ data[ii]) & 0xFF] ^ (crc16 >> 8);
-        }
-        return crc16 & 0xFFFF;
-    }
-
-}

+ 0 - 22
src/main/java/com/sig/app/common/utils/Converter.java

@@ -1,22 +0,0 @@
-package com.sig.app.common.utils;
-
-public class Converter {
-
-    private Converter() {}
-
-    public static String getSize(double bytes) {
-        final long kilo = 1024;
-
-        double kb = bytes / kilo;
-        double mb = kb / kilo;
-        double gb = mb / kilo;
-        double tb = gb / kilo;
-
-        if (tb > 1.0D) return String.format("%.2f TB", tb);
-        if (gb > 1.0D) return String.format("%.2f GB", gb);
-        if (mb > 1.0D) return String.format("%.2f MB", mb);
-        if (kb > 1.0D) return String.format("%.2f KB", kb);
-
-        return String.format("%.2f Bytes", bytes);
-    }
-}

+ 0 - 38
src/main/java/com/sig/app/common/utils/Counter.java

@@ -1,38 +0,0 @@
-package com.sig.app.common.utils;
-
-import java.util.concurrent.atomic.AtomicLong;
-
-public class Counter {
-
-    private AtomicLong counter;
-
-    public Counter() {
-        this.counter = new AtomicLong(0);
-    }
-
-    public long reset() {
-        return this.counter.getAndSet(0);
-    }
-    public long reset(long value) {
-        return this.counter.getAndSet(0);
-    }
-
-    public long increment() {
-        return this.counter.incrementAndGet();
-    }
-    public long add(long value) {
-        return this.counter.addAndGet(value);
-    }
-
-    public long decrement() {
-        return this.counter.decrementAndGet();
-    }
-    public long get() {
-        return this.counter.get();
-    }
-
-    @Override
-    public String toString() {
-        return Converter.getSize(this.counter.doubleValue());
-    }
-}

+ 0 - 31
src/main/java/com/sig/app/common/utils/Elapsed.java

@@ -1,31 +0,0 @@
-package com.sig.app.common.utils;
-
-import java.util.concurrent.TimeUnit;
-
-public class Elapsed {
-
-	private long sTime = 0;
-
-	public Elapsed() {
-		reset();
-	}
-
-	private long getElapsed() {
-		return System.nanoTime() - sTime;
-	}
-	public long nanoSeconds() {
-		return getElapsed();
-	}
-
-	public long milliSeconds() {
-		return TimeUnit.MILLISECONDS.convert(getElapsed(), TimeUnit.NANOSECONDS);
-	}
-
-	public long seconds() {
-		return TimeUnit.SECONDS.convert(getElapsed(), TimeUnit.NANOSECONDS);
-	}
-	
-	public void reset() {
-		sTime = System.nanoTime();
-	}
-}

+ 0 - 122
src/main/java/com/sig/app/common/utils/HexString.java

@@ -1,122 +0,0 @@
-package com.sig.app.common.utils;
-
-import java.nio.ByteBuffer;
-import java.util.Objects;
-
-public class HexString {
-    private static final char[] hexArray = "0123456789ABCDEF".toCharArray();
-
-    private HexString() {}
-
-    public static String fromByte(byte b) {
-        return fromBytes(new byte[] {b});
-    }
-
-    public static String fromByte(int b) {
-        return fromBytes(new byte[] {(byte) b});
-    }
-
-    public static String fromInt(int i) {
-        byte[] bytes = new byte[] {(byte) (i >> 24), (byte) (i >> 16), (byte) (i >> 8), (byte) (i)};
-        return fromBytes(bytes);
-    }
-
-    public static String fromLong(long l) {
-        byte[] bytes =
-                new byte[] {
-                        (byte) (l >> 56),
-                        (byte) (l >> 48),
-                        (byte) (l >> 40),
-                        (byte) (l >> 32),
-                        (byte) (l >> 24),
-                        (byte) (l >> 16),
-                        (byte) (l >> 8),
-                        (byte) (l)
-                };
-        return fromBytes(bytes);
-    }
-
-    public static String fromBytes(byte[] bytes) {
-        return fromBytes(bytes, 0, bytes.length);
-    }
-
-    public static String fromBytesFormatted(byte[] bytes) {
-        return fromBytesFormatted(bytes, 0, bytes.length);
-    }
-
-    public static String fromBytes(byte[] bytes, int offset, int length) {
-        char[] hexChars = new char[length * 2];
-        for (int j = 0; j < length; j++) {
-            int v = bytes[j + offset] & 0xff;
-            hexChars[j * 2] = hexArray[v >>> 4];
-            hexChars[j * 2 + 1] = hexArray[v & 0x0f];
-        }
-        return new String(hexChars);
-    }
-
-    public static String fromBytesSpace(byte[] bytes, int offset, int length) {
-        char[] hexChars = new char[length * 3];
-        for (int j = 0; j < length; j++) {
-            int v = bytes[j + offset] & 0xff;
-            hexChars[j * 2    ] = hexArray[v >>> 4];
-            hexChars[j * 2 + 1] = hexArray[v & 0x0f];
-            hexChars[j * 2 + 2] = ' ';
-        }
-        return new String(hexChars);
-    }
-
-    public static String fromBytes(ByteBuffer buffer) {
-        return fromBytes(buffer.array(), buffer.arrayOffset(), buffer.arrayOffset() + buffer.limit());
-    }
-
-    public static String fromBytesFormatted(byte[] bytes, int offset, int length) {
-        StringBuilder builder = new StringBuilder();
-
-        int l = 1;
-        for (int i = offset; i < (offset + length); i++) {
-            if ((l != 1) && ((l - 1) % 8 == 0)) {
-                builder.append(' ');
-            }
-            if ((l != 1) && ((l - 1) % 16 == 0)) {
-                builder.append('\n');
-            }
-            l++;
-            appendFromByte(bytes[i], builder);
-            if (i != offset + length - 1) {
-                builder.append(' ');
-            }
-        }
-        return builder.toString();
-    }
-
-    public static byte[] toBytes(String hexString) {
-
-        Objects.requireNonNull(hexString);
-        if ((hexString.length() == 0) || ((hexString.length() % 2) != 0)) {
-            throw new NumberFormatException("argument is not a valid hex string");
-        }
-
-        int length = hexString.length();
-
-        byte[] data = new byte[length / 2];
-        for (int i = 0; i < length; i += 2) {
-            int firstCharacter = Character.digit(hexString.charAt(i), 16);
-            int secondCharacter = Character.digit(hexString.charAt(i + 1), 16);
-
-            if (firstCharacter == -1 || secondCharacter == -1) {
-                throw new NumberFormatException("argument is not a valid hex string");
-            }
-
-            data[i / 2] = (byte) ((firstCharacter << 4) + secondCharacter);
-        }
-        return data;
-    }
-
-    public static void appendFromByte(byte b, StringBuilder builder) {
-        builder.append(fromByte(b));
-    }
-
-    public static void appendFromBytes(StringBuilder builder, byte[] bytes, int offset, int length) {
-        builder.append(fromBytes(bytes, offset, length));
-    }
-}

+ 0 - 76
src/main/java/com/sig/app/common/utils/LockFreeStack.java

@@ -1,76 +0,0 @@
-package com.sig.app.common.utils;
-
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.concurrent.locks.LockSupport;
-
-public class LockFreeStack<T> {
-
-    private AtomicReference<StackNode<T> > headNode = new AtomicReference<StackNode<T> >();
-    private AtomicInteger remains = new AtomicInteger(0);
-
-    // Push operation
-    public boolean offer(T value)
-    {
-        StackNode<T> newHead = new StackNode<T>(value);
-
-        // CAS loop defined
-        while (true) {
-            StackNode<T> currentHeadNode = headNode.get();
-            newHead.next = currentHeadNode;
-
-            // perform CAS operation before setting new
-            // value
-            if (headNode.compareAndSet(currentHeadNode, newHead)) {
-                break;
-            }
-            else {
-                // waiting for a nanosecond
-                LockSupport.parkNanos(1);
-            }
-        }
-
-        // getting the value atomically
-        remains.incrementAndGet();
-        return true;
-    }
-
-    // Pop function
-    public T take()
-    {
-        StackNode<T> currentHeadNode = headNode.get();
-
-        // CAS loop defined
-        while (currentHeadNode != null) {
-            StackNode<T> newHead = currentHeadNode.next;
-            if (headNode.compareAndSet(currentHeadNode,
-                    newHead)) {
-                break;
-            }
-            else {
-                // waiting for a nanosecond
-                LockSupport.parkNanos(1);
-                currentHeadNode = headNode.get();
-            }
-        }
-
-        T t = currentHeadNode != null ? currentHeadNode.value : null;
-
-        if (t != null)
-            remains.decrementAndGet();
-
-        return t;
-    }
-
-    public int size() {
-        return (int)remains.get();
-    }
-
-    private static class StackNode<T> {
-        T value;
-        StackNode<T> next;
-        StackNode(T value) { this.value = value; }
-
-        public T getValue() { return this.value; }
-    }
-}

+ 0 - 82
src/main/java/com/sig/app/common/utils/NonBlockingQueue.java

@@ -1,82 +0,0 @@
-package com.sig.app.common.utils;
-
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
-
-public class NonBlockingQueue<T> {
-
-    private final AtomicReference<Node<T>> head, tail;
-    private final AtomicInteger size;
-
-    public NonBlockingQueue() {
-        head = new AtomicReference<>(null);
-        tail = new AtomicReference<>(null);
-        size = new AtomicInteger();
-        size.set(0);
-    }
-
-    public boolean offer(T element) {
-        if (element == null) {
-            return false;//throw new NullPointerException();
-        }
-
-        Node<T> node = new Node<>(element);
-        Node<T> currentTail;
-        do {
-            currentTail = tail.get();
-            node.setPrevious(currentTail);
-        } while(!tail.compareAndSet(currentTail, node));
-
-        if(node.previous != null) {
-            node.previous.next = node;
-        }
-
-        head.compareAndSet(null, node); //if we are inserting the first element
-        size.incrementAndGet();
-        return true;
-    }
-
-    public T take() {
-        if(head.get() == null) {
-            return null;
-            //throw new NoSuchElementException();
-        }
-
-        Node<T> currentHead;
-        Node<T> nextNode;
-        do {
-            currentHead = head.get();
-            nextNode = currentHead.getNext();
-        } while(!head.compareAndSet(currentHead, nextNode));
-
-        size.decrementAndGet();
-        return currentHead.getValue();
-    }
-
-    public int size() {
-        return this.size.get();
-    }
-
-    private class Node<T> {
-        private final T value;
-        private volatile Node<T> next;
-        private volatile Node<T> previous;
-
-        public Node(T value) {
-            this.value = value;
-            this.next = null;
-        }
-
-        public T getValue() {
-            return value;
-        }
-
-        public Node<T> getNext() {
-            return next;
-        }
-
-        public void setPrevious(Node<T> previous) {
-            this.previous = previous;
-        }
-    }
-}

+ 0 - 8
src/main/java/com/sig/app/common/utils/OS.java

@@ -1,8 +0,0 @@
-package com.sig.app.common.utils;
-
-public class OS {
-    static final private String OS = System.getProperty("os.name").toLowerCase();
-    public static boolean isWindows() {
-        return OS.contains("win");
-    }
-}

+ 0 - 44
src/main/java/com/sig/app/common/utils/StringUtils.java

@@ -1,44 +0,0 @@
-package com.sig.app.common.utils;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-
-public class StringUtils {
-
-    private StringUtils() {}
-
-    public static String getString(boolean value) {
-        return value ? "1" : "0";
-    }
-
-    public static List<String> splitEmpty(String value, String separator) {
-        List<String> results = new ArrayList<String>();
-        StringTokenizer stringTokenizer = new StringTokenizer(value, separator);
-        while (stringTokenizer.hasMoreTokens()) {
-            results.add(stringTokenizer.nextToken().trim());
-        }
-        return results;
-    }
-
-    public static List<String> split(String value, String separator) {
-        String[] splits = value.split(separator);
-        List<String> results = new ArrayList<String>();
-        for (int ii = 0; ii < splits.length; ii++) {
-            splits[ii] = splits[ii].trim();
-            if (splits[ii].length() > 0) {
-                results.add(splits[ii]);
-            }
-        }
-        return results;
-    }
-
-    public static boolean isEmpty(String str) {
-        return str == null || str.length() == 0;
-    }
-
-    public static boolean isBlank(String s) {
-        return s == null || s.trim().isEmpty();
-    }
-
-}

+ 1 - 1
src/main/java/com/sig/app/common/utils/TimeUtils.java

@@ -30,7 +30,7 @@ public class TimeUtils {
         long nanoSeconds = TimeUnit.NANOSECONDS.convert(elapsed, TimeUnit.NANOSECONDS) % 1000;
 
         if (seconds > 0) {
-            return String.format("Elapsed: %,d sec. %3d ms. %d us. %3d ns.", seconds, miliSeconds, microSeconds, nanoSeconds);
+            return String.format("Elapsed: %,d sec. %3d ms. %3d us. %3d ns.", seconds, miliSeconds, microSeconds, nanoSeconds);
         }
         if (miliSeconds > 0) {
             return String.format("Elapsed: %3d ms. %3d us. %3d ns.", miliSeconds, microSeconds, nanoSeconds);

+ 0 - 63
src/main/java/com/sig/app/common/utils/Timespec.java

@@ -1,63 +0,0 @@
-package com.sig.app.common.utils;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.util.concurrent.TimeUnit;
-
-public class Timespec {
-
-    protected long tv_sec;
-    protected long tv_nsec;
-
-    public Timespec(ByteBuffer buffer) {
-        buffer.order(ByteOrder.nativeOrder());
-        this.tv_sec = buffer.getLong();
-        this.tv_nsec = buffer.getLong();
-    }
-    public Timespec(long sec, long nsec) {
-        this.tv_sec = sec;
-        this.tv_nsec = nsec;
-    }
-    public Timespec() {
-        init();
-    }
-
-    public void init() {
-        this.tv_sec = TimeUnit.SECONDS.convert(System.currentTimeMillis(), TimeUnit.MILLISECONDS);
-        this.tv_nsec = System.nanoTime();
-    }
-    public void tv_nsec(long nsec) {
-        this.tv_nsec = nsec;
-    }
-    public void tv_sec(long sec) {
-        this.tv_sec = sec;
-    }
-    public void set(long nsec, long sec) {
-        this.tv_nsec = nsec;
-        this.tv_sec = sec;
-    }
-    public byte[] tv_sec() {
-        ByteBuffer buffer = ByteBuffer.allocate(8);
-        buffer.putLong(this.tv_sec);
-        return buffer.array();
-    }
-    public byte[] tv_nsec() {
-        ByteBuffer buffer = ByteBuffer.allocate(8);
-        buffer.putLong(this.tv_nsec);
-        return buffer.array();
-    }
-    public byte[] bytes() {
-        ByteBuffer buffer = ByteBuffer.allocate(16);
-        buffer.order(ByteOrder.LITTLE_ENDIAN);
-        buffer.putLong(this.tv_sec);
-        buffer.putLong(this.tv_nsec);
-        return buffer.array();
-    }
-    public long timestamp() {
-        return this.tv_nsec;
-    }
-    public long times() {
-        return this.tv_sec;
-    }
-
-}

+ 24 - 2
src/main/resources/logback-spring.xml

@@ -2,11 +2,19 @@
 <configuration scan="true" scanPeriod="60 seconds">
     <shutdownHook class="ch.qos.logback.core.hook.DelayingShutdownHook"/>
 
-    <property name="PROJECT_NAME"    value="tsi-consumer"/>
+    <property name="PROJECT_NAME"    value="sig-consumer"/>
     <property name="ROOT_LOG_LEVEL"  value="DEBUG"/>
     <property name="LOG_CHARSET"     value="UTF-8" />
+    <property name="LOG_PATH"        value="${user.home}/logs/sig-comm-server/"/>
+    <property name="LOG_BACKUP_PATH" value="${user.home}/logs/sig-comm-server/backup/"/>
 
+    <property name="LOG_FILE_NAME"       value="${PROJECT_NAME}.log"/>
+    <property name="LOG_FILE_NAME_ERROR"   value="${PROJECT_NAME}.err.log"/>
+    <property name="LOG_FILE_NAME_BACKUP"  value="%d{yyyyMMdd}_%i.log.gz"/>
+    <property name="LOG_PATTERN_FILE"    value="[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level] %msg%n"/>
     <property name="LOG_PATTERN_CONSOLE" value="[%d{HH:mm:ss.SSS}] %highlight([%5level]): %cyan(%msg) %n"/>
+    <property name="MAX_FILESIZE" value="10MB"/>
+    <property name="MAX_HISTORY"  value="10"/>
 
     <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
         <withJansi>true</withJansi>
@@ -16,8 +24,22 @@
         </encoder>
     </appender>
 
-    <root level="INFO" additivity="true">
+    <appender name="FILE_LOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${LOG_PATH}${LOG_FILE_NAME}</file>
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <charset>${LOG_CHARSET}</charset>
+            <pattern>${LOG_PATTERN_FILE}</pattern>
+        </encoder>
+        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+            <fileNamePattern>${LOG_BACKUP_PATH}${LOG_FILE_NAME}.${LOG_FILE_NAME_BACKUP}</fileNamePattern>
+            <maxFileSize>${MAX_FILESIZE}</maxFileSize>
+            <maxHistory>${MAX_HISTORY}</maxHistory>
+        </rollingPolicy>
+    </appender>
+
+    <root level="INFO">
         <appender-ref ref="CONSOLE"/>
+        <appender-ref ref="FILE_LOG"/>
     </root>
 
 </configuration>

+ 4 - 80
src/test/java/com/sig/comm/consumer/SigCommConsumerApplicationTests.java

@@ -8,15 +8,15 @@ import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.Arrays;
 import java.util.HashSet;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
 
 @Slf4j
 //@SpringBootTest
 public class SigCommConsumerApplicationTests {
 
+    @Test
+    void tt1() {
+//        BitSet
+    }
     @Test
     void tt() {
         int MAX_DATA_SIZE = 8155;
@@ -80,83 +80,7 @@ public class SigCommConsumerApplicationTests {
             System.out.println("Your current Hostname : " + hostname);
 
         } catch (UnknownHostException e) {
-
             e.printStackTrace();
         }
     }
-    class WorkerThreadTask implements Runnable {
-
-        private ThreadPoolExecutor processExecutor;
-
-        public WorkerThreadTask(ThreadPoolExecutor processExecutor, int idx) {
-            Thread.currentThread().setName(String.format("worker-pool-%02d", idx));
-            this.processExecutor = processExecutor;
-        }
-
-        @Override
-        public void run() {
-            while (true) {
-                log.error("{}, corePoolSize: {}, activeCount: {}, maximumPoolSize: {}, poolSize: {}, taskCount: {}",
-                        Thread.currentThread().getName(),
-                        processExecutor.getCorePoolSize(),
-                        processExecutor.getActiveCount(),
-                        processExecutor.getMaximumPoolSize(),
-                        processExecutor.getPoolSize(),
-                        processExecutor.getTaskCount());
-                try {
-                    Thread.sleep(1000);
-                    if (processExecutor.awaitTermination(1L, TimeUnit.MILLISECONDS))
-                        log.info("Terminated");
-
-                } catch (InterruptedException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-    }
-    class NamedThreadsFactory implements ThreadFactory {
-
-        private int count = 0;
-        private String Name = "MyThread-";
-
-        @Override
-        public Thread newThread(Runnable r) {
-            return new Thread(r, Name + ++count); // Mythread-x 형태로 쓰레드 이름 설정
-        }
-    }
-
-    @Test
-    public void testThread() throws InterruptedException {
-        int threadPoolSize = Runtime.getRuntime().availableProcessors() * 10;
-        ThreadPoolExecutor processExecutor = (ThreadPoolExecutor) Executors.newFixedThreadPool(1);
-        log.info("corePoolSize: {}, activeCount: {}, maximumPoolSize: {}, poolSize: {}, taskCount: {}",
-                processExecutor.getCorePoolSize(),
-                processExecutor.getActiveCount(),
-                processExecutor.getMaximumPoolSize(),
-                processExecutor.getPoolSize(),
-                processExecutor.getTaskCount());
-
-        for (int ii = 0; ii < threadPoolSize; ii++) {
-            log.info("Thread Start: {}", ii);
-            processExecutor.execute(new WorkerThreadTask(processExecutor, ii));
-            /*processExecutor.execute(() -> {
-                while (true) {
-                    try {
-                        log.error("{}, corePoolSize: {}, activeCount: {}, maximumPoolSize: {}, poolSize: {}, taskCount: {}",
-                                Thread.currentThread().getName(),
-                                processExecutor.getCorePoolSize(),
-                                processExecutor.getActiveCount(),
-                                processExecutor.getMaximumPoolSize(),
-                                processExecutor.getPoolSize(),
-                                processExecutor.getTaskCount());
-                        Thread.sleep(1000);
-                    }
-                    catch (Exception e) {
-                        log.error("{}", e.getMessage(), e);
-                    }
-                }
-            });*/
-        }
-        Thread.sleep(20000);
-    }
 }