如何知道Service Fabric群集升级是否在微服务中完成

时间:2017-09-01 00:45:08

标签: azure azure-service-fabric

我需要做的是,在整个集群升级完成后,做一些事情(在其中一个微服务中)。

是否有任何事件或事情通知服务?

1 个答案:

答案 0 :(得分:1)

您可以撰写通知服务的事件或其他内容。借助其中任何一个。

  1. 您将Get Cluster Upgrade Progress作为Azure REST API。
  2. 如果您希望使用Azure Service Fabric Powershell方式,可以使用Get-​Service​Fabric​Cluster​Upgrade
  3. 显然没有你想要的条款。仅举一个例子,我在Azure服务结构集群中部署了一个应用程序。

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); PrintWriter out = response.getWriter(); String name = request.getParameter("name"); Blob image = null; byte[] imgData = null; Statement stmt = null; ResultSet rs = null; try { Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/users", "root", ""); stmt = con.createStatement(); rs = stmt.executeQuery("select photo from details where name='" + name + "'"); String imgLen = ""; while (rs.next()) { imgLen = rs.getString(1); } rs = stmt.executeQuery("select photo from details where name='" + name + "'"); if (rs.next()) { out.println("\n"); out.println("Getting blob"); Blob blob = rs.getBlob(1); out.println("Reading image"); BufferedImage img = ImageIO.read(blob.getBinaryStream()); out.println("img = " + img); } catch (Exception e) { out.println("Unable To Display image"); out.println("Image Display Error"); return; } finally { try { rs.close(); stmt.close(); //con.close(); } catch (Exception e) { e.printStackTrace(); } } } 窗口中的部分响应是:

    output

    这清楚地表明,使用3>Started executing script 'Get-ServiceFabricApplicationStatus'. 3>[void](Connect-ServiceFabricCluster -TimeoutSec:10 -WarningAction:'SilentlyContinue' -ConnectionEndpoint:'sfcluster.southeastasia.cloudapp.azure.com:19000'); Import-Module 'C:\Program Files\Microsoft SDKs\Service Fabric\Tools\PSModuleServiceFabricSDK\ServiceFabricSDK.psm1'; Get-ServiceFabricApplicationStatus -ApplicationName 'fabric:/SortApp' -ErrorAction Stop 3>The application has started. 3>Service Status: 3>fabric:/SortApp/SortService is ready. 3> 3>The application is ready. 3>Finished executing script 'Get-ServiceFabricApplicationStatus'. 的脚本代替了通知服务的事件或事件。