You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ranger.apache.org by "peng.jianhua (JIRA)" <ji...@apache.org> on 2017/08/25 05:35:00 UTC

[jira] [Comment Edited] (RANGER-1725) It is incorrect to judge whether you need to create a RangerServiceDef object for a given service

    [ https://issues.apache.org/jira/browse/RANGER-1725?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16141216#comment-16141216 ] 

peng.jianhua edited comment on RANGER-1725 at 8/25/17 5:34 AM:
---------------------------------------------------------------

[~madhan.neethiraj]
You can see the definition of variable ‘supportedServiceDefs’ like this:
{code:java}
supportedServiceDefs =getSupportedServiceDef();
{code}

Then you can see the detail code application about the function 'getSupportedServiceDef' as follow
{code:java}
	private Set<String> getSupportedServiceDef() {
		Set<String> supportedServiceDef = new HashSet<>();
		String ranger_supportedcomponents = RangerConfiguration.getInstance().get(PROPERTY_SUPPORTED_SERVICE_DEFS, DEFAULT_BOOTSTRAP_SERVICEDEF_LIST);
		if (StringUtils.isBlank(ranger_supportedcomponents) || "all".equalsIgnoreCase(ranger_supportedcomponents)) {
			ranger_supportedcomponents = DEFAULT_BOOTSTRAP_SERVICEDEF_LIST;
		}
		String[] supportedComponents = ranger_supportedcomponents.split(",");
		if (supportedComponents != null && supportedComponents.length > 0) {
			for (String element : supportedComponents) {
				if (!StringUtils.isBlank(element)) {
					element = element.toLowerCase();
					supportedServiceDef.add(element);
				}
			}
		}
		return supportedServiceDef;
	}
{code}

If you config wrong value for key 'ranger.supportedcomponents' in the ranger configuration file, such as ',,,,,,,,', the function 'getSupportedServiceDef' will return empty Set.
Follow the previous logic, the boolean flag 'createServiceDef' will be true, do not you think there is something wrong?


was (Author: peng.jianhua):
You can see the definition of variable ‘supportedServiceDefs’ like this:
{code:java}
supportedServiceDefs =getSupportedServiceDef();
{code}

Then you can see the detail code application about the function 'getSupportedServiceDef' as follow
{code:java}
	private Set<String> getSupportedServiceDef() {
		Set<String> supportedServiceDef = new HashSet<>();
		String ranger_supportedcomponents = RangerConfiguration.getInstance().get(PROPERTY_SUPPORTED_SERVICE_DEFS, DEFAULT_BOOTSTRAP_SERVICEDEF_LIST);
		if (StringUtils.isBlank(ranger_supportedcomponents) || "all".equalsIgnoreCase(ranger_supportedcomponents)) {
			ranger_supportedcomponents = DEFAULT_BOOTSTRAP_SERVICEDEF_LIST;
		}
		String[] supportedComponents = ranger_supportedcomponents.split(",");
		if (supportedComponents != null && supportedComponents.length > 0) {
			for (String element : supportedComponents) {
				if (!StringUtils.isBlank(element)) {
					element = element.toLowerCase();
					supportedServiceDef.add(element);
				}
			}
		}
		return supportedServiceDef;
	}
{code}

If you config wrong value for key 'ranger.supportedcomponents' in the ranger configuration file, such as ',,,,,,,,', the function 'getSupportedServiceDef' will return empty Set.
Follow the previous logic, the boolean flag 'createServiceDef' will be true, do not you think there is something wrong?

> It is incorrect to judge whether you need to create a RangerServiceDef object for a given service
> -------------------------------------------------------------------------------------------------
>
>                 Key: RANGER-1725
>                 URL: https://issues.apache.org/jira/browse/RANGER-1725
>             Project: Ranger
>          Issue Type: Bug
>          Components: Ranger
>            Reporter: peng.jianhua
>            Assignee: peng.jianhua
>              Labels: patch
>             Fix For: 1.0.0
>
>         Attachments: 0001-RANGER-1725-It-is-incorrect-to-judge-whether-you-nee.patch
>
>
> It is incorrect to judge whether you need to create a RangerServiceDef object for a given service.
> The current judgment condition is in the org.apache.ranger.plugin.store.EmbeddedServiceDefsUtil#getOrCreateServiceDef, as follows
> {code:java}
> boolean createServiceDef = (CollectionUtils.isEmpty(supportedServiceDefs) || supportedServiceDefs.contains(serviceDefName));
> {code}
> It means When the supportedServiceDefs is empty, the RangerServiceDef object for the specified service will be created, but I think this judge is incorrect.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)