Skip to content

Commit

Permalink
fix license, findbug of dereference, line length
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveTeng0 committed May 22, 2024
1 parent cfd4cf3 commit eae5ae0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,11 @@ public static RaftGroupId retrieveRemoteGroupId(RaftGroupId raftGroupIdFromConfi
return remoteGroupId;
}

public static GroupInfoReply retrieveGroupInfoByGroupId(RaftGroupId remoteGroupId, List<RaftPeer> peers, RaftClient client, PrintStream printStream)
public static GroupInfoReply retrieveGroupInfoByGroupId(RaftGroupId remoteGroupId, List<RaftPeer> peers,
RaftClient client, PrintStream printStream)
throws IOException {
GroupInfoReply groupInfoReply = runFunction(peers, p -> client.getGroupManagementApi((p.getId())).info(remoteGroupId));
GroupInfoReply groupInfoReply = runFunction(peers,
p -> client.getGroupManagementApi((p.getId())).info(remoteGroupId));
processReply(groupInfoReply,
printStream::println, "Failed to get group info for group id " + remoteGroupId.getUuid() + " from " + peers);
return groupInfoReply;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* 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.ratis.shell.cli;

import org.slf4j.Logger;
Expand All @@ -17,7 +34,9 @@
import java.util.Arrays;

public class SecurityUtils {
static Logger LOG = LoggerFactory.getLogger(SecurityUtils.class);
private SecurityUtils() {
// prevent instantiation
}

public static KeyStore getTrustStore()
throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,12 @@ protected AbstractRatisCommand(Context context) {

@Override
public int run(CommandLine cl) throws IOException {

List<RaftPeer> peers = buildRaftPeersFromStr(cl.getOptionValue(PEER_OPTION_NAME));
RaftGroupId raftGroupIdFromConfig = buildRaftGroupIdFromStr(cl.getOptionValue(GROUPID_OPTION_NAME));
raftGroup = RaftGroup.valueOf(raftGroupIdFromConfig, peers);

try (final RaftClient client = getRaftClient(cl.hasOption(TLS_ENABLED_OPTION_NAME))) {
RaftGroupId remoteGroupId = retrieveRemoteGroupId(raftGroupIdFromConfig, peers, client, printStream);;
RaftGroupId remoteGroupId = retrieveRemoteGroupId(raftGroupIdFromConfig, peers, client, printStream);
groupInfoReply = retrieveGroupInfoByGroupId(remoteGroupId, peers, client, printStream);
raftGroup = groupInfoReply.getGroup();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public int run(CommandLine cl) throws IOException {
peerId = null;
}
RaftClientReply reply = raftClient.getSnapshotManagementApi(peerId).create(timeout);
processReply(reply, this::println, String.format("Failed to take snapshot of peerId %s", peerId.toString()));
processReply(reply, this::println, String.format("Failed to take snapshot of peerId %s", peerId != null ? peerId.toString() : null));
printf(String.format("Successful take snapshot on peerId %s, the latest snapshot index is %d",
peerId, reply.getLogIndex()));
}
Expand Down

0 comments on commit eae5ae0

Please sign in to comment.