change: 日常小调整.
This commit is contained in:
@@ -17,7 +17,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||||||
*/
|
*/
|
||||||
public abstract class AbstractConfiguration implements Configuration {
|
public abstract class AbstractConfiguration implements Configuration {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(AbstractConfiguration.class);
|
protected final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||||
protected final Map<String, String> valueMap = new LinkedHashMap<>(16);
|
protected final Map<String, String> valueMap = new LinkedHashMap<>(16);
|
||||||
private final Lock loadLock = new ReentrantLock();
|
private final Lock loadLock = new ReentrantLock();
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ package com.serliunx.ddns.config;
|
|||||||
*/
|
*/
|
||||||
public final class ConfigurationKeys {
|
public final class ConfigurationKeys {
|
||||||
|
|
||||||
private ConfigurationKeys(){throw new UnsupportedOperationException();}
|
private ConfigurationKeys() {throw new UnsupportedOperationException();}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 线程池核心线程数量
|
* 线程池核心线程数量
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
package com.serliunx.ddns.config;
|
package com.serliunx.ddns.config;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@@ -19,8 +16,6 @@ import java.util.Set;
|
|||||||
*/
|
*/
|
||||||
public class PropertiesConfiguration extends FileConfiguration {
|
public class PropertiesConfiguration extends FileConfiguration {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(PropertiesConfiguration.class);
|
|
||||||
|
|
||||||
private Properties properties;
|
private Properties properties;
|
||||||
|
|
||||||
public PropertiesConfiguration(String path) {
|
public PropertiesConfiguration(String path) {
|
||||||
@@ -42,13 +37,13 @@ public class PropertiesConfiguration extends FileConfiguration {
|
|||||||
// 载入配置信息
|
// 载入配置信息
|
||||||
load();
|
load();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.error("配置文件读取出现异常 => {}", e.toString());
|
log.error("配置文件读取出现异常 => {}", e.toString());
|
||||||
}finally {
|
}finally {
|
||||||
if(inputStream != null){
|
if(inputStream != null){
|
||||||
try {
|
try {
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.error("配置文件资源释放出现异常 => {}", e.getMessage());
|
log.error("配置文件资源释放出现异常 => {}", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import static com.serliunx.ddns.util.InstanceUtils.validateInstance;
|
|||||||
*/
|
*/
|
||||||
public abstract class AbstractInstanceContext implements InstanceContext, MultipleSourceInstanceContext {
|
public abstract class AbstractInstanceContext implements InstanceContext, MultipleSourceInstanceContext {
|
||||||
|
|
||||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
protected final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||||
|
|
||||||
private final Set<ListableInstanceFactory> listableInstanceFactories = new HashSet<>();
|
private final Set<ListableInstanceFactory> listableInstanceFactories = new HashSet<>();
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import static com.serliunx.ddns.constant.SystemConstants.XML_ROOT_INSTANCE_NAME;
|
|||||||
@JacksonXmlRootElement(localName = XML_ROOT_INSTANCE_NAME)
|
@JacksonXmlRootElement(localName = XML_ROOT_INSTANCE_NAME)
|
||||||
public abstract class AbstractInstance implements Instance {
|
public abstract class AbstractInstance implements Instance {
|
||||||
|
|
||||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
protected final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 实例名称
|
* 实例名称
|
||||||
|
|||||||
@@ -29,8 +29,6 @@ import static com.serliunx.ddns.constant.SystemConstants.XML_ROOT_INSTANCE_NAME;
|
|||||||
@JacksonXmlRootElement(localName = XML_ROOT_INSTANCE_NAME)
|
@JacksonXmlRootElement(localName = XML_ROOT_INSTANCE_NAME)
|
||||||
public class AliyunInstance extends AbstractInstance {
|
public class AliyunInstance extends AbstractInstance {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(AliyunInstance.class);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AccessKey ID
|
* AccessKey ID
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -24,26 +24,26 @@ public final class NetworkContextHolder {
|
|||||||
private static final Integer IP_CONTEXT_TIME_OUT = 5;
|
private static final Integer IP_CONTEXT_TIME_OUT = 5;
|
||||||
private static volatile String IP_ADDRESS;
|
private static volatile String IP_ADDRESS;
|
||||||
|
|
||||||
private NetworkContextHolder(){throw new UnsupportedOperationException();}
|
private NetworkContextHolder() {throw new UnsupportedOperationException();}
|
||||||
|
|
||||||
public static void setIpAddress(String i) {
|
public static void setIpAddress(String i) {
|
||||||
try {
|
try {
|
||||||
IP_LOCK.lock();
|
IP_LOCK.lock();
|
||||||
IP_ADDRESS = i;
|
IP_ADDRESS = i;
|
||||||
if(IP_CONTEXT_WAIT_LATCH.getCount() > 0){
|
if (IP_CONTEXT_WAIT_LATCH.getCount() > 0) {
|
||||||
IP_CONTEXT_WAIT_LATCH.countDown();
|
IP_CONTEXT_WAIT_LATCH.countDown();
|
||||||
}
|
}
|
||||||
}finally {
|
} finally {
|
||||||
IP_LOCK.unlock();
|
IP_LOCK.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getIpAddress() {
|
public static String getIpAddress() {
|
||||||
if(IP_ADDRESS != null) {
|
if (IP_ADDRESS != null) {
|
||||||
return IP_ADDRESS;
|
return IP_ADDRESS;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if(!IP_CONTEXT_WAIT_LATCH.await(IP_CONTEXT_TIME_OUT, TimeUnit.SECONDS)) {
|
if (!IP_CONTEXT_WAIT_LATCH.await(IP_CONTEXT_TIME_OUT, TimeUnit.SECONDS)) {
|
||||||
log.error("IP地址获取超时.");
|
log.error("IP地址获取超时.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user