public class MergeSortPipe extends Object
| Constructor and Description |
|---|
MergeSortPipe(int numberOfworkers)
constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(int workerID,
ArrayList<MergeSortElement> elements)
Adds a new elements' array in the queue
|
void |
add(int workerID,
MergeSortElement element)
Adds a new element in the queue
|
boolean |
areAllQueuesNonEmpty()
checks if all the queues, of the active workers,
have at least one element
|
boolean |
canMergeSorterPause()
checks if a MergeSorter can pause and let the
workers do the processing, until there is enough
data to do merge sorting, or there are more results
than the results requested by the client, or there
is no worker left
|
boolean |
canWorkerPause(int workerID)
checks if a specific worker can sleep
|
long |
getGetUntil()
gets the sum of the results requested by the client,
until now
|
MergeSortElement |
getNext() |
long |
getResultsRetrieved()
gets the sum of the results retrieved
|
long |
getResultsSent() |
boolean |
isActive(int workerID)
returns the state of the workerID
|
boolean |
isAnyWorkerLeft()
checks if there is any worker left
|
boolean |
isStoped()
returns the stop flag
|
boolean |
sendMergerNotification()
checks if a MergeSorter must receive a notification.
|
boolean |
sendWorkersNotification()
checks if workers must receive notifications.
|
void |
setGetUntil(long getUntil)
sets the number of results requested by the client
|
void |
setInActive(int workerID)
sets the workerID worker as inactive
|
void |
setResultsRetrieved(long resultsRetrieved)
sets the resultsRetrieved
|
void |
setStop()
raises the stop flag
|
public MergeSortPipe(int numberOfworkers)
numberOfworkers - - the number of workerspublic void setInActive(int workerID)
workerID - public boolean isActive(int workerID)
workerID - public long getResultsRetrieved()
public void setResultsRetrieved(long resultsRetrieved)
resultsRetrieved - public long getResultsSent()
public long getGetUntil()
public void setGetUntil(long getUntil)
getUntil - public void add(int workerID,
ArrayList<MergeSortElement> elements)
workerID - - the ID of the owrker that adds the elementelements - - the elements to be added in the queuepublic MergeSortElement getNext()
public void add(int workerID,
MergeSortElement element)
workerID - - the ID of the owrker that adds the elementelement - - the element to be added in the queuepublic boolean areAllQueuesNonEmpty()
public boolean isAnyWorkerLeft()
public boolean canWorkerPause(int workerID)
workerID - - the ID of the workerpublic boolean canMergeSorterPause()
public boolean sendMergerNotification()
public boolean sendWorkersNotification()
public void setStop()
public boolean isStoped()
Copyright © 2014. All Rights Reserved.