From a5475f35abe7f192668fe3c5ba48cd9be3cf44af Mon Sep 17 00:00:00 2001 From: chenzhiguo Date: Mon, 30 Dec 2024 21:29:58 +0800 Subject: [PATCH] Add metadata in reponse for demo --- .../agent/demo/response/LiveLocation.java | 8 +++++-- .../agent/demo/response/LiveTransmission.java | 20 ++++++++++++++++-- .../jd/live/agent/demo/util/LiveLocation.java | 13 ++++++++++++ .../agent/demo/util/LiveTransmission.java | 21 ++++++++++++++++++- 4 files changed, 57 insertions(+), 5 deletions(-) diff --git a/joylive-demo/joylive-demo-common/joylive-demo-api/src/main/java/com/jd/live/agent/demo/response/LiveLocation.java b/joylive-demo/joylive-demo-common/joylive-demo-api/src/main/java/com/jd/live/agent/demo/response/LiveLocation.java index 930de04e7..e99e49168 100644 --- a/joylive-demo/joylive-demo-common/joylive-demo-api/src/main/java/com/jd/live/agent/demo/response/LiveLocation.java +++ b/joylive-demo/joylive-demo-common/joylive-demo-api/src/main/java/com/jd/live/agent/demo/response/LiveLocation.java @@ -32,13 +32,14 @@ public class LiveLocation implements Serializable { private String ruleId; private String laneSpaceId; private String lane; + private String group; private String ip; public LiveLocation() { } - public LiveLocation(String liveSpaceId, String unit, String cell, String cluster, String cloud, String ruleId, String laneSpaceId, String lane) { + public LiveLocation(String liveSpaceId, String unit, String cell, String cluster, String cloud, String ruleId, String laneSpaceId, String lane, String group) { this.liveSpaceId = liveSpaceId; this.unit = unit; this.cell = cell; @@ -47,6 +48,7 @@ public LiveLocation(String liveSpaceId, String unit, String cell, String cluster this.ruleId = ruleId; this.laneSpaceId = laneSpaceId; this.lane = lane; + this.group = group; this.ip = Ipv4.getLocalIp(); } @@ -59,7 +61,8 @@ public static LiveLocation build() { System.getProperty(LiveTransmission.X_LIVE_CLOUD), System.getProperty(LiveTransmission.X_LIVE_RULE_ID), System.getProperty(LiveTransmission.X_LANE_SPACE_ID), - System.getProperty(LiveTransmission.X_LANE_CODE) + System.getProperty(LiveTransmission.X_LANE_CODE), + System.getProperty(LiveTransmission.X_SERVICE_GROUP) ); } @@ -74,6 +77,7 @@ public String toString() { ", ruleId=" + (ruleId == null ? "null" : ('\'' + ruleId + '\'')) + ", lane-space-id=" + (laneSpaceId == null ? "null" : ('\'' + laneSpaceId + '\'')) + ", lane=" + (lane == null ? "null" : ('\'' + lane + '\'')) + + ", group=" + (group == null ? "null" : ('\'' + group + '\'')) + ", ip=" + (ip == null ? "null" : ('\'' + ip + '\'')) + '}'; } diff --git a/joylive-demo/joylive-demo-common/joylive-demo-api/src/main/java/com/jd/live/agent/demo/response/LiveTransmission.java b/joylive-demo/joylive-demo-common/joylive-demo-api/src/main/java/com/jd/live/agent/demo/response/LiveTransmission.java index 80606a979..555324e3b 100644 --- a/joylive-demo/joylive-demo-common/joylive-demo-api/src/main/java/com/jd/live/agent/demo/response/LiveTransmission.java +++ b/joylive-demo/joylive-demo-common/joylive-demo-api/src/main/java/com/jd/live/agent/demo/response/LiveTransmission.java @@ -15,6 +15,7 @@ */ package com.jd.live.agent.demo.response; +import com.jd.live.agent.core.util.network.Ipv4; import lombok.Getter; import lombok.Setter; @@ -33,23 +34,32 @@ public class LiveTransmission implements Serializable { public static final String X_LIVE_UID = "x-live-uid"; public static final String X_LANE_SPACE_ID = "x-lane-space-id"; public static final String X_LANE_CODE = "x-lane-code"; + public static final String X_SERVICE_GROUP = "x-service-group"; private String carrier; private String liveSpaceId; private String ruleId; private String uid; private String laneSpaceId; private String lane; + private String cluster; + private String cloud; + private String group; + private String ip; public LiveTransmission() { } - public LiveTransmission(String carrier, String liveSpaceId, String ruleId, String uid, String laneSpaceId, String lane) { + public LiveTransmission(String carrier, String liveSpaceId, String ruleId, String uid, String laneSpaceId, String lane, String cluster, String cloud, String group) { this.carrier = carrier; this.liveSpaceId = liveSpaceId; this.ruleId = ruleId; this.uid = uid; this.laneSpaceId = laneSpaceId; this.lane = lane; + this.cluster = cluster; + this.cloud = cloud; + this.group = group; + this.ip = Ipv4.getLocalIp(); } public static LiveTransmission build(String carrier, Function tagFunc) { @@ -58,7 +68,10 @@ public static LiveTransmission build(String carrier, Function ta tagFunc.apply(X_LIVE_RULE_ID), tagFunc.apply(X_LIVE_UID), tagFunc.apply(X_LANE_SPACE_ID), - tagFunc.apply(X_LANE_CODE) + tagFunc.apply(X_LANE_CODE), + tagFunc.apply(X_LIVE_CLUSTER), + tagFunc.apply(X_LIVE_CLOUD), + tagFunc.apply(X_SERVICE_GROUP) ); } @@ -70,6 +83,9 @@ public String toString() { ", x-live-uid=" + (uid == null ? "null" : ('\'' + uid + '\'')) + ", x-lane-space-id=" + (laneSpaceId == null ? "null" : ('\'' + laneSpaceId + '\'')) + ", x-lane-code=" + (lane == null ? "null" : ('\'' + lane + '\'')) + + ", x-live-cluster=" + (cluster == null ? "null" : ('\'' + cluster + '\'')) + + ", x-live-cloud=" + (cloud == null ? "null" : ('\'' + cloud + '\'')) + + ", x-service-group=" + (group == null ? "null" : ('\'' + group + '\'')) + '}'; } } diff --git a/joylive-demo/joylive-demo-common/joylive-demo-api/src/main/java/com/jd/live/agent/demo/util/LiveLocation.java b/joylive-demo/joylive-demo-common/joylive-demo-api/src/main/java/com/jd/live/agent/demo/util/LiveLocation.java index 587a51df0..38be8f107 100644 --- a/joylive-demo/joylive-demo-common/joylive-demo-api/src/main/java/com/jd/live/agent/demo/util/LiveLocation.java +++ b/joylive-demo/joylive-demo-common/joylive-demo-api/src/main/java/com/jd/live/agent/demo/util/LiveLocation.java @@ -15,6 +15,7 @@ */ package com.jd.live.agent.demo.util; +import com.jd.live.agent.core.util.network.Ipv4; import lombok.Getter; import lombok.Setter; @@ -26,6 +27,10 @@ public class LiveLocation { private String cell; private String laneSpaceId; private String lane; + private String cluster; + private String cloud; + private String group; + private String ip; public LiveLocation() { liveSpaceId = System.getProperty("x-live-space-id"); @@ -33,6 +38,10 @@ public LiveLocation() { cell = System.getProperty("x-live-cell"); laneSpaceId = System.getProperty("x-lane-space-id"); lane = System.getProperty("x-lane-code"); + cluster = System.getProperty("x-live-cluster"); + cloud = System.getProperty("x-live-cloud"); + group = System.getProperty("x-service-group"); + ip = Ipv4.getLocalIp(); } @Override @@ -43,6 +52,10 @@ public String toString() { ", cell=" + (cell == null ? "null" : ('\'' + cell + '\'')) + ", lane-space-id=" + (laneSpaceId == null ? "null" : ('\'' + laneSpaceId + '\'')) + ", lane=" + (lane == null ? "null" : ('\'' + lane + '\'')) + + ", cluster=" + (cluster == null ? "null" : ('\'' + cluster + '\'')) + + ", cloud=" + (cloud == null ? "null" : ('\'' + cloud + '\'')) + + ", group=" + (group == null ? "null" : ('\'' + group + '\'')) + + ", ip=" + (ip == null ? "null" : ('\'' + ip + '\'')) + '}'; } } diff --git a/joylive-demo/joylive-demo-common/joylive-demo-api/src/main/java/com/jd/live/agent/demo/util/LiveTransmission.java b/joylive-demo/joylive-demo-common/joylive-demo-api/src/main/java/com/jd/live/agent/demo/util/LiveTransmission.java index ae944a931..57628a884 100644 --- a/joylive-demo/joylive-demo-common/joylive-demo-api/src/main/java/com/jd/live/agent/demo/util/LiveTransmission.java +++ b/joylive-demo/joylive-demo-common/joylive-demo-api/src/main/java/com/jd/live/agent/demo/util/LiveTransmission.java @@ -15,11 +15,15 @@ */ package com.jd.live.agent.demo.util; +import com.jd.live.agent.core.util.network.Ipv4; import lombok.Getter; import lombok.Setter; import java.util.function.Function; +import static com.jd.live.agent.demo.response.LiveTransmission.X_LIVE_CLOUD; +import static com.jd.live.agent.demo.response.LiveTransmission.X_LIVE_CLUSTER; + @Getter @Setter public class LiveTransmission { @@ -28,20 +32,29 @@ public class LiveTransmission { public static final String X_LIVE_UID = "x-live-uid"; public static final String X_LANE_SPACE_ID = "x-lane-space-id"; public static final String X_LANE_CODE = "x-lane-code"; + public static final String X_SERVICE_GROUP = "x-service-group"; private String carrier; private String liveSpaceId; private String ruleId; private String uid; private String laneSpaceId; private String lane; + private String cluster; + private String cloud; + private String group; + private String ip; - public LiveTransmission(String carrier, String liveSpaceId, String ruleId, String uid, String laneSpaceId, String lane) { + public LiveTransmission(String carrier, String liveSpaceId, String ruleId, String uid, String laneSpaceId, String lane, String cluster, String cloud, String group) { this.carrier = carrier; this.liveSpaceId = liveSpaceId; this.ruleId = ruleId; this.uid = uid; this.laneSpaceId = laneSpaceId; this.lane = lane; + this.cluster = cluster; + this.cloud = cloud; + this.group = group; + this.ip = Ipv4.getLocalIp(); } public LiveTransmission(String carrier, Function tagFunc) { @@ -51,6 +64,9 @@ public LiveTransmission(String carrier, Function tagFunc) { uid = tagFunc.apply(X_LIVE_UID); laneSpaceId = tagFunc.apply(X_LANE_SPACE_ID); lane = tagFunc.apply(X_LANE_CODE); + cluster = tagFunc.apply(X_LIVE_CLUSTER); + cloud = tagFunc.apply(X_LIVE_CLOUD); + group = tagFunc.apply(X_SERVICE_GROUP); } @Override @@ -61,6 +77,9 @@ public String toString() { ", x-live-uid=" + (uid == null ? "null" : ('\'' + uid + '\'')) + ", x-lane-space-id=" + (laneSpaceId == null ? "null" : ('\'' + laneSpaceId + '\'')) + ", x-lane-code=" + (lane == null ? "null" : ('\'' + lane + '\'')) + + ", x-live-cluster=" + (cluster == null ? "null" : ('\'' + cluster + '\'')) + + ", x-live-cloud=" + (cloud == null ? "null" : ('\'' + cloud + '\'')) + + ", x-service-group=" + (group == null ? "null" : ('\'' + group + '\'')) + '}'; } }