-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[AMBARI-22845] Update service metainfo schema #194
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -54,6 +54,9 @@ public class StackServiceResourceProvider extends ReadOnlyResourceProvider { | |||||||||
| protected static final String SERVICE_TYPE_PROPERTY_ID = PropertyHelper.getPropertyId( | ||||||||||
| "StackServices", "service_type"); | ||||||||||
|
|
||||||||||
| protected static final String SERVICE_CATEGORY_PROPERTY_ID = PropertyHelper.getPropertyId( | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should also be added to Lines 117 to 120 in 48d882d
|
||||||||||
| "StackServices", "service_category"); | ||||||||||
|
|
||||||||||
| public static final String STACK_NAME_PROPERTY_ID = PropertyHelper.getPropertyId( | ||||||||||
| "StackServices", "stack_name"); | ||||||||||
|
|
||||||||||
|
|
@@ -117,6 +120,7 @@ public class StackServiceResourceProvider extends ReadOnlyResourceProvider { | |||||||||
| private static Set<String> propertyIds = Sets.newHashSet( | ||||||||||
| SERVICE_NAME_PROPERTY_ID, | ||||||||||
| SERVICE_TYPE_PROPERTY_ID, | ||||||||||
| SERVICE_CATEGORY_PROPERTY_ID, | ||||||||||
| STACK_NAME_PROPERTY_ID, | ||||||||||
| STACK_VERSION_PROPERTY_ID, | ||||||||||
| SERVICE_DISPLAY_NAME_PROPERTY_ID, | ||||||||||
|
|
@@ -185,11 +189,14 @@ private Resource createResource(StackServiceResponse response, Set<String> reque | |||||||||
| setResourceProperty(resource, STACK_NAME_PROPERTY_ID, | ||||||||||
| response.getStackName(), requestedIds); | ||||||||||
|
|
||||||||||
| setResourceProperty(resource, SERVICE_NAME_PROPERTY_ID, | ||||||||||
| response.getServiceName(), requestedIds); | ||||||||||
| setResourceProperty(resource, SERVICE_NAME_PROPERTY_ID, | ||||||||||
| response.getServiceName(), requestedIds); | ||||||||||
|
|
||||||||||
| setResourceProperty(resource, SERVICE_TYPE_PROPERTY_ID, | ||||||||||
| response.getServiceType(), requestedIds); | ||||||||||
|
|
||||||||||
| setResourceProperty(resource, SERVICE_TYPE_PROPERTY_ID, | ||||||||||
| response.getServiceType(), requestedIds); | ||||||||||
| setResourceProperty(resource, SERVICE_CATEGORY_PROPERTY_ID, | ||||||||||
| response.getServiceCategory(), requestedIds); | ||||||||||
|
|
||||||||||
| setResourceProperty(resource, STACK_VERSION_PROPERTY_ID, | ||||||||||
| response.getStackVersion(), requestedIds); | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ | |
| import org.apache.ambari.server.state.ComponentInfo; | ||
| import org.apache.ambari.server.state.CustomCommandDefinition; | ||
| import org.apache.ambari.server.state.QuickLinksConfigurationInfo; | ||
| import org.apache.ambari.server.state.ServiceCategory; | ||
| import org.apache.ambari.server.state.ServiceInfo; | ||
| import org.apache.ambari.server.state.ServicePropertyInfo; | ||
| import org.apache.ambari.server.state.ThemeInfo; | ||
|
|
@@ -209,6 +210,10 @@ public void resolveInternal( | |
| ServiceInfo.ServiceAdvisorType serviceAdvisorType = parent.getServiceAdvisorType(); | ||
| serviceInfo.setServiceAdvisorType(serviceAdvisorType == null ? ServiceInfo.ServiceAdvisorType.PYTHON : serviceAdvisorType); | ||
| } | ||
| if (serviceInfo.getCategory() == null) { | ||
| ServiceCategory category = parent.getCategory(); | ||
| serviceInfo.setCategory(category == null ? ServiceCategory.LEGACY : category); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi Dmitry,
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven't completely understood the issue here. In case the service is not inherited from other service this code will never be reached, instead the one from StackModule will be executed: https://github.com/d0zen1/ambari/blob/137d82ebfb8db273706c23a352803a8ed671a09b/ambari-server/src/main/java/org/apache/ambari/server/stack/StackModule.java#L356-L364 The general logic follows the following priority rules, given 1 is the highest priority:
|
||
| } | ||
| if (serviceInfo.getVersion() == null) { | ||
| serviceInfo.setVersion(parent.getVersion()); | ||
| } | ||
|
|
@@ -602,11 +607,26 @@ private void mergeComponents( | |
| ServiceModule parent, Map<String, StackModule> allStacks, Map<String, ServiceModule> commonServices, Map<String, ExtensionModule> extensions) | ||
| throws AmbariException { | ||
| serviceInfo.getComponents().clear(); | ||
|
|
||
| //component version should not inherit from parent service | ||
| //make deep copy of all the parent components and set component versions to null | ||
| //TODO get rid of this when we move to only standalone stack definitions | ||
| Map<String, ComponentModule> parentComponentsCopy = new HashMap<>(); | ||
| parent.componentModules.values().forEach(componentModule -> parentComponentsCopy.put(componentModule.getId(), | ||
| new ComponentModule(new ComponentInfo(componentModule.getModuleInfo())))); | ||
| //set nulls to component versions | ||
| parentComponentsCopy.values().forEach(componentModule -> componentModule.getModuleInfo().setVersion(null)); | ||
|
|
||
| Collection<ComponentModule> mergedModules = mergeChildModules( | ||
| allStacks, commonServices, extensions, componentModules, parent.componentModules); | ||
| allStacks, commonServices, extensions, componentModules, parentComponentsCopy); | ||
| componentModules.clear(); | ||
| for (ComponentModule module : mergedModules) { | ||
| if (!module.isDeleted()){ | ||
| //if the version is not defined for component, set the service version | ||
| if (module.getModuleInfo().getVersion() == null) { | ||
| module.getModuleInfo().setVersion(serviceInfo.getVersion()); | ||
| } | ||
|
|
||
| componentModules.put(module.getId(), module); | ||
| serviceInfo.getComponents().add(module.getModuleInfo()); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.ambari.server.state; | ||
|
|
||
| /** | ||
| * The category of service. | ||
| */ | ||
| public enum ServiceCategory { | ||
| /** | ||
| * The service contains form only master and slave components | ||
| */ | ||
| SERVER, | ||
|
|
||
| /** | ||
| * The service contains from only client components | ||
| */ | ||
| CLIENT, | ||
|
|
||
| /** | ||
| * The service contains all kind of components | ||
| */ | ||
| LEGACY | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -189,6 +189,7 @@ | |
| "StackServices/stack_name", | ||
| "StackServices/stack_version", | ||
| "StackServices/service_name", | ||
| "StackServices/service_category", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn't know about this change. Thanks for noticing |
||
| "StackServices/display_name", | ||
| "StackServices/selection", | ||
| "StackServices/user_name", | ||
|
|
@@ -227,6 +228,7 @@ | |
| "StackServiceComponents/stack_version", | ||
| "StackServiceComponents/service_name", | ||
| "StackServiceComponents/component_name", | ||
| "StackServiceComponents/component_version", | ||
| "StackServiceComponents/display_name", | ||
| "StackServiceComponents/component_category", | ||
| "StackServiceComponents/is_client", | ||
|
|
||
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.
Should also be added to
propertyIds:ambari/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceComponentResourceProvider.java
Lines 124 to 127 in 48d882d