Ambari的Stack配置合并

目的

Ambari的stack有继承机制,一个Service可以从stack或者从common-service中继承,当一个服务从另一个版本的服务继承时,有几种规则,对于不同类型的文件,有不同的规则。不幸的是要研究ambari源码或对实现进行定制修复问题,就需要知道某一个版本的的服务完整的配置是怎样的,而这些继承的规则又非常的复杂,通过手工去合并配置和脚本,工作量很大而且无法保证手动合并的代码正确,几乎是不可能手动去完成。需要有一种机制,既能保证合并效率又能保证合并后配置和脚本的正确性。

实现

Ambari代码会处理继承,只需要把Ambari解析到内存中的StackInfo的对象的数据,写入相应的文件和目录中,就可以简单的实现配置和脚本的合并,下面是实现的配置合并的代码,要运行下面的代码,首先需要生成StackInfo的对象info。

1. 获取StackInfo对象

1
2
3
4
5
6
7
StackManager stackManager = new StackManager(
      new File(stackRoot),
      new File(commonServices), // commonServices设置为null时不会从common-service继承实现
      null,
      osFamily, false,
      metaInfoDao, actionMetadata, stackDao, extensionDao, linkDao, helper);
StackInfo info = stackManager.getStack("HDP", "2.6");

2. 主要实现代码

