Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Use the correct ctor for NodeDetailsCollector #166

Merged
merged 2 commits into from
Aug 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public PerformanceAnalyzerPlugin(final Settings settings, final java.nio.file.Pa

scheduledMetricCollectorsExecutor.addScheduledMetricCollector(new MetricsPurgeActivity());

scheduledMetricCollectorsExecutor.addScheduledMetricCollector(new NodeDetailsCollector());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove this default constructor from NodeDetailsCollector, or is it required?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me check the usages. Maybe the no arg constructor is not used anymore.

scheduledMetricCollectorsExecutor.addScheduledMetricCollector(new NodeDetailsCollector(configOverridesWrapper));
scheduledMetricCollectorsExecutor.addScheduledMetricCollector(new
NodeStatsAllShardsMetricsCollector(performanceAnalyzerController));
scheduledMetricCollectorsExecutor.addScheduledMetricCollector(new
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,23 @@ public void collectMetrics(long startTime) {
// know this information in advance unless we add the number of nodes as
// additional metadata in the file.
try {
String rcaOverrides = ConfigOverridesHelper.serialize(configOverridesWrapper.getCurrentClusterConfigOverrides());
value.append(rcaOverrides);
if (configOverridesWrapper != null) {
String rcaOverrides = ConfigOverridesHelper.serialize(configOverridesWrapper.getCurrentClusterConfigOverrides());
value.append(rcaOverrides);
} else {
LOG.warn("Overrides wrapper is null. Check NodeDetailsCollector instantiation.");
}
} catch (IOException ioe) {
LOG.error("Unable to serialize rca config overrides.", ioe);
}
value.append(PerformanceAnalyzerMetrics.sMetricNewLineDelimitor);

// line#3 denotes when the timestamp when the config override happened.
value.append(configOverridesWrapper.getLastUpdatedTimestamp());
if (configOverridesWrapper != null) {
value.append(configOverridesWrapper.getLastUpdatedTimestamp());
} else {
value.append(0L);
}
value.append(PerformanceAnalyzerMetrics.sMetricNewLineDelimitor);

DiscoveryNodes discoveryNodes = ESResources.INSTANCE.getClusterService().state().nodes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@ public ConfigOverridesClusterSettingHandler(final ConfigOverridesWrapper overrid
@Override
public void onSettingUpdate(String newSettingValue) {
try {
final ConfigOverrides newOverrides = ConfigOverridesHelper.deserialize(newSettingValue);
overridesHolder.setCurrentClusterConfigOverrides(newOverrides);
overridesHolder.setLastUpdatedTimestamp(System.currentTimeMillis());
if (newSettingValue != null && !newSettingValue.isEmpty()) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a UT for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add a UT for this.

final ConfigOverrides newOverrides = ConfigOverridesHelper.deserialize(newSettingValue);
overridesHolder.setCurrentClusterConfigOverrides(newOverrides);
overridesHolder.setLastUpdatedTimestamp(System.currentTimeMillis());
} else {
LOG.warn("Config override setting update called with empty string. Ignoring.");
}
} catch (IOException e) {
LOG.error("Unable to apply received cluster setting update: " + newSettingValue, e);
}
Expand All @@ -73,8 +77,7 @@ public void onSettingUpdate(String newSettingValue) {
*/
public void updateConfigOverrides(final ConfigOverrides newOverrides) throws IOException {
String newClusterSettingValue = buildClusterSettingValue(newOverrides);
// TODO: @ktkrg - Change to debug
LOG.error("Updating cluster setting with new overrides string: {}", newClusterSettingValue);
LOG.debug("Updating cluster setting with new overrides string: {}", newClusterSettingValue);
clusterSettingsManager.updateSetting(setting, newClusterSettingValue);
}

Expand Down