router.h 1.99 KB
Newer Older
1
/*
Bernd Zeimetz's avatar
Bernd Zeimetz committed
2
 * Copyright 2013-2017 Fabian Groffen
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


#ifndef ROUTER_H
#define ROUTER_H 1

#include <stdio.h>
#include <regex.h>

#include "server.h"
25
#include "aggregator.h"
26

Bernd Zeimetz's avatar
Bernd Zeimetz committed
27 28 29 30 31 32
#define PMODE_NORM    (1 << 0)
#define PMODE_AGGR    (1 << 1)
#define PMODE_HASH    (1 << 2)
#define PMODE_STUB    (1 << 3)
#define PMODE_DEBUG   (PMODE_HASH | PMODE_STUB)

33
#define CONN_DESTS_SIZE    64
34 35 36 37 38
typedef struct {
	const char *metric;
	server *dest;
} destination;

39
typedef struct _router router;
40 41 42

#define RE_MAX_MATCHES     64

Bernd Zeimetz's avatar
Bernd Zeimetz committed
43
router *router_readconfig(router *orig, const char *path, size_t queuesize, size_t batchsize, int maxstalls, unsigned short iotimeout, unsigned int sockbufsize);
44
void router_optimise(router *r);
Bernd Zeimetz's avatar
Bernd Zeimetz committed
45 46 47
char router_printdiffs(router *old, router *new, FILE *out);
void router_transplant_queues(router *new, router *old);
char router_start(router *r);
48
size_t router_rewrite_metric(char (*newmetric)[METRIC_BUFSIZ], char **newfirstspace, const char *metric, const char *firstspace, const char *replacement, const size_t nmatch, const regmatch_t *pmatch);
49 50 51 52 53 54
void router_printconfig(router *r, FILE *f, char mode);
char router_route(router *r, destination ret[], size_t *retcnt, size_t retsize, char *srcaddr, char *metric, char *firstspace);
void router_test(router *r, char *metric_path);
server **router_getservers(router *r);
aggregator *router_getaggregators(router *r);
char *router_getcollectorstub(router *r);
Bernd Zeimetz's avatar
Bernd Zeimetz committed
55
void router_shutdown(router *r);
56
void router_free(router *r);
57 58

#endif