Skip to content

Commit

Permalink
Add nested Property List
Browse files Browse the repository at this point in the history
  • Loading branch information
lhpqaq committed Dec 15, 2024
1 parent 25b4366 commit 4be4db8
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,16 @@ public interface ServiceConverter {
ServiceVO fromPO2VO(ServicePO servicePO);

List<ServiceVO> fromPO2VO(List<ServicePO> servicePOList);

// @AfterMapping
// default void afterMapping(@MappingTarget ServiceVO serviceVO, ServiceDTO serviceDTO) {
// for (int i = 0; i < serviceDTO.getConfigs().size(); i++) {
// for (int j = 0; j < serviceDTO.getConfigs().get(i).getProperties().size(); j++) {
// if (serviceDTO.getConfigs().get(i).getProperties().get(j).getValues() != null) {
// System.out.println(serviceDTO.getConfigs().get(i).getProperties().get(j).getValues());
// System.out.println(serviceVO.getConfigs().get(i).getProperties().get(j).getValues());
// }
// }
// }
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import lombok.Data;

import java.io.Serializable;
import java.util.List;

@Data
public class PropertyDTO implements Serializable {
Expand All @@ -34,4 +35,6 @@ public class PropertyDTO implements Serializable {
private String desc;

private AttrsDTO attrs;

private List<PropertyDTO> values;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import lombok.Data;

import java.util.List;

@Data
public class PropertyVO {

Expand All @@ -32,4 +34,6 @@ public class PropertyVO {
private String desc;

private AttrsVO attrs;

private List<PropertyVO> values;
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ public List<StackVO> list() {
List<ServiceDTO> serviceDTOList = entry.getValue();
for (ServiceDTO serviceDTO : serviceDTOList) {
serviceDTO.setConfigs(StackUtils.SERVICE_CONFIG_MAP.get(serviceDTO.getName()));
// if (serviceDTO.getName().equals("grafana")) {
// List<ServiceConfigDTO> serviceConfigDTOList =
// StackUtils.SERVICE_CONFIG_MAP.get(serviceDTO.getName());
//
// log.info(String.valueOf(PropertyConverter.INSTANCE.fromDTO2VO(serviceConfigDTOList.get(0).getProperties())));
// log.info(ServiceConverter.INSTANCE.fromDTO2VO(serviceDTO).toString());
// }
}

StackVO stackVO = StackConverter.INSTANCE.fromDTO2VO(stackDTO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import java.util.List;

@Data
@XmlAccessorType(XmlAccessType.FIELD)
Expand All @@ -40,4 +42,8 @@ public class PropertyModel {

@XmlElement(name = "attrs")
private AttrsModel attrs;

@XmlElementWrapper(name = "values")
@XmlElement(name = "property")
private List<PropertyModel> values;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@

import org.apache.commons.lang3.StringUtils;

import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j
public class StackConfigUtils {

/**
Expand All @@ -46,6 +49,9 @@ public static List<PropertyDTO> loadConfig(String fileName) {
List<PropertyDTO> propertyDTOList = new ArrayList<>();
for (PropertyModel propertyModel : propertyModels) {
PropertyDTO propertyDTO = getPropertyDTO(propertyModel);
if (propertyDTO.getValues() != null) {
log.info(propertyDTO.toString());
}
propertyDTOList.add(propertyDTO);
}

Expand All @@ -65,6 +71,15 @@ private static PropertyDTO getPropertyDTO(PropertyModel propertyModel) {
propertyDTO.setAttrs(attrsDTO);
}

if (propertyModel.getValues() != null) {
List<PropertyDTO> values = new ArrayList<>();
for (PropertyModel childProperty : propertyModel.getValues()) {
PropertyDTO childPropertyDTO = getPropertyDTO(childProperty);
values.add(childPropertyDTO);
}
propertyDTO.setValues(values);
}

return propertyDTO;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,27 @@
-->

<configuration>
<property>
<name>hbase_user_nproc_limit</name>
<values>
<property>
<name>nofile_limit</name>
<value>128000</value>
<description>Max open files limit</description>
</property>
<property>
<name>nproc_limit</name>
<value>65536</value>
<description>Max number of processes limit</description>
</property>
<property>
<name>custom_limit</name>
<value>32000</value>
<description>Custom limit for another resource</description>
</property>
</values>
<description>Max number of processes limit setting for HBase user.</description>
</property>
<property>
<name>content</name>
<description>This is the freemarker template for grafana.ini file</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ scrape_configs:
static_configs:
- targets: ['localhost:9090']
<#list scrapeJobs as job>
- job_name: "${job.name}"
scrape_interval: ${job.scrapeInterval}
static_configs:
- targets: ${job.targets}
</#list>
]]>
</value>
<attrs>
Expand Down

0 comments on commit 4be4db8

Please sign in to comment.