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 2019/04/03 21:07:35 UTC

[incubator-skywalking] 01/01: New query graphql protocol added.

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch log
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git

commit 3cf4e6cb95abf75168b2c17322d7db689edcfaf4
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Wed Apr 3 14:07:22 2019 -0700

    New query graphql protocol added.
---
 .../oap/server/core/query/entity/ContentType.java  | 26 ++++++++++++++
 .../oap/server/core/query/entity/Log.java          | 40 ++++++++++++++++++++++
 .../oap/server/core/query/entity/LogState.java     | 26 ++++++++++++++
 .../oap/server/core/query/entity/Logs.java         | 34 ++++++++++++++++++
 .../oap/query/graphql/GraphQLQueryProvider.java    |  2 ++
 .../oap/query/graphql/resolver/LogQuery.java       | 40 ++++++++++++++++++++++
 .../oap/query/graphql/type/LogQueryCondition.java  | 39 +++++++++++++++++++++
 .../src/main/resources/query-protocol              |  2 +-
 8 files changed, 208 insertions(+), 1 deletion(-)

diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/ContentType.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/ContentType.java
new file mode 100644
index 0000000..983e547
--- /dev/null
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/ContentType.java
@@ -0,0 +1,26 @@
+/*
+ * 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.query.entity;
+
+/**
+ * @author wusheng
+ */
+public enum ContentType {
+    TEXT, JSON, NONE
+}
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Log.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Log.java
new file mode 100644
index 0000000..f0aad27
--- /dev/null
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Log.java
@@ -0,0 +1,40 @@
+/*
+ * 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.query.entity;
+
+import lombok.*;
+
+/**
+ * @author wusheng
+ */
+@Setter
+@Getter
+public class Log {
+    private String serviceName;
+    private int serviceId;
+    private String serviceInstanceName;
+    private int serviceInstanceId;
+    private String endpointName;
+    private int endpointId;
+    private String timestamp;
+    private boolean isError;
+    private String statusCode;
+    private ContentType contentType = ContentType.NONE;
+    private String content;
+}
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/LogState.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/LogState.java
new file mode 100644
index 0000000..dd262c9
--- /dev/null
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/LogState.java
@@ -0,0 +1,26 @@
+/*
+ * 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.query.entity;
+
+/**
+ * @author wusheng
+ */
+public enum LogState {
+    ALL, SUCCESS, ERROR
+}
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Logs.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Logs.java
new file mode 100644
index 0000000..2fe81c6
--- /dev/null
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Logs.java
@@ -0,0 +1,34 @@
+/*
+ * 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.query.entity;
+
+import java.util.*;
+import lombok.Setter;
+
+/**
+ * @author wusheng
+ */
+public class Logs {
+    private final List<Log> logs;
+    @Setter private int total;
+
+    public Logs() {
+        this.logs = new ArrayList<>();
+    }
+}
diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/GraphQLQueryProvider.java b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/GraphQLQueryProvider.java
index d940141..fcd3b24 100644
--- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/GraphQLQueryProvider.java
+++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/GraphQLQueryProvider.java
@@ -68,6 +68,8 @@ public class GraphQLQueryProvider extends ModuleProvider {
             .resolvers(new AlarmQuery(getManager()))
             .file("query-protocol/top-n-records.graphqls")
             .resolvers(new TopNRecordsQuery(getManager()))
+            .file("query-protocol/log.graphqls")
+            .resolvers(new LogQuery(getManager()))
             .build()
             .makeExecutableSchema();
         this.graphQL = GraphQL.newGraphQL(schema).build();
diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/LogQuery.java b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/LogQuery.java
new file mode 100644
index 0000000..08dfe97
--- /dev/null
+++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/LogQuery.java
@@ -0,0 +1,40 @@
+/*
+ * 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.query.graphql.resolver;
+
+import com.coxautodev.graphql.tools.GraphQLQueryResolver;
+import java.io.IOException;
+import org.apache.skywalking.oap.query.graphql.type.LogQueryCondition;
+import org.apache.skywalking.oap.server.core.query.entity.Logs;
+import org.apache.skywalking.oap.server.library.module.ModuleManager;
+
+/**
+ * @author wusheng
+ */
+public class LogQuery implements GraphQLQueryResolver {
+    private final ModuleManager moduleManager;
+
+    public LogQuery(ModuleManager moduleManager) {
+        this.moduleManager = moduleManager;
+    }
+
+    public Logs queryLogs(LogQueryCondition condition) throws IOException {
+        return null;
+    }
+}
diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/LogQueryCondition.java b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/LogQueryCondition.java
new file mode 100644
index 0000000..dd178a3
--- /dev/null
+++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/LogQueryCondition.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.query.graphql.type;
+
+import lombok.*;
+import org.apache.skywalking.oap.server.core.query.entity.*;
+
+/**
+ * @author wusheng
+ */
+@Getter
+@Setter
+public class LogQueryCondition {
+    private String metricName;
+    private String serviceId;
+    private String serviceInstanceId;
+    private String traceId;
+    private String endpointId;
+    private LogState state;
+    private String stateCode;
+    private Duration queryDuration;
+    private Pagination paging;
+}
diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol b/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol
index 6f11e3b..7aa4418 160000
--- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol
+++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol
@@ -1 +1 @@
-Subproject commit 6f11e3b829bba4d3532477e968291cf657f0ac0b
+Subproject commit 7aa441857b5e944c3ddc225336b50256ec649f1c