-
Notifications
You must be signed in to change notification settings - Fork 390
/
viz_collector.h
146 lines (131 loc) · 4.39 KB
/
viz_collector.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
* Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
*/
#ifndef VIZ_COLLECTOR_H_
#define VIZ_COLLECTOR_H_
#include <boost/asio.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/ptr_container/ptr_map.hpp>
#include <boost/uuid/uuid.hpp>
#include <utility>
#include "base/parse_object.h"
#include "base/contrail_ports.h"
#include "collector.h"
#include "OpServerProxy.h"
#include "viz_constants.h"
#include "syslog_collector.h"
#include "db_handler.h"
class Ruleeng;
class ProtobufCollector;
class SFlowCollector;
class IpfixCollector;
class VizCollector {
public:
VizCollector(EventManager *evm, unsigned short listen_port,
bool protobuf_collector_enabled,
unsigned short protobuf_listen_port,
const std::vector<std::string> &cassandra_ips,
const std::vector<int> &cassandra_ports,
const std::string &redis_uve_ip, unsigned short redis_uve_port,
const std::string &redis_password,
const std::string &brokers,
int syslog_port, int sflow_port, int ipfix_port,
uint16_t partitions, bool dup,
const std::string &kafka_prefix, const TtlMap &ttlmap,
const std::string& cassandra_user,
const std::string& cassandra_password,
bool use_cql,
const std::string &zookeeper_server_list,
bool use_zookeeper);
VizCollector(EventManager *evm, DbHandlerPtr db_handler,
Ruleeng *ruleeng,
Collector *collector, OpServerProxy *osp);
~VizCollector();
std::string name() { return name_; }
bool Init();
void Shutdown();
static void WaitForIdle();
SyslogListeners *GetSyslogListener() const {
return syslog_listener_;
}
Collector *GetCollector() const {
return collector_;
}
Ruleeng *GetRuleeng() const {
return ruleeng_.get();
}
OpServerProxy *GetOsp() const {
return osp_.get();
}
bool SendRemote(const std::string& destination, const std::string& dec_sandesh);
void RedisUpdate(bool rsc) {
collector_->RedisUpdate(rsc);
if (rsc) {
redis_gen_ ++;
CollectorPublish();
}
}
void SendDbStatistics();
void SendProtobufCollectorStatistics();
void SendGeneratorStatistics();
void TestDatabaseConnection();
void CollectorPublish();
bool GetCqlMetrics(cass::cql::Metrics *metrics);
static const unsigned int kPartCountCnodes = 1;
static const unsigned int kPartMinTotalCount = 15;
static std::pair<unsigned int,unsigned int> PartitionRange(
PartType::type ptype, unsigned int partitions) {
if (partitions < kPartMinTotalCount) {
return std::make_pair(0, partitions);
}
unsigned int pnodeparts = (partitions / 15) + 1;
unsigned int varparts = (partitions -
kPartCountCnodes - pnodeparts) / 3;
unsigned int bpart;
unsigned int npart;
switch (ptype)
{
case PartType::PART_TYPE_CNODES:
bpart = 0;
npart = kPartCountCnodes;
break;
case PartType::PART_TYPE_PNODES:
bpart = kPartCountCnodes;
npart = pnodeparts;
break;
case PartType::PART_TYPE_VMS:
bpart = kPartCountCnodes + pnodeparts;
npart = varparts;
break;
case PartType::PART_TYPE_IFS:
bpart = kPartCountCnodes + pnodeparts +
varparts;
npart = varparts;
break;
default:
bpart = kPartCountCnodes + pnodeparts +
(2*varparts);
npart = partitions - bpart;
break;
}
return std::make_pair(bpart, npart);
}
private:
std::string DbGlobalName(bool dup=false);
void DbInitializeCb();
boost::scoped_ptr<DbHandlerInitializer> db_initializer_;
boost::scoped_ptr<OpServerProxy> osp_;
boost::scoped_ptr<Ruleeng> ruleeng_;
Collector *collector_;
SyslogListeners *syslog_listener_;
SFlowCollector *sflow_collector_;
IpfixCollector *ipfix_collector_;
boost::scoped_ptr<ProtobufCollector> protobuf_collector_;
std::string name_;
unsigned short listen_port_;
uint32_t redis_gen_;
uint16_t partitions_;
std::string kafka_prefix_;
DISALLOW_COPY_AND_ASSIGN(VizCollector);
};
#endif /* VIZ_COLLECTOR_H_ */