我看到网络实例计数设置为-1。 -1是什么意思?
<Parameter Name="Web1_InstanceCount" Value="-1" />
最佳答案
在您的示例中,-1表示仅一个参数值,在上下文中不表示任何含义。用您的变量名,它是可能在ApplicationManifest.xml上的服务声明上使用的参数。
您可能会有这样的事情:
<?xml version="1.0" encoding="utf-8"?>
<ApplicationManifest ApplicationTypeName="MyAppTypeName" ApplicationTypeVersion="1.0.0" xmlns=...>
<Parameters>
<Parameter Name="Web1_InstanceCount" Value="-1" />
<Parameter Name="FEPlacementConstraints" Value="NodeTypeName==FrontEnd" />
</Parameters>
<ServiceManifestImport>
<ServiceManifestRef ServiceManifestName="MyServicePkg" ServiceManifestVersion="1.0.0" />
<ConfigOverrides />
</ServiceManifestImport>
<DefaultServices>
<Service Name="Web1">
<StatelessService ServiceTypeName="MyServiceType" InstanceCount="[Web1_InstanceCount]">
<SingletonPartition />
<PlacementConstraints>[FEPlacementConstraints]</PlacementConstraints>
</StatelessService>
</Service>
</DefaultServices>
</ApplicationManifest>
如果要注意,请在开始时定义参数,并在底部在声明服务时使用由[]括起来的参数。
现在,关于值-1的含义。
-1是动态实例计数,这意味着命名服务(Web1)的实例数量将随着可用的有效节点的数量而动态扩展。在这里注意“可用的有效节点”而不是“所有节点”
为什么有可用的有效节点?
您可以找到更多信息here