[test/plugin] immigrate elasticsearch-5.x scenario (#3686)
This commit is contained in:
parent
2f3d009e63
commit
7273e63020
|
|
@ -57,7 +57,7 @@ pipeline {
|
|||
}
|
||||
}
|
||||
|
||||
stage('Test Cases Report (129)') {
|
||||
stage('Test Cases Report (132)') {
|
||||
steps {
|
||||
echo "reserve."
|
||||
}
|
||||
|
|
@ -81,6 +81,11 @@ pipeline {
|
|||
sh 'bash test/plugin/run.sh --build_id=wl3_${BUILD_ID} sofarpc-scenario'
|
||||
}
|
||||
}
|
||||
stage('elasticsearch 5.x (3)') {
|
||||
steps {
|
||||
sh 'bash test/plugin/run.sh --build_id=wl3_${BUILD_ID} elasticsearch-5.x-scenario'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Group2') {
|
||||
|
|
@ -107,4 +112,4 @@ pipeline {
|
|||
deleteDir()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
home="$(cd "$(dirname $0)"; pwd)"
|
||||
|
||||
java -jar ${agent_opts} ${home}/../libs/elasticsearch-5.x-scenario.jar &
|
||||
|
|
@ -0,0 +1,177 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
registryItems:
|
||||
applications:
|
||||
- {elasticsearch-5.x-scenario: nq 0}
|
||||
instances:
|
||||
- {elasticsearch-5.x-scenario: 1}
|
||||
operationNames:
|
||||
- elasticsearch-5.x-scenario: [Elasticsearch/IndexRequest, Elasticsearch/GetRequest,
|
||||
Elasticsearch/SearchRequest, Elasticsearch/UpdateRequest,
|
||||
Elasticsearch/DeleteRequest, Elasticsearch/DeleteIndexRequest,
|
||||
/case/elasticsearch]
|
||||
heartbeat: []
|
||||
segmentItems:
|
||||
- applicationCode: elasticsearch-5.x-scenario
|
||||
segmentSize: ge 1
|
||||
segments:
|
||||
- segmentId: not null
|
||||
spans:
|
||||
- operationName: Elasticsearch/IndexRequest
|
||||
operationId: 0
|
||||
parentSpanId: 0
|
||||
spanId: 1
|
||||
spanLayer: Database
|
||||
startTime: nq 0
|
||||
endTime: nq 0
|
||||
componentId: 48
|
||||
componentName: ''
|
||||
isError: false
|
||||
spanType: Exit
|
||||
peer: not null
|
||||
peerId: 0
|
||||
tags:
|
||||
- {key: db.type, value: Elasticsearch}
|
||||
- {key: db.instance, value: not null}
|
||||
- {key: node.address, value: not null}
|
||||
- {key: es.indices, value: not null}
|
||||
- {key: es.types, value: not null}
|
||||
- operationName: Elasticsearch/actionGet
|
||||
operationId: 0
|
||||
parentSpanId: 0
|
||||
spanId: 2
|
||||
spanLayer: null
|
||||
startTime: nq 0
|
||||
endTime: nq 0
|
||||
componentId: 48
|
||||
componentName: ''
|
||||
isError: false
|
||||
spanType: Local
|
||||
peer: null
|
||||
peerId: 0
|
||||
tags:
|
||||
- {key: db.type, value: Elasticsearch}
|
||||
- operationName: Elasticsearch/GetRequest
|
||||
operationId: 0
|
||||
parentSpanId: 0
|
||||
spanId: 3
|
||||
spanLayer: Database
|
||||
startTime: nq 0
|
||||
endTime: nq 0
|
||||
componentId: 48
|
||||
componentName: ''
|
||||
isError: false
|
||||
spanType: Exit
|
||||
peer: not null
|
||||
peerId: 0
|
||||
tags:
|
||||
- {key: db.type, value: Elasticsearch}
|
||||
- {key: db.instance, value: not null}
|
||||
- {key: node.address, value: not null}
|
||||
- {key: es.indices, value: not null}
|
||||
- {key: es.types, value: not null}
|
||||
- operationName: Elasticsearch/SearchRequest
|
||||
operationId: 0
|
||||
parentSpanId: 0
|
||||
spanId: 4
|
||||
spanLayer: Database
|
||||
startTime: nq 0
|
||||
endTime: nq 0
|
||||
componentId: 48
|
||||
componentName: ''
|
||||
isError: false
|
||||
spanType: Exit
|
||||
peer: not null
|
||||
peerId: 0
|
||||
tags:
|
||||
- {key: db.type, value: Elasticsearch}
|
||||
- {key: db.instance, value: not null}
|
||||
- {key: node.address, value: not null}
|
||||
- {key: es.indices, value: not null}
|
||||
- {key: es.types, value: not null}
|
||||
- operationName: Elasticsearch/UpdateRequest
|
||||
operationId: 0
|
||||
parentSpanId: 0
|
||||
spanId: 5
|
||||
spanLayer: Database
|
||||
startTime: nq 0
|
||||
endTime: nq 0
|
||||
componentId: 48
|
||||
componentName: ''
|
||||
isError: false
|
||||
spanType: Exit
|
||||
peer: not null
|
||||
peerId: 0
|
||||
tags:
|
||||
- {key: db.type, value: Elasticsearch}
|
||||
- {key: db.instance, value: not null}
|
||||
- {key: node.address, value: not null}
|
||||
- {key: es.indices, value: not null}
|
||||
- {key: es.types, value: not null}
|
||||
- operationName: Elasticsearch/DeleteRequest
|
||||
operationId: 0
|
||||
parentSpanId: 0
|
||||
spanId: 6
|
||||
spanLayer: Database
|
||||
startTime: nq 0
|
||||
endTime: nq 0
|
||||
componentId: 48
|
||||
componentName: ''
|
||||
isError: false
|
||||
spanType: Exit
|
||||
peer: not null
|
||||
peerId: 0
|
||||
tags:
|
||||
- {key: db.type, value: Elasticsearch}
|
||||
- {key: db.instance, value: not null}
|
||||
- {key: node.address, value: not null}
|
||||
- {key: es.indices, value: not null}
|
||||
- {key: es.types, value: not null}
|
||||
- operationName: Elasticsearch/DeleteIndexRequest
|
||||
operationId: 0
|
||||
parentSpanId: 0
|
||||
spanId: 7
|
||||
spanLayer: Database
|
||||
startTime: nq 0
|
||||
endTime: nq 0
|
||||
componentId: 48
|
||||
componentName: ''
|
||||
isError: false
|
||||
spanType: Exit
|
||||
peer: not null
|
||||
peerId: 0
|
||||
tags:
|
||||
- {key: db.type, value: Elasticsearch}
|
||||
- {key: db.instance, value: not null}
|
||||
- {key: node.address, value: not null}
|
||||
- {key: es.indices, value: ''}
|
||||
- {key: es.types, value: ''}
|
||||
- operationName: /case/elasticsearch
|
||||
operationId: 0
|
||||
parentSpanId: -1
|
||||
spanId: 0
|
||||
spanLayer: Http
|
||||
startTime: nq 0
|
||||
endTime: nq 0
|
||||
componentId: 14
|
||||
componentName: ''
|
||||
isError: false
|
||||
spanType: Entry
|
||||
peer: ''
|
||||
peerId: 0
|
||||
tags:
|
||||
- {key: url, value: 'http://localhost:8080/elasticsearch-case/case/elasticsearch'}
|
||||
- {key: http.method, value: GET}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
type: jvm
|
||||
entryService: http://localhost:8080/elasticsearch-case/case/elasticsearch
|
||||
healthCheck: http://localhost:8080/elasticsearch-case/case/healthcheck
|
||||
startScript: ./bin/startup.sh
|
||||
framework: elasticsearch
|
||||
environment:
|
||||
- elasticsearch.server=elasticsearch-server
|
||||
dependencies:
|
||||
elasticsearch-server:
|
||||
image: docker.elastic.co/elasticsearch/elasticsearch:5.4.0
|
||||
hostname: elasticsearch-server
|
||||
expose:
|
||||
- 9300
|
||||
- 9200
|
||||
environment:
|
||||
- cluster.name=docker-node
|
||||
- xpack.security.enabled=false
|
||||
- bootstrap.memory_lock=true
|
||||
- "ES_JAVA_OPTS=-Xms256m -Xmx256m"
|
||||
- discovery.type=single-node
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
~ contributor license agreements. See the NOTICE file distributed with
|
||||
~ this work for additional information regarding copyright ownership.
|
||||
~ The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
~ (the "License"); you may not use this file except in compliance with
|
||||
~ the License. You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
~
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.apache.skywalking</groupId>
|
||||
<artifactId>elasticsearch-5.x-scenario</artifactId>
|
||||
<version>5.0.0</version>
|
||||
|
||||
<name>skywalking-elasticsearch-5.x-scenario</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<compiler.version>1.8</compiler.version>
|
||||
|
||||
<test.framework.version>5.4.0</test.framework.version>
|
||||
<docker.image.version>${test.framework.version}</docker.image.version>
|
||||
|
||||
<spring-boot.version>2.1.4.RELEASE</spring-boot.version>
|
||||
<lombok.version>1.16.20</lombok.version>
|
||||
<log4j.version>2.8.1</log4j.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- spring boot -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
</dependency>
|
||||
<!-- elasticsearch client -->
|
||||
<dependency>
|
||||
<groupId>org.elasticsearch.client</groupId>
|
||||
<artifactId>transport</artifactId>
|
||||
<version>${test.framework.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>elasticsearch-5.x-scenario</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.6.0</version>
|
||||
<configuration>
|
||||
<source>${compiler.version}</source>
|
||||
<target>${compiler.version}</target>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>1.5.9.RELEASE</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>assemble</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>src/main/assembly/assembly.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
~ contributor license agreements. See the NOTICE file distributed with
|
||||
~ this work for additional information regarding copyright ownership.
|
||||
~ The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
~ (the "License"); you may not use this file except in compliance with
|
||||
~ the License. You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
~
|
||||
-->
|
||||
<assembly
|
||||
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
|
||||
<formats>
|
||||
<format>zip</format>
|
||||
</formats>
|
||||
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<directory>./bin</directory>
|
||||
<fileMode>0775</fileMode>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
|
||||
<files>
|
||||
<file>
|
||||
<source>${project.build.directory}/elasticsearch-5.x-scenario.jar</source>
|
||||
<outputDirectory>./libs</outputDirectory>
|
||||
<fileMode>0775</fileMode>
|
||||
</file>
|
||||
</files>
|
||||
</assembly>
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package test.apache.skywalking.apm.testcase.elasticsearch;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
SpringApplication.run(Application.class, args);
|
||||
} catch (Exception e) {
|
||||
// Never do this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
package test.apache.skywalking.apm.testcase.elasticsearch.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.UUID;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.client.transport.TransportClient;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.transport.client.PreBuiltTransportClient;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/case")
|
||||
public class CaseController {
|
||||
|
||||
private static Logger logger = LogManager.getLogger(CaseController.class);
|
||||
|
||||
@Value("${elasticsearch.server}")
|
||||
private String host;
|
||||
|
||||
@GetMapping("/healthcheck")
|
||||
public String healthcheck() throws Exception {
|
||||
Client client = initTransportClient();
|
||||
ClusterHealthResponse response = client.admin().cluster().prepareHealth()
|
||||
.setWaitForYellowStatus()
|
||||
.get();
|
||||
if (response.isTimedOut()) {
|
||||
String message = "elastic search node start fail!";
|
||||
logger.error(message);
|
||||
throw new RuntimeException(message);
|
||||
}
|
||||
client.close();
|
||||
return "Success";
|
||||
}
|
||||
|
||||
@GetMapping("/elasticsearch")
|
||||
public String elasticsearch() throws Exception {
|
||||
Client client = initTransportClient();
|
||||
String indexName = UUID.randomUUID().toString();
|
||||
try {
|
||||
// create
|
||||
index(client, indexName);
|
||||
// get
|
||||
get(client, indexName);
|
||||
// search
|
||||
search(client, indexName);
|
||||
// update
|
||||
update(client, indexName);
|
||||
// delete
|
||||
delete(client, indexName);
|
||||
// remove index
|
||||
client.admin().indices().prepareDelete(indexName).execute();
|
||||
} finally {
|
||||
if (null != client) {
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
return "Success";
|
||||
}
|
||||
|
||||
private void index(Client client, String indexName) throws IOException {
|
||||
try {
|
||||
client.prepareIndex(indexName, "test", "1")
|
||||
.setSource(XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.field("name", "mysql innodb")
|
||||
.field("price", "0")
|
||||
.field("language", "chinese")
|
||||
.endObject())
|
||||
.get();
|
||||
} catch (IOException e) {
|
||||
logger.error("index document error.", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private void get(Client client, String indexName) {
|
||||
client.prepareGet().setIndex(indexName).setId("1").execute();
|
||||
}
|
||||
|
||||
private void update(Client client, String indexName) throws IOException {
|
||||
try {
|
||||
client.prepareUpdate(indexName, "test", "1")
|
||||
.setDoc(XContentFactory.jsonBuilder().startObject().field("price", "9.9").endObject())
|
||||
.execute();
|
||||
} catch (IOException e) {
|
||||
logger.error("update document error.", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private void delete(Client client, String indexName) {
|
||||
client.prepareDelete(indexName, "test", "1").execute();
|
||||
}
|
||||
|
||||
private void search(Client client, String indexName) {
|
||||
client.prepareSearch(indexName).setTypes("test").setSize(10).execute();
|
||||
}
|
||||
|
||||
private Client initTransportClient() throws UnknownHostException {
|
||||
TransportClient client = null;
|
||||
try {
|
||||
Settings settings = Settings.builder()
|
||||
.put("cluster.name", "docker-node")
|
||||
.put("client.transport.sniff", false)
|
||||
.build();
|
||||
|
||||
client = new PreBuiltTransportClient(settings)
|
||||
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(host), 9300));
|
||||
} catch (UnknownHostException e) {
|
||||
logger.error("create client error", e);
|
||||
throw e;
|
||||
}
|
||||
return client;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
server:
|
||||
port: 8080
|
||||
servlet:
|
||||
context-path: /elasticsearch-case
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
~ contributor license agreements. See the NOTICE file distributed with
|
||||
~ this work for additional information regarding copyright ownership.
|
||||
~ The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
~ (the "License"); you may not use this file except in compliance with
|
||||
~ the License. You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
~
|
||||
-->
|
||||
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_ERR">
|
||||
<PatternLayout charset="UTF-8" pattern="[%d{yyyy-MM-dd HH:mm:ss:SSS}] [%p] - %l - %m%n"/>
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Root level="WARN">
|
||||
<AppenderRef ref="Console"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
5.4.0
|
||||
5.4.1
|
||||
5.4.2
|
||||
Loading…
Reference in New Issue