View Javadoc

1   package org.lsst.ccs.config;
2   
3   import javax.persistence.Entity;
4   import javax.persistence.GeneratedValue;
5   import javax.persistence.Id;
6   import java.io.Serializable;
7   
8   /**
9    * Entries int his table are generated by reading the status bus where subsystem advertise their startup.
10   * <P>
11   * Though there is a "endTimestamp" it is possible that the end of an execution is "missed" by the system.
12   * So finding the configuration at a precise moment in time may be complex.
13   * <p>
14   *     this can be done either by sorting (should be performed during a day task)
15   *     or as a direct operation
16   * <P>
17   *   in this last case two operations should correlate:
18   *   <UL>
19   *       <LI> When creating a new entry with same subsystem name
20   *       get all entries with same subsystem and where "timenext" is zero.
21   *       put the timenext at current value and if "endTimeStampLimit" is max put the current time
22   *        <LI> when looking for a precise entry in time.
23   *        just operate a comparison between starttime and endTimeLimit
24   *
25   *   </UL>
26   * @author bamade
27   */
28  // Date: 24/05/12
29  
30      @Entity
31  public class RunHistory  implements Serializable {
32      private static final long serialVersionUID = 927127673789827728L;
33      @Id
34      @GeneratedValue
35      private long id ;
36  
37      private String subsystemName;
38  
39      private String configurationName;
40  
41      private String tag ;
42  
43      private long startTimestamp ;
44      /**
45       * used to tell that the <TT>startTimestamp</TT> is not real but was artificially reconstituted
46       * (an unlikely event: end message received and start message lost)
47       */
48      private boolean startGuessed ;
49  
50      /**
51       * Possible end of task: may be missing due to dysfunctional system.
52       * So next occurence with same subsystem will replace by its own time.
53       * Defaults to  STILL_VALID
54       */
55      private long endTimestampLimit = PackCst.STILL_VALID;
56      /**
57       * used to tall that the <TT>endTimestampLimit</TT> has been artificially set
58       * to a value which is different from constant <TT>STILL_VALID</TT> : this
59       * may happen when an "end" message is lost.
60       */
61      private boolean endGuessed ;
62  
63      /**
64       * startTimestamp of next entry in time with same subsystem.
65       * Defaults to zero
66       */
67      private long timeNext = 0L;
68  
69      RunHistory() {}
70  
71      public RunHistory(String subsystemName, String configurationName, String tag, long startTimestamp) {
72          this.subsystemName = subsystemName;
73          this.configurationName = configurationName;
74          this.tag = tag;
75          this.startTimestamp = startTimestamp;
76      }
77      ///////////////////////////// ACCESSORS/MUTATORS
78  
79      public long getId() {
80          return id;
81      }
82  
83       void setId(long id) {
84          this.id = id;
85      }
86  
87      public String getSubsystemName() {
88          return subsystemName;
89      }
90  
91       void setSubsystemName(String subsystemName) {
92          this.subsystemName = subsystemName;
93      }
94  
95      public String getConfigurationName() {
96          return configurationName;
97      }
98  
99       void setConfigurationName(String configurationName) {
100         this.configurationName = configurationName;
101     }
102 
103     public String getTag() {
104         return tag;
105     }
106 
107     void setTag(String tag) {
108         this.tag = tag;
109     }
110 
111     public long getStartTimestamp() {
112         return startTimestamp;
113     }
114 
115      void setStartTimestamp(long startTimestamp) {
116         this.startTimestamp = startTimestamp;
117     }
118 
119     public boolean isStartGuessed() {
120         return startGuessed;
121     }
122 
123     public void setStartGuessed(boolean startGuessed) {
124         this.startGuessed = startGuessed;
125     }
126 
127     public boolean isEndGuessed() {
128         return endGuessed;
129     }
130 
131     public void setEndGuessed(boolean endGuessed) {
132         this.endGuessed = endGuessed;
133     }
134 
135     public long getEndTimestampLimit() {
136         return endTimestampLimit;
137     }
138 
139     public void setEndTimestampLimit(long endTimestampLimit) {
140         this.endTimestampLimit = endTimestampLimit;
141     }
142 
143     public long getTimeNext() {
144         return timeNext;
145     }
146 
147     public void setTimeNext(long timeNext) {
148         this.timeNext = timeNext;
149     }
150 }