我是 Apache Ignite 的新手,并尝试在 IIS 网站和 WCF 服务中使用 Ignite。我的测试用例涉及一台 PC 上的两个 IIS 托管的 WCF 测试服务。我在两个 IIS 应用程序中的任何一个中实例化 Ignite,然后尝试从另一个应用程序进行访问。到目前为止这还没有奏效。一旦 Ignite 在一个 IIS 应用程序中启动,我就会从另一个应用程序收到“默认网格实例已启动”的消息,但另一个应用程序无法获取现有默认网格实例的句柄。
我正在从两个 IIS 测试应用程序的 Global.asax Application_Start 运行以下代码。希望有人能够提供见解并指出我正确的方向:
Random random = new Random();
short startCounter = 0;
Stopwatch sw = new Stopwatch();
sw.Start();
do
{
Thread.Sleep( 1000 * random.Next( 10, 20 ) );
IgniteEngine = Ignition.TryGetIgnite();
startCounter++;
if ( null == IgniteEngine )
{
LogHelper.Write( "{0}: CacheManager.InitializeCache attempt {1} to get a new ignite instance failed.".InvariantFormat( CommonSystemInfo.MachineName, startCounter ), "TraceLogger" );
}
if ( null == IgniteEngine )
{
try
{
IgniteEngine = Ignition.Start( new IgniteConfiguration
{
JvmClasspath = System.IO.Directory.GetFiles( System.Web.HttpContext.Current.Server.MapPath( @"~\bin\libs" ) ).Aggregate( ( x, y ) => x + ";" + y )
} );
if ( null != IgniteEngine )
{
LogHelper.Write( "{0}: CacheManager.InitializeCache success starting ignite after {1} attempts and {2} seconds".InvariantFormat( CommonSystemInfo.MachineName, startCounter, sw.Elapsed.TotalSeconds ), "TraceLogger" );
}
}
catch ( Exception ex2 )
{
LogHelper.Write( "{0}: CacheManager.InitializeCache error while trying to start a new ignite instance. {1}".InvariantFormat( CommonSystemInfo.MachineName, ex2.GetAllMessages() ), "TraceLogger" );
}
}
}
while ( null == IgniteEngine && sw.Elapsed.TotalMinutes <= 2 );
看起来您的服务在一个 IIS 应用程序池中运行,这意味着一个进程和不同的应用程序域。这意味着进程内只有一个 JVM,这会导致Default grid instance has already been started
error.
您的选择是:
- 使用不同的
IgniteConfiguration.GridName
- 将不同的 IIS 应用程序池分配给其中一项服务
- 在一个应用程序中运行这两项服务,以便
TryGetIgnite
有效,您不必启动 Ignite 两次
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)