Shared Data Service Add-on installieren
  • 06 Sep 2024
  • 2 Minuten Lesezeit

Shared Data Service Add-on installieren


Artikel-Zusammenfassung

Shared Data Service ist ein Add-on für den Grassfish Windows und Linux Player. Es kann Daten auf dem Player speichern und diese über eine REST-Webservice-Schnittstelle abfragen.

Dies kann beispielsweise nützlich sein, um Fotos von einem Tablet direkt an einen Player zu senden.

Add-on installieren

Sie können das Add-on entweder über ein Update-Paket auf dem Server oder lokal auf dem Player installieren. Führen Sie dazu folgende Schritte aus:

  1. Speichern Sie das Installationspaket in einem beliebigen Ordner auf dem Player.

  2. Öffnen Sie eine Konsole mit Administratorrechten.

  3. Geben Sie den passenden Befehl für das Betriebssystem Ihres Players ein:

    • Windows: C:\GVClient\tools\current\gfBootstrap\gfBootstrap "[path to]\SharedDataService.zip"

    • Linux: sudo /opt/grassfish/tools/current/gfBootstrap/gfBootstrap "[path to]/SharedDataService.zip

Add-on benutzen

Shared Data Service ist eine in ASP.NET Core geschriebene Konsolenanwendung. Es bietet zwei REST-Schnittstellen zum Speichern und Abrufen von JSON-Dokumenten und Binärdaten. Diese Daten werden gespeichert und über einen String-Schlüssel abgefragt.

Cleanup durchführen

Alle 30 Sekunden wird ein Cleanup-Task ausgeführt, der alle abgelaufenen Einträge dauerhaft aus dem Dateisystem löscht.

Alle gespeicherten Daten haben eine in Sekunden gemessene Gültigkeitsdauer. Es gibt zwei Varianten:

  • Absolute: die Gültigkeit ist absolut und kann nicht verlängert werden. Nur durch erneutes Speichern kann die Gültigkeit verlängert werden.

  • Sliding: solange der Eintrag noch nicht abgelaufen ist, verlängert sich die Gültigkeit jedes Get-Aufrufs auf now + expirationSeconds.

Einstellungen konfigurieren

Sie können die Einstellungen des Add-ons in der Datei user.config bearbeiten. Abhängig vom Betriebssystem des Players lautet der Pfad zur Datei wie folgt:

  • Windows: C:\GVClient\addons\gfPlayer\SharedDataService\current\user.config

  • Linux: /opt/grassfish/addons/gfPlayer/SharedDataService/current/user.config

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><appSettings>
    <add key="LogLevel" value="2"/></appSettings>

Sie können die folgenden Einstellungen bearbeiten:

Einstellung

Standard

Beschreibung

LogLevel

3

1 - Error

2 - Warn

3 - Info

4 - Debug

5 - Debug

LogDir

./log

 

DataDir

./data

In diesem Ordner werden die Binärdaten gespeichert.

DbConnectionString

Data source=./data/data.db

 

MaxRequestBodySize

52428800

Maximale Größe eines HTTP-Requests in Bytes.

ServiceUrls

http://*:5003

URLs unter denen der Service erreichbar ist. Getrennt durch ;

MaxStorageSizeMegaBytes

-1

Wird die maximale Ordnergröße von DataDir überschritten, liefert der Service bei weiteren Insert-Aufrufen den HTTP-Code 507 zurück. 

Ein Wert von <= 0 deaktiviert dieses Limit.

KeepLogsXDays

10

Protokolle, die älter als KeepLogsXDays sind, werden automatisch gelöscht. 

Ein Wert <= 0 deaktiviert diese Funktion.

Swagger aufrufen

Nach dem Starten der Anwendung können Sie das Swagger User Interface unter der URL http://localhost:5003/swagger aufrufen.

Beispiele

Dateien

Get List

Request:

GET http://localhost:5003/api/Files

 

Response:

HTTP/1.1 200 OK

Date: Wed, 16 May 2018 06:28:54 GMT

Content-Type: application/json; charset=utf-8

Server: Kestrel

Transfer-Encoding: chunked

