... |
... |
@@ -17,7 +17,6 @@ |
17
|
17
|
BuildGridServer
|
18
|
18
|
==============
|
19
|
19
|
|
20
|
|
-Creates a BuildGrid server, binding all the requisite service instances together.
|
21
|
20
|
"""
|
22
|
21
|
|
23
|
22
|
import logging
|
... |
... |
@@ -35,8 +34,18 @@ from .referencestorage.service import ReferenceStorageService |
35
|
34
|
|
36
|
35
|
|
37
|
36
|
class BuildGridServer:
|
|
37
|
+ """Creates a BuildGrid server.
|
|
38
|
+
|
|
39
|
+ The :class:`BuildGridServer` class binds together all the
|
|
40
|
+ requisite services.
|
|
41
|
+ """
|
38
|
42
|
|
39
|
43
|
def __init__(self, max_workers=None):
|
|
44
|
+ """Initializes a new :class:`BuildGridServer` instance.
|
|
45
|
+
|
|
46
|
+ Args:
|
|
47
|
+ max_workers (int, optional): A pool of max worker threads.
|
|
48
|
+ """
|
40
|
49
|
|
41
|
50
|
self.logger = logging.getLogger(__name__)
|
42
|
51
|
|
... |
... |
@@ -57,12 +66,25 @@ class BuildGridServer: |
57
|
66
|
self._bytestream_service = None
|
58
|
67
|
|
59
|
68
|
def start(self):
|
|
69
|
+ """Starts the server.
|
|
70
|
+ """
|
60
|
71
|
self._server.start()
|
61
|
72
|
|
62
|
73
|
def stop(self, grace=0):
|
|
74
|
+ """Stops the server.
|
|
75
|
+ """
|
63
|
76
|
self._server.stop(grace)
|
64
|
77
|
|
65
|
78
|
def add_port(self, address, credentials):
|
|
79
|
+ """Adds a port to the server.
|
|
80
|
+
|
|
81
|
+ Must be called before the server starts. If a credentials object exists,
|
|
82
|
+ it will make a secure port.
|
|
83
|
+
|
|
84
|
+ Args:
|
|
85
|
+ address (str): The address with port number.
|
|
86
|
+ credentials (:obj:`grpc.ChannelCredentials`): Credentials object.
|
|
87
|
+ """
|
66
|
88
|
if credentials is not None:
|
67
|
89
|
self.logger.info("Adding secure connection on: [{}]".format(address))
|
68
|
90
|
self._server.add_secure_port(address, credentials)
|
... |
... |
@@ -72,42 +94,98 @@ class BuildGridServer: |
72
|
94
|
self._server.add_insecure_port(address)
|
73
|
95
|
|
74
|
96
|
def add_execution_instance(self, instance, instance_name):
|
|
97
|
+ """Adds an :obj:`ExecutionInstance` to the service.
|
|
98
|
+
|
|
99
|
+ If no service exists, it creates one.
|
|
100
|
+
|
|
101
|
+ Args:
|
|
102
|
+ instance (:obj:`ExecutionInstance`): Instance to add.
|
|
103
|
+ instance_name (str): Instance name.
|
|
104
|
+ """
|
75
|
105
|
if self._execution_service is None:
|
76
|
106
|
self._execution_service = ExecutionService(self._server)
|
77
|
107
|
|
78
|
108
|
self._execution_service.add_instance(instance_name, instance)
|
79
|
109
|
|
80
|
110
|
def add_bots_interface(self, instance, instance_name):
|
|
111
|
+ """Adds a :obj:`BotsInterface` to the service.
|
|
112
|
+
|
|
113
|
+ If no service exists, it creates one.
|
|
114
|
+
|
|
115
|
+ Args:
|
|
116
|
+ instance (:obj:`BotsInterface`): Instance to add.
|
|
117
|
+ instance_name (str): Instance name.
|
|
118
|
+ """
|
81
|
119
|
if self._bots_service is None:
|
82
|
120
|
self._bots_service = BotsService(self._server)
|
83
|
121
|
|
84
|
122
|
self._bots_service.add_instance(instance_name, instance)
|
85
|
123
|
|
86
|
124
|
def add_operations_instance(self, instance, instance_name):
|
|
125
|
+ """Adds an :obj:`OperationsInstance` to the service.
|
|
126
|
+
|
|
127
|
+ If no service exists, it creates one.
|
|
128
|
+
|
|
129
|
+ Args:
|
|
130
|
+ instance (:obj:`OperationsInstance`): Instance to add.
|
|
131
|
+ instance_name (str): Instance name.
|
|
132
|
+ """
|
87
|
133
|
if self._operations_service is None:
|
88
|
134
|
self._operations_service = OperationsService(self._server)
|
89
|
135
|
|
90
|
136
|
self._operations_service.add_instance(instance_name, instance)
|
91
|
137
|
|
92
|
138
|
def add_reference_storage_instance(self, instance, instance_name):
|
|
139
|
+ """Adds a :obj:`ReferenceCache` to the service.
|
|
140
|
+
|
|
141
|
+ If no service exists, it creates one.
|
|
142
|
+
|
|
143
|
+ Args:
|
|
144
|
+ instance (:obj:`ReferenceCache`): Instance to add.
|
|
145
|
+ instance_name (str): Instance name.
|
|
146
|
+ """
|
93
|
147
|
if self._reference_storage_service is None:
|
94
|
148
|
self._reference_storage_service = ReferenceStorageService(self._server)
|
95
|
149
|
|
96
|
150
|
self._reference_storage_service.add_instance(instance_name, instance)
|
97
|
151
|
|
98
|
152
|
def add_action_cache_instance(self, instance, instance_name):
|
|
153
|
+ """Adds a :obj:`ReferenceCache` to the service.
|
|
154
|
+
|
|
155
|
+ If no service exists, it creates one.
|
|
156
|
+
|
|
157
|
+ Args:
|
|
158
|
+ instance (:obj:`ReferenceCache`): Instance to add.
|
|
159
|
+ instance_name (str): Instance name.
|
|
160
|
+ """
|
99
|
161
|
if self._action_cache_service is None:
|
100
|
162
|
self._action_cache_service = ActionCacheService(self._server)
|
101
|
163
|
|
102
|
164
|
self._action_cache_service.add_instance(instance_name, instance)
|
103
|
165
|
|
104
|
166
|
def add_cas_instance(self, instance, instance_name):
|
|
167
|
+ """Stores a :obj:`ContentAddressableStorageInstance` to the service.
|
|
168
|
+
|
|
169
|
+ If no service exists, it creates one.
|
|
170
|
+
|
|
171
|
+ Args:
|
|
172
|
+ instance (:obj:`ReferenceCache`): Instance to add.
|
|
173
|
+ instance_name (str): Instance name.
|
|
174
|
+ """
|
105
|
175
|
if self._cas_service is None:
|
106
|
176
|
self._cas_service = ContentAddressableStorageService(self._server)
|
107
|
177
|
|
108
|
178
|
self._cas_service.add_instance(instance_name, instance)
|
109
|
179
|
|
110
|
180
|
def add_bytestream_instance(self, instance, instance_name):
|
|
181
|
+ """Stores a :obj:`ByteStreamInstance` to the service.
|
|
182
|
+
|
|
183
|
+ If no service exists, it creates one.
|
|
184
|
+
|
|
185
|
+ Args:
|
|
186
|
+ instance (:obj:`ByteStreamInstance`): Instance to add.
|
|
187
|
+ instance_name (str): Instance name.
|
|
188
|
+ """
|
111
|
189
|
if self._bytestream_service is None:
|
112
|
190
|
self._bytestream_service = ByteStreamService(self._server)
|
113
|
191
|
|