Class TapePerNodeLocalQueue
java.lang.Object
com.atlassian.bamboo.cluster.tape.TapePerNodeLocalQueue
- All Implemented Interfaces:
PerNodeLocalQueue
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.atlassian.bamboo.cluster.tape.PerNodeLocalQueue
PerNodeLocalQueue.QueueId -
Field Summary
Fields inherited from interface com.atlassian.bamboo.cluster.tape.PerNodeLocalQueue
NUMBER_OF_PHYSICAL_QUEUES_PER_NODE -
Constructor Summary
ConstructorsConstructorDescriptionTapePerNodeLocalQueue(File localDirectoryForQueues, BambooNodeInfo node, int nodeQueueNumber, Supplier<com.squareup.tape.FileObjectQueue.Converter<CrossNodesEvent>> tapePerNodeLocalQueueConverterSupplier, int maxQueueSize, int maxQueueUsedBytes) -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(CrossNodesEvent data) transactional add ofCrossNodesEventto the queue; when operation finished we "guarantee" that theCrossNodesEventis persistedvoidbackupQueue(String prefix) Note: use with caution This method is mainly designed to handle critical state of the queue storage by backing up the current queue persistent store and recreating a new one.voidclose()closes the queue and all resources connected with this queue (like processing thread(s), files); closing a queue is definitive - it will never be open (i.e.static TapePerNodeLocalQueuecreate(File localDirectoryForQueues, BambooNodeInfo node, int nodeQueueNumber) booleaninthashCode()boolean@NotNull PerNodeLocalQueue.QueueIdid()booleanisClosed()Some operations (likePerNodeLocalQueue.add(CrossNodesEvent)) on a closed queue will throw aIllegalStateException.@NotNull Stringname()protected voidonDrop()@Nullable CrossNodesEventpeek()Allows to see what's on the head of the queue without removing it.voidremove()RemoveCrossNodesEventfrom head of the queue.intsize()@Nullable Long
-
Constructor Details
-
TapePerNodeLocalQueue
public TapePerNodeLocalQueue(File localDirectoryForQueues, BambooNodeInfo node, int nodeQueueNumber, Supplier<com.squareup.tape.FileObjectQueue.Converter<CrossNodesEvent>> tapePerNodeLocalQueueConverterSupplier, int maxQueueSize, int maxQueueUsedBytes) throws IOException - Throws:
IOException
-
-
Method Details
-
close
public void close()Description copied from interface:PerNodeLocalQueuecloses the queue and all resources connected with this queue (like processing thread(s), files); closing a queue is definitive - it will never be open (i.e. not-closed) again;- Specified by:
closein interfacePerNodeLocalQueue
-
isClosed
public boolean isClosed()Description copied from interface:PerNodeLocalQueueSome operations (likePerNodeLocalQueue.add(CrossNodesEvent)) on a closed queue will throw aIllegalStateException. This method allows to check if the queue has not been closed.- Specified by:
isClosedin interfacePerNodeLocalQueue- Returns:
- true if queue is closed
-
name
- Specified by:
namein interfacePerNodeLocalQueue- Returns:
- name of the queue could be useful for the user, like identifying the queue file path from logs
-
id
- Specified by:
idin interfacePerNodeLocalQueue- Returns:
- queue id which uniquely identifies this queue, i.e destination node and nodeQueueNumber, see
PerNodeLocalQueue.QueueId
-
add
Description copied from interface:PerNodeLocalQueuetransactional add ofCrossNodesEventto the queue; when operation finished we "guarantee" that theCrossNodesEventis persisted- Specified by:
addin interfacePerNodeLocalQueue- Returns:
- true if message was added or false if dropped (like exceeding queue size limit)
- Throws:
IllegalStateException- when queue is closed
-
peek
Description copied from interface:PerNodeLocalQueueAllows to see what's on the head of the queue without removing it.- Specified by:
peekin interfacePerNodeLocalQueue- Returns:
- crossNodesEvent from queue head or null when queue is empty.
- Throws:
IllegalStateException- when queue is closed
-
remove
Description copied from interface:PerNodeLocalQueueRemoveCrossNodesEventfrom head of the queue.- Specified by:
removein interfacePerNodeLocalQueue- Throws:
NoSuchElementException- when doing a remove on an empty queueIllegalStateException- when queue is closed
-
getQueueFilePath
- Specified by:
getQueueFilePathin interfacePerNodeLocalQueue- Returns:
- the queue file path if exists, empty otherwise
-
hasPermission
public boolean hasPermission()- Specified by:
hasPermissionin interfacePerNodeLocalQueue- Returns:
- true if it has read/write access to queue storage
-
usableSpaceInBytes
- Specified by:
usableSpaceInBytesin interfacePerNodeLocalQueue- Returns:
- number of bytes left on device where this queue is stored or null if unable to get this value
-
size
public int size()- Specified by:
sizein interfacePerNodeLocalQueue- Returns:
- number of elements in this queue
-
backupQueue
Description copied from interface:PerNodeLocalQueueNote: use with caution This method is mainly designed to handle critical state of the queue storage by backing up the current queue persistent store and recreating a new one. Renames current queue file name to [prefix]_[queue_file_name] and re-creates queue file with [queue_file_name]. If file with [prefix]_[queue_file_name] already exists it will be deleted. Note that ifPerNodeLocalQueue.backupQueue(String)is called betweenPerNodeLocalQueue.peek()andPerNodeLocalQueue.remove()this can causePerNodeLocalQueue.remove()to delete a differentCrossNodesEventthen expected or may throwNoSuchElementExceptionif the new queue afterPerNodeLocalQueue.backupQueue(String)is empty.- Specified by:
backupQueuein interfacePerNodeLocalQueue- Throws:
IOException
-
equals
-
hashCode
public int hashCode() -
create
public static TapePerNodeLocalQueue create(File localDirectoryForQueues, BambooNodeInfo node, int nodeQueueNumber) throws IOException - Throws:
IOException
-
onDrop
protected void onDrop()
-