-
Notifications
You must be signed in to change notification settings - Fork 675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SOLR-17579: Refactoring suggested by IDE in ReplicationHandler and tests #2893
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -153,8 +152,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; | ||
|
@@ -227,8 +224,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"); | ||
|
@@ -323,8 +318,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; | ||
|
@@ -800,14 +794,6 @@ private Date getNextScheduledExecTime() { | |
return nextTime; | ||
} | ||
|
||
int getTimesReplicatedSinceStartup() { | ||
return numTimesReplicated; | ||
} | ||
|
||
void setTimesReplicatedSinceStartup() { | ||
numTimesReplicated++; | ||
} | ||
|
||
@Override | ||
public Category getCategory() { | ||
return Category.REPLICATION; | ||
|
@@ -1043,7 +1029,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 = | ||
|
@@ -1108,13 +1094,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()); | ||
|
@@ -1272,11 +1258,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); | ||
|
@@ -1347,7 +1333,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(); | ||
|
@@ -1532,7 +1518,8 @@ 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 | ||
Comment on lines
+1522
to
1524
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. reflow There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dang it, I trusted |
||
// state from leader | ||
|
@@ -1576,8 +1563,6 @@ private Long readIntervalNs(String interval) { | |
|
||
public static final String ALIAS = "alias"; | ||
|
||
public static final String CONF_CHECKSUM = "confchecksum"; | ||
|
||
public static final String CONF_FILES = "confFiles"; | ||
|
||
public static final String REPLICATE_AFTER = "replicateAfter"; | ||
|
@@ -1601,7 +1586,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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
honestly, would any reader of CHANGES.txt care? I'm not questioning your effort in this PR but ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i went back and forth on it, since I'd created a JIRA... I then thought, it should then go in Changes... Plus removing a public variable...
We do need to add to our dev docs a concise "this is what Changes" is for...