]>
Commit | Line | Data |
---|---|---|
fe000966 DM |
1 | /* |
2 | Copyright (C) 2010 Proxmox Server Solutions GmbH | |
3 | ||
4 | This program is free software: you can redistribute it and/or modify | |
5 | it under the terms of the GNU Affero General Public License as published by | |
6 | the Free Software Foundation, either version 3 of the License, or | |
7 | (at your option) any later version. | |
8 | ||
9 | This program is distributed in the hope that it will be useful, | |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | GNU Affero General Public License for more details. | |
13 | ||
14 | You should have received a copy of the GNU Affero General Public License | |
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | ||
17 | Author: Dietmar Maurer <dietmar@proxmox.com> | |
18 | ||
19 | */ | |
20 | ||
21 | #define _XOPEN_SOURCE /* glibc2 needs this */ | |
22 | #include <time.h> /* for strptime */ | |
23 | ||
24 | #include <stdio.h> | |
25 | #include <stdlib.h> | |
26 | #include <glib.h> | |
27 | #include <sys/types.h> | |
28 | #include <sys/syslog.h> | |
29 | #include <sys/stat.h> | |
30 | #include <fcntl.h> | |
31 | #include <errno.h> | |
32 | #include <unistd.h> | |
33 | #include <string.h> | |
34 | #include <ctype.h> | |
35 | ||
36 | #include "cfs-utils.h" | |
37 | #include "logger.h" | |
38 | ||
39 | cfs_t cfs = { | |
40 | .debug = 0, | |
41 | .nodename = "testnode", | |
fe000966 DM |
42 | }; |
43 | ||
44 | ||
45 | int | |
46 | main(void) | |
47 | { | |
48 | ||
49 | uint32_t pid = getpid(); | |
50 | ||
51 | #if 1 | |
52 | clusterlog_t *cl3 = clusterlog_new(); | |
53 | ||
54 | clog_entry_t *entry = (clog_entry_t *)alloca(CLOG_MAX_ENTRY_SIZE); | |
55 | clog_pack(entry, cfs.nodename, "root", "cluster", pid, time(NULL), LOG_INFO, "starting cluster log"); | |
56 | clusterlog_insert(cl3, entry); | |
57 | ||
58 | for (int i = 0; i < 5000; i++) { | |
59 | clusterlog_add(cl3, "user1", "TESTDOMAIN1", pid, LOG_INFO, | |
60 | "test user1 รค message asdasd d dsgfdfgdgdg dgg dgdg %d", i); | |
61 | } | |
62 | ||
63 | #if 0 | |
64 | for (int i = 0; i < 5000; i++) { | |
65 | clog_base_t *clog[2] = { cl3->base, cl3->base }; | |
66 | ||
67 | clusterlog_merge(cl3, clog, 2); | |
68 | //clusterlog_sort(cl3); | |
69 | } | |
70 | #endif | |
71 | ||
72 | //clog_dump(cl3->base); | |
73 | ||
74 | clusterlog_destroy(cl3); | |
75 | ||
76 | exit(0); | |
77 | ||
78 | #endif | |
79 | ||
80 | ||
81 | clusterlog_t *cl1 = clusterlog_new(); | |
82 | ||
83 | for (int i = 0; i < 5; i++) { | |
84 | clusterlog_add(cl1, "user1", "TESTDOMAIN1", pid, LOG_INFO, | |
85 | "test user1 message asdasd %d", i); | |
86 | } | |
87 | ||
88 | ||
89 | #if 0 | |
90 | for (int i = 0; i < 5; i++) { | |
91 | clusterlog_add(cl1, "user2", "TESTDOMAIN1", pid, LOG_INFO, | |
92 | "test user2 message asdasd %d", i); | |
93 | } | |
94 | #endif | |
95 | ||
96 | clusterlog_t *cl2 = clusterlog_new(); | |
97 | ||
98 | #if 1 | |
99 | for (int i = 0; i < 5; i++) { | |
100 | clusterlog_add(cl2, "user3", "TESTDOMAIN2", pid, LOG_INFO, | |
101 | "test user3 message asdasd %d", i); | |
102 | } | |
103 | #endif | |
104 | ||
105 | #if 0 | |
106 | clog_base_t *clog[2] = { cl1->base, cl2->base }; | |
107 | ||
108 | clusterlog_merge(cl1, clog, 2); | |
109 | clog_dump(cl1->base); | |
110 | ||
111 | clusterlog_destroy(cl1); | |
112 | clusterlog_destroy(cl2); | |
113 | #endif | |
114 | } |