Skip to content

Commit

Permalink
Extend UI topic view by new field: fallbackToRemoteDatacenterEnabled (#…
Browse files Browse the repository at this point in the history
…1945)

* added new field to topic UI form - fallbackToRemoteDatacenterEnabled
  • Loading branch information
Diewa authored Feb 5, 2025
1 parent 1a912ce commit b97157b
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 6 deletions.
1 change: 1 addition & 0 deletions hermes-console/json-server/db.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
},
"jsonToAvroDryRun": false,
"ack": "LEADER",
"fallbackToRemoteDatacenterEnabled": true,
"trackingEnabled": true,
"migratedFromJsonType": false,
"schemaIdAwareSerializationEnabled": false,
Expand Down
1 change: 1 addition & 0 deletions hermes-console/json-server/topics.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"ack": "LEADER",
"trackingEnabled": false,
"migratedFromJsonType": false,
"fallbackToRemoteDatacenterEnabled": true,
"schemaIdAwareSerializationEnabled": false,
"contentType": "AVRO",
"maxMessageSize": 10240,
Expand Down
1 change: 1 addition & 0 deletions hermes-console/src/api/topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface Topic {
labels: TopicLabel[];
createdAt: number; // java.time.Instant
modifiedAt: number; // java.time.Instant
fallbackToRemoteDatacenterEnabled: boolean;
}

export type TopicName = string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface TopicForm {
contentType: string;
maxMessageSize: number;
ack: string;
fallbackToRemoteDatacenterEnabled: boolean;
schema?: string;
}

Expand Down
1 change: 1 addition & 0 deletions hermes-console/src/dummy/topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const dummyTopic: TopicWithSchema = {
ack: Ack.LEADER,
trackingEnabled: false,
migratedFromJsonType: false,
fallbackToRemoteDatacenterEnabled: true,
schemaIdAwareSerializationEnabled: false,
contentType: ContentType.AVRO,
maxMessageSize: defaultMaxMessageSize,
Expand Down
3 changes: 3 additions & 0 deletions hermes-console/src/i18n/en-US/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ const en_US = {
offlineRetention: 'Offline retention',
creationDate: 'Creation date',
modificationDate: 'Modification date',
fallbackToRemoteDatacenterEnabled: 'Fallback to remote DC enabled',
tooltips: {
acknowledgement:
'Specifies the strength of guarantees that acknowledged message was indeed persisted. ' +
Expand All @@ -366,6 +367,8 @@ const en_US = {
'Should data from this topic be stored in offline storage (e.g. HDFS).',
offlineRetention:
'For how long should this topic be stored in offline storage.',
fallbackToRemoteDatacenterEnabled:
'In the event of a message publishing failure, Hermes falls back to a remote data center instead of storing unsent messages on local disk. Enabling fallback to the remote data center increases the durability of your messages but may impact the publishing latency and increase number of duplicated messages.',
},
ackText: {
all: 'All brokers',
Expand Down
1 change: 1 addition & 0 deletions hermes-console/src/i18n/en-US/topic-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const messages = {
days: 'DAYS',
},
ack: 'Kafka ACK level',
fallbackToRemoteDatacenterEnabled: 'Fallback to remote DC enabled',
ackHelpTitle: 'ACK level is very important',
ackHelpText:
'Set ACK level according to your durability and latency requirements, see: ',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@
:name="$t('topicView.properties.modificationDate')"
:value="formatTimestamp(props.topic.modifiedAt)"
/>
<key-value-card-item
:name="$t('topicView.properties.fallbackToRemoteDatacenterEnabled')"
:value="topic.fallbackToRemoteDatacenterEnabled"
:tooltip="
$t('topicView.properties.tooltips.fallbackToRemoteDatacenterEnabled')
"
/>
</key-value-card>
</template>

Expand Down
10 changes: 10 additions & 0 deletions hermes-console/src/views/topic/topic-form/TopicForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,16 @@
hide-details
/>

<v-switch
v-if="operation !== 'add' && !topic.fallbackToRemoteDatacenterEnabled"
v-model="form.fallbackToRemoteDatacenterEnabled"
:label="$t('topicForm.fields.fallbackToRemoteDatacenterEnabled')"
inset
color="success"
density="comfortable"
hide-details
/>

<console-alert
v-if="showTrackingAlert"
:title="$t('topicForm.warnings.trackingEnabled.title')"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ public void ensureUpdatedTopicIsValid(Topic updated, Topic previous, RequestUser
checkOwner(updated);
checkTopicLabels(updated);

if ((previous.isFallbackToRemoteDatacenterEnabled()
!= updated.isFallbackToRemoteDatacenterEnabled())
if (previous.isFallbackToRemoteDatacenterEnabled()
&& !updated.isFallbackToRemoteDatacenterEnabled()
&& !modifiedBy.isAdmin()) {
throw new TopicValidationException(
"User is not allowed to update fallback to remote datacenter for this topic");
"User is not allowed to disable fallback to remote datacenter for this topic");
}

if (!previous.getChaos().equals(updated.getChaos()) && !modifiedBy.isAdmin()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ public void shouldAllowAdminUserCreateTopicWithNonDefaultFallbackToRemoteDatacen
}

@Test
public void shouldNotAllowNonAdminUserToChangeFallbackToRemoteDatacenter() {
public void shouldNotAllowNonAdminUserToDisableFallbackToRemoteDatacenter() {
// given
Topic topic =
hermes
Expand All @@ -840,11 +840,27 @@ public void shouldNotAllowNonAdminUserToChangeFallbackToRemoteDatacenter() {
// then
response.expectStatus().isBadRequest();
assertThat(response.expectBody(String.class).returnResult().getResponseBody())
.contains("User is not allowed to update fallback to remote datacenter for this topic");
.contains("User is not allowed to disable fallback to remote datacenter for this topic");
}

@Test
public void shouldAllowAdminUserToChangeFallbackToRemoteDatacenter() {
public void shouldAllowNonAdminUserToEnableFallbackToRemoteDatacenter() {
// given
Topic topic = hermes.initHelper().createTopic(topicWithRandomName().build());
TestSecurityProvider.setUserIsAdmin(false);
PatchData patchData =
PatchData.from(ImmutableMap.of("fallbackToRemoteDatacenterEnabled", true));

// when
WebTestClient.ResponseSpec response =
hermes.api().updateTopic(topic.getQualifiedName(), patchData);

// then
response.expectStatus().isOk();
}

@Test
public void shouldAllowAdminUserToDisableFallbackToRemoteDatacenter() {
// given
Topic topic =
hermes
Expand Down

0 comments on commit b97157b

Please sign in to comment.