sensorconfig_internal.h 4 KB
Newer Older
1
2
//================================================================================
// Name        : sensorconfig_internal.h
3
// Author      : Axel Auweter, Daniele Tafani
Micha Müller's avatar
Micha Müller committed
4
// Contact     : info@dcdb.it
5
// Copyright   : Leibniz Supercomputing Centre
Michael Ott's avatar
Michael Ott committed
6
// Description : Internal Interface for configuring libdcdb public sensors.
7
8
9
10
//================================================================================

//================================================================================
// This file is part of DCDB (DataCenter DataBase)
11
// Copyright (C) 2011-2019 Leibniz Supercomputing Centre
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//================================================================================
Axel Auweter's avatar
Axel Auweter committed
27
28

#include <list>
Axel Auweter's avatar
Axel Auweter committed
29
#include <string>
30
#include <unordered_map>
31
#include <functional>
Axel Auweter's avatar
Axel Auweter committed
32
33

#include "cassandra.h"
Axel Auweter's avatar
Axel Auweter committed
34

35
36
37
#include "dcdb/connection.h"
#include "dcdb/timestamp.h"
#include "dcdb/sensorid.h"
Axel Auweter's avatar
Axel Auweter committed
38

39
#include "dcdb/sensorconfig.h"
Axel Auweter's avatar
Axel Auweter committed
40

41
42
43
44
#ifndef DCDB_SENSORCONFIG_INTERNAL_H
#define DCDB_SENSORCONFIG_INTERNAL_H

namespace DCDB {
Axel Auweter's avatar
Axel Auweter committed
45
46
47
48

class SensorConfigImpl
{
protected:
49
  Connection* connection;
50
  CassSession* session;
Axel Auweter's avatar
Axel Auweter committed
51

52
53
54
  typedef std::unordered_map<std::string, std::reference_wrapper<PublicSensor>> SensorMap_t;
  SensorMap_t sensorMapByName;
  std::list<PublicSensor> sensorList;
55

Axel Auweter's avatar
Axel Auweter committed
56
  bool validateSensorPattern(const char* sensorPattern);
57
  bool validateSensorPublicName(std::string publicName);
Axel Auweter's avatar
Axel Auweter committed
58
59

public:
60
  SCError loadCache();
Axel Auweter's avatar
Axel Auweter committed
61
  SCError publishSensor(std::string publicName, std::string sensorPattern);
62
  SCError publishSensor(const PublicSensor& sensor);
63
  SCError publishSensor(const SensorMetadata& sensor);
64
  SCError publishVirtualSensor(std::string publicName, std::string vSensorExpression, std::string vSensorId, TimeStamp tZero, uint64_t interval);
65
  SCError unPublishSensor(std::string publicName);
66
  SCError unPublishSensorsByWildcard(std::string wildcard);
67
  SCError getPublicSensorNames(std::list<std::string>& publicSensors);
68
  SCError getPublicSensorsVerbose(std::list<PublicSensor>& publicSensors);
69
  
70
  SCError getPublicSensorByName(PublicSensor& sensor, const char* publicName);
71
72
  SCError getPublicSensorsByWildcard(std::list<PublicSensor>& sensors, const char* wildcard);
    
73
74
  SCError isVirtual(bool& isVirtual, std::string publicName);

Axel Auweter's avatar
Axel Auweter committed
75
76
  SCError getSensorPattern(std::string& pattern, std::string publicName);
  SCError getSensorListForPattern(std::list<SensorId>& sensorIds, std::string pattern);
77
  SCError getSensorListForPattern(std::list<SensorId>& sensorIds, std::string pattern, TimeStamp start, TimeStamp end);
Axel Auweter's avatar
Axel Auweter committed
78

79
80
  SCError setSensorScalingFactor(std::string publicName, double scalingFactor);
  SCError setSensorUnit(std::string publicName, std::string unit);
81
  SCError setSensorMask(std::string publicName, uint64_t mask);
82
  SCError setOperations(std::string publicName, std::set<std::string> operations);
83
  SCError clearOperations(std::string publicName);
84
  SCError clearOperationsByWildcard(std::string wildcard);
85
86
  SCError setTimeToLive(std::string publicName, uint64_t ttl);
  SCError setSensorInterval(std::string publicName, uint64_t interval);
87

88
89
90
  SCError setVirtualSensorExpression(std::string publicName, std::string expression);
  SCError setVirtualSensorTZero(std::string publicName, TimeStamp tZero);

91
  SensorConfigImpl(Connection* conn);
Axel Auweter's avatar
Axel Auweter committed
92
93
94
  virtual ~SensorConfigImpl();
};

95
96
97
} /* End of namespace DCDB */

#endif /* DCDB_SENSORCONFIG_INTERNAL_H */