-
-
Notifications
You must be signed in to change notification settings - Fork 27k
Issue #450. First commit. Queue Based Load Leveling #521
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
Conversation
@Amarnath510 the Travis CI build is failing and needs to be fixed first. Looks like there's wrong artifactId in |
@iluwatar |
@Amarnath510 thanks for the quick fix. The changes are applied automatically as you push. Unfortunately now there's a new (Checkstyle) error in the build - see https://travis-ci.org/iluwatar/java-design-patterns/builds/177451598 |
@iluwatar |
You can reproduce the Checkstyle issues in Eclipse IDE by selecting the project(s) in package/project explorer, right-clicking the project and choosing Checkstyle - Check Code with Checkstyle. I'll add that to the instructions. |
@iluwatar
Just to make clear what steps I have done,
Please let me know if I have missed something here. |
There is |
@iluwatar Also can you tell me how to compile the whole project locally. I want to check locally before committing my changes. |
Added dependency "maven-pmd-plugin" to the pom file.
If you scroll the build output a bit upwards you will find this line: To build locally you just need to do |
@iluwatar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest some improvements to the code. In general the pattern looks good already 👍
|
||
## Credits | ||
|
||
* [Design Pattern: Queue-Based Load Leveling Pattern](https://msdn.microsoft.com/en-us/library/dn589783.aspx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would formulate this Microsoft Cloud Design Patterns: Queue-Based Load Leveling Pattern
srvExec.start(); | ||
} catch (Exception e) { | ||
LOGGER.error(e.getMessage()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of working directly with Thread
s it is recommended practise to use ExecutorService instead. For example take a look at this tutorial.
public String toString() { | ||
return msg; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would refactor to make this class immutable. Remove no-args constructor and setter and make msg
final.
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(App.class); | ||
|
||
private BlockingQueue<Message> blkQueue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(App.class); | ||
|
||
private MessageQueue msgQueue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final
private MessageQueue msgQueue; | ||
|
||
// Total message count that a TaskGenerator will submit. | ||
private int msgCount; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make attributes final
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am using msgCount
to create particular number of messages which I am submitting to MessageQueue. For each message I am reducing the the msgCount
value. If I make this value final then I can't keep count of message that I am creating.
Should I use a local variable and copy the value of the msgCount and then use it? Is this the way to do?
Apart from this I have made all the remaining changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's ok then. Can you resolve the merge conflict, please?
while (this.msgCount > 0) { | ||
String statusMsg = "Message-" + this.msgCount + " submitted by " + Thread.currentThread().getName(); | ||
Message newMessage = new Message(statusMsg); | ||
this.submit(newMessage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Message could be created and submitted on one line
import org.junit.Test; | ||
|
||
/** | ||
* Tests that Caching example runs without errors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix comment
Message msg = new Message("MessageQueue Test"); | ||
|
||
// submit message | ||
msgQueue.submitMsg(msg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Message can be created and submitted on one line
@iluwatar |
The conflict should be easy to resolve. See this guide for instructions how to solve this using the command line only. |
@iluwatar |
Good job @Amarnath510 👍 I'm happy to accept your contribution. |
@iluwatar |
Excellent, I'm looking forward to hearing from you again 😄 |
I have completed coding, design (UML), README.md. jUnit tests.
This is my first code submission for open source.
Please review and let me know the issues.
I have one question,
In the README.md file we have to generate the "pumlid". I don't know how to generate the same.
As of now I have left it blank. Let me know how to generate the same.