當我嘗試創建新的IgniteConfiguration實例時,我不斷收到空引用異常。這是我如何創建配置:「未將對象引用設置到對象的實例」我無法讓Apache Ignite.NET在我的.NET應用程序內正確啓動
var cfg = new IgniteConfiguration
{
// Explicitly configure TCP discovery SPI to provide list of initial nodes
// from the first cluster.
DiscoverySpi = new TcpDiscoverySpi
{
// Initial local port to listen to.
LocalPort = 49500,
// Changing local port range. This is an optional action.
LocalPortRange = 2,
IpFinder = new TcpDiscoveryStaticIpFinder
{
// Addresses and port range of the nodes from the first cluster.
// 127.0.0.1 can be replaced with actual IP addresses or host names.
// The port range is optional.
Endpoints = { "127.0.0.1:49500..49520" }
}
},
// Explicitly configure TCP communication SPI changing
// local port number for the nodes from the first cluster.
CommunicationSpi = new TcpCommunicationSpi
{
LocalPort = 49100
}
};
細節沒有內部異常和消息的異常只是說
當我嘗試使用web.config配置啓動Ignite時,它將工作,除非我嘗試明確設置端口。例如,這是一個有效的配置:
<igniteConfiguration xmlns="http://ignite.apache.org/schema/dotnet/IgniteConfigurationSection" localhost="127.0.0.1" peerAssemblyLoadingMode="CurrentAppDomain">
<atomicConfiguration atomicSequenceReserveSize="10" />
<AutoGenerateIgniteInstanceName>true</AutoGenerateIgniteInstanceName>
<discoverySpi type="TcpDiscoverySpi" localPort="49500" localPortRange="2">
<ipFinder type="TcpDiscoveryStaticIpFinder">
<endpoints>
<string>127.0.0.1</string>
<string>127.0.0.1:49500..49502</string>
</endpoints>
</ipFinder>
</discoverySpi>
不過,我有必要不使用mutlicast廣播,我需要設置明確的端口。該配置最終使用一些默認端口。所以,根據我的文檔可以這樣做:
<igniteConfiguration xmlns="http://ignite.apache.org/schema/dotnet/IgniteConfigurationSection" localhost="127.0.0.1" peerAssemblyLoadingMode="CurrentAppDomain">
<atomicConfiguration atomicSequenceReserveSize="10" />
<AutoGenerateIgniteInstanceName>true</AutoGenerateIgniteInstanceName>
<discoverySpi type="TcpDiscoverySpi" localPort="49500" localPortRange="2">
<ipFinder type="TcpDiscoveryStaticIpFinder">
<endpoints>
<string>127.0.0.1</string>
<string>127.0.0.1:49500..49502</string>
</endpoints>
</ipFinder>
</discoverySpi>
<communicationSpi type="TcpCommunicationSpi" localPort="49500" localPortRange="2" />
明確設置端口49500,但使用此配置的應用程序不啓動,只是掛在Ignite.startFromConfiguration()的一步。
所以我不能使用web.config創建實例,也不能以編程方式啓動它,因爲空引用異常。
任何人有任何想法?
再深入一點,我發現這個異常事實上是由構建TcpDiscoveryStaticIpFinder類引發的。這對我來說沒有任何意義,因爲當我反編譯它並查看構造函數的作用時,它看起來沒有任何作用。即使是基類構造函數也是空的。但我一定在做錯事。 – DKhanaf
更新,所以我得到了編程配置的工作。顯然它不喜歡這個Endpoints = {「127.0.0.1:49500..49520」},但它可以很好地與Endpoints = new List {「127.0.0.1:49500..49520」} –
DKhanaf