Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
epugh committed Dec 3, 2024
1 parent 51c34fa commit 982eeff
Showing 1 changed file with 9 additions and 23 deletions.
32 changes: 9 additions & 23 deletions solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -228,8 +225,6 @@ public String toString() {

private volatile long executorStartTime;

private int numTimesReplicated = 0;

private final Map<String, FileInfo> confFileInfoCache = new HashMap<>();

private Long reserveCommitDuration = readIntervalMs("00:00:10");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -809,14 +803,6 @@ private Date getNextScheduledExecTime() {
return nextTime;
}

int getTimesReplicatedSinceStartup() {
return numTimesReplicated;
}

void setTimesReplicatedSinceStartup() {
numTimesReplicated++;
}

@Override
public Category getCategory() {
return Category.REPLICATION;
Expand Down Expand Up @@ -1052,7 +1038,7 @@ private NamedList<Object> 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 =
Expand Down Expand Up @@ -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<String> l = new ArrayList<>();
for (String s1 : ss) {
l.add(new Date(Long.parseLong(s1)).toString());
Expand Down Expand Up @@ -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<String> 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);
Expand Down Expand Up @@ -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<IndexWriter> iw =
core.getUpdateHandler().getSolrCoreState().getIndexWriter(core);
iw.decref();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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. <b>NOTE:</b> 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
Expand Down

0 comments on commit 982eeff

Please sign in to comment.