Skip to content

Commit

Permalink
Enable CheckStyle Plugin in Pulsar metadata (apache#13284)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhangJian He authored Dec 14, 2021
1 parent 56323e4 commit 12ca27f
Show file tree
Hide file tree
Showing 41 changed files with 213 additions and 80 deletions.
13 changes: 13 additions & 0 deletions pulsar-metadata/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<id>checkstyle</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;

import org.apache.pulsar.metadata.api.MetadataStoreException.AlreadyExistsException;
import org.apache.pulsar.metadata.api.MetadataStoreException.NotFoundException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@

import com.fasterxml.jackson.core.type.TypeReference;
import com.google.common.annotations.Beta;

import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;

import org.apache.pulsar.metadata.api.MetadataStoreException.BadVersionException;
import org.apache.pulsar.metadata.api.MetadataStoreException.NotFoundException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,25 @@ public class MetadataStoreConfig {
private final String configFilePath = null;

/**
* Whether we should enable metadata operations batching
* Whether we should enable metadata operations batching.
*/
@Builder.Default
private final boolean batchingEnabled = true;

/**
* Maximum delay to impose on batching grouping
* Maximum delay to impose on batching grouping.
*/
@Builder.Default
private final int batchingMaxDelayMillis = 5;

/**
* Maximum number of operations to include in a singular batch
* Maximum number of operations to include in a singular batch.
*/
@Builder.Default
private final int batchingMaxOperations = 1_000;

/**
* Maximum size of a batch
* Maximum size of a batch.
*/
@Builder.Default
private final int batchingMaxSizeKb = 128;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public MetadataStoreException(String msg, Throwable t) {
}

/**
* Implementation is invalid
* Implementation is invalid.
*/
public static class InvalidImplementationException extends MetadataStoreException {
public InvalidImplementationException() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
package org.apache.pulsar.metadata.api;

import java.io.IOException;

import lombok.experimental.UtilityClass;

import org.apache.pulsar.metadata.impl.MetadataStoreFactoryImpl;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public final class Notification {
private final NotificationType type;

/**
* Path of the kev/value pair interested by the notification
* Path of the kev/value pair interested by the notification.
*/
private final String path;
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
public class Stat {

/**
* The path of the value
* The path of the value.
*/
final String path;

Expand All @@ -47,12 +47,12 @@ public class Stat {
final long modificationTimestamp;

/**
* Whether the key-value pair is ephemeral or persistent
* Whether the key-value pair is ephemeral or persistent.
*/
final boolean ephemeral;

/**
* Whether the key-value pair had been created within the current "session"
* Whether the key-value pair had been created within the current "session".
*/
final boolean createdBySelf;
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@ public interface LeaderElection<T> extends AutoCloseable {
* @param proposedValue
* the value to set for the leader, in the case this instance succeeds in becoming leader
* @return a future that will track the completion of the operation
* @throws MetadataStoreException
* if there's a failure in the leader election
*/
CompletableFuture<LeaderElectionState> elect(T proposedValue);

/**
* Get the current leader election state
* Get the current leader election state.
*/
LeaderElectionState getState();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@
*/
public enum LeaderElectionState {
/**
* No leader has been elected yet
* No leader has been elected yet.
*/
NoLeader,

/**
* We are currently the leader
* We are currently the leader.
*/
Leading,

/**
* Follower state
* Follower state.
*/
Following
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;

import org.apache.pulsar.metadata.api.MetadataStoreException;
import org.apache.pulsar.metadata.api.MetadataStoreException.LockBusyException;
import org.apache.pulsar.metadata.api.MetadataStoreException.NotFoundException;
Expand All @@ -41,8 +40,6 @@ public interface LockManager<T> extends AutoCloseable {
*
* @param path
* the path of the resource on which to acquire the lock
* @param content
* the payload of the lock
* @return a future that will track the completion of the operation
* @throws NotFoundException
* if the lock is not taken
Expand Down
Original file line number Diff line number Diff line change
@@ -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.metadata.api.coordination;
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
package org.apache.pulsar.metadata.api.extended;

/**
* Options to use when creating key-value pairs on the {@link MetadataStoreExtended}
* Options to use when creating key-value pairs on the {@link MetadataStoreExtended}.
*/
public enum CreateOption {
/**
* The key-value pair will automatically expires when the session is terminated
* The key-value pair will automatically expires when the session is terminated.
*/
Ephemeral,

/**
* Create a sequential unique key
* Create a sequential unique key.
*/
Sequential
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;

import org.apache.pulsar.metadata.api.MetadataStore;
import org.apache.pulsar.metadata.api.MetadataStoreConfig;
import org.apache.pulsar.metadata.api.MetadataStoreException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
package org.apache.pulsar.metadata.api.extended;

/**
* An event regarding a session of MetadataStore
* An event regarding a session of MetadataStore.
*/
public enum SessionEvent {

/**
* The client is temporarily disconnected, although the session is still valid
* The client is temporarily disconnected, although the session is still valid.
*/
ConnectionLost,

/**
* The client was able to successfully reconnect
* The client was able to successfully reconnect.
*/
Reconnected,

Expand All @@ -40,7 +40,7 @@ public enum SessionEvent {
SessionLost,

/**
* The session was established
* The session was established.
*/
SessionReestablished;

Expand Down
Original file line number Diff line number Diff line change
@@ -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.metadata.api.extended;
Original file line number Diff line number Diff line change
@@ -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.metadata.api;
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ protected void asyncProcessLedgersInSingleNode(
final int successRc, final int failureRc) {
store.getChildren(path)
.thenAccept(ledgerNodes -> {
Set<Long> activeLedgers = HierarchicalLedgerUtils.ledgerListToSet(ledgerNodes, ledgerRootPath, path);
Set<Long> activeLedgers = HierarchicalLedgerUtils.ledgerListToSet(ledgerNodes,
ledgerRootPath, path);
if (log.isDebugEnabled()) {
log.debug("Processing ledgers: {}", activeLedgers);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import lombok.Cleanup;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.apache.bookkeeper.bookie.Bookie;
Expand Down Expand Up @@ -303,10 +302,10 @@ public static ClientConfiguration newBaseClientConfiguration() {
private static String getLoopbackInterfaceName() {
try {
Enumeration<NetworkInterface> nifs = NetworkInterface.getNetworkInterfaces();
Iterator var1 = Collections.list(nifs).iterator();
Iterator<NetworkInterface> var1 = Collections.list(nifs).iterator();

while(var1.hasNext()) {
NetworkInterface nif = (NetworkInterface)var1.next();
while (var1.hasNext()) {
NetworkInterface nif = var1.next();
if (nif.isLoopback()) {
return nif.getName();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.bookkeeper.discover.BookieServiceInfo;
import org.apache.bookkeeper.proto.DataFormats.BookieServiceInfoFormat;
import org.apache.bookkeeper.server.service.BookieService;
import org.apache.pulsar.metadata.api.MetadataSerde;
import org.apache.pulsar.metadata.api.Stat;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public LedgerAuditorManager newLedgerAuditorManager() throws IOException, Interr
@Override
public void format(AbstractConfiguration<?> abstractConfiguration, LayoutManager layoutManager)
throws InterruptedException, IOException {
// TODO: XXX
// TODO: format
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
import org.apache.bookkeeper.replication.ReplicationException;
import org.apache.bookkeeper.util.BookKeeperConstants;
import org.apache.pulsar.metadata.api.GetResult;
import org.apache.pulsar.metadata.api.MetadataStore;
import org.apache.pulsar.metadata.api.MetadataStoreException;
import org.apache.pulsar.metadata.api.Notification;
import org.apache.pulsar.metadata.api.NotificationType;
Expand Down
Original file line number Diff line number Diff line change
@@ -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.metadata.bookkeeper;
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
package org.apache.pulsar.metadata.cache.impl;

import com.fasterxml.jackson.core.type.TypeReference;

import java.io.IOException;

import org.apache.pulsar.common.util.ObjectMapperFactory;
import org.apache.pulsar.metadata.api.MetadataSerde;
import org.apache.pulsar.metadata.api.Stat;
Expand Down
Loading

0 comments on commit 12ca27f

Please sign in to comment.