implemented decode from opened cache

This commit is contained in:
strawmanbobi
2019-01-08 21:19:25 +08:00
parent 9b36d9e715
commit cc486a1c8c
17 changed files with 172 additions and 605 deletions

5
.idea/codeStyles/codeStyleConfig.xml generated Normal file
View File

@@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>

116
pom.xml
View File

@@ -1,56 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.irext.decoder</groupId>
<artifactId>irext-decode-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<groupId>net.irext.decoder</groupId>
<artifactId>irext-decode-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>IRext Decode Service</name>
<description>Decoding IR binaries online</description>
<name>IRext Decode Service</name>
<description>Decoding IR binaries online</description>
<parent>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<relativePath/>
</parent>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependencies>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.1.1.RELEASE</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>2.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.13</version>
</dependency>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
@@ -61,30 +61,30 @@
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>2.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
<version>2.1.1.RELEASE</version>
</dependency>
</dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>2.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
<version>2.1.1.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@@ -22,8 +22,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class IRDecoderApplication {
public static void main(String[] args) {
SpringApplication.run(IRDecoderApplication.class, args);
}
public static void main(String[] args) {
SpringApplication.run(IRDecoderApplication.class, args);
}
}

View File

@@ -2,9 +2,8 @@ package net.irext.decoder.businesslogic;
import net.irext.decoder.alioss.OSSHelper;
import net.irext.decoder.cache.IDecodeSessionRepository;
import net.irext.decoder.model.IRBinary;
import net.irext.decoder.model.RemoteIndex;
import net.irext.decoder.cache.IIRBinaryRepository;
import net.irext.decoder.model.RemoteIndex;
import net.irext.decoder.utils.FileUtil;
import net.irext.decoder.utils.LoggerUtil;
import net.irext.decoder.utils.MD5Util;
@@ -44,7 +43,7 @@ public class DecodeLogic {
return decodeLogic;
}
public byte[] openIRBinary(ServletContext context, IIRBinaryRepository irBinaryRepository,
public RemoteIndex openIRBinary(ServletContext context, IIRBinaryRepository irBinaryRepository,
RemoteIndex remoteIndex) {
if (null == remoteIndex) {
return null;
@@ -56,15 +55,16 @@ public class DecodeLogic {
LoggerUtil.getInstance().trace(TAG, "checksum for remoteIndex " +
remoteIndex.getId() + " = " + checksum);
byte[] binaries = irBinaryRepository.find(remoteIndex.getId());
if (null != binaries) {
LoggerUtil.getInstance().trace(TAG, "binary content fetched from redis : " + binaries.length);
RemoteIndex cachedRemoteIndex = irBinaryRepository.find(remoteIndex.getId());
if (null != cachedRemoteIndex) {
LoggerUtil.getInstance().trace(TAG, "binary content fetched from redis : " +
cachedRemoteIndex.getRemoteMap());
// validate binary content
String cachedChecksum =
MD5Util.byteArrayToHexString(MessageDigest.getInstance("MD5")
.digest(binaries)).toUpperCase();
.digest(cachedRemoteIndex.getBinaries())).toUpperCase();
if (cachedChecksum.equals(checksum)) {
return binaries;
return cachedRemoteIndex;
}
}
@@ -79,9 +79,9 @@ public class DecodeLogic {
if (null != fin) {
byte[] newBinaries = IOUtils.toByteArray(fin);
LoggerUtil.getInstance().trace(TAG, "binary content get, save it to redis");
irBinaryRepository.add(remoteIndex.getId(), newBinaries);
return binaries;
remoteIndex.setBinaries(newBinaries);
irBinaryRepository.add(remoteIndex.getId(), remoteIndex);
return remoteIndex;
}
} else {
LoggerUtil.getInstance().trace(TAG, "servlet context is null");
@@ -94,20 +94,24 @@ public class DecodeLogic {
}
public int[] decode(IIRBinaryRepository irBinaryRepository, IDecodeSessionRepository decodeSessionRepository,
String sessionId, int remoteIndexId, ACStatus acStatus, int keyCode, int changeWindDirection) {
String sessionId, int remoteIndexId, ACStatus acStatus, int keyCode, int changeWindDirection) {
// since the binary is already opened and probably cached to redis, we just need to load it
Integer cachedRemoteIndexId = decodeSessionRepository.find(sessionId);
int []decoded = null;
int[] decoded = null;
if (null != cachedRemoteIndexId) {
byte[] remoteBinary = irBinaryRepository.find(cachedRemoteIndexId);
IRDecode irDecode = IRDecode.getInstance();
int ret = 0;
// int ret = irDecode.openBinary(categoryId, subCate, binaryContent, binaryContent.length);
if (0 == ret) {
decoded = irDecode.decodeBinary(keyCode, acStatus, changeWindDirection);
RemoteIndex cachedRemoteIndex = irBinaryRepository.find(cachedRemoteIndexId);
if (null != cachedRemoteIndex) {
int categoryId = cachedRemoteIndex.getCategoryId();
int subCate = cachedRemoteIndex.getSubCate();
byte[] binaryContent = cachedRemoteIndex.getBinaries();
IRDecode irDecode = IRDecode.getInstance();
int ret = irDecode.openBinary(categoryId, subCate, binaryContent, binaryContent.length);
if (0 == ret) {
decoded = irDecode.decodeBinary(keyCode, acStatus, changeWindDirection);
}
irDecode.closeBinary();
return decoded;
}
irDecode.closeBinary();
return decoded;
} else {
LoggerUtil.getInstance().trace(TAG, "session cache missed, need to re-open binary");
}
@@ -124,7 +128,7 @@ public class DecodeLogic {
if (binFile.exists()) {
FileInputStream fileInputStream = new FileInputStream(binFile);
// validate binary content
byte []binaries = IOUtils.toByteArray(fileInputStream);
byte[] binaries = IOUtils.toByteArray(fileInputStream);
String fileChecksum =
MD5Util.byteArrayToHexString(MessageDigest.getInstance("MD5").digest(binaries)).toUpperCase();
@@ -135,7 +139,7 @@ public class DecodeLogic {
OSSHelper ossHelper = new OSSHelper();
InputStream inputStream = ossHelper.getOSS2InputStream(OSSHelper.BUCKET_NAME, "", fileName);
// validate binary content
byte []binaries = IOUtils.toByteArray(inputStream);
byte[] binaries = IOUtils.toByteArray(inputStream);
String ossChecksum =
MD5Util.byteArrayToHexString(MessageDigest.getInstance("MD5").digest(binaries)).toUpperCase();
if (ossChecksum.equals(checksum)) {

View File

@@ -1,7 +1,5 @@
package net.irext.decoder.cache;
import net.irext.decoder.model.DecodeSession;
import java.util.Map;
/**

View File

@@ -1,6 +1,6 @@
package net.irext.decoder.cache;
import net.irext.decoder.model.IRBinary;
import net.irext.decoder.model.RemoteIndex;
import java.util.Map;
@@ -16,11 +16,11 @@ import java.util.Map;
*/
public interface IIRBinaryRepository {
Map<Object, Object> findAllIRBinaries();
Map<Object, Object> findAllRemoteIndexes();
void add(Integer id, byte[] binaries);
void add(Integer id, RemoteIndex remoteIndex);
void delete(Integer id);
byte[] find(Integer id);
RemoteIndex find(Integer id);
}

View File

@@ -1,6 +1,5 @@
package net.irext.decoder.cache.impl;
import net.irext.decoder.model.DecodeSession;
import net.irext.decoder.cache.IDecodeSessionRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.HashOperations;

View File

@@ -1,6 +1,7 @@
package net.irext.decoder.cache.impl;
import net.irext.decoder.cache.IIRBinaryRepository;
import net.irext.decoder.model.RemoteIndex;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
@@ -24,7 +25,7 @@ import java.util.Map;
public class IRBinaryRepositoryImpl implements IIRBinaryRepository {
private static final String KEY = "BINARY_KEY";
@Resource(name="redisTemplate")
@Resource(name = "redisTemplate")
private RedisTemplate<String, Object> redisTemplate;
private HashOperations hashOperations;
@@ -38,19 +39,19 @@ public class IRBinaryRepositoryImpl implements IIRBinaryRepository {
hashOperations = redisTemplate.opsForHash();
}
public void add(Integer id, byte[] binaries) {
hashOperations.put(KEY, id, binaries);
public void add(Integer id, RemoteIndex remoteIndex) {
hashOperations.put(KEY, id, remoteIndex);
}
public void delete(final Integer id) {
hashOperations.delete(KEY, id);
}
public byte[] find(final Integer id) {
return (byte[])hashOperations.get(KEY, id);
public RemoteIndex find(final Integer id) {
return (RemoteIndex) hashOperations.get(KEY, id);
}
public Map<Object, Object> findAllIRBinaries() {
public Map<Object, Object> findAllRemoteIndexes() {
return hashOperations.entries(KEY);
}
}

View File

@@ -1,693 +1,255 @@
package net.irext.decoder.model;
public class RemoteIndex {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column remote_index.id
*
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
private Integer id;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column remote_index.category_id
*
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
private Integer categoryId;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column remote_index.category_name
*
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
private String categoryName;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column remote_index.brand_id
*
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
private Integer brandId;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column remote_index.brand_name
*
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
private String brandName;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column remote_index.city_code
*
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
private String cityCode;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column remote_index.city_name
*
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
private String cityName;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column remote_index.operator_id
*
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
private String operatorId;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column remote_index.operator_name
*
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
private String operatorName;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column remote_index.protocol
*
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
private String protocol;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column remote_index.remote
*
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
private String remote;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column remote_index.remote_map
*
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
private String remoteMap;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column remote_index.status
*
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
private Byte status;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column remote_index.sub_cate
*
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
private Byte subCate;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column remote_index.priority
*
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
private Integer priority;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column remote_index.remote_number
*
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
private String remoteNumber;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column remote_index.operator_name_tw
*
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
private String operatorNameTw;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column remote_index.category_name_tw
*
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
private String categoryNameTw;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column remote_index.brand_name_tw
*
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
private String brandNameTw;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column remote_index.city_name_tw
*
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
private String cityNameTw;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column remote_index.binary_md5
*
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
private String binaryMd5;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column remote_index.contributor
*
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
private String contributor;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column remote_index.update_time
*
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
private String updateTime;
private byte[] binaries;
public RemoteIndex(Integer id, Integer categoryId, String categoryName, Integer brandId, String brandName,
String cityCode, String cityName, String operatorId, String operatorName, String protocol,
String remote, String remoteMap, Byte status, Byte subCate, Integer priority,
String remoteNumber, String operatorNameTw, String categoryNameTw, String brandNameTw,
String cityNameTw, String binaryMd5, String contributor, String updateTime, byte[] binaries) {
this.id = id;
this.categoryId = categoryId;
this.categoryName = categoryName;
this.brandId = brandId;
this.brandName = brandName;
this.cityCode = cityCode;
this.cityName = cityName;
this.operatorId = operatorId;
this.operatorName = operatorName;
this.protocol = protocol;
this.remote = remote;
this.remoteMap = remoteMap;
this.status = status;
this.subCate = subCate;
this.priority = priority;
this.remoteNumber = remoteNumber;
this.operatorNameTw = operatorNameTw;
this.categoryNameTw = categoryNameTw;
this.brandNameTw = brandNameTw;
this.cityNameTw = cityNameTw;
this.binaryMd5 = binaryMd5;
this.contributor = contributor;
this.updateTime = updateTime;
this.binaries = binaries;
}
public RemoteIndex() {
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column remote_index.id
*
* @return the value of remote_index.id
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public Integer getId() {
return id;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column remote_index.id
*
* @param id the value for remote_index.id
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public void setId(Integer id) {
this.id = id;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column remote_index.category_id
*
* @return the value of remote_index.category_id
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public Integer getCategoryId() {
return categoryId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column remote_index.category_id
*
* @param categoryId the value for remote_index.category_id
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public void setCategoryId(Integer categoryId) {
this.categoryId = categoryId;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column remote_index.category_name
*
* @return the value of remote_index.category_name
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public String getCategoryName() {
return categoryName;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column remote_index.category_name
*
* @param categoryName the value for remote_index.category_name
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column remote_index.brand_id
*
* @return the value of remote_index.brand_id
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public Integer getBrandId() {
return brandId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column remote_index.brand_id
*
* @param brandId the value for remote_index.brand_id
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public void setBrandId(Integer brandId) {
this.brandId = brandId;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column remote_index.brand_name
*
* @return the value of remote_index.brand_name
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public String getBrandName() {
return brandName;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column remote_index.brand_name
*
* @param brandName the value for remote_index.brand_name
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public void setBrandName(String brandName) {
this.brandName = brandName;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column remote_index.city_code
*
* @return the value of remote_index.city_code
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public String getCityCode() {
return cityCode;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column remote_index.city_code
*
* @param cityCode the value for remote_index.city_code
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public void setCityCode(String cityCode) {
this.cityCode = cityCode;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column remote_index.city_name
*
* @return the value of remote_index.city_name
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public String getCityName() {
return cityName;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column remote_index.city_name
*
* @param cityName the value for remote_index.city_name
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public void setCityName(String cityName) {
this.cityName = cityName;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column remote_index.operator_id
*
* @return the value of remote_index.operator_id
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public String getOperatorId() {
return operatorId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column remote_index.operator_id
*
* @param operatorId the value for remote_index.operator_id
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public void setOperatorId(String operatorId) {
this.operatorId = operatorId;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column remote_index.operator_name
*
* @return the value of remote_index.operator_name
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public String getOperatorName() {
return operatorName;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column remote_index.operator_name
*
* @param operatorName the value for remote_index.operator_name
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public void setOperatorName(String operatorName) {
this.operatorName = operatorName;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column remote_index.protocol
*
* @return the value of remote_index.protocol
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public String getProtocol() {
return protocol;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column remote_index.protocol
*
* @param protocol the value for remote_index.protocol
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public void setProtocol(String protocol) {
this.protocol = protocol;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column remote_index.remote
*
* @return the value of remote_index.remote
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public String getRemote() {
return remote;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column remote_index.remote
*
* @param remote the value for remote_index.remote
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public void setRemote(String remote) {
this.remote = remote;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column remote_index.remote_map
*
* @return the value of remote_index.remote_map
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public String getRemoteMap() {
return remoteMap;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column remote_index.remote_map
*
* @param remoteMap the value for remote_index.remote_map
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public void setRemoteMap(String remoteMap) {
this.remoteMap = remoteMap;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column remote_index.status
*
* @return the value of remote_index.status
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public Byte getStatus() {
return status;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column remote_index.status
*
* @param status the value for remote_index.status
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public void setStatus(Byte status) {
this.status = status;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column remote_index.sub_cate
*
* @return the value of remote_index.sub_cate
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public Byte getSubCate() {
return subCate;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column remote_index.sub_cate
*
* @param subCate the value for remote_index.sub_cate
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public void setSubCate(Byte subCate) {
this.subCate = subCate;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column remote_index.priority
*
* @return the value of remote_index.priority
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public Integer getPriority() {
return priority;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column remote_index.priority
*
* @param priority the value for remote_index.priority
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public void setPriority(Integer priority) {
this.priority = priority;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column remote_index.remote_number
*
* @return the value of remote_index.remote_number
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public String getRemoteNumber() {
return remoteNumber;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column remote_index.remote_number
*
* @param remoteNumber the value for remote_index.remote_number
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public void setRemoteNumber(String remoteNumber) {
this.remoteNumber = remoteNumber;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column remote_index.operator_name_tw
*
* @return the value of remote_index.operator_name_tw
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public String getOperatorNameTw() {
return operatorNameTw;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column remote_index.operator_name_tw
*
* @param operatorNameTw the value for remote_index.operator_name_tw
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public void setOperatorNameTw(String operatorNameTw) {
this.operatorNameTw = operatorNameTw;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column remote_index.category_name_tw
*
* @return the value of remote_index.category_name_tw
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public String getCategoryNameTw() {
return categoryNameTw;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column remote_index.category_name_tw
*
* @param categoryNameTw the value for remote_index.category_name_tw
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public void setCategoryNameTw(String categoryNameTw) {
this.categoryNameTw = categoryNameTw;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column remote_index.brand_name_tw
*
* @return the value of remote_index.brand_name_tw
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public String getBrandNameTw() {
return brandNameTw;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column remote_index.brand_name_tw
*
* @param brandNameTw the value for remote_index.brand_name_tw
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public void setBrandNameTw(String brandNameTw) {
this.brandNameTw = brandNameTw;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column remote_index.city_name_tw
*
* @return the value of remote_index.city_name_tw
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public String getCityNameTw() {
return cityNameTw;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column remote_index.city_name_tw
*
* @param cityNameTw the value for remote_index.city_name_tw
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public void setCityNameTw(String cityNameTw) {
this.cityNameTw = cityNameTw;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column remote_index.binary_md5
*
* @return the value of remote_index.binary_md5
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public String getBinaryMd5() {
return binaryMd5;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column remote_index.binary_md5
*
* @param binaryMd5 the value for remote_index.binary_md5
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public void setBinaryMd5(String binaryMd5) {
this.binaryMd5 = binaryMd5;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column remote_index.contributor
*
* @return the value of remote_index.contributor
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public String getContributor() {
return contributor;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column remote_index.contributor
*
* @param contributor the value for remote_index.contributor
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public void setContributor(String contributor) {
this.contributor = contributor;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column remote_index.update_time
*
* @return the value of remote_index.update_time
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public String getUpdateTime() {
return updateTime;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column remote_index.update_time
*
* @param updateTime the value for remote_index.update_time
* @mbggenerated Thu May 04 12:06:44 CST 2017
*/
public void setUpdateTime(String updateTime) {
this.updateTime = updateTime;
}
public byte[] getBinaries() {
return binaries;
}
public void setBinaries(byte[] binaries) {
this.binaries = binaries;
}
}

View File

@@ -1,12 +1,12 @@
package net.irext.decoder.queue;
import java.util.ArrayList;
import java.util.List;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* Filename: MessageSubscriber.java
* Revised: Date: 2018-12-29

View File

@@ -2,11 +2,11 @@ package net.irext.decoder.service;
import net.irext.decoder.businesslogic.DecodeLogic;
import net.irext.decoder.businesslogic.IndexLogic;
import net.irext.decoder.cache.IDecodeSessionRepository;
import net.irext.decoder.cache.IIRBinaryRepository;
import net.irext.decoder.mapper.RemoteIndexMapper;
import net.irext.decoder.model.DecodeSession;
import net.irext.decoder.model.RemoteIndex;
import net.irext.decoder.cache.IDecodeSessionRepository;
import net.irext.decoder.cache.IIRBinaryRepository;
import net.irext.decoder.request.CloseRequest;
import net.irext.decoder.request.DecodeRequest;
import net.irext.decoder.request.OpenRequest;
@@ -21,7 +21,10 @@ import net.irext.decodesdk.bean.ACStatus;
import net.irext.decodesdk.utils.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
@@ -64,7 +67,7 @@ public class IRDecodeService extends AbstractBaseService {
try {
int remoteIndexId = openRequest.getRemoteIndexId();
LoggerUtil.getInstance().trace(TAG,"irOpen API called : " + remoteIndexId);
LoggerUtil.getInstance().trace(TAG, "irOpen API called : " + remoteIndexId);
StringResponse response = new StringResponse();
RemoteIndex remoteIndex = IndexLogic.getInstance(remoteIndexMapper).getRemoteIndex(remoteIndexId);
@@ -76,10 +79,10 @@ public class IRDecodeService extends AbstractBaseService {
LoggerUtil.getInstance().trace(TAG, "remoteIndex get : " + remoteIndex.getId() + ", " +
remoteIndex.getRemoteMap());
}
byte []binaryContent = DecodeLogic.getInstance().openIRBinary(context, irBinaryRepository, remoteIndex);
byte[] binaryContent = DecodeLogic.getInstance().openIRBinary(context, irBinaryRepository, remoteIndex);
if (null != binaryContent) {
LoggerUtil.getInstance().trace(TAG,"binary content fetched : " + binaryContent.length);
LoggerUtil.getInstance().trace(TAG, "binary content fetched : " + binaryContent.length);
// construct a session with this binary
String address = request.getRemoteAddr();
LoggerUtil.getInstance().trace(TAG, "request Address = " + address);

View File

@@ -5,8 +5,6 @@ import net.irext.decoder.response.ServiceResponse;
import net.irext.decoder.response.Status;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* Filename: AbstractBaseService.java

View File

@@ -90,7 +90,7 @@ public class FileUtil {
if (f.isDirectory()) {
deleteAllFiles(f);
try {
if(!f.delete()) {
if (!f.delete()) {
System.out.println("failed to delete file");
}
} catch (Exception e) {
@@ -100,7 +100,7 @@ public class FileUtil {
if (f.exists()) {
deleteAllFiles(f);
try {
if(!f.delete()) {
if (!f.delete()) {
System.out.println("failed to delete file");
}
} catch (Exception e) {

View File

@@ -1,6 +1,5 @@
package net.irext.decoder.utils;
import net.irext.decoder.service.IRDecodeService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

View File

@@ -66,7 +66,7 @@ public class IRDecode {
}
public int[] decodeBinary(int keyCode, ACStatus acStatus, int changeWindDir) {
int []decoded;
int[] decoded;
synchronized (mSync) {
if (null == acStatus) {
acStatus = new ACStatus();
@@ -86,7 +86,7 @@ public class IRDecode {
public int[] getACSupportedMode() {
// cool, heat, auto, fan, de-humidification
int []retSupportedMode = {0, 0, 0, 0, 0};
int[] retSupportedMode = {0, 0, 0, 0, 0};
int supportedMode = irACGetSupportedMode();
for (int i = Constants.ACMode.MODE_COOL.getValue(); i <=
Constants.ACMode.MODE_DEHUMIDITY.getValue(); i++) {
@@ -97,7 +97,7 @@ public class IRDecode {
public int[] getACSupportedWindSpeed(int acMode) {
// auto, low, medium, high
int []retSupportedWindSpeed = {0, 0, 0, 0};
int[] retSupportedWindSpeed = {0, 0, 0, 0};
int supportedWindSpeed = irACGetSupportedWindSpeed(acMode);
for (int i = Constants.ACWindSpeed.SPEED_AUTO.getValue();
i <= Constants.ACWindSpeed.SPEED_HIGH.getValue();
@@ -109,7 +109,7 @@ public class IRDecode {
public int[] getACSupportedSwing(int acMode) {
// swing-on, swing-off
int []retSupportedSwing= {0, 0};
int[] retSupportedSwing = {0, 0};
int supportedSwing = irACGetSupportedSwing(acMode);
for (int i = Constants.ACSwing.SWING_ON.getValue();
i <= Constants.ACSwing.SWING_OFF.getValue();

View File

@@ -1,9 +1,7 @@
server.port=8082
spring.cache.type=redis
spring.redis.host=localhost
spring.redis.port=6379
spring.datasource.url=jdbc:mysql://localhost:3306/irext?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=root

View File

@@ -3,7 +3,7 @@
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout
pattern="%style{%d{ISO8601}}{black} %highlight{%-5level }[%style{%t}{bright,blue}] %style{%C{1.}}{bright,yellow}: %msg%n%throwable" />
pattern="%style{%d{ISO8601}}{black} %highlight{%-5level }[%style{%t}{bright,blue}] %style{%C{1.}}{bright,yellow}: %msg%n%throwable"/>
</Console>
<RollingFile name="RollingFile"
@@ -15,10 +15,10 @@
<Policies>
<!-- rollover on startup, daily and when the file reaches
10 MegaBytes -->
<OnStartupTriggeringPolicy />
<OnStartupTriggeringPolicy/>
<SizeBasedTriggeringPolicy
size="10 MB" />
<TimeBasedTriggeringPolicy />
size="10 MB"/>
<TimeBasedTriggeringPolicy/>
</Policies>
</RollingFile>
</Appenders>
@@ -26,8 +26,8 @@
<Loggers>
<!-- LOG everything at INFO level -->
<Root level="info">
<AppenderRef ref="Console" />
<AppenderRef ref="RollingFile" />
<AppenderRef ref="Console"/>
<AppenderRef ref="RollingFile"/>
</Root>
<!-- LOG "com.baeldung*" at TRACE level -->