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 String
AGENT_RETRY_FAILED_COMMANDS_DURATION
static long
DEFAULT_RETRY_DURATION
static String
LOG_MESSAGES_ACTION_MAX_MESSAGES
static String
LOG_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 boolean
buildDetachedFromAgent(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 itboolean
buildFinished(String buildId, Date finishDate, boolean buildFailed)
boolean
buildInterrupted(String buildId, String comment, boolean needRequeue)
void
dispose()
Stop agent log proxy, after invocation no other messages will be sent to the servervoid
flush()
Synchronously send queued messages to the server, if possibleint
getBuildMessageSequence()
Returns the current build message sequence number.File
getDirectoryForPersistedMessages()
boolean
hasConnection2Server()
boolean
hasPendingBuildFinishedCommand()
Returns true if buildFinished command is waiting to be sent to the serverboolean
hasPendingCommands()
boolean
isBuildFailing(String buildId)
Checks for build status on the build server.void
killAllPendingAndIgnore(String buildId)
Cleanup queue of messages which should be sent to the server.boolean
logMessages(String buildId, List<BuildMessage1> messages)
void
onBuildStart(String buildId)
Notifies proxy that another build was startedvoid
runRemote(String buildId, RemoteAction action)
Run remote action, which can be queued for later execution if server is not accessiblevoid
runRemoteAndWait(String buildId, RemoteAction action)
Runs remote action and waits till it is executed.void
setBuildMessageSequence(int buildMessageSequence)
Setter for the build message sequence number.void
setTimeService(TimeService timeService)
void
wakeUpFlush()
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:AgentLogProxy
Notifies proxy that another build was started- Specified by:
onBuildStart
in interfaceAgentLogProxy
-
dispose
public void dispose()
Description copied from interface:AgentLogProxy
Stop agent log proxy, after invocation no other messages will be sent to the server- Specified by:
dispose
in interfaceAgentLogProxy
-
buildInterrupted
public boolean buildInterrupted(@NotNull String buildId, @NotNull String comment, boolean needRequeue)
- Specified by:
buildInterrupted
in interfaceAgentLogProxy
comment
- 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:AgentLogProxy
Checks 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:
isBuildFailing
in 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:
buildFinished
in interfaceAgentLogProxy
- Returns:
- fake value, to conform XML-RPC requirements
-
buildDetachedFromAgent
public boolean buildDetachedFromAgent(String buildId, String stepId)
Description copied from interface:AgentLogProxy
Indicates that the build tasks are finished on the agent but the build itself should continue until some external process finishes it- Specified by:
buildDetachedFromAgent
in interfaceAgentLogProxy
-
runRemote
public void runRemote(@NotNull String buildId, @NotNull RemoteAction action)
Description copied from interface:AgentLogProxy
Run remote action, which can be queued for later execution if server is not accessible- Specified by:
runRemote
in interfaceAgentLogProxy
-
getBuildMessageSequence
public int getBuildMessageSequence()
Description copied from interface:AgentLogProxy
Returns the current build message sequence number. The build message sequence number is an incrementing number attached to all log messages.- Specified by:
getBuildMessageSequence
in interfaceAgentLogProxy
- Returns:
- see above
-
setBuildMessageSequence
public void setBuildMessageSequence(int buildMessageSequence)
Description copied from interface:AgentLogProxy
Setter for the build message sequence number. The build message sequence number is an incrementing number attached to all log messages.- Specified by:
setBuildMessageSequence
in interfaceAgentLogProxy
- Parameters:
buildMessageSequence
- the new build message sequence number
-
runRemoteAndWait
public void runRemoteAndWait(@NotNull String buildId, @NotNull RemoteAction action) throws InterruptedException
Description copied from interface:AgentLogProxy
Runs remote action and waits till it is executed.- Specified by:
runRemoteAndWait
in 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:
logMessages
in interfaceAgentLogProxy
-
killAllPendingAndIgnore
public void killAllPendingAndIgnore(@Nullable String buildId)
Description copied from interface:AgentLogProxy
Cleanup queue of messages which should be sent to the server.- Specified by:
killAllPendingAndIgnore
in 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:
hasPendingCommands
in interfaceAgentLogProxy
- Returns:
- true if there are unsent messages to the server
-
hasPendingBuildFinishedCommand
public boolean hasPendingBuildFinishedCommand()
Description copied from interface:AgentLogProxy
Returns true if buildFinished command is waiting to be sent to the server- Specified by:
hasPendingBuildFinishedCommand
in interfaceAgentLogProxy
- Returns:
- true if buildFinished command is pending
-
hasConnection2Server
public boolean hasConnection2Server()
- Specified by:
hasConnection2Server
in interfaceAgentLogProxy
- Returns:
- true if build agent thinks that there is a valid connection to TeamCity server
-
wakeUpFlush
public void wakeUpFlush()
Description copied from interface:AgentLogProxy
Wakes up flush thread if it is waiting to send messages to server- Specified by:
wakeUpFlush
in interfaceAgentLogProxy
-
flush
public void flush()
Description copied from interface:AgentLogProxy
Synchronously send queued messages to the server, if possible- Specified by:
flush
in interfaceAgentLogProxy
-
-