Skip to content
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

Refactor: Clean up compaction config classes #16810

Merged
merged 5 commits into from
Jul 30, 2024

Conversation

kfaraz
Copy link
Contributor

@kfaraz kfaraz commented Jul 28, 2024

Changes

  • Rename CoordinatorCompactionConfig to DruidCompactionConfig
  • Rename CompactionConfigUpdateRequest to ClusterCompactionConfig
  • Refactor methods in DruidCompactionConfig
  • Clean up DataSourceCompactionConfigHistory and its tests
  • Clean up tests and add new tests
  • Change API path /druid/coordinator/v1/config/global to /druid/coordinator/v1/config/cluster

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

Copy link
Contributor

@gargvishesh gargvishesh left a comment

Choose a reason for hiding this comment

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

Thanks @kfaraz for the cleanup. Minor comments.

.forDataSource(UPGRADE_DATASOURCE_NAME)
.withSkipOffsetFromLatest(newSkipOffset)
.withTuningConfig(
new UserCompactionTaskQueryTuningConfig(
Copy link
Contributor

Choose a reason for hiding this comment

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

A builder can be introduced for this one as well in future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's already in the works. 😄

private final DataSourceCompactionConfig compactionConfig;
private final AuditInfo auditInfo;
private final DateTime auditTime;

@JsonCreator
public DataSourceCompactionConfigAuditEntry(
@JsonProperty("globalConfig") GlobalCompactionConfig globalConfig,
@JsonProperty("globalConfig") ClusterCompactionConfig globalConfig,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
@JsonProperty("globalConfig") ClusterCompactionConfig globalConfig,
@JsonProperty("globalConfig") ClusterCompactionConfig clusterCompactionConfig,

@@ -50,7 +51,7 @@ public DataSourceCompactionConfigAuditEntry(
}

@JsonProperty
public GlobalCompactionConfig getGlobalConfig()
public ClusterCompactionConfig getGlobalConfig()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public ClusterCompactionConfig getGlobalConfig()
public ClusterCompactionConfig getClusterCompactionConfig()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

globalConfig is also a term used by the web-console.
Renaming this getter would require us to use @JsonProperty("globalConfig") on the getter for backwards compatibility. Leaving the names as is seemed cleaner.

Let me know if you feel strongly about this.

/**
* A DTO containing audit information for compaction config for a datasource.
*/
public class DataSourceCompactionConfigAuditEntry
{
private final GlobalCompactionConfig globalConfig;
private final ClusterCompactionConfig globalConfig;
Copy link
Contributor

Choose a reason for hiding this comment

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

Consistent naming may be better. Can use older annotation for getter property name.

Suggested change
private final ClusterCompactionConfig globalConfig;
private final ClusterCompactionConfig clusterCompactionConfig;

);
}

public Optional<DataSourceCompactionConfig> findConfigForDatasource(String dataSource)
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for this handy function!

@JsonProperty("compactionTaskSlotRatio") @Nullable Double compactionTaskSlotRatio,
@JsonProperty("maxCompactionTaskSlots") @Nullable Integer maxCompactionTaskSlots,
@JsonProperty("useAutoScaleSlots") @Nullable Boolean useAutoScaleSlots,
@JsonProperty("compactionEngine") @Nullable CompactionEngine compactionEngine
@JsonProperty("engine") @Nullable CompactionEngine engine
)
{
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the constructor should take in null values but create a compaction config with the non-null default fields.
Otherwise the comparison in the Audit history can be incorrect when there are null values but the default values change

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 considered that. But that becomes problematic since this payload is used to update cluster configs.
If we assign non-null values in the constructor, it would seem that the values are being updated even if we don't want them to be updated.

The audit entry thing is not an issue as there we always use non-null values.
See DruidCompactionConfig.clusterConfig() method which always returns non-null values.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the clarification!

Copy link
Contributor

@AmatyaAvadhanula AmatyaAvadhanula left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks, @kfaraz

@kfaraz kfaraz merged commit 954aaaf into apache:master Jul 30, 2024
88 checks passed
@kfaraz kfaraz deleted the compaction_audit_entry branch July 30, 2024 06:47
@kfaraz
Copy link
Contributor Author

kfaraz commented Jul 30, 2024

Thanks a lot for the prompt reviews, @AmatyaAvadhanula , @gargvishesh !!

sreemanamala pushed a commit to sreemanamala/druid that referenced this pull request Aug 6, 2024
Changes:
- Rename `CoordinatorCompactionConfig` to `DruidCompactionConfig`
- Rename `CompactionConfigUpdateRequest` to `ClusterCompactionConfig`
- Refactor methods in `DruidCompactionConfig`
- Clean up `DataSourceCompactionConfigHistory` and its tests
- Clean up tests and add new tests
- Change API path `/druid/coordinator/v1/config/global` to `/druid/coordinator/v1/config/cluster`
@kfaraz kfaraz added this to the 31.0.0 milestone Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants