diff --git a/db/init/mysql/schema.sql b/db/init/mysql/schema.sql index c838022633b8..732999229fc1 100644 --- a/db/init/mysql/schema.sql +++ b/db/init/mysql/schema.sql @@ -2446,6 +2446,7 @@ CREATE TABLE `discovery_upstream` `upstream_status` int(0) NOT NULL COMMENT 'type (0, healthy, 1 unhealthy)', `weight` int(0) NOT NULL COMMENT 'the weight for lists', `props` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'the other field (json)', + `metadata` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'user-defined metadata for gray release', `date_created` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'create time', `date_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT 'update time', PRIMARY KEY (`id`) USING BTREE, diff --git a/db/init/ob/schema.sql b/db/init/ob/schema.sql index 906323b20b10..fd655fca5efc 100644 --- a/db/init/ob/schema.sql +++ b/db/init/ob/schema.sql @@ -2363,6 +2363,7 @@ CREATE TABLE `discovery_upstream` `upstream_status` int(0) NOT NULL COMMENT 'type (0, healthy, 1 unhealthy)', `weight` int(0) NOT NULL COMMENT 'the weight for lists', `props` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'the other field (json)', + `metadata` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'user-defined metadata for gray release', `date_created` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'create time', `date_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT 'update time', PRIMARY KEY (`id`) USING BTREE, diff --git a/db/init/og/create-table.sql b/db/init/og/create-table.sql index 932dd7b449f8..bb1963c2523f 100644 --- a/db/init/og/create-table.sql +++ b/db/init/og/create-table.sql @@ -2544,6 +2544,7 @@ CREATE TABLE "public"."discovery_upstream" "upstream_status" int4 NOT NULL, "weight" int4 NOT NULL, "props" text COLLATE "pg_catalog"."default", + "metadata" text COLLATE "pg_catalog"."default", "date_created" timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "date_updated" timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP ) @@ -2556,6 +2557,7 @@ COMMENT ON COLUMN "public"."discovery_upstream"."upstream_url" IS 'ip:port'; COMMENT ON COLUMN "public"."discovery_upstream"."upstream_status" IS 'type (0, healthy, 1 unhealthy)'; COMMENT ON COLUMN "public"."discovery_upstream"."weight" IS 'the weight for lists'; COMMENT ON COLUMN "public"."discovery_upstream"."props" IS 'the other field (json)'; +COMMENT ON COLUMN "public"."discovery_upstream"."metadata" IS 'user-defined metadata for gray release'; COMMENT ON COLUMN "public"."discovery_upstream"."date_created" IS 'create time'; COMMENT ON COLUMN "public"."discovery_upstream"."date_updated" IS 'update time'; CREATE INDEX "unique_discovery_upstream_discovery_handler_id" ON "public"."discovery_upstream" USING btree ( diff --git a/db/init/oracle/schema.sql b/db/init/oracle/schema.sql index 7aeb47b46c50..56053ca835ec 100644 --- a/db/init/oracle/schema.sql +++ b/db/init/oracle/schema.sql @@ -2735,10 +2735,12 @@ create table discovery_upstream upstream_status NUMBER(10) not null, weight NUMBER(10) not null, props CLOB, + metadata CLOB, date_created timestamp(3) default SYSDATE not null, date_updated timestamp(3) default SYSDATE not null, PRIMARY KEY (id) ); +COMMENT ON COLUMN discovery_upstream.metadata IS 'user-defined metadata for gray release'; CREATE UNIQUE INDEX discovery_upstream_idx ON discovery_upstream (discovery_handler_id, upstream_url); -- Add comments to the columns @@ -3815,4 +3817,4 @@ INSERT INTO permission (id, object_id, resource_id, date_created, date_updated) INSERT INTO permission (id, object_id, resource_id, date_created, date_updated) VALUES ('1953049887387303902', '1346358560427216896', '1953048313980116901', sysdate, sysdate); INSERT INTO permission (id, object_id, resource_id, date_created, date_updated) VALUES ('1953049887387303903', '1346358560427216896', '1953048313980116902', sysdate, sysdate); INSERT INTO permission (id, object_id, resource_id, date_created, date_updated) VALUES ('1953049887387303904', '1346358560427216896', '1953048313980116903', sysdate, sysdate); -INSERT INTO permission (id, object_id, resource_id, date_created, date_updated) VALUES ('1953049887387303905', '1346358560427216896', '1953048313980116904', sysdate, sysdate); \ No newline at end of file +INSERT INTO permission (id, object_id, resource_id, date_created, date_updated) VALUES ('1953049887387303905', '1346358560427216896', '1953048313980116904', sysdate, sysdate); diff --git a/db/init/pg/create-table.sql b/db/init/pg/create-table.sql index d1e0130fd33d..4f57be5db34c 100644 --- a/db/init/pg/create-table.sql +++ b/db/init/pg/create-table.sql @@ -2667,6 +2667,7 @@ CREATE TABLE "public"."discovery_upstream" "upstream_status" int4 NOT NULL, "weight" int4 NOT NULL, "props" text COLLATE "pg_catalog"."default", + "metadata" text COLLATE "pg_catalog"."default", "date_created" timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "date_updated" timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP ) @@ -2679,6 +2680,7 @@ COMMENT ON COLUMN "public"."discovery_upstream"."upstream_url" IS 'ip:port'; COMMENT ON COLUMN "public"."discovery_upstream"."upstream_status" IS 'type (0, healthy, 1 unhealthy)'; COMMENT ON COLUMN "public"."discovery_upstream"."weight" IS 'the weight for lists'; COMMENT ON COLUMN "public"."discovery_upstream"."props" IS 'the other field (json)'; +COMMENT ON COLUMN "public"."discovery_upstream"."metadata" IS 'user-defined metadata for gray release'; COMMENT ON COLUMN "public"."discovery_upstream"."date_created" IS 'create time'; COMMENT ON COLUMN "public"."discovery_upstream"."date_updated" IS 'update time'; diff --git a/db/upgrade/2.7.1-upgrade-2.7.2-mysql.sql b/db/upgrade/2.7.1-upgrade-2.7.2-mysql.sql new file mode 100644 index 000000000000..6f89cfa9d122 --- /dev/null +++ b/db/upgrade/2.7.1-upgrade-2.7.2-mysql.sql @@ -0,0 +1,20 @@ +-- 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. + +-- this file works for MySQL. + +-- Add metadata column to discovery_upstream table for gray release +ALTER TABLE `discovery_upstream` ADD COLUMN `metadata` TEXT COMMENT 'User-defined metadata for gray release' AFTER `props`; diff --git a/db/upgrade/2.7.1-upgrade-2.7.2-ob.sql b/db/upgrade/2.7.1-upgrade-2.7.2-ob.sql new file mode 100644 index 000000000000..e93b88d95af4 --- /dev/null +++ b/db/upgrade/2.7.1-upgrade-2.7.2-ob.sql @@ -0,0 +1,18 @@ +-- 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. + +-- this file works for Oceanbase. +ALTER TABLE `discovery_upstream` ADD COLUMN `metadata` TEXT COMMENT 'User-defined metadata for gray release' AFTER `props`; diff --git a/db/upgrade/2.7.1-upgrade-2.7.2-og.sql b/db/upgrade/2.7.1-upgrade-2.7.2-og.sql new file mode 100644 index 000000000000..a736062b21d8 --- /dev/null +++ b/db/upgrade/2.7.1-upgrade-2.7.2-og.sql @@ -0,0 +1,19 @@ +-- 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. + +-- this file works for og. +ALTER TABLE "public"."discovery_upstream" ADD COLUMN "metadata" text; +COMMENT ON COLUMN "public"."discovery_upstream"."metadata" IS 'User-defined metadata for gray release'; diff --git a/db/upgrade/2.7.1-upgrade-2.7.2-oracle.sql b/db/upgrade/2.7.1-upgrade-2.7.2-oracle.sql new file mode 100644 index 000000000000..e5beaa874ef3 --- /dev/null +++ b/db/upgrade/2.7.1-upgrade-2.7.2-oracle.sql @@ -0,0 +1,19 @@ +-- 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. + +-- this file works for Oracle, can not use "`" syntax. +ALTER TABLE discovery_upstream ADD metadata CLOB; +COMMENT ON COLUMN discovery_upstream.metadata IS 'User-defined metadata for gray release'; diff --git a/db/upgrade/2.7.1-upgrade-2.7.2-pg.sql b/db/upgrade/2.7.1-upgrade-2.7.2-pg.sql new file mode 100644 index 000000000000..f23396401fb9 --- /dev/null +++ b/db/upgrade/2.7.1-upgrade-2.7.2-pg.sql @@ -0,0 +1,19 @@ +-- 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. + +-- this file works for PostgreSQL, can not use "`" syntax. +ALTER TABLE "public"."discovery_upstream" ADD COLUMN "metadata" text; +COMMENT ON COLUMN "public"."discovery_upstream"."metadata" IS 'User-defined metadata for gray release'; diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/DiscoveryUpstreamDTO.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/DiscoveryUpstreamDTO.java index dcceeb0bf4cc..af29e787e51b 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/DiscoveryUpstreamDTO.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/DiscoveryUpstreamDTO.java @@ -82,6 +82,11 @@ public class DiscoveryUpstreamDTO implements Serializable { @NotBlank(message = "props can't be null") private String props; + /** + * metadata. + */ + private String metadata; + /** * created time. */ @@ -231,6 +236,24 @@ public void setProps(final String props) { this.props = props; } + /** + * getMetadata. + * + * @return metadata + */ + public String getMetadata() { + return metadata; + } + + /** + * setMetadata. + * + * @param metadata metadata + */ + public void setMetadata(final String metadata) { + this.metadata = metadata; + } + /** * getDateCreated. * diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/ProxySelectorAddDTO.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/ProxySelectorAddDTO.java index 661ca0c0884b..558df7246562 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/ProxySelectorAddDTO.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/ProxySelectorAddDTO.java @@ -450,6 +450,11 @@ public static class DiscoveryUpstream { */ private String props; + /** + * metadata. + */ + private String metadata; + /** * startupTime. */ @@ -573,6 +578,24 @@ public void setProps(final String props) { this.props = props; } + /** + * get metadata. + * + * @return metadata + */ + public String getMetadata() { + return metadata; + } + + /** + * set metadata. + * + * @param metadata metadata + */ + public void setMetadata(final String metadata) { + this.metadata = metadata; + } + /** * get startupTime. * @return startupTime diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/DiscoveryUpstreamDO.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/DiscoveryUpstreamDO.java index 93f899b8ccf6..d08af7ca4bab 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/DiscoveryUpstreamDO.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/DiscoveryUpstreamDO.java @@ -61,6 +61,11 @@ public class DiscoveryUpstreamDO extends BaseDO { */ private String props; + /** + * metadata. + */ + private String metadata; + /** * namespaceId. */ @@ -214,6 +219,24 @@ public void setProps(final String props) { this.props = props; } + /** + * getMetadata. + * + * @return metadata + */ + public String getMetadata() { + return metadata; + } + + /** + * setMetadata. + * + * @param metadata metadata + */ + public void setMetadata(final String metadata) { + this.metadata = metadata; + } + /** * builder. * @@ -258,6 +281,7 @@ public static DiscoveryUpstreamDO buildDiscoveryUpstreamDO(final DiscoveryUpstre .status(item.getStatus()) .weight(item.getWeight()) .props(item.getProps()) + .metadata(item.getMetadata()) .url(item.getUrl()) .namespaceId(item.getNamespaceId()) .dateCreated(currentTime) @@ -322,6 +346,11 @@ public static final class DiscoveryUpstreamBuilder { */ private String props; + /** + * metadata. + */ + private String metadata; + /** * namespaceId. */ @@ -435,6 +464,17 @@ public DiscoveryUpstreamBuilder props(final String props) { return this; } + /** + * metadata. + * + * @param metadata metadata + * @return DiscoveryUpstreamBuilder + */ + public DiscoveryUpstreamBuilder metadata(final String metadata) { + this.metadata = metadata; + return this; + } + /** * build namespaceId. * @@ -461,6 +501,7 @@ public DiscoveryUpstreamDO build() { discoveryUpstreamDO.setUpstreamStatus(this.status); discoveryUpstreamDO.setWeight(this.weight); discoveryUpstreamDO.setProps(this.props); + discoveryUpstreamDO.setMetadata(this.metadata); discoveryUpstreamDO.setNamespaceId(this.namespaceId); discoveryUpstreamDO.setDateCreated(this.dateCreated); discoveryUpstreamDO.setDateUpdated(this.dateUpdated); diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/DiscoveryUpstreamVO.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/DiscoveryUpstreamVO.java index a6bfcd42f26c..22792b591618 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/DiscoveryUpstreamVO.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/DiscoveryUpstreamVO.java @@ -54,6 +54,11 @@ public class DiscoveryUpstreamVO { */ private String props; + /** + * metadata. + */ + private String metadata; + /** * dateCreated. */ @@ -185,6 +190,24 @@ public void setProps(final String props) { this.props = props; } + /** + * getMetadata. + * + * @return metadata + */ + public String getMetadata() { + return metadata; + } + + /** + * setMetadata. + * + * @param metadata metadata + */ + public void setMetadata(final String metadata) { + this.metadata = metadata; + } + /** * getStartupTime. * diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/ProxySelectorServiceImpl.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/ProxySelectorServiceImpl.java index a4b2a40fd907..354c0aa7768a 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/ProxySelectorServiceImpl.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/ProxySelectorServiceImpl.java @@ -266,6 +266,7 @@ private void addUpstreamList(final ProxySelectorAddDTO proxySelectorAddDTO, fina .status(discoveryUpstream.getStatus()) .weight(discoveryUpstream.getWeight()) .props(Optional.ofNullable(discoveryUpstream.getProps()).orElse("{}")) + .metadata(discoveryUpstream.getMetadata()) .dateCreated(currentTime) .dateUpdated(currentTime) .build(); @@ -380,6 +381,7 @@ public String update(final ProxySelectorAddDTO proxySelectorAddDTO) { .status(discoveryUpstream.getStatus()) .weight(discoveryUpstream.getWeight()) .props(discoveryUpstream.getProps()) + .metadata(discoveryUpstream.getMetadata()) .dateCreated(Optional.ofNullable(discoveryUpstream.getStartupTime()).map(t -> new Timestamp(Long.parseLong(t))).orElse(currentTime)) .dateUpdated(Optional.ofNullable(discoveryUpstream.getStartupTime()).map(t -> new Timestamp(Long.parseLong(t))).orElse(currentTime)) .build(); diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/transfer/DiscoveryTransfer.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/transfer/DiscoveryTransfer.java index 91f854cd5ff1..b87642b6f08f 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/transfer/DiscoveryTransfer.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/transfer/DiscoveryTransfer.java @@ -17,6 +17,7 @@ package org.apache.shenyu.admin.transfer; +import org.apache.commons.lang3.StringUtils; import org.apache.shenyu.admin.model.dto.DiscoveryDTO; import org.apache.shenyu.admin.model.dto.DiscoveryHandlerDTO; import org.apache.shenyu.admin.model.dto.DiscoveryRelDTO; @@ -37,6 +38,8 @@ import org.apache.shenyu.common.dto.convert.selector.CommonUpstream; import org.apache.shenyu.common.utils.GsonUtils; +import java.util.Collections; +import java.util.Map; import java.util.Optional; import java.util.Properties; @@ -64,6 +67,7 @@ public DiscoveryUpstreamDO mapToDo(DiscoveryUpstreamData discoveryUpstreamData) .status(data.getStatus()) .weight(data.getWeight()) .props(data.getProps()) + .metadata(data.getMetadata()) .url(data.getUrl()) .dateUpdated(data.getDateUpdated()) .dateCreated(data.getDateCreated()).build()).orElse(null); @@ -85,6 +89,15 @@ public CommonUpstream mapToCommonUpstream(DiscoveryUpstreamData discoveryUpstrea .orElse(new Properties()); commonUpstream .setHealthCheckEnabled(Boolean.parseBoolean(properties.getProperty("healthCheckEnabled", "true"))); + Map metadataMap; + try { + metadataMap = StringUtils.isBlank(data.getMetadata()) + ? Collections.emptyMap() + : GsonUtils.getInstance().toObjectMap(data.getMetadata(), String.class); + } catch (Exception ex) { + metadataMap = Collections.emptyMap(); + } + commonUpstream.setMetadata(metadataMap); return commonUpstream; }).orElse(null); } @@ -105,6 +118,7 @@ public DiscoveryUpstreamVO mapToVo(DiscoveryUpstreamDO discoveryUpstreamDO) { vo.setStatus(data.getUpstreamStatus()); vo.setWeight(data.getWeight()); vo.setProps(data.getProps()); + vo.setMetadata(data.getMetadata()); vo.setStartupTime(String.valueOf(data.getDateCreated().getTime())); return vo; }).orElse(null); @@ -191,6 +205,7 @@ public DiscoveryUpstreamData mapToData(DiscoveryUpstreamDO discoveryUpstreamDO) discoveryUpstreamData.setDiscoveryHandlerId(data.getDiscoveryHandlerId()); discoveryUpstreamData.setWeight(data.getWeight()); discoveryUpstreamData.setProps(data.getProps()); + discoveryUpstreamData.setMetadata(data.getMetadata()); discoveryUpstreamData.setDateUpdated(data.getDateUpdated()); discoveryUpstreamData.setDateCreated(data.getDateCreated()); return discoveryUpstreamData; @@ -213,6 +228,7 @@ public DiscoveryUpstreamData mapToData(DiscoveryUpstreamDTO discoveryUpstreamDTO discoveryUpstreamData.setDiscoveryHandlerId(data.getDiscoveryHandlerId()); discoveryUpstreamData.setWeight(data.getWeight()); discoveryUpstreamData.setProps(data.getProps()); + discoveryUpstreamData.setMetadata(data.getMetadata()); discoveryUpstreamData.setNamespaceId(data.getNamespaceId()); discoveryUpstreamData.setDateCreated(data.getDateCreated()); discoveryUpstreamData.setDateUpdated(data.getDateUpdated()); @@ -329,6 +345,7 @@ public DiscoveryUpstreamDTO mapToDTO(DiscoveryUpstreamDO discoveryUpstreamDO) { return Optional.ofNullable(discoveryUpstreamDO).map(data -> { DiscoveryUpstreamDTO discoveryUpstreamDTO = new DiscoveryUpstreamDTO(); discoveryUpstreamDTO.setProps(data.getProps()); + discoveryUpstreamDTO.setMetadata(data.getMetadata()); discoveryUpstreamDTO.setStatus(data.getUpstreamStatus()); discoveryUpstreamDTO.setUrl(data.getUpstreamUrl()); discoveryUpstreamDTO.setDiscoveryHandlerId(data.getDiscoveryHandlerId()); @@ -372,6 +389,9 @@ public DiscoveryUpstreamData mapToDiscoveryUpstreamData(CommonUpstream commonUps .orElse(new Properties()); properties.setProperty("healthCheckEnabled", String.valueOf(commonUpstream.isHealthCheckEnabled())); discoveryUpstreamDTO.setProps(GsonUtils.getInstance().toJson(properties)); + if (commonUpstream.getMetadata() != null && !commonUpstream.getMetadata().isEmpty()) { + discoveryUpstreamDTO.setMetadata(GsonUtils.getInstance().toJson(commonUpstream.getMetadata())); + } return mapToData(discoveryUpstreamDTO); } } diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/utils/CommonUpstreamUtils.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/utils/CommonUpstreamUtils.java index 6a6cdc5c2e26..1a60b721d2d3 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/utils/CommonUpstreamUtils.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/utils/CommonUpstreamUtils.java @@ -251,6 +251,7 @@ public static List convertCommonUpstreamList(final List + @@ -41,7 +42,8 @@ upstream_url, upstream_status, weight, - props + props, + metadata