Commit 7869fb5ef48eb2892aa5c0818c85017b0d86d08a
Committed by
GitHub
1 parent
84421598
added to tenant fields isolatedTbCore and isolatedTbRuleEngine (#2611)
Co-authored-by: Andrew Shvayka <ashvayka@thingsboard.io>
Showing
11 changed files
with
134 additions
and
30 deletions
... | ... | @@ -290,6 +290,20 @@ public class CassandraDatabaseUpgradeService extends AbstractCassandraDatabaseUp |
290 | 290 | log.info("Attributes updated."); |
291 | 291 | } catch (InvalidQueryException e) { |
292 | 292 | } |
293 | + | |
294 | + String updateTenantCoreTableStmt = "alter table tenant add isolated_tb_core boolean"; | |
295 | + String updateTenantRuleEngineTableStmt = "alter table tenant add isolated_tb_rule_engine boolean"; | |
296 | + | |
297 | + try { | |
298 | + log.info("Updating tenant..."); | |
299 | + cluster.getSession().execute(updateTenantCoreTableStmt); | |
300 | + Thread.sleep(2500); | |
301 | + | |
302 | + cluster.getSession().execute(updateTenantRuleEngineTableStmt); | |
303 | + Thread.sleep(2500); | |
304 | + log.info("Tenant updated."); | |
305 | + } catch (InvalidQueryException e) { | |
306 | + } | |
293 | 307 | log.info("Schema updated."); |
294 | 308 | break; |
295 | 309 | default: | ... | ... |
... | ... | @@ -221,6 +221,7 @@ public class SqlDatabaseUpgradeService implements DatabaseEntitiesUpgradeService |
221 | 221 | } |
222 | 222 | } |
223 | 223 | } |
224 | + conn.createStatement().execute("ALTER TABLE tenant ADD COLUMN isolated_tb_core boolean DEFAULT (false), ADD COLUMN isolated_tb_rule_engine boolean DEFAULT (false)"); | |
224 | 225 | log.info("Schema updated."); |
225 | 226 | } |
226 | 227 | break; | ... | ... |
... | ... | @@ -29,6 +29,8 @@ public class Tenant extends ContactBased<TenantId> implements HasTenantId { |
29 | 29 | |
30 | 30 | private String title; |
31 | 31 | private String region; |
32 | + private boolean isolatedTbCore; | |
33 | + private boolean isolatedTbRuleEngine; | |
32 | 34 | |
33 | 35 | public Tenant() { |
34 | 36 | super(); |
... | ... | @@ -72,6 +74,22 @@ public class Tenant extends ContactBased<TenantId> implements HasTenantId { |
72 | 74 | this.region = region; |
73 | 75 | } |
74 | 76 | |
77 | + public boolean isIsolatedTbCore() { | |
78 | + return isolatedTbCore; | |
79 | + } | |
80 | + | |
81 | + public void setIsolatedTbCore(boolean isolatedTbCore) { | |
82 | + this.isolatedTbCore = isolatedTbCore; | |
83 | + } | |
84 | + | |
85 | + public boolean isIsolatedTbRuleEngine() { | |
86 | + return isolatedTbRuleEngine; | |
87 | + } | |
88 | + | |
89 | + public void setIsolatedTbRuleEngine(boolean isolatedTbRuleEngine) { | |
90 | + this.isolatedTbRuleEngine = isolatedTbRuleEngine; | |
91 | + } | |
92 | + | |
75 | 93 | @Override |
76 | 94 | public String getSearchText() { |
77 | 95 | return getTitle(); |
... | ... | @@ -84,6 +102,10 @@ public class Tenant extends ContactBased<TenantId> implements HasTenantId { |
84 | 102 | builder.append(title); |
85 | 103 | builder.append(", region="); |
86 | 104 | builder.append(region); |
105 | + builder.append(", isolatedTbCore="); | |
106 | + builder.append(isolatedTbCore); | |
107 | + builder.append(", isolatedTbRuleEngine="); | |
108 | + builder.append(isolatedTbRuleEngine); | |
87 | 109 | builder.append(", additionalInfo="); |
88 | 110 | builder.append(getAdditionalInfo()); |
89 | 111 | builder.append(", country="); | ... | ... |
... | ... | @@ -112,6 +112,8 @@ public class ModelConstants { |
112 | 112 | public static final String TENANT_TITLE_PROPERTY = TITLE_PROPERTY; |
113 | 113 | public static final String TENANT_REGION_PROPERTY = "region"; |
114 | 114 | public static final String TENANT_ADDITIONAL_INFO_PROPERTY = ADDITIONAL_INFO_PROPERTY; |
115 | + public static final String TENANT_ISOLATED_TB_CORE = "isolated_tb_core"; | |
116 | + public static final String TENANT_ISOLATED_TB_RULE_ENGINE = "isolated_tb_rule_engine"; | |
115 | 117 | |
116 | 118 | public static final String TENANT_BY_REGION_AND_SEARCH_TEXT_COLUMN_FAMILY_NAME = "tenant_by_region_and_search_text"; |
117 | 119 | ... | ... |
... | ... | @@ -24,6 +24,7 @@ import lombok.EqualsAndHashCode; |
24 | 24 | import lombok.ToString; |
25 | 25 | import org.thingsboard.server.common.data.Tenant; |
26 | 26 | import org.thingsboard.server.common.data.id.TenantId; |
27 | +import org.thingsboard.server.dao.model.ModelConstants; | |
27 | 28 | import org.thingsboard.server.dao.model.SearchTextEntity; |
28 | 29 | import org.thingsboard.server.dao.model.type.JsonCodec; |
29 | 30 | |
... | ... | @@ -55,16 +56,16 @@ public final class TenantEntity implements SearchTextEntity<Tenant> { |
55 | 56 | |
56 | 57 | @Column(name = TENANT_TITLE_PROPERTY) |
57 | 58 | private String title; |
58 | - | |
59 | + | |
59 | 60 | @Column(name = SEARCH_TEXT_PROPERTY) |
60 | 61 | private String searchText; |
61 | 62 | |
62 | 63 | @Column(name = TENANT_REGION_PROPERTY) |
63 | 64 | private String region; |
64 | - | |
65 | + | |
65 | 66 | @Column(name = COUNTRY_PROPERTY) |
66 | 67 | private String country; |
67 | - | |
68 | + | |
68 | 69 | @Column(name = STATE_PROPERTY) |
69 | 70 | private String state; |
70 | 71 | |
... | ... | @@ -89,6 +90,12 @@ public final class TenantEntity implements SearchTextEntity<Tenant> { |
89 | 90 | @Column(name = TENANT_ADDITIONAL_INFO_PROPERTY, codec = JsonCodec.class) |
90 | 91 | private JsonNode additionalInfo; |
91 | 92 | |
93 | + @Column(name = ModelConstants.TENANT_ISOLATED_TB_CORE) | |
94 | + private boolean isolatedTbCore; | |
95 | + | |
96 | + @Column(name = ModelConstants.TENANT_ISOLATED_TB_RULE_ENGINE) | |
97 | + private boolean isolatedTbRuleEngine; | |
98 | + | |
92 | 99 | public TenantEntity() { |
93 | 100 | super(); |
94 | 101 | } |
... | ... | @@ -108,6 +115,8 @@ public final class TenantEntity implements SearchTextEntity<Tenant> { |
108 | 115 | this.phone = tenant.getPhone(); |
109 | 116 | this.email = tenant.getEmail(); |
110 | 117 | this.additionalInfo = tenant.getAdditionalInfo(); |
118 | + this.isolatedTbCore = tenant.isIsolatedTbCore(); | |
119 | + this.isolatedTbRuleEngine = tenant.isIsolatedTbRuleEngine(); | |
111 | 120 | } |
112 | 121 | |
113 | 122 | public UUID getUuid() { |
... | ... | @@ -206,6 +215,22 @@ public final class TenantEntity implements SearchTextEntity<Tenant> { |
206 | 215 | this.additionalInfo = additionalInfo; |
207 | 216 | } |
208 | 217 | |
218 | + public boolean isIsolatedTbCore() { | |
219 | + return isolatedTbCore; | |
220 | + } | |
221 | + | |
222 | + public void setIsolatedTbCore(boolean isolatedTbCore) { | |
223 | + this.isolatedTbCore = isolatedTbCore; | |
224 | + } | |
225 | + | |
226 | + public boolean isIsolatedTbRuleEngine() { | |
227 | + return isolatedTbRuleEngine; | |
228 | + } | |
229 | + | |
230 | + public void setIsolatedTbRuleEngine(boolean isolatedTbRuleEngine) { | |
231 | + this.isolatedTbRuleEngine = isolatedTbRuleEngine; | |
232 | + } | |
233 | + | |
209 | 234 | @Override |
210 | 235 | public String getSearchTextSource() { |
211 | 236 | return getTitle(); |
... | ... | @@ -215,7 +240,7 @@ public final class TenantEntity implements SearchTextEntity<Tenant> { |
215 | 240 | public void setSearchText(String searchText) { |
216 | 241 | this.searchText = searchText; |
217 | 242 | } |
218 | - | |
243 | + | |
219 | 244 | public String getSearchText() { |
220 | 245 | return searchText; |
221 | 246 | } |
... | ... | @@ -235,6 +260,8 @@ public final class TenantEntity implements SearchTextEntity<Tenant> { |
235 | 260 | tenant.setPhone(phone); |
236 | 261 | tenant.setEmail(email); |
237 | 262 | tenant.setAdditionalInfo(additionalInfo); |
263 | + tenant.setIsolatedTbCore(isolatedTbCore); | |
264 | + tenant.setIsolatedTbRuleEngine(isolatedTbRuleEngine); | |
238 | 265 | return tenant; |
239 | 266 | } |
240 | 267 | ... | ... |
... | ... | @@ -72,6 +72,12 @@ public final class TenantEntity extends BaseSqlEntity<Tenant> implements SearchT |
72 | 72 | @Column(name = ModelConstants.EMAIL_PROPERTY) |
73 | 73 | private String email; |
74 | 74 | |
75 | + @Column(name = ModelConstants.TENANT_ISOLATED_TB_CORE) | |
76 | + private boolean isolatedTbCore; | |
77 | + | |
78 | + @Column(name = ModelConstants.TENANT_ISOLATED_TB_RULE_ENGINE) | |
79 | + private boolean isolatedTbRuleEngine; | |
80 | + | |
75 | 81 | @Type(type = "json") |
76 | 82 | @Column(name = ModelConstants.TENANT_ADDITIONAL_INFO_PROPERTY) |
77 | 83 | private JsonNode additionalInfo; |
... | ... | @@ -95,6 +101,8 @@ public final class TenantEntity extends BaseSqlEntity<Tenant> implements SearchT |
95 | 101 | this.phone = tenant.getPhone(); |
96 | 102 | this.email = tenant.getEmail(); |
97 | 103 | this.additionalInfo = tenant.getAdditionalInfo(); |
104 | + this.isolatedTbCore = tenant.isIsolatedTbCore(); | |
105 | + this.isolatedTbRuleEngine = tenant.isIsolatedTbRuleEngine(); | |
98 | 106 | } |
99 | 107 | |
100 | 108 | @Override |
... | ... | @@ -126,6 +134,8 @@ public final class TenantEntity extends BaseSqlEntity<Tenant> implements SearchT |
126 | 134 | tenant.setPhone(phone); |
127 | 135 | tenant.setEmail(email); |
128 | 136 | tenant.setAdditionalInfo(additionalInfo); |
137 | + tenant.setIsolatedTbCore(isolatedTbCore); | |
138 | + tenant.setIsolatedTbRuleEngine(isolatedTbRuleEngine); | |
129 | 139 | return tenant; |
130 | 140 | } |
131 | 141 | ... | ... |
... | ... | @@ -183,7 +183,9 @@ CREATE TABLE IF NOT EXISTS tenant ( |
183 | 183 | search_text varchar(255), |
184 | 184 | state varchar(255), |
185 | 185 | title varchar(255), |
186 | - zip varchar(255) | |
186 | + zip varchar(255), | |
187 | + isolated_tb_core boolean, | |
188 | + isolated_tb_rule_engine boolean | |
187 | 189 | ); |
188 | 190 | |
189 | 191 | CREATE TABLE IF NOT EXISTS user_credentials ( | ... | ... |
... | ... | @@ -183,7 +183,9 @@ CREATE TABLE IF NOT EXISTS tenant ( |
183 | 183 | search_text varchar(255), |
184 | 184 | state varchar(255), |
185 | 185 | title varchar(255), |
186 | - zip varchar(255) | |
186 | + zip varchar(255), | |
187 | + isolated_tb_core boolean, | |
188 | + isolated_tb_rule_engine boolean | |
187 | 189 | ); |
188 | 190 | |
189 | 191 | CREATE TABLE IF NOT EXISTS user_credentials ( | ... | ... |
... | ... | @@ -1508,7 +1508,11 @@ |
1508 | 1508 | "idCopiedMessage": "Tenant Id has been copied to clipboard", |
1509 | 1509 | "select-tenant": "Select tenant", |
1510 | 1510 | "no-tenants-matching": "No tenants matching '{{entity}}' were found.", |
1511 | - "tenant-required": "Tenant is required" | |
1511 | + "tenant-required": "Tenant is required", | |
1512 | + "isolated-tb-core": "Processing in isolated ThingsBoard Core container", | |
1513 | + "isolated-tb-rule-engine": "Processing in isolated ThingsBoard Rule Engine container", | |
1514 | + "isolated-tb-core-details": "Requires separate microservice(s) per isolated Tenant", | |
1515 | + "isolated-tb-rule-engine-details": "Requires separate microservice(s) per isolated Tenant" | |
1512 | 1516 | }, |
1513 | 1517 | "timeinterval": { |
1514 | 1518 | "seconds-interval": "{ seconds, plural, 1 {1 second} other {# seconds} }", | ... | ... |
... | ... | @@ -15,32 +15,50 @@ |
15 | 15 | limitations under the License. |
16 | 16 | |
17 | 17 | --> |
18 | -<md-button ng-click="onManageUsers({event: $event})" ng-show="!isEdit" class="md-raised md-primary">{{ 'tenant.manage-tenant-admins' | translate }}</md-button> | |
19 | -<md-button ng-click="onDeleteTenant({event: $event})" ng-show="!isEdit" class="md-raised md-primary">{{ 'tenant.delete' | translate }}</md-button> | |
18 | +<md-button ng-click="onManageUsers({event: $event})" ng-show="!isEdit" class="md-raised md-primary">{{ | |
19 | + 'tenant.manage-tenant-admins' | translate }} | |
20 | +</md-button> | |
21 | +<md-button ng-click="onDeleteTenant({event: $event})" ng-show="!isEdit" class="md-raised md-primary">{{ 'tenant.delete' | |
22 | + | translate }} | |
23 | +</md-button> | |
20 | 24 | |
21 | 25 | <div layout="row"> |
22 | - <md-button ngclipboard data-clipboard-action="copy" | |
23 | - ngclipboard-success="onTenantIdCopied(e)" | |
24 | - data-clipboard-text="{{tenant.id.id}}" ng-show="!isEdit" | |
25 | - class="md-raised"> | |
26 | - <md-icon md-svg-icon="mdi:clipboard-arrow-left"></md-icon> | |
27 | - <span translate>tenant.copyId</span> | |
28 | - </md-button> | |
26 | + <md-button ngclipboard data-clipboard-action="copy" | |
27 | + ngclipboard-success="onTenantIdCopied(e)" | |
28 | + data-clipboard-text="{{tenant.id.id}}" ng-show="!isEdit" | |
29 | + class="md-raised"> | |
30 | + <md-icon md-svg-icon="mdi:clipboard-arrow-left"></md-icon> | |
31 | + <span translate>tenant.copyId</span> | |
32 | + </md-button> | |
29 | 33 | </div> |
30 | 34 | |
31 | 35 | <md-content class="md-padding" layout="column"> |
32 | - <fieldset ng-disabled="$root.loading || !isEdit"> | |
33 | - <md-input-container class="md-block"> | |
34 | - <label translate>tenant.title</label> | |
35 | - <input required name="title" ng-model="tenant.title"> | |
36 | - <div ng-messages="theForm.title.$error"> | |
37 | - <div translate ng-message="required">tenant.title-required</div> | |
38 | - </div> | |
39 | - </md-input-container> | |
40 | - <md-input-container class="md-block"> | |
41 | - <label translate>tenant.description</label> | |
42 | - <textarea ng-model="tenant.additionalInfo.description" rows="2"></textarea> | |
43 | - </md-input-container> | |
44 | - <tb-contact contact="tenant" the-form="theForm" is-edit="isEdit"></tb-contact> | |
45 | - </fieldset> | |
36 | + <fieldset ng-disabled="$root.loading || !isEdit"> | |
37 | + <md-input-container class="md-block"> | |
38 | + <label translate>tenant.title</label> | |
39 | + <input required name="title" ng-model="tenant.title"> | |
40 | + <div ng-messages="theForm.title.$error"> | |
41 | + <div translate ng-message="required">tenant.title-required</div> | |
42 | + </div> | |
43 | + </md-input-container> | |
44 | + <md-input-container class="md-block"> | |
45 | + <label translate>tenant.description</label> | |
46 | + <textarea ng-model="tenant.additionalInfo.description" rows="2"></textarea> | |
47 | + </md-input-container> | |
48 | + <tb-contact contact="tenant" the-form="theForm" is-edit="isEdit"></tb-contact> | |
49 | + <md-input-container class="md-block"> | |
50 | + <md-checkbox ng-disabled="$root.loading || !isEdit" | |
51 | + ng-model="tenant.isolatedTbCore"> | |
52 | + {{'tenant.isolated-tb-core' | translate}}<br/> | |
53 | + <span style="font-size: 10px">{{'tenant.isolated-tb-core-details' | translate}}</span> | |
54 | + </md-checkbox> | |
55 | + </md-input-container> | |
56 | + <md-input-container class="md-block"> | |
57 | + <md-checkbox ng-disabled="$root.loading || !isEdit" | |
58 | + ng-model="tenant.isolatedTbRuleEngine"> | |
59 | + {{'tenant.isolated-tb-rule-engine' | translate}}<br/> | |
60 | + <span style="font-size: 10px">{{'tenant.isolated-tb-rule-engine-details' | translate}}</span> | |
61 | + </md-checkbox> | |
62 | + </md-input-container> | |
63 | + </fieldset> | |
46 | 64 | </md-content> | ... | ... |