Skip to main content

Database Model

This document explains where and in what shape the gateway stores data. Refer to it when adjusting the retention period, when the disk fills up, or when you need to query directly.

There is one Cassandra inside the gateway

Edge stores its own data in local Cassandra (127.0.0.1:9042, keyspace PE). This is different from the Cassandra on the upper platform (pp) — it is a self-contained store that lets the gateway keep collecting on its own even if it loses connection.

There are only 11 tables, split into two groups.

PrefixMeaning
APP_Configuration — what to collect
TM_Time series / operational records — what was collected and how

APP_ — Collection configuration​

Whatever you create on the screens (connection · tag) goes straight in here.

TableContents
APP_OPCConnection definitions — OPC_ID · name · protocol (OPC_TYPE) · target IP/port · collection interval (TIMECYCLE) · auto-collect flag
APP_TAGTag definitions — address to read and data type
If these two disappear, collection stops

Time series data can be re-collected, but configuration is something a person created, so there is no way to recover it. Don't forget these two tables when backing up → Backup and Recovery.


TM_ — Collected values and operational records​

TableContents
TM_TAG_POINTRaw collected values — the core of this store
TM_TAG_POINT_ARCHIVEArchival copy
TM_TAG_ERRORPer-tag collection errors
TM_TAG_STATPer-tag statistics
TM_TAG_WRITEWrite (control) history
TM_OPC_STATPer-connection statistics
TM_PLC_PINGTarget equipment response check history
TM_MONITORGateway resources/status
TM_API_LOGREST API call log

Shape of TM_TAG_POINT​

PRIMARY KEY (TAG_ID, TIMESTAMP)
WITH CLUSTERING ORDER BY (TIMESTAMP DESC)
PropertyValue
Partition keyTAG_ID — one tag = one partition
ClusteringTIMESTAMP descending — reads start from the latest
ColumnsVALUE · QUALITY · ERROR_CODE · TYPE · ATTRIBUTE (map)
CompactionTimeWindowCompactionStrategy, 10-minute window
Why TimeWindow?

For the gateway, the workflow is simply "write, briefly read, then discard via TTL." By grouping SSTables into time windows, an entire expired window can be discarded as a whole, keeping compaction cost near zero.


Retention period — the number exists in two places​

The 30 days in the schema is not the actual value

The default_time_to_live in scheme.cql is 30 days (2592000 seconds), but at startup it is overwritten by ALTER TABLE the table TTL with the edge.ttl value from app.properties.

Since the factory default is edge.ttl = 60 (days), the actual retention is 60 days. Don't assume 30 days just by looking at the schema file.

To change it, edit edge.ttl and restart.

cd /opt/kopens/plantpulse-edge/bin
./config.sh --get edge.ttl
./config.sh --set edge.ttl 90
./config.sh --restart # 기동 시 ALTER TABLE 로 반영된다
Shortening it takes effect immediately

If you shorten the TTL, data older than the new value gets reclaimed on the next compaction. This cannot be undone. If you're shortening it because disk space is running out, make sure you've uploaded any needed range to the upper platform first.


When the disk fills up​

Capacity is determined by number of tags × collection interval × retention days. You need to reduce one of the three.

What to adjustHow
Retention daysReduce edge.ttl (see above)
Collection intervalIncrease TIMECYCLE on the connection — keep second-level collection only for tags that truly need it
Number of tagsTurn off auto-collect for unused tags

For diagnostics, see Diagnostics and Inspection.