vas 0.4.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. data/README.md +1 -1
  2. data/lib/vas.rb +44 -1
  3. data/lib/vas/gemfire/agent_instances.rb +4 -3
  4. data/lib/vas/gemfire/agent_live_configurations.rb +3 -3
  5. data/lib/vas/gemfire/agent_node_instances.rb +2 -2
  6. data/lib/vas/gemfire/agent_node_live_configurations.rb +39 -0
  7. data/lib/vas/gemfire/application_code.rb +13 -12
  8. data/lib/vas/gemfire/application_code_images.rb +13 -11
  9. data/lib/vas/gemfire/cache_server_instances.rb +20 -12
  10. data/lib/vas/gemfire/cache_server_live_configurations.rb +3 -3
  11. data/lib/vas/gemfire/cache_server_node_instances.rb +16 -9
  12. data/lib/vas/gemfire/cache_server_node_live_configurations.rb +39 -0
  13. data/lib/vas/gemfire/disk_stores.rb +19 -11
  14. data/lib/vas/gemfire/gemfire.rb +4 -4
  15. data/lib/vas/gemfire/groups.rb +17 -10
  16. data/lib/vas/gemfire/installations.rb +12 -3
  17. data/lib/vas/gemfire/live_application_codes.rb +2 -2
  18. data/lib/vas/gemfire/locator_instances.rb +23 -13
  19. data/lib/vas/gemfire/locator_live_configurations.rb +3 -3
  20. data/lib/vas/gemfire/locator_node_instances.rb +22 -14
  21. data/lib/vas/gemfire/locator_node_live_configurations.rb +39 -0
  22. data/lib/vas/gemfire/nodes.rb +27 -6
  23. data/lib/vas/gemfire/pending_application_codes.rb +7 -2
  24. data/lib/vas/gemfire/statistics.rb +18 -11
  25. data/lib/vas/rabbitmq/groups.rb +6 -4
  26. data/lib/vas/rabbitmq/installations.rb +14 -6
  27. data/lib/vas/rabbitmq/instances.rb +9 -6
  28. data/lib/vas/rabbitmq/live_configurations.rb +3 -3
  29. data/lib/vas/rabbitmq/node_instances.rb +2 -2
  30. data/lib/vas/rabbitmq/node_live_configurations.rb +39 -0
  31. data/lib/vas/rabbitmq/nodes.rb +11 -8
  32. data/lib/vas/rabbitmq/plugin_images.rb +14 -7
  33. data/lib/vas/rabbitmq/plugins.rb +29 -20
  34. data/lib/vas/rabbitmq/rabbitmq.rb +4 -4
  35. data/lib/vas/shared/collection.rb +34 -11
  36. data/lib/vas/shared/configuration.rb +16 -9
  37. data/lib/vas/shared/deletable.rb +34 -0
  38. data/lib/vas/shared/groups.rb +26 -15
  39. data/lib/vas/shared/installation_images.rb +18 -10
  40. data/lib/vas/shared/installations.rb +22 -22
  41. data/lib/vas/shared/instance.rb +40 -19
  42. data/lib/vas/shared/live_configuration.rb +42 -0
  43. data/lib/vas/shared/logs.rb +27 -14
  44. data/lib/vas/shared/mutable_collection.rb +13 -5
  45. data/lib/vas/shared/node_configuration.rb +74 -0
  46. data/lib/vas/shared/node_instances.rb +32 -14
  47. data/lib/vas/shared/nodes.rb +37 -14
  48. data/lib/vas/shared/{pending_configuration.rb → pending_configurations.rb} +4 -2
  49. data/lib/vas/shared/resource.rb +12 -2
  50. data/lib/vas/shared/security.rb +11 -4
  51. data/lib/vas/shared/state_resource.rb +1 -1
  52. data/lib/vas/sqlfire/agent_instances.rb +98 -0
  53. data/lib/vas/sqlfire/agent_live_configurations.rb +39 -0
  54. data/lib/vas/sqlfire/agent_logs.rb +39 -0
  55. data/lib/vas/sqlfire/agent_node_instances.rb +54 -0
  56. data/lib/vas/sqlfire/agent_node_live_configurations.rb +39 -0
  57. data/lib/vas/sqlfire/agent_pending_configurations.rb +39 -0
  58. data/lib/vas/sqlfire/groups.rb +58 -0
  59. data/lib/vas/sqlfire/installation_images.rb +39 -0
  60. data/lib/vas/sqlfire/installations.rb +61 -0
  61. data/lib/vas/sqlfire/locator_instances.rb +210 -0
  62. data/lib/vas/sqlfire/locator_live_configurations.rb +39 -0
  63. data/lib/vas/sqlfire/locator_logs.rb +39 -0
  64. data/lib/vas/sqlfire/locator_node_instances.rb +91 -0
  65. data/lib/vas/sqlfire/locator_node_live_configurations.rb +39 -0
  66. data/lib/vas/sqlfire/locator_pending_configurations.rb +39 -0
  67. data/lib/vas/sqlfire/nodes.rb +73 -0
  68. data/lib/vas/sqlfire/server_instances.rb +192 -0
  69. data/lib/vas/sqlfire/server_live_configurations.rb +39 -0
  70. data/lib/vas/sqlfire/server_logs.rb +39 -0
  71. data/lib/vas/sqlfire/server_node_instances.rb +86 -0
  72. data/lib/vas/sqlfire/server_node_live_configurations.rb +39 -0
  73. data/lib/vas/sqlfire/server_pending_configurations.rb +39 -0
  74. data/lib/vas/sqlfire/sqlfire.rb +44 -0
  75. data/lib/vas/tc_server/applications.rb +32 -21
  76. data/lib/vas/tc_server/configuration.rb +1 -1
  77. data/lib/vas/tc_server/groups.rb +7 -4
  78. data/lib/vas/tc_server/installations.rb +16 -6
  79. data/lib/vas/tc_server/instances.rb +25 -13
  80. data/lib/vas/tc_server/live_configurations.rb +11 -1
  81. data/lib/vas/tc_server/logs.rb +4 -2
  82. data/lib/vas/tc_server/node_applications.rb +21 -17
  83. data/lib/vas/tc_server/node_instances.rb +23 -9
  84. data/lib/vas/tc_server/node_live_configurations.rb +39 -0
  85. data/lib/vas/tc_server/node_revisions.rb +15 -10
  86. data/lib/vas/tc_server/nodes.rb +15 -8
  87. data/lib/vas/tc_server/revision_images.rb +16 -10
  88. data/lib/vas/tc_server/revisions.rb +20 -16
  89. data/lib/vas/tc_server/tc_server.rb +5 -5
  90. data/lib/vas/tc_server/template_images.rb +13 -7
  91. data/lib/vas/tc_server/templates.rb +21 -13
  92. data/lib/vas/util/client.rb +15 -6
  93. data/lib/vas/vfabric/agent_image.rb +1 -1
  94. data/lib/vas/vfabric/nodes.rb +4 -11
  95. data/lib/vas/vfabric/v_fabric.rb +2 -2
  96. data/lib/vas/vfabric_administration_server.rb +37 -6
  97. data/lib/vas/web_server/configuration.rb +29 -0
  98. data/lib/vas/web_server/groups.rb +44 -0
  99. data/lib/vas/web_server/installation_images.rb +54 -0
  100. data/lib/vas/web_server/installations.rb +52 -0
  101. data/lib/vas/web_server/instances.rb +65 -0
  102. data/lib/vas/web_server/live_configurations.rb +39 -0
  103. data/lib/vas/web_server/logs.rb +37 -0
  104. data/lib/vas/web_server/node_instances.rb +39 -0
  105. data/lib/vas/web_server/node_live_configurations.rb +39 -0
  106. data/lib/vas/web_server/nodes.rb +53 -0
  107. data/lib/vas/web_server/pending_configurations.rb +39 -0
  108. data/lib/vas/web_server/web_server.rb +43 -0
  109. metadata +137 -76
