Skip to content

Commit 31dc96c

Browse files
Merge pull request #67 from delphi-hub/develop
Release version 0.8.0
2 parents 6ad8680 + 5678a69 commit 31dc96c

21 files changed

+3076
-334
lines changed

OpenAPISpecification.yaml

Lines changed: 218 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ paths:
9292
on the server.
9393
operationId: matchingInstance
9494
parameters:
95+
- in: query
96+
name: Id
97+
description: Id of the instance that is requesting a dependency
98+
required: true
99+
type: integer
100+
format: int64
95101
- name: ComponentType
96102
in: query
97103
description: Type of the instance to be retrieved
@@ -110,6 +116,31 @@ paths:
110116
$ref: '#/definitions/Instance'
111117
'400':
112118
description: Invalid status value
119+
/instance:
120+
get:
121+
tags:
122+
- Basic Operations
123+
summary: Get the instance with the specified id
124+
description: >-
125+
This command retrieves the instance with the specified id from the server.
126+
If that id is not present, 404 will be returned.
127+
operationId: instance
128+
parameters:
129+
- in: query
130+
name: Id
131+
description: Id of the instance
132+
required: true
133+
type: integer
134+
format: int64
135+
responses:
136+
'200':
137+
description: The instance that was requested
138+
schema:
139+
$ref: '#/definitions/Instance'
140+
'404':
141+
description: The id was not found on the server
142+
'500':
143+
description: Internal server error
113144
/instances:
114145
get:
115146
tags:
@@ -185,7 +216,13 @@ paths:
185216
operationId: matchInstance
186217
parameters:
187218
- in: query
188-
name: Id
219+
name: CallerId
220+
description: The ID of the instance that is calling this endpoint
221+
required: true
222+
type: integer
223+
format: int64
224+
- in: query
225+
name: MatchedInstanceId
189226
description: The ID of the instance that the sender was matched to.
190227
required: true
191228
type: integer
@@ -208,7 +245,8 @@ paths:
208245
- Basic Operations
209246
summary: Gets the list of events associated to the specified instance
210247
description: >-
211-
This command retrieves a list of events that are associated to the instance with the specified id.
248+
This command retrieves a list of events that are associated to the
249+
instance with the specified id.
212250
operationId: eventList
213251
parameters:
214252
- name: Id
@@ -226,6 +264,98 @@ paths:
226264
$ref: '#/definitions/Event'
227265
'404':
228266
description: Instance not found
267+
/linksFrom:
268+
get:
269+
tags:
270+
- Basic Operations
271+
summary: Retrieves outgoing links from an instance
272+
description: >-
273+
This command retreives a list of outgoing links from the instance with
274+
the specified id.
275+
operationId: linksFrom
276+
parameters:
277+
- name: Id
278+
in: query
279+
description: Id of the instance
280+
required: true
281+
type: integer
282+
format: int64
283+
responses:
284+
'200':
285+
description: List of InstanceLinks from the specified instance
286+
schema:
287+
type: array
288+
items:
289+
$ref: '#/definitions/InstanceLink'
290+
'404':
291+
description: Instance not found
292+
/linksTo:
293+
get:
294+
tags:
295+
- Basic Operations
296+
summary: Retrieves incoming links to an instance
297+
description: >-
298+
This command retreives a list of incoming links from the instance with
299+
the specified id.
300+
operationId: linksTo
301+
parameters:
302+
- name: Id
303+
in: query
304+
description: Id of the instance
305+
required: true
306+
type: integer
307+
format: int64
308+
responses:
309+
'200':
310+
description: List of InstanceLinks to the specified instance
311+
schema:
312+
type: array
313+
items:
314+
$ref: '#/definitions/InstanceLink'
315+
'404':
316+
description: Instance not found
317+
/network:
318+
get:
319+
tags:
320+
- Basic Operations
321+
summary: Retrieves the current instance network
322+
description: >-
323+
Retrieves the instance network, meaning a list of all instances as well
324+
as a list of all links currently registered at the registry.
325+
operationId: network
326+
responses:
327+
'200':
328+
description: The instance network
329+
schema:
330+
$ref: '#/definitions/InstanceNetwork'
331+
/addLabel:
332+
post:
333+
tags:
334+
- Basic Operations
335+
summary: Add a label to the instance with the specified id
336+
description: >-
337+
This command will add the specified label to the instance with the
338+
specified id.
339+
operationId: addLabel
340+
parameters:
341+
- name: Id
342+
in: query
343+
description: Id of the instance
344+
required: true
345+
type: integer
346+
format: int64
347+
- name: Label
348+
in: query
349+
description: The label to add to the instance
350+
required: true
351+
type: string
352+
responses:
353+
'200':
354+
description: Label successfully added
355+
'400':
356+
description: 'Bad request, your label exceeded the character limit'
357+
'404':
358+
description: 'Not found, the id you specified could not be found'
229359
/deploy:
230360
post:
231361
tags:
@@ -417,9 +547,11 @@ paths:
417547
- Docker Operations
418548
summary: Stops the specified instances' docker container
419549
description: >-
420-
This command stops the docker container of the instance with the
421-
specified ID. The instance will be properly shut down by calling its
422-
/stop command first. Will change the instance state to 'Stopped'.
550+
This command stops the specified instance. If the instance is running
551+
inside a docker container, the container will be stopped. If not, the
552+
instance will be gracefully shut down by calling its /stop endpoint.
553+
Will change the instance state to 'Stopped' for docker containers, will
554+
remove the instance for non-docker instances.
423555
operationId: stop
424556
parameters:
425557
- in: query
@@ -432,9 +564,7 @@ paths:
432564
'202':
433565
description: 'Accepted, the operation will be completed in the future.'
434566
'400':
435-
description: >-
436-
Bad request, the instance with the specified ID is either already
437-
stopped or not deployed as a docker container at all.
567+
description: 'Bad request, the instance with the specified ID is already stopped.'
438568
'404':
439569
description: ID not found on server
440570
'500':
@@ -495,7 +625,80 @@ paths:
495625
description: ID not found on server
496626
'500':
497627
description: Internal server error
628+
/assignInstance:
629+
post:
630+
tags:
631+
- Docker Operations
632+
summary: Assignes a new dependency to the specified instance
633+
description: >-
634+
This command assignes a new dependency to the instance with the
635+
specified id. Internally, this will stop the instance, assign the new
636+
dependency and start the instance again. This is why this is only
637+
applicable to docker instances.
638+
operationId: assignInstance
639+
parameters:
640+
- in: query
641+
name: Id
642+
description: The ID of the instance whichs dependency should be updated
643+
required: true
644+
type: integer
645+
format: int64
646+
- in: query
647+
name: AssignedInstanceId
648+
description: The ID of the instance that should be assigned as dependency
649+
required: true
650+
type: integer
651+
format: int64
652+
responses:
653+
'202':
654+
description: 'Accepted, the operation will be completed in the future.'
655+
'400':
656+
description: >-
657+
Bad request, the instance with the specified ID is no running inside
658+
a docker container or the assigned instance is of the wrong
659+
component type.
660+
'404':
661+
description: One of the ids was not found on the server
662+
'500':
663+
description: Internal server error
498664
definitions:
665+
InstanceNetwork:
666+
type: object
667+
required:
668+
- instances
669+
- links
670+
properties:
671+
instances:
672+
type: array
673+
items:
674+
$ref: '#/definitions/Instance'
675+
links:
676+
type: array
677+
items:
678+
$ref: '#/definitions/InstanceLink'
679+
InstanceLink:
680+
type: object
681+
required:
682+
- idFrom
683+
- idTo
684+
- linkState
685+
properties:
686+
idFrom:
687+
type: integer
688+
format: int64
689+
example: 0
690+
idTo:
691+
type: integer
692+
format: int64
693+
example: 42
694+
linkState:
695+
type: string
696+
description: Valid states for an InstanceLink
697+
example: Assigned
698+
enum:
699+
- Assigned
700+
- Outdated
701+
- Failed
499702
Event:
500703
type: object
501704
required:
@@ -557,3 +760,10 @@ definitions:
557760
- Stopped
558761
- Paused
559762
- NotReachable
763+
labels:
764+
type: array
765+
items:
766+
type: string
767+
example:
768+
- private
769+
- debug

