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

Prerequisites

  • Make sure that your EDAS Container version is 3.5.7 or later. If your EDAS Container version is earlier than 3.5.7, upgrade it. For more information, see Upgrade or downgrade the application runtime environment.
  • Make sure that your application is configured with a health check URL.

    To release an HSF application gracefully, configure a health check URL for the application, so that a script that is automatically executed after the application is started is mounted, which informs EDAS when the application is started.

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

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

    Compared with the port-based health check, URL-based health check reflects the health status of the application more accurately.

    • 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, the service is registered with the registry, and the consumer that subscribes to this service initiates a call to the service provider after receiving the notification. Application startup is a continuous process, during which a service may have been released but the dependent components, such as Redis or database resources, are not initialized. The call fails if any inbound traffic exists at this time. To avoid call failure, you can use the graceful HSF application release function.

All ProviderBeans of HSF are not registered with the registry during initialization. Instead, they are registered only after all 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 but before the web server is started, use curl localhost:12201/hsf/status to check whether the service has been initialized. If yes, start the web server (Apache or NGINX).

Configure delayed release for HSF applications

  1. In the left-side navigation pane, chooseApplication Management > Applications
  2. On the Applications page, click the application you want to release gracefully.
  3. On the Basic Information page, click Settings in the Application Settings section, and then click JVM in the list that appears.
  4. In the Application Settings dialog box, click Custom. In the Custom Parameters field, enter -Dhsf.publish.delayed=true, and then click Configure JVM Parameters.
    After the delayed release is configured, the HSF application is not released immediately. Instead, it is released only after the release script notification is received.
  5. Log on to the ECS instance where the HSF application is deployed for verification.
    1. Run telnet localhost 12201 to log on to the Elastic Compute Service (ECS) instance.
    2. Run cd hsf to access the HSF directory.
    3. Run ls to check the service release status.
      View the HSF service release status

Mount the auto release script

  1. In the left-side navigation pane, chooseApplication Management > Applications
  2. On the Applications page, click the application you want to release gracefully.
  3. On the Basic Information page, click Settings in the Application Settings section, and then click Mount Script in the list that appears.
  4. In the Mount Script dialog box, click Post-launch Script, and run the following command to mount the 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 describes the mounted 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, which is generally 12201. When the port has been occupied, the next port is used.
    • curl localhost:"$2"/hsf/online? k=hsf is used to release the HSF application and notify the container that the HSF has been released. You can manually run this command.

Verify the result

You can verify whether the HSF application is gracefully released by using the Quality of Service (QoS) method or the log method.

  • QoS

    After the script is configured, you can gracefully release the HSF application when deploying or resetting the application. Log on to the ECS instance in 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 yes, 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-bd7bf121e2e9] [] [] Receive online command.Do HSF online.