5

我正在尝试使用 SQL Server 作为 Orleans 的数据存储。

我已经设法让我的解决方案使用 Azure 本地存储模拟器工作,但无法让它与 SQL Server 的本地实例一起工作。我使用以下方法创建了数据库:

https://github.com/dotnet/orleans/blob/master/src/OrleansSQLUtils/CreateOrleansTables_SqlServer.sql

并使我的配置文件看起来像这里的一个:

http://dotnet.github.io/orleans/Documentation/Advanced-Concepts/Configuring-SQL-Tables.html

这是我的配置文件:

<?xml version="1.0" encoding="utf-8"?>
<OrleansConfiguration xmlns="urn:orleans">
  <Globals>
    <StorageProviders>
      <SystemStore SystemStoreType ="SqlServer"
           DeploymentId="OrleansTest"
           DataConnectionString="Data Source=.\SQL2014;Initial Catalog=Orleans;Integrated Security=True;Pooling=False;Max Pool Size=200;Asynchronous Processing=True;MultipleActiveResultSets=True" AdoInvariant="System.Data.SqlClient" />
      <Provider Type="Orleans.SqlUtils.StorageProvider.SqlStorageProvider" Name="SqlServer" />
      <!--<Provider Type="Orleans.Storage.AzureTableStorage" Name="AzureStore" DataConnectionString="UseDevelopmentStorage=true" />-->
    </StorageProviders>
    <SeedNode Address="localhost" Port="11111" />
  </Globals>
  <Defaults>
    <Networking Address="localhost" Port="11111" />
    <ProxyingGateway Address="localhost" Port="30000" />
  </Defaults>
</OrleansConfiguration>

我在谷物中添加了以下属性:

[StorageProvider(ProviderName = "SqlServer")]

然后我收到以下错误: Could not locate a state map factory type...

请有人让我知道我需要向提供者添加什么,或者我做错了什么?我是否需要为 SQL Provider 创建与 StateMapFactoryType 相关的内容?

谢谢

4

1 回答 1

4

首先<SystemStore>不是 StorageProvider。该节点用于 Membership Oracle。像这样:

<OrleansConfiguration xmlns="urn:orleans">
  <Globals>
    <SystemStore SystemStoreType ="SqlServer"
       DeploymentId="OrleansTest"
       DataConnectionString="Data Source=.\SQL2014;Initial Catalog=Orleans;Integrated Security=True;Pooling=False;Max Pool Size=200;Asynchronous Processing=True;MultipleActiveResultSets=True" AdoInvariant="System.Data.SqlClient" />        
  </Globals>
  <Defaults>
    <Networking Address="" Port="11111" />
    <ProxyingGateway Address="" Port="30000" />
  </Defaults>
</OrleansConfiguration>

现在让我们放入您的 StorageProvider

<OrleansConfiguration xmlns="urn:orleans">
  <Globals>

<StorageProviders>
  <Provider Type="Orleans.SqlUtils.StorageProvider.SqlStorageProvider" Name="SqlServer" />
</StorageProviders>


    <SystemStore SystemStoreType ="SqlServer"
       DeploymentId="OrleansTest"
       DataConnectionString="Data Source=.\SQL2014;Initial Catalog=Orleans;Integrated Security=True;Pooling=False;Max Pool Size=200;Asynchronous Processing=True;MultipleActiveResultSets=True" AdoInvariant="System.Data.SqlClient" />        
  </Globals>
  <Defaults>
    <Networking Address="" Port="11111" />
    <ProxyingGateway Address="" Port="30000" />
  </Defaults>
</OrleansConfiguration>

现在到了有趣的部分。设置Orleans.SqlUtils.StorageProvider.SqlStorageProvider

这个特定的存储提供程序基于 P&P 组的 ElasticClient,它使用特殊的分片数据库(例如,分片主数据库和分片数据库)

可能会建议这个较低的摩擦提供者(插入无耻的插件(如果它有效,我写了它,如果它没有,那么我不知道是谁做的:D)https://github.com/OrleansContrib/Orleans.StorageProviders.SimpleSQLServerStorage

好的,回到Orleans.SqlUtils.StorageProvider.SqlStorageProvider 你需要更多的配置项:

  • 连接字符串
  • 地图名称
  • StateMapFactoryType

<Provider Type="Orleans.SqlUtils.StorageProvider.SqlStorageProvider" Name="guts"  ConnectionString = "Server=.;Initial catalog=guts;Integrated Security=SSPI;" MapName="guts" StateMapFactoryType="ClassName, assemblyname" />

您将需要创建 StateMapFactory 实现Orleans.SqlUtils.StorageProvider.IGrainStateMapFactory 参见 https://github.com/dotnet/orleans/blob/v1.1.3/src/OrleansSQLUtils/Storage/Provider/IGrainStateMapFactory.cs

您可以使用https://github.com/dotnet/orleans/blob/v1.1.3/src/TesterInternal/StorageTests/SQLAdapter/SampleGrainStateMapFactory.cs 作为参考

但!!看起来 1.1.3 版仍然Orleans.SqlUtils.StorageProvider.IGrainStateMapFactory标记为内部版本,因​​此您必须从源代码编译或从 github 获取最新版本。

于 2016-04-06T22:18:00.577 回答