move NetUtils for refaction.
This commit is contained in:
parent
5e5944833d
commit
293981f2a2
|
|
@ -1,8 +1,7 @@
|
|||
package com.a.eye.skywalking.storage.util;
|
||||
package com.a.eye.skywalking.registry.assist;
|
||||
|
||||
import com.a.eye.skywalking.logging.api.ILog;
|
||||
import com.a.eye.skywalking.logging.api.LogManager;
|
||||
import com.a.eye.skywalking.storage.config.Config;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
|
|
@ -71,8 +70,4 @@ public class NetUtils {
|
|||
// 不能是0.0.0.0 也不能是127.0.0.1 并且还得符合IP的正则
|
||||
return (name != null && !ANYHOST.equals(name) && !LOCALHOST.equals(name) && IP_PATTERN.matcher(name).matches());
|
||||
}
|
||||
|
||||
public static int getIndexServerPort(){
|
||||
return Config.Server.PORT + 1000;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1
|
||||
|
|
@ -16,7 +16,7 @@ import com.a.eye.skywalking.storage.data.file.DataFilesManager;
|
|||
import com.a.eye.skywalking.storage.data.index.IndexOperatorFactory;
|
||||
import com.a.eye.skywalking.storage.listener.SearchListener;
|
||||
import com.a.eye.skywalking.storage.listener.StorageListener;
|
||||
import com.a.eye.skywalking.storage.util.NetUtils;
|
||||
import com.a.eye.skywalking.registry.assist.NetUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
|
@ -43,7 +43,7 @@ public class Main {
|
|||
initConfig();
|
||||
HealthCollector.init(SERVER_REPORTER_NAME);
|
||||
|
||||
new ElasticBootstrap().boot(NetUtils.getIndexServerPort());
|
||||
new ElasticBootstrap().boot();
|
||||
IndexOperatorFactory.initOperatorPool();
|
||||
|
||||
DataFilesManager.init();
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.a.eye.skywalking.storage.boot;
|
|||
|
||||
import com.a.eye.skywalking.logging.api.ILog;
|
||||
import com.a.eye.skywalking.logging.api.LogManager;
|
||||
import com.a.eye.skywalking.storage.config.Config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
|
@ -22,7 +23,8 @@ public class ElasticBootstrap {
|
|||
this.elasticHome = fetchElasticHome();
|
||||
}
|
||||
|
||||
public void boot(int port) throws IOException {
|
||||
public void boot() throws IOException {
|
||||
int port = getIndexServerPort();
|
||||
ElasticConfigModifier modifier = new ElasticConfigModifier(elasticHome);
|
||||
modifier.replaceConfig(port);
|
||||
|
||||
|
|
@ -48,4 +50,9 @@ public class ElasticBootstrap {
|
|||
public String fetchElasticHome() {
|
||||
return System.getProperty(DATA_INDEX_HOME, DEVELOP_RUNTIME_ELASTIC_HOME);
|
||||
}
|
||||
|
||||
public static int getIndexServerPort(){
|
||||
return Config.Server.PORT + 1000;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
package com.a.eye.skywalking.storage.data.index;
|
||||
|
||||
import com.a.eye.skywalking.storage.boot.ElasticBootstrap;
|
||||
import com.a.eye.skywalking.storage.config.Config;
|
||||
import com.a.eye.skywalking.storage.data.exception.BorrowIndexOperatorFromPoolFailedException;
|
||||
import com.a.eye.skywalking.storage.data.exception.IndexOperatorInitializeFailedException;
|
||||
import com.a.eye.skywalking.storage.util.NetUtils;
|
||||
import com.a.eye.skywalking.registry.assist.NetUtils;
|
||||
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
||||
|
|
@ -18,7 +19,7 @@ public class IndexOperatorFactory {
|
|||
public static IndexOperator createIndexOperator() {
|
||||
try {
|
||||
return new IndexOperator(new PreBuiltTransportClient(Settings.EMPTY).addTransportAddress(
|
||||
new InetSocketTransportAddress(InetAddress.getLoopbackAddress(), NetUtils.getIndexServerPort()
|
||||
new InetSocketTransportAddress(InetAddress.getLoopbackAddress(), ElasticBootstrap.getIndexServerPort()
|
||||
)));
|
||||
} catch (Exception e) {
|
||||
throw new IndexOperatorInitializeFailedException("Failed to initialize operator.", e);
|
||||
|
|
|
|||
|
|
@ -1,16 +1,14 @@
|
|||
import com.a.eye.skywalking.network.Client;
|
||||
import com.a.eye.skywalking.network.grpc.AckSpan;
|
||||
import com.a.eye.skywalking.network.grpc.RequestSpan;
|
||||
import com.a.eye.skywalking.network.grpc.SendResult;
|
||||
import com.a.eye.skywalking.network.grpc.TraceId;
|
||||
import com.a.eye.skywalking.network.grpc.client.SpanStorageClient;
|
||||
import com.a.eye.skywalking.network.listener.client.StorageClientListener;
|
||||
import com.a.eye.skywalking.storage.util.NetUtils;
|
||||
import com.a.eye.skywalking.registry.assist.NetUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.locks.LockSupport;
|
||||
|
||||
public class StorageThread extends Thread {
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import com.a.eye.skywalking.network.grpc.RequestSpan;
|
|||
import com.a.eye.skywalking.network.grpc.TraceId;
|
||||
import com.a.eye.skywalking.storage.data.file.DataFileNameDesc;
|
||||
import com.a.eye.skywalking.storage.data.spandata.RequestSpanData;
|
||||
import com.a.eye.skywalking.storage.util.NetUtils;
|
||||
import com.a.eye.skywalking.registry.assist.NetUtils;
|
||||
import org.elasticsearch.client.transport.TransportClient;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
||||
|
|
|
|||
Loading…
Reference in New Issue