首先使用ambari内部映射对象去encode文件内容写到文件中,如果出现异常(异常应该不难处理,javax.xml.bind.JAXBException: class java.util.LinkedHashMap nor any of its super class is known to this context 此处没有解决此异常,使用其它方法生成文件)使用模板处理文件内容生成

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
{
    final File stackDirFile = new File("/tmp/" + info.getName() + "/" + info.getVersion());
    stackDirFile.mkdirs();
 
    StackMetainfoXml stackMetainfoXml = new StackMetainfoXml();
    stackMetainfoXml.setValid(info.isValid());
//    stackMetainfoXml.setExtendsVersion(info.getParentStackVersion());
//    stackMetainfoXml.setMinJdk(info.getMinJdk());
//    stackMetainfoXml.setMaxJdk(info.getMaxJdk());
//    stackMetainfoXml.setVersion(info.getVersion());
    //
    {
      {
        String kerberosDescriptorFileLocation = info.getKerberosDescriptorFileLocation();
        if (kerberosDescriptorFileLocation != null) {
          File file = new File(kerberosDescriptorFileLocation);
          Files.copy(file, new File(stackDirFile.getAbsolutePath(), FilenameUtils.getName(file.getAbsolutePath())));
        }
      }
      {
        String kerberosDescriptorPreConfigurationFileLocation = info.getKerberosDescriptorPreConfigurationFileLocation();
        if (kerberosDescriptorPreConfigurationFileLocation != null) {
          File file = new File(kerberosDescriptorPreConfigurationFileLocation);
          Files.copy(file, new File(stackDirFile.getAbsolutePath(), FilenameUtils.getName(file.getAbsolutePath())));
        }
      }
      {
        String widgetsDescriptorFileLocation = info.getWidgetsDescriptorFileLocation();
        if (widgetsDescriptorFileLocation != null) {
          File file = new File(widgetsDescriptorFileLocation);
          Files.copy(file, new File(stackDirFile.getAbsolutePath(), FilenameUtils.getName(file.getAbsolutePath())));
        }
      }
      {
        StackRoleCommandOrder roleCommandOrder = info.getRoleCommandOrder();
        String value = new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(roleCommandOrder.getContent());
        Files.write(value, new File(stackDirFile.getAbsolutePath(), "role_command_order.json"), Charset.forName("UTF-8"));
      }
    }
 
    // service
    Collection serviceInfos = info.getServices();
    for (ServiceInfo serviceInfo : serviceInfos) {
      String name = serviceInfo.getName();
      File serviceDir = new File(stackDirFile.getAbsolutePath() + "/" + "services", name);
      serviceDir.mkdirs();
 
      {
        File kerberosDescriptorFile = serviceInfo.getKerberosDescriptorFile();
        File widgetsDescriptorFile = serviceInfo.getWidgetsDescriptorFile();
        File metricsFile = serviceInfo.getMetricsFile();
 
        if (kerberosDescriptorFile != null) {
          Files.copy(kerberosDescriptorFile, new File(serviceDir.getAbsolutePath(), FilenameUtils.getName(kerberosDescriptorFile.getAbsolutePath())));
        }
        if (widgetsDescriptorFile != null) {
          Files.copy(widgetsDescriptorFile, new File(serviceDir.getAbsolutePath(), serviceInfo.getWidgetsFileName()));
        }
        if (metricsFile != null) {
          Files.copy(metricsFile, new File(serviceDir.getAbsolutePath(), serviceInfo.getMetricsFileName()));
        }
        {
          StackRoleCommandOrder roleCommandOrder = info.getRoleCommandOrder();
          String value = new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(roleCommandOrder.getContent());
          Files.write(value, new File(serviceDir.getAbsolutePath(), "role_command_order.json"), Charset.forName("UTF-8"));
        }
      }
 
      if (serviceInfo.getQuickLinksConfigurationsMap() != null && !serviceInfo.getQuickLinksConfigurationsMap().isEmpty()) {
        File dir = new File(serviceDir.getAbsolutePath(), serviceInfo.getQuickLinksConfigurationsDir());
        dir.mkdirs();
 
        List infos = Lists.newArrayList();
        for (Map.Entry<String, QuickLinksConfigurationInfo> entry : serviceInfo.getQuickLinksConfigurationsMap().entrySet()) {
          infos.add(entry.getValue());
 
          ObjectMapper objectMapper = new ObjectMapper();
          ObjectWriter writer = objectMapper.writerWithDefaultPrettyPrinter();
 
          QuickLinksConfigurationInfo configurationInfo = entry.getValue();
          QuickLinks quickLinks = configurationInfo.getQuickLinksConfigurationMap().values().iterator().next();
          String value = writer.writeValueAsString(quickLinks);
          Files.write(value, new File(dir.getAbsolutePath(), entry.getKey()), Charset.forName("UTF-8"));
        }
        serviceInfo.setQuickLinksConfigurations(infos);
      }
 
      if (serviceInfo.getThemesMap() != null &amp;&amp; !serviceInfo.getThemesMap().isEmpty()) {
        File themeDir = new File(serviceDir.getAbsolutePath(), serviceInfo.getThemesDir());
        themeDir.mkdirs();
 
        List themes = Lists.newArrayList();
        for (Map.Entry<String, ThemeInfo> entry : serviceInfo.getThemesMap().entrySet()) {
          themes.add(entry.getValue());
 
          ObjectMapper objectMapper = new ObjectMapper();
          ObjectWriter writer = objectMapper.writerWithDefaultPrettyPrinter();
 
          ThemeInfo themeInfo = entry.getValue();
          Theme theme = themeInfo.getThemeMap().values().iterator().next();
          String value = writer.writeValueAsString(theme);
          Files.write(value, new File(themeDir.getAbsolutePath(), entry.getKey()), Charset.forName("UTF-8"));
        }
        serviceInfo.setThemes(themes);
      }
 
      // 生成configuration配置文件
      List properties = serviceInfo.getProperties();
      Set pFileNames = Sets.newLinkedHashSet();
      Set pFileSortNames = Sets.newLinkedHashSet();
      Map<String, List> configurationFiles = Maps.newLinkedHashMap();
      // configuration
      for (PropertyInfo propertyInfo : properties) {
        String filename = propertyInfo.getFilename();
        pFileNames.add(filename);
        pFileSortNames.add(FilenameUtils.getBaseName(filename));
 
        List propertyInfos = configurationFiles.get(filename);
        if (propertyInfos == null) {
          configurationFiles.put(filename, new ArrayList());
          propertyInfos = configurationFiles.get(filename);
        }
        propertyInfos.add(propertyInfo);
      }
      if (configurationFiles.size() > 0) {
        File configDir = new File(serviceDir.getAbsolutePath() + "/configuration");
        configDir.mkdirs();
 
        for (Map.Entry<String, List> entry : configurationFiles.entrySet()) {
          String fileName = entry.getKey();
          String shortName = FilenameUtils.getBaseName(fileName);
          {// configuration
            ConfigurationXml configurationXml = new ConfigurationXml();
            configurationXml.addAll(entry.getValue());
            Map<QName, String> attri = Maps.newLinkedHashMap();
//            attri.put(new QName("configuration.xsl", "text/xsl", "kkkk"), "yyyy");
            // configuration xmlns:kkkk="configuration.xsl" kkkk:text/xsl="yyyy">
            Map<String, String> supports = serviceInfo.getConfigTypeAttributes().get(shortName).get("supports");
 
            attri.put(new QName(null, "supports_adding_forbidden", ""), supports.get("adding_forbidden"));
            attri.put(new QName(null, "supports_final", ""), supports.get("final"));
            attri.put(new QName(null, "supports_do_not_extend", ""), supports.get("do_not_extend"));
            configurationXml.addAll(attri);
            FileOutputStream stream = null;
            try {
              stream = new FileOutputStream(new File(configDir.getAbsolutePath(), fileName));
              JAXBContext jc = JAXBContext.newInstance(ConfigurationXml.class);
              Marshaller ms = jc.createMarshaller();
              ms.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");//编码格式
              ms.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
              ms.setProperty(Marshaller.JAXB_FRAGMENT, false);
              ms.setProperty("com.sun.xml.bind.xmlHeaders", "\n<!--?xml-stylesheet type=\"text/xsl\" href=\"configuration.xsl\"?-->\n" +
                "<!--\n" + "/**\n" + " * Licensed to the Apache Software Foundation (ASF) under one\n" + " * or more contributor license agreements. See the NOTICE file\n" + " * distributed with this work for additional information\n" + " * regarding copyright ownership. The ASF licenses this file\n" + " * to you under the Apache License, Version 2.0 (the\n" + " * \"License\"); you may not use this file except in compliance\n" + " * with the License. You may obtain a copy of the License at\n" + " *\n" + " * http://www.apache.org/licenses/LICENSE-2.0\n" + " *\n" + " * Unless required by applicable law or agreed to in writing, software\n" + " * distributed under the License is distributed on an \"AS IS\" BASIS,\n" + " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" + " * See the License for the specific language governing permissions and\n" + " * limitations under the License.\n" + " */\n" + "-->\n");
 
              ms.marshal(configurationXml, stream);
            } catch (JAXBException e) {
//        e.printStackTrace();
              new File(stackDirFile.getAbsolutePath() + "/" + "configuration_0").mkdirs();
              FileOutputStream outputStream = new FileOutputStream(new File(stackDirFile.getAbsolutePath() + "/" + "configuration_0", name));
              e.printStackTrace(new PrintStream(outputStream, true));
              outputStream.close();
            } finally {
              Closeables.close(stream, true);
            }
          }
//          {
//            // configuration Deprecate
//            VelocityContext context = new VelocityContext();
//            List propertyInfos = entry.getValue();
//            propertyInfos = Lists.transform(propertyInfos, new Function<PropertyInfo, PropertyInfo>() {
//              public PropertyInfo apply(PropertyInfo input) {
//                String value = input.getValue();
//                if (value != null &amp;&amp; (value.contains("<") || value.contains(">") || value.contains("/") || value.length() > 1024)) {
//                  input.setValue(String.format("<![CDATA[%s]]>", value));
//                }
//                return input;
//              }
//            });
//            context.put("properties", propertyInfos);
//            context.put("configType", serviceInfo.getConfigTypeAttributes().get(shortName));
//            Template template = VelocityUtil.getTemplateByName("configuration");
//            FileWriter writer = new FileWriter(new File(serviceDir.getAbsolutePath() + "/configuration", fileName));
//            template.merge(context, writer);
//            writer.flush();
//            writer.close();
//          }
        }
      }
//      FileWriter fileWriter = new FileWriter("/tmp/HDP/server_" + serviceInfo.getName());
//      GsonBuilder gsonBuilder = new GsonBuilder().setPrettyPrinting();
//      fileWriter.write(gsonBuilder.create().toJson(serviceInfo));
//      fileWriter.close();
      // 生成metainfo.xml
      FileOutputStream stream = null;
      try {
        JAXBContext jc = JAXBContext.newInstance(ServiceMetainfoXml.class);
        Marshaller ms = jc.createMarshaller();
        ms.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");//编码格式
        ms.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        ms.setProperty(Marshaller.JAXB_FRAGMENT, false);
        ms.setProperty("com.sun.xml.bind.xmlHeaders", "\n\n" +
          "<!--\n" + " Licensed to the Apache Software Foundation (ASF) under one or more\n" + " contributor license agreements. See the NOTICE file distributed with\n" + " this work for additional information regarding copyright ownership.\n" + " The ASF licenses this file to You under the Apache License, Version 2.0\n" + " (the \"License\"); you may not use this file except in compliance with\n" + " the License. You may obtain a copy of the License at\n" + "\n" + " http://www.apache.org/licenses/LICENSE-2.0\n" + "\n" + " Unless required by applicable law or agreed to in writing, software\n" + " distributed under the License is distributed on an \"AS IS\" BASIS,\n" + " WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" + " See the License for the specific language governing permissions and\n" + " limitations under the License.\n" + "-->\n");
 
        ServiceMetainfoXml serviceMetainfoXml = new ServiceMetainfoXml();
        serviceMetainfoXml.setServices(Lists.newArrayList(serviceInfo));
        serviceMetainfoXml.setSchemaVersion("2.0");
        serviceMetainfoXml.setValid(serviceInfo.isValid());
 
        stream = new FileOutputStream(new File(serviceDir.getAbsolutePath(), "metainfo.xml"));
        ms.marshal(serviceMetainfoXml, stream);
      } catch (JAXBException e) {
//        e.printStackTrace();
        new File(stackDirFile.getAbsolutePath() + "/" + "services_2").mkdirs();
        FileOutputStream outputStream = new FileOutputStream(new File(stackDirFile.getAbsolutePath() + "/" + "services_2", name));
        e.printStackTrace(new PrintStream(outputStream, true));
        outputStream.close();
 
        {// @Deprecate
          // meteinfo.xml
          VelocityContext context = new VelocityContext();
          context.put("serviceInfo", serviceInfo);
          context.put("pFileNames", pFileNames);
          context.put("pFileSortNames", pFileSortNames);
          Template template = VelocityUtil.getTemplateByName("metainfo");
          FileWriter writer = new FileWriter(new File(serviceDir.getAbsolutePath(), "metainfo.xml"));
          template.merge(context, writer);
          writer.flush();
          writer.close();
        }
      } finally {
        Closeables.close(stream, true);
      }
    }
  }

