-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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
KAFKA-7011 - Remove ResourceNameType field from Java Resource class. #5160
Conversation
* @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) { |
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 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}. |
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.
Perhaps something like "Represents a pattern that is used by ACLs to match zero or more Resources"
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.
Currently used by ACLs only, but was trying to keep it ACL free in the description. Still want me to change?
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.
Done
import static org.apache.kafka.common.resource.ResourcePattern.WILDCARD_RESOURCE; | ||
|
||
/** | ||
* Represents a filter that can match {@link ResourcePatternFilter}. |
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.
s/ResourcePatternFilter/ResourcePattern/
+1. LGTM. I really don't have anything to add except for the comment suggestion. |
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.
@big-andy-coates : Thanks for the patch. LGTM
…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>
…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>
Fix for KAFKA-7011.
The initial PR for KIP-290 #5117 added a
ResourceNameType
field to the Java and ScalaResource
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 theAuthorizer
interface, so this class was not touched).This is achieved by replacing the use of
Resource
withResourcePattern
andResourceFilter
withResourceFilterPattern
. AResourcePattern
is a combination of resource type, name and name type, where each field needs to be defined. AResourcePatternFilter
is used to select patterns during describe and delete operations.The adminClient uses
AclBinding
andAclBindingFilter
. 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
andResourceFilter
classes are not really used anywhere, except deprecated methods. However, theResource
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)