小编Alk*_*ris的帖子

使用Elastic Cloud/Found随机断开与主节点NoNodeAvailableException的连接

我正在使用带有盾牌和传输java客户端的弹性云(以前找到).与ES通信的应用程序在heroku上运行.我正在使用一个节点对暂存环境进行压力测试

{
    "cluster_name": ...,
    "status": "yellow", 
    "timed_out": false,
    "number_of_nodes": 1,
    "number_of_data_nodes": 1,
    "active_primary_shards": 19,
    "active_shards": 19,
    "relocating_shards": 0,
    "initializing_shards": 0,
    "unassigned_shards": 7,
    "delayed_unassigned_shards": 0,
    "number_of_pending_tasks": 0,
    "number_of_in_flight_fetch": 0
}
Run Code Online (Sandbox Code Playgroud)

一开始一切都很完美.但过了一段时间(3-4分钟),我开始出现一些错误.我已经将日志级别设置为跟踪,这些是我一直在犯的错误(我已经替换了...一切无关紧要的错误.

org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes were available: [[...][...][...][inet[...]]{logical_availability_zone=..., availability_zone=..., max_local_storage_nodes=1, region=..., master=true}]
    at org.elasticsearch.client.transport.TransportClientNodesService$RetryListener.onFailure(TransportClientNodesService.java:242)
    at org.elasticsearch.action.TransportActionNodeProxy$1.handleException(TransportActionNodeProxy.java:78)
    at org.elasticsearch.transport.TransportService$3.run(TransportService.java:290)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.elasticsearch.transport.SendRequestTransportException: [...][inet[...]][indices:data/read/search]
    at org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:286)
    at org.elasticsearch.shield.transport.ShieldClientTransportService.sendRequest(ShieldClientTransportService.java:41)
    at org.elasticsearch.action.TransportActionNodeProxy.execute(TransportActionNodeProxy.java:57)
    at org.elasticsearch.client.transport.support.InternalTransportClient$1.doWithNode(InternalTransportClient.java:109)
    at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:205)
    at org.elasticsearch.client.transport.support.InternalTransportClient.execute(InternalTransportClient.java:106)
    at org.elasticsearch.client.support.AbstractClient.search(AbstractClient.java:334)
    at org.elasticsearch.client.transport.TransportClient.search(TransportClient.java:416)
    at org.elasticsearch.action.search.SearchRequestBuilder.doExecute(SearchRequestBuilder.java:1122)
    at …
Run Code Online (Sandbox Code Playgroud)

java elasticsearch

6
推荐指数
1
解决办法
913
查看次数

将用户输入转换为正则表达式

我正在开发一个项目,用户使用AND OR运算符输入人类可读的搜索字符串.我举三个例子

  1. a AND(b OR c) - >(?=.\ ba\b)(?=.(\ bb\b)|(\ bc\b)).*
  2. OR(b和c)
  3. (a或b)和(c或d)

以上是我可能获得的输入样本.我想获取该输入并将其转换为正则表达式.这不是编译器的样本吗?看着它,我看到我想要做的是将高级命令转换为低级命令.您对我如何完成上述工作有什么建议吗?我想要的是,将正在生成的正则表达式传递给jsoup(伪选择器:matchesOwn)并查询html文档.谢谢您的帮助.

regex expression jsoup

5
推荐指数
1
解决办法
238
查看次数

Jsoup http日志记录

有没有办法记录http请求和响应?我们假设以下请求

Connection.Response res = Jsoup.connect("LOGIN_URL_HERE")
            .data("user", "USER", "pass", "PASS")
            .method(Connection.Method.POST)
            .execute();
Run Code Online (Sandbox Code Playgroud)

如何记录http请求和响应?请注意,我想要HTTP,而不仅仅是要解析的HTML.

html java logging http jsoup

5
推荐指数
1
解决办法
1860
查看次数

替换所有出现的组

我想替换字符串中所有出现的组.

String test = "###,##.##0.0########";
System.out.println(test);
test = test.replaceAll("\\.0(#)", "0");
System.out.println(test);
Run Code Online (Sandbox Code Playgroud)

我试图获得的结果###,##.##0.000000000 基本上,我想要替换所有#尾随的符号.0.我发现这是关于动态替换的,但我不能真正使它工作.

最佳解决方案不会考虑要替换的哈希数量(如果这样可以清除任何混淆).

java regex replaceall

5
推荐指数
2
解决办法
559
查看次数

Docker没有安装卷

只需在Windows 10中设置docker工具箱,我的docker容器就有一点问题.当我进行docker-compose时,实例将启动,但我的/ var/www/html目录中没有安装任何内容.如果我打开Kitematic,我会看到容器,当我点击卷时,我看不到本地文件夹集.这是我的docker-compose.yml的样子.

web:
    build: .
    ports:
        - "80:80"
    volumes:
        - app/:/var/www/html/
Run Code Online (Sandbox Code Playgroud)

我是否需要指定本地目录的绝对路径?app目录与docker-compose.yml文件位于同一文件夹中.

docker docker-compose

5
推荐指数
1
解决办法
5696
查看次数

RabbitMQ java客户端停止消费消息

我的应用程序使用来自 RabbitMQ 的一些消息并处理它们。我有大约 10 个队列,每个队列最多有 10 个消费者(线程)。我的预取为 5。我使用 CloudAMQP 插件(RabbitMQ 作为服务)在 Heroku 中运行我的设置。

我正在使用默认的心跳和连接超时设置(60 秒)运行。

我的java应用程序是一个使用spring-rabbit库的spring boot应用程序。

版本:

