Skip to content

Conversation

@miguelcnf
Copy link
Contributor

This tries to remove the oldest metric of the buffer once we reach max capacity and replace it with the new metrics instead of discarding those.

 This tries to remove the oldest metric of the buffer once we reach max capacity and replace it with the new metrics instead of discarding those.
@miguelcnf miguelcnf requested a review from reistiago March 9, 2017 20:52
Copy link
Contributor

@reistiago reistiago left a comment

Choose a reason for hiding this comment

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

I would really like to replace the exception based approach.

Thoughts?

if (!inserted) {
try {
LOGGER.fine("Buffer is full, trying to discard oldest metric.");
aggregatedFreqBuffer.remove();
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of remove we could use pool ( https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ArrayBlockingQueue.html#poll() ) which would allow us to log the discarded metric if we wanted, which I think we want, and doesn't throw exception if it's empty - returns null).

Thinking out loud, should we drop more then one metric?

if (!inserted) {
try {
LOGGER.fine("Buffer is full, trying to discard oldest metric.");
buffer.remove();
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

}

@Test
public void shouldDiscardIfStandardBufferIsFull() {
Copy link
Contributor

Choose a reason for hiding this comment

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

we should, somehow, test the behaviour of trying to empty it when it's empty, more so if we keep the current exception based implementation for when it's empty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants