-
Notifications
You must be signed in to change notification settings - Fork 0
/
GaleraClient.pm
106 lines (88 loc) · 2.07 KB
/
GaleraClient.pm
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
package GaleraClient;
# This class models a single instance of the glbd.
# It communicates with the glbd, and with the database nodes, and with other minders.
# It decides the weightings to be used in the glbd, and advises glbd of those weightings.
use strict;
use warnings;
use DBI;
use ClusterConfig;
use parent 'Wakeup';
use Class::Tiny qw(
status_running
status_serving
status_primary
status_group
access
dbh
notify_status
notify_uuid
notify_primary
notify_index
notify_members
wsrep_cluster_size
wsrep_cluster_state_uuid
wsrep_cluster_status
wsrep_connected
wsrep_desync_count
wsrep_gcomm_uuid
wsrep_incoming_addresses
wsrep_last_committed
wsrep_local_state
wsrep_local_state_comment
wsrep_local_state_uuid
wsrep_ready
),
{
DBI_string => 'DBI:mysql:host=localhost',
User => 'root',
Password => '', #uHuNUvH1fX2T
cluster_size => 0
}
;
my $singleton;
sub BUILD {
my $self=shift;
$singleton = $self;
$self->set_wakeup('poll',1);
ClusterConfig::create_Servers();
}
sub single() {
return $singleton;
}
sub poll {
my $self = shift;
print "Client is polling!";
getinfo();
$self->set_wakeup('poll',6);
# The regular polling to be done is
# Check each db node for its up status
# Check for new configuration information
# Check that minder is still running correctly.
}
sub glb_connect {
# Open a tcp socket to the minder
my $message = shift;
my $socket = new IO::Socket::INET (
PeerAddr => ClusterConfig::node()->{glb_ip},
PeerPort => ClusterConfig::node()->{glb_port},
Proto => 'tcp',
) or die "ERROR in Socket Creation for glb : $! \n";
$socket->send($message,0);
my $peer_data;
$socket->recv($peer_data,1024);
return $peer_data;
}
sub getinfo {
# Send "getinfo"
my $result = glb_connect("getinfo\n");
print $result;
### Interpret result
}
sub setweights {
# This sets or adjusts weights, or adds or removes db nodes
my $message = 'hello';
my $result = glb_connect($message);
print $result;
### Check result = Ok
}
1;