decodes.tsdb.PythonWritten Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of opendcs Show documentation
Show all versions of opendcs Show documentation
A collection of software for aggregatting and processing environmental data such as from NOAA GOES satellites.
The newest version!
package decodes.tsdb;
import java.util.Date;
import decodes.sql.DbKey;
/**
* Bean that stores a value written to the database from a python algorithm.
* These beans will stay in the compproc queue for 2 minutes. The purpose is
* to prevent a python algorithm from triggering itself.
*
* Example: Simple python algorithm with two inputs A, and B, and one pure
* output, C:
*
* if isNew('A'):
* setOutput('B', A.value * 2)
* setOutput('C', rating('B', B.value))
*
* So, A is used to compute B. Then B is used to compute C.
* Without the PythonWritten queue, this is what would happen:
*
* - Computation triggered by new A being written to the database.
* - Computation computes and writes B
* - Computation computes and writes C
* - A new tasklist record for B is created
* - Computation runs again. It fetches existin A value. It does not recompute
* B because the isNew call returns false.
* - Computation computes and writes C
*
* To fix this, whenever a multi-input python algorithm writes an output, it places
* a PythonWritten entry in a queue where it resides for 2 minutes.
* The Resolver will ignore matching tasklist records.
* @author mmaloney
*
*/
public class PythonWritten
{
private DbKey compId = DbKey.NullKey;
private DbKey tsCode = DbKey.NullKey;
private Date timeWritten = null;
public PythonWritten(DbKey compId, DbKey tsCode)
{
super();
this.compId = compId;
this.tsCode = tsCode;
this.timeWritten = new Date();
}
public DbKey getCompId()
{
return compId;
}
public DbKey getTsCode()
{
return tsCode;
}
public Date getTimeWritten()
{
return timeWritten;
}
}