Skip to content

JeffersonLab/myquery

Repository files navigation

myquery CI Docker

The myquery web service provides a simple query interface to the Jefferson Lab MYA archiver via jmyapi.

Screenshot



Overview

The primary goal of myquery is to allow users simple, programmatic access to MYA data without any dependencies on a specific language or requiring wrapping a command line tool. The myquery server supports HTTP requests and returns JSON responses.

Supports querying channel history over a time interval and at a specific point in time, and includes simple forms that allow users to easily generate a valid query string for each type of supported query.

See: Public MYA Web Service (auth required from offsite).

Quick Start with Compose

  1. Grab project
git clone https://github.com/JeffersonLab/myquery
cd myquery
  1. Launch Compose
docker compose up
  1. Use web browser to request channel list

http://localhost:8080/myquery/channel?q=channel%25&m=docker

Install

  1. Download Java JDK 17+
  2. Download Apache Tomcat 10+ (Compiled against Jakarta EE)
  3. Download MariaDB Driver and drop it into the Tomcat lib directory
  4. Download myquery.war and drop it into the Tomcat webapps directory
  5. Configure Tomcat
  6. Start Tomcat and navigate your web browser to localhost:8080/myquery

API

API Reference

Configure

A deployments.properites file must be placed in the lib directory of Tomcat. Download the mariadb database driver and place it in the lib directory of Tomcat. A new context.xml file is needed in the Tomcat conf directory that includes a DataSource for each host in the deployments.properties.

CORS

You can enable the Tomcat CORS filter for cross origin support by setting the environment variable CORS_ALLOWED_ORIGINS to the orgins you'd like to support. See Docker Compose example.

Build

This project is built with Java 17 (compiled to Java 17 bytecode), and uses the Gradle 7 build tool to automatically download dependencies and build the project from source:

git clone https://github.com/JeffersonLab/myquery
cd myquery
gradlew build

Note: If you do not already have Gradle installed, it will be installed automatically by the wrapper script included in the source

Note for JLab On-Site Users: Jefferson Lab has an intercepting proxy

Develop

In order to iterate rapidly when making changes it's often useful to run the app directly on the local workstation, perhaps leveraging an IDE. In this scenario run the service dependencies with:

docker compose -f deps.yaml up

Note: The local install of Tomcat should be configured to proxy connections to mya via localhost and therefore deployments.properties should contain:

port=3306
docker.master.host=mya
docker.hosts=mya
proxy.host.mya=localhost

Further, the local mya DataSource must also leverage localhost port forwarding so the context.xml URL field should be: url="jdbc:mariadb://localhost:3306/archive".

Test

Continuous Integration (CI) is setup using GitHub Actions, so on push tests are automatically run unless [no ci] is included in the commit message. Tests can be manually run on a local workstation using:

docker compose -f build.yaml up

Wait for containers to start then:

gradlew integrationTest

Release

  1. Bump the version number in the VERSION file and commit and push to GitHub (using Semantic Versioning).
  2. The CD GitHub Action should run automatically invoking:
    • The Create release GitHub Action to tag the source and create release notes summarizing any pull requests. Edit the release notes to add any missing details. A war file artifact is attached to the release.
    • The Publish docker image GitHub Action to create a new demo Docker image, and bump the compose.override.yaml to use the new image.
    • The Deploy to JLab GitHub Action to deploy to the JLab test environment.

Deploy

The deploy to JLab's epicswebtest is handled automatically via the release workflow.

At JLab this app is found at epicsweb.jlab.org/myquery and internally at epicswebtest.acc.jlab.org/myquery. However, those servers are proxies for tomcat1.acc.jlab.org and tomcattest1.acc.jlab.org respectively. A deploy script is provided on each server to automate wget and deploy. Example:

/opt/tomcat/cd/deploy.sh myquery 1.2.3

JLab Internal Docs: InstallGuideTomcatRHEL9

See Also