作者:潘罡 (Van Pan)@ Microsoft

我们回到Service Fabric最底层的话题,谈谈Service Fabric是怎么工作的。

首先,我们回到下面的文档,看看Service Fabric的整体架构

https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-architecture

文档中有一段对于CM的定义:CM和Failover Manager进行交互,主要负责可靠性和服务运行位置分配。Resource Manager保证约束不被打破,CM管理Application的整个生命周期。同时它还和Health Manger进行交互并确保application在升级过程中在语义层面不会出现可用性问题。

CM工作流程

我们回到一个场景,SF管理员更新一个Application。他会使用下面的步骤

https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-automate-powershell

按步解释,他需要对SF进行如下操作:

1. 上传SF Application的package

2. 注册Application type

3. 命令SF升级

从顺序而言,SF的各个系统服务是这样工作的

1. 上传SF package,SF Image Store Service会将package储存至本地

2. 注册Application type,命令发至CM,CM进行初始化处理

3. 升级SF第一步,创建Application。CM会和Naming Service通讯并告知新的type以及版本号的一系列信息。

4. 升级SF第二步,创建Service。CM同样会先和Naming Service通讯。随后Naming Service会和FM通讯并告知服务信息,FM根据算法统计Service需要跑在哪些Node上,随后FM通知Node进行Service部署。Node根据需要部署的Service信息,从Image Store中获取Service exe文件等运行数据,并且启动服务。

5. 如果是升级Application操作,CM同样会做初始化操作。随后CM直接和FM通讯升级操作,FM随后将升级Service的工作部署到各个Node。

CM配置信息解析

CM是如何读取Application和Service的详细信息的呢?

它是读取ServiceManifest.xml和ApplicationManifest.xml

你可以在本地源代码中找到这两个文件

我们先看ServiceManifest.xml,默认情况下它是这样子的

<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="Stateless1Pkg"
Version="1.0.0"
xmlns="http://schemas.microsoft.com/2011/01/fabric"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ServiceTypes>
<!-- This is the name of your ServiceType.
This name must match the string used in RegisterServiceType call in Program.cs. -->
<StatelessServiceType ServiceTypeName="Stateless1Type" />
</ServiceTypes> <!-- Code package is your service executable. -->
<CodePackage Name="Code" Version="1.0.0">
<EntryPoint>
<ExeHost>
<Program>Stateless1.exe</Program>
</ExeHost>
</EntryPoint>
</CodePackage> <!-- Config package is the contents of the Config directoy under PackageRoot that contains an
independently-updateable and versioned set of custom configuration settings for your service. -->
<ConfigPackage Name="Config" Version="1.0.0" /> <Resources>
<Endpoints>
<!-- This endpoint is used by the communication listener to obtain the port on which to
listen. Please note that if your service is partitioned, this port is shared with
replicas of different partitions that are placed in your code. -->
<Endpoint Name="ServiceEndpoint" />
</Endpoints>
</Resources>
</ServiceManifest>

请注意以下描述:

在ServiceTypes中,其实你可以添加多个ServiceType。也就是说,你完全可以在同一个Service的源代码中定义多个Micro-Service。

CodePackage定义了以上Service的Exe入口,你同样可以添加多个EXE。

在Program.cs中,定义了如何将Exe和ServiceType进行连接。

ServiceRuntime.RegisterServiceAsync("Stateless1Type",
context => new Stateless1(context)).GetAwaiter().GetResult(); ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(Stateless1).Name);

换言之,我们完全可以在同一个项目中定义多种Service并让他们Host在同一个EXE中。

再回到ApplicationManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<ApplicationManifest ApplicationTypeName="Application1Type"
ApplicationTypeVersion="1.0.0"
xmlns="http://schemas.microsoft.com/2011/01/fabric"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Parameters>
<Parameter Name="Stateless1_InstanceCount" DefaultValue="-1" />
</Parameters>
<!-- Import the ServiceManifest from the ServicePackage. The ServiceManifestName and ServiceManifestVersion
should match the Name and Version attributes of the ServiceManifest element defined in the
ServiceManifest.xml file. -->
<ServiceManifestImport>
<ServiceManifestRef ServiceManifestName="Stateless1Pkg" ServiceManifestVersion="1.0.0" />
<ConfigOverrides />
</ServiceManifestImport>
<DefaultServices>
<!-- The section below creates instances of service types, when an instance of this
application type is created. You can also create one or more instances of service type using the
ServiceFabric PowerShell module. The attribute ServiceTypeName below must match the name defined in the imported ServiceManifest.xml file. -->
<Service Name="Stateless1">
<StatelessService ServiceTypeName="Stateless1Type" InstanceCount="[Stateless1_InstanceCount]">
<SingletonPartition />
</StatelessService>
</Service>
</DefaultServices>
</ApplicationManifest>

CM通过ServiceManifestName和ServiceTypeName找到Service的定义。

