1: <?php
2: /**
3: * PHP OpenCloud library.
4: *
5: * @copyright Copyright 2013 Rackspace US, Inc. See COPYING for licensing information.
6: * @license https://www.apache.org/licenses/LICENSE-2.0 Apache 2.0
7: * @version 1.6.0
8: * @author Glen Campbell <glen.campbell@rackspace.com>
9: * @author Jamie Hannaford <jamie.hannaford@rackspace.com>
10: */
11:
12: namespace OpenCloud\LoadBalancer\Resources;
13:
14: /**
15: * Active health monitoring is a technique that uses synthetic transactions
16: * executed at periodic intervals to determine the condition of a node. One of
17: * the advantages of active health monitoring is that it does not require active
18: * transactions to be processed by the load balancer to determine whether or not
19: * a node is suitable for handling traffic. Active health monitoring is not
20: * applied by default and must be enabled per load balancer.
21: *
22: * The active health monitor can use one of three types of probes:
23: *
24: * * connect
25: * * HTTP
26: * * HTTPS
27: *
28: * These probes are executed at configured intervals; in the event of a failure,
29: * the node status changes to OFFLINE and the node will not receive traffic. If,
30: * after running a subsequent test, the probe detects that the node has recovered,
31: * then the node's status is changed to ONLINE and it is capable of servicing requests.
32: */
33: class HealthMonitor extends SubResource
34: {
35:
36: /**
37: * Type of the health monitor. Can either be "connect", "HTTP" or "HTTPS"
38: *
39: * @var string
40: */
41: public $type;
42:
43: /**
44: * The minimum number of seconds to wait before executing the health monitor.
45: * Must be a number between 1 and 3600.
46: *
47: * @var int
48: */
49: public $delay;
50:
51: /**
52: * Maximum number of seconds to wait for a connection to be established
53: * before timing out. Must be a number between 1 and 300.
54: *
55: * @var int
56: */
57: public $timeout;
58:
59: /**
60: * Number of permissible monitor failures before removing a node from rotation.
61: * Must be a number between 1 and 10.
62: *
63: * @var int
64: */
65: public $attemptsBeforeDeactivation;
66:
67: /**
68: * A regular expression that will be used to evaluate the contents of the
69: * body of the response.
70: *
71: * @var string
72: */
73: public $bodyRegex;
74:
75: /**
76: * The name of a host for which the health monitors will check.
77: *
78: * @var string
79: */
80: public $hostHeader;
81:
82: /**
83: * The HTTP path that will be used in the sample request.
84: *
85: * @var string
86: */
87: public $path;
88:
89: /**
90: * A regular expression that will be used to evaluate the HTTP status code
91: * returned in the response.
92: *
93: * @var string
94: */
95: public $statusRegex;
96:
97: protected static $json_name = 'healthMonitor';
98: protected static $url_resource = 'healthmonitor';
99: protected $createKeys = array(
100: 'type',
101: 'delay',
102: 'timeout',
103: 'attemptsBeforeDeactivation',
104: 'bodyRegex',
105: 'hostHeader',
106: 'path',
107: 'statusRegex'
108: );
109:
110: /**
111: * creates a new health monitor
112: *
113: * This calls the Update() method, since it requires a PUT to create
114: * a new error page. A POST request is not supported, since the URL
115: * resource is already defined.
116: *
117: * @param array $params array of parameters
118: */
119: public function create($params = array())
120: {
121: return $this->update($params);
122: }
123:
124: }
125: