Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/en/changes/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* Storage: separate `SpanAttachedEventRecord` for SkyWalking trace and Zipkin trace.
* [Break Change]BanyanDB: Setup new Group policy.
* Bump up commons-beanutils to 1.11.0.
* Refactor: simplify the `Accept` http header process.

#### UI

Expand Down
8 changes: 4 additions & 4 deletions docs/en/status/query_cluster_nodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ This API is used to get the unified and effective TTL configurations.
{
"host": "10.0.12.23",
"port": 11800,
"isSelf": true
"self": true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Fine0830 this protocol is changed.

},
{
"host": "10.0.12.25",
"port": 11800,
"isSelf": false
"self": false
},
{
"host": "10.0.12.37",
"port": 11800,
"isSelf": false
"self": false
}
]
}
```

The `nodes` list all the nodes in the cluster. The size of the list should be exactly same as your cluster setup.
The `host` and `port` are the address of the OAP node, which are used for OAP nodes communicating with each other. The
`isSelf` is a flag to indicate whether the node is the current node, others are remote nodes.
`self` is a flag to indicate whether the node is the current node, others are remote nodes.
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public void prepare() throws ServiceNotProvidedException, ModuleStartException {
httpServer.initialize();

this.registerServiceImplementation(ConfigService.class, new ConfigService(moduleConfig, this));
this.registerServiceImplementation(ServerStatusService.class, new ServerStatusService(getManager(), moduleConfig));
this.registerServiceImplementation(ServerStatusService.class, new ServerStatusService(getManager()));
this.registerServiceImplementation(HierarchyDefinitionService.class, new HierarchyDefinitionService(moduleConfig));
hierarchyService = new HierarchyService(getManager(), moduleConfig);
this.registerServiceImplementation(HierarchyService.class, hierarchyService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@

package org.apache.skywalking.oap.server.core.status;

import com.google.gson.Gson;
import io.vavr.Tuple2;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.skywalking.oap.server.core.CoreModuleConfig;
import org.apache.skywalking.oap.server.library.module.ApplicationConfiguration;
import org.apache.skywalking.oap.server.library.module.ModuleManager;
import org.apache.skywalking.oap.server.library.module.Service;
Expand All @@ -43,7 +40,6 @@
@RequiredArgsConstructor
public class ServerStatusService implements Service {
private final ModuleManager manager;
private final CoreModuleConfig moduleConfig;
@Getter
private BootingStatus bootingStatus = new BootingStatus();
@Getter
Expand Down Expand Up @@ -98,7 +94,7 @@ public ConfigList dumpBootingConfigurations(String keywords4MaskingSecretsOfConf
for (ApplicationConfiguration.ModuleConfiguration configuration : configurations) {
final String moduleName = configuration.getModuleName();
if (configuration.getProviders().size() == 1) {
configList.add(moduleName + ".provider", configuration.getProviders().keySet().iterator().next());
configList.put(moduleName + ".provider", configuration.getProviders().keySet().iterator().next());
}
configuration.getProviders().forEach(
(providerName, providerConfiguration) ->
Expand All @@ -109,41 +105,25 @@ public ConfigList dumpBootingConfigurations(String keywords4MaskingSecretsOfConf
value = "******";
}
}
configList.add(moduleName + "." + providerName + "." + key, value.toString());
configList.put(moduleName + "." + providerName + "." + key, value.toString());
}
)
);
}
return configList;
}

public static class ConfigList {
private final static Gson GSON = new Gson();
private List<Tuple2> configurations = new ArrayList<>(200);

public void add(String key, String value) {
configurations.add(new Tuple2<>(key, value));
}

public static class ConfigList extends HashMap<String, String> {
@Override
public String toString() {
StringBuilder configList = new StringBuilder();
for (Tuple2 tuple : configurations) {
configList.append(tuple._1)
for (final var entry : this.entrySet()) {
configList.append(entry.getKey())
.append("=")
.append(tuple._2)
.append(entry.getValue())
.append("\n");
}
return configList.toString();
}

public String toJsonString() {
return GSON.toJson(configurations.stream()
.collect(
java.util.stream.Collectors.toMap(
tuple -> tuple._1.toString(),
tuple -> tuple._2.toString()
)));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,18 @@

package org.apache.skywalking.oap.server.core.storage.ttl;

import com.google.gson.Gson;
import lombok.Data;

/**
* TTLDefinition defines the TTL of the data in the storage.
*/
@Data
public class TTLDefinition {
private final static Gson GSON = new Gson();
private final MetricsTTL metrics;
private final RecordsTTL records;

public String generateTTLDefinition() {
@Override
public String toString() {
StringBuilder ttlDefinition = new StringBuilder();
ttlDefinition.append("# Metrics TTL includes the definition of the TTL of the metrics-ish data in the storage,\n");
ttlDefinition.append("# e.g.\n");
Expand Down Expand Up @@ -67,8 +66,4 @@ public String generateTTLDefinition() {
ttlDefinition.append("records.browserErrorLog.cold=").append(records.getColdBrowserErrorLog()).append("\n");
return ttlDefinition.toString();
}

public String generateTTLDefinitionAsJSONStr() {
return GSON.toJson(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@

package org.apache.skywalking.oap.query.debug;

import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.linecorp.armeria.common.HttpRequest;
import com.linecorp.armeria.common.HttpResponse;
import com.linecorp.armeria.common.MediaType;
import com.linecorp.armeria.server.annotation.ExceptionHandler;
import com.linecorp.armeria.server.annotation.Get;
import com.linecorp.armeria.server.annotation.ProducesJson;

import lombok.extern.slf4j.Slf4j;

import java.util.Map;
import java.util.stream.Collectors;

import org.apache.skywalking.oap.server.core.CoreModule;
import org.apache.skywalking.oap.server.core.remote.client.Address;
import org.apache.skywalking.oap.server.core.remote.client.RemoteClient;
import org.apache.skywalking.oap.server.core.remote.client.RemoteClientManager;
import org.apache.skywalking.oap.server.library.module.ModuleManager;

Expand All @@ -50,22 +52,15 @@ private RemoteClientManager getRemoteClientManager() {
return remoteClientManager;
}

@ProducesJson
@Get("/status/cluster/nodes")
public HttpResponse buildClusterNodeList(HttpRequest request) {
JsonObject clusterInfo = new JsonObject();

JsonArray nodeList = new JsonArray();
clusterInfo.add("nodes", nodeList);
getRemoteClientManager().getRemoteClient().stream().map(c -> {
final Address address = c.getAddress();
JsonObject node = new JsonObject();
node.addProperty("host", address.getHost());
node.addProperty("port", address.getPort());
node.addProperty("isSelf", address.isSelf());
return node;
}).forEach(nodeList::add);

return HttpResponse.of(MediaType.JSON_UTF_8, clusterInfo.toString());
public Map<String, ?> buildClusterNodeList(HttpRequest request) {
return Map.of(
"nodes",
getRemoteClientManager().getRemoteClient()
.stream()
.map(RemoteClient::getAddress)
.collect(Collectors.toList())
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.linecorp.armeria.common.AggregatedHttpResponse;
import com.linecorp.armeria.common.HttpHeaderNames;
import com.linecorp.armeria.common.HttpRequest;
import com.linecorp.armeria.server.annotation.Default;
import com.linecorp.armeria.server.annotation.ExceptionHandler;
import com.linecorp.armeria.server.annotation.Get;
import com.linecorp.armeria.server.annotation.Param;
import com.linecorp.armeria.server.annotation.ProducesJson;
import com.linecorp.armeria.server.annotation.ProducesText;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -83,6 +85,7 @@
import org.apache.skywalking.oap.server.core.query.type.debugging.DebuggingTrace;
import org.apache.skywalking.oap.server.core.query.type.debugging.DebuggingTraceContext;
import org.apache.skywalking.oap.server.core.status.ServerStatusService;
import org.apache.skywalking.oap.server.core.status.ServerStatusService.ConfigList;
import org.apache.skywalking.oap.server.library.module.ModuleManager;
import zipkin2.Span;

Expand Down Expand Up @@ -110,14 +113,11 @@ public DebuggingHTTPHandler(final ModuleManager manager, final StatusQueryConfig
this.logQuery = new LogQuery(manager);
}

@ProducesText
@ProducesJson
@Get("/debugging/config/dump")
public String dumpConfigurations(HttpRequest request) {
final String acceptHeader = request.headers().get(HttpHeaderNames.ACCEPT);
if (acceptHeader != null && acceptHeader.toLowerCase().contains("application/json")) {
return serverStatusService.dumpBootingConfigurations(config.getKeywords4MaskingSecretsOfConfig())
.toJsonString();
}
return serverStatusService.dumpBootingConfigurations(config.getKeywords4MaskingSecretsOfConfig()).toString();
public ConfigList dumpConfigurations(HttpRequest request) {
return serverStatusService.dumpBootingConfigurations(config.getKeywords4MaskingSecretsOfConfig());
}

@SneakyThrows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@

package org.apache.skywalking.oap.query.debug;

import com.linecorp.armeria.common.HttpHeaderNames;
import com.linecorp.armeria.common.HttpRequest;
import com.linecorp.armeria.common.HttpResponse;
import com.linecorp.armeria.common.MediaType;
import com.linecorp.armeria.server.annotation.ExceptionHandler;
import com.linecorp.armeria.server.annotation.Get;
import com.linecorp.armeria.server.annotation.ProducesJson;
import com.linecorp.armeria.server.annotation.ProducesText;

import lombok.extern.slf4j.Slf4j;
import org.apache.skywalking.oap.server.core.CoreModule;
import org.apache.skywalking.oap.server.core.query.TTLStatusQuery;
import org.apache.skywalking.oap.server.core.storage.ttl.TTLDefinition;
import org.apache.skywalking.oap.server.library.module.ModuleManager;

@Slf4j
Expand All @@ -48,12 +48,10 @@ private TTLStatusQuery getTTLStatusQuery() {
return ttlStatusQuery;
}

@ProducesText
@ProducesJson
@Get("/status/config/ttl")
public HttpResponse affectedTTLConfigurations(HttpRequest request) {
final String acceptHeader = request.headers().get(HttpHeaderNames.ACCEPT);
if (acceptHeader != null && acceptHeader.toLowerCase().contains("application/json")) {
return HttpResponse.of(MediaType.JSON_UTF_8, getTTLStatusQuery().getTTL().generateTTLDefinitionAsJSONStr());
}
return HttpResponse.of(MediaType.PLAIN_TEXT_UTF_8, getTTLStatusQuery().getTTL().generateTTLDefinition());
public TTLDefinition effectiveTTLConfigurations() {
return getTTLStatusQuery().getTTL();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void prepare() throws ServiceNotProvidedException, ModuleStartException {

CoreModuleConfig moduleConfig = new CoreModuleConfig();
this.registerServiceImplementation(ConfigService.class, new ConfigService(moduleConfig, this));
this.registerServiceImplementation(ServerStatusService.class, new ServerStatusService(getManager(), moduleConfig));
this.registerServiceImplementation(ServerStatusService.class, new ServerStatusService(getManager()));
moduleConfig.setEnableHierarchy(false);
this.registerServiceImplementation(HierarchyDefinitionService.class, new HierarchyDefinitionService(moduleConfig));
this.registerServiceImplementation(HierarchyService.class, new HierarchyService(getManager(), moduleConfig));
Expand Down
Loading