Skip to content

Commit

Permalink
[ISSUE-3064][Improve] Improve streampark-console map variable name ba…
Browse files Browse the repository at this point in the history
…se on [3.1 Naming Style] (#3354) (#3363)
  • Loading branch information
VampireAchao authored Nov 30, 2023
1 parent 7b8c21c commit 9c06a86
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ public RestResponse update(Application app) {
@Operation(summary = "Get applications dashboard data")
@PostMapping("dashboard")
public RestResponse dashboard(Long teamId) {
Map<String, Serializable> map = applicationInfoService.getDashboardDataMap(teamId);
return RestResponse.success(map);
Map<String, Serializable> dashboardMap = applicationInfoService.getDashboardDataMap(teamId);
return RestResponse.success(dashboardMap);
}

@Operation(summary = "List applications")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,9 @@ public Map<String, Object> getOptionMap() {
if (StringUtils.isBlank(this.options)) {
return Collections.emptyMap();
}
Map<String, Object> map = JacksonUtils.read(this.options, Map.class);
map.entrySet().removeIf(entry -> entry.getValue() == null);
return map;
Map<String, Object> optionMap = JacksonUtils.read(this.options, Map.class);
optionMap.entrySet().removeIf(entry -> entry.getValue() == null);
return optionMap;
}

@JsonIgnore
Expand Down Expand Up @@ -538,9 +538,9 @@ public Workspace getWorkspace() {
@SuppressWarnings("unchecked")
public Map<String, Object> getHotParamsMap() {
if (StringUtils.isNotBlank(this.hotParams)) {
Map<String, Object> map = JacksonUtils.read(this.hotParams, Map.class);
map.entrySet().removeIf(entry -> entry.getValue() == null);
return map;
Map<String, Object> hotParamsMap = JacksonUtils.read(this.hotParams, Map.class);
hotParamsMap.entrySet().removeIf(entry -> entry.getValue() == null);
return hotParamsMap;
}
return Collections.EMPTY_MAP;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,13 @@ public Map<String, Object> getOptionMap() {
if (StringUtils.isBlank(this.options)) {
return Collections.emptyMap();
}
Map<String, Object> map = JacksonUtils.read(this.options, Map.class);
Map<String, Object> optionMap = JacksonUtils.read(this.options, Map.class);
if (FlinkExecutionMode.YARN_SESSION == getFlinkExecutionModeEnum()) {
map.put(ConfigKeys.KEY_YARN_APP_NAME(), this.clusterName);
map.putAll(YarnQueueLabelExpression.getQueueLabelMap(yarnQueue));
optionMap.put(ConfigKeys.KEY_YARN_APP_NAME(), this.clusterName);
optionMap.putAll(YarnQueueLabelExpression.getQueueLabelMap(yarnQueue));
}
map.entrySet().removeIf(entry -> entry.getValue() == null);
return map;
optionMap.entrySet().removeIf(entry -> entry.getValue() == null);
return optionMap;
}

@JsonIgnore
Expand Down Expand Up @@ -176,16 +176,16 @@ public Map<String, String> getFlinkConfig() throws JsonProcessingException {

@JsonIgnore
public Map<String, Object> getProperties() {
Map<String, Object> map = new HashMap<>();
Map<String, String> dynamicProperties =
Map<String, Object> propertyMap = new HashMap<>();
Map<String, String> dynamicPropertyMap =
PropertiesUtils.extractDynamicPropertiesAsJava(this.getDynamicProperties());
map.putAll(this.getOptionMap());
map.putAll(dynamicProperties);
propertyMap.putAll(this.getOptionMap());
propertyMap.putAll(dynamicPropertyMap);
ResolveOrder resolveOrder = ResolveOrder.of(this.getResolveOrder());
if (resolveOrder != null) {
map.put(CoreOptions.CLASSLOADER_RESOLVE_ORDER.key(), resolveOrder.getName());
propertyMap.put(CoreOptions.CLASSLOADER_RESOLVE_ORDER.key(), resolveOrder.getName());
}
return map;
return propertyMap;
}

public static class SFunc {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ public enum AlertTypeEnum {
private static final Map<Integer, AlertTypeEnum> CACHE_MAP = createCacheMap();

private static Map<Integer, AlertTypeEnum> createCacheMap() {
Map<Integer, AlertTypeEnum> map = new HashMap<>();
Map<Integer, AlertTypeEnum> cacheMap = new HashMap<>();
for (AlertTypeEnum notifyType : AlertTypeEnum.values()) {
map.put(notifyType.code, notifyType);
cacheMap.put(notifyType.code, notifyType);
}
return Collections.unmodifiableMap(map);
return Collections.unmodifiableMap(cacheMap);
}

AlertTypeEnum(Integer code, Class<? extends AlertNotifyService> clazz) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,16 @@ public Map<String, Serializable> getDashboardDataMap(Long teamId) {
}

// result json
Map<String, Serializable> map = new HashMap<>(8);
map.put("task", overview);
map.put("jmMemory", totalJmMemory);
map.put("tmMemory", totalTmMemory);
map.put("totalTM", totalTm);
map.put("availableSlot", availableSlot);
map.put("totalSlot", totalSlot);
map.put("runningJob", runningJob);

return map;
Map<String, Serializable> dashboardDataMap = new HashMap<>(8);
dashboardDataMap.put("task", overview);
dashboardDataMap.put("jmMemory", totalJmMemory);
dashboardDataMap.put("tmMemory", totalTmMemory);
dashboardDataMap.put("totalTM", totalTm);
dashboardDataMap.put("availableSlot", availableSlot);
dashboardDataMap.put("totalSlot", totalSlot);
dashboardDataMap.put("runningJob", runningJob);

return dashboardDataMap;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,14 @@ public List<ExternalLink> render(Long appId) {
}

private void renderLinkUrl(ExternalLink link, Application app) {
Map<String, String> map = new HashMap<>();
map.put(PlaceholderTypeEnum.JOB_ID.get(), app.getJobId());
map.put(PlaceholderTypeEnum.JOB_NAME.get(), app.getJobName());
map.put(PlaceholderTypeEnum.YARN_ID.get(), app.getAppId());
Map<String, String> placeholderValueMap = new HashMap<>();
placeholderValueMap.put(PlaceholderTypeEnum.JOB_ID.get(), app.getJobId());
placeholderValueMap.put(PlaceholderTypeEnum.JOB_NAME.get(), app.getJobName());
placeholderValueMap.put(PlaceholderTypeEnum.YARN_ID.get(), app.getAppId());
PropertyPlaceholderHelper propertyPlaceholderHelper = new PropertyPlaceholderHelper("{", "}");
link.setRenderedLinkUrl(
propertyPlaceholderHelper.replacePlaceholders(link.getLinkUrl().trim(), map::get));
propertyPlaceholderHelper.replacePlaceholders(
link.getLinkUrl().trim(), placeholderValueMap::get));
}

private boolean check(ExternalLink params) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,30 +311,30 @@ public List<Map<String, Object>> listConf(Project project) {
private void eachFile(File file, List<Map<String, Object>> list, Boolean isRoot) {
if (file != null && file.exists() && file.listFiles() != null) {
if (isRoot) {
Map<String, Object> map = new HashMap<>(0);
map.put("key", file.getName());
map.put("title", file.getName());
map.put("value", file.getAbsolutePath());
Map<String, Object> fileMap = new HashMap<>(0);
fileMap.put("key", file.getName());
fileMap.put("title", file.getName());
fileMap.put("value", file.getAbsolutePath());
List<Map<String, Object>> children = new ArrayList<>();
eachFile(file, children, false);
if (!children.isEmpty()) {
map.put("children", children);
fileMap.put("children", children);
}
list.add(map);
list.add(fileMap);
} else {
for (File item : Objects.requireNonNull(file.listFiles())) {
String title = item.getName();
String value = item.getAbsolutePath();
Map<String, Object> map = new HashMap<>(0);
map.put("key", title);
map.put("title", title);
map.put("value", value);
Map<String, Object> fileMap = new HashMap<>(0);
fileMap.put("key", title);
fileMap.put("title", title);
fileMap.put("value", value);
List<Map<String, Object>> children = new ArrayList<>();
eachFile(item, children, false);
if (!children.isEmpty()) {
map.put("children", children);
fileMap.put("children", children);
}
list.add(map);
list.add(fileMap);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,10 @@ public String getSavepointFromAppCfgIfStreamParkOrSQLJob(Application application
if (applicationConfig == null) {
return null;
}
Map<String, String> map = applicationConfig.readConfig();
return FlinkUtils.isCheckpointEnabled(map) ? map.get(SAVEPOINT_DIRECTORY.key()) : null;
Map<String, String> configMap = applicationConfig.readConfig();
return FlinkUtils.isCheckpointEnabled(configMap)
? configMap.get(SAVEPOINT_DIRECTORY.key())
: null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ public static Map<String, String> getQueueLabelMap(String queueLabelExp) {
return Collections.emptyMap();
}
YarnQueueLabelExpression yarnQueueLabelExpression = of(queueLabelExp);
Map<String, String> map = new HashMap<>(2);
Map<String, String> queueLabelMap = new HashMap<>(2);
yarnQueueLabelExpression
.getLabelExpression()
.ifPresent(labelExp -> map.put(ConfigKeys.KEY_YARN_APP_NODE_LABEL(), labelExp));
map.put(ConfigKeys.KEY_YARN_APP_QUEUE(), yarnQueueLabelExpression.queue);
return map;
.ifPresent(labelExp -> queueLabelMap.put(ConfigKeys.KEY_YARN_APP_NODE_LABEL(), labelExp));
queueLabelMap.put(ConfigKeys.KEY_YARN_APP_QUEUE(), yarnQueueLabelExpression.queue);
return queueLabelMap;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public RestResponse getUserRouters(Long teamId) {
@PostMapping("list")
@RequiresPermissions("menu:view")
public RestResponse menuList(Menu menu) {
Map<String, Object> maps = this.menuService.listMenuMap(menu);
return RestResponse.success(maps);
Map<String, Object> menuMap = this.menuService.listMenuMap(menu);
return RestResponse.success(menuMap);
}
}

0 comments on commit 9c06a86

Please sign in to comment.