GanfengTan commented on code in PR #5534:
URL: https://github.com/apache/inlong/pull/5534#discussion_r944357496
##########
inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/utils/MetaDataUtils.java:
##########
@@ -53,10 +62,59 @@ public static Map<String, String> getLogInfo(String
fileName) {
return podInf;
}
- public static String concatString(String str1, String str2) {
- if (!StringUtils.isNoneBlank(str2)) {
- return str1;
+ /**
+ * standard log for k8s
+ *
+ * get labels of pod
+ */
+ public static Map<String, String> getPodLabels(JobProfile jobProfile) {
+ if (Objects.isNull(jobProfile) ||
!jobProfile.hasKey(JOB_FILE_META_FILTER_BY_LABELS)) {
+ return null;
+ }
+ String labels = jobProfile.get(JOB_FILE_META_FILTER_BY_LABELS);
+ Type type = new TypeToken<HashMap<Integer, String>>() {
+ }.getType();
+ Gson gson = new Gson();
+ return gson.fromJson(labels, type);
+ }
+
+ public static List<String> getNamespace(JobProfile jobProfile) {
+ if (Objects.isNull(jobProfile) ||
!jobProfile.hasKey(JOB_FILE_PROPERTIES)) {
+ return null;
+ }
+ String property = jobProfile.get(JOB_FILE_PROPERTIES);
+ Type type = new TypeToken<HashMap<Integer, String>>() {
+ }.getType();
+ Gson gson = new Gson();
+ Map<String, String> properties = gson.fromJson(property, type);
+ return properties.keySet().stream().map(data -> {
+ if (data.contains(NAMESPACE)) {
+ return properties.get(data);
+ }
+ return null;
+ }).filter(Objects::nonNull).collect(Collectors.toList());
+ }
+
+ /**
+ * standard log for k8s
+ *
+ * get name of pod
+ */
+ public static String getPodName(JobProfile jobProfile) {
+ if (Objects.isNull(jobProfile) ||
!jobProfile.hasKey(JOB_FILE_PROPERTIES)) {
+ return null;
}
- return str1.concat("\n").concat(str2);
+ String property = jobProfile.get(JOB_FILE_PROPERTIES);
+ Type type = new TypeToken<HashMap<Integer, String>>() {
+ }.getType();
+ Gson gson = new Gson();
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]