首页 \ 问答 \ 如何在debian 8上设置rails sunspot solr production?(How can I set up rails sunspot solr production on debian 8?)

如何在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启动solr rake 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
更新时间:2022-04-17 09:04

最满意答案

如果您的目标是保护otherClass.executeCritical(con, arg)调用,那么您将需要锁定otherClass实例的粒度。 如果目标是在给定时间只有一个线程使用“主连接”,这似乎是你非常想要的东西,那么你需要锁定粒度在TCPMasterConnection的实例。 在后一种情况下,您的代码将如下所示:

    public Object criticalFunction(int arg) {
        synchronized(con) {
          return otherClass.executeCritical(con, arg);
        }
    }

现在,如果你在otherClasscon (TCPMasterConnection)中都有多线程不安全的代码,你可能想要一个更大粒度的锁。 在这种情况下,一个简单的事情可能是锁定在类级别,如其他答案中所述。


If your goal is to protect the otherClass.executeCritical(con, arg) invocation, then you'll want to lock at the granularity of the otherClass 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 of TCPMasterConnection. 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 and con (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.

相关问答

更多
  • 维基百科:线程(计算) 维基百科:线程(计算) - 多线程 在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 ...
  • $_SERVER['HTTP_REFERER']很容易被任何人伪造。 你的安全有多重要? 如果没有人付费访问页面是至关重要的,那么不要依赖HTTP_REFERER。 我很长一段时间没有使用PayPal,但是当我使用PayPal时,它们有一个用于验证付款的回叫网址。 数据流应该看起来像这样 Your Server Paypal ...
  • 在存储上创建一个同步方法,在接受存储时返回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 ...
  • 您需要使用互斥量来避免竞争条件,并且还需要使用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请求来自您的客户端应用程序,而不是攻击者。 这 ...
  • 1:否。通过使用cricital部分,您可以保证代码一次只能在一个线程中运行; 实际上,任何调用Enter的线程都会挂起 ,直到任何其他运行该代码的线程进入Leave调用。 但这并不意味着它将在主线程中运行(使用GetCurrentThreadID检查) 2:你提到公寓配置,但哪个公寓穿线模型? 这定义了(D)COM何时为您进行线程同步 。 在实践中,COM将使用代理存根和幕后编组来遍历公寓(和网络)边界,除非您选择了多线程公寓,在这种情况下COM将假设组件自己处理线程问题。 如果我理解正确,主表单会冻结' ...
  • 这通常称为读写器锁。 读写器锁的规则是: 可以在任何给定时间获取任意数量的读锁,可能是由不同的线程获取。 只有一个作家能够获得锁定,并且只有当所有读者都完成时才能获得。 在作者拥有锁定时,没有读者可以获得锁定。 在您的示例中, RebuildAll()将是一个RebuildAll() , DoSomethingA()通过DoSomethingC()将成为读者。 Boost有一个名为boost::shared_mutex的读写器锁的实现。 但是,这还没有出现在标准库中。 This is often calle ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。