Package jetbrains.buildServer.agent.impl
Class AgentLogProxyImpl
- java.lang.Object
-
- jetbrains.buildServer.agent.impl.AgentLogProxyImpl
-
- All Implemented Interfaces:
AgentLogProxy
public class AgentLogProxyImpl extends Object implements AgentLogProxy
- Author:
- Kir This class collects messages obtained from executed build and translates them to the BuildServer. If server is not available, messages are cached. When server becomes available, messages are sent to it.
-
-
Field Summary
Fields Modifier and Type Field Description static StringAGENT_RETRY_FAILED_COMMANDS_DURATIONstatic longDEFAULT_RETRY_DURATIONstatic StringLOG_MESSAGES_ACTION_MAX_MESSAGESstatic StringLOG_MESSAGES_ACTION_MAX_SIZE_BYTES
-
Constructor Summary
Constructors Constructor Description AgentLogProxyImpl(BuildAgentEx agent, long retryPeriodMSecs, PersistedMessagesLoader persistedMessagesLoader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanbuildDetachedFromAgent(String buildId, String stepId)Indicates that the build tasks are finished on the agent but the build itself should continue until some external process finishes itbooleanbuildFinished(String buildId, Date finishDate, boolean buildFailed)booleanbuildInterrupted(String buildId, String comment, boolean needRequeue)voiddispose()Stop agent log proxy, after invocation no other messages will be sent to the servervoidflush()Synchronously send queued messages to the server, if possibleintgetBuildMessageSequence()Returns the current build message sequence number.FilegetDirectoryForPersistedMessages()booleanhasConnection2Server()booleanhasPendingBuildFinishedCommand()Returns true if buildFinished command is waiting to be sent to the serverbooleanhasPendingCommands()booleanisBuildFailing(String buildId)Checks for build status on the build server.voidkillAllPendingAndIgnore(String buildId)Cleanup queue of messages which should be sent to the server.booleanlogMessages(String buildId, List<BuildMessage1> messages)voidonBuildStart(String buildId)Notifies proxy that another build was startedvoidrunRemote(String buildId, RemoteAction action)Run remote action, which can be queued for later execution if server is not accessiblevoidrunRemoteAndWait(String buildId, RemoteAction action)Runs remote action and waits till it is executed.voidsetBuildMessageSequence(int buildMessageSequence)Setter for the build message sequence number.voidsetTimeService(TimeService timeService)voidwakeUpFlush()Wakes up flush thread if it is waiting to send messages to server
-
-
-
Field Detail
-
AGENT_RETRY_FAILED_COMMANDS_DURATION
public static final String AGENT_RETRY_FAILED_COMMANDS_DURATION
- See Also:
- Constant Field Values
-
DEFAULT_RETRY_DURATION
public static final long DEFAULT_RETRY_DURATION
-
LOG_MESSAGES_ACTION_MAX_SIZE_BYTES
public static final String LOG_MESSAGES_ACTION_MAX_SIZE_BYTES
- See Also:
- Constant Field Values
-
LOG_MESSAGES_ACTION_MAX_MESSAGES
public static final String LOG_MESSAGES_ACTION_MAX_MESSAGES
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AgentLogProxyImpl
public AgentLogProxyImpl(@NotNull BuildAgentEx agent, long retryPeriodMSecs, @NotNull PersistedMessagesLoader persistedMessagesLoader)
-
-
Method Detail
-
setTimeService
public void setTimeService(TimeService timeService)
-
onBuildStart
public void onBuildStart(String buildId)
Description copied from interface:AgentLogProxyNotifies proxy that another build was started- Specified by:
onBuildStartin interfaceAgentLogProxy
-
dispose
public void dispose()
Description copied from interface:AgentLogProxyStop agent log proxy, after invocation no other messages will be sent to the server- Specified by:
disposein interfaceAgentLogProxy
-
buildInterrupted
public boolean buildInterrupted(@NotNull String buildId, @NotNull String comment, boolean needRequeue)- Specified by:
buildInterruptedin interfaceAgentLogProxycomment- a comment to interrupt the build withneedRequeue- if true, build should be re-added to the build queue- Returns:
- fake value, to conform XML-RPC requirements
-
isBuildFailing
public boolean isBuildFailing(String buildId) throws InterruptedException
Description copied from interface:AgentLogProxyChecks for build status on the build server. The call is synchronous, it makes sure that previous logged messages are sent to the server.- Specified by:
isBuildFailingin interfaceAgentLogProxy- Returns:
- true if build status on the server is failing
- Throws:
InterruptedException- if action was removed from the queue for some reason, and could not be completed (for instance, build is obsolete)
-
buildFinished
public boolean buildFinished(@NotNull String buildId, Date finishDate, boolean buildFailed)- Specified by:
buildFinishedin interfaceAgentLogProxy- Returns:
- fake value, to conform XML-RPC requirements
-
buildDetachedFromAgent
public boolean buildDetachedFromAgent(String buildId, String stepId)
Description copied from interface:AgentLogProxyIndicates that the build tasks are finished on the agent but the build itself should continue until some external process finishes it- Specified by:
buildDetachedFromAgentin interfaceAgentLogProxy
-
runRemote
public void runRemote(@NotNull String buildId, @NotNull RemoteAction action)Description copied from interface:AgentLogProxyRun remote action, which can be queued for later execution if server is not accessible- Specified by:
runRemotein interfaceAgentLogProxy
-
getBuildMessageSequence
public int getBuildMessageSequence()
Description copied from interface:AgentLogProxyReturns the current build message sequence number. The build message sequence number is an incrementing number attached to all log messages.- Specified by:
getBuildMessageSequencein interfaceAgentLogProxy- Returns:
- see above
-
setBuildMessageSequence
public void setBuildMessageSequence(int buildMessageSequence)
Description copied from interface:AgentLogProxySetter for the build message sequence number. The build message sequence number is an incrementing number attached to all log messages.- Specified by:
setBuildMessageSequencein interfaceAgentLogProxy- Parameters:
buildMessageSequence- the new build message sequence number
-
runRemoteAndWait
public void runRemoteAndWait(@NotNull String buildId, @NotNull RemoteAction action) throws InterruptedExceptionDescription copied from interface:AgentLogProxyRuns remote action and waits till it is executed.- Specified by:
runRemoteAndWaitin interfaceAgentLogProxy- Parameters:
buildId- build idaction- action to execute- Throws:
InterruptedException- if action was removed from the queue for some reason
-
getDirectoryForPersistedMessages
@NotNull public File getDirectoryForPersistedMessages()
-
logMessages
public boolean logMessages(String buildId, List<BuildMessage1> messages)
- Specified by:
logMessagesin interfaceAgentLogProxy
-
killAllPendingAndIgnore
public void killAllPendingAndIgnore(@Nullable String buildId)Description copied from interface:AgentLogProxyCleanup queue of messages which should be sent to the server.- Specified by:
killAllPendingAndIgnorein interfaceAgentLogProxy- Parameters:
buildId- this buildId will be placed to stop list and other messages won't be accepted for this build
-
hasPendingCommands
public boolean hasPendingCommands()
- Specified by:
hasPendingCommandsin interfaceAgentLogProxy- Returns:
- true if there are unsent messages to the server
-
hasPendingBuildFinishedCommand
public boolean hasPendingBuildFinishedCommand()
Description copied from interface:AgentLogProxyReturns true if buildFinished command is waiting to be sent to the server- Specified by:
hasPendingBuildFinishedCommandin interfaceAgentLogProxy- Returns:
- true if buildFinished command is pending
-
hasConnection2Server
public boolean hasConnection2Server()
- Specified by:
hasConnection2Serverin interfaceAgentLogProxy- Returns:
- true if build agent thinks that there is a valid connection to TeamCity server
-
wakeUpFlush
public void wakeUpFlush()
Description copied from interface:AgentLogProxyWakes up flush thread if it is waiting to send messages to server- Specified by:
wakeUpFlushin interfaceAgentLogProxy
-
flush
public void flush()
Description copied from interface:AgentLogProxySynchronously send queued messages to the server, if possible- Specified by:
flushin interfaceAgentLogProxy
-
-