当我尝试创建新的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