wu-sheng commented on a change in pull request #4172: Provide profile task downstream to sniffer URL: https://github.com/apache/skywalking/pull/4172#discussion_r363041066
########## File path: apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/profile/ProfileTaskExecutionService.java ########## @@ -0,0 +1,92 @@ +/* + * 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.apm.agent.core.profile; + +import org.apache.skywalking.apm.agent.core.boot.BootService; +import org.apache.skywalking.apm.agent.core.boot.DefaultNamedThreadFactory; + +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +/** + * Profile task executor, use {@link #addProfileTask(ProfileTask)} to add a new profile task. + * + * @author MrPro + */ +public class ProfileTaskExecutionService implements BootService { + + private static volatile ScheduledExecutorService PROFILE_TASK_READY_SCHEDULE = Executors.newScheduledThreadPool(15, new DefaultNamedThreadFactory("PROFILE-TASK-READY-SCHEDULE")); + + // last command create time, use to next query task list + private volatile long lastCommandCreateTime = -1; + + /** + * get profile task from OAP + * @param task + */ + public void addProfileTask(ProfileTask task) { Review comment: Tasklist in the queue list should be cached and do time window validation again. Even we did in the UI, but there could be bug or storage changed through DB directly. It is better to recheck here. Same rule as backend did. There should be only one task in a certain time. ---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services
