mirror of https://github.com/longtai-cn/hippo4j
commit
7f99067fe0
@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package cn.hippo4j.common.model;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Web ip and port info
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Slf4j
|
||||||
|
public class WebIpAndPortInfo {
|
||||||
|
|
||||||
|
protected static final String ALL = "*";
|
||||||
|
|
||||||
|
protected static final String SPOT = "\\.";
|
||||||
|
|
||||||
|
protected static final String COLON = ":";
|
||||||
|
|
||||||
|
private String ip;
|
||||||
|
|
||||||
|
private String port;
|
||||||
|
|
||||||
|
private String[] ipSegment;
|
||||||
|
|
||||||
|
public WebIpAndPortInfo(String ip, String port) {
|
||||||
|
this.ip = ip;
|
||||||
|
this.port = port;
|
||||||
|
this.ipSegment = ip.split(SPOT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WebIpAndPortInfo build(String node) {
|
||||||
|
if (ALL.equals(node)) {
|
||||||
|
return new WebIpAndPortInfo(ALL, ALL);
|
||||||
|
}
|
||||||
|
String[] ipPort = node.split(COLON);
|
||||||
|
if (ipPort.length != 2) {
|
||||||
|
log.error("The IP address format is error : {}", node);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new WebIpAndPortInfo(ipPort[0], ipPort[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check.
|
||||||
|
*
|
||||||
|
* @param appIpSegment application ip segment
|
||||||
|
* @param port application port
|
||||||
|
*/
|
||||||
|
public boolean check(String[] appIpSegment, String port) {
|
||||||
|
return checkPort(port) && checkIp(appIpSegment);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check ip.
|
||||||
|
*
|
||||||
|
* @param appIpSegment application ip segment
|
||||||
|
*/
|
||||||
|
protected boolean checkIp(String[] appIpSegment) {
|
||||||
|
if (ALL.equals(this.ip)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
boolean flag = true;
|
||||||
|
for (int i = 0; i < ipSegment.length && flag; i++) {
|
||||||
|
String propIp = ipSegment[i];
|
||||||
|
String appIp = appIpSegment[i];
|
||||||
|
flag = contrastSegment(appIp, propIp);
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check port.
|
||||||
|
*
|
||||||
|
* @param port application port
|
||||||
|
*/
|
||||||
|
protected boolean checkPort(String port) {
|
||||||
|
return contrastSegment(port, this.port);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the strings are the same.
|
||||||
|
*
|
||||||
|
* @param appIp appIp
|
||||||
|
* @param propIp propIp
|
||||||
|
*/
|
||||||
|
protected boolean contrastSegment(String appIp, String propIp) {
|
||||||
|
return ALL.equals(propIp) || appIp.equals(propIp);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
### Default database
|
||||||
|
spring.datasource.driver-class-name=org.h2.Driver
|
||||||
|
spring.datasource.url=jdbc:h2:mem:hippo4j_manager;DB_CLOSE_DELAY=-1;MODE=MySQL;
|
||||||
|
spring.datasource.username=sa
|
||||||
|
spring.datasource.password=sa
|
||||||
|
spring.datasource.schema=classpath:sql-script/h2/hippo4j_manager.sql
|
@ -0,0 +1,5 @@
|
|||||||
|
### Data source customization section
|
||||||
|
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||||
|
spring.datasource.url=jdbc:mysql://localhost:3306/hippo4j_manager?characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8
|
||||||
|
spring.datasource.username=root
|
||||||
|
spring.datasource.password=root
|
2
hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/DynamicThreadPoolCoreAutoConfiguration.java → hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/DynamicThreadPoolAutoConfiguration.java
2
hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/DynamicThreadPoolCoreAutoConfiguration.java → hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/DynamicThreadPoolAutoConfiguration.java
@ -1 +1 @@
|
|||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=cn.hippo4j.config.springboot.starter.config.DynamicThreadPoolCoreAutoConfiguration
|
org.springframework.boot.autoconfigure.EnableAutoConfiguration=cn.hippo4j.config.springboot.starter.config.DynamicThreadPoolAutoConfiguration
|
||||||
|
Loading…
Reference in new issue