RabbitMQ 3.5.3 
Erlang 17.5.3
Java 1.8
Spring boot 1.3.2.RELEASE
Spring rabbit 1.5.3.RELEASE
Run Code Online (Sandbox Code Playgroud)

问题在于,对于一​​个特定队列的消费者来说,在一段时间后停止消费消息。当我重新启动我的 java 应用程序时,一切正常。但其他队列正在正常消耗。应用程序端没有错误。在兔子这边的日志流中,我看到一些条目,例如

= REPORT==== 2016-08-02 15:53:32 UTC ===
closing AMQP connection <SOMETHING> (SOMETHING_ELSE -> SOMETHING_ELSE_ELSE):
{heartbeat_timeout,running}
Run Code Online (Sandbox Code Playgroud)

我无法在本地或 Heroku 的测试环境中重现。

更新

下面的代码可以在AMQConnection.class

int heartbeat = negotiatedMaxValue(this.requestedHeartbeat,
                                   connTune.getHeartbeat());


private static int negotiatedMaxValue(int clientValue, int serverValue) {
        return (clientValue == 0 || serverValue == 0) ?
            Math.max(clientValue, serverValue) :
            Math.min(clientValue, serverValue); …
Run Code Online (Sandbox Code Playgroud)

java heroku rabbitmq spring-rabbit spring-boot

5
推荐指数
1
解决办法
1954
查看次数

外置硬盘上的Docker卷

我正在使用postgres映像在本地运行容器。我需要处理大量数据,并且我想为此使用外部硬盘驱动器。是否可以在外部硬盘驱动器上装载卷?我可以用Flocker完成我想要的吗?

我正在为Mac使用本机docker。

docker flocker

5
推荐指数
1
解决办法
5966
查看次数

liquibase maven 插件多个 changeLogFile

我正在使用liquibase maven plugin通过jenkins自动构建更新数据库更改。

我有这个 pom.xml

<plugin>
    <groupId>org.liquibase</groupId>
    <artifactId>liquibase-maven-plugin</artifactId>
    <version>3.4.2</version>
    <dependencies>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.5</version>
        </dependency>
    </dependencies>
    <configuration>
        <changeLogFile>${basedir}/src/main/resources/schema.sql</changeLogFile>
        <changeLogFile>${basedir}/src/main/resources/data.sql</changeLogFile>
        <driver>org.postgresql.Driver</driver>
        <url>jdbc:postgresql://${db.url}</url>
        <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
    </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

我需要跑schema.sql之前data.sql。当我在本地运行它时,它可以工作。当我通过 jenkins 运行它时,schema changeLogFile第二个执行,所以为了使它工作,我反转了命令。

问题:执行顺序是什么?难道我做错了什么?

liquibase maven-3 maven jenkins

4
推荐指数
1
解决办法
3118
查看次数

使用可完成的未来对方法运行基准测试

我正在尝试衡量特定方法的性能。当直接调用该方法时,我运行基准测试得很好,但是当该方法使用带有自定义执行器的完整未来时,一切都崩溃了。我已经实现了使用可完成的未来的方法,以便在该方法花费太长时间时强制超时。

@Benchmark
@BenchmarkMode(Mode.SingleShotTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Threads(value = 5)
@Warmup(iterations = 20)
@Measurement(iterations = 50, timeUnit = TimeUnit.MILLISECONDS)
public String very_big_query(TestState testState) throws Exception {
    return testState.transpiler.process(testState.veryBigQuery);
}
Run Code Online (Sandbox Code Playgroud)
@State(Scope.Thread)
public static class TestState {
    String veryBigQuery;
    Transpiler transpiler;

    @Setup(Level.Trial)
    public void doSetupTrial() throws Exception {
        veryBigQuery = "(";
        for(int i = 0; i < 99; i++) {
            veryBigQuery += String.format("java_%s OR ", i);
        }
        veryBigQuery += "java_100) AND (";
        for(int i = 100; i < 199; i++) {
            veryBigQuery += String.format("java_%s OR …
Run Code Online (Sandbox Code Playgroud)

java benchmarking java-8 jmh completable-future

4
推荐指数
1
解决办法
1272
查看次数

在配置文件中运行插件的目标

    <profile>
        <id>integration-tests</id>
        <activation>
            <property>
                <name>integrations</name>
                <value>true</value>
            </property>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>1.4.0</version>
                    <executions>
                        <execution>
                            <id>script-chmod</id>
                            <phase>integration-test</phase>
                            <goals>
                                <goal>exec</goal>
                            </goals>
                            <configuration>
                                <executable>chmod</executable>
                                <arguments>
                                    <argument>+x</argument>
                                    <argument>integration-test-docker/integrations.sh</argument>
                                </arguments>
                            </configuration>
                        </execution>
                        <execution>
                            <id>script-exec</id>
                            <phase>integration-test</phase>
                            <goals>
                                <goal>exec</goal>
                            </goals>
                            <configuration>
                                <executable>integration-test-docker/integrations.sh</executable>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
Run Code Online (Sandbox Code Playgroud)

此配置文件中包含更多内容,但我只包含了我想要运行的内容.如何执行此特定插件的特定目标?

我试过mvn exec:exec但是我明白了

[错误]无法执行目标org.codehaus.mojo:exec-maven-plugin:1.3.2:exec(default-cli)on project ando:目标org.codehaus.mojo的参数'executable':exec-maven-插件:1.3.2:exec丢失或无效 - > [帮助1]

此外,错误输出表明版本1.3.2,但我正在使用1.4.0.

pom.xml maven-3 maven exec-maven-plugin maven-profiles

3
推荐指数
1
解决办法
5157
查看次数