国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

ES查詢報錯:entity content is too long [142501157] for the configured buffer limit [104857600]

這篇具有很好參考價值的文章主要介紹了ES查詢報錯:entity content is too long [142501157] for the configured buffer limit [104857600]。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

java - org.apache.http.ContentTooLongException: entity content is too long [105539255] for the configured buffer limit [104857600] - Stack Overflow

在生產(chǎn)環(huán)境批量同步數(shù)據(jù)的時候,我寫了一個查詢請求,然后直接報錯:entity content is too long [142501157] for the configured buffer limit [104857600]

具體內(nèi)容如下:

Caused by: org.apache.http.ContentTooLongException: entity content is too long [142501157] for the configured buffer limit [104857600]
        at org.elasticsearch.client.HeapBufferedAsyncResponseConsumer.onEntityEnclosed(HeapBufferedAsyncResponseConsumer.java:76)
        at org.apache.http.nio.protocol.AbstractAsyncResponseConsumer.responseReceived(AbstractAsyncResponseConsumer.java:137)
        at org.apache.http.impl.nio.client.MainClientExec.responseReceived(MainClientExec.java:315)
        at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.responseReceived(DefaultClientExchangeHandlerImpl.java:151)
        at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.responseReceived(HttpAsyncRequestExecutor.java:315)
        at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:255)
        at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:81)
        at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:39)
        at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady(AbstractIODispatch.java:114)
        at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:162)
        at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:337)
        at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:315)
        at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:276)
        at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104)
        at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:591)
        at java.lang.Thread.run(Thread.java:748)
        Suppressed: org.apache.http.ContentTooLongException: entity content is too long [142501157] for the configured buffer limit [104857600]
                ... 16 more
                Suppressed: org.apache.http.ContentTooLongException: entity content is too long [142501157] for the configured buffer limit [104857600]
                        ... 16 more

HttpAsyncResponseConsumerFactory類中:

ES查詢報錯:entity content is too long [142501157] for the configured buffer limit [104857600]

HeapBufferedAsyncResponseConsumer類中有一個判斷:返回的內(nèi)容長度大于限定的100MB就會拋出ContentTooLongException異常。

ES查詢報錯:entity content is too long [142501157] for the configured buffer limit [104857600]

我這里用的依賴是:

            <dependency>
                <groupId>org.elasticsearch.client</groupId>
                <artifactId>elasticsearch-rest-client</artifactId>
                <version>6.6.2</version>
            </dependency>

            <dependency>
                <groupId>org.elasticsearch.client</groupId>
                <artifactId>transport</artifactId>
                <version>6.6.2</version>
            </dependency>

            <dependency>
                <groupId>org.elasticsearch.client</groupId>
                <artifactId>elasticsearch-rest-high-level-client</artifactId>
                <version>6.6.2</version>
            </dependency>

            <dependency>
                <groupId>org.elasticsearch</groupId>
                <artifactId>elasticsearch</artifactId>
                <version>6.6.2</version>
            </dependency>

而我們對es進行查詢操作,或者其他增刪改操作是,都會默認使用如下的RequestOptions.DEFAULT

ES查詢報錯:entity content is too long [142501157] for the configured buffer limit [104857600]

進入RequestOptions.DEFAULT看它的代碼:這里用了HeapBufferedResponseConsumerFactory.DEFAULT

ES查詢報錯:entity content is too long [142501157] for the configured buffer limit [104857600]

而這個HeapBufferedResponseConsumerFactory.DEFAULT,就是我們之前看到的,已經(jīng)被限制了100MB返回值的HeapBufferedResponseConsumerFactory。

ES查詢報錯:entity content is too long [142501157] for the configured buffer limit [104857600]

所以有兩種方式可以解決這個bug。

方式一:

不使用默認的RequestOptions.DEFAULT,而通過使用自定義RequestOptions的方式(ES官方api已經(jīng)給我們開放出來了):

RequestOptions.Builder builder = RequestOptions.DEFAULT.toBuilder();
builder.setHttpAsyncResponseConsumerFactory(
    new HttpAsyncResponseConsumerFactory
    //修改為500MB
    .HeapBufferedResponseConsumerFactory(500 * 1024 * 1024));

RequestOptions requestOptions=builder.build();

方式二:

如果不方便修改怎么辦,例如我們使用的是Spring Data ElasticSearch或者是其他的一些框架,而它默認使用的也是RequestOptions.DEFAULT

ES查詢報錯:entity content is too long [142501157] for the configured buffer limit [104857600]

這時候我們可以通過java反射進行修改:

        //設(shè)置es查詢buffer大小
        RequestOptions requestOptions = RequestOptions.DEFAULT;
        Class<? extends RequestOptions> reqClass = requestOptions.getClass();
        Field reqField = reqClass.getDeclaredField("httpAsyncResponseConsumerFactory");
        reqField.setAccessible(true);
        //去除final
        Field modifiersField = Field.class.getDeclaredField("modifiers");
        modifiersField.setAccessible(true);
        modifiersField.setInt(reqField, reqField.getModifiers() & ~Modifier.FINAL);

        //設(shè)置默認的工廠
        reqField.set(requestOptions, new HttpAsyncResponseConsumerFactory() {
            @Override
            public HttpAsyncResponseConsumer<HttpResponse> createHttpAsyncResponseConsumer() {
                //500MB
                return new HeapBufferedAsyncResponseConsumer(5 * 100 * 1024 * 1024);
            }
        });

如果你使用的是springmvc,那么可以把這段代碼加入到攔截器中,這樣可以攔截需要自定義返回值大小的es請求文章來源地址http://www.zghlxwxcb.cn/news/detail-445900.html