Velocity模板类

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
public final class VelocityUtil {
  private static final Logger LOGGER = LoggerFactory.getLogger(VelocityUtil.class);
 
  private VelocityUtil() {/**/}
 
  private static final VelocityEngine VELOCITY_ENGINE;
 
  static {
    VELOCITY_ENGINE = new VelocityEngine();
    VELOCITY_ENGINE.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
    VELOCITY_ENGINE.setProperty("userdirective", "org.apache.ambari.server.utils.Ifnull");
    VELOCITY_ENGINE.setProperty("userdirective", "org.apache.ambari.server.utils.Ifnotnull");
    VELOCITY_ENGINE.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
    VELOCITY_ENGINE.init();
  }
 
  public static Template getTemplateByName(String templateName) {
    return VELOCITY_ENGINE.getTemplate("velocity/" + templateName + ".vm", "utf8");
  }
 
  public static String getContentByTemplate(String templateName, Map<String, Object> datas) {
    try {
      Template template = VELOCITY_ENGINE.getTemplate("velocity/" + templateName + ".vm", "utf8");
      VelocityContext context = new VelocityContext();
      for (Map.Entry<String, Object> data : datas.entrySet()) {
        context.put(data.getKey(), data.getValue());
      }
      StringWriter writer = new StringWriter();
      template.merge(context, writer);
      return writer.toString();
    } catch (Exception e) {
      LOGGER.error("对应模板文件未找到", e);
    }
    return null;
  }
 
}

