Merge branch '2.4' of github.com:mariadb-corporation/MaxScale into 2.4
This commit is contained in:
@ -49,8 +49,8 @@ These tutorials are for specific use cases and module combinations.
|
||||
- [Filter Tutorial](Tutorials/Filter-Tutorial.md)
|
||||
- [RabbitMQ and Tee Filter Data Archiving Tutorial](Tutorials/RabbitMQ-And-Tee-Archiving.md)
|
||||
- [RabbitMQ Setup and MariaDB MaxScale Integration Tutorial](Tutorials/RabbitMQ-Setup-And-MaxScale-Integration.md)
|
||||
- [Clustrix Monitor Tutorial](Tutorials/Configuring-Clustrix-Monitor.md)
|
||||
- [MaxScale Clustrix Tutorial](Tutorials/MaxScale-Clustrix-Tutorial.md)
|
||||
- [Xpand Monitor Tutorial](Tutorials/Configuring-Xpand-Monitor.md)
|
||||
- [MaxScale Xpand Tutorial](Tutorials/MaxScale-Xpand-Tutorial.md)
|
||||
|
||||
Here are tutorials on monitoring and managing MariaDB MaxScale in cluster environments.
|
||||
|
||||
@ -110,7 +110,7 @@ Module specific documentation.
|
||||
- [Galera Monitor](Monitors/Galera-Monitor.md)
|
||||
- [ColumnStore Monitor](Monitors/ColumnStore-Monitor.md)
|
||||
- [Aurora Monitor](Monitors/Aurora-Monitor.md)
|
||||
- [Clustrix Monitor](Monitors/Clustrix-Monitor.md)
|
||||
- [Xpand Monitor](Monitors/Xpand-Monitor.md)
|
||||
|
||||
## Protocols
|
||||
|
||||
|
@ -1,29 +1,32 @@
|
||||
# Clustrix Monitor
|
||||
# Xpand Monitor
|
||||
|
||||
**NOTE** The Xpand monitor is intended for use with a native Xpand
|
||||
cluster, not with the Xpand storage engine.
|
||||
|
||||
## Overview
|
||||
|
||||
The Clustrix Monitor is a monitor that monitors a Clustrix cluster. It is
|
||||
The Xpand Monitor is a monitor that monitors a Xpand cluster. It is
|
||||
capable of detecting the cluster setup and creating corresponding server
|
||||
instances within MaxScale.
|
||||
|
||||
## Configuration
|
||||
|
||||
A minimal configuration for a monitor requires one server in the Clustrix
|
||||
A minimal configuration for a monitor requires one server in the Xpand
|
||||
cluster, and a username and a password to connect to the server. Note that
|
||||
by default the Clustrix monitor will only use that server in order to
|
||||
by default the Xpand monitor will only use that server in order to
|
||||
dynamically find out the configuration of the cluster; after startup it
|
||||
will completely rely upon information obtained at runtime. To change the
|
||||
default behaviour, please see the parameter
|
||||
[dynamic_node_detection](#dynamic_node_detection).
|
||||
|
||||
To ensure that the Clustrix monitor will be able to start, it is adviseable
|
||||
To ensure that the Xpand monitor will be able to start, it is adviseable
|
||||
to provide _more_ than one server to cater for the case that not all nodes
|
||||
are always up when MaxScale starts.
|
||||
|
||||
```
|
||||
[TheClustrixMonitor]
|
||||
[TheXpandMonitor]
|
||||
type=monitor
|
||||
module=clustrixmon
|
||||
module=xpandmon
|
||||
servers=server1,server2,server3
|
||||
user=myuser
|
||||
password=mypwd
|
||||
@ -32,22 +35,22 @@ password=mypwd
|
||||
|
||||
## Dynamic Servers
|
||||
|
||||
The server objects the Clustrix monitor creates for each detected
|
||||
Clustrix node will be named like
|
||||
The server objects the Xpand monitor creates for each detected
|
||||
Xpand node will be named like
|
||||
```
|
||||
@@<name-of-clustrix-monitor>:node-<id>
|
||||
@@<name-of-xpand-monitor>:node-<id>
|
||||
```
|
||||
where `<name-of-clustrix-monitor>` is the name of the Clustrix monitor
|
||||
where `<name-of-xpand-monitor>` is the name of the Xpand monitor
|
||||
instance, as defined in the MaxScale configuration file, and `<id>` is the
|
||||
id of the Clustrix node.
|
||||
id of the Xpand node.
|
||||
|
||||
For instance, with the Clustrix monitor defined as above and a Clustrix
|
||||
For instance, with the Xpand monitor defined as above and a Xpand
|
||||
cluster consisting of 3 nodes whose ids are `1`, `2` and `3` respectively,
|
||||
the names of the created server objects will be:
|
||||
```
|
||||
@@TheClustrixMonitor:node-1
|
||||
@@TheClustrixMonitor:node-2
|
||||
@@TheClustrixMonitor:node-3
|
||||
@@TheXpandMonitor:node-1
|
||||
@@TheXpandMonitor:node-2
|
||||
@@TheXpandMonitor:node-3
|
||||
```
|
||||
|
||||
### Grants
|
||||
@ -76,9 +79,9 @@ The user name must be changed to the one actually being used.
|
||||
For a list of optional parameters that all monitors support, read the
|
||||
[Monitor Common](Monitor-Common.md) document.
|
||||
|
||||
## Clustrix Monitor optional parameters
|
||||
## Xpand Monitor optional parameters
|
||||
|
||||
These are optional parameters specific to the Clustrix Monitor.
|
||||
These are optional parameters specific to the Xpand Monitor.
|
||||
|
||||
### `cluster_monitor_interval`
|
||||
|
||||
@ -105,12 +108,12 @@ health_check_threshold=3
|
||||
|
||||
### `dynamic_node_detection`
|
||||
|
||||
By default, the Clustrix monitor will only use the bootstrap nodes
|
||||
in order to connect to the Clustrix cluster and then find out the
|
||||
By default, the Xpand monitor will only use the bootstrap nodes
|
||||
in order to connect to the Xpand cluster and then find out the
|
||||
cluster configuration dynamically at runtime.
|
||||
|
||||
That behaviour can be turned off with this optional parameter, in
|
||||
which case all Clustrix nodes must manually be defined as shown below.
|
||||
which case all Xpand nodes must manually be defined as shown below.
|
||||
|
||||
```
|
||||
[Node-1]
|
||||
@ -125,9 +128,9 @@ port=3306
|
||||
[Node-3]
|
||||
...
|
||||
|
||||
[Clustrix-Monitor]
|
||||
[TheXpandMonitor]
|
||||
type=monitor
|
||||
module=clustrixmon
|
||||
module=xpandmon
|
||||
servers=Node-1, Node-2, Node-3
|
||||
dynamic_node_detection=false
|
||||
```
|
||||
@ -151,26 +154,26 @@ is `false`. Note also that the port must be the same for all nodes.
|
||||
|
||||
## Commands
|
||||
|
||||
The Clustrix monitor supports the following module commands.
|
||||
The Xpand monitor supports the following module commands.
|
||||
|
||||
### `softfail`
|
||||
|
||||
With the `softfail` module command, a node can be _softfailed_ via
|
||||
MaxScale. The command requires as argument the name of the Clustrix
|
||||
MaxScale. The command requires as argument the name of the Xpand
|
||||
monitor instance (as defined in the configuration file) and the name
|
||||
of the node to be softfailed.
|
||||
|
||||
For instance, with a configuration file like
|
||||
```
|
||||
[TheClustrixMonitor]
|
||||
[TheXpandMonitor]
|
||||
type=monitor
|
||||
module=clustrixmon
|
||||
module=xpandmon
|
||||
...
|
||||
```
|
||||
then the node whose server name is `@@TheClustrixMonitor:node-1` can
|
||||
then the node whose server name is `@@TheXpandMonitor:node-1` can
|
||||
be softfailed like
|
||||
```
|
||||
$ maxctrl call command clustrixmon softfail TheClustrixMonitor @@TheClustrixMonitor:node-1
|
||||
$ maxctrl call command xpandmon softfail TheXpandMonitor @@TheXpandMonitor:node-1
|
||||
```
|
||||
If the softfailing of a node is successfully initiated, then the status
|
||||
of the corresponding MaxScale server object will be set to `Draining`,
|
||||
@ -184,14 +187,14 @@ of the softfailing operation is.
|
||||
### `unsoftfail`
|
||||
|
||||
With the `unsoftfail` module command, a node can be _unsoftfailed_ via
|
||||
MaxScale. The command requires as argument the name of the Clustrix
|
||||
MaxScale. The command requires as argument the name of the Xpand
|
||||
monitor instance (as defined in the configuration file) and the name
|
||||
of the node to be unsoftfailed.
|
||||
|
||||
With a setup similar to the `softfail` case, a node can be unsoftfailed
|
||||
like:
|
||||
```
|
||||
$ maxctrl call command clustrixmon unsoftfail TheClustrixMonitor @@TheClustrixMonitor:node-1
|
||||
$ maxctrl call command xpandmon unsoftfail TheXpandMonitor @@TheXpandMonitor:node-1
|
||||
```
|
||||
If a node is successfully softfailed, then a `Draining` status of
|
||||
the corresponding MaxScale server object will be cleared.
|
||||
@ -213,6 +216,6 @@ If a node that was softfailed is UNSOFTFAILed then the `Draining`
|
||||
status will be cleared.
|
||||
|
||||
If the softfailing and unsoftfailing is initiated using the `softfail`
|
||||
and `unsoftfail` commands of the Clustrix monitor, then there will be
|
||||
and `unsoftfail` commands of the Xpand monitor, then there will be
|
||||
no delay between the softfailing or unsoftfailing being initated and the
|
||||
`Draining` status being turned on/off.
|
@ -120,22 +120,20 @@ value of `threads`.
|
||||
"type": "threads",
|
||||
"attributes": {
|
||||
"stats": {
|
||||
"reads": 2,
|
||||
"writes": 0,
|
||||
"errors": 0,
|
||||
"hangups": 0,
|
||||
"accepts": 0,
|
||||
"blocking_polls": 180,
|
||||
"event_queue_length": 1,
|
||||
"max_event_queue_length": 1,
|
||||
"max_exec_time": 0,
|
||||
"max_queue_time": 0,
|
||||
"current_descriptors": 1,
|
||||
"total_descriptors": 1,
|
||||
"load": {
|
||||
"last_second": 0,
|
||||
"last_minute": 0,
|
||||
"last_hour": 0
|
||||
"reads": 2, // Number of EPOLLIN events
|
||||
"writes": 0, // number of EPOLLOUT events
|
||||
"errors": 0, // Number of EPOLLERR events
|
||||
"hangups": 0, // Number of EPOLLHUP or EPOLLRDHUP events
|
||||
"accepts": 0, // Number of EPOLLIN events for listeners
|
||||
"max_event_queue_length": 1, // Maximum number of events returned by epoll
|
||||
"max_exec_time": 0, // Maximum number of internal ticks (100ms per tick) an event took to execute
|
||||
"max_queue_time": 0, // Maximum number of internal ticks that an event waited in the queue
|
||||
"current_descriptors": 1, // How many file descriptors this thread is handling
|
||||
"total_descriptors": 1, // Total number of file descriptors added to this thread
|
||||
"load": { // Thread load in percentages i.e. 100 is 100%
|
||||
"last_second": 0, // Load over the past second
|
||||
"last_minute": 0, // Load over the past minute
|
||||
"last_hour": 0 // Load over the past hour
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -1,16 +1,19 @@
|
||||
# Configuring the Clustrix Monitor
|
||||
# Configuring the Xpand Monitor
|
||||
|
||||
This document describes how to configure the Clustrix monitor for use
|
||||
with a Clustrix cluster.
|
||||
**NOTE** The Xpand monitor is intended for use with a native Xpand
|
||||
cluster, not with the Xpand storage engine.
|
||||
|
||||
This document describes how to configure the Xpand monitor for use
|
||||
with a Xpand cluster.
|
||||
|
||||
## Configuring the Monitor
|
||||
|
||||
Contrary to the other monitors of MaxScale, the Clustrix monitor will
|
||||
autonomously figure out the cluster configuration and for each Clustrix
|
||||
Contrary to the other monitors of MaxScale, the Xpand monitor will
|
||||
autonomously figure out the cluster configuration and for each Xpand
|
||||
node create the corresponding MaxScale server object.
|
||||
|
||||
In order to do that, a _sufficient_ number of "bootstrap" server instances
|
||||
must be specified in the MaxScale configuration file for the Clustrix
|
||||
must be specified in the MaxScale configuration file for the Xpand
|
||||
monitor to start with. One server instance is in principle sufficient, but
|
||||
if the corresponding node happens to be down when MaxScale starts, the
|
||||
monitor will not be able to function.
|
||||
@ -30,14 +33,14 @@ protocol=mariadbbackend
|
||||
```
|
||||
|
||||
The server configuration is identical with that of any other server, but since
|
||||
these servers are _only_ used for bootstrapping the Clustrix monitor it is
|
||||
these servers are _only_ used for bootstrapping the Xpand monitor it is
|
||||
adviceable to use names that clearly will identify them as such.
|
||||
|
||||
The actual Clustrix monitor configuration looks as follows:
|
||||
The actual Xpand monitor configuration looks as follows:
|
||||
```
|
||||
[Clustrix]
|
||||
[Xpand]
|
||||
type=monitor
|
||||
module=clustrixmon
|
||||
module=xpandmon
|
||||
servers=Bootstrap1, Bootstrap2
|
||||
user=monitor_user
|
||||
password=monitor_password
|
||||
@ -56,19 +59,19 @@ is, access the `system` tables of the Cluster for checking the Cluster
|
||||
configuration. The default values are `2000` and `60000`, that is, 2 seconds
|
||||
and 1 minute, respectively.
|
||||
|
||||
For each detected Clustrix node a corresponding MaxScale server object will be
|
||||
For each detected Xpand node a corresponding MaxScale server object will be
|
||||
created, whose name is `@@<Monitor-Name>:node-<id>, where _Monitor-Name_
|
||||
is the name of the monitor, in this example `Clustrix` and _id_ is the node id
|
||||
of the Clustrix node. So, with a cluster of three nodes, the created servers
|
||||
is the name of the monitor, in this example `Xpand` and _id_ is the node id
|
||||
of the Xpand node. So, with a cluster of three nodes, the created servers
|
||||
might be named like.
|
||||
|
||||
```
|
||||
@@Clustrix:node-2`
|
||||
@@Clustrix:node-3`
|
||||
@@Clustrix:node-7`
|
||||
@@Xpand:node-2`
|
||||
@@Xpand:node-3`
|
||||
@@Xpand:node-7`
|
||||
```
|
||||
Note that as these are created at runtime and may disappear at any moment,
|
||||
depending on changes happening in and made to the Clustrix cluster, they
|
||||
depending on changes happening in and made to the Xpand cluster, they
|
||||
should never be referred to directly from service configurations. Instead,
|
||||
services should refer to the monitor, as shown in the following:
|
||||
```
|
||||
@ -77,12 +80,12 @@ type=service
|
||||
router=readconnroute
|
||||
user=service_user
|
||||
password=service_password
|
||||
cluster=Clustrix
|
||||
cluster=Xpand
|
||||
```
|
||||
Instead of listing the servers of the service explicitly using the `servers`
|
||||
parameter as usually is the case, the service refers to the Clustrix monitor
|
||||
using the `cluster` parameter. This will cause the service to use the Clustrix
|
||||
nodes that the Clustrix monitor discovers at runtime.
|
||||
parameter as usually is the case, the service refers to the Xpand monitor
|
||||
using the `cluster` parameter. This will cause the service to use the Xpand
|
||||
nodes that the Xpand monitor discovers at runtime.
|
||||
|
||||
For additional details, please consult the monitor
|
||||
[documentation](../Monitors/Clustrix-Monitor.md).
|
||||
[documentation](../Monitors/Xpand-Monitor.md).
|
@ -1,28 +1,31 @@
|
||||
# MaxScale and Clustrix Tutorial
|
||||
# MaxScale and Xpand Tutorial
|
||||
|
||||
Since version 2.4, MaxScale has built-in support for Clustrix. This
|
||||
tutorial explains how to setup MaxScale in front of a Clustrix
|
||||
**NOTE** The Xpand monitor is intended for use with a native Xpand
|
||||
cluster, not with the Xpand storage engine.
|
||||
|
||||
Since version 2.4, MaxScale has built-in support for Xpand. This
|
||||
tutorial explains how to setup MaxScale in front of a Xpand
|
||||
cluster.
|
||||
|
||||
There is no Clustrix specific router, but both the
|
||||
There is no Xpand specific router, but both the
|
||||
[readconnroute](../Routers/ReadConnRoute.md) and
|
||||
the [readwritesplit](../Routers/ReadWriteSplit.md) routers can be
|
||||
used.
|
||||
|
||||
## Clustrix and Readconnroute
|
||||
## Xpand and Readconnroute
|
||||
|
||||
With _readconnroute_ you get simple connection based routing, where
|
||||
each new connection is created (by default) to the Clustrix node with
|
||||
each new connection is created (by default) to the Xpand node with
|
||||
the least amount of existing connections. That is, with readconnroute
|
||||
the behaviour will be very similar to the behaviour when
|
||||
[HAProxy](http://www.haproxy.org) is used as the Clustrix load
|
||||
[HAProxy](http://www.haproxy.org) is used as the Xpand load
|
||||
balancer.
|
||||
|
||||
### Bootstrap servers
|
||||
|
||||
The Clustrix monitor is capable of autonomously figuring out the cluster
|
||||
The Xpand monitor is capable of autonomously figuring out the cluster
|
||||
configuration, but in order to get going there must be at least one
|
||||
_server_-section referring to a node in the Clustrix cluster.
|
||||
_server_-section referring to a node in the Xpand cluster.
|
||||
```
|
||||
[Bootstrap-1]
|
||||
type=server
|
||||
@ -31,31 +34,31 @@ port=3306
|
||||
protocol=MySQLBackend
|
||||
```
|
||||
That server defintion will be used by the monitor in order to connect
|
||||
to the Clustrix cluster. There can be more than one such "bootstrap"
|
||||
to the Xpand cluster. There can be more than one such "bootstrap"
|
||||
definition to cater for the case that the node used as a bootstrap
|
||||
server is down when MaxScale starts.
|
||||
|
||||
**NOTE** These bootstrap servers should _only_ be referred to from the
|
||||
Clustrix monitor configuration, but _never_ from a service.
|
||||
Xpand monitor configuration, but _never_ from a service.
|
||||
|
||||
### Monitor
|
||||
|
||||
In the Clustrix monitor section, the bootstrap servers are referred to
|
||||
In the Xpand monitor section, the bootstrap servers are referred to
|
||||
in the same way as "ordinary" servers are referred to in other monitors.
|
||||
```
|
||||
[Clustrix]
|
||||
[Xpand]
|
||||
type=monitor
|
||||
module=clustrixmon
|
||||
module=xpandmon
|
||||
servers=Bootstrap-1
|
||||
user=USER
|
||||
password=PASSWORD
|
||||
```
|
||||
The bootstrap servers are only used for connecting to the Clustrix
|
||||
cluster; thereafter the Clustrix monitor will dynamically find out the
|
||||
The bootstrap servers are only used for connecting to the Xpand
|
||||
cluster; thereafter the Xpand monitor will dynamically find out the
|
||||
cluster configuration.
|
||||
|
||||
The discovered cluster configuration will be stored (the ips and ports
|
||||
of the Clustrix nodes) and upon subsequent restarts the Clustrix
|
||||
of the Xpand nodes) and upon subsequent restarts the Xpand
|
||||
monitor will use that information if the bootstrap servers happen to
|
||||
be unavailable.
|
||||
|
||||
@ -65,11 +68,11 @@ the following:
|
||||
┌───────────────────┬──────────────┬──────┬─────────────┬─────────────────┬──────┐
|
||||
│ Server │ Address │ Port │ Connections │ State │ GTID │
|
||||
├───────────────────┼──────────────┼──────┼─────────────┼─────────────────┼──────┤
|
||||
│ @@Clustrix:node-7 │ 10.2.224.102 │ 3306 │ 0 │ Master, Running │ │
|
||||
│ @@Xpand:node-7 │ 10.2.224.102 │ 3306 │ 0 │ Master, Running │ │
|
||||
├───────────────────┼──────────────┼──────┼─────────────┼─────────────────┼──────┤
|
||||
│ @@Clustrix:node-8 │ 10.2.224.103 │ 3306 │ 0 │ Master, Running │ │
|
||||
│ @@Xpand:node-8 │ 10.2.224.103 │ 3306 │ 0 │ Master, Running │ │
|
||||
├───────────────────┼──────────────┼──────┼─────────────┼─────────────────┼──────┤
|
||||
│ @@Clustrix:node-6 │ 10.2.224.101 │ 3306 │ 0 │ Master, Running │ │
|
||||
│ @@Xpand:node-6 │ 10.2.224.101 │ 3306 │ 0 │ Master, Running │ │
|
||||
├───────────────────┼──────────────┼──────┼─────────────┼─────────────────┼──────┤
|
||||
│ Bootstrap-1 │ 10.2.224.101 │ 3306 │ 0 │ Master, Running │ │
|
||||
└───────────────────┴──────────────┴──────┴─────────────┴─────────────────┴──────┘
|
||||
@ -77,29 +80,29 @@ the following:
|
||||
All servers whose name start with `@@` have been detected dynamically.
|
||||
|
||||
Note that the address `10.2.224.101` appears twice; once for
|
||||
`Bootstrap-1` and another time for `@@Clustrix:node-6`. The Clustrix
|
||||
`Bootstrap-1` and another time for `@@Xpand:node-6`. The Xpand
|
||||
monitor will create a dynamic server instance for _all_ nodes in the
|
||||
Clustrix cluster; also for the ones used in bootstrap server sections.
|
||||
Xpand cluster; also for the ones used in bootstrap server sections.
|
||||
|
||||
### Service
|
||||
|
||||
The service is specified as follows:
|
||||
```
|
||||
[Clustrix-Service]
|
||||
[Xpand-Service]
|
||||
type=service
|
||||
router=readconnroute
|
||||
user=USER
|
||||
password=PASSWORD
|
||||
cluster=Clustrix
|
||||
cluster=Xpand
|
||||
```
|
||||
Note that the service does *not* list any specific servers, but
|
||||
instead refers, using the argument `cluster`, to the Clustrix monitor.
|
||||
instead refers, using the argument `cluster`, to the Xpand monitor.
|
||||
|
||||
In practice this means that the service will use the servers of the
|
||||
monitor named `Clustrix` and in the case of a Clustrix monitor those
|
||||
monitor named `Xpand` and in the case of a Xpand monitor those
|
||||
servers will be the ones that the monitor has detected
|
||||
dynamically. That is, when setup like this, the service will
|
||||
automatically adjust to any changes taking place in the Clustrix
|
||||
automatically adjust to any changes taking place in the Xpand
|
||||
cluster.
|
||||
|
||||
**NOTE** There is no need to specify any `router_options`, but the
|
||||
@ -111,25 +114,25 @@ cause only a _single_ node to be used.
|
||||
|
||||
To complete the configuration, a listener must be specified.
|
||||
```
|
||||
[Clustrix-Service-Listener]
|
||||
[Xpand-Service-Listener]
|
||||
type=listener
|
||||
service=Clustrix-Service
|
||||
service=Xpand-Service
|
||||
protocol=MariaDBClient
|
||||
port=4008
|
||||
```
|
||||
|
||||
## Clustrix and Readwritesplit
|
||||
## Xpand and Readwritesplit
|
||||
|
||||
The primary purpose of the router _readwritesplit_ is to split
|
||||
statements between one master and multiple slaves. In the case of
|
||||
Clustrix, all servers will be masters, but _readwritesplit_ may still
|
||||
Xpand, all servers will be masters, but _readwritesplit_ may still
|
||||
be the right choise.
|
||||
|
||||
Namely, as _readwritesplit_ is transaction aware and capable of
|
||||
replaying transactions, it can be used for hiding certain events
|
||||
taking place in Clustrix from the clients that use it.
|
||||
taking place in Xpand from the clients that use it.
|
||||
|
||||
For instance, whenever a node is removed from or added to a Clustrix
|
||||
For instance, whenever a node is removed from or added to a Xpand
|
||||
cluster there will be a _group change_, which is visible to a client
|
||||
as a transaction rollback. However, if _readwritesplit_ is used and
|
||||
transaction replay is enabled, then MaxScale may be able to hide the
|
||||
@ -143,12 +146,12 @@ described above.
|
||||
|
||||
The service is specified as follows:
|
||||
```
|
||||
[Clustrix-Service]
|
||||
[Xpand-Service]
|
||||
type=service
|
||||
router=readwritesplit
|
||||
user=maxscale
|
||||
password=maxscale
|
||||
cluster=Clustrix
|
||||
cluster=Xpand
|
||||
transaction_replay=true
|
||||
slave_selection_criteria=LEAST_GLOBAL_CONNECTIONS
|
||||
```
|
||||
@ -163,7 +166,7 @@ to the _readwritesplit_
|
||||
|
||||
**NOTE** It is vital to have
|
||||
`slave_selection_criteria=LEAST_GLOBAL_CONNECTIONS`, as otherwise
|
||||
connections will **not** be distributed evenly across all Clustrix
|
||||
connections will **not** be distributed evenly across all Xpand
|
||||
nodes.
|
||||
|
||||
As a rule of thumb, use _readwritesplit_ if it is important that
|
@ -65,6 +65,7 @@ struct NAME_MAPPING
|
||||
|
||||
static NAME_MAPPING name_mappings[] =
|
||||
{
|
||||
{MODULE_MONITOR, "clustrixmon", "xpandmon", false},
|
||||
{MODULE_MONITOR, "mysqlmon", "mariadbmon", false},
|
||||
{MODULE_PROTOCOL, "mysqlclient", "mariadbclient", false},
|
||||
{MODULE_PROTOCOL, "mysqlbackend", "mariadbbackend", false},
|
||||
|
@ -1,6 +1,6 @@
|
||||
add_subdirectory(auroramon)
|
||||
add_subdirectory(clustrixmon)
|
||||
add_subdirectory(csmon)
|
||||
add_subdirectory(galeramon)
|
||||
add_subdirectory(grmon)
|
||||
add_subdirectory(mariadbmon)
|
||||
add_subdirectory(xpandmon)
|
||||
|
@ -1,9 +0,0 @@
|
||||
add_library(clustrixmon SHARED
|
||||
clustrix.cc
|
||||
clustrixmon.cc
|
||||
clustrixmonitor.cc
|
||||
clustrixnode.cc
|
||||
)
|
||||
target_link_libraries(clustrixmon maxscale-common)
|
||||
set_target_properties(clustrixmon PROPERTIES VERSION "1.0.0" LINK_FLAGS -Wl,-z,defs)
|
||||
install_module(clustrixmon core)
|
9
server/modules/monitor/xpandmon/CMakeLists.txt
Normal file
9
server/modules/monitor/xpandmon/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
||||
add_library(xpandmon SHARED
|
||||
xpand.cc
|
||||
xpandmon.cc
|
||||
xpandmonitor.cc
|
||||
xpandnode.cc
|
||||
)
|
||||
target_link_libraries(xpandmon maxscale-common)
|
||||
set_target_properties(xpandmon PROPERTIES VERSION "1.0.0" LINK_FLAGS -Wl,-z,defs)
|
||||
install_module(xpandmon core)
|
@ -11,7 +11,7 @@
|
||||
* Public License.
|
||||
*/
|
||||
|
||||
#include "clustrix.hh"
|
||||
#include "xpand.hh"
|
||||
#include <maxbase/assert.h>
|
||||
|
||||
using maxscale::Monitor;
|
||||
@ -27,7 +27,7 @@ const char CN_STATIC[] = "static";
|
||||
const char CN_UNKNOWN[] = "unknown";
|
||||
}
|
||||
|
||||
std::string Clustrix::to_string(Clustrix::Status status)
|
||||
std::string xpand::to_string(xpand::Status status)
|
||||
{
|
||||
switch (status)
|
||||
{
|
||||
@ -48,7 +48,7 @@ std::string Clustrix::to_string(Clustrix::Status status)
|
||||
return CN_UNKNOWN;
|
||||
}
|
||||
|
||||
Clustrix::Status Clustrix::status_from_string(const std::string& status)
|
||||
xpand::Status xpand::status_from_string(const std::string& status)
|
||||
{
|
||||
if (status == CN_QUORUM)
|
||||
{
|
||||
@ -64,12 +64,12 @@ Clustrix::Status Clustrix::status_from_string(const std::string& status)
|
||||
}
|
||||
else
|
||||
{
|
||||
MXB_WARNING("'%s' is an unknown status for a Clustrix node.", status.c_str());
|
||||
MXB_WARNING("'%s' is an unknown status for a Xpand node.", status.c_str());
|
||||
return Status::UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
std::string Clustrix::to_string(Clustrix::SubState substate)
|
||||
std::string xpand::to_string(xpand::SubState substate)
|
||||
{
|
||||
switch (substate)
|
||||
{
|
||||
@ -84,7 +84,7 @@ std::string Clustrix::to_string(Clustrix::SubState substate)
|
||||
return CN_UNKNOWN;
|
||||
}
|
||||
|
||||
Clustrix::SubState Clustrix::substate_from_string(const std::string& substate)
|
||||
xpand::SubState xpand::substate_from_string(const std::string& substate)
|
||||
{
|
||||
if (substate == CN_NORMAL)
|
||||
{
|
||||
@ -92,12 +92,12 @@ Clustrix::SubState Clustrix::substate_from_string(const std::string& substate)
|
||||
}
|
||||
else
|
||||
{
|
||||
MXB_WARNING("'%s' is an unknown sub-state for a Clustrix node.", substate.c_str());
|
||||
MXB_WARNING("'%s' is an unknown sub-state for a Xpand node.", substate.c_str());
|
||||
return SubState::UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
bool Clustrix::is_part_of_the_quorum(const char* zName, MYSQL* pCon)
|
||||
bool xpand::is_part_of_the_quorum(const char* zName, MYSQL* pCon)
|
||||
{
|
||||
bool rv = false;
|
||||
|
||||
@ -114,27 +114,27 @@ bool Clustrix::is_part_of_the_quorum(const char* zName, MYSQL* pCon)
|
||||
MYSQL_ROW row = mysql_fetch_row(pResult);
|
||||
if (row && row[0])
|
||||
{
|
||||
Clustrix::Status status = Clustrix::status_from_string(row[0]);
|
||||
xpand::Status status = xpand::status_from_string(row[0]);
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case Clustrix::Status::QUORUM:
|
||||
case xpand::Status::QUORUM:
|
||||
rv = true;
|
||||
break;
|
||||
|
||||
case Clustrix::Status::STATIC:
|
||||
case xpand::Status::STATIC:
|
||||
MXS_NOTICE("%s: Node %s is not part of the quorum (static), switching to "
|
||||
"other node for monitoring.",
|
||||
zName, mysql_get_host_info(pCon));
|
||||
break;
|
||||
|
||||
case Clustrix::Status::DYNAMIC:
|
||||
case xpand::Status::DYNAMIC:
|
||||
MXS_NOTICE("%s: Node %s is not part of the quorum (dynamic), switching to "
|
||||
"other node for monitoring.",
|
||||
zName, mysql_get_host_info(pCon));
|
||||
break;
|
||||
|
||||
case Clustrix::Status::UNKNOWN:
|
||||
case xpand::Status::UNKNOWN:
|
||||
MXS_WARNING("%s: Do not know how to interpret '%s'. Assuming node %s "
|
||||
"is not part of the quorum.",
|
||||
zName, row[0], mysql_get_host_info(pCon));
|
||||
@ -163,7 +163,7 @@ bool Clustrix::is_part_of_the_quorum(const char* zName, MYSQL* pCon)
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool Clustrix::is_being_softfailed(const char* zName, MYSQL* pCon)
|
||||
bool xpand::is_being_softfailed(const char* zName, MYSQL* pCon)
|
||||
{
|
||||
bool rv = false;
|
||||
|
||||
@ -201,7 +201,7 @@ bool Clustrix::is_being_softfailed(const char* zName, MYSQL* pCon)
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool Clustrix::ping_or_connect_to_hub(const char* zName,
|
||||
bool xpand::ping_or_connect_to_hub(const char* zName,
|
||||
const MonitorServer::ConnectionSettings& settings,
|
||||
Softfailed softfailed,
|
||||
SERVER& server,
|
||||
@ -212,11 +212,11 @@ bool Clustrix::ping_or_connect_to_hub(const char* zName,
|
||||
|
||||
if (Monitor::connection_is_ok(rv))
|
||||
{
|
||||
if (Clustrix::is_part_of_the_quorum(zName, *ppCon))
|
||||
if (xpand::is_part_of_the_quorum(zName, *ppCon))
|
||||
{
|
||||
if ((softfailed == Softfailed::REJECT) && Clustrix::is_being_softfailed(zName, *ppCon))
|
||||
if ((softfailed == Softfailed::REJECT) && xpand::is_being_softfailed(zName, *ppCon))
|
||||
{
|
||||
MXS_NOTICE("%s: The Clustrix node %s used as hub is part of the quorum, "
|
||||
MXS_NOTICE("%s: The Xpand node %s used as hub is part of the quorum, "
|
||||
"but it is being softfailed. Switching to another node.",
|
||||
zName, server.address);
|
||||
}
|
@ -12,12 +12,12 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "clustrixmon.hh"
|
||||
#include "xpandmon.hh"
|
||||
#include <string>
|
||||
#include <maxscale/monitor.hh>
|
||||
#include <maxscale/server.hh>
|
||||
|
||||
namespace Clustrix
|
||||
namespace xpand
|
||||
{
|
||||
|
||||
enum class Status
|
||||
@ -47,9 +47,9 @@ enum class Softfailed
|
||||
};
|
||||
|
||||
/**
|
||||
* Is a particular Clustrix node part of the quorum.
|
||||
* Is a particular Xpand node part of the quorum.
|
||||
*
|
||||
* @param zName The name of the Clustrix monitor instance.
|
||||
* @param zName The name of the Xpand monitor instance.
|
||||
* @param pCon Valid MYSQL handle to the server.
|
||||
*
|
||||
* @return True, if the node is part of the quorum, false otherwise.
|
||||
@ -57,10 +57,10 @@ enum class Softfailed
|
||||
bool is_part_of_the_quorum(const char* zName, MYSQL* pCon);
|
||||
|
||||
/**
|
||||
* Is a particular Clustrix node part of the quorum.
|
||||
* Is a particular Xpand node part of the quorum.
|
||||
*
|
||||
* @param zName The name of the Clustrix monitor instance.
|
||||
* @param ms The monitored server object of a Clustrix node.
|
||||
* @param zName The name of the Xpand monitor instance.
|
||||
* @param ms The monitored server object of a Xpand node.
|
||||
*
|
||||
* @return True, if the node is part of the quorum, false otherwise.
|
||||
*/
|
||||
@ -72,9 +72,9 @@ inline bool is_part_of_the_quorum(const char* zName, mxs::MonitorServer& ms)
|
||||
}
|
||||
|
||||
/**
|
||||
* Is a particular Clustrix node being softfailed.
|
||||
* Is a particular Xpand node being softfailed.
|
||||
*
|
||||
* @param zName The name of the Clustrix monitor instance.
|
||||
* @param zName The name of the Xpand monitor instance.
|
||||
* @param pCon Valid MYSQL handle to the server.
|
||||
*
|
||||
* @return True, if the node is being softfailed, false otherwise.
|
||||
@ -85,10 +85,10 @@ bool is_being_softfailed(const char* zName, MYSQL* pCon);
|
||||
* Ping or create connection to server and check whether it can be used
|
||||
* as hub.
|
||||
*
|
||||
* @param zName The name of the Clustrix monitor instance.
|
||||
* @param zName The name of the Xpand monitor instance.
|
||||
* @param settings Connection settings
|
||||
* @param softfailed Whether a softfailed node is considered ok or not.
|
||||
* @param server Server object referring to a Clustrix node.
|
||||
* @param server Server object referring to a Xpand node.
|
||||
* @param ppCon Address of pointer to MYSQL object referring to @server
|
||||
* (@c *ppCon may also be NULL).
|
||||
*
|
||||
@ -106,7 +106,7 @@ bool ping_or_connect_to_hub(const char* zName,
|
||||
* Ping or create connection to server and check whether it can be used
|
||||
* as hub.
|
||||
*
|
||||
* @param zName The name of the Clustrix monitor instance.
|
||||
* @param zName The name of the Xpand monitor instance.
|
||||
* @param settings Connection settings
|
||||
* @param softfailed Whether a softfailed node is considered ok or not.
|
||||
* @param ms The monitored server.
|
@ -12,18 +12,18 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "clustrixmon.hh"
|
||||
#include "xpandmon.hh"
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include "clustrix.hh"
|
||||
#include "xpand.hh"
|
||||
|
||||
class ClustrixMembership
|
||||
class XpandMembership
|
||||
{
|
||||
public:
|
||||
ClustrixMembership(int id,
|
||||
Clustrix::Status status,
|
||||
Clustrix::SubState substate,
|
||||
XpandMembership(int id,
|
||||
xpand::Status status,
|
||||
xpand::SubState substate,
|
||||
int instance)
|
||||
: m_id(id)
|
||||
, m_status(status)
|
||||
@ -37,12 +37,12 @@ public:
|
||||
return m_id;
|
||||
}
|
||||
|
||||
Clustrix::Status status() const
|
||||
xpand::Status status() const
|
||||
{
|
||||
return m_status;
|
||||
}
|
||||
|
||||
Clustrix::SubState substate() const
|
||||
xpand::SubState substate() const
|
||||
{
|
||||
return m_substate;
|
||||
}
|
||||
@ -57,8 +57,8 @@ public:
|
||||
std::stringstream ss;
|
||||
ss << "{"
|
||||
<< m_id << ", "
|
||||
<< Clustrix::to_string(m_status) << ", "
|
||||
<< Clustrix::to_string(m_substate) << ", "
|
||||
<< xpand::to_string(m_status) << ", "
|
||||
<< xpand::to_string(m_substate) << ", "
|
||||
<< m_instance
|
||||
<< "}";
|
||||
return ss.str();
|
||||
@ -71,12 +71,12 @@ public:
|
||||
|
||||
private:
|
||||
int m_id;
|
||||
Clustrix::Status m_status;
|
||||
Clustrix::SubState m_substate;
|
||||
xpand::Status m_status;
|
||||
xpand::SubState m_substate;
|
||||
int m_instance;
|
||||
};
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& out, const ClustrixMembership& x)
|
||||
inline std::ostream& operator<<(std::ostream& out, const XpandMembership& x)
|
||||
{
|
||||
x.print(out);
|
||||
return out;
|
@ -11,10 +11,10 @@
|
||||
* Public License.
|
||||
*/
|
||||
|
||||
#include "clustrixmon.hh"
|
||||
#include "xpandmon.hh"
|
||||
#include <maxscale/modinfo.h>
|
||||
#include <maxscale/modulecmd.hh>
|
||||
#include "clustrixmonitor.hh"
|
||||
#include "xpandmonitor.hh"
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -25,7 +25,7 @@ bool handle_softfail(const MODULECMD_ARG* args, json_t** error_out)
|
||||
mxb_assert(MODULECMD_GET_TYPE(&args->argv[0].type) == MODULECMD_ARG_MONITOR);
|
||||
mxb_assert(MODULECMD_GET_TYPE(&args->argv[1].type) == MODULECMD_ARG_SERVER);
|
||||
|
||||
ClustrixMonitor* pMon = static_cast<ClustrixMonitor*>(args->argv[0].value.monitor);
|
||||
XpandMonitor* pMon = static_cast<XpandMonitor*>(args->argv[0].value.monitor);
|
||||
SERVER* pServer = args->argv[1].value.server;
|
||||
|
||||
return pMon->softfail(pServer, error_out);
|
||||
@ -37,7 +37,7 @@ bool handle_unsoftfail(const MODULECMD_ARG* args, json_t** error_out)
|
||||
mxb_assert(MODULECMD_GET_TYPE(&args->argv[0].type) == MODULECMD_ARG_MONITOR);
|
||||
mxb_assert(MODULECMD_GET_TYPE(&args->argv[1].type) == MODULECMD_ARG_SERVER);
|
||||
|
||||
ClustrixMonitor* pMon = static_cast<ClustrixMonitor*>(args->argv[0].value.monitor);
|
||||
XpandMonitor* pMon = static_cast<XpandMonitor*>(args->argv[0].value.monitor);
|
||||
SERVER* pServer = args->argv[1].value.server;
|
||||
|
||||
return pMon->unsoftfail(pServer, error_out);
|
||||
@ -54,7 +54,7 @@ bool handle_unsoftfail(const MODULECMD_ARG* args, json_t** error_out)
|
||||
*/
|
||||
extern "C" MXS_MODULE* MXS_CREATE_MODULE()
|
||||
{
|
||||
MXS_NOTICE("Initialise the MariaDB Clustrix Monitor module.");
|
||||
MXS_NOTICE("Initialise the MariaDB Xpand Monitor module.");
|
||||
|
||||
static modulecmd_arg_type_t softfail_argv[] =
|
||||
{
|
||||
@ -91,17 +91,17 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
|
||||
MXS_MODULE_API_MONITOR,
|
||||
MXS_MODULE_GA,
|
||||
MXS_MONITOR_VERSION,
|
||||
"A Clustrix cluster monitor",
|
||||
"A Xpand cluster monitor",
|
||||
"V1.0.0",
|
||||
MXS_NO_MODULE_CAPABILITIES,
|
||||
&maxscale::MonitorApi<ClustrixMonitor>::s_api,
|
||||
&maxscale::MonitorApi<XpandMonitor>::s_api,
|
||||
NULL, /* Process init. */
|
||||
NULL, /* Process finish. */
|
||||
NULL, /* Thread init. */
|
||||
NULL, /* Thread finish. */
|
||||
};
|
||||
|
||||
ClustrixMonitor::Config::populate(info);
|
||||
XpandMonitor::Config::populate(info);
|
||||
|
||||
return &info;
|
||||
}
|
@ -12,7 +12,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#define MXS_MODULE_NAME "clustrixmon"
|
||||
#define MXS_MODULE_NAME "xpandmon"
|
||||
|
||||
#include <maxscale/ccdefs.hh>
|
||||
#include <maxbase/log.hh>
|
@ -11,7 +11,7 @@
|
||||
* Public License.
|
||||
*/
|
||||
|
||||
#include "clustrixmonitor.hh"
|
||||
#include "xpandmonitor.hh"
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include <maxbase/string.hh>
|
||||
@ -38,7 +38,7 @@ using maxscale::MonitorServer;
|
||||
namespace
|
||||
{
|
||||
|
||||
namespace clustrixmon
|
||||
namespace xpandmon
|
||||
{
|
||||
|
||||
config::Specification specification(MXS_MODULE_NAME, config::Specification::MONITOR);
|
||||
@ -46,7 +46,7 @@ config::Specification specification(MXS_MODULE_NAME, config::Specification::MONI
|
||||
config::ParamDuration<std::chrono::milliseconds>
|
||||
cluster_monitor_interval(&specification,
|
||||
"cluster_monitor_interval",
|
||||
"How frequently the Clustrix monitor should perform a cluster check.",
|
||||
"How frequently the Xpand monitor should perform a cluster check.",
|
||||
mxs::config::INTERPRET_AS_MILLISECONDS,
|
||||
std::chrono::milliseconds(DEFAULT_CLUSTER_MONITOR_INTERVAL));
|
||||
|
||||
@ -66,7 +66,7 @@ dynamic_node_detection(&specification,
|
||||
config::ParamInteger
|
||||
health_check_port(&specification,
|
||||
"health_check_port",
|
||||
"Port number for Clustrix health check.",
|
||||
"Port number for Xpand health check.",
|
||||
DEFAULT_HEALTH_CHECK_PORT,
|
||||
0, std::numeric_limits<uint16_t>::max()); // min, max
|
||||
|
||||
@ -186,7 +186,7 @@ sqlite3* open_or_create_db(const std::string& path)
|
||||
path.c_str(), sqlite3_errmsg(pDb));
|
||||
}
|
||||
MXS_ERROR("Could not open sqlite3 database for storing information "
|
||||
"about dynamically detected Clustrix nodes. The Clustrix "
|
||||
"about dynamically detected Xpand nodes. The Xpand "
|
||||
"monitor will remain dependent upon statically defined "
|
||||
"bootstrap nodes.");
|
||||
}
|
||||
@ -195,40 +195,40 @@ sqlite3* open_or_create_db(const std::string& path)
|
||||
}
|
||||
}
|
||||
|
||||
ClustrixMonitor::Config::Config(const std::string& name)
|
||||
: m_configuration(name, &clustrixmon::specification)
|
||||
, m_cluster_monitor_interval(&m_configuration, &clustrixmon::cluster_monitor_interval)
|
||||
, m_health_check_threshold(&m_configuration, &clustrixmon::health_check_threshold)
|
||||
, m_dynamic_node_detection(&m_configuration, &clustrixmon::dynamic_node_detection)
|
||||
, m_health_check_port(&m_configuration, &clustrixmon::health_check_port)
|
||||
XpandMonitor::Config::Config(const std::string& name)
|
||||
: m_configuration(name, &xpandmon::specification)
|
||||
, m_cluster_monitor_interval(&m_configuration, &xpandmon::cluster_monitor_interval)
|
||||
, m_health_check_threshold(&m_configuration, &xpandmon::health_check_threshold)
|
||||
, m_dynamic_node_detection(&m_configuration, &xpandmon::dynamic_node_detection)
|
||||
, m_health_check_port(&m_configuration, &xpandmon::health_check_port)
|
||||
{
|
||||
}
|
||||
|
||||
//static
|
||||
void ClustrixMonitor::Config::populate(MXS_MODULE& module)
|
||||
void XpandMonitor::Config::populate(MXS_MODULE& module)
|
||||
{
|
||||
clustrixmon::specification.populate(module);
|
||||
xpandmon::specification.populate(module);
|
||||
}
|
||||
|
||||
bool ClustrixMonitor::Config::configure(const MXS_CONFIG_PARAMETER& params)
|
||||
bool XpandMonitor::Config::configure(const MXS_CONFIG_PARAMETER& params)
|
||||
{
|
||||
return clustrixmon::specification.configure(m_configuration, params);
|
||||
return xpandmon::specification.configure(m_configuration, params);
|
||||
}
|
||||
|
||||
ClustrixMonitor::ClustrixMonitor(const string& name, const string& module, sqlite3* pDb)
|
||||
XpandMonitor::XpandMonitor(const string& name, const string& module, sqlite3* pDb)
|
||||
: MonitorWorker(name, module)
|
||||
, m_config(name)
|
||||
, m_pDb(pDb)
|
||||
{
|
||||
}
|
||||
|
||||
ClustrixMonitor::~ClustrixMonitor()
|
||||
XpandMonitor::~XpandMonitor()
|
||||
{
|
||||
sqlite3_close_v2(m_pDb);
|
||||
}
|
||||
|
||||
// static
|
||||
ClustrixMonitor* ClustrixMonitor::create(const string& name, const string& module)
|
||||
XpandMonitor* XpandMonitor::create(const string& name, const string& module)
|
||||
{
|
||||
string path = get_datadir();
|
||||
|
||||
@ -239,29 +239,29 @@ ClustrixMonitor* ClustrixMonitor::create(const string& name, const string& modul
|
||||
{
|
||||
MXS_ERROR("Could not create the directory %s, MaxScale will not be "
|
||||
"able to create database for persisting connection "
|
||||
"information of dynamically detected Clustrix nodes.",
|
||||
"information of dynamically detected Xpand nodes.",
|
||||
path.c_str());
|
||||
}
|
||||
|
||||
path += "/clustrix_nodes-v";
|
||||
path += "/xpand_nodes-v";
|
||||
path += std::to_string(SCHEMA_VERSION);
|
||||
path += ".db";
|
||||
|
||||
sqlite3* pDb = open_or_create_db(path);
|
||||
|
||||
ClustrixMonitor* pThis = nullptr;
|
||||
XpandMonitor* pThis = nullptr;
|
||||
|
||||
if (pDb)
|
||||
{
|
||||
// Even if the creation/opening of the sqlite3 database fails, we will still
|
||||
// get a valid database handle.
|
||||
pThis = new ClustrixMonitor(name, module, pDb);
|
||||
pThis = new XpandMonitor(name, module, pDb);
|
||||
}
|
||||
else
|
||||
{
|
||||
// The handle will be null, *only* if the opening fails due to a memory
|
||||
// allocation error.
|
||||
MXS_ALERT("sqlite3 memory allocation failed, the Clustrix monitor "
|
||||
MXS_ALERT("sqlite3 memory allocation failed, the Xpand monitor "
|
||||
"cannot continue.");
|
||||
}
|
||||
|
||||
@ -270,9 +270,9 @@ ClustrixMonitor* ClustrixMonitor::create(const string& name, const string& modul
|
||||
|
||||
using std::chrono::milliseconds;
|
||||
|
||||
bool ClustrixMonitor::configure(const MXS_CONFIG_PARAMETER* pParams)
|
||||
bool XpandMonitor::configure(const MXS_CONFIG_PARAMETER* pParams)
|
||||
{
|
||||
if (!clustrixmon::specification.validate(*pParams))
|
||||
if (!xpandmon::specification.validate(*pParams))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -294,16 +294,16 @@ bool ClustrixMonitor::configure(const MXS_CONFIG_PARAMETER* pParams)
|
||||
return true;
|
||||
}
|
||||
|
||||
void ClustrixMonitor::populate_services()
|
||||
void XpandMonitor::populate_services()
|
||||
{
|
||||
mxb_assert(!is_running());
|
||||
|
||||
// The servers that the Clustrix monitor has been configured with are
|
||||
// The servers that the Xpand monitor has been configured with are
|
||||
// only used for bootstrapping and services will not be populated
|
||||
// with them.
|
||||
}
|
||||
|
||||
bool ClustrixMonitor::softfail(SERVER* pServer, json_t** ppError)
|
||||
bool XpandMonitor::softfail(SERVER* pServer, json_t** ppError)
|
||||
{
|
||||
bool rv = false;
|
||||
|
||||
@ -325,7 +325,7 @@ bool ClustrixMonitor::softfail(SERVER* pServer, json_t** ppError)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ClustrixMonitor::unsoftfail(SERVER* pServer, json_t** ppError)
|
||||
bool XpandMonitor::unsoftfail(SERVER* pServer, json_t** ppError)
|
||||
{
|
||||
bool rv = false;
|
||||
|
||||
@ -347,26 +347,26 @@ bool ClustrixMonitor::unsoftfail(SERVER* pServer, json_t** ppError)
|
||||
return true;
|
||||
}
|
||||
|
||||
void ClustrixMonitor::server_added(SERVER* pServer)
|
||||
void XpandMonitor::server_added(SERVER* pServer)
|
||||
{
|
||||
// The servers explicitly added to the Cluster monitor are only used
|
||||
// as bootstrap servers, so they are not added to any services.
|
||||
}
|
||||
|
||||
void ClustrixMonitor::server_removed(SERVER* pServer)
|
||||
void XpandMonitor::server_removed(SERVER* pServer)
|
||||
{
|
||||
// @see server_added(), no action is needed.
|
||||
}
|
||||
|
||||
|
||||
void ClustrixMonitor::pre_loop()
|
||||
void XpandMonitor::pre_loop()
|
||||
{
|
||||
load_server_journal(nullptr);
|
||||
if (m_config.dynamic_node_detection())
|
||||
{
|
||||
// At startup we accept softfailed nodes in an attempt to be able to
|
||||
// connect at any cost. It'll be replaced once there is an alternative.
|
||||
check_cluster(Clustrix::Softfailed::ACCEPT);
|
||||
check_cluster(xpand::Softfailed::ACCEPT);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -376,7 +376,7 @@ void ClustrixMonitor::pre_loop()
|
||||
make_health_check();
|
||||
}
|
||||
|
||||
void ClustrixMonitor::post_loop()
|
||||
void XpandMonitor::post_loop()
|
||||
{
|
||||
if (m_pHub_con)
|
||||
{
|
||||
@ -387,12 +387,12 @@ void ClustrixMonitor::post_loop()
|
||||
m_pHub_server = nullptr;
|
||||
}
|
||||
|
||||
void ClustrixMonitor::tick()
|
||||
void XpandMonitor::tick()
|
||||
{
|
||||
check_maintenance_requests();
|
||||
if (m_config.dynamic_node_detection() && should_check_cluster())
|
||||
{
|
||||
check_cluster(Clustrix::Softfailed::REJECT);
|
||||
check_cluster(xpand::Softfailed::REJECT);
|
||||
}
|
||||
|
||||
switch (m_http.status())
|
||||
@ -418,7 +418,7 @@ void ClustrixMonitor::tick()
|
||||
store_server_journal(nullptr);
|
||||
}
|
||||
|
||||
void ClustrixMonitor::choose_hub(Clustrix::Softfailed softfailed)
|
||||
void XpandMonitor::choose_hub(xpand::Softfailed softfailed)
|
||||
{
|
||||
mxb_assert(!m_pHub_con);
|
||||
|
||||
@ -443,7 +443,7 @@ void ClustrixMonitor::choose_hub(Clustrix::Softfailed softfailed)
|
||||
|
||||
if (m_pHub_con)
|
||||
{
|
||||
MXS_NOTICE("%s: Monitoring Clustrix cluster state using node %s:%d.",
|
||||
MXS_NOTICE("%s: Monitoring Xpand cluster state using node %s:%d.",
|
||||
name(), m_pHub_server->address, m_pHub_server->port);
|
||||
}
|
||||
else
|
||||
@ -453,11 +453,11 @@ void ClustrixMonitor::choose_hub(Clustrix::Softfailed softfailed)
|
||||
}
|
||||
}
|
||||
|
||||
bool ClustrixMonitor::choose_dynamic_hub(Clustrix::Softfailed softfailed, std::set<string>& ips_checked)
|
||||
bool XpandMonitor::choose_dynamic_hub(xpand::Softfailed softfailed, std::set<string>& ips_checked)
|
||||
{
|
||||
for (auto& kv : m_nodes_by_id)
|
||||
{
|
||||
ClustrixNode& node = kv.second;
|
||||
XpandNode& node = kv.second;
|
||||
|
||||
if (node.can_be_used_as_hub(name(), settings().conn_settings, softfailed))
|
||||
{
|
||||
@ -476,13 +476,13 @@ bool ClustrixMonitor::choose_dynamic_hub(Clustrix::Softfailed softfailed, std::s
|
||||
return m_pHub_con != nullptr;
|
||||
}
|
||||
|
||||
bool ClustrixMonitor::choose_bootstrap_hub(Clustrix::Softfailed softfailed, std::set<string>& ips_checked)
|
||||
bool XpandMonitor::choose_bootstrap_hub(xpand::Softfailed softfailed, std::set<string>& ips_checked)
|
||||
{
|
||||
for (auto* pMs : servers())
|
||||
{
|
||||
if (ips_checked.find(pMs->server->address) == ips_checked.end())
|
||||
{
|
||||
if (Clustrix::ping_or_connect_to_hub(name(), settings().conn_settings, softfailed, *pMs))
|
||||
if (xpand::ping_or_connect_to_hub(name(), settings().conn_settings, softfailed, *pMs))
|
||||
{
|
||||
m_pHub_con = pMs->con;
|
||||
m_pHub_server = pMs->server;
|
||||
@ -504,9 +504,9 @@ bool ClustrixMonitor::choose_bootstrap_hub(Clustrix::Softfailed softfailed, std:
|
||||
return m_pHub_con != nullptr;
|
||||
}
|
||||
|
||||
bool ClustrixMonitor::refresh_using_persisted_nodes(std::set<string>& ips_checked)
|
||||
bool XpandMonitor::refresh_using_persisted_nodes(std::set<string>& ips_checked)
|
||||
{
|
||||
MXS_NOTICE("Attempting to find a Clustrix bootstrap node from one of the nodes "
|
||||
MXS_NOTICE("Attempting to find a Xpand bootstrap node from one of the nodes "
|
||||
"used during the previous run of MaxScale.");
|
||||
|
||||
bool refreshed = false;
|
||||
@ -543,7 +543,7 @@ bool ClustrixMonitor::refresh_using_persisted_nodes(std::set<string>& ips_checke
|
||||
nullptr,
|
||||
port, nullptr, 0))
|
||||
{
|
||||
if (Clustrix::is_part_of_the_quorum(name(), pHub_con))
|
||||
if (xpand::is_part_of_the_quorum(name(), pHub_con))
|
||||
{
|
||||
if (refresh_nodes(pHub_con))
|
||||
{
|
||||
@ -577,18 +577,18 @@ bool ClustrixMonitor::refresh_using_persisted_nodes(std::set<string>& ips_checke
|
||||
return refreshed;
|
||||
}
|
||||
|
||||
bool ClustrixMonitor::refresh_nodes()
|
||||
bool XpandMonitor::refresh_nodes()
|
||||
{
|
||||
mxb_assert(m_pHub_con);
|
||||
|
||||
return refresh_nodes(m_pHub_con);
|
||||
}
|
||||
|
||||
bool ClustrixMonitor::refresh_nodes(MYSQL* pHub_con)
|
||||
bool XpandMonitor::refresh_nodes(MYSQL* pHub_con)
|
||||
{
|
||||
mxb_assert(pHub_con);
|
||||
|
||||
map<int, ClustrixMembership> memberships;
|
||||
map<int, XpandMembership> memberships;
|
||||
|
||||
bool refreshed = check_cluster_membership(pHub_con, &memberships);
|
||||
|
||||
@ -610,7 +610,7 @@ bool ClustrixMonitor::refresh_nodes(MYSQL* pHub_con)
|
||||
set<int> nids;
|
||||
for (const auto& kv : m_nodes_by_id)
|
||||
{
|
||||
const ClustrixNode& node = kv.second;
|
||||
const XpandNode& node = kv.second;
|
||||
nids.insert(node.id());
|
||||
}
|
||||
|
||||
@ -626,7 +626,7 @@ bool ClustrixMonitor::refresh_nodes(MYSQL* pHub_con)
|
||||
bool softfailed = row[4] ? true : false;
|
||||
|
||||
// '@@' ensures no clash with user created servers.
|
||||
// Monitor name ensures no clash with other Clustrix monitor instances.
|
||||
// Monitor name ensures no clash with other Xpand monitor instances.
|
||||
string server_name = string("@@") + m_name + ":node-" + std::to_string(id);
|
||||
|
||||
auto nit = m_nodes_by_id.find(id);
|
||||
@ -637,7 +637,7 @@ bool ClustrixMonitor::refresh_nodes(MYSQL* pHub_con)
|
||||
// Existing node.
|
||||
mxb_assert(SERVER::find_by_unique_name(server_name));
|
||||
|
||||
ClustrixNode& node = nit->second;
|
||||
XpandNode& node = nit->second;
|
||||
|
||||
node.update(ip, mysql_port, health_port);
|
||||
|
||||
@ -684,10 +684,10 @@ bool ClustrixMonitor::refresh_nodes(MYSQL* pHub_con)
|
||||
pServer->set_status(SERVER_DRAINING);
|
||||
}
|
||||
|
||||
const ClustrixMembership& membership = mit->second;
|
||||
const XpandMembership& membership = mit->second;
|
||||
int health_check_threshold = m_config.health_check_threshold();
|
||||
|
||||
ClustrixNode node(this, membership, ip, mysql_port, health_port,
|
||||
XpandNode node(this, membership, ip, mysql_port, health_port,
|
||||
health_check_threshold, pServer);
|
||||
|
||||
m_nodes_by_id.insert(make_pair(id, node));
|
||||
@ -735,8 +735,8 @@ bool ClustrixMonitor::refresh_nodes(MYSQL* pHub_con)
|
||||
auto it = m_nodes_by_id.find(nid);
|
||||
mxb_assert(it != m_nodes_by_id.end());
|
||||
|
||||
ClustrixNode& node = it->second;
|
||||
node.set_running(false, ClustrixNode::APPROACH_OVERRIDE);
|
||||
XpandNode& node = it->second;
|
||||
node.set_running(false, XpandNode::APPROACH_OVERRIDE);
|
||||
}
|
||||
|
||||
cluster_checked();
|
||||
@ -762,7 +762,7 @@ bool ClustrixMonitor::refresh_nodes(MYSQL* pHub_con)
|
||||
return refreshed;
|
||||
}
|
||||
|
||||
void ClustrixMonitor::check_bootstrap_servers()
|
||||
void XpandMonitor::check_bootstrap_servers()
|
||||
{
|
||||
HostPortPairs nodes;
|
||||
char* pError = nullptr;
|
||||
@ -813,7 +813,7 @@ void ClustrixMonitor::check_bootstrap_servers()
|
||||
}
|
||||
}
|
||||
|
||||
bool ClustrixMonitor::remove_persisted_information()
|
||||
bool XpandMonitor::remove_persisted_information()
|
||||
{
|
||||
char* pError = nullptr;
|
||||
int rv;
|
||||
@ -833,7 +833,7 @@ bool ClustrixMonitor::remove_persisted_information()
|
||||
return rv1 == SQLITE_OK && rv2 == SQLITE_OK;
|
||||
}
|
||||
|
||||
void ClustrixMonitor::persist_bootstrap_servers()
|
||||
void XpandMonitor::persist_bootstrap_servers()
|
||||
{
|
||||
string values;
|
||||
|
||||
@ -871,7 +871,7 @@ void ClustrixMonitor::persist_bootstrap_servers()
|
||||
}
|
||||
}
|
||||
|
||||
void ClustrixMonitor::check_cluster(Clustrix::Softfailed softfailed)
|
||||
void XpandMonitor::check_cluster(xpand::Softfailed softfailed)
|
||||
{
|
||||
if (m_pHub_con)
|
||||
{
|
||||
@ -889,12 +889,12 @@ void ClustrixMonitor::check_cluster(Clustrix::Softfailed softfailed)
|
||||
}
|
||||
}
|
||||
|
||||
void ClustrixMonitor::check_hub(Clustrix::Softfailed softfailed)
|
||||
void XpandMonitor::check_hub(xpand::Softfailed softfailed)
|
||||
{
|
||||
mxb_assert(m_pHub_con);
|
||||
mxb_assert(m_pHub_server);
|
||||
|
||||
if (!Clustrix::ping_or_connect_to_hub(name(), settings().conn_settings, softfailed,
|
||||
if (!xpand::ping_or_connect_to_hub(name(), settings().conn_settings, softfailed,
|
||||
*m_pHub_server, &m_pHub_con))
|
||||
{
|
||||
mysql_close(m_pHub_con);
|
||||
@ -902,8 +902,8 @@ void ClustrixMonitor::check_hub(Clustrix::Softfailed softfailed)
|
||||
}
|
||||
}
|
||||
|
||||
bool ClustrixMonitor::check_cluster_membership(MYSQL* pHub_con,
|
||||
std::map<int, ClustrixMembership>* pMemberships)
|
||||
bool XpandMonitor::check_cluster_membership(MYSQL* pHub_con,
|
||||
std::map<int, XpandMembership>* pMemberships)
|
||||
{
|
||||
mxb_assert(pHub_con);
|
||||
mxb_assert(pMemberships);
|
||||
@ -923,7 +923,7 @@ bool ClustrixMonitor::check_cluster_membership(MYSQL* pHub_con,
|
||||
set<int> nids;
|
||||
for (const auto& kv : m_nodes_by_id)
|
||||
{
|
||||
const ClustrixNode& node = kv.second;
|
||||
const XpandNode& node = kv.second;
|
||||
nids.insert(node.id());
|
||||
}
|
||||
|
||||
@ -941,19 +941,19 @@ bool ClustrixMonitor::check_cluster_membership(MYSQL* pHub_con,
|
||||
|
||||
if (it != m_nodes_by_id.end())
|
||||
{
|
||||
ClustrixNode& node = it->second;
|
||||
XpandNode& node = it->second;
|
||||
|
||||
node.update(Clustrix::status_from_string(status),
|
||||
Clustrix::substate_from_string(substate),
|
||||
node.update(xpand::status_from_string(status),
|
||||
xpand::substate_from_string(substate),
|
||||
instance);
|
||||
|
||||
nids.erase(node.id());
|
||||
}
|
||||
else
|
||||
{
|
||||
ClustrixMembership membership(nid,
|
||||
Clustrix::status_from_string(status),
|
||||
Clustrix::substate_from_string(substate),
|
||||
XpandMembership membership(nid,
|
||||
xpand::status_from_string(status),
|
||||
xpand::substate_from_string(substate),
|
||||
instance);
|
||||
|
||||
pMemberships->insert(make_pair(nid, membership));
|
||||
@ -974,7 +974,7 @@ bool ClustrixMonitor::check_cluster_membership(MYSQL* pHub_con,
|
||||
auto it = m_nodes_by_id.find(nid);
|
||||
mxb_assert(it != m_nodes_by_id.end());
|
||||
|
||||
ClustrixNode& node = it->second;
|
||||
XpandNode& node = it->second;
|
||||
node.deactivate_server();
|
||||
m_nodes_by_id.erase(it);
|
||||
}
|
||||
@ -995,7 +995,7 @@ bool ClustrixMonitor::check_cluster_membership(MYSQL* pHub_con,
|
||||
return rv;
|
||||
}
|
||||
|
||||
void ClustrixMonitor::populate_from_bootstrap_servers()
|
||||
void XpandMonitor::populate_from_bootstrap_servers()
|
||||
{
|
||||
int id = 1;
|
||||
|
||||
@ -1003,17 +1003,17 @@ void ClustrixMonitor::populate_from_bootstrap_servers()
|
||||
{
|
||||
SERVER* pServer = ms->server;
|
||||
|
||||
Clustrix::Status status = Clustrix::Status::UNKNOWN;
|
||||
Clustrix::SubState substate = Clustrix::SubState::UNKNOWN;
|
||||
xpand::Status status = xpand::Status::UNKNOWN;
|
||||
xpand::SubState substate = xpand::SubState::UNKNOWN;
|
||||
int instance = 1;
|
||||
ClustrixMembership membership(id, status, substate, instance);
|
||||
XpandMembership membership(id, status, substate, instance);
|
||||
|
||||
std::string ip = pServer->address;
|
||||
int mysql_port = pServer->port;
|
||||
int health_port = m_config.health_check_port();
|
||||
int health_check_threshold = m_config.health_check_threshold();
|
||||
|
||||
ClustrixNode node(this, membership, ip, mysql_port, health_port, health_check_threshold, pServer);
|
||||
XpandNode node(this, membership, ip, mysql_port, health_port, health_check_threshold, pServer);
|
||||
|
||||
m_nodes_by_id.insert(make_pair(id, node));
|
||||
++id;
|
||||
@ -1026,7 +1026,7 @@ void ClustrixMonitor::populate_from_bootstrap_servers()
|
||||
update_http_urls();
|
||||
}
|
||||
|
||||
void ClustrixMonitor::update_server_statuses()
|
||||
void XpandMonitor::update_server_statuses()
|
||||
{
|
||||
mxb_assert(!servers().empty());
|
||||
|
||||
@ -1035,14 +1035,14 @@ void ClustrixMonitor::update_server_statuses()
|
||||
pMs->stash_current_status();
|
||||
|
||||
auto it = find_if(m_nodes_by_id.begin(), m_nodes_by_id.end(),
|
||||
[pMs](const std::pair<int, ClustrixNode>& element) -> bool {
|
||||
const ClustrixNode& info = element.second;
|
||||
[pMs](const std::pair<int, XpandNode>& element) -> bool {
|
||||
const XpandNode& info = element.second;
|
||||
return pMs->server->address == info.ip();
|
||||
});
|
||||
|
||||
if (it != m_nodes_by_id.end())
|
||||
{
|
||||
const ClustrixNode& info = it->second;
|
||||
const XpandNode& info = it->second;
|
||||
|
||||
if (info.is_running())
|
||||
{
|
||||
@ -1060,7 +1060,7 @@ void ClustrixMonitor::update_server_statuses()
|
||||
}
|
||||
}
|
||||
|
||||
void ClustrixMonitor::make_health_check()
|
||||
void XpandMonitor::make_health_check()
|
||||
{
|
||||
mxb_assert(m_http.status() != http::Async::PENDING);
|
||||
|
||||
@ -1082,7 +1082,7 @@ void ClustrixMonitor::make_health_check()
|
||||
}
|
||||
}
|
||||
|
||||
void ClustrixMonitor::initiate_delayed_http_check()
|
||||
void XpandMonitor::initiate_delayed_http_check()
|
||||
{
|
||||
mxb_assert(m_delayed_http_check_id == 0);
|
||||
|
||||
@ -1095,10 +1095,10 @@ void ClustrixMonitor::initiate_delayed_http_check()
|
||||
ms = max_delay_ms;
|
||||
}
|
||||
|
||||
m_delayed_http_check_id = delayed_call(ms, &ClustrixMonitor::check_http, this);
|
||||
m_delayed_http_check_id = delayed_call(ms, &XpandMonitor::check_http, this);
|
||||
}
|
||||
|
||||
bool ClustrixMonitor::check_http(Call::action_t action)
|
||||
bool XpandMonitor::check_http(Call::action_t action)
|
||||
{
|
||||
m_delayed_http_check_id = 0;
|
||||
|
||||
@ -1124,7 +1124,7 @@ bool ClustrixMonitor::check_http(Call::action_t action)
|
||||
{
|
||||
bool running = (result.code == 200); // HTTP OK
|
||||
|
||||
ClustrixNode& node = it->second;
|
||||
XpandNode& node = it->second;
|
||||
|
||||
node.set_running(running);
|
||||
|
||||
@ -1153,12 +1153,12 @@ bool ClustrixMonitor::check_http(Call::action_t action)
|
||||
return false;
|
||||
}
|
||||
|
||||
void ClustrixMonitor::update_http_urls()
|
||||
void XpandMonitor::update_http_urls()
|
||||
{
|
||||
vector<string> health_urls;
|
||||
for (const auto& kv : m_nodes_by_id)
|
||||
{
|
||||
const ClustrixNode& node = kv.second;
|
||||
const XpandNode& node = kv.second;
|
||||
string url = "http://" + node.ip() + ":" + std::to_string(node.health_port());
|
||||
|
||||
health_urls.push_back(url);
|
||||
@ -1178,7 +1178,7 @@ void ClustrixMonitor::update_http_urls()
|
||||
}
|
||||
}
|
||||
|
||||
bool ClustrixMonitor::perform_softfail(SERVER* pServer, json_t** ppError)
|
||||
bool XpandMonitor::perform_softfail(SERVER* pServer, json_t** ppError)
|
||||
{
|
||||
bool rv = perform_operation(Operation::SOFTFAIL, pServer, ppError);
|
||||
|
||||
@ -1189,12 +1189,12 @@ bool ClustrixMonitor::perform_softfail(SERVER* pServer, json_t** ppError)
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool ClustrixMonitor::perform_unsoftfail(SERVER* pServer, json_t** ppError)
|
||||
bool XpandMonitor::perform_unsoftfail(SERVER* pServer, json_t** ppError)
|
||||
{
|
||||
return perform_operation(Operation::UNSOFTFAIL, pServer, ppError);
|
||||
}
|
||||
|
||||
bool ClustrixMonitor::perform_operation(Operation operation,
|
||||
bool XpandMonitor::perform_operation(Operation operation,
|
||||
SERVER* pServer,
|
||||
json_t** ppError)
|
||||
{
|
||||
@ -1207,19 +1207,19 @@ bool ClustrixMonitor::perform_operation(Operation operation,
|
||||
|
||||
if (!m_pHub_con)
|
||||
{
|
||||
check_cluster(Clustrix::Softfailed::ACCEPT);
|
||||
check_cluster(xpand::Softfailed::ACCEPT);
|
||||
}
|
||||
|
||||
if (m_pHub_con)
|
||||
{
|
||||
auto it = find_if(m_nodes_by_id.begin(), m_nodes_by_id.end(),
|
||||
[pServer](const std::pair<int, ClustrixNode>& element) {
|
||||
[pServer](const std::pair<int, XpandNode>& element) {
|
||||
return element.second.server() == pServer;
|
||||
});
|
||||
|
||||
if (it != m_nodes_by_id.end())
|
||||
{
|
||||
ClustrixNode& node = it->second;
|
||||
XpandNode& node = it->second;
|
||||
|
||||
const char ZQUERY_FORMAT[] = "ALTER CLUSTER %s %d";
|
||||
|
||||
@ -1267,7 +1267,7 @@ bool ClustrixMonitor::perform_operation(Operation operation,
|
||||
else
|
||||
{
|
||||
LOG_JSON_ERROR(ppError,
|
||||
"%s: Could not could not connect to any Clustrix node, "
|
||||
"%s: Could not could not connect to any Xpand node, "
|
||||
"cannot perform %s of %s.",
|
||||
name(), zOperation, pServer->address);
|
||||
}
|
||||
@ -1275,7 +1275,7 @@ bool ClustrixMonitor::perform_operation(Operation operation,
|
||||
return performed;
|
||||
}
|
||||
|
||||
void ClustrixMonitor::persist(const ClustrixNode& node)
|
||||
void XpandMonitor::persist(const XpandNode& node)
|
||||
{
|
||||
if (!m_pDb)
|
||||
{
|
||||
@ -1294,7 +1294,7 @@ void ClustrixMonitor::persist(const ClustrixNode& node)
|
||||
char* pError = nullptr;
|
||||
if (sqlite3_exec(m_pDb, sql_upsert, nullptr, nullptr, &pError) == SQLITE_OK)
|
||||
{
|
||||
MXS_INFO("Updated Clustrix node in bookkeeping: %d, '%s', %d, %d.",
|
||||
MXS_INFO("Updated Xpand node in bookkeeping: %d, '%s', %d, %d.",
|
||||
id, zIp, mysql_port, health_port);
|
||||
}
|
||||
else
|
||||
@ -1304,7 +1304,7 @@ void ClustrixMonitor::persist(const ClustrixNode& node)
|
||||
}
|
||||
}
|
||||
|
||||
void ClustrixMonitor::unpersist(const ClustrixNode& node)
|
||||
void XpandMonitor::unpersist(const XpandNode& node)
|
||||
{
|
||||
if (!m_pDb)
|
||||
{
|
||||
@ -1320,7 +1320,7 @@ void ClustrixMonitor::unpersist(const ClustrixNode& node)
|
||||
char* pError = nullptr;
|
||||
if (sqlite3_exec(m_pDb, sql_delete, nullptr, nullptr, &pError) == SQLITE_OK)
|
||||
{
|
||||
MXS_INFO("Deleted Clustrix node %d from bookkeeping.", id);
|
||||
MXS_INFO("Deleted Xpand node %d from bookkeeping.", id);
|
||||
}
|
||||
else
|
||||
{
|
@ -12,21 +12,21 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "clustrixmon.hh"
|
||||
#include "xpandmon.hh"
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <sqlite3.h>
|
||||
#include <maxscale/config2.hh>
|
||||
#include <maxscale/monitor.hh>
|
||||
#include <maxbase/http.hh>
|
||||
#include "clustrixmembership.hh"
|
||||
#include "clustrixnode.hh"
|
||||
#include "xpandmembership.hh"
|
||||
#include "xpandnode.hh"
|
||||
|
||||
class ClustrixMonitor : public maxscale::MonitorWorker
|
||||
, private ClustrixNode::Persister
|
||||
class XpandMonitor : public maxscale::MonitorWorker
|
||||
, private XpandNode::Persister
|
||||
{
|
||||
ClustrixMonitor(const ClustrixMonitor&) = delete;
|
||||
ClustrixMonitor& operator=(const ClustrixMonitor&) = delete;
|
||||
XpandMonitor(const XpandMonitor&) = delete;
|
||||
XpandMonitor& operator=(const XpandMonitor&) = delete;
|
||||
public:
|
||||
class Config
|
||||
{
|
||||
@ -65,9 +65,9 @@ public:
|
||||
config::Integer m_health_check_port;
|
||||
};
|
||||
|
||||
~ClustrixMonitor();
|
||||
~XpandMonitor();
|
||||
|
||||
static ClustrixMonitor* create(const std::string& name, const std::string& module);
|
||||
static XpandMonitor* create(const std::string& name, const std::string& module);
|
||||
|
||||
bool configure(const MXS_CONFIG_PARAMETER* pParams) override;
|
||||
|
||||
@ -81,7 +81,7 @@ protected:
|
||||
void server_removed(SERVER* pServer) override;
|
||||
|
||||
private:
|
||||
ClustrixMonitor(const std::string& name,
|
||||
XpandMonitor(const std::string& name,
|
||||
const std::string& module,
|
||||
sqlite3* pDb);
|
||||
|
||||
@ -94,18 +94,18 @@ private:
|
||||
bool remove_persisted_information();
|
||||
void persist_bootstrap_servers();
|
||||
|
||||
void check_cluster(Clustrix::Softfailed softfailed);
|
||||
void check_hub(Clustrix::Softfailed softfailed);
|
||||
void choose_hub(Clustrix::Softfailed softfailed);
|
||||
void check_cluster(xpand::Softfailed softfailed);
|
||||
void check_hub(xpand::Softfailed softfailed);
|
||||
void choose_hub(xpand::Softfailed softfailed);
|
||||
|
||||
bool choose_dynamic_hub(Clustrix::Softfailed softfailed, std::set<std::string>& ips_checked);
|
||||
bool choose_bootstrap_hub(Clustrix::Softfailed softfailed, std::set<std::string>& ips_checked);
|
||||
bool choose_dynamic_hub(xpand::Softfailed softfailed, std::set<std::string>& ips_checked);
|
||||
bool choose_bootstrap_hub(xpand::Softfailed softfailed, std::set<std::string>& ips_checked);
|
||||
bool refresh_using_persisted_nodes(std::set<std::string>& ips_checked);
|
||||
|
||||
bool refresh_nodes();
|
||||
bool refresh_nodes(MYSQL* pHub_con);
|
||||
bool check_cluster_membership(MYSQL* pHub_con,
|
||||
std::map<int, ClustrixMembership>* pMemberships);
|
||||
std::map<int, XpandMembership>* pMemberships);
|
||||
|
||||
void populate_from_bootstrap_servers();
|
||||
|
||||
@ -150,13 +150,13 @@ private:
|
||||
return mxb::WorkerLoad::get_time_ms();
|
||||
}
|
||||
|
||||
// ClustrixNode::Persister
|
||||
void persist(const ClustrixNode& node);
|
||||
void unpersist(const ClustrixNode& node);
|
||||
// XpandNode::Persister
|
||||
void persist(const XpandNode& node);
|
||||
void unpersist(const XpandNode& node);
|
||||
|
||||
private:
|
||||
Config m_config;
|
||||
std::map<int, ClustrixNode> m_nodes_by_id;
|
||||
std::map<int, XpandNode> m_nodes_by_id;
|
||||
std::vector<std::string> m_health_urls;
|
||||
mxb::http::Async m_http;
|
||||
uint32_t m_delayed_http_check_id {0};
|
@ -11,15 +11,15 @@
|
||||
* Public License.
|
||||
*/
|
||||
|
||||
#include "clustrixnode.hh"
|
||||
#include "clustrix.hh"
|
||||
#include "xpandnode.hh"
|
||||
#include "xpand.hh"
|
||||
|
||||
bool ClustrixNode::can_be_used_as_hub(const char* zName,
|
||||
bool XpandNode::can_be_used_as_hub(const char* zName,
|
||||
const mxs::MonitorServer::ConnectionSettings& settings,
|
||||
Clustrix::Softfailed softfailed)
|
||||
xpand::Softfailed softfailed)
|
||||
{
|
||||
mxb_assert(m_pServer);
|
||||
bool rv = Clustrix::ping_or_connect_to_hub(zName, settings, softfailed, *m_pServer, &m_pCon);
|
||||
bool rv = xpand::ping_or_connect_to_hub(zName, settings, softfailed, *m_pServer, &m_pCon);
|
||||
|
||||
if (!rv)
|
||||
{
|
@ -12,21 +12,21 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "clustrixmon.hh"
|
||||
#include "xpandmon.hh"
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include "clustrix.hh"
|
||||
#include "clustrixmembership.hh"
|
||||
#include "xpand.hh"
|
||||
#include "xpandmembership.hh"
|
||||
|
||||
class ClustrixNode
|
||||
class XpandNode
|
||||
{
|
||||
public:
|
||||
class Persister
|
||||
{
|
||||
public:
|
||||
virtual void persist(const ClustrixNode& node) = 0;
|
||||
virtual void unpersist(const ClustrixNode& node) = 0;
|
||||
virtual void persist(const XpandNode& node) = 0;
|
||||
virtual void unpersist(const XpandNode& node) = 0;
|
||||
};
|
||||
|
||||
enum
|
||||
@ -41,8 +41,8 @@ public:
|
||||
APPROACH_DEFAULT
|
||||
};
|
||||
|
||||
ClustrixNode(Persister* pPersister,
|
||||
const ClustrixMembership& membership,
|
||||
XpandNode(Persister* pPersister,
|
||||
const XpandMembership& membership,
|
||||
const std::string& ip,
|
||||
int mysql_port,
|
||||
int health_port,
|
||||
@ -65,7 +65,7 @@ public:
|
||||
m_persister.persist(*this);
|
||||
}
|
||||
|
||||
~ClustrixNode()
|
||||
~XpandNode()
|
||||
{
|
||||
if (m_pCon)
|
||||
{
|
||||
@ -78,12 +78,12 @@ public:
|
||||
return m_id;
|
||||
}
|
||||
|
||||
Clustrix::Status status() const
|
||||
xpand::Status status() const
|
||||
{
|
||||
return m_status;
|
||||
}
|
||||
|
||||
Clustrix::SubState substate() const
|
||||
xpand::SubState substate() const
|
||||
{
|
||||
return m_substate;
|
||||
}
|
||||
@ -178,7 +178,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void update(Clustrix::Status status, Clustrix::SubState substate, int instance)
|
||||
void update(xpand::Status status, xpand::SubState substate, int instance)
|
||||
{
|
||||
m_status = status;
|
||||
m_substate = substate;
|
||||
@ -193,7 +193,7 @@ public:
|
||||
|
||||
bool can_be_used_as_hub(const char* zName,
|
||||
const mxs::MonitorServer::ConnectionSettings& settings,
|
||||
Clustrix::Softfailed softfailed);
|
||||
xpand::Softfailed softfailed);
|
||||
|
||||
SERVER* server() const
|
||||
{
|
||||
@ -227,8 +227,8 @@ public:
|
||||
private:
|
||||
Persister& m_persister;
|
||||
int m_id;
|
||||
Clustrix::Status m_status;
|
||||
Clustrix::SubState m_substate;
|
||||
xpand::Status m_status;
|
||||
xpand::SubState m_substate;
|
||||
int m_instance;
|
||||
std::string m_ip;
|
||||
int m_mysql_port {DEFAULT_MYSQL_PORT};
|
||||
@ -239,7 +239,7 @@ private:
|
||||
MYSQL* m_pCon {nullptr};
|
||||
};
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& out, const ClustrixNode& x)
|
||||
inline std::ostream& operator<<(std::ostream& out, const XpandNode& x)
|
||||
{
|
||||
x.print(out);
|
||||
return out;
|
@ -185,7 +185,7 @@ public:
|
||||
|
||||
bypass_whitespace();
|
||||
|
||||
if (is_set(m_pI))
|
||||
if (m_pEnd - m_pI > 3 && is_set(m_pI))
|
||||
{
|
||||
rv = parse(pResult);
|
||||
}
|
||||
|
Reference in New Issue
Block a user