Get File

Request:

GET http://localhost:5003/api/Files/{key}

 

Response:

HTTP/1.1 200 OK

Date: Wed, 16 May 2018 06:30:09 GMT

Content-Type: image/jpeg

Server: Kestrel

Content-Length: 378299

Last-Modified: Wed, 16 May 2018 06:28:48 GMT

Accept-Ranges: bytes

Access-Control-Allow-Origin: *

 

BINARYDATA...

Delete File

Request:

DELETE http://localhost:5003/api/Files/{key}

 

Response:

HTTP/1.1 200 OK

Date: Wed, 16 May 2018 06:34:33 GMT

Server: Kestrel

Content-Length: 0

Insert/Update File (application/json)

Request:

PUT http://localhost:5003/api/Files/sample_text HTTP/1.1

Content-Type: application/json

 

{

  "expirationType": "Absolute",

  "expirationSeconds": 120,

  "mimeType": "text/plain",

  "data": "VGVzdCBUZXh0"

}

 

Response:

HTTP/1.1 201 Created

Date: Wed, 16 May 2018 06:41:18 GMT

Content-Type: application/json; charset=utf-8

Server: Kestrel

Transfer-Encoding: chunked

Location: http://localhost:5003/api/Files/sample_text

 

{

  "key": "sample_text"

}

Insert/Update File (multipart/form-data)

Request:

POST http://localhost:5003/api/Files/upload HTTP/1.1

Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryBz1rPpiFH0Pj0RAN

 

------WebKitFormBoundaryBz1rPpiFH0Pj0RAN

Content-Disposition: form-data; name="key"

 

key123

------WebKitFormBoundaryBz1rPpiFH0Pj0RAN

Content-Disposition: form-data; name="expirationType"

 

Absolute

------WebKitFormBoundaryBz1rPpiFH0Pj0RAN

Content-Disposition: form-data; name="expirationSeconds"120------WebKitFormBoundaryBz1rPpiFH0Pj0RAN

Content-Disposition: form-data; name="file"; filename="test.txt"

Content-Type: text/plain

 

dsfgsdfgsdfgsdfgdfgdfgdghfghdfghfgh

------WebKitFormBoundaryBz1rPpiFH0Pj0RAN--

 

Response:

HTTP/1.1 201 Created

Date: Wed, 16 May 2018 06:42:58 GMT

Content-Type: application/json; charset=utf-8

Server: Kestrel

Transfer-Encoding: chunked

Location: http://localhost:5003/api/Files

 

{

  "key": "key123"

}

JSON

Get List

Request:

GET http://localhost:5003/api/Json

 

Response:

HTTP/1.1 200 OK

Date: Wed, 16 May 2018 06:54:45 GMT

Content-Type: application/json; charset=utf-8

Server: Kestrel

Transfer-Encoding: chunked

 

[

  "sample_json"

]

Get JSON Document

Request:

GET http://localhost:5003/api/Files/{key}

 

Response:

HTTP/1.1 200 OK

Date: Wed, 16 May 2018 06:55:39 GMT

Content-Type: application/json; charset=utf-8

Server: Kestrel

Transfer-Encoding: chunked

 

{

  "expirationType": 0,

  "expirationSeconds": 117,

  "value": {}

}

Delete JSON Document

Request:

DELETE http://localhost:5003/api/Json/{key}

 

Response:

HTTP/1.1 200 OK

Date: Wed, 16 May 2018 06:56:13 GMT

Server: Kestrel

Content-Length: 0

Insert/Update JSON Document

Request:

PUT http://localhost:5003/api/Json/sample_json HTTP/1.1

Content-Type: application/json

 

{

  "expirationType": "Absolute",

  "expirationSeconds": 120,

  "value": {}

}

 

Response:

HTTP/1.1 201 Created

Date: Wed, 16 May 2018 06:57:06 GMT

Content-Type: application/json; charset=utf-8

Server: Kestrel

Transfer-Encoding: chunked

Location: http://localhost:5003/api/Json/sample_json

 

{

  "key": "sample_json"

}

Download

Add-on herunterladen


Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.