You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/07/19 10:52:57 UTC

[GitHub] [inlong] vernedeng commented on a diff in pull request #5126: [INLONG-5094][SortStandalone] Implements time interval interceptor

vernedeng commented on code in PR #5126:
URL: https://github.com/apache/inlong/pull/5126#discussion_r924351638


##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/rollback/TimeBasedFilterInterceptor.java:
##########
@@ -0,0 +1,134 @@
+/*
+ * 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.sort.standalone.rollback;
+
+import org.apache.commons.lang3.math.NumberUtils;
+import org.apache.flume.Context;
+import org.apache.flume.Event;
+import org.apache.flume.interceptor.Interceptor;
+import org.apache.inlong.sort.standalone.channel.ProfileEvent;
+import org.apache.inlong.sort.standalone.utils.Constants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+/**
+ * Interceptor that filters events selectively based on a configured time interval.
+ * Usually, it's used to roll back data in a certain time interval.
+ * It supports config either one of start, stop time or both of them.
+ * Multiple TimeBasedFilterInterceptor can be chained together to create more complex time intervals.
+ */
+public class TimeBasedFilterInterceptor implements Interceptor {
+
+    private static final Logger logger = LoggerFactory
+            .getLogger(TimeBasedFilterInterceptor.class);
+    private final long startTime;
+    private final long stopTime;
+
+    public TimeBasedFilterInterceptor(long startTime, long stopTime) {
+        this.startTime = startTime;
+        this.stopTime = stopTime;
+    }
+
+    @Override
+    public void initialize() {
+        //no-op

Review Comment:
   fix, thx



-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org