|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Thread
com.sonyericsson.hudson.plugins.gerrit.gerritevents.GerritHandler
public class GerritHandler
Main class for this module. Contains the main loop for connecting and reading streamed events from Gerrit.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
Thread.State, Thread.UncaughtExceptionHandler |
| Field Summary | |
|---|---|
protected static int |
BRUTE_FORCE_TRIES
How many times to try and set the shutdown flag to true. |
static int |
CONNECT_SLEEP
Time to wait between connection attempts. |
protected static int |
PAUSE_SECOND
The amount of milliseconds to pause when brute forcing the shutdown flag to true. |
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
|---|---|
GerritHandler()
Creates a GerritHandler with all the default values set. |
|
GerritHandler(GerritConnectionConfig config)
Creates a GerritHandler with the specified values. |
|
GerritHandler(String gerritHostName,
int gerritSshPort,
Authentication authentication)
Creates a GerritHandler with the specified values and default number of worker threads. |
|
GerritHandler(String gerritHostName,
int gerritSshPort,
Authentication authentication,
int numberOfWorkerThreads)
Creates a GerritHandler with the specified values. |
|
| Method Summary | |
|---|---|
void |
addConnectionListeners(Collection<? extends ConnectionListener> listeners)
Add all ConnectionListeners to the list of listeners. |
void |
addConnectionListeners(Map<Integer,ConnectionListener> listeners)
Deprecated. |
void |
addEventListeners(Collection<? extends GerritEventListener> listeners)
Adds all the provided listeners to the internal list of listeners. |
void |
addEventListeners(Map<Integer,GerritEventListener> listeners)
Deprecated. |
boolean |
addListener(ConnectionListener listener)
Add a ConnectionListener to the list of listeners. |
void |
addListener(GerritEventListener listener)
Add a GerritEventListener to the list of listeners. |
Authentication |
getAuthentication()
The authentication credentials for ssh connection. |
int |
getEventListenersCount()
The number of added e GerritEventListeners. |
String |
getGerritHostName()
gets the hostname where Gerrit is running. |
int |
getGerritSshPort()
Gets the port for gerrit ssh commands. |
String |
getGerritVersion()
The gerrit version we are connected to. |
int |
getNumberOfWorkerThreads()
Gets the number of event worker threads. |
BlockingQueue<Work> |
getWorkQueue()
Retrieves the work queue for workers to poll. |
boolean |
isShutdownInProgress()
If the system is shutting down. |
protected void |
notifyConnectionDown()
Notifies all ConnectionListeners that the connection is down. |
protected void |
notifyConnectionEstablished()
Notifies all ConnectionListeners that the connection is established. |
void |
notifyListeners(GerritEvent event)
Notifies all listeners of a Gerrit event. |
Collection<ConnectionListener> |
removeAllConnectionListeners()
Removes all connection listeners and returns those who where removed. |
Collection<GerritEventListener> |
removeAllEventListeners()
Removes all event listeners and returns those that where removed. |
void |
removeListener(ConnectionListener listener)
Removes a ConnectionListener from the list of listeners. |
void |
removeListener(GerritEventListener listener)
Removes a GerritEventListener from the list of listeners. |
void |
run()
Main loop for connecting and reading Gerrit JSON Events and dispatching them to Workers. |
void |
setAuthentication(Authentication authentication)
The authentication credentials for ssh connection. |
void |
setGerritHostName(String gerritHostName)
Sets the hostname where Gerrit is running. |
void |
setGerritSshPort(int gerritSshPort)
Sets the port for gerrit ssh commands. |
void |
setNumberOfWorkerThreads(int numberOfWorkerThreads)
Sets the number of worker event threads. |
void |
shutdown(boolean join)
Closes the connection. |
void |
triggerEvent(GerritEvent event)
"Triggers" an event by adding it to the internal queue and be taken by one of the worker threads. |
| Methods inherited from class java.lang.Thread |
|---|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int CONNECT_SLEEP
protected static final int PAUSE_SECOND
protected static final int BRUTE_FORCE_TRIES
shutdown(boolean),
PAUSE_SECOND,
Constant Field Values| Constructor Detail |
|---|
public GerritHandler()
GerritDefaultValues.DEFAULT_GERRIT_HOSTNAME,
GerritDefaultValues.DEFAULT_GERRIT_SSH_PORT,
GerritDefaultValues.DEFAULT_GERRIT_USERNAME,
GerritDefaultValues.DEFAULT_GERRIT_AUTH_KEY_FILE,
GerritDefaultValues.DEFAULT_GERRIT_AUTH_KEY_FILE_PASSWORD,
GerritDefaultValues.DEFAULT_NR_OF_RECEIVING_WORKER_THREADS
public GerritHandler(String gerritHostName,
int gerritSshPort,
Authentication authentication)
gerritHostName - the hostNamegerritSshPort - the ssh port that the gerrit server listens to.authentication - the authentication credentials.public GerritHandler(GerritConnectionConfig config)
config - the configuration containing the connection values.
public GerritHandler(String gerritHostName,
int gerritSshPort,
Authentication authentication,
int numberOfWorkerThreads)
gerritHostName - the hostName for gerrit.gerritSshPort - the ssh port that the gerrit server listens to.authentication - the authentication credentials.numberOfWorkerThreads - the number of eventthreads.| Method Detail |
|---|
public String getGerritVersion()
public void run()
run in interface Runnablerun in class Threadpublic void addListener(GerritEventListener listener)
listener - the listener to add.@Deprecated public void addEventListeners(Map<Integer,GerritEventListener> listeners)
listeners - the listeners to add.public void addEventListeners(Collection<? extends GerritEventListener> listeners)
listeners - the listeners to add.public void removeListener(GerritEventListener listener)
listener - the listener to remove.public Collection<GerritEventListener> removeAllEventListeners()
public int getEventListenersCount()
GerritEventListeners.
public boolean addListener(ConnectionListener listener)
listener - the listener to add.
@Deprecated public void addConnectionListeners(Map<Integer,ConnectionListener> listeners)
listeners - the listener.public void addConnectionListeners(Collection<? extends ConnectionListener> listeners)
listeners - the listeners to add.public void removeListener(ConnectionListener listener)
listener - the listener to remove.public Collection<ConnectionListener> removeAllConnectionListeners()
public Authentication getAuthentication()
public void setAuthentication(Authentication authentication)
authentication - the credentials.public String getGerritHostName()
public void setGerritHostName(String gerritHostName)
gerritHostName - the hostname.public int getGerritSshPort()
public void setGerritSshPort(int gerritSshPort)
gerritSshPort - the port nr.public int getNumberOfWorkerThreads()
public void setNumberOfWorkerThreads(int numberOfWorkerThreads)
numberOfWorkerThreads - the number of threadspublic BlockingQueue<Work> getWorkQueue()
Coordinator
getWorkQueue in interface Coordinatorpublic void notifyListeners(GerritEvent event)
EventThread and not on this Thread which would
defeat the purpose of having workers.
notifyListeners in interface Coordinatorevent - the event.public boolean isShutdownInProgress()
public void shutdown(boolean join)
join - if the method should wait for the thread to finish before returning.protected void notifyConnectionDown()
protected void notifyConnectionEstablished()
public void triggerEvent(GerritEvent event)
event - the event to trigger.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||