MCPcopy Create free account
hub / github.com/apache/trafficserver / init

Method init

src/tscpp/api/Stat.cc:43–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41}
42
43bool
44Stat::init(const string &name, Stat::SyncType type, bool persistent)
45{
46 if (TSStatFindName(name.c_str(), &stat_id_) == TS_SUCCESS) {
47 LOG_DEBUG("Attached to stat '%s' with stat_id = %d", name.c_str(), stat_id_);
48 return true;
49 }
50
51 // TS_RECORDDATATYPE_INT is the only type currently supported
52 // so that's why this api doesn't expose other types, TSStatSync is equivalent to StatSyncType
53 stat_id_ = TSStatCreate(name.c_str(), TS_RECORDDATATYPE_INT, persistent ? TS_STAT_PERSISTENT : TS_STAT_NON_PERSISTENT,
54 static_cast<TSStatSync>(type));
55 if (stat_id_ != TS_ERROR) {
56 LOG_DEBUG("Created new stat named '%s' with stat_id = %d", name.c_str(), stat_id_);
57 } else {
58 LOG_ERROR("Unable to create stat named '%s'.", name.c_str());
59 }
60
61 if (stat_id_ == TS_ERROR) {
62 return false;
63 }
64
65 if (!persistent) {
66 set(0);
67 }
68
69 return true;
70}
71
72void
73Stat::set(int64_t value)

Callers

nothing calls this directly

Calls 4

TSStatFindNameFunction · 0.85
TSStatCreateFunction · 0.85
setFunction · 0.85
c_strMethod · 0.45

Tested by

no test coverage detected