Skip to content
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

ARTEMIS-4751 upgrade to Apache parent 32 #4911

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
*/
package org.apache.activemq.artemis.cli.commands.messages.perf;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.concurrent.TimeUnit;

public class MicrosClock {

// no need for volatile here
private static long offset = -1;
private static long NANOS_PER_SECOND = TimeUnit.SECONDS.toNanos(1);
private static Class vm;
private static Method getNanoTimeAdjustment;

private static final boolean AVAILABLE = checkAvailable();

Expand All @@ -43,23 +47,32 @@ public static boolean isAvailable() {
}

public static long now() {
long epochSecond = offset;
long nanoAdjustment = jdk.internal.misc.VM.getNanoTimeAdjustment(epochSecond);
try {
long epochSecond = offset;
if (vm == null) {
vm = Class.forName("jdk.internal.misc.VM");
}
if (getNanoTimeAdjustment == null) {
getNanoTimeAdjustment = vm.getMethod("getNanoTimeAdjustment", long.class);
}
long nanoAdjustment = (long) getNanoTimeAdjustment.invoke(getNanoTimeAdjustment, epochSecond);

if (nanoAdjustment == -1) {
epochSecond = System.currentTimeMillis() / 1000 - 1024;
nanoAdjustment = jdk.internal.misc.VM.getNanoTimeAdjustment(epochSecond);
if (nanoAdjustment == -1) {
throw new InternalError("Offset " + epochSecond + " is not in range");
} else {
offset = epochSecond;
epochSecond = System.currentTimeMillis() / 1000 - 1024;
nanoAdjustment = (long) getNanoTimeAdjustment.invoke(getNanoTimeAdjustment, epochSecond);
if (nanoAdjustment == -1) {
throw new InternalError("Offset " + epochSecond + " is not in range");
} else {
offset = epochSecond;
}
}
final long secs = Math.addExact(epochSecond, Math.floorDiv(nanoAdjustment, NANOS_PER_SECOND));
final long secsInUs = TimeUnit.SECONDS.toMicros(secs);
final long nsOffset = (int) Math.floorMod(nanoAdjustment, NANOS_PER_SECOND);
final long usOffset = TimeUnit.NANOSECONDS.toMicros(nsOffset);
return secsInUs + usOffset;
} catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
throw new IllegalStateException(e);
}
final long secs = Math.addExact(epochSecond, Math.floorDiv(nanoAdjustment, NANOS_PER_SECOND));
final long secsInUs = TimeUnit.SECONDS.toMicros(secs);
final long nsOffset = (int) Math.floorMod(nanoAdjustment, NANOS_PER_SECOND);
final long usOffset = TimeUnit.NANOSECONDS.toMicros(nsOffset);
return secsInUs + usOffset;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ HAWTIO_ROLE='${role}'

# Java Opts
if [ -z "$JAVA_ARGS" ]; then
JAVA_ARGS="-XX:AutoBoxCacheMax=20000 -XX:+PrintClassHistogram -XX:+UseG1GC -XX:+UseStringDeduplication -Xms512M -Xmx${java-memory} -Dhawtio.disableProxy=true -Dhawtio.realm=activemq -Dhawtio.offline=true -Dhawtio.rolePrincipalClasses=org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal -Dhawtio.http.strictTransportSecurity=max-age=31536000;includeSubDomains;preload -Djolokia.policyLocation=${ARTEMIS_INSTANCE_ETC_URI}jolokia-access.xml -Dlog4j2.disableJmx=true ${java-opts}"
JAVA_ARGS="-XX:AutoBoxCacheMax=20000 -XX:+PrintClassHistogram -XX:+UseG1GC -XX:+UseStringDeduplication -Xms512M -Xmx${java-memory} -Dhawtio.disableProxy=true -Dhawtio.realm=activemq -Dhawtio.offline=true -Dhawtio.rolePrincipalClasses=org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal -Dhawtio.http.strictTransportSecurity=max-age=31536000;includeSubDomains;preload -Djolokia.policyLocation=${ARTEMIS_INSTANCE_ETC_URI}jolokia-access.xml -Dlog4j2.disableJmx=true --add-opens java.base/jdk.internal.misc=ALL-UNNAMED ${java-opts}"
fi

# Uncomment to enable logging for Safepoint JVM pauses
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ rem Cluster Properties: Used to pass arguments to ActiveMQ Artemis which can be
rem set ARTEMIS_CLUSTER_PROPS=-Dactivemq.remoting.default.port=61617 -Dactivemq.remoting.amqp.port=5673 -Dactivemq.remoting.stomp.port=61614 -Dactivemq.remoting.hornetq.port=5446

rem Java Opts
IF "%JAVA_ARGS%"=="" (set JAVA_ARGS=${java-opts} -XX:AutoBoxCacheMax=20000 -XX:+PrintClassHistogram -XX:+UseG1GC -XX:+UseStringDeduplication -Xms512M -Xmx${java-memory} -Djava.security.auth.login.config=%ARTEMIS_ETC_DIR%\login.config -Dhawtio.disableProxy=true -Dhawtio.offline=true -Dhawtio.realm=activemq -Dhawtio.role=${role} -Dhawtio.rolePrincipalClasses=org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal -Dhawtio.http.strictTransportSecurity=max-age=31536000;includeSubDomains;preload -Djolokia.policyLocation=%ARTEMIS_INSTANCE_ETC_URI%\jolokia-access.xml -Dartemis.instance=%ARTEMIS_INSTANCE% -Dlog4j2.disableJmx=true)
IF "%JAVA_ARGS%"=="" (set JAVA_ARGS=${java-opts} -XX:AutoBoxCacheMax=20000 -XX:+PrintClassHistogram -XX:+UseG1GC -XX:+UseStringDeduplication -Xms512M -Xmx${java-memory} -Djava.security.auth.login.config=%ARTEMIS_ETC_DIR%\login.config -Dhawtio.disableProxy=true -Dhawtio.offline=true -Dhawtio.realm=activemq -Dhawtio.role=${role} -Dhawtio.rolePrincipalClasses=org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal -Dhawtio.http.strictTransportSecurity=max-age=31536000;includeSubDomains;preload -Djolokia.policyLocation=%ARTEMIS_INSTANCE_ETC_URI%\jolokia-access.xml -Dartemis.instance=%ARTEMIS_INSTANCE% --add-opens java.base/jdk.internal.misc=ALL-UNNAMED -Dlog4j2.disableJmx=true)

rem Logs Safepoints JVM pauses: Uncomment to enable them
rem In addition to the traditional GC logs you could enable some JVM flags to know any meaningful and "hidden" pause that could
Expand Down
19 changes: 1 addition & 18 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<parent>
<groupId>org.apache</groupId>
<artifactId>apache</artifactId>
<version>31</version>
<version>32</version>
<relativePath>org.apache:apache</relativePath>
</parent>

Expand Down Expand Up @@ -119,9 +119,6 @@
<zookeeper.version>3.9.1</zookeeper.version>
<woodstox.version>4.4.0</woodstox.version>
<pem-keystore.version>2.3.0</pem-keystore.version>
<!-- This overrides the Apache parent POM due to https://issues.apache.org/jira/browse/MSHADE-462. Once that issue
is resolved and a new Apache parent is released then we can get rid of this. -->
<version.maven-shade-plugin>3.4.1</version.maven-shade-plugin>

<!-- This overrides the Apache parent POM. Once a new Apache parent is released with the latest version then we
can get rid of this. -->
Expand Down Expand Up @@ -340,8 +337,6 @@
<configuration>
<compilerArgs>
<arg>-Xdiags:verbose</arg>
<arg>--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED</arg>
<arg>--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED</arg>
<arg>-XDcompilePolicy=simple</arg>
<arg>-Xplugin:ErrorProne -Xep:ThreadLocalUsage:ERROR -Xep:MissingOverride:ERROR -Xep:NonAtomicVolatileUpdate:ERROR -Xep:SynchronizeOnNonFinalField:ERROR -Xep:StaticQualifiedUsingExpression:ERROR -Xep:WaitNotInLoop:ERROR -Xep:BanJNDI:OFF -XepExcludedPaths:.*/generated-sources/.*</arg>
</compilerArgs>
Expand Down Expand Up @@ -376,8 +371,6 @@
<fork>true</fork>
<compilerArgs>
<arg>-Xdiags:verbose</arg>
<arg>--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED</arg>
<arg>--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED</arg>
<arg>-XDcompilePolicy=simple</arg>
<arg>-Xplugin:ErrorProne -Xep:ThreadLocalUsage:ERROR -Xep:MissingOverride:WARN -Xep:NonAtomicVolatileUpdate:ERROR -Xep:SynchronizeOnNonFinalField:ERROR -Xep:StaticQualifiedUsingExpression:ERROR -Xep:WaitNotInLoop:ERROR -Xep:BanJNDI:OFF -XepExcludedPaths:.*/generated-sources/.*</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</arg>
Expand Down Expand Up @@ -829,16 +822,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<showWarnings>true</showWarnings>
<compilerArgs>
<arg>--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-rar-plugin</artifactId>
Expand Down
10 changes: 0 additions & 10 deletions tests/smoke-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -291,16 +291,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs>
<arg>--add-exports=java.rmi/sun.rmi.server=ALL-UNNAMED</arg>
<arg>--add-exports=java.rmi/sun.rmi.transport=ALL-UNNAMED</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import javax.management.remote.rmi.RMIConnector;
import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.rmi.server.RemoteObject;
import java.rmi.server.RemoteRef;

Expand All @@ -36,8 +37,6 @@
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import sun.rmi.server.UnicastRef;
import sun.rmi.transport.LiveRef;

/**
* This test checks JMX connection to Artemis with both necessary ports set up so that it's easier to tunnel through
Expand Down Expand Up @@ -142,12 +141,13 @@ public void testJmxConnection() throws Throwable {
remoteRefField = (RemoteRef) UnsafeAccess.UNSAFE.getObject(remoteRef, UnsafeAccess.UNSAFE.objectFieldOffset(refField));
}
Assert.assertNotNull(remoteRefField);
Assert.assertTrue(remoteRefField instanceof UnicastRef);
Assert.assertEquals("sun.rmi.server.UnicastRef2", remoteRefField.getClass().getTypeName());

// 5. UnicastRef::getLiveRef returns LiveRef
LiveRef liveRef = ((UnicastRef) remoteRefField).getLiveRef();
Method getLiveRef = remoteRefField.getClass().getMethod("getLiveRef");
Object liveRef = getLiveRef.invoke(remoteRefField);

Assert.assertEquals(RMI_REGISTRY_PORT, liveRef.getPort());
Assert.assertEquals(RMI_REGISTRY_PORT, liveRef.getClass().getMethod("getPort").invoke(liveRef));

} finally {
jmxConnector.close();
Expand Down
Loading