Class ServerBuildLog

    • Field Detail

      • USE_FLOW_AWARE_INDEX_INTERNAL_PROPERTY

        public static final String USE_FLOW_AWARE_INDEX_INTERNAL_PROPERTY
        See Also:
        Constant Field Values
      • MESSAGES_ANCHORS_ENABLED_INTERNAL_PROPERTY

        public static final String MESSAGES_ANCHORS_ENABLED_INTERNAL_PROPERTY
        See Also:
        Constant Field Values
      • FLUSH_ON_UNRESOLVED_ANCHORS_INTERNAL_PROPERTY

        public static final String FLUSH_ON_UNRESOLVED_ANCHORS_INTERNAL_PROPERTY
        See Also:
        Constant Field Values
      • CREATE_FLOW_AWARE_INDEX_ON_LOG_CLOSE_INTERNAL_PROPERTY

        public static final String CREATE_FLOW_AWARE_INDEX_ON_LOG_CLOSE_INTERNAL_PROPERTY
        See Also:
        Constant Field Values
      • RETURN_FAKE_MESSAGE_FOR_CLOSED_STATE_PROPERTY

        public static final String RETURN_FAKE_MESSAGE_FOR_CLOSED_STATE_PROPERTY
        See Also:
        Constant Field Values
      • ANCHORS_RESERVATION_RANGE_SIZE_PROPERTY

        public static final String ANCHORS_RESERVATION_RANGE_SIZE_PROPERTY
        See Also:
        Constant Field Values
      • ANCHORS_RESERVATION_RANGE_SIZE_INITIAL_PROPERTY

        public static final String ANCHORS_RESERVATION_RANGE_SIZE_INITIAL_PROPERTY
        See Also:
        Constant Field Values
    • Method Detail

      • openBlock

        @NotNull
        public BlockLogMessage openBlock​(@NotNull
                                         String blockName,
                                         @NotNull
                                         String blockType,
                                         @Nullable
                                         Date timestamp,
                                         @Nullable
                                         String renderingHint,
                                         @Nullable
                                         String flowId,
                                         @Nullable
                                         Collection<String> tags)
        Description copied from interface: MessagesState
        Opens new block.
        Specified by:
        openBlock in interface MessagesState
        Parameters:
        blockName - name of the block
        blockType - type of the block
        timestamp - timestamp
        renderingHint - hint for rendering this block
        flowId - block flow identifier
        tags - block tags which may be used to pass additional data
        Returns:
        block message
      • openBlock

        @NotNull
        public BlockLogMessage openBlock​(@NotNull
                                         String blockName,
                                         @NotNull
                                         String blockType,
                                         @NotNull
                                         MessageAttrs attrs)
        Description copied from interface: MessagesState
        Opens new block.
        Specified by:
        openBlock in interface MessagesState
        Parameters:
        blockName - name of the block
        blockType - type of the block
        attrs - message attributes
        Returns:
        block message
      • openBlockAsync

        public void openBlockAsync​(@NotNull
                                   String blockName,
                                   @NotNull
                                   String blockType,
                                   @NotNull
                                   MessageAttrs attrs)
        Description copied from interface: MessagesState
        Logs an open block message to the build log. The method does not write to the build log immediately, instead it puts the message into a buffer which will be flushed later.
        Specified by:
        openBlockAsync in interface MessagesState
        Parameters:
        blockName - name of the block
        blockType - type of the block
        attrs - message attributes
      • openBlockAsync

        public void openBlockAsync​(@NotNull
                                   String blockName,
                                   @NotNull
                                   String blockType,
                                   @NotNull
                                   MessageAttrs attrs,
                                   @NotNull
                                   Consumer<Integer> anchorConsumer)
        Description copied from interface: MessagesState
        Logs an open block message to the build log. The method does not write to the build log immediately, instead it puts the message into a buffer which will be flushed later.
        Specified by:
        openBlockAsync in interface MessagesState
        Parameters:
        blockName - name of the block
        blockType - type of the block
        attrs - message attributes
        anchorConsumer - a consumer that is populated by message id that can later be used to access the message
      • closeBlock

        @Nullable
        public BlockLogMessage closeBlock​(@NotNull
                                          String blockName,
                                          @NotNull
                                          String blockType,
                                          @NotNull
                                          Date timestamp,
                                          @NotNull
                                          String flowId)
        Description copied from interface: MessagesState
        Closes last opened block with specified name and type and returns it.
        Specified by:
        closeBlock in interface MessagesState
        Parameters:
        blockName - name of the block to close
        blockType - type of the block to close
        timestamp - finish date
        flowId - block flow identifier
      • closeBlockAsync

        public void closeBlockAsync​(@NotNull
                                    String blockName,
                                    @NotNull
                                    String blockType,
                                    @NotNull
                                    Date timestamp,
                                    @NotNull
                                    String flowId)
        Description copied from interface: MessagesState
        Marks an open block message as closed in the build log. The method does not write to the build log immediately, instead it puts the message into a buffer which will be flushed later.
        Specified by:
        closeBlockAsync in interface MessagesState
        Parameters:
        blockName - name of the block to close
        blockType - type of the block to close
        timestamp - finish date
        flowId - block flow identifier
      • closeBlockAsync

        public void closeBlockAsync​(@NotNull
                                    String blockName,
                                    @NotNull
                                    String blockType,
                                    @NotNull
                                    Date timestamp,
                                    @NotNull
                                    String flowId,
                                    @NotNull
                                    Consumer<BlockLogMessage> openBlockConsumer)
        Description copied from interface: BuildLogWriterEx
        Marks an open block message as closed in the build log. The method does not write to the build log immediately, instead it puts the message into a buffer which will be flushed later. But any messages that are in the buffer when this method is called are going to be flushed so that corresponding open bLock could be correctly determined.
        Specified by:
        closeBlockAsync in interface BuildLogWriterEx
        Parameters:
        blockName - name of the block to close
        blockType - type of the block to close
        timestamp - finish date
        flowId - block flow identifier
        openBlockConsumer - a consumer that is populated by an open block that was closed.
      • message

        @NotNull
        public LogMessage message​(@Nullable
                                  String text,
                                  @Nullable
                                  Status status,
                                  @Nullable
                                  Date timestamp,
                                  @Nullable
                                  String renderingHint,
                                  @Nullable
                                  String flowId,
                                  @Nullable
                                  Collection<String> tags)
        Description copied from interface: MessagesState
        Adds message and returns it
        Specified by:
        message in interface MessagesState
        Parameters:
        text - message text
        status - message status
        timestamp - timestamp
        renderingHint - hint for rendering this message
        flowId - message flow identifier
        tags - message tags which may be used to pass additional data
        Returns:
        message
      • message

        @NotNull
        public LogMessage message​(@Nullable
                                  String text,
                                  @Nullable
                                  Status status,
                                  @NotNull
                                  MessageAttrs attrs)
        Description copied from interface: MessagesState
        Adds message and returns it
        Specified by:
        message in interface MessagesState
        Parameters:
        text - message text
        status - message status
        attrs - message attributes
        Returns:
        message
      • messageAsync

        public void messageAsync​(@Nullable
                                 String text,
                                 @Nullable
                                 Status status,
                                 @NotNull
                                 MessageAttrs attrs)
        Description copied from interface: MessagesState
        Logs a message to the build log. The method does not write to the build log immediately, instead it puts the message into a buffer which will be flushed later.
        Specified by:
        messageAsync in interface MessagesState
        Parameters:
        text - message text
        status - message status
        attrs - message attributes
      • messageAsync

        public void messageAsync​(@Nullable
                                 String text,
                                 @Nullable
                                 Status status,
                                 @NotNull
                                 MessageAttrs attrs,
                                 @NotNull
                                 Consumer<Integer> anchorConsumer)
        Description copied from interface: MessagesState
        Logs a message to the build log. The method does not write to the build log immediately, instead it puts the message into a buffer which will be flushed later.
        Specified by:
        messageAsync in interface MessagesState
        Parameters:
        text - message text
        status - message status
        attrs - message attributes
        anchorConsumer - a consumer that is populated by message id that can later be used to access the message
      • error

        @NotNull
        public LogMessage error​(@Nullable
                                String type,
                                @Nullable
                                String message,
                                @Nullable
                                Date timestamp,
                                @Nullable
                                String renderingHint,
                                @Nullable
                                String flowId,
                                @Nullable
                                Collection<String> tags)
        Description copied from interface: MessagesState
        Creates and returns a new log message, which reports about an error.
        Specified by:
        error in interface MessagesState
        Parameters:
        type - the error type
        message - the error message
        timestamp - timestamp
        renderingHint - rendering hint
        flowId - message flow identifier
        tags - message tags which may be used to pass additional data
        Returns:
        corresponding log message
      • getLastBlockMessage

        @Nullable
        public BlockLogMessage getLastBlockMessage​(@NotNull
                                                   String flowId)
        Description copied from interface: MessagesState
        Returns last block message inside specified flow
        Specified by:
        getLastBlockMessage in interface MessagesState
        Parameters:
        flowId - flow id
        Returns:
        last opened block or null if no such flow or no blocks are open
      • openProgressBlockAsync

        public void openProgressBlockAsync​(@NotNull
                                           String blockName,
                                           @NotNull
                                           MessageAttrs attrs)
        Description copied from interface: MessagesState
        Logs an open progress block message to the build log. The method does not write to the build log immediately, instead it puts the message into a buffer which will be flushed later.
        Specified by:
        openProgressBlockAsync in interface MessagesState
        Parameters:
        blockName - progress block name
        attrs - progress block attributes
      • closeProgressBlock

        @Nullable
        public BlockLogMessage closeProgressBlock​(@NotNull
                                                  Date timestamp,
                                                  @NotNull
                                                  String flowId)
        Description copied from interface: MessagesState
        Closes last progress block and returns it.
        Specified by:
        closeProgressBlock in interface MessagesState
        Parameters:
        timestamp - finish date
        flowId - flow id
        Returns:
        closed progress block or null
      • closeProgressBlockAsync

        public void closeProgressBlockAsync​(@NotNull
                                            Date timestamp,
                                            @NotNull
                                            String flowId)
        Description copied from interface: MessagesState
        Marks an open progress block message as closed in the build log. The method does not write to the build log immediately, instead it puts the message into a buffer which will be flushed later.
        Specified by:
        closeProgressBlockAsync in interface MessagesState
        Parameters:
        timestamp - finish date
        flowId - block flow identifier
      • progressMessageAsync

        public void progressMessageAsync​(@NotNull
                                         String message,
                                         @NotNull
                                         MessageAttrs attrs)
        Description copied from interface: MessagesState
        Logs a progress message to the build log. The method does not write to the build log immediately, instead it puts the message into a buffer which will be flushed later.
        Specified by:
        progressMessageAsync in interface MessagesState
        Parameters:
        message - progress message text (empty parameter will be perceived as "drop progress text command" - current progress text for specified flow will be cleared)
        attrs - progress message attributes
      • dropProgressText

        public void dropProgressText​(@NotNull
                                     String flowId)
        Description copied from interface: MessagesState
        Drops current progress text.
        Specified by:
        dropProgressText in interface MessagesState
        Parameters:
        flowId - flow id
      • getCurrentProgressText

        @Nullable
        public String getCurrentProgressText()
        Specified by:
        getCurrentProgressText in interface MessagesState
        Returns:
        current progress text, i.e. text defined via progress messages; returns null if there is no progress text defined
      • getSizeEstimate

        @NotNull
        public String getSizeEstimate()
        Description copied from interface: BuildLog
        Returns a human-readable string containing approx. build log size.
        Specified by:
        getSizeEstimate in interface BuildLog
        Returns:
        approx. build log size as string
      • getSizeEstimateAsLong

        public long getSizeEstimateAsLong()
        Description copied from interface: BuildLog
        Returns an approx. build log size.
        Specified by:
        getSizeEstimateAsLong in interface BuildLog
        Returns:
        approx. build log size as long
      • getMainLogFile

        @NotNull
        public File getMainLogFile()
        Description copied from interface: BuildLog
        Primary log file which contains messages of the log. This file MUST NOT be used to read or write messages, but only as a reference on where the log is stored. The build log also may have one or more index files, stored nearby this messages log file.
        Specified by:
        getMainLogFile in interface BuildLog
      • getBuildLogId

        @NotNull
        public String getBuildLogId()
        Description copied from interface: BuildLogEx
        The unique id of the build log that allows to find the build log in the storage. For now this id is the path to the main messages file, but this implementation may be changed at any time.
        Specified by:
        getBuildLogId in interface BuildLogEx
      • getMessagesIterator

        @NotNull
        public Iterator<LogMessage> getMessagesIterator()
        Description copied from interface: BuildLogReader
        Returns iterator over all log messages. Build log messages form a tree which is iterated as follows: iterator walks down the tree until it meets a leaf, then it seeks whether parent of the leaf has siblings and iterate over them, moving down to their children if needed and so on. In other words this iterator iterates over all messages in the tree in order of their appearance.

        The iterator is filtered by default, i.e. it doesn't include internal messages.

        Each log message has parent, so while iterating down the tree it is possible to go up to the topmost parent. You can obtain level in the tree for each message with help of LogMessage.getLevel() method.

        Specified by:
        getMessagesIterator in interface BuildLogReader
        Returns:
        filtered iterator by log messages.
        See Also:
        LogMessage.isInternal()
      • isClosed

        public boolean isClosed()
        Description copied from interface: BuildLogReader
        Returns true if this build log was closed.

        It's important that if the build log was closed on another node, the current one may not know about it!

        Specified by:
        isClosed in interface BuildLogReader
      • getLastMessageTimestamp

        @Nullable
        public Date getLastMessageTimestamp()
        Description copied from interface: BuildLogReader
        Returns timestamp of the last logged message.
        Specified by:
        getLastMessageTimestamp in interface BuildLogReader
        Returns:
        timestamp or null if there were no messages yet.
      • getCurrentPath

        @NotNull
        public String getCurrentPath()
        Specified by:
        getCurrentPath in interface BuildLogReader
        Returns:
        current path - concatenation of text from the last message and names of all the parent blocks
      • flush

        public void flush()
        Description copied from interface: BuildLogWriter
        Flushes messages from this build log to disk.
        Specified by:
        flush in interface BuildLogWriter
      • close

        public void close()
        Description copied from interface: BuildLogWriter
        Closes this build log. Subsequent attempts to call addMessage will result in an exception.
        Specified by:
        close in interface BuildLogWriter
      • flowStarted

        public void flowStarted​(@NotNull
                                String flowId,
                                @NotNull
                                String parentFlowId)
        Description copied from interface: FlowHierarchy
        This flow is started
        Specified by:
        flowStarted in interface FlowHierarchy
        Parameters:
        flowId - flow id
        parentFlowId - parent flow id
      • flowFinished

        public void flowFinished​(@NotNull
                                 String flowId)
        Description copied from interface: FlowHierarchy
        This flow is finished and can be released
        Specified by:
        flowFinished in interface FlowHierarchy
        Parameters:
        flowId - flow id
      • getFlowWithChildren

        @NotNull
        public List<Integer> getFlowWithChildren​(@NotNull
                                                 String flowId)
        Description copied from interface: FlowHierarchy
        Return list of child flows for given flow id, plus flowId itself
        Specified by:
        getFlowWithChildren in interface FlowHierarchy
        Parameters:
        flowId - parent of the child flows to be returned. the param is returned with results of the call.
        Returns:
        A list of flowIds in topological order.
      • getParentFlow

        @Nullable
        public Integer getParentFlow​(int flowId)
        Description copied from interface: FlowHierarchy
        Return parent flow ID for given flow ID
        Specified by:
        getParentFlow in interface FlowHierarchy
        Parameters:
        flowId - child flow ID
        Returns:
        see above
      • refreshNextMessageIndex

        public void refreshNextMessageIndex()
        Description copied from interface: BuildLogEx
        This method exists as a workaround for multi node setup when several nodes can write messages to build log. In this case index of the next message can become obsolete and if this index is required, then this refresh method should be called before logging a message to the build log.
        Specified by:
        refreshNextMessageIndex in interface BuildLogEx
      • getPendingOpenBlocks

        @NotNull
        public List<BlockDescriptor> getPendingOpenBlocks​(@Nullable
                                                          Integer flowId,
                                                          @Nullable
                                                          String blockType)
        Specified by:
        getPendingOpenBlocks in interface BuildLogReaderEx
        Parameters:
        flowId - if null blocks from any flow are returned, if not null, only blocks in the specified flow are returned
        blockType - if null all blocks are returned, if not null, only blocks of the specified type are returned
        Returns:
        all not yet closed blocks in all flows (returned blocks are order by their opening time - oldest at the beginning, newest at the end).
      • getNumberOfMessages

        public int getNumberOfMessages()
        Specified by:
        getNumberOfMessages in interface BuildLogReaderEx
        Returns:
        total number of logged messages in this build log
      • flushIfNeeded

        public void flushIfNeeded()
        Description copied from interface: BuildLogWriterEx
        Flushes all messages from local buffer to persister's buffer. Flushes persister's buffer if its size or exceeds some threshold, or it was not flushed for some time period.
        Specified by:
        flushIfNeeded in interface BuildLogWriterEx
      • scheduleAfterFlushTask

        public void scheduleAfterFlushTask​(@NotNull
                                           String taskId,
                                           @NotNull
                                           Runnable runnable)
        Description copied from interface: BuildLogWriterEx
        Adds a task which should be executed right after the next build log flush.
        Specified by:
        scheduleAfterFlushTask in interface BuildLogWriterEx
        Parameters:
        taskId - unique (in for a build) task id, subsequent attempts to add a task with the same id are ignored
        runnable - task
      • isFlowAwareIndexAvailable

        public boolean isFlowAwareIndexAvailable()
        Description copied from interface: BuildLogEx
        Returns true if the flow-aware index is available for the build (might trigger index costruction if it is not available yet).
        Specified by:
        isFlowAwareIndexAvailable in interface BuildLogEx
      • serverVersion

        @NotNull
        public static String serverVersion()
      • remotePersistLogMessage

        public int remotePersistLogMessage​(@NotNull
                                           LogMessageInfo info)
      • remotePersistBlocksUpdate

        public void remotePersistBlocksUpdate​(@NotNull
                                              List<Integer> messageIndexes,
                                              @Nullable
                                              Status status,
                                              @Nullable
                                              Date finishTs)
      • initialFlowId

        public static int initialFlowId()
      • getMessages

        @NotNull
        @TestOnly
        public List<LogMessage> getMessages()
        Description copied from interface: BuildLogReader
        Returns all messages as list in order of their appearance.
        Specified by:
        getMessages in interface BuildLogReader
        Returns:
        all messages as list in order of their appearance.
      • getNextMessageIndex

        @TestOnly
        public int getNextMessageIndex()
      • recoverBuildLog

        @TestOnly
        public void recoverBuildLog()