Skip to content

Commit 3deca3f

Browse files
committed
chore: add asl
Signed-off-by: Marcos Tischer Vallim <tischer@gmail.com>
1 parent 6d6f7db commit 3deca3f

5 files changed

Lines changed: 120 additions & 40 deletions

File tree

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.amazon.sns.messaging.lib.concurrent;
218

319
import java.lang.reflect.Method;
@@ -14,11 +30,11 @@
1430

1531
@NoArgsConstructor(access = AccessLevel.PRIVATE)
1632
public final class ExecutorsProvider {
17-
33+
1834
private static final Logger LOGGER = LoggerFactory.getLogger(ExecutorsProvider.class);
19-
35+
2036
private static Supplier<ExecutorService> supplierExecutorService;
21-
37+
2238
static {
2339
if (ExecutorsProvider.getJavaVersion() >= 21) {
2440
ExecutorsProvider.supplierExecutorService = ExecutorsProvider::getVirtualThreadExecutor;
@@ -28,35 +44,35 @@ public final class ExecutorsProvider {
2844
ExecutorsProvider.LOGGER.info("Java version is {}, using default thread executor", ExecutorsProvider.getJavaVersion());
2945
}
3046
}
31-
47+
3248
public static ExecutorService getThreadExecutor() {
3349
return ExecutorsProvider.supplierExecutorService.get();
3450
}
35-
51+
3652
@SneakyThrows
3753
private static ExecutorService getDefaultThreadExecutor() {
3854
return Executors.newSingleThreadExecutor();
3955
}
40-
56+
4157
@SneakyThrows
4258
private static ExecutorService getVirtualThreadExecutor() {
4359
final Class<?> clazzThread = Executors.class;
4460
final Method ofVirtualMethod = clazzThread.getMethod("newVirtualThreadPerTaskExecutor");
4561
return ExecutorService.class.cast(ofVirtualMethod.invoke(null));
4662
}
47-
63+
4864
private static int getJavaVersion() {
4965
String version = System.getProperty("java.version");
50-
66+
5167
if (version.startsWith("1.")) {
5268
version = version.substring(2);
5369
}
54-
70+
5571
final int dotPos = version.indexOf('.');
5672
final int dashPos = version.indexOf('-');
5773
final int endIndex = dotPos > -1 ? dotPos : dashPos > -1 ? dashPos : 1;
58-
74+
5975
return Integer.parseInt(version.substring(0, endIndex));
6076
}
61-
77+
6278
}
Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.amazon.sns.messaging.lib.instrument;
218

319
import java.lang.management.ManagementFactory;
@@ -11,27 +27,27 @@
1127

1228
@NoArgsConstructor(access = AccessLevel.PRIVATE)
1329
public final class MBeanRegistrar {
14-
30+
1531
private static final MBeanServer BEAN_SERVER = ManagementFactory.getPlatformMBeanServer();
16-
32+
1733
@SneakyThrows
1834
public static void registerMBean(final Object mbean, final String name) {
1935
final ObjectName objectName = new ObjectName(name);
20-
36+
2137
if (!MBeanRegistrar.BEAN_SERVER.isRegistered(objectName)) {
2238
MBeanRegistrar.BEAN_SERVER.registerMBean(mbean, objectName);
2339
}
24-
25-
}
2640

41+
}
42+
2743
@SneakyThrows
2844
public static void unregisterMBean(final String name) {
2945
final ObjectName objectName = new ObjectName(name);
30-
46+
3147
if (MBeanRegistrar.BEAN_SERVER.isRegistered(objectName)) {
3248
MBeanRegistrar.BEAN_SERVER.unregisterMBean(objectName);
3349
}
34-
50+
3551
}
36-
52+
3753
}
Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.amazon.sns.messaging.lib.instrument;
218

319
import com.amazon.sns.messaging.lib.concurrent.RingBufferBlockingQueue;
@@ -6,37 +22,37 @@
622

723
@RequiredArgsConstructor
824
public class RingBufferBlockingQueueJmx implements RingBufferBlockingQueueJmxMBean {
9-
25+
1026
private final RingBufferBlockingQueue<?> ringBufferBlockingQueue;
11-
27+
1228
@Override
1329
public int capacity() {
14-
return this.ringBufferBlockingQueue.capacity();
30+
return ringBufferBlockingQueue.capacity();
1531
}
16-
32+
1733
@Override
1834
public int size() {
19-
return this.ringBufferBlockingQueue.size();
35+
return ringBufferBlockingQueue.size();
2036
}
21-
37+
2238
@Override
2339
public boolean isEmpty() {
24-
return this.ringBufferBlockingQueue.isEmpty();
40+
return ringBufferBlockingQueue.isEmpty();
2541
}
26-
42+
2743
@Override
2844
public boolean isFull() {
29-
return this.ringBufferBlockingQueue.isFull();
45+
return ringBufferBlockingQueue.isFull();
3046
}
31-
47+
3248
@Override
3349
public long writeSequence() {
34-
return this.ringBufferBlockingQueue.writeSequence();
50+
return ringBufferBlockingQueue.writeSequence();
3551
}
36-
52+
3753
@Override
3854
public long readSequence() {
39-
return this.ringBufferBlockingQueue.readSequence();
55+
return ringBufferBlockingQueue.readSequence();
4056
}
41-
57+
4258
}
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,33 @@
1+
/*
2+
* Copyright 2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.amazon.sns.messaging.lib.instrument;
218

319
public interface RingBufferBlockingQueueJmxMBean {
4-
20+
521
int capacity();
6-
22+
723
int size();
8-
24+
925
boolean isEmpty();
10-
26+
1127
boolean isFull();
12-
28+
1329
long writeSequence();
14-
30+
1531
long readSequence();
16-
32+
1733
}

amazon-sns-java-messaging-lib-template/src/test/java/com/amazon/sns/messaging/lib/core/ListenableFutureRegistryTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.amazon.sns.messaging.lib.core;
218

319
import static org.hamcrest.CoreMatchers.notNullValue;

0 commit comments

Comments
 (0)