1 /**
2 * Licensed to jclouds, Inc. (jclouds) under one or more
3 * contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. jclouds licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.jclouds.cloudloadbalancers.domain;
20
21 import org.jclouds.cloudloadbalancers.domain.internal.BaseNode;
22
23 /**
24 * The nodes defined by the load balancer are responsible for servicing the requests received
25 * through the load balancer's virtual IP. By default, the load balancer employs a basic health
26 * check that ensures the node is listening on its defined port. The node is checked at the time of
27 * addition and at regular intervals as defined by the load balancer health check configuration. If
28 * a back-end node is not listening on its port or does not meet the conditions of the defined
29 * active health check for the load balancer, then the load balancer will not forward connections
30 * and its status will be listed as OFFLINE. Only nodes that are in an ONLINE status will receive
31 * and be able to service traffic from the load balancer.
32 * <p/>
33 * All nodes have an associated status that indicates whether the node is ONLINE, OFFLINE, or
34 * DRAINING. Only nodes that are in ONLINE status will receive and be able to service traffic from
35 * the load balancer. The OFFLINE status represents a node that cannot accept or service traffic. A
36 * node in DRAINING status represents a node that stops the traffic manager from sending any
37 * additional new connections to the node, but honors established sessions. If the traffic manager
38 * receives a request and session persistence requires that the node is used, the traffic manager
39 * will use it. The status is determined by the passive or active health monitors.
40 * <p/>
41 * If the WEIGHTED_ROUND_ROBIN load balancer algorithm mode is selected, then the caller should
42 * assign the relevant weights to the node as part of the weight attribute of the node element. When
43 * the algorithm of the load balancer is changed to WEIGHTED_ROUND_ROBIN and the nodes do not
44 * already have an assigned weight, the service will automatically set the weight to "1" for all
45 * nodes.
46 *
47 * @author Adrian Cole
48 * @see <a href=
49 * "http://docs.rackspacecloud.com/loadbalancers/api/v1.0/clb-devguide/content/ch04s02.html" />
50 */
51 public class NodeRequest extends BaseNode<NodeRequest> {
52
53 @SuppressWarnings("unchecked")
54 public static Builder builder() {
55 return new Builder();
56 }
57
58 /**
59 * {@inheritDoc}
60 */
61 @Override
62 public Builder toBuilder() {
63 return new Builder().from(this);
64 }
65
66 public static class Builder extends BaseNode.Builder<NodeRequest> {
67
68 @Override
69 public NodeRequest build() {
70 return new NodeRequest(address, port, condition, weight);
71 }
72
73 @Override
74 public Builder address(String address) {
75 return Builder.class.cast(super.address(address));
76 }
77
78 @Override
79 public Builder condition(Condition condition) {
80 return Builder.class.cast(super.condition(condition));
81 }
82
83 @Override
84 public Builder from(NodeRequest in) {
85 return Builder.class.cast(super.from(in));
86 }
87
88 @Override
89 public Builder port(int port) {
90 return Builder.class.cast(super.port(port));
91 }
92
93 @Override
94 public Builder weight(Integer weight) {
95 return Builder.class.cast(super.weight(weight));
96 }
97
98 }
99
100 // for serialization only
101 NodeRequest() {
102
103 }
104
105 public NodeRequest(String address, int port, Condition condition, Integer weight) {
106 super(address, port, condition, weight);
107 }
108
109 }