This topic describes how to gracefully release High-Speed Service Framework (HSF) applications in Enterprise Distributed Application Service (EDAS).

Prerequisites

  • Your EDAS Container version is V3.5.7 or later. If your EDAS Container version is earlier than V3.5.7, update it. For more information, see Upgrade or downgrade the runtime environment.
  • Your application is configured with a health check URL.

    If you want to gracefully release an HSF application, you must configure a health check URL for the application. This way, an automatic release script can be mounted to inform EDAS when the application is started. The script is automatically executed after the application is started.

    By default, the health check URL is not configured in EDAS. You must manually create and configure the required controller in the application code.

    @RestController
    public class HealthCheckController {
    
        @RequestMapping("/health")
        public String healthCheck(){
            return "success";
        }
    
    }

    The URL-based health check reflects the health status of an application more accurately than the port-based health check.

    • Before a health check URL is configured Instance deployment information - Before a health check URL is configured
    • After a health check URL is configured Instance deployment information - After a health check URL is configured

Background information

During application startup, a service is registered with the registry. After a service consumer receives a notification of successful registration, the consumer initiates a call to the service provider. However, the application startup is a continuous process. During this process, the service may have been released, but its dependent components, such as Redis or database resources, are still not initialized. If inbound traffic is generated in this situation, the call fails. To prevent call failures, you can gracefully release the HSF application.

All provider beans of HSF are not registered with the registry during initialization. Instead, they are registered after all the beans in the Spring container are initialized and RefreshEvent is sent. In addition, Pandora sets the status to true after all services are registered. O&M is also required. After the app server (Tomcat) is started and before the web server is started, you can run the curl localhost:12201/hsf/status command to check whether the service is initialized. If so, start the Apache or NGINX web server.

Configure delayed release for HSF applications

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, click Applications.
  3. In the top navigation bar, select a region. On the Applications page, select the microservice namespace to which the application that you want to gracefully release belongs. Then, click the name of the application.
  4. On the Basic Information page of the application, click Edit to the right of JVM Parameters in the Application Settings section.
  5. In the Application Settings dialog box, click Custom. In the Custom Parameters field, enter -Dhsf.publish.delayed=true and click Configure JVM Parameters.
    After delayed release is configured, the HSF application is not immediately released. Instead, the HSF application is released after it receives a notification sent by the release script.
  6. Log on to the Elastic Compute Service (ECS) instance on which the HSF application is deployed to verify the delayed release.
    1. Run the telnet localhost 12201 command to log on to the ECS instance.
    2. Run the cd hsf command to go to the HSF directory.
    3. Run the ls command to view the service release status.

Mount the automatic release script

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, click Applications.
  3. In the top navigation bar, select a region. On the Applications page, select the microservice namespace to which the application that you want to gracefully release belongs. Then, click the name of the application.
  4. On the Basic Information page of the application, click Mount Script in the Application Settings section.
  5. In the Mount Script dialog box, click Post-launch Script and enter the following script:
    grep "PANDORA QOS PORT" /home/admin/edas-assist/edas-assist.pid | sed 's/\x0D$//' | awk -F":" '{ print "curl localhost:"$2"/hsf/online?k=hsf"}'| sh
    The following list describes the script:
    • Content of the edas-assist.pid file
      PID:19426
      HSF PORT:12200
      PANDORA QOS PORT:12203
      MONITOR PORT:8006
      CSP PORT:8719
    • /home/admin/edas-assist/edas-assist.pid is the file that records the port number of Pandora Boot. The port number of Pandora Boot is randomly generated after EDAS Container is started. In most cases, the port number is 12201. If the port is occupied, the next port is used.
    • The curl localhost:"$2"/hsf/online?k=hsf command is used to release the HSF application and notify EDAS Container that the HSF application is released. You can also manually run this command.

Verify the result

You can use the quality of service (QoS) method or the log method to check whether the HSF application is gracefully released.

  • QoS

    After the script is configured, you can gracefully release the HSF application when you perform operations such as deploying or resetting the application. You can log on to the ECS instance on which the application is deployed and check the service release status.

  • Log

    Check whether the /home/admin/logs/hsf/hsf.log file contains the following logs. If the logs exist, the HSF application has received the release command.

    01 2019-11-26 16:23:03.456 INFO [qos-worker-3-1:t.hsf] [38ef6d01-10a8-405d-8725-bd7bf121****] [] [] Receive online command.Do HSF online.