You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2019/12/30 01:34:31 UTC

[GitHub] [skywalking] kezhenxu94 commented on a change in pull request #4145: Provide thread monitor create task feature

kezhenxu94 commented on a change in pull request #4145: Provide thread monitor create task feature
URL: https://github.com/apache/skywalking/pull/4145#discussion_r361884312
 
 

 ##########
 File path: oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/ProfileMutation.java
 ##########
 @@ -0,0 +1,61 @@
+/*
+ * 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.GraphQLMutationResolver;
+import org.apache.skywalking.oap.query.graphql.type.ProfileTaskCreationRequest;
+import org.apache.skywalking.oap.server.core.CoreModule;
+import org.apache.skywalking.oap.server.core.profile.ProfileTaskMutationService;
+import org.apache.skywalking.oap.server.core.profile.entity.ProfileTaskCreationResult;
+import org.apache.skywalking.oap.server.core.query.DurationUtils;
+import org.apache.skywalking.oap.server.library.module.ModuleManager;
+
+import java.io.IOException;
+
+/**
+ * profile mutation GraphQL resolver
+ *
+ * @author MrPro
+ */
+public class ProfileMutation implements GraphQLMutationResolver {
+
+    private final ModuleManager moduleManager;
+    private ProfileTaskMutationService profileTaskService;
+
+    public ProfileMutation(ModuleManager moduleManager) {
+        this.moduleManager = moduleManager;
+    }
+
+    private ProfileTaskMutationService getProfileTaskService() {
+        if (profileTaskService == null) {
+            this.profileTaskService = moduleManager.find(CoreModule.NAME).provider().getService(ProfileTaskMutationService.class);
+        }
+        return profileTaskService;
+    }
+
+    public ProfileTaskCreationResult createProfileTask(ProfileTaskCreationRequest creationRequest) throws IOException {
+        return getProfileTaskService().createTask(
+                creationRequest.getServiceId(),
+                creationRequest.getEndpointName(),
+                creationRequest.getStartTime() == null ? -1 : creationRequest.getStartTime(),
+                Math.toIntExact(DurationUtils.INSTANCE.toSecond(creationRequest.getDurationUnit(), creationRequest.getDuration())),
 
 Review comment:
   > Reading this makes me feel, we should set the duration in minute level only, and remove the step in the protocol. @kezhenxu94 @arugal What do you think?
   
   Make sense to me, but `minute` level seems too large in time span, what about making it `second` level?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services