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

Fixed Initial Size #6

Open
rai-lo opened this issue Jun 24, 2020 · 1 comment
Open

Fixed Initial Size #6

rai-lo opened this issue Jun 24, 2020 · 1 comment

Comments

@rai-lo
Copy link

rai-lo commented Jun 24, 2020

We would like to use FileQueue as an emergency storage, if the database connection is not available.
Therefor it would be great if it is possible to reserve a fix number of blocks initially on the disk when creating the storage file.
This parameter (number of blocks) should be part of the builder.
Thanks
Rainer

@jamieb22
Copy link
Collaborator

jamieb22 commented Jun 24, 2020

Are you referring to .maxQueueSize()? If so, it is already implemented. Please take a look at the queueItem method outlined below. When calling queueItem, it will block for specified time frame or until a slot becomes available in the queue. As soon as slot becomes available, FileQueue will call availableSlot. Use your availableSlot method to write your storage file to disk. Then when queue consume() is called by FileQueue, use the ID stored in your FileQueueItem to load the cached storage file from disk, perform processing, then delete the cached file.

public void queueItem(T fileQueueItem,
QueueCallback queueCallback,
int acquireWait,
TimeUnit acquireWaitUnit)
throws Exception
Queue item for delivery. Wait for an open slot for a specified time period. Calls availableSlot when slot becomes available, immediately before queuing

interface QueueCallback
void availableSlot(T fileQueueItem)
throws Exception
Called when a slot is available in the queue for processing.

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

No branches or pull requests

2 participants