到了這里,關(guān)于ES查詢報錯:entity content is too long [142501157] for the configured buffer limit [104857600]的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • 報錯Command line is too long. Shorten the command line xxx【解決辦法】

    報錯Command line is too long. Shorten the command line xxx【解決辦法】

    運行springboot項目的時候,出現(xiàn)報錯,報錯信息如下: Error running OrderServiceBoot. Command line is too long. Shorten the command line via JAR manifest or via a classpath file and rerun. 報錯原因: springboot項目啟動命令過長 解決辦法 解決方法有兩種,正如報錯信息截圖所示,縮短命令行或者改為應(yīng)用程

    2024年02月11日
    瀏覽(24)
  • 查詢ES報錯429 circuit_breaking_exception,“reason“:“[parent] Data too large, data for \[<http_request\>\]

    查詢ES報錯:429 Too Many Requests;circuit_breaking_exception,”reason”:”[parent] Data too large, data for [http_request]“ 問題 :ES查詢報錯:429 Too Many Requests;circuit_breaking_exception,“reason”:“[parent] Data too large, data for [http_request]” 原因 :ES查詢緩存占用內(nèi)存過大,超過閾值(默認70%),查

    2024年02月12日
    瀏覽(30)
  • Command line is too long

    Command line is too long

    目錄 一、遇到的問題 二、使用環(huán)境 三、問題分析 四、解決方案 1、解決方式一 2、解決方式二 上周五,我要改造一個之前從未接觸過的 SpringBoot 項目。我用 git 拉下代碼后,試圖使用 Idea 運行它。但是,Idea 在運行時拋出了一個問題:Error running \\\'Application\\\': Command line is too l

    2023年04月23日
    瀏覽(20)
  • IDEA:Error running,Command line is too long. 解決方法

    IDEA:Error running,Command line is too long. 解決方法

    報錯如下: 原因是啟動命令過長。 解決方法: 1、打開Edit Configurations 2、點擊Modify options設(shè)置,勾選Shorten command line 3、在Edit Configurations界面下方新增的Shorten command line選項中選擇JAR manifest或classpath file 然后 Apply,OK 即可。

    2024年02月01日
    瀏覽(18)
  • Intellij IDEA運行報Command line is too long的解決辦法

    Intellij IDEA運行報Command line is too long的解決辦法

    想哭,vue前端運行起來,對應(yīng)的后端也得起服務(wù)。 后端出的這個bug,下面的博客寫的第二種方法,完整截圖是下面這個。 ????????????????????Intellij IDEA運行報Command line is too long的解決辦法 - 知乎 (zhihu.com)??????? ???????? ? ?

    2024年02月14日
    瀏覽(18)
  • IDEA 啟動錯誤提示:Command line is too long. Shorten command line

    IDEA 啟動錯誤提示:Command line is too long. Shorten command line

    Edit Configurations-configuration-shorten command line none:這是默認選項。IDE不會縮短長類路徑。如果命令行超出操作系統(tǒng)限制,則IDEA將無法運行您的應(yīng)用程序 jar manifest:IDE通過臨時classpath.jar傳遞長類路徑。原始類路徑在MANIFEST.MF中定義為classpath.jar中的類路徑屬性 classpath file:IDE將把

    2024年02月02日
    瀏覽(24)
  • Nginx報錯 HTTP 413 Request Entity Too Large(Payload Too Large)解決方案

    上傳文件時,請求參數(shù)過大,導(dǎo)致超出服務(wù)端限制。 客戶端發(fā)送的實體主體部分比服務(wù)器能夠或者希望處理的要大。? Nginx默認最大能夠上傳1MB文件,打開nginx.conf在http{}中,找到server{}設(shè)置: client_max_body_size 30m;(配置客戶端請求實體最大值) client_body_buffer_size 128k;(配置請

    2024年02月07日
    瀏覽(24)
  • 啟動springboot項目時命令行太長錯誤解決(Command line is too long)

    啟動springboot項目時命令行太長錯誤解決(Command line is too long)

    剛從git拉取的項目進行啟動時報錯,說命令行太長。 Error running ‘YudaoServerApplication’: Command line is too long. Shorten command line for YudaoServerApplication or also for Spring Boot default configuration. 1.選擇項目配置項 2.選擇 Configuration 菜單中的 Shorten command line 下拉框中的 JAR manifest 或者 classpat

    2024年02月12日
    瀏覽(19)
  • elastic安裝報錯:max file descriptors [4096] for elasticsearch process is too low, increase to at least

    elastic安裝報錯:max file descriptors [4096] for elasticsearch process is too low, increase to at least

    一、現(xiàn)象 因為 es 不允許使用root用戶安裝,在使用新建的es用戶安裝的時候報錯如下, max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535] 二、解決辦法 將當(dāng)前用戶的軟硬限制調(diào)大。找到文件 /etc/security/limits.conf ,編輯,在文件的最后追加如下配置: ?

    2024年02月11日
    瀏覽(25)
  • Data too long for column ‘xxxx‘ at row 1 解決辦法

    很簡單的啦,往下看 Data too long for column ‘xxxx’ at row 1 第一種情況就是很普遍的,xxx字段長度不夠 就是用Mybatis映射文件xml,字段匹配順序錯誤即 原來很短的一個列,插入了很長的數(shù)據(jù) 就是數(shù)據(jù)庫字符集的問題 重新設(shè)置字符串長度 仔細看一眼sql,就能排錯 PS: 前端提出來

    2024年02月07日
    瀏覽(24)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包