模板 configuration.vm

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<!--?xml version="1.0"?-->
<!--?xml-stylesheet type="text/xsl" href="configuration.xsl"?-->
<!-- /** * 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. */ -->
#macro(output $__p_page, $box)
    #ifnotnull($__p_page)
        #if($__p_page != "")
            <$!{box}>$__p_page
        #end
    #end
#end
 
 
#foreach($entry in $properties)
 
        $!{entry.name}
        $!{entry.value}
        $!{entry.description}
        $!{entry.displayName}
        $!{entry.filename}
        $!{entry.deleted}
        $!{entry.deleted}
 
        #ifnotnull($entry.propertyAmbariUpgradeBehavior)
 
        #end
        #if($entry.propertyTypes.size()>0)
            #foreach($ept in $entry.propertyTypes)$!{ept}#end
        #end
        #ifnotnull($entry.propertyValueAttributes)
 
            #output("$!{entry.propertyValueAttributes.type}", "type")
            #output("$!{entry.propertyValueAttributes.minimum}", "minimum")
            #output("$!{entry.propertyValueAttributes.maximum}", "maximum")
            #output("$!{entry.propertyValueAttributes.unit}", "unit")
            #output("$!{entry.propertyValueAttributes.delete}", "delete")
            #output("$!{entry.propertyValueAttributes.visible}", "visible")
            #output("$!{entry.propertyValueAttributes.overridable}", "overridable")
            #output("$!{entry.propertyValueAttributes.copy}", "copy")
            #output("$!{entry.propertyValueAttributes.emptyValueValid}", "empty-value-valid")
            #output("$!{entry.propertyValueAttributes.uiOnlyProperty}", "ui-only-property")
            #output("$!{entry.propertyValueAttributes.readOnly}", "readOnly")
            #output("$!{entry.propertyValueAttributes.editableOnlyAtInstall}", "editable-only-at-install")
            #output("$!{entry.propertyValueAttributes.showPropertyName}", "show-property-name")
            #output("$!{entry.propertyValueAttributes.incrementStep}", "increment-step")
            #output("$!{entry.propertyValueAttributes.keyStore}", "keyStore")
 
            #if($entry.propertyValueAttributes.entries.size()>0)
 
                #foreach($pvae in $entry.propertyValueAttributes.entries)
 
                        #output("$!{pvae.value}", "value")
                        #output("$!{pvae.label}", "label")
                        #output("$!{pvae.description}", "description")
 
                #end
 
            #end
            #output("$!{entry.propertyValueAttributes.hidden}", "hidden")
            #output("$!{entry.propertyValueAttributes.entriesEditable}", "entries_editable")
            #output("$!{entry.propertyValueAttributes.selectionCardinality}", "selection-cardinality")
            #output("$!{entry.propertyValueAttributes.propertyFileName}", "property-file-name")
            #output("$!{entry.propertyValueAttributes.propertyFileType}", "property-file-type")
            #output("$!{entry.propertyValueAttributes.propertyFileType}", "property-file-type")
            #if($entry.propertyValueAttributes.userGroupEntries.size()>0)
 
                #foreach($pvae in $entry.propertyValueAttributes.userGroupEntries)
 
                        #output("$!{pvae.value}", "value")
                        #output("$!{pvae.label}", "label")
 
                #end
 
            #end
 
        #end
        #if($entry.dependsOnProperties.size()>0)
 
            #foreach($edop in $entry.dependsOnProperties)
 
                    #output("$!{pvae.name}", "name")
                    #output("$!{pvae.type}", "type")
 
            #end
 
        #end
        #if($entry.dependedByProperties.size()>0)
 
            #foreach($edop in $entry.dependedByProperties)
 
                    #output("$!{pvae.name}", "name")
                    #output("$!{pvae.type}", "type")
 
            #end
 
        #end
        #if($entry.usedByProperties.size()>0)
 
            #foreach($edop in $entry.usedByProperties)
 
                    #output("$!{pvae.name}", "name")
                    #output("$!{pvae.type}", "type")
 
            #end
 
        #end
 
