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

#405: Refactored NB services to work with async requests #1421

Merged
merged 5 commits into from Oct 16, 2018

Conversation

nikitacherevko
Copy link
Collaborator

No description provided.

}

/**
* {@inheritDoc}
*/
@Override
public List<FlowPayload> deleteFlows() {
public CompletableFuture<List<FlowPayload>> deleteFlows() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we rename this method into deleteAllFlows... because names deleteFlow and deleteFlows too similar.

PS We should keep together deleteFlow and delete(All)Flows methods.

for (int i = 0; i < flows.size(); i++) {
String requestId = correlationId + "-" + i;
FlowPayload flow = flows.get(i);
deleteResult.add(sendDeleteFlow(flow.getId(), requestId).join());
Copy link
Collaborator

Choose a reason for hiding this comment

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

It will not parallel execute.

@@ -385,83 +346,70 @@ private BatchResults flowPushUnpush(List<FlowInfoData> externalFlows, FlowOperat
InfoMessage flowRequest =
new InfoMessage(data, System.currentTimeMillis(), flowCorrelation, Destination.WFM);
flowRequests.add(flowRequest);
messageProducer.send(topic, flowRequest);
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you use CompletableFuture.allOf method, you can keep "current" worflow of this method.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've rewritten it using the way you suggested

} else {
msgs.add("FAILURE (TE): Flow " + status.getId()

FlowStatusResponse teResponse = (FlowStatusResponse) flowPair.getRight().join();
Copy link
Collaborator

Choose a reason for hiding this comment

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

you are ignoring request into TE (.getRight())... Usage Pair<> object here looks weird.

}
final Map<SwitchId, List<SimpleSwitchRule>> switchRules = new HashMap<>();

return CompletableFuture.supplyAsync(() -> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe that CompletableFuture.allOf is more suitable here.

@@ -55,9 +48,6 @@ public void onMessage(Message message) {
try (MDCCloseable closable = MDC.putCloseable(CORRELATION_ID, message.getCorrelationId())) {
logger.debug("Message received: {} - {}", Thread.currentThread().getId(), message);
messagingChannel.onResponse(message);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why for we need separate "listenr"? Why we can't attach kafka-consumer directly to messagingChannel.onResponse (or some other method of KafkaMessagingChannel)?

…ync-service

# Conflicts:
#	services/src/northbound/src/main/java/org/openkilda/northbound/config/MessageConsumerConfig.java
@nikitacherevko nikitacherevko merged commit b70ddde into issue/nb-async Oct 16, 2018
@nikitacherevko nikitacherevko deleted the issue/nb-async-service branch October 16, 2018 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants