Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Databus Throttling Changes #847

Merged
merged 27 commits into from
Nov 6, 2024
Merged

Databus Throttling Changes #847

merged 27 commits into from
Nov 6, 2024

Conversation

nabajyotiDash-hub
Copy link
Contributor

Github Issue

1234

What Are We Doing Here?

Here is where you should describe the problem you are solving as it relates to the Github Issue referred above, adding any fine
details on the solution that might otherwise not be recognizable for someone
unfamiliar with the changes. Add some pictures if it helps.

How to Test and Verify

  1. Check out this PR
  2. Run Command X, Click Button Y
  3. Profit

Risk

Level

Low, Medium, or High. Give an indication of what you think is the level of change introduced by this PR. High means a massive change to a core functionality.
Low means a really minor change that shouldn't have any regression effect.

Required Testing

Smoke, Regression, or Manual. (All changes except documentation need smoke
testing at a minimum).

Risk Summary

Add one or a few complete sentences about the possible risks or concerns for
this change.

Code Review Checklist

  • Tests are included. If not, make sure you leave us a line or two for the reason.

  • Pulled down the PR and performed verification of at least being able to
    build and run.

  • Well documented, including updates to any necessary markdown files. When
    we inevitably come back to this code it will only take hours to figure out, not
    days.

  • Consistent/Clear/Thoughtful? We are better with this code. We also aren't
    a victim of rampaging consistency, and should be using this course of action.
    We don't have coding standards out yet for this project, so please make sure to address any feedback regarding STYLE so the codebase remains consistent.

  • PR has a valid summary, and a good description.

@nabajyotiDash-hub nabajyotiDash-hub requested a review from a team as a code owner November 4, 2024 15:00
@nabajyotiDash-hub nabajyotiDash-hub changed the title Master2 Databus Throttling Changes Nov 4, 2024
anurag0510 and others added 6 commits November 5, 2024 16:03
* PD-257044-changes-for-databus

* duplicated kafka and ssm util packages in emo sor module

* removed redundant dependencies
* PD-257044-changes-for-databus

* duplicated kafka and ssm util packages in emo sor module

* removed redundant dependencies

* additional changes

* additional changes

* additional changes

* removed unneccessary dependencies
bharadwaj-k
bharadwaj-k previously approved these changes Nov 6, 2024
bharadwaj-k
bharadwaj-k previously approved these changes Nov 6, 2024
Copy link

@bharadwaj-k bharadwaj-k left a comment

Choose a reason for hiding this comment

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

LGTM

anandujayan
anandujayan previously approved these changes Nov 6, 2024
bharadwaj-k
bharadwaj-k previously approved these changes Nov 6, 2024
anandujayan
anandujayan previously approved these changes Nov 6, 2024
bharadwaj-k
bharadwaj-k previously approved these changes Nov 6, 2024
Copy link
Contributor

@IgorKruiper IgorKruiper left a comment

Choose a reason for hiding this comment

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

one potential blocking issue

Copy link
Contributor

@IgorKruiper IgorKruiper left a comment

Choose a reason for hiding this comment

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

Thanks

bharadwaj-k
bharadwaj-k previously approved these changes Nov 6, 2024
bharadwaj-k
bharadwaj-k previously approved these changes Nov 6, 2024
@nabajyotiDash-hub nabajyotiDash-hub merged commit 387db36 into main Nov 6, 2024
3 of 5 checks passed
@nabajyotiDash-hub nabajyotiDash-hub deleted the master2 branch November 6, 2024 17:40
@@ -46,7 +46,7 @@ public void sendMessages(String topic, Collection<String> events, String queueTy
throw new RuntimeException("Error sending messages to Kafka", e);
}
}
_log.info("Finished sending messages to topic '{}' time taken : {} milliseconds", topic, Duration.between(startTime,LocalDateTime.now()).toMillis());
_log.info("Finished sending messages to topic '{}' time taken : {} milliseconds", topic, Duration.between(startTime, LocalDateTime.now()).toMillis());

Choose a reason for hiding this comment

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

do log the events.size(O as well in this log, will be easy for analytics, on time taken per topic for the events size...

return response.getVersion();
} catch (Exception e) {
logger.error("Failed to update parameter: " + key + " with value: " + value, e);
throw new RuntimeException("Unexpected error updating parameter: " + key + " with value: " + value, e);

Choose a reason for hiding this comment

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

Why its a RuntimeException and not an Exception?

logger.info("Successfully updated parameter: " + key + " with value: " + value + ", Update Version: " + response.getVersion());
return response.getVersion();
} catch (Exception e) {
logger.error("Failed to update parameter: " + key + " with value: " + value, e);

Choose a reason for hiding this comment

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

Is this log required? adding too much log events... anyway the thrown exception will be logged by the caller/catcher...

}
executionName = executionName.trim();
// Replace invalid characters with underscores
String sanitized = executionName.replaceAll("[^a-zA-Z0-9\\-_]", "_");

Choose a reason for hiding this comment

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

suggestion: to optimize
replaceAll("[^a-zA-Z0-9\\-_]+", "")
a '+' after the square bracket would be better, as it will reduce the consecutive invalid character to one '
' string...
"ab_2@@3###4$$$$5%%%%%".replaceAll("[^a-zA-Z0-9\\-_]", "") would return 'ab_2___3____4_____5___'

"ab_2@@_3###4$$$$5%%%%%".replaceAll("[^a-zA-Z0-9\\-_]+", "") would return 'ab_2__3__4__5'


// Truncate from the beginning if length exceeds 66 characters
if (sanitized.length() > 66) {
sanitized = sanitized.substring(sanitized.length() - 66);

Choose a reason for hiding this comment

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

Is the sanitized text expected to be unique?
If so why not append a GUID value to the string, after trimming to 50 characters?

return;
} catch(Exception e){
logger.error("Error starting step-function with attributes " + queueExecutionAttributes + " | " + e.getMessage());
throw new RuntimeException("Error starting step-function with attributes " + queueExecutionAttributes + " | " + e.getMessage());

Choose a reason for hiding this comment

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

Why not throw the exception and why thrownig a RuntimeException?

private Integer queueThreshold;
private Integer batchSize;
private Integer interval;
private String status;

Choose a reason for hiding this comment

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

Status should be a boolean or ENUM, random string will be confusing and maintenance hassle

private String queueName;
private String queueType;
private String topicName;
private Integer queueThreshold;

Choose a reason for hiding this comment

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

Why is this an Object (Integer) and not a primitive 'integer'?
I suppose this should be a 'long', to support really long size value

}

if(executionAttributes.getStatus() == null || executionAttributes.getStatus().isEmpty()) {
executionAttributes.setStatus("ENABLED");

Choose a reason for hiding this comment

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

Use Enum for status, to have the predefined list of values and easy comparison/check

} catch (StateMachineDoesNotExistException e) {
logger.error("State Machine does not exist for queue_type: " + queueType + ", queue_name: " + queueName, e);
} catch (InvalidArnException e) {
logger.error("Invalid ARN provided for queue_type: " + queueType + ", queue_name: " + queueName, e);

Choose a reason for hiding this comment

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

Why not log the ARN?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants