如何在debian 8上设置rails sunspot solr production?(How can I set up rails sunspot solr production on debian 8?)
我有两个带太阳黑子solr的rails web应用程序。
它们在开发环境中非常有效(使用
rake sunspot:solr:start
启动solrrake sunspot:solr:start
),但在生产环境中,我想使用两个rails应用程序安装一个单独的多核solr服务。我该怎么做?
I have two rails web applications with sunspot solr.
They works very well in development environment ( starting solr with
rake sunspot:solr:start
), but in production environment I would like to install a separated multicore solr service using both of the rails application.How can I do it?
原文:https://stackoverflow.com/questions/39478546
最满意答案
如果您的目标是保护
otherClass.executeCritical(con, arg)
调用,那么您将需要锁定otherClass
实例的粒度。 如果目标是在给定时间只有一个线程使用“主连接”,这似乎是你非常想要的东西,那么你需要锁定粒度在TCPMasterConnection
的实例。 在后一种情况下,您的代码将如下所示:public Object criticalFunction(int arg) { synchronized(con) { return otherClass.executeCritical(con, arg); } }
现在,如果你在
otherClass
和con
(TCPMasterConnection)中都有多线程不安全的代码,你可能想要一个更大粒度的锁。 在这种情况下,一个简单的事情可能是锁定在类级别,如其他答案中所述。If your goal is to protect the
otherClass.executeCritical(con, arg)
invocation, then you'll want to lock at the granularity of theotherClass
instance. If the goal is to have only one thread using the "master connection" at a given time, which seems like it would be something you very much want, then you need the locking granularity to be at the instance ofTCPMasterConnection
. In the latter case, your code would look like this:public Object criticalFunction(int arg) { synchronized(con) { return otherClass.executeCritical(con, arg); } }
Now if you have multithread-unsafe code in both
otherClass
andcon
(of TCPMasterConnection), you'll maybe want a lock with larger granularity. In that case, an easy thing might be to lock at the class level as described in other answers.
相关问答
更多-
什么是线程?(What are threads?)[2023-02-17]
维基百科:线程(计算) 维基百科:线程(计算) - 多线程 在Delphi中进行线程化 Wikipedia: Thread (computing) Wikipedia: Thread (computing) - Multithreading Threading in Delphi -
如果您的目标是保护otherClass.executeCritical(con, arg)调用,那么您将需要锁定otherClass实例的粒度。 如果目标是在给定时间只有一个线程使用“主连接”,这似乎是你非常想要的东西,那么你需要锁定粒度在TCPMasterConnection的实例。 在后一种情况下,您的代码将如下所示: public Object criticalFunction(int arg) { synchronized(con) { return ot ...
-
由于我没有对这个问题给予足够的重视,我将其发布到了苹果开发者论坛。 他们建议在启用数据保护之后如果我们要更新应用程序(不删除旧应用程序),我们应该明确为所有文件(包括旧文件)设置数据保护。 所以我做的是遍历我的文档文件夹并将数据保护属性设置为我所有的旧文件。 我还在创建新文件的所有地方设置了数据保护属性。 这解决了我的问题。 所以最重要的是如果您要在旧应用程序中启用数据保护,请更好地明确地执行此操作。 Since I didn't get enough attention to this question ...
-
如果原材料产品不足以生产,请将以下约束添加到mrp.production模型以限制保存制造订单。 from openerp import api from openerp.exceptions import Warning @api.one @api.constrains('move_lines','bom_id') def _check_product_stock_availability(self): if self.move_lines: for move in self.mo ...
-
PHP页面保护(PHP page protection)[2023-06-08]
$_SERVER['HTTP_REFERER']很容易被任何人伪造。 你的安全有多重要? 如果没有人付费访问页面是至关重要的,那么不要依赖HTTP_REFERER。 我很长一段时间没有使用PayPal,但是当我使用PayPal时,它们有一个用于验证付款的回叫网址。 数据流应该看起来像这样 Your Server Paypal ... -
Java,使用线程(Java, working with threads)[2022-08-24]
在存储上创建一个同步方法,在接受存储时返回true。 像这样的东西... public synchronized boolean store ( int num) { if ( items < capacity ) { items ++; return true; } return false; } Create a synchronised method on storage which returns true on accepting s ... -
如何同步线程?(How to synchronize threads?)[2023-06-23]
您需要使用互斥量来避免竞争条件,并且还需要使用pthread_join在进程终止之前同步所有线程。 Mutexes允许您在其中一个线程使用共享资源执行操作时停止某些线程(请参阅man pthread_mutex_lock,pthread_mutex_init) pthread_join在你的代码中是必不可少的,因为它强制你的主线程等待你创建的其他线程,如果你不使用它,你不确定当主线程从主线程返回时所有线程都将完成。 You need to use mutexes ton avoid race conditi ... -
您提供的网址有一个HttpClient类的链接,您可以在其中找到以下文本: 跨站点请求伪造(XSRF)是一种攻击技术,攻击者可以通过该技术欺骗已认证的用户,在不知情的情况下在您的网站上执行操作。 HttpClient支持用于防止XSRF攻击的通用机制。 在执行HTTP请求时,拦截器从Cookie中读取一个标记,默认为XSRF-TOKEN,并将其设置为HTTP标头X-XSRF-TOKEN。 由于只有在您的域上运行的代码才能读取cookie,因此后端可以确定HTTP请求来自您的客户端应用程序,而不是攻击者。 这 ...
-
使用DCOM处理线程(Working with threads with DCOM)[2022-04-28]
1:否。通过使用cricital部分,您可以保证代码一次只能在一个线程中运行; 实际上,任何调用Enter的线程都会挂起 ,直到任何其他运行该代码的线程进入Leave调用。 但这并不意味着它将在主线程中运行(使用GetCurrentThreadID检查) 2:你提到公寓配置,但哪个公寓穿线模型? 这定义了(D)COM何时为您进行线程同步 。 在实践中,COM将使用代理存根和幕后编组来遍历公寓(和网络)边界,除非您选择了多线程公寓,在这种情况下COM将假设组件自己处理线程问题。 如果我理解正确,主表单会冻结' ... -
这通常称为读写器锁。 读写器锁的规则是: 可以在任何给定时间获取任意数量的读锁,可能是由不同的线程获取。 只有一个作家能够获得锁定,并且只有当所有读者都完成时才能获得。 在作者拥有锁定时,没有读者可以获得锁定。 在您的示例中, RebuildAll()将是一个RebuildAll() , DoSomethingA()通过DoSomethingC()将成为读者。 Boost有一个名为boost::shared_mutex的读写器锁的实现。 但是,这还没有出现在标准库中。 This is often calle ...