This repository has been archived by the owner on Jul 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Initial implementation of disk backed queue. #2
Open
mspiegel
wants to merge
6
commits into
master
Choose a base branch
from
spiegel/disk-backed-queue
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db1b51d
to
6a3c77d
Compare
Thread-safe FIFO queue that uses a muxy filesystem to write overflow elements to disk. If memory capacity is not exceeded then all operations occur in memory. {@link #put(Object)} requests are designed to return quickly and write to disk asynchronously if one or more background threads have been configured. All requests of the {@link DiskBackedQueueInternals#get(long, TimeUnit)} family perform synchronous reads from the disk. A {@link #close()} will write the contents of the queue to the muxy filesystem. Nearly all parameter are required to the Builder object. This is a deliberate design decision to discourage a reliance of magical default values that lead to behavior surprises for your application. Single threaded unit tests are passing. Multithreaded test is failing on IOException for uninitialized muxy stream. I am probably doing something silly that is easily fixed. Two changes to core muxy implementation. (1) Added MuxFileDirectory#sync() method. Written with same concurrency protections as WritableMuxFile#sync() (which are none) so presumed to be safe. (2) MuxyEventListener is described as optional in the Javadoc but a few places assumed it was always defined. Fixed those instances.
6a3c77d
to
463e323
Compare
Add a workaround to have the unit tests partially work. The tests pass only if each file write is followed by a sync() operation.
this is a lot to review at once, is it possible that this could be broken up into a few different sub changes? |
that aside, please move out all the inner classes, and keep fields adjacent to each other rather than spread throughout the class. |
The multithreaded unit tests are only passing if a sync() is called after every write. Uncommenting https://github.com/addthis/muxy/pull/2/files#diff-12d90acbab2efef07369c1c6f30506adR179 will fail the test. |
02618b4
to
3b817e3
Compare
Pulling out inner class Page into its own class. Performance tests are next on the TODO list.
3b817e3
to
f09881c
Compare
Copy pages to temporary streams before reading and writing to external storage. Incurs the overhead of an extra copy of the memory contents. Benefit is reduced time spend holding the lock on the external storage. In synthetic benchmarks overall performance is improved.
Also cleanup a unit test where termination condition was incorrectly specified.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thread-safe FIFO queue that uses a muxy filesystem to
write overflow elements to disk. If memory capacity is not exceeded
then all operations occur in memory. {@link #put(Object)}
requests are designed to return quickly and write to disk
asynchronously if one or more background threads have been configured.
All requests of the {@link DiskBackedQueueInternals#get(long, TimeUnit)}
family perform synchronous reads from the disk. A {@link #close()}
will write the contents of the queue to the muxy filesystem.
Nearly all parameter are required to the Builder object.
This is a deliberate design decision to discourage a reliance of magical
default values that lead to behavior surprises for your application.
Single threaded unit tests are passing. Multithreaded test is failing
on IOException for uninitialized muxy stream. I am probably doing something
silly that is easily fixed.
Two changes to core muxy implementation. (1) Added MuxFileDirectory#sync()
method. Written with same concurrency protections as WritableMuxFile#sync()
(which are none) so presumed to be safe. (2) MuxyEventListener is described
as optional in the Javadoc but a few places assumed it was always defined.
Fixed those instances.