@@ -0,0 +1,39 @@
1
+ # vFabric Administration Server Ruby API
2
+ # Copyright (c) 2012 VMware, Inc. All Rights Reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+
17
+ module Sqlfire
18
+
19
+ # Used to enumerate an agent instance's live configuration
20
+ class AgentLiveConfigurations < Shared::Collection
21
+
22
+ # @private
23
+ def initialize(location, client)
24
+ super(location, client, 'live-configurations', AgentLiveConfiguration)
25
+ end
26
+
27
+ end
28
+
29
+ # A live configuration file in an agent instance
30
+ class AgentLiveConfiguration < Shared::LiveConfiguration
31
+
32
+ # @private
33
+ def initialize(location, client)
34
+ super(location, client, 'agent-group-instance', AgentInstance, AgentNodeLiveConfiguration)
35
+ end
36
+
37
+ end
38
+
39
+ end
@@ -0,0 +1,39 @@
1
+ # vFabric Administration Server Ruby API
2
+ # Copyright (c) 2012 VMware, Inc. All Rights Reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+
17
+ module Sqlfire
18
+
19
+ # Used to enumerate an agent node instance's logs
20
+ class AgentLogs < Shared::Logs
21
+
22
+ # @private
23
+ def initialize(location, client)
24
+ super(location, client, AgentLog)
25
+ end
26
+
27
+ end
28
+
29
+ # A log file in an agent node instance
30
+ class AgentLog < Shared::Log
31
+
32
+ # @private
33
+ def initialize(location, client)
34
+ super(location, client, 'agent-node-instance', AgentNodeInstance)
35
+ end
36
+
37
+ end
38
+
39
+ end
@@ -0,0 +1,54 @@
1
+ # vFabric Administration Server Ruby API
2
+ # Copyright (c) 2012 VMware, Inc. All Rights Reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+
17
+ module Sqlfire
18
+
19
+ # Used to enumerate agent instances on an individual node
20
+ class AgentNodeInstances < Shared::NodeInstances
21
+
22
+ # @private
23
+ def initialize(location, client)
24
+ super(location, client, 'agent-node-instances', AgentNodeInstance)
25
+ end
26
+
27
+ end
28
+
29
+ # An agent node instance
30
+ class AgentNodeInstance < Shared::NodeInstance
31
+
32
+ # @return [String[]] The JVM options that are passed to the agent's JVM when it is started
33
+ attr_reader :jvm_options
34
+
35
+ # @private
36
+ def initialize(location, client)
37
+ super(location, client, Node, AgentLogs, AgentInstance, 'agent-group-instance', AgentNodeLiveConfigurations)
38
+ end
39
+
40
+ # Reloads the agent instance's details from the server
41
+ # @return [void]
42
+ def reload
43
+ super
44
+ @jvm_options = details['jvm-options']
45
+ end
46
+
47
+ # @return [String] a string representation of the instance
48
+ def to_s
49
+ "#<#{self.class} name='#{name}' jvm_options='#@jvm_options'>"
50
+ end
51
+
52
+ end
53
+
54
+ end
@@ -0,0 +1,39 @@
1
+ # vFabric Administration Server Ruby API
2
+ # Copyright (c) 2012 VMware, Inc. All Rights Reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+
17
+ module Sqlfire
18
+
19
+ # Used to enumerate an agent node instance's live configuration
20
+ class AgentNodeLiveConfigurations < Shared::Collection
21
+
22
+ # @private
23
+ def initialize(location, client)
24
+ super(location, client, 'node-live-configurations', AgentNodeLiveConfiguration)
25
+ end
26
+
27
+ end
28
+
29
+ # A live configuration file in an agent node instance
30
+ class AgentNodeLiveConfiguration < Shared::NodeConfiguration
31
+
32
+ # @private
33
+ def initialize(location, client)
34
+ super(location, client, 'agent-node-instance', AgentNodeInstance, AgentLiveConfiguration)
35
+ end
36
+
37
+ end
38
+
39
+ end
@@ -0,0 +1,39 @@
1
+ # vFabric Administration Server Ruby API
2
+ # Copyright (c) 2012 VMware, Inc. All Rights Reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+
17
+ module Sqlfire
18
+
19
+ # Used to enumerate an agent instance's pending configuration
20
+ class AgentPendingConfigurations < Shared::PendingConfigurations
21
+
22
+ # @private
23
+ def initialize(location, client)
24
+ super(location, client, 'pending-configurations', AgentPendingConfiguration)
25
+ end
26
+
27
+ end
28
+
29
+ # A configuration file that is pending
30
+ class AgentPendingConfiguration < Shared::PendingConfiguration
31
+
32
+ # @private
33
+ def initialize(location, client)
34
+ super(location, client, 'agent-group-instance', AgentInstance)
35
+ end
36
+
37
+ end
38
+
39
+ end
@@ -0,0 +1,58 @@
1
+ # vFabric Administration Server Ruby API
2
+ # Copyright (c) 2012 VMware, Inc. All Rights Reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+
17
+ module Sqlfire
18
+
19
+ # Used to enumerate, create, and delete SQLFire groups.
20
+ class Groups < Shared::Groups
21
+
22
+ # @private
23
+ def initialize(location, client)
24
+ super(location, client, Group)
25
+ end
26
+
27
+ end
28
+
29
+ # A SQLFire group
30
+ class Group < Shared::MutableGroup
31
+
32
+ # @private
33
+ def initialize(location, client)
34
+ super(location, client, Node, Installations)
35
+
36
+ @agent_instances_location = Util::LinkUtils.get_link_href(details, 'agent-group-instances')
37
+ @locator_instances_location = Util::LinkUtils.get_link_href(details, 'locator-group-instances')
38
+ @server_instances_location = Util::LinkUtils.get_link_href(details, 'server-group-instances')
39
+ end
40
+
41
+ # @return [AgentInstances] the group's agent instances
42
+ def agent_instances
43
+ @agent_instances ||= AgentInstances.new(@agent_instances_location, client)
44
+ end
45
+
46
+ # @return [LocatorInstances] the group's locator instances
47
+ def locator_instances
48
+ @locator_instances ||= LocatorInstances.new(@locator_instances_location, client)
49
+ end
50
+
51
+ # @return [ServerInstances] the group's server instances
52
+ def server_instances
53
+ @server_instances ||= ServerInstances.new(@server_instances_location, client)
54
+ end
55
+
56
+ end
57
+
58
+ end
@@ -0,0 +1,39 @@
1
+ # vFabric Administration Server Ruby API
2
+ # Copyright (c) 2012 VMware, Inc. All Rights Reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+
17
+ module Sqlfire
18
+
19
+ # Used to enumerate, create, and delete SQLFire installation images.
20
+ class InstallationImages < Shared::InstallationImages
21
+
22
+ # @private
23
+ def initialize(location, client)
24
+ super(location, client, InstallationImage)
25
+ end
26
+
27
+ end
28
+
29
+ # A SQLFire installation image
30
+ class InstallationImage < Shared::InstallationImage
31
+
32
+ # @private
33
+ def initialize(location, client)
34
+ super(location, client, Installation)
35
+ end
36
+
37
+ end
38
+
39
+ end
@@ -0,0 +1,61 @@
1
+ # vFabric Administration Server Ruby API
2
+ # Copyright (c) 2012 VMware, Inc. All Rights Reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+
17
+ module Sqlfire
18
+
19
+ # Used to enumerate, create, and delete SQLFire installations.
20
+ class Installations < Shared::Installations
21
+
22
+ # @private
23
+ def initialize(location, client)
24
+ super(location, client, Installation)
25
+ end
26
+
27
+ end
28
+
29
+ # A SQLFire installation
30
+ class Installation < Shared::Installation
31
+
32
+ # @private
33
+ def initialize(location, client)
34
+ super(location, client, InstallationImage, Group)
35
+ end
36
+
37
+ def reload
38
+ super
39
+ @agent_instances = nil
40
+ @locator_instances = nil
41
+ @server_instances = nil
42
+ end
43
+
44
+ # @return [AgentInstance[]] the agent instances that are using the installation
45
+ def agent_instances
46
+ @agent_instances ||= create_resources_from_links('agent-group-instance', AgentInstance);
47
+ end
48
+
49
+ # @return [LocatorInstance[]] the locator instances that are using the installation
50
+ def locator_instances
51
+ @locator_instances ||= create_resources_from_links('locator-group-instance', LocatorInstance);
52
+ end
53
+
54
+ # @return [ServerInstance[]] the server instances that are using the installation
55
+ def server_instances
56
+ @server_instances ||= create_resources_from_links('server-group-instance', ServerInstance);
57
+ end
58
+
59
+ end
60
+
61
+ end
@@ -0,0 +1,210 @@
1
+ # vFabric Administration Server Ruby API
2
+ # Copyright (c) 2012 VMware, Inc. All Rights Reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+
17
+ module Sqlfire
18
+
19
+ # Used to enumerate, create, and delete locator instances.
20
+ class LocatorInstances < Shared::MutableCollection
21
+
22
+ private
23
+
24
+ CREATE_PAYLOAD_KEYS = ['bind-address',
25
+ 'client-bind-address',
26
+ 'client-port',
27
+ 'initial-heap',
28
+ 'jvm-options',
29
+ 'max-heap',
30
+ 'peer-discovery-address',
31
+ 'peer-discovery-port',
32
+ 'run-netserver']
33
+
34
+ public
35
+
36
+ # @private
37
+ def initialize(location, client)
38
+ super(location, client, 'locator-group-instances', LocatorInstance)
39
+ end
40
+
41
+ # Creates a new locator instance
42
+ #
43
+ # @param installation [Installation] the installation that the instance will use
44
+ # @param name [String] the name of the instance
45
+ # @param options [Hash] optional configuration for the instance
46
+ #
47
+ # @option options 'bind-address' [String] The property in a node's metadata to use to determine the address that the
48
+ # locator binds to for peer-to-peer communication. If omitted, or if the property does not exist, the locator will
49
+ # use the value derived from +peer-discovery-address+
50
+ # @option options 'client-bind-address' [String] The property in a node's metadata to use to determine the address
51
+ # that the locator binds to for client communication. If omitted, or if the property does not exist, the locator
52
+ # will use the node's hostname. Only takes effect if +run-netserver+ is +true+
53
+ # @option options 'client-port' [Integer] The port that the locator listens on for client connections. Only take
54
+ # effect if +run-netserver+ is +true+
55
+ # @option options 'initial-heap' [String] The intial heap size to be used by the locator's JVM. If not specified,
56
+ # the JVM's default is used
57
+ # @option options 'jvm-options' [String[]] The JVM options that are passed to the locator's JVM when it is started
58
+ # @option options 'max-heap' [String] The maximum heap size to be used by the locator's JVM. If not specified, the
59
+ # JVM's default is used
60
+ # @option options 'peer-discovery-address' [String] The property in a node's metadata to use to determine the
61
+ # address that the locator binds to for peer-discovery communication. If omitted, or if the property does not
62
+ # exist, the locator will use +0.0.0.0+
63
+ # @option options 'peer-discovery-port' [Integer] The port that the locator listens on for peer-discovery
64
+ # connections. If omitted, the locator will listen on the default port (10334)
65
+ # @option options 'run-netserver' [Boolean] Whether the locator should run a netserver that can service thin
66
+ # clients. Default is +true+.
67
+ #
68
+ # @return [LocatorInstance] the new instance
69
+ def create(installation, name, options = {})
70
+
71
+ payload = {:installation => installation.location,
72
+ :name => name}
73
+
74
+ options.each { |key, value|
75
+ if (CREATE_PAYLOAD_KEYS.include?(key))
76
+ payload[key] = value
77
+ end
78
+ }
79
+
80
+ super(payload, 'locator-group-instance')
81
+ end
82
+
83
+ end
84
+
85
+ # A locator instance
86
+ class LocatorInstance < Shared::Instance
87
+
88
+ private
89
+
90
+ UPDATE_PAYLOAD_KEYS = ['bind-address',
91
+ 'client-bind-address',
92
+ 'client-port',
93
+ 'initial-heap',
94
+ 'jvm-options',
95
+ 'max-heap',
96
+ 'peer-discovery-address',
97
+ 'peer-discovery-port',
98
+ 'run-netserver']
99
+
100
+ public
101
+
102
+ # @return [String] the property in a node's metadata used to determine the address that the locator binds to for
103
+ # peer-to-peer communication. If +nil+, the locator uses the value derived from +peer_discovery_address+
104
+ attr_reader :bind_address
105
+
106
+ # @return [String] the property in a node's metadata used to determine the address that the locator binds to for
107
+ # client communication. If +nil+, the locator uses the node's hostname. Only takes effect if +run_netserver+ is
108
+ # +true+
109
+ attr_reader :client_bind_address
110
+
111
+ # @return [Integer] The port that the locator listens on for client connections. Only takes effect if
112
+ # +run_netserver+ is +true+
113
+ attr_reader :client_port
114
+
115
+ # @return [String] The initial heap size of the locator's JVM. +nil+ if the default is used
116
+ attr_reader :initial_heap
117
+
118
+
119
+ # @return [String[]] The JVM options that are passed to the locator's JVM when it is started
120
+ attr_reader :jvm_options
121
+
122
+
123
+ # @return [String] The max heap size of the locator's JVM. +nil+ if the default is used
124
+ attr_reader :max_heap
125
+
126
+
127
+ # @return [String] the property in a node's metadata used to determine the address that the locator binds to for
128
+ # peer-discovery communication. If +nil+, the locator uses +0.0.0.0+
129
+ attr_reader :peer_discovery_address
130
+
131
+
132
+ # @return [Integer] The port that the locator listens of for peer-discovery connections
133
+ attr_reader :peer_discovery_port
134
+
135
+
136
+ # @return [Boolean] +true+ if the locator runs a netserver that can service thin clients, otherwise +false+
137
+ attr_reader :run_netserver
138
+
139
+ # @private
140
+ def initialize(location, client)
141
+ super(location, client, Group, Installation, LocatorLiveConfigurations, LocatorPendingConfigurations, LocatorNodeInstance, 'locator-node-instance')
142
+ end
143
+
144
+ # Updates the instance using the supplied +options+.
145
+ #
146
+ # @param options [Hash] optional configuration for the instance
147
+ #
148
+ # @option options 'bind-address' [String] The property in a node's metadata to use to determine the address that the
149
+ # locator binds to for peer-to-peer communication. If omitted or +nil+, the configuration will not be changed. If
150
+ # set to an empty string the locator will use the value derived from +peer-discovery-address+.
151
+ # @option options 'client-bind-address' [String] The property in a node's metadata to use to determine the address
152
+ # that the locator binds to for client communication. If omitted or +nil+, the configuration will not be changed.
153
+ # If set to an empty string the locator will use its node's hostname
154
+ # @option options 'client-port' [Integer] The port that the locator listens on for client connections. If omitted or
155
+ # +nil+, the configuration will not be changed
156
+ # @option options 'initial-heap' [String] The intial heap size to be used by the locator's JVM. If omitted or +nil+,
157
+ # the configuration will not be changed. If set to an empty string the JVM's default is used
158
+ # @option options :installation [String] The installation to be used by the instance. If omitted or +nil+, the
159
+ # configuration will not be changed.
160
+ # @option options 'jvm-options' [String[]] The JVM options that are passed to the locator's JVM when it is started.
161
+ # If omitted or +nil+, the configuration will not be changed
162
+ # @option options 'max-heap' [String] The maximum heap size to be used by the locator's JVM. If omitted or +nil+, the
163
+ # configuration will not be changed. If set to an empty string the JVM's default is used
164
+ # @option options 'peer-discovery-address' [String] The property in a node's metadata to use to determine the
165
+ # address that the locator binds to for peer-discovery communication. If omitted or +nil+, the configuration will
166
+ # not be changed. If set to an empty string the locator will use +0.0.0.0+
167
+ # @option options 'peer-discovery-port' [Integer] The port that the locator listens on for peer-discovery
168
+ # connections. If omitted or +nil+, the configuration will not be changed
169
+ # @option options 'run-netserver' [Boolean] Whether the locator should run a netserver that can service thin
170
+ # clients. If omitted or +nil+, the configuration will not be changed
171
+ #
172
+ # @return [void]
173
+ def update(options)
174
+ payload = {}
175
+
176
+ options.each { |key, value|
177
+ if (UPDATE_PAYLOAD_KEYS.include?(key))
178
+ payload[key] = value
179
+ end
180
+ }
181
+
182
+ if (options.has_key? :installation)
183
+ payload[:installation] = options[:installation].location
184
+ end
185
+
186
+ client.post(location, payload)
187
+ reload
188
+ end
189
+
190
+ def reload
191
+ super
192
+ @bind_address = details['bind-address']
193
+ @client_bind_address = details['client-bind-address']
194
+ @client_port = details['client-port']
195
+ @initial_heap = details['initial-heap']
196
+ @jvm_options = details['jvm-options']
197
+ @max_heap = details['max-heap']
198
+ @peer_discovery_address = details['peer-discovery-address']
199
+ @peer_discovery_port = details['peer-discovery-port']
200
+ @run_netserver = details['run-netserver']
201
+ end
202
+
203
+ # @return [String] a string representation of the instance
204
+ def to_s
205
+ "#<#{self.class} name='#{name}' bind_address='#@bind_address' client_bind_address='#@client_bind_address' client_port='#@client_port' initial_heap='#@initial_heap' jvm_options='#@jvm_options' max_heap='#@max_heap' peer_discovery_address='#@peer_discovery_address' peer_discovery_port='#@peer_discovery_port' run_netserver='#@run_netserver'>"
206
+ end
207
+
208
+ end
209
+
210
+ end