Service Fabric Cluster Manager的更多相关文章

  1. Service Fabric Failover Manager

    作者:潘罡 (Van Pan)@ Microsoft 什么是Failover Manager 我们回到Service Fabric系统架构图. Failover Manager是Reliability ...

  2. Service Fabric SfDevCluster目录从默认的C盘移动

    管理员权限打开Powershell CD\ 回车 CD "C:\Program Files\Microsoft SDKs\Service Fabric\ClusterSetup" ...

  3. ServiceFabric极简文档-1.1 附属文件:规划和准备 Service Fabric 独立群集部署

    准备好要充当节点的计算机 下面是要添加到群集的每台计算机的建议规格: 至少 16 GB RAM 至少 40 GB 可用磁盘空间 4 核或更高规格的 CPU 所有计算机与安全网络连接 Windows S ...

  4. How to deploy JAVA Application on Azure Service Fabric

    At this moment, Azure Service Fabric does not support JAVA application natively (but it's on the sup ...

  5. 微服务框架之微软Service Fabric

    常见的微服务架构用到的软件&组件: docker(成熟应用) spring boot % spring cloud(技术趋势) Service Fabric(属于后起之秀 背后是微软云的驱动) ...

  6. Service Fabric基本概念: Node, Application, Service, Partition/Replicas

    作者:张鼎松 (Dingsong Zhang) @ Microsoft 在上一节中,为大家简明扼要的介绍了微软针对现代分布式系统在Azure上实现的相关服务组件.紧接上文内容,本节将为大家介绍Azur ...

  7. 转:微服务框架之微软Service Fabric

    常见的微服务架构用到的软件&组件: docker(成熟应用) spring boot % spring cloud(技术趋势) Service Fabric(属于后起之秀 背后是微软云的驱动) ...

  8. 【Azure微服务 Service Fabric 】如何转移Service Fabric集群中的种子节点(Seed Node)

    注意:在对Service Fabric的节点做操作之前,请务必确认是否是种子节点(Seed Node)且当前节点的数量是否与SF的持久层要求的数量一致. 可靠性级别是 Service Fabric 群 ...

  9. 【Azure微服务 Service Fabric 】使用az命令创建Service Fabric集群

    问题描述 在使用Service Fabric的快速入门文档: 将 Windows 容器部署到 Service Fabric. 其中在创建Service Fabric时候,示例代码中使用的是PowerS ...

随机推荐

  1. js备忘录1

    新建对象 赋值和取值操作 var book={ topic:"JavaScript", fat: true }; book.topic  通过点访问 book["fat& ...

  2. Scrum立会报告+燃尽图(十二月七日总第三十八次):功能测试

    此作业要求参见:https://edu.cnblogs.com/campus/nenu/2018fall/homework/2284 项目地址:https://git.coding.net/zhang ...

  3. 互评Alpha版本—SkyHunter

    1.根据NABCD评论作品:   N(Need,需求):飞机大战题材的游戏对80,90后的人来说算是童年的记忆,可以在闲暇之余打开电脑玩一会儿.但是面向初中生,高中生的话这种PC小游戏可能不会那么适合 ...

  4. Daily Scrum (2015/11/7)

    今晚谢金洛同学的UI工作完成,我们进行了UI和后端的拼接,准备开始规范化地进行系统测试. 成员 今日任务及成果 时间 明日任务 符美潇 1.把之前PM分配的编码任务及其说明准备好发给PM 1h 待定 ...

  5. [buaa-SE-2017]结对项目-数独程序扩展

    结对项目-数独程序扩展 step1~step3:github:SE-Sudoku-Pair-master step4:github:SE-Sudoku-Pair-dev-combine step5:g ...

  6. 第五次作业+4505B寝室队

    1.需求分析: 作一个简单的MP3播放器,并能显示播放文件的路径. 2.设计思路: 用窗体设计播放器的界面,以市面上主流的播放器为标准,采用一个窗体的界面. 3.实现的功能: 第一是能播放MP3文件, ...

  7. POJ 3597 Polygon Division 多边形剖分

    题目链接: http://poj.org/problem?id=3597 Polygon Division Time Limit: 2000MSMemory Limit: 131072K 问题描述 G ...

  8. Good Time 冲刺 五

    一.今日完成任务情况及遇到的问题 第五天 日期:2018.6.18 王怡镔:今天继续在学习中完善编写页面,对之前的页面进行部分改进. 于鑫宇:修改完善布局,复习. 胡雅馨:今天继续改进页面,努力解决时 ...

  9. Maven解读:项目依赖管理如何优化

    Github地址:https://github.com/zwjlpeng/Maven_Detail Maven最大的好处莫过于其强大的依赖管理系统,在Pom配置文件中指定项目需要的Jar包的坐标,Ma ...

  10. 关于SVM数学细节逻辑的个人理解(一) :得到最大间隔分类器的基本形式

    网上,书上有很多的关于SVM的资料,但是我觉得一些细节的地方并没有讲的太清楚,下面是我对SVM的整个数学原理的推导过程,其中逻辑的推导力求每一步都是有理有据.现在整理出来和大家讨论分享. 因为目前我的 ...