[test/plugin]immigrate pulsar scenario (#3997)
* Apache Pulsar Immigration. * Add apache license header and move pulsar scenario to Feign_Canal
This commit is contained in:
parent
aa022ffa00
commit
821c50d0e4
|
|
@ -149,6 +149,8 @@ jobs:
|
|||
run: bash test/plugin/run.sh customize-scenario
|
||||
- name: Run canal 1.0.24-1.1.2 (5)
|
||||
run: bash test/plugin/run.sh canal-scenario
|
||||
- name: Run Feign_Canal_Pulsar 2.2.0-2.4.1 (7)
|
||||
run: bash test/plugin/run.sh pulsar-scenario
|
||||
|
||||
Hystrix_SofaRPC_Spring30x:
|
||||
runs-on: ubuntu-18.04
|
||||
|
|
|
|||
|
|
@ -102,6 +102,7 @@ public class DockerComposeRunningGenerator extends AbstractRunningGenerator {
|
|||
service.setImageName(imageName);
|
||||
service.setExpose(dependency.getExpose());
|
||||
service.setLinks(dependency.getDepends_on());
|
||||
service.setStartScript(dependency.getStartScript());
|
||||
service.setHostname(dependency.getHostname());
|
||||
service.setDepends_on(dependency.getDepends_on());
|
||||
service.setEntrypoint(dependency.getEntrypoint());
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ public class DependencyComponent {
|
|||
private String image;
|
||||
private String hostname;
|
||||
private String version;
|
||||
private List<String> startScript;
|
||||
private List<String> links;
|
||||
private List<String> expose;
|
||||
private List<String> entrypoint;
|
||||
|
|
@ -100,4 +101,12 @@ public class DependencyComponent {
|
|||
public void setHealthcheck(List<String> healthcheck) {
|
||||
this.healthcheck = healthcheck;
|
||||
}
|
||||
|
||||
public List<String> getStartScript() {
|
||||
return startScript;
|
||||
}
|
||||
|
||||
public void setStartScript(List<String> startScript) {
|
||||
this.startScript = startScript;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ public class DockerService {
|
|||
private String name;
|
||||
private String imageName;
|
||||
private String hostname;
|
||||
private List<String> startScript;
|
||||
private List<String> links;
|
||||
private List<String> expose;
|
||||
private List<String> entrypoint;
|
||||
|
|
@ -100,4 +101,12 @@ public class DockerService {
|
|||
public void setEnvironment(List<String> environment) {
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
public List<String> getStartScript() {
|
||||
return startScript;
|
||||
}
|
||||
|
||||
public void setStartScript(List<String> startScript) {
|
||||
this.startScript = startScript;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,6 +76,12 @@ services:
|
|||
- ${expose}
|
||||
</#list>
|
||||
</#if>
|
||||
<#if service.startScript??>
|
||||
command:
|
||||
<#list service.startScript as startScript>
|
||||
- ${startScript}
|
||||
</#list>
|
||||
</#if>
|
||||
<#if service.depends_on??>
|
||||
depends_on:
|
||||
<#list service.depends_on as item>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
#!/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 -Dservice.url=${PULSAR_STANDALONE} -jar ${agent_opts} ${home}/../libs/pulsar-scenario.jar &
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
# 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:
|
||||
- {pulsar-scenario: nq 0}
|
||||
instances:
|
||||
- {pulsar-scenario: nq 0}
|
||||
operationNames:
|
||||
- pulsar-scenario: [Pulsar/test/Producer, /case/pulsar-case, Pulsar/test/Consumer/test]
|
||||
segmentItems:
|
||||
- applicationCode: pulsar-scenario
|
||||
segmentSize: ge 3
|
||||
segments:
|
||||
- segmentId: not null
|
||||
spans:
|
||||
- operationName: Pulsar/test/Producer
|
||||
operationId: 0
|
||||
parentSpanId: 0
|
||||
spanId: 1
|
||||
spanLayer: MQ
|
||||
startTime: nq 0
|
||||
endTime: nq 0
|
||||
componentId: 73
|
||||
componentName: ''
|
||||
isError: false
|
||||
spanType: Exit
|
||||
peer: not null
|
||||
peerId: 0
|
||||
tags:
|
||||
- {key: mq.broker, value: not null}
|
||||
- {key: mq.topic, value: 'test'}
|
||||
- operationName: /case/pulsar-case
|
||||
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/pulsar-scenario/case/pulsar-case'}
|
||||
- {key: http.method, value: GET}
|
||||
- segmentId: not null
|
||||
spans:
|
||||
- operationName: Pulsar/Producer/Callback
|
||||
operationId: 0
|
||||
parentSpanId: -1
|
||||
spanId: 0
|
||||
spanLayer: MQ
|
||||
startTime: nq 0
|
||||
endTime: nq 0
|
||||
componentId: 73
|
||||
componentName: ''
|
||||
isError: false
|
||||
spanType: Local
|
||||
peer: ''
|
||||
peerId: 0
|
||||
tags:
|
||||
- {key: mq.topic, value: 'test'}
|
||||
refs:
|
||||
- {parentEndpointId: 0, parentEndpoint: /case/pulsar-case, networkAddressId: 0, entryEndpointId: 0, refType: CrossThread, parentSpanId: 1, parentTraceSegmentId: '${pulsar-scenario[0]}', parentServiceInstanceId: nq 0, networkAddress: '', entryEndpoint: /case/pulsar-case, entryServiceInstanceId: nq 0 }
|
||||
- segmentId: not null
|
||||
spans:
|
||||
- operationName: Pulsar/test/Consumer/test
|
||||
operationId: 0
|
||||
parentSpanId: -1
|
||||
spanId: 0
|
||||
spanLayer: MQ
|
||||
startTime: nq 0
|
||||
endTime: nq 0
|
||||
componentId: 74
|
||||
componentName: ''
|
||||
isError: false
|
||||
spanType: Entry
|
||||
peer: ''
|
||||
peerId: 0
|
||||
tags:
|
||||
- {key: mq.broker, value: not null}
|
||||
- {key: mq.topic, value: 'test'}
|
||||
refs:
|
||||
- {parentEndpointId: 0, parentEndpoint: /case/pulsar-case, networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: '${pulsar-scenario[0]}', parentServiceInstanceId: nq 0, networkAddress: not null, entryEndpoint: /case/pulsar-case, entryServiceInstanceId: nq 0}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
# 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/pulsar-scenario/case/pulsar-case
|
||||
healthCheck: http://localhost:8080/pulsar-scenario/case/healthCheck
|
||||
startScript: ./bin/startup.sh
|
||||
framework: pulsar
|
||||
environment:
|
||||
- PULSAR_STANDALONE=pulsar-standalone:6650
|
||||
depends_on:
|
||||
- pulsar-standalone
|
||||
dependencies:
|
||||
pulsar-standalone:
|
||||
image: apachepulsar/pulsar:2.4.1
|
||||
hostname: pulsar-standalone
|
||||
startScript: ["bin/pulsar","standalone"]
|
||||
expose:
|
||||
- 6650
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
<?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>pulsar-scenario</artifactId>
|
||||
<version>5.0.0</version>
|
||||
<name>skywalking-pulsar-scenario</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<compiler.version>1.8</compiler.version>
|
||||
<test.framework.version>2.4.0</test.framework.version>
|
||||
<test.framework>spring</test.framework>
|
||||
<!-- -->
|
||||
<log4j.version>2.6.2</log4j.version>
|
||||
<spring.version>4.3.8.RELEASE</spring.version>
|
||||
<spring-boot-version>1.5.2.RELEASE</spring-boot-version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.pulsar</groupId>
|
||||
<artifactId>pulsar-client</artifactId>
|
||||
<version>${test.framework.version}</version>
|
||||
</dependency>
|
||||
<!-- Spring Boot-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<version>${spring-boot-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>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-slf4j-impl</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-jcl</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
<version>${spring-boot-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>${spring-boot-version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>pulsar-scenario</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>${compiler.version}</source>
|
||||
<target>${compiler.version}</target>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
</configuration>
|
||||
</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>
|
||||
<outputDirectory>./target/</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>spring-snapshots</id>
|
||||
<url>http://repo.spring.io/snapshot</url>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>spring-milestones</id>
|
||||
<url>http://repo.spring.io/milestone</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</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}/pulsar-scenario.jar</source>
|
||||
<outputDirectory>./libs</outputDirectory>
|
||||
<fileMode>0775</fileMode>
|
||||
</file>
|
||||
</files>
|
||||
</assembly>
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* 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.org.apache.skywalking.apm.testcase.pulsar;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
@EnableAutoConfiguration
|
||||
@SpringBootApplication()
|
||||
@ComponentScan("test.org.apache.skywalking.apm.testcase.pulsar")
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
SpringApplication.run(Application.class, args);
|
||||
} catch (Exception e) {
|
||||
// Never do this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
* 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.org.apache.skywalking.apm.testcase.pulsar.controller;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.pulsar.client.api.Consumer;
|
||||
import org.apache.pulsar.client.api.Message;
|
||||
import org.apache.pulsar.client.api.Producer;
|
||||
import org.apache.pulsar.client.api.PulsarClient;
|
||||
import org.apache.pulsar.client.api.PulsarClientException;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/case")
|
||||
@PropertySource("classpath:application.properties")
|
||||
public class CaseController {
|
||||
|
||||
private Logger logger = LogManager.getLogger(CaseController.class);
|
||||
|
||||
private static final String PULSAR_DOMAIN = "pulsar://";
|
||||
|
||||
@Value("${service.url:127.0.0.1:6650}")
|
||||
private String serviceUrl;
|
||||
|
||||
@RequestMapping("/pulsar-case")
|
||||
@ResponseBody
|
||||
public String pulsarCase() throws PulsarClientException, InterruptedException {
|
||||
|
||||
String topic = "test";
|
||||
|
||||
PulsarClient pulsarClient = PulsarClient.builder()
|
||||
.serviceUrl(PULSAR_DOMAIN + serviceUrl)
|
||||
.build();
|
||||
|
||||
Producer<byte[]> producer = pulsarClient.newProducer()
|
||||
.topic(topic)
|
||||
.create();
|
||||
|
||||
Consumer<byte[]> consumer = pulsarClient.newConsumer()
|
||||
.topic(topic)
|
||||
.subscriptionName("test")
|
||||
.subscribe();
|
||||
|
||||
producer.newMessage()
|
||||
.key("testKey")
|
||||
.value(Integer.toString(1).getBytes())
|
||||
.property("TEST", "TEST")
|
||||
.send();
|
||||
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
|
||||
Thread t = new Thread(() -> {
|
||||
try {
|
||||
Message<byte[]> msg = consumer.receive(3, TimeUnit.SECONDS);
|
||||
if (msg != null) {
|
||||
String propertiesFormat = "key = %s, value = %s";
|
||||
StringBuilder builder = new StringBuilder();
|
||||
msg.getProperties().forEach((k, v) -> builder.append(String.format(propertiesFormat, k, v)).append(", "));
|
||||
logger.info("Received message with messageId = {}, key = {}, value = {}, properties = {}",
|
||||
msg.getMessageId(), msg.getKey(), new String(msg.getValue()), builder.toString());
|
||||
|
||||
}
|
||||
consumer.acknowledge(msg);
|
||||
} catch (PulsarClientException e) {
|
||||
logger.error("Receive message error", e);
|
||||
} finally {
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
|
||||
t.start();
|
||||
|
||||
try {
|
||||
latch.await(3, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
logger.error("Can get message from consumer", e);
|
||||
t.interrupt();
|
||||
throw e;
|
||||
}
|
||||
|
||||
producer.close();
|
||||
consumer.close();
|
||||
|
||||
return "Success";
|
||||
}
|
||||
|
||||
@RequestMapping("/healthCheck")
|
||||
@ResponseBody
|
||||
public String healthCheck() throws InterruptedException {
|
||||
try(PulsarClient pulsarClient = PulsarClient.builder()
|
||||
.serviceUrl(PULSAR_DOMAIN + serviceUrl)
|
||||
.build();
|
||||
Producer<byte[]> producer = pulsarClient.newProducer()
|
||||
.topic("healthCheck")
|
||||
.create()) {
|
||||
if (producer.isConnected()) {
|
||||
return "Success";
|
||||
} else {
|
||||
throw new RuntimeException("Health check error, the reason is test producer is disconnected!");
|
||||
}
|
||||
} catch (PulsarClientException e) {
|
||||
if (e instanceof PulsarClientException.BrokerMetadataException) {
|
||||
// Broker is not ready, retry here
|
||||
Thread.sleep(1000);
|
||||
return healthCheck();
|
||||
} else {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
#
|
||||
# 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
|
||||
server.contextPath=/pulsar-scenario
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?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="debug">
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout charset="UTF-8" pattern="[%d{yyyy-MM-dd HH:mm:ss:SSS}] [%p] - %l - %m%n"/>
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<logger name="com.a.eye.skywalking.ui" level="debug" additivity="false">
|
||||
<AppenderRef ref="Console"/>
|
||||
</logger>
|
||||
<Root level="debug">
|
||||
<AppenderRef ref="Console"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
# 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
|
||||
# "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.
|
||||
|
||||
2.2.0
|
||||
2.2.1
|
||||
2.3.0
|
||||
2.3.1
|
||||
2.3.2
|
||||
2.4.0
|
||||
2.4.1
|
||||
Loading…
Reference in New Issue