You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2022/12/03 09:55:39 UTC
[skywalking] 01/01: Add `ServerStatusService` in the core module
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch new-service
in repository https://gitbox.apache.org/repos/asf/skywalking.git
commit 46d25f82ce228b1edc07f970df83d8b7597c8cf3
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Sat Dec 3 17:55:21 2022 +0800
Add `ServerStatusService` in the core module
---
docs/en/changes/changes.md | 4 +-
.../skywalking/oap/server/core/CoreModule.java | 4 +-
.../oap/server/core/CoreModuleProvider.java | 2 +
.../oap/server/core/status/BootingStatus.java | 39 +++++++++++++++++
.../server/core/status/ServerStatusService.java | 51 ++++++++++++++++++++++
.../oap/server/starter/OAPServerBootstrap.java | 13 +++---
6 files changed, 101 insertions(+), 12 deletions(-)
diff --git a/docs/en/changes/changes.md b/docs/en/changes/changes.md
index 4e7bd5c6b4..d1a9e01160 100644
--- a/docs/en/changes/changes.md
+++ b/docs/en/changes/changes.md
@@ -2,14 +2,12 @@
#### Project
-
#### OAP Server
+* Add `ServerStatusService` in the core module to provide a new way to expose booting status to other modules.
#### UI
-
#### Documentation
-
All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/160?closed=1)
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModule.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModule.java
index 5c67c10a53..66d9934e97 100755
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModule.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModule.java
@@ -33,6 +33,7 @@ import org.apache.skywalking.oap.server.core.oal.rt.OALEngineLoaderService;
import org.apache.skywalking.oap.server.core.profiling.ebpf.EBPFProfilingMutationService;
import org.apache.skywalking.oap.server.core.profiling.ebpf.EBPFProfilingQueryService;
import org.apache.skywalking.oap.server.core.profiling.trace.ProfileTaskMutationService;
+import org.apache.skywalking.oap.server.core.profiling.trace.ProfileTaskQueryService;
import org.apache.skywalking.oap.server.core.query.AggregationQueryService;
import org.apache.skywalking.oap.server.core.query.AlarmQueryService;
import org.apache.skywalking.oap.server.core.query.BrowserLogQueryService;
@@ -41,7 +42,6 @@ import org.apache.skywalking.oap.server.core.query.LogQueryService;
import org.apache.skywalking.oap.server.core.query.MetadataQueryService;
import org.apache.skywalking.oap.server.core.query.MetricsMetadataQueryService;
import org.apache.skywalking.oap.server.core.query.MetricsQueryService;
-import org.apache.skywalking.oap.server.core.profiling.trace.ProfileTaskQueryService;
import org.apache.skywalking.oap.server.core.query.RecordQueryService;
import org.apache.skywalking.oap.server.core.query.TagAutoCompleteQueryService;
import org.apache.skywalking.oap.server.core.query.TopNRecordsQueryService;
@@ -52,6 +52,7 @@ import org.apache.skywalking.oap.server.core.remote.client.RemoteClientManager;
import org.apache.skywalking.oap.server.core.server.GRPCHandlerRegister;
import org.apache.skywalking.oap.server.core.server.HTTPHandlerRegister;
import org.apache.skywalking.oap.server.core.source.SourceReceiver;
+import org.apache.skywalking.oap.server.core.status.ServerStatusService;
import org.apache.skywalking.oap.server.core.storage.model.IModelManager;
import org.apache.skywalking.oap.server.core.storage.model.ModelCreator;
import org.apache.skywalking.oap.server.core.storage.model.ModelManipulator;
@@ -73,6 +74,7 @@ public class CoreModule extends ModuleDefine {
public Class[] services() {
List<Class> classes = new ArrayList<>();
classes.add(ConfigService.class);
+ classes.add(ServerStatusService.class);
classes.add(DownSamplingConfigService.class);
classes.add(NamingControl.class);
classes.add(IComponentLibraryCatalogService.class);
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleProvider.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleProvider.java
index 2f96358ae6..429830cfab 100755
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleProvider.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleProvider.java
@@ -81,6 +81,7 @@ import org.apache.skywalking.oap.server.core.server.HTTPHandlerRegisterImpl;
import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine;
import org.apache.skywalking.oap.server.core.source.SourceReceiver;
import org.apache.skywalking.oap.server.core.source.SourceReceiverImpl;
+import org.apache.skywalking.oap.server.core.status.ServerStatusService;
import org.apache.skywalking.oap.server.core.storage.PersistenceTimer;
import org.apache.skywalking.oap.server.core.storage.StorageException;
import org.apache.skywalking.oap.server.core.storage.model.IModelManager;
@@ -240,6 +241,7 @@ public class CoreModuleProvider extends ModuleProvider {
httpServer.initialize();
this.registerServiceImplementation(ConfigService.class, new ConfigService(moduleConfig));
+ this.registerServiceImplementation(ServerStatusService.class, new ServerStatusService(getManager()));
this.registerServiceImplementation(
DownSamplingConfigService.class, new DownSamplingConfigService(moduleConfig.getDownsampling()));
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/status/BootingStatus.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/status/BootingStatus.java
new file mode 100644
index 0000000000..4de30fcff8
--- /dev/null
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/status/BootingStatus.java
@@ -0,0 +1,39 @@
+/*
+ * 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 org.apache.skywalking.oap.server.core.status;
+
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * Booting status indicate whether the current server starts successfully.
+ */
+@Getter
+@Setter(AccessLevel.PACKAGE)
+public class BootingStatus {
+ /**
+ * The status of OAP is fully booted successfully.
+ */
+ private boolean isBooted = false;
+ /**
+ * The uptime in milliseconds if {@link #isBooted} is true;
+ */
+ private long uptime = 0;
+}
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/status/ServerStatusService.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/status/ServerStatusService.java
new file mode 100644
index 0000000000..27a3b328df
--- /dev/null
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/status/ServerStatusService.java
@@ -0,0 +1,51 @@
+/*
+ * 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 org.apache.skywalking.oap.server.core.status;
+
+import lombok.RequiredArgsConstructor;
+import org.apache.skywalking.oap.server.library.module.ModuleManager;
+import org.apache.skywalking.oap.server.library.module.Service;
+import org.apache.skywalking.oap.server.telemetry.TelemetryModule;
+import org.apache.skywalking.oap.server.telemetry.api.MetricsCreator;
+import org.apache.skywalking.oap.server.telemetry.api.MetricsTag;
+
+/**
+ * The server status service provides the indicators for the current server status.
+ * Notice, this should not be treated as a kind of health checker or self telemetry.
+ * For more, this helps modules to be aware of current OAP server status.
+ *
+ * @since 9.4.0
+ */
+@RequiredArgsConstructor
+public class ServerStatusService implements Service {
+ private final ModuleManager manager;
+ private BootingStatus bootingStatus = new BootingStatus();
+
+ public void bootedNow(long uptime) {
+ bootingStatus.setBooted(true);
+ bootingStatus.setUptime(uptime);
+ manager.find(TelemetryModule.NAME)
+ .provider()
+ .getService(MetricsCreator.class)
+ .createGauge("uptime", "oap server start up time", MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE)
+ // Set uptime to second
+ .setValue(uptime / 1000d);
+ }
+
+}
diff --git a/oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/OAPServerBootstrap.java b/oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/OAPServerBootstrap.java
index 2b8f4b8e99..f1f2a2d37d 100644
--- a/oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/OAPServerBootstrap.java
+++ b/oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/OAPServerBootstrap.java
@@ -19,14 +19,13 @@
package org.apache.skywalking.oap.server.starter;
import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.CoreModule;
import org.apache.skywalking.oap.server.core.RunningMode;
+import org.apache.skywalking.oap.server.core.status.ServerStatusService;
import org.apache.skywalking.oap.server.core.version.Version;
import org.apache.skywalking.oap.server.library.module.ApplicationConfiguration;
import org.apache.skywalking.oap.server.library.module.ModuleManager;
import org.apache.skywalking.oap.server.starter.config.ApplicationConfigLoader;
-import org.apache.skywalking.oap.server.telemetry.TelemetryModule;
-import org.apache.skywalking.oap.server.telemetry.api.MetricsCreator;
-import org.apache.skywalking.oap.server.telemetry.api.MetricsTag;
/**
* Starter core. Load the core configuration file, and initialize the startup sequence through {@link ModuleManager}.
@@ -43,12 +42,10 @@ public class OAPServerBootstrap {
ApplicationConfiguration applicationConfiguration = configLoader.load();
manager.init(applicationConfiguration);
- manager.find(TelemetryModule.NAME)
+ manager.find(CoreModule.NAME)
.provider()
- .getService(MetricsCreator.class)
- .createGauge("uptime", "oap server start up time", MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE)
- // Set uptime to second
- .setValue(System.currentTimeMillis() / 1000d);
+ .getService(ServerStatusService.class)
+ .bootedNow(System.currentTimeMillis());
log.info("Version of OAP: {}", Version.CURRENT);