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

KAFKA-7011 - Remove ResourceNameType field from Java Resource class. #5160

Merged
merged 4 commits into from
Jun 7, 2018

Conversation

big-andy-coates
Copy link
Contributor

@big-andy-coates big-andy-coates commented Jun 7, 2018

Fix for KAFKA-7011.

The initial PR for KIP-290 #5117 added a ResourceNameType field to the Java and Scala Resource classes to introduce the concept of Prefixed ACLS. This does not make a lot of sense as these classes are meant to represent cluster resources, which would not have a concept of 'name type'. This work has not been released yet, so we have time to change it.

This PR looks to refactor the code to remove the name type field from the Java Resource class. (The Scala one will age out once KIP-290 is done, and removing it would involve changes to the Authorizer interface, so this class was not touched).

This is achieved by replacing the use of Resource with ResourcePattern and ResourceFilter with ResourceFilterPattern. A ResourcePattern is a combination of resource type, name and name type, where each field needs to be defined. A ResourcePatternFilter is used to select patterns during describe and delete operations.

The adminClient uses AclBinding and AclBindingFilter. These types have been switched over to use the new pattern types.

The AclCommands class, used by Kafka-acls.sh, has been converted to use the new pattern types.

The result is that the original Resource and ResourceFilter classes are not really used anywhere, except deprecated methods. However, the Resource class will be used if/when KIP-50 is done.

cc @cmccabe, @junrao

This PR will need cherry picking onto the 2.0 branch.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

* @param name non-null resource name, which can be the {@link #WILDCARD_RESOURCE}.
* @param nameType non-null, specific, resource name type, which controls how the pattern will match resource names.
*/
public ResourcePattern(ResourceType resourceType, String name, ResourceNameType nameType) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I really like the fact that we are separating Resources from ResourcePatterns! Great job.

import java.util.Objects;

/**
* Represents a pattern that can match a {@link org.apache.kafka.common.resource.Resource}.
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps something like "Represents a pattern that is used by ACLs to match zero or more Resources"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently used by ACLs only, but was trying to keep it ACL free in the description. Still want me to 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.

Done

import static org.apache.kafka.common.resource.ResourcePattern.WILDCARD_RESOURCE;

/**
* Represents a filter that can match {@link ResourcePatternFilter}.
Copy link
Contributor

@cmccabe cmccabe Jun 7, 2018

Choose a reason for hiding this comment

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

s/ResourcePatternFilter/ResourcePattern/

@cmccabe
Copy link
Contributor

cmccabe commented Jun 7, 2018

+1. LGTM. I really don't have anything to add except for the comment suggestion.

Copy link
Contributor

@junrao junrao left a comment

Choose a reason for hiding this comment

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

@big-andy-coates : Thanks for the patch. LGTM

@junrao junrao merged commit b4fa87c into apache:trunk Jun 7, 2018
junrao pushed a commit that referenced this pull request Jun 7, 2018
…5160)

The initial PR for KIP-290 #5117 added a `ResourceNameType` field to the Java and Scala `Resource` classes to introduce the concept of Prefixed ACLS.  This does not make a lot of sense as these classes are meant to represent cluster resources, which would not have a concept of 'name type'. This work has not been released yet, so we have time to change it.

This PR looks to refactor the code to remove the name type field from the Java `Resource` class. (The Scala one will age out once KIP-290 is done, and removing it would involve changes to the `Authorizer` interface, so this class was not touched).

This is achieved by replacing the use of `Resource` with `ResourcePattern` and `ResourceFilter` with `ResourceFilterPattern`.  A `ResourcePattern` is a combination of resource type, name and name type, where each field needs to be defined. A `ResourcePatternFilter` is used to select patterns during describe and delete operations.

The adminClient uses `AclBinding` and `AclBindingFilter`. These types have been switched over to use the new pattern types.

The AclCommands class, used by Kafka-acls.sh, has been converted to use the new pattern types.

The result is that the original `Resource` and `ResourceFilter` classes are not really used anywhere, except deprecated methods. However, the `Resource` class will be used if/when KIP-50 is done.

Reviewers: Colin Patrick McCabe <colin@cmccabe.xyz>, Jun Rao <junrao@gmail.com>
@big-andy-coates big-andy-coates deleted the remove_name_type_from_resource branch June 8, 2018 10:46
ying-zheng pushed a commit to ying-zheng/kafka that referenced this pull request Jul 6, 2018
…pache#5160)

The initial PR for KIP-290 apache#5117 added a `ResourceNameType` field to the Java and Scala `Resource` classes to introduce the concept of Prefixed ACLS.  This does not make a lot of sense as these classes are meant to represent cluster resources, which would not have a concept of 'name type'. This work has not been released yet, so we have time to change it.

This PR looks to refactor the code to remove the name type field from the Java `Resource` class. (The Scala one will age out once KIP-290 is done, and removing it would involve changes to the `Authorizer` interface, so this class was not touched).

This is achieved by replacing the use of `Resource` with `ResourcePattern` and `ResourceFilter` with `ResourceFilterPattern`.  A `ResourcePattern` is a combination of resource type, name and name type, where each field needs to be defined. A `ResourcePatternFilter` is used to select patterns during describe and delete operations.

The adminClient uses `AclBinding` and `AclBindingFilter`. These types have been switched over to use the new pattern types.

The AclCommands class, used by Kafka-acls.sh, has been converted to use the new pattern types.

The result is that the original `Resource` and `ResourceFilter` classes are not really used anywhere, except deprecated methods. However, the `Resource` class will be used if/when KIP-50 is done.

Reviewers: Colin Patrick McCabe <colin@cmccabe.xyz>, Jun Rao <junrao@gmail.com>
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