Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support exchange properties #646

Merged
merged 16 commits into from
Oct 17, 2022

Conversation

coderzc
Copy link
Member

@coderzc coderzc commented Aug 4, 2022

Master Issue: #631

Motivation

Support exchange properties

Modifications

Save durable, auto-delete to exchange properties.
Add exchange declare check for the durable and auto-delete parameter.

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

This change is a trivial rework / code cleanup without any test coverage.

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added integration tests for end-to-end deployment with large payloads (10MB)
  • Extended integration test for recovery after broker failure

Does this pull request potentially affect one of the following parts:

If yes was chosen, please highlight the changes

  • Dependencies (does it add or upgrade a dependency): (yes / no)
  • The public API: (yes / no)
  • The schema: (yes / no / don't know)
  • The default values of configurations: (yes / no)
  • The wire protocol: (yes / no)
  • The rest endpoints: (yes / no)
  • The admin cli options: (yes / no)
  • Anything that affects deployment: (yes / no / don't know)

Documentation

Check the box below.

Need to update docs?

  • doc-required

    (If you need help on updating docs, create a doc issue)

  • no-need-doc

    (Please explain why)

  • doc

    (If this PR contains doc changes)

@coderzc coderzc requested review from gaoran10, codelipenghui and a team as code owners August 4, 2022 11:12
@CLAassistant
Copy link

CLAassistant commented Aug 4, 2022

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added the no-need-doc This pr does not need any document label Aug 4, 2022
@coderzc coderzc force-pushed the feature_exchange_properties branch from 0dba887 to 848f740 Compare August 5, 2022 09:06
@coderzc
Copy link
Member Author

coderzc commented Aug 8, 2022

@gaoran10 @codelipenghui PTAL

Copy link
Collaborator

@gaoran10 gaoran10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Left some comments.

case EXCHANGE:
map.put(k, ExchangeUtil.covertStringValueAsObject(v, String.class));
break;
case INDEX:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why need this?

@@ -44,11 +44,20 @@ public class InMemoryExchange extends AbstractAmqpExchange {
private final long currentLedgerId;
private long currentEntryId;

private Map<String, Object> properties;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can add this field in class AbstractAmqpExchange.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PersistentExchange don't need this field.

properties.forEach((k, v) -> {
switch (k) {
case QUEUES:
map.put(k, ExchangeUtil.covertStringValueAsObject(v, List.class));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The QUEUES is not a custom property.

map.put(k, ExchangeUtil.covertStringValueAsObject(v, List.class));
break;
case TYPE:
case EXCHANGE:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with QUEUES.

CompletableFuture<Topic> topicCompletableFuture = amqpTopicManager.getTopic(topicName, createIfMissing);

Map<String, String> newProperties = null;
if (createIfMissing && arguments != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can serialize declare custom properties to a JSON string, and put it to a specific key.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea

@@ -57,7 +68,8 @@ protected ExchangeContainer(AmqpTopicManager amqpTopicManager, PulsarService pul
public CompletableFuture<AmqpExchange> asyncGetExchange(NamespaceName namespaceName,
String exchangeName,
boolean createIfMissing,
String exchangeType) {
String exchangeType,
FieldTable arguments) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we change this to Map<String, Object>?

@coderzc coderzc requested a review from gaoran10 August 12, 2022 11:04
Comment on lines +105 to +107
props.put(DURABLE, "" + durable);
props.put(AUTO_DELETE, "" + autoDelete);
props.put(INTERNAL, "" + internal);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
props.put(DURABLE, "" + durable);
props.put(AUTO_DELETE, "" + autoDelete);
props.put(INTERNAL, "" + internal);
props.put(DURABLE, Double.toString(durable));
props.put(AUTO_DELETE, Double.toString(autoDelete));
props.put(INTERNAL, Double.toString(internal));

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'll resolve this in another PR.

@gaoran10 gaoran10 merged commit dd9ea01 into streamnative:master Oct 17, 2022
@gaoran10 gaoran10 mentioned this pull request Oct 19, 2022
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-need-doc This pr does not need any document
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants