vy commented on code in PR #4011:
URL: https://github.com/apache/logging-log4j2/pull/4011#discussion_r2648346849


##########
log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/DeferredCompressionAction.java:
##########
@@ -0,0 +1,200 @@
+/*
+ * 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.logging.log4j.core.appender.rolling.action;
+
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.status.StatusLogger;
+
+import java.io.IOException;
+import java.util.concurrent.ThreadLocalRandom;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * Wrapper action that schedules compression for defferred execution.
+ * This action wraps another action and schedules it to be executed
+ * after a random defer within a specified time window.

Review Comment:
   ```suggestion
    * Decorates an {@link Action} to execute it after a certain amount of delay.
   ```



##########
log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/DeferredCompressionAction.java:
##########
@@ -0,0 +1,200 @@
+/*
+ * 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.logging.log4j.core.appender.rolling.action;
+
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.status.StatusLogger;
+
+import java.io.IOException;
+import java.util.concurrent.ThreadLocalRandom;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * Wrapper action that schedules compression for defferred execution.
+ * This action wraps another action and schedules it to be executed
+ * after a random defer within a specified time window.
+ */
+public class DeferredCompressionAction implements Action {

Review Comment:
   I think your earlier attempt, `DelayedCompressionAction`, fits the bill 
better. AFAICT, `deferred` waits for a condition, which does not necessarily 
needs to be a time, whereas `delay` makes it clear the involvement of time.
   
   Once you implement this change, please update all the usages of `[Dd]efer` 
in this PR.



##########
log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/DeferredCompressionAction.java:
##########
@@ -0,0 +1,200 @@
+/*
+ * 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.logging.log4j.core.appender.rolling.action;
+
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.status.StatusLogger;
+
+import java.io.IOException;
+import java.util.concurrent.ThreadLocalRandom;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * Wrapper action that schedules compression for defferred execution.
+ * This action wraps another action and schedules it to be executed
+ * after a random defer within a specified time window.
+ */
+public class DeferredCompressionAction implements Action {
+
+    private static final Logger LOGGER = StatusLogger.getLogger();
+
+    private final Action originalAction;
+    private final int maxDeferSeconds;
+    private boolean complete = false;
+    private boolean interrupted = false;
+
+    /**
+     * Creates a new DelayedCompressionAction.
+     *
+     * @param originalAction the action to be executed with defer
+     * @param maxDeferSeconds the maximum defer in seconds (0 means immediate 
execution)
+     */
+    public DeferredCompressionAction(Action originalAction, int 
maxDeferSeconds) {
+        this.originalAction = requireNonNull(originalAction, "originalAction");
+        this.maxDeferSeconds = maxDeferSeconds;
+    }
+
+    /**
+     * Executes the action with a defer using sleep.
+     *
+     * @return true if the action was successfully executed
+     * @throws IOException if an error occurs during execution
+     */

Review Comment:
   ```suggestion
   ```



##########
log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/DeferredCompressionAction.java:
##########
@@ -0,0 +1,200 @@
+/*
+ * 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.logging.log4j.core.appender.rolling.action;
+
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.status.StatusLogger;
+
+import java.io.IOException;
+import java.util.concurrent.ThreadLocalRandom;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * Wrapper action that schedules compression for defferred execution.
+ * This action wraps another action and schedules it to be executed
+ * after a random defer within a specified time window.
+ */
+public class DeferredCompressionAction implements Action {
+
+    private static final Logger LOGGER = StatusLogger.getLogger();
+
+    private final Action originalAction;
+    private final int maxDeferSeconds;
+    private boolean complete = false;
+    private boolean interrupted = false;
+
+    /**
+     * Creates a new DelayedCompressionAction.
+     *
+     * @param originalAction the action to be executed with defer
+     * @param maxDeferSeconds the maximum defer in seconds (0 means immediate 
execution)
+     */
+    public DeferredCompressionAction(Action originalAction, int 
maxDeferSeconds) {
+        this.originalAction = requireNonNull(originalAction, "originalAction");
+        this.maxDeferSeconds = maxDeferSeconds;
+    }
+
+    /**
+     * Executes the action with a defer using sleep.
+     *
+     * @return true if the action was successfully executed
+     * @throws IOException if an error occurs during execution
+     */
+    @Override
+    public boolean execute() throws IOException {
+        if (interrupted) {

Review Comment:
   What about `complete == true`?



##########
log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/DeferredCompressionAction.java:
##########
@@ -0,0 +1,200 @@
+/*
+ * 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.logging.log4j.core.appender.rolling.action;
+
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.status.StatusLogger;
+
+import java.io.IOException;
+import java.util.concurrent.ThreadLocalRandom;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * Wrapper action that schedules compression for defferred execution.
+ * This action wraps another action and schedules it to be executed
+ * after a random defer within a specified time window.
+ */
+public class DeferredCompressionAction implements Action {
+
+    private static final Logger LOGGER = StatusLogger.getLogger();
+
+    private final Action originalAction;
+    private final int maxDeferSeconds;
+    private boolean complete = false;
+    private boolean interrupted = false;
+
+    /**
+     * Creates a new DelayedCompressionAction.

Review Comment:
   ```suggestion
        * Creates a new instance.
   ```



##########
log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/DeferredCompressionAction.java:
##########
@@ -0,0 +1,200 @@
+/*
+ * 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.logging.log4j.core.appender.rolling.action;
+
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.status.StatusLogger;
+
+import java.io.IOException;
+import java.util.concurrent.ThreadLocalRandom;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * Wrapper action that schedules compression for defferred execution.
+ * This action wraps another action and schedules it to be executed
+ * after a random defer within a specified time window.
+ */
+public class DeferredCompressionAction implements Action {
+
+    private static final Logger LOGGER = StatusLogger.getLogger();
+
+    private final Action originalAction;
+    private final int maxDeferSeconds;
+    private boolean complete = false;
+    private boolean interrupted = false;
+
+    /**
+     * Creates a new DelayedCompressionAction.
+     *
+     * @param originalAction the action to be executed with defer

Review Comment:
   ```suggestion
        * @param originalAction the action to be executed with delay
   ```



##########
log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/DeferredCompressionAction.java:
##########
@@ -0,0 +1,200 @@
+/*
+ * 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.logging.log4j.core.appender.rolling.action;
+
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.status.StatusLogger;
+
+import java.io.IOException;
+import java.util.concurrent.ThreadLocalRandom;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * Wrapper action that schedules compression for defferred execution.
+ * This action wraps another action and schedules it to be executed
+ * after a random defer within a specified time window.
+ */
+public class DeferredCompressionAction implements Action {
+
+    private static final Logger LOGGER = StatusLogger.getLogger();
+
+    private final Action originalAction;
+    private final int maxDeferSeconds;
+    private boolean complete = false;
+    private boolean interrupted = false;
+
+    /**
+     * Creates a new DelayedCompressionAction.
+     *
+     * @param originalAction the action to be executed with defer
+     * @param maxDeferSeconds the maximum defer in seconds (0 means immediate 
execution)
+     */
+    public DeferredCompressionAction(Action originalAction, int 
maxDeferSeconds) {

Review Comment:
   _Question:_ Shouldn't we be receiving a range instead of an upper bound?



-- 
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]

Reply via email to