• Facebook
  • Twitter(现为X)
  • Youtube
  • 内衬
  • RSS
  • 文档
  • 比较
  • 博客
  • 下载
  • 联系我们
下载
显示/隐藏目录

Azure Service Fabric - 创建缓存发现服务

现在集群和管理服务已经创建, NCache 创建发现服务的目的是获取服务器的 IP 地址 NCache 服务器并将它们提供给客户端应用程序。这是一个无状态的 ASP.NET Core Web API,它查询 Azure Service Fabric 命名服务以获取已注册的终结点。 NCache 集群服务并将它们作为 HTTP 响应提供给客户端。

Azure Service Fabric:要创建的服务清单文件 NCache 发现服务

服务清单文件包含通信侦听器获取要侦听的端口的端点。

<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="NCacheDiscoveryPkg"
                 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>
    <StatelessServiceType ServiceTypeName="NCacheDiscoveryType" />
  </ServiceTypes>
  <CodePackage Name="Code" Version="1.0.0">
    <EntryPoint>
      <ExeHost>
        <Program>NCacheDiscovery.exe</Program>
        <WorkingFolder>CodePackage</WorkingFolder>
      </ExeHost>
    </EntryPoint>
    <EnvironmentVariables>
      <EnvironmentVariable Name="ASPNETCORE_ENVIRONMENT" Value=""/>
    </EnvironmentVariables>
  </CodePackage>
  <ConfigPackage Name="Config" Version="1.0.0" />
  <Resources>
    <Endpoints>
      <Endpoint Protocol="http" Name="ServiceEndpoint" UriScheme="http" Port="55100" Type="Input" />
    </Endpoints>
  </Resources>
</ServiceManifest>

这是来自 NCache 服务发现应用程序,其中服务调用 Azure Service Fabric 命名服务来访问由 NCache 服务。

// Beginning Code
            string serviceUri = $"fabric:/ServiceFabricApplication/NCacheService";


            ServicePartitionResolver resolver = ServicePartitionResolver.GetDefault();

            ResolvedServicePartition resolvedServicePartition = await resolver.ResolveAsync(new Uri(serviceUri), new ServicePartitionKey(), new System.Threading.CancellationToken());

            var endpoints = resolvedServicePartition.Endpoints;
            var endpointDictionary =
                new Dictionary<string, List<string>>();

            JObject addresses;
            string bridge_management_address;
            string cache_management_address;
            string cache_client_address;
            string bridge_client_address;

            foreach (var endpoint1 in endpoints)
            {
                addresses = JObject.Parse(endpoint1.Address);
                bridge_management_address = (string)addresses["Endpoints"]["bridge-management"];
                cache_management_address = (string)addresses["Endpoints"]["cache-management"];
                cache_client_address = (string)addresses["Endpoints"]["cache-client"];
                bridge_client_address = (string)addresses["Endpoints"]["bridge-client"];

                if (!endpointDictionary.ContainsKey("bridge-management"))
                {
                    endpointDictionary["bridge-management"] = new List<string>();
                }
                if (!endpointDictionary.ContainsKey("cache-management"))
                {
                    endpointDictionary["cache-management"] = new List<string>();
                }
                if (!endpointDictionary.ContainsKey("cache-client"))
                {
                    endpointDictionary["cache-client"] = new List<string>();
                }
                if (!endpointDictionary.ContainsKey("bridge-client"))
                {
                    endpointDictionary["bridge-client"] = new List<string>();
                }

                endpointDictionary["bridge-management"].Add(bridge_management_address);
                endpointDictionary["cache-management"].Add(cache_management_address);
                endpointDictionary["cache-client"].Add(cache_client_address);
                endpointDictionary["bridge-client"].Add(bridge_client_address);
            }
// Rest of code

参见

部署 NCache 在 Azure 服务结构中
创建 Service Fabric 群集
创建 NCache 集群服务
创建 NCache 管理服务

联系我们

联系电话

+1 (214) 764-6933   (美国)

+44 20 7993 8327   (英国)

 
邮箱地址

sales@alachisoft.com

support@alachisoft.com

NCache
  • NCache 企业版
  • NCache 社區
  • 版本比较
  • NCache 卓越
  • 基准
下载
定价
尝试游乐场

部署
  • 云(SaaS 和软件)
  • 内部部署
  • Kubernetes
  • Docker
技术用例
  • ASP.NET 会话
  • ASP.NET Core 会话
  • 发布/订阅消息
  • 实时 ASP.NET SignalR
  • 物联网(IOT)
  • NoSQL 数据库
  • 流处理
  • 微服务
相关资源
  • 杂志文章
  • 第三方文章
  • 专题文章
  • 视频
  • 白皮书
  • 作品
  • 会谈
  • 博客
  • 文档
客户案例研究
  • 评价
  • 客户
支持
  • 安排演示
  • 论坛(谷歌组)
  • 小技巧
关于我们
  • 领导团队
  • 合作伙伴
  • 新闻
  • 活动
  • 加入我们
联系我们

  • 英语简体中文法语版德语版意大利语版日语版韩语版葡萄牙语西班牙语

  • 联系我们
  •  
  • 网站地图
  •  
  • 使用条款
  •  
  • 隐私政策
©版权所有 Alachisoft 2002 - 版权所有。 NCache 是 Diyatech Corp. 的注册商标。
Back to top