From 982eeffa3aa81742fd9ca9b578af1b1b937496e4 Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Tue, 3 Dec 2024 10:58:37 -0500 Subject: [PATCH] Code cleanup --- .../solr/handler/ReplicationHandler.java | 32 ++++++------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java index 0a5ce9c3453..bdb5ae08647 100644 --- a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java @@ -42,7 +42,6 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Date; @@ -154,8 +153,6 @@ public class ReplicationHandler extends RequestHandlerBase private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); SolrCore core; - private volatile boolean closed = false; - @Override public Name getPermissionName(AuthorizationContext request) { return Name.READ_PERM; @@ -228,8 +225,6 @@ public String toString() { private volatile long executorStartTime; - private int numTimesReplicated = 0; - private final Map confFileInfoCache = new HashMap<>(); private Long reserveCommitDuration = readIntervalMs("00:00:10"); @@ -324,8 +319,7 @@ public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throw * @see IndexFetcher.LocalFsFileFetcher * @see IndexFetcher.DirectoryFileFetcher */ - private void getFileStream(SolrParams solrParams, SolrQueryResponse rsp, SolrQueryRequest req) - throws IOException { + private void getFileStream(SolrParams solrParams, SolrQueryResponse rsp, SolrQueryRequest req) { final CoreReplication coreReplicationAPI = new CoreReplication(core, req, rsp); String fileName; String dirType; @@ -809,14 +803,6 @@ private Date getNextScheduledExecTime() { return nextTime; } - int getTimesReplicatedSinceStartup() { - return numTimesReplicated; - } - - void setTimesReplicatedSinceStartup() { - numTimesReplicated++; - } - @Override public Category getCategory() { return Category.REPLICATION; @@ -1052,7 +1038,7 @@ private NamedList getReplicationDetails( follower.add("replicationStartTime", replicationStartTimeStamp.toString()); } long elapsed = fetcher.getReplicationTimeElapsed(); - follower.add("timeElapsed", String.valueOf(elapsed) + "s"); + follower.add("timeElapsed", elapsed + "s"); if (bytesDownloaded > 0) estimatedTimeRemaining = @@ -1117,13 +1103,13 @@ private Object formatVal(String key, Properties props, Class clzz) { if (s == null || s.trim().length() == 0) return null; if (clzz == Date.class) { try { - Long l = Long.parseLong(s); + long l = Long.parseLong(s); return new Date(l).toString(); } catch (NumberFormatException e) { return null; } } else if (clzz == List.class) { - String ss[] = s.split(","); + String[] ss = s.split(","); List l = new ArrayList<>(); for (String s1 : ss) { l.add(new Date(Long.parseLong(s1)).toString()); @@ -1281,11 +1267,11 @@ public void inform(SolrCore core) { if (enableLeader) { includeConfFiles = (String) leader.get(CONF_FILES); if (includeConfFiles != null && includeConfFiles.trim().length() > 0) { - List files = Arrays.asList(includeConfFiles.split(",")); + String[] files = includeConfFiles.split(","); for (String file : files) { if (file.trim().length() == 0) continue; String[] strs = file.trim().split(":"); - // if there is an alias add it or it is null + // if there is an alias add it, or it is null confFileNameAlias.add(strs[0], strs.length > 1 ? strs[1] : null); } log.info("Replication enabled for following config files: {}", includeConfFiles); @@ -1356,7 +1342,7 @@ public void inform(SolrCore core) { } } - // ensure the writer is init'd so that we have a list of commit points + // ensure the writer is initialized so that we have a list of commit points RefCounted iw = core.getUpdateHandler().getSolrCoreState().getIndexWriter(core); iw.decref(); @@ -1541,7 +1527,7 @@ private Long readIntervalNs(String interval) { public static final String FETCH_FROM_LEADER = "fetchFromLeader"; // in case of TLOG replica, if leaderVersion = zero, don't do commit - // otherwise updates from current tlog won't copied over properly to the new tlog, leading to data + // otherwise updates from current tlog won't be copied over properly to the new tlog, leading to data // loss // don't commit on leader version zero for PULL replicas as PULL should only get its index // state from leader @@ -1608,7 +1594,7 @@ private Long readIntervalNs(String interval) { /** * Boolean param for tests that can be specified when using {@link #CMD_FETCH_INDEX} to force the * current request to block until the fetch is complete. NOTE: This param is not advised - * for non-test code, since the duration of the fetch for non-trivial indexes will likeley cause + * for non-test code, since the duration of the fetch for non-trivial indexes will likely cause * the request to time out. * * @lucene.internal