Skip to content

Commit d7819d3

Browse files
Migrate to Java >= 21 (#5)
* update to last atlas version * add documentation * add doc * Update gradle.yml Use java 21 * change doc * Update gradle.yml * add gradle wrapper * Update gradle.yml * Update gradle.yml * add jacoco * activate sonar * activate sonar * Update gradle.yml * add sonarqube config * Update gradle.yml Update using instructions from https://sonarcloud.io/project/configuration/GitHubActions?id=andreaformica_Crest * Update gradle.yml Clean up. * Update gradle.yml clean up * Fix from sonar * Fix from sonar * clean up from sonar * fix from sonar * fix from sonar * fix from sonar * add tests * add tests * add tests * add tests payload * add tests payload * clean up * clean up * add test for run lumi * add test * add test * clean up * clean up * clean up * add monitoring test * add update tag * add update tag * clean up * add test batch payload upload * clean up * clean up * clean up * add meta test * add remove tag test * add remove tag test * add test on sqlrequest * add test on tags * add test on tags meta * clean up * add tests on iovs * add tests on sqlrequests * add tests on iovs * add tests on iovs * add tests on payload from file * add tests on iovservice * add tests on meta service * add tests on tag service * add tests crest tablename * add tests on meta
1 parent 6e6e956 commit d7819d3

File tree

1,541 files changed

+47111
-103780
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,541 files changed

+47111
-103780
lines changed

.github/workflows/gradle.yml

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,32 @@ on:
1111

1212
jobs:
1313
build:
14-
14+
name: Build and analyze
1515
runs-on: ubuntu-latest
16-
1716
steps:
18-
- uses: actions/checkout@v2
19-
- name: Set up JDK 1.8
20-
uses: actions/setup-java@v1
21-
with:
22-
java-version: 1.8
23-
- name: Grant execute permission for gradlew
24-
run: chmod +x gradlew
25-
- name: Build with Gradle
26-
run: ./gradlew build
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
20+
- name: Set up JDK 23
21+
uses: actions/setup-java@v4
22+
with:
23+
java-version: 23
24+
distribution: 'temurin' # Alternative distribution options are available
25+
- name: Cache SonarQube packages
26+
uses: actions/cache@v4
27+
with:
28+
path: ~/.sonar/cache
29+
key: ${{ runner.os }}-sonar
30+
restore-keys: ${{ runner.os }}-sonar
31+
- name: Grant execute permission for gradlew
32+
run: chmod +x gradlew
33+
- name: Cache Gradle packages
34+
uses: actions/cache@v4
35+
with:
36+
path: ~/.gradle/caches
37+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
38+
restore-keys: ${{ runner.os }}-gradle
39+
- name: Build and analyze
40+
env:
41+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
42+
run: ./gradlew build jacocoTestReport sonar --info

CREST_DOC.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
![Java CI with Gradle](https://github.com/HSF/Crest/workflows/Java%20CI%20with%20Gradle/badge.svg?event=push)
2+
3+
#### Author: A.Formica, R.Sipos
4+
#### Contributors: M.Mineev, E.Alexandrov (client tools)
5+
```
6+
Copyright (C) 2016 A.Formica, R.Sipos
7+
8+
This program is free software: you can redistribute it and/or modify
9+
it under the terms of the GNU General Public License as published by
10+
the Free Software Foundation, either version 3 of the License, or
11+
(at your option) any later version.
12+
13+
This program is distributed in the hope that it will be useful,
14+
but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
GNU General Public License for more details.
17+
18+
You should have received a copy of the GNU General Public License
19+
along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
```
21+
# Table of Contents
22+
1. [Description](#description)
23+
2. [Data Model](#data-model-overview)
24+
1. [Workflows](#workflows)
25+
26+
## Description
27+
CREST service is a RESTful API for the storage and retrieval of IOVs (Interval of Validity) and payloads.
28+
The data model is illustrated in the following diagram:
29+
30+
```mermaid
31+
classDiagram
32+
GlobalTag --* Maps
33+
Tag --* Maps
34+
Tag --* Iov
35+
Iov *--|> Payload
36+
class GlobalTag{
37+
+String name
38+
+String workflow
39+
}
40+
class Tag{
41+
+String name
42+
+Long endTime
43+
}
44+
class Iov{
45+
+Long since
46+
+String tagName
47+
+Timestamp insertionTime
48+
+String payloadHash
49+
}
50+
class Maps{
51+
+String globalTagName
52+
+String tagName
53+
+String label
54+
+String record
55+
}
56+
class Payload{
57+
+String hash
58+
+binary data
59+
+String objectType
60+
}
61+
```
62+
63+
The entity relationship in the relational DB is represented in the following diagram:
64+
65+
```mermaid
66+
erDiagram
67+
GlobalTag ||..|{ GlobalTagMaps : maps
68+
GlobalTagMaps }|..|| Tag: maps
69+
Tag ||..|| Meta: description
70+
Tag ||..o{ Iov : links
71+
Iov }|--|| Payload : has
72+
Payload ||..|| Data : contains
73+
Payload ||..|| Streamer : contains
74+
```
75+
## Data Model overview
76+
1. `TAG` : a tag is a virtual container of metadata (the `IOVs`), and is defined via the following properties
77+
* `name` : a string identifying the tag in a unique way
78+
* `description` : a general description of the tag
79+
* `timeType` : the time type of the tag [time, run-lumi,...]
80+
* `payloadSpec` : the type of the object that the tag is associated with (a CrestContainer can generate either `crest-json-single-iov`, or `crest-json-multi-iov`)
81+
* `synchronization` : the synchronization of the tag, this is still to be defined, but could be `UPDX` for example (optional, can be taken from tag name).
82+
* `lastValidatedTime`: The last validated time of the tag, in millisecon (optional, not used in Athena).
83+
* `endOfValidity` : the end of validity of the tag, in the same units as the "since" of the IOVs (see later).
84+
1. `TAGMETA` : this object has been introduced mainly to provide a correct mapping with the existing `metadata` of `COOL`, in particular related to `channels` list and `folder` specifications. It is in one-to-one relationship with the `TAG`. It is essential to have these metadata in order to increase compatibility with COOL related code in Athena. We will provide more details below on its content. For Athena usage, it is mandatory to create a TAGMETA entry for each TAG that a user create.
85+
86+
2. `IOV` : the metadata represeting the start of validity for a given payload. It is defined via the following properties
87+
* `tagName` : the name of the tag.
88+
* `since` : the since of the IOV.
89+
* `insertionTime` : the insertion time of the IOV. Provided by the server.
90+
* `payloadHash` : the unique key for the payload. It is computed as the SHA256 hash of the payload by the server.
91+
In CREST the concept of IOV is always *open-ended*, in the sense that it is valid until the next since. The only IOV for which we foresee a possible *end time* is the last IOV; when the *end time* is not INFINITY, then it can be provided during the PAYLOAD upload. It will update the *endOfValidity* field in the TAG table. Any search functionality will in any case only use the *since* field in CREST, and eventually the *insertionTime*. The latter is used to *go back* into the history of a given *since*, in the case that it has been overridden by the expert with another PAYLOAD.
92+
3. `PAYLOAD` : it is the binary object containing the conditions data payload. In our default serialization this is a JSON file, created with the help of `CrestContainer`. This allows to transparently migrate existing COOL data in a format that can then be used to generate a generic `CoralAttributeList` container on the Athena side. In terms of server implementation, the CREST server itself and its underlying relational DB tables are completely agnostic as far as the serialization choice of the PAYLOAD is concerned. For obvious reason, that is not at all the case on the client side, so it is important to understand the implication of the chosen serialization, and eventually adopt a strategy which is optimal for the given payload type.
93+
94+
The CREST API can then be seen as a *KEY=VALUE* store for PAYLOAD files. The TAG identifies a *payload type* (a combination of *folder* and *tag* in COOL), and every TAG will contain the *time history* of the PAYLOAD. When looking at the IOV in a tag, we get a unique *KEY* (the `payloadHash`) corresponding to a given time. Using that *KEY* we can download the corresponding PAYLOAD in a reproducible way, satisfying the basic principle of a REST interface.
95+
96+
## Workflows
97+
The typical operational workflows can be described in the following way.
98+
An expert having a specific payload to upload over time (a sort of conditions type) should proceed with the following steps in order to upload to CREST.
99+
1. Create a `TAG` if it does not exists.
100+
2. Upload `IOV` and `PAYLOAD` to an existing `TAG`.
101+
3. Find an existing `TAG`.
102+
4. Load the `IOV` for a given `TAG`.
103+
5. Create a `GLOBALTAG`.
104+
6. Associate a given `TAG` to one or more `GLOBALTAG`s.
105+
7. Find a `GLOBALTAG` and retrieve the associated `TAG`s via the `GLOBALTAGMAP`.

Dockerfile

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,42 @@
11
# CrestDB
2-
#
3-
# VERSION CrestDB-1.0
4-
5-
# use the centos base image provided by dotCloud
6-
# FROM openjdk:8u121-jdk
7-
# FROM anapsix/alpine-java
8-
# FROM openjdk:8u212-jre-alpine3.9
9-
#FROM openjdk:15-jdk-alpine
10-
FROM adoptopenjdk/openjdk11:alpine-jre
11-
MAINTAINER Andrea Formica
12-
13-
ENV USR crest
14-
ENV CREST_GID 208
15-
16-
ENV crest_version 1.0-SNAPSHOT
17-
ENV crest_dir /home/${USR}/crest
18-
ENV data_dir /home/${USR}/data
19-
#ENV data_dir /data
20-
ENV gradle_version 6.7
21-
ENV TZ GMT
22-
23-
RUN addgroup -g $CREST_GID $USR \
24-
&& adduser -S -u $CREST_GID -G $USR -h /home/$USR $USR
2+
FROM registry.cern.ch/docker.io/eclipse-temurin:23-alpine
3+
LABEL maintainer="Andrea Formica"
4+
5+
ENV USR=crestsvc
6+
ENV CREST_GID=208
7+
8+
ENV crest_version=1.0-SNAPSHOT
9+
ENV crest_dir=/home/${USR}/crest
10+
ENV data_dir=/home/${USR}/data
11+
ENV config_dir=/home/${USR}/config
12+
ENV TZ=GMT
13+
14+
## RUN groupadd -g 208 crest && adduser -u $CREST_GID -g $CREST_GID -d /home/${USR} ${USR} && usermod -aG crest ${USR}
15+
RUN addgroup -g $CREST_GID crest \
16+
&& adduser -u $CREST_GID -G crest -h /home/${USR} -D ${USR} \
17+
&& addgroup ${USR} crest
2518

2619
RUN mkdir -p ${crest_dir} \
20+
&& mkdir -p ${config_dir} \
2721
&& mkdir -p ${data_dir}/web \
2822
&& mkdir -p ${data_dir}/dump \
29-
&& mkdir -p ${data_dir}/logs
23+
&& mkdir -p ${data_dir}/logs \
24+
&& chown -R ${CREST_GID}:${CREST_GID} /home/${USR}
3025

3126
## This works if using an externally generated war, in the local directory
32-
ADD crestdb-web/build/libs/crest.war ${crest_dir}/crest.war
33-
ADD web ${data_dir}/web
34-
ADD logback.xml.crest ${data_dir}/logback.xml
27+
ADD build/libs/crest.jar ${crest_dir}/crest.jar
28+
## ADD web ${data_dir}/web
3529

3630
### we export only 1 directories....
3731
VOLUME "${data_dir}"
3832
EXPOSE 8080
3933

4034
# copy the entrypoint
4135
COPY ./entrypoint.sh /home/${USR}
42-
COPY ./create-properties.sh /home/${USR}
36+
COPY ./logback.xml.crest /home/${USR}/logback.xml
37+
## This is not needed in swarm deployment, only for local testing.
38+
COPY ./javaopts.properties /home/${USR}
39+
#COPY ./create-properties.sh /home/${USR}
4340

4441
RUN chown -R $USR:$CREST_GID /home/${USR}
4542

Makefile

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,30 @@ else
77
SPECFILE = $(shell find . -maxdepth 1 -type f -name *.spec)
88
endif
99

10-
SPECFILE_NAME = $(shell awk '$$1 == "Name:" { print $$2 }' $(SPECFILE) )
11-
SPECFILE_VERSION = $(shell awk '$$1 == "Version:" { print $$2 }' $(SPECFILE) )
12-
SPECFILE_RELEASE = $(shell awk '$$1 == "Release:" { print $$2 }' $(SPECFILE) )
13-
TARFILE = $(SPECFILE_NAME)-$(SPECFILE_VERSION).tgz
10+
#SPECFILE_NAME = $(shell awk '$$1 == "Name:" { print $$2 }' $(SPECFILE) )
11+
#SPECFILE_VERSION = $(shell awk '$$1 == "Version:" { print $$2 }' $(SPECFILE) )
12+
#SPECFILE_RELEASE = $(shell awk '$$1 == "Release:" { print $$2 }' $(SPECFILE) )
13+
#TARFILE = $(SPECFILE_NAME)-$(SPECFILE_VERSION).tgz
1414
DIST = $(shell rpm --eval %{dist})
15-
CREST_VERSION = 2.0
16-
CREST_RELEASE = $(shell sed -nr '/release=/ s/.*release=([^"]+).*/\1/p' $(PWD)/crestdb-web/src/main/resources/messages.properties)
15+
CREST_VERSION = $(shell sed -nr '/version=/ s/.*version=([^"]+).*/\1/p' $(PWD)/src/main/resources/rpm.properties)
16+
CREST_RELEASE = $(shell sed -nr '/release=/ s/.*release=([^"]+).*/\1/p' $(PWD)/src/main/resources/rpm.properties)
17+
$(info CREST version : $(CREST_VERSION))
18+
$(info CREST release : $(CREST_RELEASE))
19+
1720
TARGET_DIR = "crest-dist"
18-
CREST_TARFILE = $(SPECFILE_NAME)-$(CREST_VERSION).tgz
19-
CREST_WAR = $(shell find ./crestdb-web/ -maxdepth 3 -type f -name "crest.war")
20-
CREST_IMAGE = "gitlab-registry.cern.ch/formica/crest:$(CREST_VERSION)"
21-
##CREST_IMAGE = "crest-test"
21+
CREST_JAR = $(shell find ./ -maxdepth 3 -type f -name "crest.jar")
2222
## Commands
2323
MD = mkdir
2424
CP = cp
2525
DOCK = docker
2626
GRADLE = ./gradlew
27-
sources:
28-
ifeq ($(UNAME_S), Darwin)
29-
$(info create tar for MACOSX)
30-
tar -zcvf --exclude='.git' --exclude='.gitignore' --transform 's,^,$(SPECFILE_NAME)-$(SPECFILE_VERSION)/,' $(TARFILE) src/*
31-
else
32-
tar -zcvf $(TARFILE) --exclude-vcs --transform 's,^,$(SPECFILE_NAME)-$(SPECFILE_VERSION)/,' src/*
33-
endif
27+
#sources:
28+
# ifeq ($(UNAME_S), Darwin)
29+
# $(info create tar for MACOSX)
30+
# tar -zcvf --exclude='.git' --exclude='.gitignore' --transform 's,^,$(SPECFILE_NAME)-$(SPECFILE_VERSION)/,' $(TARFILE) src/*
31+
# else
32+
# tar -zcvf $(TARFILE) --exclude-vcs --transform 's,^,$(SPECFILE_NAME)-$(SPECFILE_VERSION)/,' src/*
33+
# endif
3434

3535
clean:
3636
rm -rf build/ $(TARFILE)
@@ -40,7 +40,7 @@ rpm: sources
4040
srpm: sources
4141
rpmbuild -bs --define 'dist $(DIST)' --define "_topdir $(PWD)/build" --define '_sourcedir $(PWD)' $(SPECFILE)
4242
mrpm:
43-
rpmbuild -bb --define "_topdir $(PWD)/build" --define "_sourcedir $(PWD)" --define "version $(COOLR_VERSION)" --define "release $(COOLR_RELEASE)" $(SPECFILE)
43+
rpmbuild -bb --define "_topdir $(PWD)/build" --define "_sourcedir $(PWD)" --define "version $(CREST_VERSION)" --define "release $(CREST_RELEASE)" $(SPECFILE)
4444

4545
dist:
4646
rm -rf $(TARGET_DIR)
@@ -49,7 +49,7 @@ dist:
4949
build: clean
5050
$(GRADLE) clean build
5151
package: dist
52-
$(CP) $(CREST_WAR) $(TARGET_DIR)/crest.war
52+
$(CP) $(CREST_JAR) $(TARGET_DIR)/crest.jar
5353
$(CP) ./logback.xml.crest $(TARGET_DIR)/logback.xml
5454
$(CP) ./javaopts.properties.rpm $(TARGET_DIR)/javaopts.properties
5555
$(CP) ./entrypoint.sh $(TARGET_DIR)/entrypoint.sh

0 commit comments

Comments
 (0)