当我尝试创建一个新的IgniteConfiguration实例时,我一直得到空引用异常。这就是我创建配置的方式:
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创建实例,也无法以编程方式启动它,因为null引用异常。
有人有什么想法吗?
答案 0 :(得分:0)
Endpoints
是地址列表,因此应将其初始化为new[] {...}
。请参阅此处的示例:https://apacheignite-net.readme.io/v2.1/docs/configuration#section-c-code
至于第二个问题,你试图为发现和通信设置相同的端口,这没有意义。这是不同的协议,应使用不同的,不相交的端口范围。