-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'apache/main' into feature/main/2229_mon…
…godb_docker
- Loading branch information
Showing
76 changed files
with
1,216 additions
and
365 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This file is here to activate the `plugin-processing` Maven profile. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ 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. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j</artifactId> | ||
<version>${revision}</version> | ||
<relativePath>../log4j-parent</relativePath> | ||
</parent> | ||
|
||
<artifactId>log4j-conversant</artifactId> | ||
<name>Apache Log4j Conversant Disruptor-based supplements</name> | ||
<description>Provides ConversantMedia Disruptor-based data structure implementations for the Apache Log4j.</description> | ||
|
||
<properties> | ||
<conversant.disruptor.version>1.2.21</conversant.disruptor.version> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>com.conversantmedia</groupId> | ||
<artifactId>disruptor</artifactId> | ||
<version>${conversant.disruptor.version}</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.jspecify</groupId> | ||
<artifactId>jspecify</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.conversantmedia</groupId> | ||
<artifactId>disruptor</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-core</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-plugins</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-core-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
...t/src/main/java/org/apache/logging/log4j/conversant/DisruptorRecyclerFactoryProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
/* | ||
* 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.conversant; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import aQute.bnd.annotation.spi.ServiceProvider; | ||
import com.conversantmedia.util.concurrent.DisruptorBlockingQueue; | ||
import com.conversantmedia.util.concurrent.SpinPolicy; | ||
import java.util.Queue; | ||
import java.util.function.Consumer; | ||
import java.util.function.Supplier; | ||
import org.apache.logging.log4j.Logger; | ||
import org.apache.logging.log4j.core.util.Integers; | ||
import org.apache.logging.log4j.kit.env.PropertyEnvironment; | ||
import org.apache.logging.log4j.kit.recycler.Recycler; | ||
import org.apache.logging.log4j.kit.recycler.RecyclerFactory; | ||
import org.apache.logging.log4j.kit.recycler.RecyclerFactoryProvider; | ||
import org.apache.logging.log4j.kit.recycler.RecyclerProperties; | ||
import org.apache.logging.log4j.kit.recycler.support.AbstractRecycler; | ||
import org.apache.logging.log4j.status.StatusLogger; | ||
|
||
/** | ||
* A {@link Recycler} factory provider implementation based on | ||
* <a href="https://github.com/conversant/disruptor>Conversant's Disruptor BlockingQueue</a>. | ||
* | ||
* @since 3.0.0 | ||
*/ | ||
@ServiceProvider(value = RecyclerFactoryProvider.class) | ||
public final class DisruptorRecyclerFactoryProvider implements RecyclerFactoryProvider { | ||
|
||
private static final Logger LOGGER = StatusLogger.getLogger(); | ||
|
||
@Override | ||
public int getOrder() { | ||
return 600; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "conversant-disruptor"; | ||
} | ||
|
||
@Override | ||
public RecyclerFactory createForEnvironment(final PropertyEnvironment environment) { | ||
requireNonNull(environment, "environment"); | ||
return new DisruptorRecyclerFactory( | ||
environment.getProperty(RecyclerProperties.class), | ||
environment.getProperty(DisruptorRecyclerProperties.class)); | ||
} | ||
|
||
private static final class DisruptorRecyclerFactory implements RecyclerFactory { | ||
|
||
/** | ||
* Minimum capacity of the disruptor | ||
*/ | ||
private static final int MIN_CAPACITY = 8; | ||
|
||
private final int capacity; | ||
private final SpinPolicy spinPolicy; | ||
|
||
private DisruptorRecyclerFactory( | ||
final RecyclerProperties recyclerProperties, final DisruptorRecyclerProperties disruptorProperties) { | ||
this.capacity = validateCapacity(recyclerProperties.capacity()); | ||
this.spinPolicy = disruptorProperties.spinPolicy(); | ||
} | ||
|
||
@Override | ||
public <V> Recycler<V> create(final Supplier<V> supplier, final Consumer<V> cleaner) { | ||
requireNonNull(supplier, "supplier"); | ||
requireNonNull(cleaner, "cleaner"); | ||
final DisruptorBlockingQueue<V> queue = new DisruptorBlockingQueue<>(capacity, spinPolicy); | ||
return new DisruptorRecycler<>(supplier, cleaner, queue); | ||
} | ||
|
||
private static Integer validateCapacity(final int capacity) { | ||
if (capacity < MIN_CAPACITY) { | ||
LOGGER.warn( | ||
"Invalid DisruptorBlockingQueue capacity {}, using minimum size {}.", capacity, MIN_CAPACITY); | ||
return MIN_CAPACITY; | ||
} | ||
final int roundedCapacity = Integers.ceilingNextPowerOfTwo(capacity); | ||
if (capacity != roundedCapacity) { | ||
LOGGER.warn( | ||
"Invalid DisruptorBlockingQueue size {}, using rounded size {}.", capacity, roundedCapacity); | ||
} | ||
return roundedCapacity; | ||
} | ||
|
||
private static final class DisruptorRecycler<V> extends AbstractRecycler<V> { | ||
|
||
private final Consumer<V> cleaner; | ||
|
||
private final Queue<V> queue; | ||
|
||
private DisruptorRecycler(final Supplier<V> supplier, final Consumer<V> cleaner, final Queue<V> queue) { | ||
super(supplier); | ||
this.cleaner = cleaner; | ||
this.queue = queue; | ||
} | ||
|
||
@Override | ||
public V acquire() { | ||
final V value = queue.poll(); | ||
return value != null ? value : createInstance(); | ||
} | ||
|
||
@Override | ||
public void release(final V value) { | ||
requireNonNull(value, "value"); | ||
cleaner.accept(value); | ||
queue.offer(value); | ||
} | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...ersant/src/main/java/org/apache/logging/log4j/conversant/DisruptorRecyclerProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* 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.conversant; | ||
|
||
import com.conversantmedia.util.concurrent.SpinPolicy; | ||
import org.apache.logging.log4j.kit.env.Log4jProperty; | ||
import org.jspecify.annotations.NullMarked; | ||
|
||
@NullMarked | ||
@Log4jProperty(name = "recycler.conversant") | ||
public record DisruptorRecyclerProperties(@Log4jProperty(defaultValue = "WAITING") SpinPolicy spinPolicy) {} |
22 changes: 22 additions & 0 deletions
22
log4j-conversant/src/main/java/org/apache/logging/log4j/conversant/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* 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. | ||
*/ | ||
@Export | ||
@Version("3.0.0") | ||
package org.apache.logging.log4j.conversant; | ||
|
||
import org.osgi.annotation.bundle.Export; | ||
import org.osgi.annotation.versioning.Version; |
Oops, something went wrong.