如何从两个或多个IIS应用程序中使用Apache Ignite [英] How do I use Apache Ignite from two or more IIS applications

查看:259
本文介绍了如何从两个或多个IIS应用程序中使用Apache Ignite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Apache Ignite的新手,并尝试在IIS网站和WCF服务中使用Ignite。我的测试用例涉及一台PC上的两个IIS托管的WCF测试服务。我在两个IIS应用程序中的任何一个中实例化Ignite,然后尝试从另一个访问。到目前为止,这还没有奏效。一旦Ignite在一个IIS应用程序中启动,我从另一个应用程序获得默认网格实例已经启动,但另一个应用程序无法获得现有默认网格实例的句柄。

I am new to Apache Ignite and trying to use Ignite within IIS websites and WCF services. My test case involves two IIS hosted WCF test services on one PC. I am instantiating Ignite in either of the two IIS applications and then trying to access from the other. So far this has not worked. Once Ignite starts in one IIS app, I get a "Default grid instance has already been started" from the other app, but the other app is not able to get a handle of the existing default grid instance.

我从两个IIS测试应用程序的Global.asax Application_Start运行下面的代码。希望有人可以提供见解并指出我正确的方向:

I am running the code below from the Global.asax Application_Start of both IIS test applications. Hoping someone can give insight and point me in the right direction:

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,导致默认网格实例已经启动错误。

Looks like your services run within one IIS Application Pool, which means one process and different app domains. This means that there is a single JVM within the process, which causes Default grid instance has already been started error.

您的选择是:


  • 使用不同的 IgniteConfiguration.GridName

  • 将不同的IIS应用程序池分配给其中一个服务

  • 在一个应用程序中运行两个服务,以便 TryGetIgnite 工作而且你不必开始点燃两次

  • Use different IgniteConfiguration.GridName
  • Assign different IIS Application Pool to one of the services
  • Run both services within one application so that TryGetIgnite works and you don't have to start Ignite twice

这篇关于如何从两个或多个IIS应用程序中使用Apache Ignite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