Class TapePerNodeLocalQueueWithStats
- java.lang.Object
-
- com.atlassian.bamboo.cluster.tape.TapePerNodeLocalQueueWithStats
-
- All Implemented Interfaces:
PerNodeLocalQueue
public class TapePerNodeLocalQueueWithStats extends Object implements PerNodeLocalQueue
Statistics for the delegatePerNodeLocalQueueManager
. ContainsstatsTotal
with statistics for queue since "the beginning" andstatsSnapshot
with statistics for queue since laststatsSnapshot()
call.See:
statsTotal()
andstatsSnapshot()
- Since:
- 9.5
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TapePerNodeLocalQueueWithStats.QueueStats
-
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
Constructors Constructor Description TapePerNodeLocalQueueWithStats(PerNodeLocalQueue delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(CrossNodesEvent data)
transactional add ofCrossNodesEvent
to the queue; when operation finished we "guarantee" that theCrossNodesEvent
is persistedvoid
backupQueue(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.void
close()
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.boolean
equals(Object o)
@NotNull Optional<Path>
getQueueFilePath()
int
hashCode()
boolean
hasPermission()
@NotNull PerNodeLocalQueue.QueueId
id()
boolean
isClosed()
Some operations (likePerNodeLocalQueue.add(CrossNodesEvent)
) on a closed queue will throw aIllegalStateException
.@NotNull String
name()
void
notifyCriticalAdd()
void
notifyCriticalPeek()
void
notifyCriticalRemove()
void
notifyDroppedOnSend()
void
notifySendFailureException()
void
notifySendUnavailableException()
void
notifySendWithTime(long timeInMillis)
CrossNodesEvent
peek()
Allows to see what's on the head of the queue without removing it.void
remove()
RemoveCrossNodesEvent
from head of the queue.int
size()
Long
usableSpaceInBytes()
-
-
-
Constructor Detail
-
TapePerNodeLocalQueueWithStats
public TapePerNodeLocalQueueWithStats(PerNodeLocalQueue delegate)
-
-
Method Detail
-
close
public void close()
Description copied from interface:PerNodeLocalQueue
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. not-closed) again;- Specified by:
close
in interfacePerNodeLocalQueue
-
isClosed
public boolean isClosed()
Description copied from interface:PerNodeLocalQueue
Some 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:
isClosed
in interfacePerNodeLocalQueue
- Returns:
- true if queue is closed
-
name
@NotNull public @NotNull String name()
- Specified by:
name
in interfacePerNodeLocalQueue
- Returns:
- name of the queue could be useful for the user, like identifying the queue file path from logs
-
id
@NotNull public @NotNull PerNodeLocalQueue.QueueId id()
- Specified by:
id
in interfacePerNodeLocalQueue
- Returns:
- queue id which uniquely identifies this queue, i.e destination node and nodeQueueNumber, see
PerNodeLocalQueue.QueueId
-
add
public boolean add(CrossNodesEvent data) throws IllegalStateException
Description copied from interface:PerNodeLocalQueue
transactional add ofCrossNodesEvent
to the queue; when operation finished we "guarantee" that theCrossNodesEvent
is persisted- Specified by:
add
in interfacePerNodeLocalQueue
- Returns:
- true if message was added or false if dropped (like exceeding queue size limit)
- Throws:
IllegalStateException
- when queue is closed
-
peek
@Nullable public CrossNodesEvent peek() throws IllegalStateException
Description copied from interface:PerNodeLocalQueue
Allows to see what's on the head of the queue without removing it.- Specified by:
peek
in interfacePerNodeLocalQueue
- Returns:
- crossNodesEvent from queue head or null when queue is empty.
- Throws:
IllegalStateException
- when queue is closed
-
remove
public void remove() throws NoSuchElementException, IllegalStateException
Description copied from interface:PerNodeLocalQueue
RemoveCrossNodesEvent
from head of the queue.- Specified by:
remove
in interfacePerNodeLocalQueue
- Throws:
NoSuchElementException
- when doing a remove on an empty queueIllegalStateException
- when queue is closed
-
size
public int size()
- Specified by:
size
in interfacePerNodeLocalQueue
- Returns:
- number of elements in this queue
-
backupQueue
public void backupQueue(String prefix) throws IOException
Description copied from interface:PerNodeLocalQueue
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. 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 differentCrossNodesEvent
then expected or may throwNoSuchElementException
if the new queue afterPerNodeLocalQueue.backupQueue(String)
is empty.- Specified by:
backupQueue
in interfacePerNodeLocalQueue
- Throws:
IOException
-
notifySendWithTime
public void notifySendWithTime(long timeInMillis)
-
notifyDroppedOnSend
public void notifyDroppedOnSend()
-
notifySendFailureException
public void notifySendFailureException()
-
notifySendUnavailableException
public void notifySendUnavailableException()
-
notifyCriticalAdd
public void notifyCriticalAdd()
-
notifyCriticalPeek
public void notifyCriticalPeek()
-
notifyCriticalRemove
public void notifyCriticalRemove()
-
usableSpaceInBytes
@Nullable public Long usableSpaceInBytes()
- Specified by:
usableSpaceInBytes
in interfacePerNodeLocalQueue
- Returns:
- number of bytes left on device where this queue is stored or null if unable to get this value
-
hasPermission
public boolean hasPermission()
- Specified by:
hasPermission
in interfacePerNodeLocalQueue
- Returns:
- true if it has read/write access to queue storage
-
getQueueFilePath
@NotNull public @NotNull Optional<Path> getQueueFilePath()
- Specified by:
getQueueFilePath
in interfacePerNodeLocalQueue
- Returns:
- the queue file path if exists, empty otherwise
-
-