-
Notifications
You must be signed in to change notification settings - Fork 217
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
ft-reaper-improvements-final small npe fix #111
Merged
adejanovski
merged 2 commits into
ft-reaper-improvements-final
from
mck/ft-reaper-improvements-final-smallfix-0
Jun 22, 2017
Merged
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -325,16 +325,17 @@ boolean canRepair(RepairSegment segment, String keyspace, JmxProxy coordinator, | |
for (String hostName : allHosts) { | ||
LOG.debug("checking host '{}' for pending compactions and other repairs (can repair?)" | ||
+ " Run id '{}'", hostName, segment.getRunId()); | ||
JmxProxy hostProxy = null; | ||
Optional<JmxProxy> hostProxy = Optional.absent(); | ||
try{ | ||
Optional<HostMetrics> hostMetrics; | ||
Optional<HostMetrics> hostMetrics = Optional.absent(); | ||
try{ | ||
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. |
||
hostProxy = context.jmxConnectionFactory.connect(hostName); | ||
hostProxy = Optional.fromNullable(context.jmxConnectionFactory.connect(hostName)); | ||
connected = true; | ||
} | ||
catch(Exception e) { | ||
LOG.debug("Couldn't reach host {} through JMX. Trying to collect metrics from storage..."); | ||
LOG.debug("Couldn't reach host {} through JMX. Trying to collect metrics from storage...", hostName); | ||
} | ||
|
||
hostMetrics = getMetricsForHost(hostName, hostProxy); | ||
|
||
if(!hostMetrics.isPresent()) { | ||
|
@@ -396,43 +397,44 @@ boolean canRepair(RepairSegment segment, String keyspace, JmxProxy coordinator, | |
return gotMetricsForAllHosts; // check if we should postpone when we cannot get all metrics, or just drop the lead | ||
} | ||
|
||
private void closeJmxConnection(JmxProxy jmxProxy, boolean connected) { | ||
if(connected) | ||
private void closeJmxConnection(Optional<JmxProxy> jmxProxy, boolean connected) { | ||
if(connected && jmxProxy.isPresent()) | ||
try { | ||
jmxProxy.close(); | ||
} catch (Exception e) { | ||
LOG.debug("Could not close JMX connection to {}. Potential leak...", jmxProxy.getHost()); | ||
jmxProxy.get().close(); | ||
} catch (ReaperException e) { | ||
LOG.warn("Could not close JMX connection to {}. Potential leak...", jmxProxy.get().getHost()); | ||
|
||
} | ||
} | ||
|
||
private void handlePotentialStuckRepairs(JmxProxy hostProxy, LazyInitializer<Set<String>> busyHosts, String hostName) throws ConcurrentException { | ||
if (!busyHosts.get().contains(hostName) && context.storage.getStorageType() != StorageType.CASSANDRA) { | ||
private void handlePotentialStuckRepairs(Optional<JmxProxy> hostProxy, LazyInitializer<Set<String>> busyHosts, String hostName) throws ConcurrentException { | ||
if (!busyHosts.get().contains(hostName) && context.storage.getStorageType() != StorageType.CASSANDRA && hostProxy.isPresent()) { | ||
LOG.warn("A host ({}) reported that it is involved in a repair, but there is no record " | ||
+ "of any ongoing repair involving the host. Sending command to abort all repairs " | ||
+ "on the host.", hostProxy.getHost()); | ||
hostProxy.cancelAllRepairs(); | ||
+ "on the host.", hostProxy.get().getHost()); | ||
hostProxy.get().cancelAllRepairs(); | ||
} | ||
} | ||
|
||
private Optional<HostMetrics> getMetricsForHost(String hostName, JmxProxy hostProxy) { | ||
try { | ||
int pendingCompactions = hostProxy.getPendingCompactions(); | ||
boolean hasRepairRunning = hostProxy.isRepairRunning(); | ||
|
||
HostMetrics metrics = HostMetrics.builder().withHostAddress(hostName) | ||
.withPendingCompactions(pendingCompactions) | ||
.withHasRepairRunning(hasRepairRunning) | ||
.withActiveAnticompactions(0) // for future use | ||
.build(); | ||
|
||
context.storage.storeHostMetrics(metrics); | ||
|
||
return Optional.fromNullable(metrics); | ||
|
||
} catch(Exception e) { | ||
LOG.debug("Cannot reach node {} through JMX. Trying to get metrics from storage...", hostName, e); | ||
return context.storage.getHostMetrics(hostName); | ||
private Optional<HostMetrics> getMetricsForHost(String hostName, Optional<JmxProxy> hostProxy) { | ||
if(hostProxy.isPresent()) { | ||
try { | ||
int pendingCompactions = hostProxy.get().getPendingCompactions(); | ||
boolean hasRepairRunning = hostProxy.get().isRepairRunning(); | ||
|
||
HostMetrics metrics = HostMetrics.builder().withHostAddress(hostName) | ||
.withPendingCompactions(pendingCompactions) | ||
.withHasRepairRunning(hasRepairRunning) | ||
.withActiveAnticompactions(0) // for future use | ||
.build(); | ||
context.storage.storeHostMetrics(metrics); | ||
return Optional.fromNullable(metrics); | ||
} catch(Exception e) { | ||
LOG.debug("Cannot reach node {} through JMX. Trying to get metrics from storage...", hostName, e); | ||
} | ||
} | ||
|
||
return context.storage.getHostMetrics(hostName); | ||
} | ||
|
||
private boolean IsRepairRunningOnOneNode(RepairSegment segment) { | ||
|
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.