diff --git a/structured-event-log/pom.xml b/structured-event-log/pom.xml index dc026a4f9104e..f797e8b403537 100644 --- a/structured-event-log/pom.xml +++ b/structured-event-log/pom.xml @@ -58,4 +58,23 @@ test + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + checkstyle + verify + + check + + + + + + + diff --git a/structured-event-log/src/main/java/org/apache/pulsar/structuredeventlog/EventGroup.java b/structured-event-log/src/main/java/org/apache/pulsar/structuredeventlog/EventGroup.java index c3d4ca8ed93c7..6e24a25bce94d 100644 --- a/structured-event-log/src/main/java/org/apache/pulsar/structuredeventlog/EventGroup.java +++ b/structured-event-log/src/main/java/org/apache/pulsar/structuredeventlog/EventGroup.java @@ -21,7 +21,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -@Retention(value=RetentionPolicy.RUNTIME) +@Retention(value = RetentionPolicy.RUNTIME) public @interface EventGroup { String component(); } diff --git a/structured-event-log/src/main/java/org/apache/pulsar/structuredeventlog/EventResourcesImpl.java b/structured-event-log/src/main/java/org/apache/pulsar/structuredeventlog/EventResourcesImpl.java index 80df37e96ed34..710f56dce41f9 100644 --- a/structured-event-log/src/main/java/org/apache/pulsar/structuredeventlog/EventResourcesImpl.java +++ b/structured-event-log/src/main/java/org/apache/pulsar/structuredeventlog/EventResourcesImpl.java @@ -40,7 +40,7 @@ public EventResources resource(String key, Object value) { @Override public EventResources resource(String key, Supplier value) { - resource(key, (Object)value); + resource(key, (Object) value); return this; } @@ -77,7 +77,7 @@ public static void forEach(List list, BiConsumer process String key = String.valueOf(list.get(i)); Object value = list.get(i + 1); if (value instanceof Supplier) { - value = ((Supplier)value).get(); + value = ((Supplier) value).get(); } process.accept(key, String.valueOf(value)); } diff --git a/structured-event-log/src/main/java/org/apache/pulsar/structuredeventlog/StructuredEventLog.java b/structured-event-log/src/main/java/org/apache/pulsar/structuredeventlog/StructuredEventLog.java index 0c3f8346c9289..bf2a00215c9fb 100644 --- a/structured-event-log/src/main/java/org/apache/pulsar/structuredeventlog/StructuredEventLog.java +++ b/structured-event-log/src/main/java/org/apache/pulsar/structuredeventlog/StructuredEventLog.java @@ -85,7 +85,7 @@ public interface StructuredEventLog { /** * Create a new logger object, from which root events can be created. */ - public static StructuredEventLog newLogger() { + static StructuredEventLog newLogger() { return Slf4jStructuredEventLog.INSTANCE; } } diff --git a/structured-event-log/src/main/java/org/apache/pulsar/structuredeventlog/package-info.java b/structured-event-log/src/main/java/org/apache/pulsar/structuredeventlog/package-info.java new file mode 100644 index 0000000000000..0106ace349272 --- /dev/null +++ b/structured-event-log/src/main/java/org/apache/pulsar/structuredeventlog/package-info.java @@ -0,0 +1,19 @@ +/** + * 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.pulsar.structuredeventlog; diff --git a/structured-event-log/src/main/java/org/apache/pulsar/structuredeventlog/slf4j/Slf4jEvent.java b/structured-event-log/src/main/java/org/apache/pulsar/structuredeventlog/slf4j/Slf4jEvent.java index 69a36bf3251f4..3fef22e29a765 100644 --- a/structured-event-log/src/main/java/org/apache/pulsar/structuredeventlog/slf4j/Slf4jEvent.java +++ b/structured-event-log/src/main/java/org/apache/pulsar/structuredeventlog/slf4j/Slf4jEvent.java @@ -28,15 +28,13 @@ import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.TimeUnit; import java.util.function.Supplier; - import org.apache.pulsar.structuredeventlog.Event; import org.apache.pulsar.structuredeventlog.EventGroup; import org.apache.pulsar.structuredeventlog.EventResources; import org.apache.pulsar.structuredeventlog.EventResourcesImpl; - -import org.slf4j.MDC; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.slf4j.MDC; class Slf4jEvent implements Event { private static final ThreadLocal> loggersTLS = ThreadLocal.withInitial(() -> new HashMap<>()); @@ -89,7 +87,7 @@ public Event sampled(Object samplingKey, int duration, TimeUnit unit) { @Override public Event resources(EventResources other) { if (other instanceof EventResourcesImpl) { - this.resources.copyFrom((EventResourcesImpl)other); + this.resources.copyFrom((EventResourcesImpl) other); } return this; } @@ -115,7 +113,7 @@ public Event attr(String key, Object value) { @Override public Event attr(String key, Supplier value) { - this.attr(key, (Object)value); + this.attr(key, (Object) value); return this; } diff --git a/structured-event-log/src/main/java/org/apache/pulsar/structuredeventlog/slf4j/Slf4jStructuredEventLog.java b/structured-event-log/src/main/java/org/apache/pulsar/structuredeventlog/slf4j/Slf4jStructuredEventLog.java index 654216186aefb..5a88a714c35e1 100644 --- a/structured-event-log/src/main/java/org/apache/pulsar/structuredeventlog/slf4j/Slf4jStructuredEventLog.java +++ b/structured-event-log/src/main/java/org/apache/pulsar/structuredeventlog/slf4j/Slf4jStructuredEventLog.java @@ -19,14 +19,13 @@ package org.apache.pulsar.structuredeventlog.slf4j; import java.time.Clock; - import org.apache.pulsar.structuredeventlog.Event; import org.apache.pulsar.structuredeventlog.EventResources; import org.apache.pulsar.structuredeventlog.EventResourcesImpl; import org.apache.pulsar.structuredeventlog.StructuredEventLog; public class Slf4jStructuredEventLog implements StructuredEventLog { - public static Slf4jStructuredEventLog INSTANCE = new Slf4jStructuredEventLog(); + public static final Slf4jStructuredEventLog INSTANCE = new Slf4jStructuredEventLog(); // Visible for testing Clock clock = Clock.systemUTC(); diff --git a/structured-event-log/src/main/java/org/apache/pulsar/structuredeventlog/slf4j/package-info.java b/structured-event-log/src/main/java/org/apache/pulsar/structuredeventlog/slf4j/package-info.java new file mode 100644 index 0000000000000..971ac050d73d9 --- /dev/null +++ b/structured-event-log/src/main/java/org/apache/pulsar/structuredeventlog/slf4j/package-info.java @@ -0,0 +1,19 @@ +/** + * 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.pulsar.structuredeventlog.slf4j;