#end

模板 metainfo.vm

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<!--?xml version="1.0"?-->
<!-- 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. -->
#macro(output $__p_page, $box)
    #ifnotnull($__p_page)
        #if($__p_page != "")
        <$!{box}>$__p_page
        #end
    #end
#end
#set($service = "service")
#set($services = "services")
 
    $!{serviceInfo.schemaVersion}
    <${services}>
        <${service}>
            #output("$!{serviceInfo.name}", "name")
            #output("$!{serviceInfo.displayName}", "displayName")
            #output("$!{serviceInfo.version}", "version")
            #output("$!{serviceInfo.comment}", "comment")
            #output("$!{serviceInfo.serviceType}", "serviceType")
            #output("$!{serviceInfo.selection}", "selection")
 
            #ifnotnull($serviceInfo.credentialStoreInfo)
 
                #output("$!{serviceInfo.credentialStoreInfo.supported}", "supported")
                #output("$!{serviceInfo.credentialStoreInfo.enabled}", "enabled")
                #output("$!{serviceInfo.credentialStoreInfo.required}", "required")
 
            #end
 
            #if($serviceInfo.components.size()>0)
 
                    #foreach($entry in $serviceInfo.components)
 
                            #output("$!{entry.name}", "name")
                            #output("$!{entry.displayName}", "displayName")
                            #output("$!{entry.category}", "category")
                            #output("$!{entry.deleted}", "deleted")
                            #output("$!{entry.cardinality}", "cardinality")
                            #output("$!{entry.versionAdvertisedField}", "versionAdvertised")
                            #output("$!{entry.versionAdvertisedInternal}", "versionAdvertisedInternal")
                            #output("$!{entry.unlimitedKeyJCERequired}", "unlimitedKeyJCERequired")
                            #output("$!{entry.rollingRestartSupported}", "rollingRestartSupported")
 
                            #ifnotnull($entry.commandScript)
 
                                    #output("$!{entry.commandScript.script}", "script")
                                    #output("$!{entry.commandScript.scriptType}", "scriptType")
                                    #output("$!{entry.commandScript.timeout}", "timeout")
 
                            #end
                            #if($entry.logs.size()>0)
 
                                    #foreach($log in $entry.logs)
 
                                            #output("$!{log.logId}", "logId")
                                            #output("$!{log.primary}", "primary")
 
                                    #end
 
                            #end
                            #if($entry.clientsToUpdateConfigs.size()>0)
 
                                    #foreach($client in $entry.clientsToUpdateConfigs)
                                        #output("$!{client}", "client")
                                    #end
 
                            #end
                            #if($entry.configFiles.size()>0)
 
                                    #foreach($configFile in $entry.configFiles)
 
                                            #output("$!{configFile.type}", "type")
                                            #output("$!{configFile.fileName}", "fileName")
                                            #output("$!{configFile.dictionaryName}", "dictionaryName")
                                            #output("$!{configFile.optional}", "optional")
 
                                    #end
 
                            #end
                            #if($entry.customCommands.size()>0)
 
                                    #foreach($customCommand in $entry.customCommands)
 
                                            #output("$!{customCommand.name}", "name")
                                            #output("$!{customCommand.background}", "background")
 
                                            #ifnotnull($customCommand.commandScript)
 
                                                #output("$!{customCommand.commandScript.script}", "script")
                                                #output("$!{customCommand.commandScript.scriptType}", "scriptType")
                                                #output("$!{customCommand.commandScript.timeout}", "timeout")
 
                                            #end
 
                                    #end
 
                            #end
 
                            #ifnotnull($entry.bulkCommandDefinition)
 
                                    #output("$!{entry.bulkCommandDefinition.displayName}", "displayName")
                                    #output("$!{entry.bulkCommandDefinition.masterComponent}", "masterComponent")
 
                            #end
 
                            #if($entry.dependencies.size()>0)
 
                                    #foreach($dependency in $entry.dependencies)
                                        #output("$!{dependency.name}", "name")
                                        #output("$!{dependency.scope}", "scope")
                                        #output("$!{dependency.serviceName}", "serviceName")
                                        #output("$!{dependency.componentName}", "componentName")
                                        #ifnotnull($dependency.autoDeploy)
 
                                            #output("$!{dependency.autoDeploy.m_enabled}", "enabled")
                                            #output("$!{dependency.autoDeploy.m_coLocate}", "co-locate")
 
                                        #end
                                    #end
 
                            #end
                            #if($entry.configDependencies.size()>0)
 
                                    #foreach($dependency in $entry.configDependencies)
                                        #output("$!{dependency}", "config-type")
                                    #end
 
                            #end
 
                            #ifnotnull($entry.autoDeploy)
 
                                #output("$!{entry.autoDeploy.m_enabled}", "extended")
                                #output("$!{entry.autoDeploy.m_coLocate}", "co-locate")
 
                            #end
 
                            #output("$!{entry.recoveryEnabled}", "recovery_enabled")
                            #output("$!{entry.reassignAllowed}", "reassignAllowed")
                            #output("$!{entry.timelineAppid}", "timelineAppid")
                            #output("$!{entry.customFolder}", "customFolder")
 
                    #end
 
            #end
            #output("$!{serviceInfo.parent}", "extends")
            #output("$!{serviceInfo.widgetsFileName}", "widgetsFileName")
            #output("$!{serviceInfo.metricsFileName}", "metricsFileName")
 
            #output("$!{serviceInfo.isDeleted}", "deleted")
 
            #if($serviceInfo.configLayout.size()>0)
 
                    #foreach($layout in $serviceInfo.configLayout.entrySet())
                    <$!{layout.key}>
                        $!{layout.value}
 
                    #end
 
            #end
            #if($serviceInfo.configDependencies.size()>0)
 
                    #foreach($depend in $serviceInfo.configDependencies)
                        #output("$!{depend}", "config-type")
                    #end
 
            #end
            #if($serviceInfo.excludedConfigTypes.size()>0)
 
                    #foreach($depend in $serviceInfo.excludedConfigTypes)
                        #output("$!{depend}", "config-type")
                    #end
 
            #end
            #if($serviceInfo.configTypes.size()>0)
 
                    #foreach($ctype in $serviceInfo.configTypes.entrySet())
                        <$!{ctype.key}>
                            #foreach($cv in $ctype.value.entrySet())
                                <$!{cv.key}>$!{cv.value}
                            #end
 
                    #end
 
            #end
 
##            #if($pFileSortNames.size()>0) // TODO: xxx
##                
##                    #foreach($name in $pFileSortNames)
##                        #output("$!{name}", "config-type")
##                    #end
##                
##            #end
##
            #if($serviceInfo.requiredServices.size()>0)
 
                #foreach($name in $serviceInfo.requiredServices)
                    #output("$!{name}", "service")
                #end
 
            #end
##
            #if($serviceInfo.themesMap.size()>0)
 
                #foreach($entry in $serviceInfo.themesMap.entrySet())
 
                        #output("$!{entry.key}", "fileName")
                        #output("$!{entry.value.isDefault}", "default")
                        #output("$!{entry.value.deleted}", "deleted")
 
                #end
 
            #end
 
    #if($serviceInfo.themesMap.size()>0)
 
            #foreach($entry in $serviceInfo.themesMap.entrySet())
 
                    #output("$!{entry.key}", "fileName")
                        #output("$!{entry.value.isDefault}", "default")
                        #output("$!{entry.value.deleted}", "deleted")
 
            #end
 
    #end

Leave a Reply

Your email address will not be published. Required fields are marked *