Skip to content

Commit

Permalink
fix import
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveTeng0 committed May 21, 2024
1 parent ca41aca commit cfd4cf3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@
import org.apache.ratis.grpc.GrpcConfigKeys;
import org.apache.ratis.grpc.GrpcTlsConfig;
import org.apache.ratis.netty.NettyConfigKeys;
import org.apache.ratis.protocol.*;
import org.apache.ratis.protocol.GroupInfoReply;
import org.apache.ratis.protocol.RaftClientReply;
import org.apache.ratis.protocol.RaftGroup;
import org.apache.ratis.protocol.RaftGroupId;
import org.apache.ratis.protocol.RaftPeer;
import org.apache.ratis.protocol.RaftPeerId;
import org.apache.ratis.protocol.exceptions.RaftException;
import org.apache.ratis.retry.ExponentialBackoffRetry;
import org.apache.ratis.rpc.RpcType;
Expand All @@ -35,10 +40,15 @@
import java.io.IOException;
import java.io.PrintStream;
import java.net.InetSocketAddress;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.concurrent.TimeUnit;
import java.util.function.*;
import java.util.function.Consumer;
import java.util.List;
import java.util.Optional;
import java.util.Properties;
import java.util.stream.Collectors;
import java.util.UUID;

/**
* Helper class for raft operations.
Expand All @@ -47,7 +57,6 @@ public final class RaftUtils {

public static final RaftGroupId DEFAULT_RAFT_GROUP_ID = RaftGroupId.randomId();


private RaftUtils() {
// prevent instantiation
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,15 @@
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
import java.io.*;
import java.net.URL;
import java.io.InputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.Arrays;
import java.util.Optional;
import java.util.function.Supplier;

public class SecurityUtils {
static Logger LOG = LoggerFactory.getLogger(SecurityUtils.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
package org.apache.ratis.shell.cli.sh.command;

import org.apache.commons.cli.Option;
import org.apache.ratis.protocol.*;
import org.apache.ratis.protocol.exceptions.RaftException;
import org.apache.ratis.protocol.RaftGroup;
import org.apache.ratis.protocol.RaftGroupId;
import org.apache.ratis.protocol.RaftPeer;
import org.apache.ratis.protocol.RaftPeerId;
import org.apache.ratis.protocol.GroupInfoReply;
import org.apache.ratis.rpc.SupportedRpcType;
import org.apache.ratis.shell.cli.RaftUtils;
import org.apache.commons.cli.CommandLine;
Expand All @@ -39,18 +42,19 @@
import java.io.IOException;
import java.io.PrintStream;
import java.net.InetSocketAddress;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static org.apache.ratis.shell.cli.RaftUtils.*;
import static org.apache.ratis.shell.cli.RaftUtils.buildRaftGroupIdFromStr;
import static org.apache.ratis.shell.cli.RaftUtils.buildRaftPeersFromStr;
import static org.apache.ratis.shell.cli.RaftUtils.retrieveGroupInfoByGroupId;
import static org.apache.ratis.shell.cli.RaftUtils.retrieveRemoteGroupId;

/**
* The base class for the ratis shell which need to connect to server.
Expand All @@ -61,8 +65,6 @@ public abstract class AbstractRatisCommand extends AbstractCommand {
public static final String TLS_ENABLED_OPTION_NAME = "t";
private PrintStream printStream;



/**
* Execute a given function with input parameter from the members of a list.
*
Expand Down Expand Up @@ -152,17 +154,6 @@ protected RaftPeerProto getLeader(RoleInfoProto roleInfo) {
return followerInfo.getLeaderInfo().getId();
}

// protected void processReply(RaftClientReply reply, Supplier<String> messageSupplier) throws IOException {
// if (reply == null || !reply.isSuccess()) {
// final RaftException e = Optional.ofNullable(reply)
// .map(RaftClientReply::getException)
// .orElseGet(() -> new RaftException("Reply: " + reply));
// final String message = messageSupplier.get();
// printf(printStream, "%s. Error: %s%n", message, e);
// throw new IOException(message, e);
// }
// }

protected List<RaftPeerId> getIds(String[] optionValues, BiConsumer<RaftPeerId, InetSocketAddress> consumer) {
if (optionValues == null) {
return Collections.emptyList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private boolean tryTransfer(RaftClient client, RaftPeer newLeader, int highestPr
}
RaftClientReply transferLeadershipReply =
client.admin().transferLeadership(newLeader.getId(), timeout.toLong(TimeUnit.MILLISECONDS));
processReply(transferLeadershipReply, this::println,"election failed");
processReply(transferLeadershipReply, this::println, "election failed");
} catch (TransferLeadershipException tle) {
if (tle.getMessage().contains("it does not has highest priority")) {
return false;
Expand Down

0 comments on commit cfd4cf3

Please sign in to comment.