| | |
| | | } |
| | | this.status = terminalStatus; |
| | | this.blockedStationId = blockedStationId; |
| | | if (shouldClearPathOnTerminal(terminalStatus)) { |
| | | clearPathState(); |
| | | } |
| | | this.updatedAt = System.currentTimeMillis(); |
| | | this.terminalExpireAt = this.updatedAt + TERMINAL_KEEP_MS; |
| | | |
| | |
| | | appendEvent(eventType, message, nextDetails); |
| | | } |
| | | |
| | | private void clearPathState() { |
| | | this.fullPathStationIds = new ArrayList<>(); |
| | | this.issuedStationIds = new ArrayList<>(); |
| | | this.passedStationIds = new ArrayList<>(); |
| | | this.pendingStationIds = new ArrayList<>(); |
| | | this.latestIssuedSegmentPath = new ArrayList<>(); |
| | | this.segmentList = new ArrayList<>(); |
| | | this.issuedSegmentCount = 0; |
| | | this.totalSegmentCount = 0; |
| | | } |
| | | |
| | | private boolean shouldClearPathOnTerminal(String terminalStatus) { |
| | | return STATUS_BLOCKED.equals(terminalStatus) |
| | | || STATUS_CANCELLED.equals(terminalStatus); |
| | | } |
| | | |
| | | private synchronized boolean shouldRemove(long now) { |
| | | return terminalExpireAt != null && terminalExpireAt <= now; |
| | | } |