aloyszhang commented on code in PR #11572: URL: https://github.com/apache/inlong/pull/11572#discussion_r1868680433
########## inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/task/cos/COSTask.java: ########## @@ -0,0 +1,341 @@ +/* + * 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.inlong.agent.plugin.task.cos; + +import org.apache.inlong.agent.conf.InstanceProfile; +import org.apache.inlong.agent.conf.TaskProfile; +import org.apache.inlong.agent.constant.TaskConstants; +import org.apache.inlong.agent.core.task.TaskAction; +import org.apache.inlong.agent.plugin.task.AbstractTask; +import org.apache.inlong.agent.plugin.task.cos.FileScanner.BasicFileInfo; +import org.apache.inlong.agent.plugin.utils.cos.COSUtils; +import org.apache.inlong.agent.plugin.utils.regex.NewDateUtils; +import org.apache.inlong.agent.plugin.utils.regex.Scanner; +import org.apache.inlong.agent.state.State; +import org.apache.inlong.agent.utils.AgentUtils; +import org.apache.inlong.agent.utils.DateTransUtils; + +import com.qcloud.cos.COSClient; +import com.qcloud.cos.model.ObjectMetadata; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TimeZone; +import java.util.TreeSet; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.LinkedBlockingQueue; + +/** + * Watch directory, if new valid files are created, create instance correspondingly. + */ +public class COSTask extends AbstractTask { + + private static final Logger LOGGER = LoggerFactory.getLogger(COSTask.class); + public static final String DEFAULT_COS_INSTANCE = "org.apache.inlong.agent.plugin.instance.COSInstance"; + private static final int INSTANCE_QUEUE_CAPACITY = 10; + private final Map<String/* dataTime */, Map<String/* fileName */, InstanceProfile>> eventMap = + new ConcurrentHashMap<>(); + public static final long DAY_TIMEOUT_INTERVAL = 2 * 24 * 3600 * 1000; + public static final int CORE_THREAD_MAX_GAP_TIME_MS = 60 * 1000; + private boolean retry; + private long startTime; + private long endTime; + private String originPattern; + private long lastScanTime = 0; + public final long SCAN_INTERVAL = 1 * 60 * 1000; + private volatile boolean runAtLeastOneTime = false; + private volatile long coreThreadUpdateTime = 0; Review Comment: not used -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
