From 5baef0eb7c35018bbfe31a23f29d7799a1ac133e Mon Sep 17 00:00:00 2001 From: houxiaoyu Date: Tue, 5 Sep 2023 11:48:38 +0800 Subject: [PATCH 1/3] [improve][pip] PIP301:Introduce LoadBalanceResources to unify the load-data handle --- pip/pip-301.md | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 pip/pip-301.md diff --git a/pip/pip-301.md b/pip/pip-301.md new file mode 100644 index 0000000000000..c05be097ad1bc --- /dev/null +++ b/pip/pip-301.md @@ -0,0 +1,81 @@ +# Background knowledge + +The following z-nodes store the load and quota data about loadbalance. And the CRUD about them are handled by `localMetadataStore`, not `configurationMetadataStore`. +* `/loadbalance/bundle-data` +* `/loadbalance/broker-time-average` +* `/loadbalance/resource-quota` + +Currently, the access about the above z-nodes are distributed everywhere. It's very easy to call the the wrong `configurationMetadataStore` to handle them, e.g.: +* [[fix] [broker] remove bundle-data in local metadata store.](https://github.com/apache/pulsar/pull/21078) + +# Motivation + +Refactor the access code about balance/load data + +# Goals + +## In Scope + +Introduce `LoadBalanceResources` to unify the CRUD about balance/load data. + +## Out of Scope + +None + +# High Level Design + +Introduce `LoadBalanceResources` which has three inner class: +* `BundleDataResources` +* `BrokerTimeAverageResources` +* `QuotaResources` + +# Detailed Design + +## Design & Implementation Details + +```java +public class LoadBalanceResources { + public static final String BUNDLE_DATA_BASE_PATH = "/loadbalance/bundle-data"; + public static final String BROKER_TIME_AVERAGE_BASE_PATH = "/loadbalance/broker-time-average"; + public static final String RESOURCE_QUOTA_BASE_PATH = "/loadbalance/resource-quota"; + + private final BundleDataResources bundleDataResources; + + public LoadBalanceResources(MetadataStore store, int operationTimeoutSec) { + bundleDataResources = new BundleDataResources(store, operationTimeoutSec); + } + + public static class BundleDataResources extends BaseResources { + public BundleDataResources(MetadataStore store, int operationTimeoutSec) { + super(store, BundleData.class, operationTimeoutSec); + } + // ... + } + + public static class BrokerTimeAverageResources extends BaseResources { + public BrokerTimeAverageResources(MetadataStore store, int operationTimeoutSec) { + super(store, TimeAverageBrokerData.class, operationTimeoutSec); + } + // ... + } + + public static class QuotaResources extends BaseResources { + public QuotaResources(MetadataStore store, int operationTimeoutSec) { + super(store, ResourceQuota.class, operationTimeoutSec); + } + // ... + } +} +``` + +## Public-facing Changes + +None + +### Public API + +None + +# Backward & Forward Compatibility + +None From abcbab687e13e84becbeb2a2c90d0cfd135b97a2 Mon Sep 17 00:00:00 2001 From: houxiaoyu Date: Tue, 5 Sep 2023 16:50:00 +0800 Subject: [PATCH 2/3] update discuss thread --- pip/pip-301.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pip/pip-301.md b/pip/pip-301.md index c05be097ad1bc..8badc8e67f503 100644 --- a/pip/pip-301.md +++ b/pip/pip-301.md @@ -79,3 +79,8 @@ None # Backward & Forward Compatibility None + +# Links + +* Mailing List discussion thread: https://lists.apache.org/thread/7ngw9dc62tj2c4c5484dgsnlwgtstpbj +* Mailing List voting thread: From f54285751b67f53df467386cb8a61f4ecc76f35d Mon Sep 17 00:00:00 2001 From: houxiaoyu Date: Mon, 18 Sep 2023 21:03:38 +0800 Subject: [PATCH 3/3] Update voting thread --- pip/pip-301.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pip/pip-301.md b/pip/pip-301.md index 8badc8e67f503..3450446b20970 100644 --- a/pip/pip-301.md +++ b/pip/pip-301.md @@ -83,4 +83,4 @@ None # Links * Mailing List discussion thread: https://lists.apache.org/thread/7ngw9dc62tj2c4c5484dgsnlwgtstpbj -* Mailing List voting thread: +* Mailing List voting thread: https://lists.apache.org/thread/26dc8r6hnp7owdsq1hpzb48g8vlfrtxt