README.md

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,9 @@ The Delphi registry is a server that provides access to all information and oper
1818
* Re-Assigning dependencies to instances (e.g. assigning a certain ElasticSearch instance to a Crawler)
1919

2020
## Requirements
21-
The Delphi registry requires a docker host to deploy containers to. By default, docker is expected to be reachable at *http://localhost:9095*, but you can override this setting by specifying the docker host URI in the environment variable *DOCKER_HOST*.
22-
To change the port of your http docker API to 9095, execute
23-
```
24-
edit /lib/systemd/system/docker.service
25-
ExecStart=/usr/bin/dockerd -H fd:// -H=tcp://0.0.0.0:9095
26-
systemctl daemon-reload
27-
sudo service docker restart
28-
```
29-
21+
In order to compile or execute the instance registry, you must have the latest version of the *Scala Build Tool* (SBT) installed. You can get it [here](https://www.scala-sbt.org/).
3022

31-
The following images must be registered at the docker registry:
23+
The Delphi registry requires a docker host to deploy containers to. The following images must be registered at the docker registry:
3224
* The Delphi Crawler ( ```delphi-crawler:1.0.0-SNAPSHOT``` )
3325
* The Delphi WebApi ( ```delphi-webapi:1.0.0-SNAPSHOT``` )
3426
* The Delphi WebApp ( ```delphi-webapp:1.0.0-SNAPSHOT``` )
@@ -39,6 +31,53 @@ To obtain these images, checkout the respective repositories ([here](https://git
3931
sbt docker:publishLocal
4032
```
4133
inside their root directory. This will build the docker images and register them directly at the local docker registry.
34+
The registry requires an initial instance of ElasticSearch to be running.
35+
36+
## Adapt the configuration file
37+
Before you can start the application, you have to make sure your configuration file contains valid data. The file can be found at *src/main/scala/de/upb/cs/swt/delphi/instanceregistry/Configuration.scala*, and most of its attributes are string or integer values. The following table describes the attributes in more detail.
38+
39+
|Attribute | Type | Default Value |Explanation |
40+
| :---: | :---: | :---: | :--- |
41+
|```bindHost``` | ```String``` | ```"0.0.0.0"``` | Host address that the registry server should be bound to |
42+
|```bindPort``` | ```Int``` | ```8087``` | Port that the registry server should be reachable at |
43+
|```defaultCrawlerPort``` | ```Int``` | ```8882``` | Port that Delphi Crawlers are reachable at. This may only be adapted if you manually changed the default port of crawlers before registering the respective image. |
44+
|```defaultWebApiPort``` | ```Int``` | ```8080``` | Port that Delphi WebAPIs are reachable at. This may only be adapted if you manually changed the default port of WebAPIs before registering the respective image. |
45+
|```defaultWebAppPort``` | ```Int``` | ```8085``` | Port that Delphi WebApps are reachable at. This may only be adapted if you manually changed the default port of WebApps before registering the respective image. |
46+
|```crawlerDockerImageName``` | ```String``` | ```"delphi-crawler:1.0.0-SNAPSHOT"``` | Name of the Docker image for Delphi Crawlers. May only be changed if you manually specified a different name when creating the image.|
47+
|```webApiDockerImageName``` | ```String``` | ```"delphi-webapi:1.0.0-SNAPSHOT"``` | Name of the Docker image for Delphi WebAPIs. May only be changed if you manually specified a different name when creating the image.|
48+
|```webAppDockerImageName``` | ```String``` | ```"delphi-webapp:1.0.0-SNAPSHOT"``` | Name of the Docker image for Delphi WebApps. May only be changed if you manually specified a different name when creating the image.|
49+
|```defaultElasticSearchInstanceHost``` | ```String``` | ```"elasticsearch://172.17.0.1"``` | Host that the default ElasticSearch instance is located at.|
50+
|```defaultElasticSearchInstancePort``` | ```Int``` | ```9200``` | Port that the default ElasticSearch instance is reachable at.|
51+
|```uriInLocalNetwork``` | ```String``` | ```"http://172.17.0.1:8087"``` | URI that the registry is reachable at for all docker containers. In most of the use-cases this is going to be the gateway of the default docker bridge.|
52+
|```maxLabelLength``` | ```Int``` | ```50``` | Maximum number of characters for instance labels. Longer labels will be rejected.|
53+
|```dockerOperationTimeout``` | ```Timeout``` | ```Timeout(20 seconds)``` | Default timeout for docker operations. If any of the async Docker operations (deploy, stop, pause, ..) takes longer than this, it will be aborted.|
54+
|```useInMemoryDB``` | ```Boolean``` | ```false``` | If set to true, all instance data will be kept in memory instead of using a MySQL database.|
55+
|```databaseHost``` | ```String``` | ```"jdbc:mysql://localhost/"``` | Host that the MySQL database is reachable at (only necessary if *useInMemoryDB* is false).|
56+
|```databaseName``` | ```String``` | ```""``` | Name of the MySQL database to use (only necessary if *useInMemoryDB* is false).|
57+
|```databaseDriver``` | ```String``` | ```"com.mysql.jdbc.Driver"``` | Driver to use for the MySQL connection (only necessary if *useInMemoryDB* is false).|
58+
|```databaseUsername``` | ```String``` | ```""``` | Username to use for the MySQL connection (only necessary if *useInMemoryDB* is false).|
59+
|```databasePassword``` | ```String``` | ```""``` | Password to use for the MySQL connection (only necessary if *useInMemoryDB* is false).|
60+
61+
By default, Docker is expected to be reachable at *http://localhost:9095*, but you can override this setting by specifying the docker host URI in the environment variable *DOCKER_HOST*.
62+
To change the port of your http docker API to 9095, execute
63+
```
64+
edit /lib/systemd/system/docker.service
65+
ExecStart=/usr/bin/dockerd -H fd:// -H=tcp://0.0.0.0:9095
66+
systemctl daemon-reload
67+
sudo service docker restart
68+
```
69+
70+
71+
72+
73+
74+
## Run the application
75+
There are two ways of running the registry application. You can either run the application directly, or build a docker image defined by the *build.sbt* file, and run a container based on this image. Either way, you have to set the correct configuration values before starting the application (see section **Adapt the configuration file** above for more information). We are currently working on a setup script that will prepare all images that need to be present on your docker host. Until its finished, you have to register the images manually, as described in the **Requirements** section.
76+
### Run the registry directly
77+
If you want to execute the registry directly on your local machine, simply go to the root folder of the repository and execute ```sbt run```. The application will stream all logging output to the terminal. You can terminate any time by pressing *RETURN*.
78+
### Run the registry in Docker
79+
For building a docker image containing the registry, go to the root folder of the repository and execute ```sbt docker:publishLocal```. This will build the application, create a docker image named ```delphi-registry:1.0.0-SNAPSHOT```, and register the image at your local docker registry.
80+
4281

4382
## Contributing
4483

build.sbt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.4" % "test"
1717

1818

1919
libraryDependencies += "org.parboiled" %% "parboiled" % "2.1.4"
20-
20+
libraryDependencies += "com.typesafe.akka" %% "akka-http-testkit" % "10.1.5"
2121

2222

2323
lazy val registry = (project in file(".")).
@@ -28,3 +28,14 @@ lazy val registry = (project in file(".")).
2828
dockerBaseImage := "openjdk:jre-alpine"
2929
)
3030

31+
libraryDependencies ++= List(
32+
"com.typesafe.slick" %% "slick" % "3.2.3",
33+
"com.typesafe.slick" %% "slick-hikaricp" % "3.2.3",
34+
"com.typesafe.slick" %% "slick-codegen" % "3.2.3",
35+
"mysql" % "mysql-connector-java" % "5.1.34",
36+
"org.slf4j" % "slf4j-nop" % "1.6.4"
37+
)
38+
39+
libraryDependencies += "com.h2database" % "h2" % "1.4.197"
40+
41+
trapExit := false

0 commit comments

Comments
 (0)