Overview

Namespaces

  • None
  • OpenCloud
    • Autoscale
      • Resource
    • CloudMonitoring
      • Exception
      • Resource
    • Common
      • Exceptions
      • Log
      • Request
        • Response
    • Compute
    • Database
    • DNS
    • LoadBalancer
      • Resources
    • ObjectStore
      • Resource
    • Orchestration
    • Volume
  • PHP

Classes

  • Access
  • Algorithm
  • AllowedDomain
  • BillableLoadBalancer
  • ConnectionLogging
  • ConnectionThrottle
  • ContentCaching
  • ErrorPage
  • HealthMonitor
  • LoadBalancer
  • Metadata
  • Node
  • NodeEvent
  • Protocol
  • Readonly
  • SessionPersistence
  • SSLTermination
  • Stats
  • SubResource
  • Usage
  • VirtualIp
  • Overview
  • Namespace
  • Class
  • Tree
  • Download
  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: use OpenCloud\Common\PersistentObject;
 15: 
 16: /**
 17:  * The nodes defined by the load balancer are responsible for servicing the 
 18:  * requests received through the load balancer's virtual IP. By default, the 
 19:  * load balancer employs a basic health check that ensures the node is listening 
 20:  * on its defined port. The node is checked at the time of addition and at regular 
 21:  * intervals as defined by the load balancer health check configuration. If a 
 22:  * back-end node is not listening on its port or does not meet the conditions of 
 23:  * the defined active health check for the load balancer, then the load balancer 
 24:  * will not forward connections and its status will be listed as "OFFLINE". Only 
 25:  * nodes that are in an "ONLINE" status will receive and be able to service 
 26:  * traffic from the load balancer.
 27:  * 
 28:  * All nodes have an associated status that indicates whether the node is 
 29:  * ONLINE, OFFLINE, or DRAINING. Only nodes that are in ONLINE status will 
 30:  * receive and be able to service traffic from the load balancer. The OFFLINE 
 31:  * status represents a node that cannot accept or service traffic. A node in 
 32:  * DRAINING status represents a node that stops the traffic manager from sending 
 33:  * any additional new connections to the node, but honors established sessions. 
 34:  * If the traffic manager receives a request and session persistence requires 
 35:  * that the node is used, the traffic manager will use it. The status is 
 36:  * determined by the passive or active health monitors.
 37:  * 
 38:  * If the WEIGHTED_ROUND_ROBIN load balancer algorithm mode is selected, then 
 39:  * the caller should assign the relevant weights to the node as part of the 
 40:  * weight attribute of the node element. When the algorithm of the load balancer 
 41:  * is changed to WEIGHTED_ROUND_ROBIN and the nodes do not already have an 
 42:  * assigned weight, the service will automatically set the weight to "1" for all nodes.
 43:  * 
 44:  * One or more secondary nodes can be added to a specified load balancer so that 
 45:  * if all the primary nodes fail, traffic can be redirected to secondary nodes. 
 46:  * The type attribute allows configuring the node as either PRIMARY or SECONDARY.
 47:  */
 48: class Node extends PersistentObject 
 49: {
 50:     
 51:     public $id;
 52:     
 53:     /**
 54:      * IP address or domain name for the node.
 55:      * 
 56:      * @var string
 57:      */
 58:     public $address;
 59:     
 60:     /**
 61:      * Port number for the service you are load balancing.
 62:      * 
 63:      * @var int 
 64:      */
 65:     public $port;
 66:     
 67:     /**
 68:      * Condition for the node, which determines its role within the load balancer.
 69:      * 
 70:      * @var string 
 71:      */
 72:     public $condition;
 73:     
 74:     /**
 75:      * Current state of the node. Can either be ONLINE, OFFLINE or DRAINING.
 76:      * 
 77:      * @var string 
 78:      */
 79:     public $status;
 80:     
 81:     /**
 82:      * Weight of node to add. If the WEIGHTED_ROUND_ROBIN load balancer algorithm 
 83:      * mode is selected, then the user should assign the relevant weight to the 
 84:      * node using the weight attribute for the node. Must be an integer from 1 to 100.
 85:      * 
 86:      * @var int 
 87:      */
 88:     public $weight;
 89:     
 90:     /**
 91:      * Type of node to add: 
 92:      * 
 93:      * * PRIMARY: Nodes defined as PRIMARY are in the normal rotation to receive 
 94:      *      traffic from the load balancer.
 95:      * 
 96:      * * SECONDARY: Nodes defined as SECONDARY are only in the rotation to 
 97:      *      receive traffic from the load balancer when all the primary nodes fail.
 98:      * 
 99:      * @var string 
100:      */
101:     public $type;
102: 
103:     protected static $json_name = FALSE;
104:     protected static $json_collection_name = 'nodes';
105:     protected static $url_resource = 'nodes';
106:     
107:     private $createKeys = array(
108:         'address',
109:         'port',
110:         'condition',
111:         'type',
112:         'weight'
113:     );
114: 
115:     /**
116:      * returns the Node name
117:      *
118:      * @return string
119:      */
120:     public function name() 
121:     {
122:         return get_class() . '[' . $this->Id() . ']';
123:     }
124: 
125:     /**
126:      * returns the object for the Create JSON
127:      *
128:      * @return \stdClass
129:      */
130:     protected function createJson() 
131:     {
132:         $nodes = (object) array('node' => new \stdClass);
133:         foreach($this->createKeys as $key) {
134:             $nodes->node->$key = $this->$key;
135:         }
136:         
137:         return (object) array('nodes' => array($nodes));
138:     }
139: 
140:     /**
141:      * factory method to create a new Metadata child of the Node
142:      *
143:      * @api
144:      * @return Metadata
145:      */
146:     public function metadata($data = null) 
147:     {
148:         return new Metadata($this, $data);
149:     }
150: 
151:     /**
152:      * factory method to create a Collection of Metadata object
153:      *
154:      * Note that these are metadata children of the Node, not of the
155:      * LoadBalancer.
156:      *
157:      * @api
158:      * @return Collection of Metadata
159:      */
160:     public function metadataList() 
161:     {
162:         return $this->getService()->collection('OpenCloud\LoadBalancer\Resources\Metadata', null, $this);
163:     }
164:     
165: }
166: 
PHP OpenCloud API API documentation generated by ApiGen 2.8.0