The WebUI service for the Adaptable TeaStore
630
The Adaptable TeaStore WebUI service provides the front-end interface for users to interact with the Adaptable TeaStore application. It displays product recommendations, user profiles, and enables transactions, ensuring a seamless shopping experience.
The WebUI operates as a microservice within the Adaptable TeaStore ecosystem. It communicates with various backend services, such as the Recommender and Persistence services, to fetch data and present it to users. This architecture allows the WebUI to scale independently and adapt to varying user demands.
To start the Adaptable TeaStore WebUI service, you can use the following command:
docker run -e "REGISTRY_HOST=10.1.2.3" -e "REGISTRY_PORT=10000" -e "HOST_NAME=10.1.2.30" -e "SERVICE_PORT=8080" -p 8080:8080 -d cerberus237/adaptable-teastore-webui
docker run: Command to create and run a new container.-e "REGISTRY_HOST=10.1.2.3": Sets the environment variable for the registry host.-e "REGISTRY_PORT=10000": Sets the environment variable for the registry port.-e "HOST_NAME=10.1.2.30": Defines the host name for the service.-e "SERVICE_PORT=8080": Sets the port number for the service.-p 8080:8080: Maps port 8080 of the host to port 8080 of the container.-d: Runs the container in detached mode.cerberus237/adaptable-teastore-webui: The name of the Docker image.Here’s a sample docker-compose.yml file to run the Adaptable TeaStore WebUI service using Docker Compose:
version: '3'
services:
webui:
image: cerberus237/adaptable-teastore-webui
expose:
- "8080"
environment:
HOST_NAME: "webui"
REGISTRY_HOST: "registry"
ports:
- "8080:8080"
version: '3': Specifies the Docker Compose file format version.services: Defines the services to be run.
webui: The name of the service.
image: Specifies the Docker image to use for the service.expose: Makes the specified port accessible to linked services (not to the host).environment: Sets environment variables needed for the service.ports: Maps the host port to the container port.The Dockerfile for the Adaptable TeaStore WebUI service is designed to set up the environment for running the service. Below is an overview of its structure and components:
FROM cerberus237/adaptable-teastore-base:latest
LABEL org.opencontainers.image.authors="Inria R&D engineer <[email protected]>"
COPY target/*.war /usr/local/tomcat/webapps/
RUN mkdir -p /usr/local/tomcat/webapps/ROOT
CMD java -jar /usr/local/tomcat/bin/dockermemoryconfigurator.jar ${TOMCAT_HEAP_MEM_PERCENTAGE}; /usr/local/tomcat/bin/start.sh && echo '<% response.sendRedirect("/tools.descartes.teastore.webui/"); %>' > /usr/local/tomcat/webapps/ROOT/index.jsp && /usr/local/tomcat/bin/catalina.sh run
FROM cerberus237/adaptable-teastore-base:latest: Specifies the base image to use, which is the latest version of the Adaptable TeaStore base image.LABEL: Provides metadata about the image, including the author's contact information.COPY target/*.war /usr/local/tomcat/webapps/: Copies the compiled WAR file of the WebUI service to the Tomcat webapps directory for deployment.RUN mkdir -p /usr/local/tomcat/webapps/ROOT: Creates a ROOT directory for the default web application.CMD: Specifies the command to run when the container starts, including memory configuration and starting Tomcat.The WebUI service provides a family of collectors to support various system metrics:
| Category | Collectors (Local & Remote) |
|---|---|
| CPU Usage | LocalCpuUsageCollector, RemoteCpuUsageCollector, RemoteCpuUsagePerInstanceCollector, RemoteCpuUsageAllLoadBalancedServiceCollector, RemoteCpuUsageAllServiceCollector |
| Memory Usage | LocalMemoryUsageCollector, RemoteMemoryUsageCollector, RemoteMemoryUsagePerInstanceCollector, RemoteMemoryUsageAllLoadBalancedServiceCollector, RemoteMemoryUsageAllServiceCollector, RemoteRegistryMemoryUsageCollector |
| Requests | LocalRequestMetricsCollector, RemoteRequestMetricsCollector, RemoteRequestMetricsPerInstanceCollector, RemoteRequestMetricsAllLoadBalancedServiceCollector, RemoteRequestMetricsAllServiceCollector |
| Response Time | RemoteResponseTimeCollector, RemoteResponseTimePerInstanceCollector, RemoteResponseTimeAllLoadBalancedServiceCollector, RemoteResponseTimeAllServiceCollector |
| Service State | RemoteServiceStateCollector, RemoteServiceStatePerInstanceCollector, RemoteServiceStateAllLoadBalancedCollector, RemoteServiceStateAllServiceCollector |
| Service Status | RemoteServiceStatusCollector, RemoteServiceStatusPerInstanceCollector, RemoteServiceStatusAllLoadBalancedCollector, RemoteServiceStatusAllServiceCollector |
Each collector is designed to either:
The LocalCpuUsageCollector retrieves CPU usage metrics from the Java Management Extensions (JMX).
LocalCpuUsageCollector cpuUsageCollector = new LocalCpuUsageCollector();
double currentCpuUsage = cpuUsageCollector.get();
System.out.println("Current CPU Usage: " + currentCpuUsage + "%");
The RemoteCpuUsageCollector fetches CPU metrics from a remote service using a REST API call.
RemoteCpuUsageCollector cpuUsageCollector = new RemoteCpuUsageCollector(Service.AUTH, "metrics/cpu");
double currentCpuUsage = cpuUsageCollector.get();
System.out.println("Current Remote CPU Usage: " + currentCpuUsage + "%");
Note: Each service in the Adaptable TeaStore exposes a REST API endpoint to provide its metrics.
| Metric | Endpoint | HTTP Method |
|---|---|---|
| CPU Usage | /metrics/cpu | GET |
| Memory Usage | /metrics/memory | GET |
| Request Count | /metrics/requests | GET |
| Response Time | /metrics/status | GET |
| Service State | /metrics/state | GET |
| Service Status | /metrics/status | GET |
curl -X GET http://service-instance:8080/metrics/cpu
| Adaptation Action | Description |
|---|---|
| OpenCircuitBreaker | Opens the circuit breaker to prevent service failures during high load or errors. |
| CloseCircuitBreaker | Closes the circuit breaker to resume normal operation once conditions stabilize. |
| DDoSAttackEventBroadcast | Broadcasts an alert to all services when a DDoS attack is detected, triggering protective measures. |
| EnableMaintenanceMode | Activates maintenance mode to inform users of potential service interruptions during high traffic or maintenance periods. |
| DisableMaintenanceMode | Deactivates maintenance mode, allowing normal operations to resume. |
The Adaptable TeaStore WebUI service is a crucial component for delivering an engaging user experience. It can be easily deployed using Docker commands or Docker Compose and integrates seamlessly with other services in the Adaptable TeaStore architecture. The provided Dockerfile ensures a well-configured environment for running the service, while the instrumented adaptation actions and metrics collectors enable effective adaptability and monitoring capabilities. For further details, refer to the Getting Started documentation.
Content type
Image
Digest
sha256:81a3cc276…
Size
279.3 MB
Last updated
about 1 year ago
docker pull cerberus237/adaptable-teastore-webui