Skip to content

Commit

Permalink
Merge remote-tracking branch 'apache/main' into feature/main/2229_mon…
Browse files Browse the repository at this point in the history
…godb_docker
  • Loading branch information
ppkarwasz committed Sep 12, 2024
2 parents 136cc6f + fda45ec commit 6a59e03
Show file tree
Hide file tree
Showing 76 changed files with 1,216 additions and 365 deletions.
19 changes: 1 addition & 18 deletions .github/generate-email.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,6 @@ RELEASE_NOTES_FILE="$SCRIPT_DIR/../target/generated-site/antora/modules/ROOT/pag
exit 1
}

dump_review_kit() {
wget -q -O - https://raw.githubusercontent.com/apache/logging-parent/main/.github/release-review-kit.txt \
| sed -n '/-----8<-----~( cut here )~-----8<-----/,$p' \
| tail -n +2 \
| sed -e "s|^| |g
s|@PROJECT_ID@|$PROJECT_ID|g
s|@PROJECT_VERSION@|$PROJECT_VERSION|g
s|@PROJECT_DIST_URL@|$PROJECT_DIST_URL|g
s|@COMMIT_ID@|${COMMIT_ID:0:8}|g"
}

dump_release_notes() {
awk "f{print} /^Release date::/{f=1}" "$RELEASE_NOTES_FILE" \
| sed -r -e 's|'$PROJECT_REPO'/(issues|pull)/[0-9]+\[([0-9]+)\]|#\2|g
Expand All @@ -84,6 +73,7 @@ Commit: $COMMIT_ID
Distribution: $PROJECT_DIST_URL
Nexus: https://repository.apache.org/content/repositories/orgapachelogging-<FIXME>
Signing key: 0x077e8893a6dcc33dd4a4d5b256e73ba9a0b592d0
Review kit: https://s.apache.org/logging-parent-release-review-kit
Please download, test, and cast your votes on this mailing list.
Expand All @@ -96,13 +86,6 @@ everyone to test the release, but only the Logging Services PMC
votes are officially counted. At least 3 +1 votes and more
positive than negative votes are required.
== Review kit
The minimum set of steps needed to review the uploaded distribution
files in the Subversion repository can be summarized as follows:
$(dump_review_kit)
== Release Notes
EOF
dump_release_notes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ public void testSingleFilterInvocation() {
disruptor.start();
try {
config.log(FQCN, FQCN, null, Level.INFO, new SimpleMessage(), null);
verify(appender, timeout(100).times(1)).append(any());
// If this fails, the log event might not have reached the asynchronous thread yet
verify(appender, timeout(1000).times(1)).append(any());
verify(filter, times(1)).filter(any());
} finally {
disruptor.stop();
Expand Down
1 change: 1 addition & 0 deletions log4j-conversant/.log4j-plugin-processing-activator
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This file is here to activate the `plugin-processing` Maven profile.
90 changes: 90 additions & 0 deletions log4j-conversant/pom.xml
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>
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.logging.log4j.core.async;
package org.apache.logging.log4j.conversant;

import com.conversantmedia.util.concurrent.DisruptorBlockingQueue;
import com.conversantmedia.util.concurrent.SpinPolicy;
import java.util.concurrent.BlockingQueue;
import org.apache.logging.log4j.core.async.BlockingQueueFactory;
import org.apache.logging.log4j.plugins.Configurable;
import org.apache.logging.log4j.plugins.Plugin;
import org.apache.logging.log4j.plugins.PluginAttribute;
import org.apache.logging.log4j.plugins.PluginFactory;

/**
* Factory for creating instances of {@link DisruptorBlockingQueue}.
* A {@link BlockingQueueFactory} based on <a href="https://github.com/conversant/disruptor">Conversant Disruptor BlockingQueue</a>.
*
* @since 2.7
* @since 3.0.0
*/
@Configurable(elementType = BlockingQueueFactory.ELEMENT_TYPE, printObject = true)
@Plugin("DisruptorBlockingQueue")
public class DisruptorBlockingQueueFactory implements BlockingQueueFactory {
public final class DisruptorBlockingQueueFactory implements BlockingQueueFactory {

private final SpinPolicy spinPolicy;

Expand Down
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);
}
}
}
}
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) {}
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;
Loading

0 comments on commit 6a59e03

Please sign in to comment.