This topic describes how to gracefully publish High-speed Service Framework (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.

    If you want to gracefully publish an HSF application, you must configure a health check URL for the application. This way, an automatic publishing 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 configuredInstance deployment information - Before a health check URL is configured
    • After a health check URL is configuredInstance 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 published, 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 avoid call failures, you can gracefully publish 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 use curl localhost:12201/hsf/status to check whether the service is initialized. If yes, start the web server (Apache or NGINX).

Configure delayed publishing 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 namespace to which the application belongs. Then, click the name of the application that you want to publish gracefully.
  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 publishing is configured, the HSF application is not immediately published. Instead, the HSF application is published after it receives a notification sent by the publishing script.
  6. Log on to the Elastic Compute Service (ECS) instance where the HSF application is deployed to verify the delayed publishing.
    1. Run telnet localhost 12201 to log on to the ECS instance.
    2. Run cd hsf to access the HSF directory.
    3. Run ls to view the service publishing status.

Mount the automatic publishing 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 namespace to which the application belongs. Then, click the name of the application that you want to publish gracefully.
  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.
    • curl localhost:"$2"/hsf/online?k=hsf is used to publish the HSF application and notify EDAS Container that the HSF application is published. 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 published.

  • QoS

    After the script is configured, you can achieve the graceful publishing of 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 publishing status.

  • Log

    Check whether the /home/admin/logs/hsf/hsf.log file contains the following logs. If yes, the HSF application has received the publishing 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.