-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feature:support random delayed compression #4011
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2.x
Are you sure you want to change the base?
Changes from 2 commits
9647fff
5bc00b8
6eeac67
b719066
e6c7db2
ef8307e
5c0f38c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -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. | ||||||||||||||
|
||||||||||||||
| * Creates a new DelayedCompressionAction. | |
| * Creates a new instance. |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * @param originalAction the action to be executed with defer | |
| * @param originalAction the action to be executed with delay |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Shouldn't we be receiving a range instead of an upper bound?
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /** | |
| * Executes the action with a defer using sleep. | |
| * | |
| * @return true if the action was successfully executed | |
| * @throws IOException if an error occurs during execution | |
| */ |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about complete == true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.