问题描述
我正在尝试使用 SQL Server 作为 Orleans 的数据存储.
I'm trying to use SQL Server as a data store for Orleans.
我已设法使用 Azure 本地存储模拟器使我的解决方案正常工作,但无法使其与 SQL Server 的本地实例一起使用.我已经使用以下方法创建了数据库:
I have managed to get my solution working using the Azure Local Storage Emulator, but can't get it to work with a local instance of SQL Server. I've created the database using:
https://github.com/dotnet/orleans/blob/master/src/OrleansSQLUtils/CreateOrleansTables_SqlServer.sql
并使我的配置文件看起来像这里的:
and made my config file look like the one here:
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>
我已将以下属性添加到我的谷物中:
I've added the following attribute to my grains:
[StorageProvider(ProviderName = "SqlServer")]
然后我收到以下错误:找不到状态映射工厂类型...
请有人告诉我我需要向提供者添加什么,或者我是否做错了什么?我需要为 SQL Provider 创建一些与 StateMapFactoryType 相关的东西吗?
Please could someone let me know what I need to add to the Providers or if I am doing something else wrong? Do I need to create something to do with a StateMapFactoryType for the SQL Provider?
谢谢
推荐答案
首先 不是 StorageProvider.该节点用于成员资格 Oracle.像这样:
Firstly the <SystemStore>
is not the StorageProvider. That node is for the Membership Oracle.like this:
<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
now lets put in your 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
now to the fun part. Setting up the Orleans.SqlUtils.StorageProvider.SqlStorageProvider
这个特定的存储提供程序基于 P&P 组的 ElasticClient,它使用特殊的分片数据库(例如分片主数据库和分片数据库)
this particular storageprovider is based on the ElasticClient from the P&P group, which uses a special sharded database (e.g. a shard master database, and the shard database(s))
可能会推荐这个低摩擦的供应商(插入无耻的插件(如果它有效,我写了它,如果它没有,那么我不知道是谁做的:D)https://github.com/OrleansContrib/Orleans.StorageProviders.SimpleSQLServerStorage
might suggest this lower friction provider (insert shameless plug (if it works I wrote it, if it doesnt then I have no idea who did :D ) https://github.com/OrleansContrib/Orleans.StorageProviders.SimpleSQLServerStorage
好的,回到Orleans.SqlUtils.StorageProvider.SqlStorageProvider
您还需要一些配置项:
ok, back to Orleans.SqlUtils.StorageProvider.SqlStorageProvider
you need a few more configuration items:
- 连接字符串
- 地图名称
- 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
You will need to create the StateMapFactory implementing Orleans.SqlUtils.StorageProvider.IGrainStateMapFactory
seehttps://github.com/dotnet/orleans/blob/v1.1.3/src/OrleansSQLUtils/Storage/Provider/IGrainStateMapFactory.cs
BUT!! 看起来 1.1.3 版仍然将 Orleans.SqlUtils.StorageProvider.IGrainStateMapFactory
标记为内部,因此您必须从源代码或从 github 获取最新信息.
BUT!! it looks like release 1.1.3 still has the Orleans.SqlUtils.StorageProvider.IGrainStateMapFactory
marked as internal, so you will have to compile from source or get latest from github.
这篇关于使用 SQL Server 作为 Orleans 存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!