Skip to content

Commit

Permalink
Seperate all receiver and querier module export port
Browse files Browse the repository at this point in the history
  • Loading branch information
mrproliu committed Oct 10, 2023
1 parent aad1f03 commit d0c3df5
Show file tree
Hide file tree
Showing 8 changed files with 314 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,71 @@
import org.apache.skywalking.oap.server.library.module.ModuleConfig;

public class HealthQueryConfig extends ModuleConfig {
private String restHost;
private int restPort;
private String restContextPath;
private int restMaxThreads = 200;
private long restIdleTimeOut = 30000;
private int restAcceptQueueSize = 0;
/**
* The maximum size in bytes allowed for request headers.
* Use -1 to disable it.
*/
private int restMaxRequestHeaderSize = 8192;

public String getRestHost() {
return restHost;
}

public void setRestHost(String restHost) {
this.restHost = restHost;
}

public int getRestPort() {
return restPort;
}

public void setRestPort(int restPort) {
this.restPort = restPort;
}

public String getRestContextPath() {
return restContextPath;
}

public void setRestContextPath(String restContextPath) {
this.restContextPath = restContextPath;
}

public int getRestMaxThreads() {
return restMaxThreads;
}

public void setRestMaxThreads(int restMaxThreads) {
this.restMaxThreads = restMaxThreads;
}

public long getRestIdleTimeOut() {
return restIdleTimeOut;
}

public void setRestIdleTimeOut(long restIdleTimeOut) {
this.restIdleTimeOut = restIdleTimeOut;
}

public int getRestAcceptQueueSize() {
return restAcceptQueueSize;
}

public void setRestAcceptQueueSize(int restAcceptQueueSize) {
this.restAcceptQueueSize = restAcceptQueueSize;
}

public int getRestMaxRequestHeaderSize() {
return restMaxRequestHeaderSize;
}

public void setRestMaxRequestHeaderSize(int restMaxRequestHeaderSize) {
this.restMaxRequestHeaderSize = restMaxRequestHeaderSize;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@
import org.apache.skywalking.oap.server.library.module.ModuleProvider;
import org.apache.skywalking.oap.server.library.module.ModuleStartException;
import org.apache.skywalking.oap.server.library.module.ServiceNotProvidedException;
import org.apache.skywalking.oap.server.library.server.http.HTTPServer;
import org.apache.skywalking.oap.server.library.server.http.HTTPServerConfig;

import java.util.Collections;

public class HealthQueryProvider extends ModuleProvider {
private HealthQueryConfig moduleConfig;
private HTTPServer httpServer;
@Override
public String name() {
return "zipkin";
Expand All @@ -46,25 +50,47 @@ public Class<HealthQueryConfig> type() {

@Override
public void onInitialized(HealthQueryConfig initialized) {
moduleConfig = initialized;
}
};
}

@Override
public void prepare() throws ServiceNotProvidedException, ModuleStartException {
if (moduleConfig.getRestPort() > 0) {
HTTPServerConfig httpServerConfig = HTTPServerConfig.builder()
.host(moduleConfig.getRestHost())
.port(moduleConfig.getRestPort())
.contextPath(moduleConfig.getRestContextPath())
.idleTimeOut(moduleConfig.getRestIdleTimeOut())
.maxThreads(moduleConfig.getRestMaxThreads())
.acceptQueueSize(moduleConfig.getRestAcceptQueueSize())
.maxRequestHeaderSize(moduleConfig.getRestMaxRequestHeaderSize())
.build();
httpServer = new HTTPServer(httpServerConfig);
httpServer.initialize();
}
}

@Override
public void start() throws ServiceNotProvidedException, ModuleStartException {
getManager().find(CoreModule.NAME).provider()
.getService(HTTPHandlerRegister.class).addHandler(
new ZipkinHealthHandler(getManager()),
Collections.singletonList(HttpMethod.GET)
);
if (httpServer != null) {
httpServer.addHandler(new ZipkinHealthHandler(getManager()),
Collections.singletonList(HttpMethod.GET));
} else {
getManager().find(CoreModule.NAME).provider()
.getService(HTTPHandlerRegister.class).addHandler(
new ZipkinHealthHandler(getManager()),
Collections.singletonList(HttpMethod.GET)
);
}
}

@Override
public void notifyAfterCompleted() throws ServiceNotProvidedException, ModuleStartException {
if (httpServer != null) {
httpServer.start();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@
import org.apache.skywalking.oap.server.library.module.ModuleConfig;

public class HTTPQueryConfig extends ModuleConfig {
private String restHost;
private int restPort;
private String restContextPath;
private int restMaxThreads = 200;
private long restIdleTimeOut = 30000;
private int restAcceptQueueSize = 0;
/**
* The maximum size in bytes allowed for request headers.
* Use -1 to disable it.
*/
private int restMaxRequestHeaderSize = 8192;

private boolean strictTraceId = true;
private long lookback = 86400000L;
private int namesMaxAge = 300;
Expand Down Expand Up @@ -92,4 +104,60 @@ public boolean getStrictTraceId() {
public void setStrictTraceId(boolean strictTraceId) {
this.strictTraceId = strictTraceId;
}

public String getRestHost() {
return restHost;
}

public void setRestHost(String restHost) {
this.restHost = restHost;
}

public int getRestPort() {
return restPort;
}

public void setRestPort(int restPort) {
this.restPort = restPort;
}

public String getRestContextPath() {
return restContextPath;
}

public void setRestContextPath(String restContextPath) {
this.restContextPath = restContextPath;
}

public int getRestMaxThreads() {
return restMaxThreads;
}

public void setRestMaxThreads(int restMaxThreads) {
this.restMaxThreads = restMaxThreads;
}

public long getRestIdleTimeOut() {
return restIdleTimeOut;
}

public void setRestIdleTimeOut(long restIdleTimeOut) {
this.restIdleTimeOut = restIdleTimeOut;
}

public int getRestAcceptQueueSize() {
return restAcceptQueueSize;
}

public void setRestAcceptQueueSize(int restAcceptQueueSize) {
this.restAcceptQueueSize = restAcceptQueueSize;
}

public int getRestMaxRequestHeaderSize() {
return restMaxRequestHeaderSize;
}

public void setRestMaxRequestHeaderSize(int restMaxRequestHeaderSize) {
this.restMaxRequestHeaderSize = restMaxRequestHeaderSize;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@
import org.apache.skywalking.oap.server.library.module.ModuleProvider;
import org.apache.skywalking.oap.server.library.module.ModuleStartException;
import org.apache.skywalking.oap.server.library.module.ServiceNotProvidedException;
import org.apache.skywalking.oap.server.library.server.http.HTTPServer;
import org.apache.skywalking.oap.server.library.server.http.HTTPServerConfig;

import java.util.Collections;

public class HTTPQueryProvider extends ModuleProvider {
private HTTPQueryConfig moduleConfig;
private HTTPServer httpServer;
@Override
public String name() {
return "zipkin";
Expand Down Expand Up @@ -55,21 +58,40 @@ public void onInitialized(HTTPQueryConfig initialized) {

@Override
public void prepare() throws ServiceNotProvidedException, ModuleStartException {

if (moduleConfig.getRestPort() > 0) {
HTTPServerConfig httpServerConfig = HTTPServerConfig.builder()
.host(moduleConfig.getRestHost())
.port(moduleConfig.getRestPort())
.contextPath(moduleConfig.getRestContextPath())
.idleTimeOut(moduleConfig.getRestIdleTimeOut())
.maxThreads(moduleConfig.getRestMaxThreads())
.acceptQueueSize(moduleConfig.getRestAcceptQueueSize())
.maxRequestHeaderSize(moduleConfig.getRestMaxRequestHeaderSize())
.build();
httpServer = new HTTPServer(httpServerConfig);
httpServer.initialize();
}
}

@Override
public void start() throws ServiceNotProvidedException, ModuleStartException {
getManager().find(CoreModule.NAME).provider()
.getService(HTTPHandlerRegister.class).addHandler(
new HTTPQueryHandler(moduleConfig, getManager()),
Collections.singletonList(HttpMethod.GET)
);
if (httpServer != null) {
httpServer.addHandler(new HTTPQueryHandler(moduleConfig, getManager()),
Collections.singletonList(HttpMethod.GET));
} else {
getManager().find(CoreModule.NAME).provider()
.getService(HTTPHandlerRegister.class).addHandler(
new HTTPQueryHandler(moduleConfig, getManager()),
Collections.singletonList(HttpMethod.GET)
);
}
}

@Override
public void notifyAfterCompleted() throws ServiceNotProvidedException, ModuleStartException {

if (httpServer != null) {
httpServer.start();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,71 @@
import org.apache.skywalking.oap.server.library.module.ModuleConfig;

public class ZipkinHTTPReceiverConfig extends ModuleConfig {
private String restHost;
private int restPort;
private String restContextPath;
private int restMaxThreads = 200;
private long restIdleTimeOut = 30000;
private int restAcceptQueueSize = 0;
/**
* The maximum size in bytes allowed for request headers.
* Use -1 to disable it.
*/
private int restMaxRequestHeaderSize = 8192;

public String getRestHost() {
return restHost;
}

public void setRestHost(String restHost) {
this.restHost = restHost;
}

public int getRestPort() {
return restPort;
}

public void setRestPort(int restPort) {
this.restPort = restPort;
}

public String getRestContextPath() {
return restContextPath;
}

public void setRestContextPath(String restContextPath) {
this.restContextPath = restContextPath;
}

public int getRestMaxThreads() {
return restMaxThreads;
}

public void setRestMaxThreads(int restMaxThreads) {
this.restMaxThreads = restMaxThreads;
}

public long getRestIdleTimeOut() {
return restIdleTimeOut;
}

public void setRestIdleTimeOut(long restIdleTimeOut) {
this.restIdleTimeOut = restIdleTimeOut;
}

public int getRestAcceptQueueSize() {
return restAcceptQueueSize;
}

public void setRestAcceptQueueSize(int restAcceptQueueSize) {
this.restAcceptQueueSize = restAcceptQueueSize;
}

public int getRestMaxRequestHeaderSize() {
return restMaxRequestHeaderSize;
}

public void setRestMaxRequestHeaderSize(int restMaxRequestHeaderSize) {
this.restMaxRequestHeaderSize = restMaxRequestHeaderSize;
}
}
Loading

0 comments on commit d0c3df5

Please sign in to comment.