提取正则表达式为成员变量,利用Java预编译功能使得匹配更高效
This commit is contained in:
@@ -28,6 +28,8 @@ public class BaseClickhouseData {
|
|||||||
private static HashMap<Integer, HashMap<String, HashMap<String, BaseEdgeDocument>>> eFqdnAddressIpMap = new HashMap<>();
|
private static HashMap<Integer, HashMap<String, HashMap<String, BaseEdgeDocument>>> eFqdnAddressIpMap = new HashMap<>();
|
||||||
private static HashMap<Integer, HashMap<String, HashMap<String, BaseEdgeDocument>>> eIpVisitFqdnMap = new HashMap<>();
|
private static HashMap<Integer, HashMap<String, HashMap<String, BaseEdgeDocument>>> eIpVisitFqdnMap = new HashMap<>();
|
||||||
|
|
||||||
|
private static Pattern pattern = Pattern.compile("^[\\d]*$");
|
||||||
|
|
||||||
private static long[] getTimeLimit() {
|
private static long[] getTimeLimit() {
|
||||||
long maxTime = System.currentTimeMillis() / 1000;
|
long maxTime = System.currentTimeMillis() / 1000;
|
||||||
long minTime = maxTime - 3600;
|
long minTime = maxTime - 3600;
|
||||||
@@ -237,36 +239,13 @@ public class BaseClickhouseData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
private static String commonSchemaGetFqdn(String commonSchemaType, ResultSet resultSet) {
|
|
||||||
String vFqdn = "";
|
|
||||||
try {
|
|
||||||
switch (commonSchemaType) {
|
|
||||||
case "HTTP":
|
|
||||||
vFqdn = resultSet.getString("http_host");
|
|
||||||
break;
|
|
||||||
case "SSL":
|
|
||||||
vFqdn = resultSet.getString("ssl_sni");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
LOG.warn("不支持该类型common_schema_type:" + commonSchemaType);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOG.error(e.getMessage());
|
|
||||||
}
|
|
||||||
if (isDomain(vFqdn)) {
|
|
||||||
return vFqdn;
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isDomain(String fqdn) {
|
private static boolean isDomain(String fqdn) {
|
||||||
try {
|
try {
|
||||||
String[] fqdnArr = fqdn.split("\\.");
|
String[] fqdnArr = fqdn.split("\\.");
|
||||||
if (fqdnArr.length < 4 || fqdnArr.length > 4) {
|
if (fqdnArr.length < 4 || fqdnArr.length > 4) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Pattern pattern = Pattern.compile("^[\\d]*$");
|
|
||||||
for (String f : fqdnArr) {
|
for (String f : fqdnArr) {
|
||||||
if (pattern.matcher(f).matches()) {
|
if (pattern.matcher(f).matches()) {
|
||||||
int i = Integer.parseInt(f);
|
int i = Integer.parseInt(f);
|
||||||
@@ -323,4 +302,27 @@ public class BaseClickhouseData {
|
|||||||
return "SELECT * FROM ((" + sslSql + ") UNION ALL (" + httpSql + "))WHERE FQDN != ''";
|
return "SELECT * FROM ((" + sslSql + ") UNION ALL (" + httpSql + "))WHERE FQDN != ''";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
private static String commonSchemaGetFqdn(String commonSchemaType, ResultSet resultSet) {
|
||||||
|
String vFqdn = "";
|
||||||
|
try {
|
||||||
|
switch (commonSchemaType) {
|
||||||
|
case "HTTP":
|
||||||
|
vFqdn = resultSet.getString("http_host");
|
||||||
|
break;
|
||||||
|
case "SSL":
|
||||||
|
vFqdn = resultSet.getString("ssl_sni");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LOG.warn("不支持该类型common_schema_type:" + commonSchemaType);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error(e.getMessage());
|
||||||
|
}
|
||||||
|
if (isDomain(vFqdn)) {
|
||||||
|
return vFqdn;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user