[OAP Server][Cluster Plugin] Provide consul cluster plugin (#2036)
* Provide consul cluster plugin. * Change log and application config file. * Add consul's config item into the docker's application.yml. * Fixed bug. * Add consul description into readme. * Add okhttp component license.
This commit is contained in:
parent
2a566bb7a3
commit
dfe2b08599
|
|
@ -37,6 +37,7 @@ Release Notes.
|
|||
- Support Zipkin format again.
|
||||
- Support init mode.
|
||||
- Support namespace in Zookeeper cluster management.
|
||||
- Support consul plugin in cluster module.
|
||||
- OAL generate tool has been integrated into main repo, in the maven `compile` stage.
|
||||
- Optimize trace paging query.
|
||||
- Fix trace query don't use fuzzy query in ElasticSearch storage.
|
||||
|
|
@ -46,7 +47,6 @@ Release Notes.
|
|||
- Fix `Remote clients selector error: / by zero `.
|
||||
- Fix segment TTL is not working.
|
||||
|
||||
|
||||
#### UI
|
||||
- Support service throughput(cpm), successful rate(sla), avg response time and p99/p95/p90/p75/p50 response time.
|
||||
- Fix TopN endpoint link doesn't work right.
|
||||
|
|
@ -59,7 +59,6 @@ Release Notes.
|
|||
- Update user wall and powered-by page.
|
||||
- Add RocketBot UI project link in document.
|
||||
|
||||
|
||||
All issues and pull requests are [here](https://github.com/apache/incubator-skywalking/milestone/31?closed=1)
|
||||
|
||||
6.0.0-alpha
|
||||
|
|
|
|||
|
|
@ -304,6 +304,8 @@ The text of each license is the standard Apache 2.0 license.
|
|||
kubernetes-client 2.0.0: https://github.com/kubernetes-client/java, Apache 2.0
|
||||
proto files from istio/istio: https://github.com/istio/istio Apache 2.0
|
||||
proto files from istio/api: https://github.com/istio/api Apache 2.0
|
||||
consul-client 1.2.6: https://github.com/rickfast/consul-client, Apache 2.0
|
||||
okhttp 3.9.0: https://github.com/square/okhttp, Apache 2.0
|
||||
|
||||
========================================================================
|
||||
MIT licenses
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
Copyright 2014 Orbitz
|
||||
|
||||
Licensed 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.
|
||||
|
|
@ -0,0 +1,202 @@
|
|||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed 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.
|
||||
|
|
@ -19,6 +19,7 @@ cluster:
|
|||
# Please check your ZooKeeper is 3.5+, However, it is also compatible with ZooKeeper 3.4.x. Replace the ZooKeeper 3.5+
|
||||
# library the oap-libs folder with your ZooKeeper 3.4.x library.
|
||||
# zookeeper:
|
||||
# nameSpace: ${SW_NAMESPACE:""}
|
||||
# hostPort: ${SW_CLUSTER_ZK_HOST_PORT:localhost:2181}
|
||||
# #Retry Policy
|
||||
# baseSleepTimeMs: ${SW_CLUSTER_ZK_SLEEP_TIME:1000} # initial amount of time to wait between retries
|
||||
|
|
@ -28,6 +29,10 @@ cluster:
|
|||
# namespace: ${SW_CLUSTER_K8S_NAMESPACE:default}
|
||||
# labelSelector: ${SW_CLUSTER_K8S_LABEL:app=collector,release=skywalking}
|
||||
# uidEnvName: ${SW_CLUSTER_K8S_UID:SKYWALKING_COLLECTOR_UID}
|
||||
# consul:
|
||||
# serviceName: ${SW_SERVICE_NAME:"SkyWalking_OAP_Cluster"}
|
||||
# Consul cluster nodes, example: 10.0.0.1:8500,10.0.0.2:8500,10.0.0.3:8500
|
||||
# hostPort: ${SW_CLUSTER_CONSUL_HOST_PORT:localhost:8500}
|
||||
core:
|
||||
default:
|
||||
restHost: ${SW_CORE_REST_HOST:0.0.0.0}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ Required Zookeeper version, 3.4+
|
|||
```yaml
|
||||
cluster:
|
||||
zookeeper:
|
||||
hostPort: localhost:2181
|
||||
nameSpace: ${SW_NAMESPACE:""}
|
||||
hostPort: ${SW_CLUSTER_ZK_HOST_PORT:localhost:2181}
|
||||
# Retry Policy
|
||||
baseSleepTimeMs: 1000 # initial amount of time to wait between retries
|
||||
maxRetries: 3 # max number of times to retry
|
||||
|
|
@ -41,3 +42,16 @@ cluster:
|
|||
labelSelector: app=collector,release=skywalking
|
||||
uidEnvName: SKYWALKING_COLLECTOR_UID
|
||||
```
|
||||
|
||||
## Consul
|
||||
Now, consul is becoming a famous system, many of companies and developers using consul to be
|
||||
their service discovery solution. Set the **cluster** module's implementor to **consul** in
|
||||
the yml to active.
|
||||
|
||||
```yaml
|
||||
cluster:
|
||||
consul:
|
||||
serviceName: ${SW_SERVICE_NAME:"SkyWalking_OAP_Cluster"}
|
||||
# Consul cluster nodes, example: 10.0.0.1:8500,10.0.0.2:8500,10.0.0.3:8500
|
||||
hostPort: ${SW_CLUSTER_CONSUL_HOST_PORT:localhost:8500}
|
||||
```
|
||||
|
|
@ -66,6 +66,7 @@
|
|||
<hikaricp.version>3.1.0</hikaricp.version>
|
||||
<zipkin.version>2.9.1</zipkin.version>
|
||||
<caffeine.version>2.6.2</caffeine.version>
|
||||
<okhttp.version>3.9.0</okhttp.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
|
@ -153,6 +154,11 @@
|
|||
<artifactId>gson</artifactId>
|
||||
<version>${gson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>${okhttp.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@
|
|||
|
||||
package org.apache.skywalking.oap.server.cluster.plugin.zookeeper;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import lombok.*;
|
||||
import org.apache.skywalking.oap.server.library.module.ModuleConfig;
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
|
|
@ -33,7 +33,7 @@ class ClusterModuleZookeeperConfig extends ModuleConfig {
|
|||
private int maxRetries;
|
||||
|
||||
public String getHostPort() {
|
||||
return StringUtils.isNotEmpty(hostPort) ? hostPort : "localhost:2181";
|
||||
return Strings.isNullOrEmpty(hostPort) ? "localhost:2181" : hostPort;
|
||||
}
|
||||
|
||||
public void setHostPort(String hostPort) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
<?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">
|
||||
<parent>
|
||||
<artifactId>server-cluster-plugin</artifactId>
|
||||
<groupId>org.apache.skywalking</groupId>
|
||||
<version>6.0.0-beta-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>cluster_consul_plugin</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.skywalking</groupId>
|
||||
<artifactId>server-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.orbitz.consul</groupId>
|
||||
<artifactId>consul-client</artifactId>
|
||||
<version>1.2.6</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* 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 org.apache.skywalking.oap.server.cluster.plugin.consul;
|
||||
|
||||
import lombok.*;
|
||||
import org.apache.skywalking.oap.server.library.module.ModuleConfig;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
class ClusterModuleConsulConfig extends ModuleConfig {
|
||||
@Setter @Getter private String serviceName;
|
||||
@Setter @Getter private String hostPort;
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* 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 org.apache.skywalking.oap.server.cluster.plugin.consul;
|
||||
|
||||
import com.google.common.net.HostAndPort;
|
||||
import com.orbitz.consul.Consul;
|
||||
import java.util.*;
|
||||
import org.apache.skywalking.oap.server.core.CoreModule;
|
||||
import org.apache.skywalking.oap.server.core.cluster.*;
|
||||
import org.apache.skywalking.oap.server.library.module.*;
|
||||
import org.apache.skywalking.oap.server.library.util.*;
|
||||
import org.slf4j.*;
|
||||
|
||||
/**
|
||||
* Use consul to manage all service instances in SkyWalking cluster.
|
||||
*
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ClusterModuleConsulProvider extends ModuleProvider {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ClusterModuleConsulProvider.class);
|
||||
|
||||
private final ClusterModuleConsulConfig config;
|
||||
private Consul client;
|
||||
|
||||
public ClusterModuleConsulProvider() {
|
||||
super();
|
||||
this.config = new ClusterModuleConsulConfig();
|
||||
}
|
||||
|
||||
@Override public String name() {
|
||||
return "consul";
|
||||
}
|
||||
|
||||
@Override public Class module() {
|
||||
return ClusterModule.class;
|
||||
}
|
||||
|
||||
@Override public ModuleConfig createConfigBeanIfAbsent() {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override public void prepare() throws ServiceNotProvidedException, ModuleStartException {
|
||||
try {
|
||||
List<Address> addressList = ConnectUtils.parse(config.getHostPort());
|
||||
|
||||
List<HostAndPort> hostAndPorts = new ArrayList<>();
|
||||
for (Address address : addressList) {
|
||||
hostAndPorts.add(HostAndPort.fromParts(address.getHost(), address.getPort()));
|
||||
}
|
||||
|
||||
if (hostAndPorts.size() > 1) {
|
||||
client = Consul.builder().withMultipleHostAndPort(hostAndPorts, 5000).build();
|
||||
} else {
|
||||
client = Consul.builder().withHostAndPort(hostAndPorts.get(0)).build();
|
||||
}
|
||||
} catch (ConnectStringParseException e) {
|
||||
throw new ModuleStartException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
ConsulCoordinator coordinator = new ConsulCoordinator(client, config.getServiceName());
|
||||
this.registerServiceImplementation(ClusterRegister.class, coordinator);
|
||||
this.registerServiceImplementation(ClusterNodesQuery.class, coordinator);
|
||||
}
|
||||
|
||||
@Override public void start() {
|
||||
}
|
||||
|
||||
@Override public void notifyAfterCompleted() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] requiredModules() {
|
||||
return new String[] {CoreModule.NAME};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* 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 org.apache.skywalking.oap.server.cluster.plugin.consul;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.orbitz.consul.*;
|
||||
import com.orbitz.consul.model.agent.*;
|
||||
import com.orbitz.consul.model.health.ServiceHealth;
|
||||
import java.util.*;
|
||||
import org.apache.skywalking.oap.server.core.cluster.*;
|
||||
import org.apache.skywalking.oap.server.core.remote.client.Address;
|
||||
import org.apache.skywalking.oap.server.library.util.CollectionUtils;
|
||||
import org.slf4j.*;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ConsulCoordinator implements ClusterRegister, ClusterNodesQuery {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ConsulCoordinator.class);
|
||||
|
||||
private final Consul client;
|
||||
private final String serviceName;
|
||||
private volatile Address selfAddress;
|
||||
|
||||
public ConsulCoordinator(Consul client, String serviceName) {
|
||||
this.client = client;
|
||||
this.serviceName = serviceName;
|
||||
}
|
||||
|
||||
@Override public List<RemoteInstance> queryRemoteNodes() {
|
||||
HealthClient healthClient = client.healthClient();
|
||||
|
||||
// Discover only "passing" nodes
|
||||
List<ServiceHealth> nodes = healthClient.getHealthyServiceInstances(serviceName).getResponse();
|
||||
|
||||
List<RemoteInstance> remoteInstances = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(nodes)) {
|
||||
nodes.forEach(node -> {
|
||||
if (!Strings.isNullOrEmpty(node.getService().getAddress())) {
|
||||
if (Objects.nonNull(selfAddress)) {
|
||||
if (selfAddress.getHost().equals(node.getService().getAddress()) && selfAddress.getPort() == node.getService().getPort()) {
|
||||
remoteInstances.add(new RemoteInstance(new Address(node.getService().getAddress(), node.getService().getPort(), true)));
|
||||
} else {
|
||||
remoteInstances.add(new RemoteInstance(new Address(node.getService().getAddress(), node.getService().getPort(), false)));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return remoteInstances;
|
||||
}
|
||||
|
||||
@Override public void registerRemote(RemoteInstance remoteInstance) throws ServiceRegisterException {
|
||||
AgentClient agentClient = client.agentClient();
|
||||
|
||||
this.selfAddress = remoteInstance.getAddress();
|
||||
|
||||
Registration registration = ImmutableRegistration.builder()
|
||||
.id(remoteInstance.getAddress().toString())
|
||||
.name(serviceName)
|
||||
.address(remoteInstance.getAddress().getHost())
|
||||
.port(remoteInstance.getAddress().getPort())
|
||||
.check(Registration.RegCheck.grpc(remoteInstance.getAddress().getHost() + ":" + remoteInstance.getAddress().getPort(), 5)) // registers with a TTL of 5 seconds
|
||||
.build();
|
||||
|
||||
agentClient.register(registration);
|
||||
}
|
||||
}
|
||||
|
|
@ -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.
|
||||
#
|
||||
#
|
||||
|
||||
org.apache.skywalking.oap.server.cluster.plugin.consul.ClusterModuleConsulProvider
|
||||
|
|
@ -31,6 +31,7 @@
|
|||
<module>cluster-zookeeper-plugin</module>
|
||||
<module>cluster-standalone-plugin</module>
|
||||
<module>cluster-kubernetes-plugin</module>
|
||||
<module>cluster_consul_plugin</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import org.apache.skywalking.oap.server.core.register.service.*;
|
|||
import org.apache.skywalking.oap.server.core.remote.*;
|
||||
import org.apache.skywalking.oap.server.core.remote.annotation.*;
|
||||
import org.apache.skywalking.oap.server.core.remote.client.*;
|
||||
import org.apache.skywalking.oap.server.core.remote.health.HealthCheckServiceHandler;
|
||||
import org.apache.skywalking.oap.server.core.server.*;
|
||||
import org.apache.skywalking.oap.server.core.source.*;
|
||||
import org.apache.skywalking.oap.server.core.storage.PersistenceTimer;
|
||||
|
|
@ -141,6 +142,7 @@ public class CoreModuleProvider extends ModuleProvider {
|
|||
|
||||
@Override public void start() throws ModuleStartException {
|
||||
grpcServer.addHandler(new RemoteServiceHandler(getManager()));
|
||||
grpcServer.addHandler(new HealthCheckServiceHandler());
|
||||
remoteClientManager.start();
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -25,10 +25,9 @@ import org.apache.skywalking.oap.server.core.register.NetworkAddressInventory;
|
|||
import org.apache.skywalking.oap.server.core.storage.StorageModule;
|
||||
import org.apache.skywalking.oap.server.core.storage.cache.INetworkAddressInventoryCacheDAO;
|
||||
import org.apache.skywalking.oap.server.library.module.*;
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtils;
|
||||
import org.slf4j.*;
|
||||
|
||||
import static java.util.Objects.isNull;
|
||||
import static java.util.Objects.*;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
|
|
@ -72,7 +71,7 @@ public class NetworkAddressInventoryCache implements Service {
|
|||
|
||||
if (isNull(networkAddress)) {
|
||||
networkAddress = getCacheDAO().get(addressId);
|
||||
if (StringUtils.isNotEmpty(networkAddress)) {
|
||||
if (nonNull(networkAddress)) {
|
||||
addressIdCache.put(addressId, networkAddress);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,9 +27,10 @@ import org.apache.skywalking.oap.server.core.query.entity.*;
|
|||
import org.apache.skywalking.oap.server.core.source.DetectPoint;
|
||||
import org.apache.skywalking.oap.server.core.storage.StorageModule;
|
||||
import org.apache.skywalking.oap.server.core.storage.query.*;
|
||||
import org.apache.skywalking.oap.server.library.module.*;
|
||||
import org.apache.skywalking.oap.server.library.module.Service;
|
||||
import org.apache.skywalking.oap.server.library.util.*;
|
||||
import org.apache.skywalking.oap.server.library.module.*;
|
||||
import org.apache.skywalking.oap.server.library.util.CollectionUtils;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.slf4j.*;
|
||||
|
||||
/**
|
||||
|
|
@ -126,7 +127,7 @@ public class TopologyQueryService implements Service {
|
|||
if (CollectionUtils.isNotEmpty(sourceServiceIds)) {
|
||||
List<Call> sourceCalls = getTopologyQueryDAO().loadSpecifiedServerSideServiceRelations(step, startTB, endTB, sourceServiceIds);
|
||||
topology.getNodes().forEach(node -> {
|
||||
if (StringUtils.isEmpty(node.getType())) {
|
||||
if (Strings.isNullOrEmpty(node.getType())) {
|
||||
for (Call call : sourceCalls) {
|
||||
if (node.getId() == call.getTarget()) {
|
||||
node.setType(getComponentLibraryCatalogService().getComponentName(call.getComponentId()));
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
|
|||
import org.apache.skywalking.oap.server.core.source.Scope;
|
||||
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
|
||||
import org.apache.skywalking.oap.server.core.storage.annotation.*;
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtils;
|
||||
import org.elasticsearch.common.Strings;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
|
|
@ -91,7 +91,7 @@ public class EndpointInventory extends RegisterSource {
|
|||
remoteBuilder.addDataLongs(getRegisterTime());
|
||||
remoteBuilder.addDataLongs(getHeartbeatTime());
|
||||
|
||||
remoteBuilder.addDataStrings(StringUtils.getOrDefault(name, Const.EMPTY_STRING));
|
||||
remoteBuilder.addDataStrings(Strings.isNullOrEmpty(name) ? Const.EMPTY_STRING : name);
|
||||
return remoteBuilder;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
|
|||
import org.apache.skywalking.oap.server.core.source.Scope;
|
||||
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
|
||||
import org.apache.skywalking.oap.server.core.storage.annotation.*;
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtils;
|
||||
import org.elasticsearch.common.Strings;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
|
|
@ -88,7 +88,7 @@ public class NetworkAddressInventory extends RegisterSource {
|
|||
remoteBuilder.addDataLongs(getRegisterTime());
|
||||
remoteBuilder.addDataLongs(getHeartbeatTime());
|
||||
|
||||
remoteBuilder.addDataStrings(StringUtils.getOrDefault(name, Const.EMPTY_STRING));
|
||||
remoteBuilder.addDataStrings(Strings.isNullOrEmpty(name) ? Const.EMPTY_STRING : name);
|
||||
return remoteBuilder;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import org.apache.skywalking.oap.server.core.source.Scope;
|
|||
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
|
||||
import org.apache.skywalking.oap.server.core.storage.annotation.*;
|
||||
import org.apache.skywalking.oap.server.library.util.BooleanUtils;
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtils;
|
||||
import org.elasticsearch.common.Strings;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
|
|
@ -123,11 +123,11 @@ public class ServiceInstanceInventory extends RegisterSource {
|
|||
remoteBuilder.addDataLongs(getRegisterTime());
|
||||
remoteBuilder.addDataLongs(getHeartbeatTime());
|
||||
|
||||
remoteBuilder.addDataStrings(StringUtils.getOrDefault(name, Const.EMPTY_STRING));
|
||||
remoteBuilder.addDataStrings(StringUtils.getOrDefault(osName, Const.EMPTY_STRING));
|
||||
remoteBuilder.addDataStrings(StringUtils.getOrDefault(hostName, Const.EMPTY_STRING));
|
||||
remoteBuilder.addDataStrings(StringUtils.getOrDefault(ipv4s, Const.EMPTY_STRING));
|
||||
remoteBuilder.addDataStrings(StringUtils.getOrDefault(instanceUUID, Const.EMPTY_STRING));
|
||||
remoteBuilder.addDataStrings(Strings.isNullOrEmpty(name) ? Const.EMPTY_STRING : name);
|
||||
remoteBuilder.addDataStrings(Strings.isNullOrEmpty(osName) ? Const.EMPTY_STRING : osName);
|
||||
remoteBuilder.addDataStrings(Strings.isNullOrEmpty(hostName) ? Const.EMPTY_STRING : hostName);
|
||||
remoteBuilder.addDataStrings(Strings.isNullOrEmpty(ipv4s) ? Const.EMPTY_STRING : ipv4s);
|
||||
remoteBuilder.addDataStrings(Strings.isNullOrEmpty(instanceUUID) ? Const.EMPTY_STRING : instanceUUID);
|
||||
return remoteBuilder;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,20 +18,17 @@
|
|||
|
||||
package org.apache.skywalking.oap.server.core.register;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import java.util.*;
|
||||
import lombok.*;
|
||||
import org.apache.skywalking.oap.server.core.Const;
|
||||
import org.apache.skywalking.oap.server.core.register.annotation.InventoryType;
|
||||
import org.apache.skywalking.oap.server.core.remote.annotation.StreamData;
|
||||
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
|
||||
import org.apache.skywalking.oap.server.core.source.Scope;
|
||||
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
|
||||
import org.apache.skywalking.oap.server.core.storage.annotation.Column;
|
||||
import org.apache.skywalking.oap.server.core.storage.annotation.StorageEntity;
|
||||
import org.apache.skywalking.oap.server.core.storage.annotation.*;
|
||||
import org.apache.skywalking.oap.server.library.util.BooleanUtils;
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtils;
|
||||
import org.elasticsearch.common.Strings;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
|
|
@ -123,7 +120,7 @@ public class ServiceInventory extends RegisterSource {
|
|||
remoteBuilder.addDataLongs(getHeartbeatTime());
|
||||
remoteBuilder.addDataLongs(getMappingLastUpdateTime());
|
||||
|
||||
remoteBuilder.addDataStrings(StringUtils.getOrDefault(name, Const.EMPTY_STRING));
|
||||
remoteBuilder.addDataStrings(Strings.isNullOrEmpty(name) ? Const.EMPTY_STRING : name);
|
||||
return remoteBuilder;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* 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 org.apache.skywalking.oap.server.core.remote.health;
|
||||
|
||||
import grpc.health.v1.*;
|
||||
import io.grpc.stub.StreamObserver;
|
||||
import org.apache.skywalking.oap.server.library.server.grpc.GRPCHandler;
|
||||
import org.slf4j.*;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class HealthCheckServiceHandler extends HealthGrpc.HealthImplBase implements GRPCHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(HealthCheckServiceHandler.class);
|
||||
|
||||
/**
|
||||
* By my test, consul didn't send the service.
|
||||
*
|
||||
* @param request service
|
||||
* @param responseObserver status
|
||||
*/
|
||||
@Override public void check(HealthCheckService.HealthCheckRequest request,
|
||||
StreamObserver<HealthCheckService.HealthCheckResponse> responseObserver) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Received the gRPC server health check with the service name of {}", request.getService());
|
||||
}
|
||||
|
||||
HealthCheckService.HealthCheckResponse.Builder response = HealthCheckService.HealthCheckResponse.newBuilder();
|
||||
response.setStatus(HealthCheckService.HealthCheckResponse.ServingStatus.SERVING);
|
||||
|
||||
responseObserver.onNext(response.build());
|
||||
responseObserver.onCompleted();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
//This is a health check proto, provided by gRPC team. Please don't change it.
|
||||
//https://github.com/grpc/grpc/blob/master/doc/health-checking.md
|
||||
syntax = "proto3";
|
||||
|
||||
package grpc.health.v1;
|
||||
|
||||
message HealthCheckRequest {
|
||||
string service = 1;
|
||||
}
|
||||
|
||||
message HealthCheckResponse {
|
||||
enum ServingStatus {
|
||||
UNKNOWN = 0;
|
||||
SERVING = 1;
|
||||
NOT_SERVING = 2;
|
||||
}
|
||||
ServingStatus status = 1;
|
||||
}
|
||||
|
||||
service Health {
|
||||
rpc Check (HealthCheckRequest) returns (HealthCheckResponse);
|
||||
}
|
||||
|
|
@ -90,6 +90,7 @@ public class GRPCServer implements Server {
|
|||
@Override
|
||||
public void initialize() {
|
||||
InetSocketAddress address = new InetSocketAddress(host, port);
|
||||
|
||||
nettyServerBuilder = NettyServerBuilder.forAddress(address);
|
||||
nettyServerBuilder = nettyServerBuilder.maxConcurrentCallsPerConnection(maxConcurrentCallsPerConnection).maxMessageSize(maxMessageSize);
|
||||
logger.info("Server started, host {} listening on {}", host, port);
|
||||
|
|
|
|||
|
|
@ -37,7 +37,10 @@
|
|||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>${joda-time.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* 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 org.apache.skywalking.oap.server.library.util;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class Address {
|
||||
private String host;
|
||||
private int port;
|
||||
}
|
||||
|
|
@ -19,21 +19,13 @@
|
|||
package org.apache.skywalking.oap.server.library.util;
|
||||
|
||||
/**
|
||||
* Thrown if the given string which build with hosts and ports is incorrect.
|
||||
*
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class StringUtils {
|
||||
public class ConnectStringParseException extends Exception {
|
||||
|
||||
public static final String EMPTY_STRING = "";
|
||||
|
||||
public static boolean isEmpty(Object str) {
|
||||
return str == null || EMPTY_STRING.equals(str);
|
||||
}
|
||||
|
||||
public static boolean isNotEmpty(Object str) {
|
||||
return !isEmpty(str);
|
||||
}
|
||||
|
||||
public static String getOrDefault(String value, String defaultValue) {
|
||||
return value == null ? defaultValue : value;
|
||||
public ConnectStringParseException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* 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 org.apache.skywalking.oap.server.library.util;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ConnectUtils {
|
||||
|
||||
private ConnectUtils() {
|
||||
}
|
||||
|
||||
public static List<Address> parse(String connectString) throws ConnectStringParseException {
|
||||
connectString = connectString == null ? "" : connectString.trim();
|
||||
connectString = connectString.startsWith(",") ? connectString.replace(",", "") : connectString;
|
||||
|
||||
if (Strings.isNullOrEmpty(connectString)) {
|
||||
throw new ConnectStringParseException("ConnectString cannot be null or empty.");
|
||||
}
|
||||
|
||||
List<Address> result = new ArrayList<>();
|
||||
|
||||
String[] connects = connectString.split(",");
|
||||
for (String connect : connects) {
|
||||
if (Strings.isNullOrEmpty(connect)) {
|
||||
throw new ConnectStringParseException("Invalid connect string pattern.");
|
||||
}
|
||||
|
||||
String[] hostAndPort = connect.split(":");
|
||||
if (hostAndPort.length != 2) {
|
||||
throw new ConnectStringParseException("Invalid connect string pattern.");
|
||||
}
|
||||
|
||||
Address address = new Address();
|
||||
address.setHost(hostAndPort[0]);
|
||||
|
||||
try {
|
||||
address.setPort(Integer.parseInt(hostAndPort[1]));
|
||||
} catch (NumberFormatException e) {
|
||||
throw new ConnectStringParseException("Invalid connect string pattern.");
|
||||
}
|
||||
result.add(address);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* 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 org.apache.skywalking.oap.server.library.util;
|
||||
|
||||
import java.util.List;
|
||||
import org.junit.*;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ConnectUtilTestCase {
|
||||
|
||||
@Test
|
||||
public void parse() throws ConnectStringParseException {
|
||||
List<Address> list = ConnectUtils.parse("10.0.0.1:1000,10.0.0.2:1001");
|
||||
Assert.assertEquals(2, list.size());
|
||||
|
||||
Assert.assertEquals("10.0.0.1", list.get(0).getHost());
|
||||
Assert.assertEquals(1000, list.get(0).getPort());
|
||||
|
||||
Assert.assertEquals("10.0.0.2", list.get(1).getHost());
|
||||
Assert.assertEquals(1001, list.get(1).getPort());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void comma() throws ConnectStringParseException {
|
||||
List<Address> list = ConnectUtils.parse("10.0.0.1:1000,");
|
||||
|
||||
Assert.assertEquals(1, list.size());
|
||||
|
||||
Assert.assertEquals("10.0.0.1", list.get(0).getHost());
|
||||
Assert.assertEquals(1000, list.get(0).getPort());
|
||||
|
||||
list = ConnectUtils.parse(",10.0.0.1:1000");
|
||||
|
||||
Assert.assertEquals(1, list.size());
|
||||
|
||||
Assert.assertEquals("10.0.0.1", list.get(0).getHost());
|
||||
Assert.assertEquals(1000, list.get(0).getPort());
|
||||
}
|
||||
|
||||
@Test(expected = ConnectStringParseException.class)
|
||||
public void nullTest() throws ConnectStringParseException {
|
||||
List<Address> list = ConnectUtils.parse(null);
|
||||
}
|
||||
|
||||
@Test(expected = ConnectStringParseException.class)
|
||||
public void emptyTest() throws ConnectStringParseException {
|
||||
List<Address> list = ConnectUtils.parse("");
|
||||
}
|
||||
|
||||
@Test(expected = ConnectStringParseException.class)
|
||||
public void invalidPattern1() throws ConnectStringParseException {
|
||||
List<Address> list = ConnectUtils.parse("10.0.0.1:");
|
||||
}
|
||||
|
||||
@Test(expected = ConnectStringParseException.class)
|
||||
public void invalidPattern2() throws ConnectStringParseException {
|
||||
List<Address> list = ConnectUtils.parse("10.0.0.1:xx");
|
||||
}
|
||||
}
|
||||
|
|
@ -19,13 +19,14 @@
|
|||
package org.apache.skywalking.oap.query.graphql.resolver;
|
||||
|
||||
import com.coxautodev.graphql.tools.GraphQLQueryResolver;
|
||||
import com.google.common.base.Strings;
|
||||
import java.io.IOException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.skywalking.oap.query.graphql.type.TraceQueryCondition;
|
||||
import org.apache.skywalking.oap.server.core.*;
|
||||
import org.apache.skywalking.oap.server.core.query.*;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.*;
|
||||
import org.apache.skywalking.oap.server.library.module.ModuleManager;
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtils;
|
||||
|
||||
import static java.util.Objects.nonNull;
|
||||
|
||||
|
|
@ -53,7 +54,7 @@ public class TraceQuery implements GraphQLQueryResolver {
|
|||
long endSecondTB = 0;
|
||||
String traceId = Const.EMPTY_STRING;
|
||||
|
||||
if (StringUtils.isNotEmpty(condition.getTraceId())) {
|
||||
if (!Strings.isNullOrEmpty(condition.getTraceId())) {
|
||||
traceId = condition.getTraceId();
|
||||
} else if (nonNull(condition.getQueryDuration())) {
|
||||
startSecondTB = DurationUtils.INSTANCE.startTimeDurationToSecondTimeBucket(condition.getQueryDuration().getStep(), condition.getQueryDuration().getStart());
|
||||
|
|
|
|||
|
|
@ -18,18 +18,16 @@
|
|||
|
||||
package org.apache.skywalking.oap.server.receiver.register.provider.handler.v5.grpc;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import io.grpc.stub.StreamObserver;
|
||||
import java.util.Objects;
|
||||
import org.apache.skywalking.apm.network.language.agent.*;
|
||||
import org.apache.skywalking.oap.server.core.CoreModule;
|
||||
import org.apache.skywalking.oap.server.core.cache.ServiceInstanceInventoryCache;
|
||||
import org.apache.skywalking.oap.server.core.cache.ServiceInventoryCache;
|
||||
import org.apache.skywalking.oap.server.core.register.ServiceInstanceInventory;
|
||||
import org.apache.skywalking.oap.server.core.register.ServiceInventory;
|
||||
import org.apache.skywalking.oap.server.core.cache.*;
|
||||
import org.apache.skywalking.oap.server.core.register.*;
|
||||
import org.apache.skywalking.oap.server.core.register.service.*;
|
||||
import org.apache.skywalking.oap.server.library.module.ModuleManager;
|
||||
import org.apache.skywalking.oap.server.library.server.grpc.GRPCHandler;
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtils;
|
||||
import org.slf4j.*;
|
||||
|
||||
/**
|
||||
|
|
@ -67,7 +65,7 @@ public class InstanceDiscoveryServiceHandler extends InstanceDiscoveryServiceGrp
|
|||
if (osinfo.getProcessNo() != 0) {
|
||||
instanceName += "-pid:" + osinfo.getProcessNo();
|
||||
}
|
||||
if (StringUtils.isNotEmpty(osinfo.getHostname())) {
|
||||
if (!Strings.isNullOrEmpty(osinfo.getHostname())) {
|
||||
instanceName += "@" + osinfo.getHostname();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,17 +18,16 @@
|
|||
|
||||
package org.apache.skywalking.oap.server.receiver.register.provider.handler.v5.rest;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.gson.*;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.apache.skywalking.oap.server.core.CoreModule;
|
||||
import org.apache.skywalking.oap.server.core.cache.ServiceInventoryCache;
|
||||
import org.apache.skywalking.oap.server.core.register.ServiceInstanceInventory;
|
||||
import org.apache.skywalking.oap.server.core.register.ServiceInventory;
|
||||
import org.apache.skywalking.oap.server.core.register.*;
|
||||
import org.apache.skywalking.oap.server.core.register.service.IServiceInstanceInventoryRegister;
|
||||
import org.apache.skywalking.oap.server.library.module.ModuleManager;
|
||||
import org.apache.skywalking.oap.server.library.server.jetty.*;
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtils;
|
||||
import org.slf4j.*;
|
||||
|
||||
/**
|
||||
|
|
@ -84,7 +83,7 @@ public class InstanceDiscoveryServletHandler extends JettyJsonHandler {
|
|||
if (agentOsInfo.getProcessNo() != 0) {
|
||||
instanceName += "-pid:" + agentOsInfo.getProcessNo();
|
||||
}
|
||||
if (StringUtils.isNotEmpty(agentOsInfo.getHostname())) {
|
||||
if (!Strings.isNullOrEmpty(agentOsInfo.getHostname())) {
|
||||
instanceName += "@" + agentOsInfo.getHostname();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,39 +18,20 @@
|
|||
|
||||
package org.apache.skywalking.oap.server.receiver.register.provider.handler.v6.grpc;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import io.grpc.stub.StreamObserver;
|
||||
import org.apache.skywalking.apm.network.common.Commands;
|
||||
import org.apache.skywalking.apm.network.common.KeyIntValuePair;
|
||||
import org.apache.skywalking.apm.network.common.KeyStringValuePair;
|
||||
import org.apache.skywalking.apm.network.register.v2.EndpointMapping;
|
||||
import org.apache.skywalking.apm.network.register.v2.EndpointMappingElement;
|
||||
import org.apache.skywalking.apm.network.register.v2.Enpoints;
|
||||
import org.apache.skywalking.apm.network.register.v2.NetAddressMapping;
|
||||
import org.apache.skywalking.apm.network.register.v2.NetAddresses;
|
||||
import org.apache.skywalking.apm.network.register.v2.RegisterGrpc;
|
||||
import org.apache.skywalking.apm.network.register.v2.ServiceAndNetworkAddressMappings;
|
||||
import org.apache.skywalking.apm.network.register.v2.ServiceInstanceRegisterMapping;
|
||||
import org.apache.skywalking.apm.network.register.v2.ServiceInstances;
|
||||
import org.apache.skywalking.apm.network.register.v2.ServiceRegisterMapping;
|
||||
import org.apache.skywalking.apm.network.register.v2.Services;
|
||||
import org.apache.skywalking.apm.network.common.*;
|
||||
import org.apache.skywalking.apm.network.register.v2.*;
|
||||
import org.apache.skywalking.apm.util.StringUtil;
|
||||
import org.apache.skywalking.oap.server.core.Const;
|
||||
import org.apache.skywalking.oap.server.core.CoreModule;
|
||||
import org.apache.skywalking.oap.server.core.cache.ServiceInstanceInventoryCache;
|
||||
import org.apache.skywalking.oap.server.core.cache.ServiceInventoryCache;
|
||||
import org.apache.skywalking.oap.server.core.register.ServiceInstanceInventory;
|
||||
import org.apache.skywalking.oap.server.core.register.ServiceInventory;
|
||||
import org.apache.skywalking.oap.server.core.register.service.IEndpointInventoryRegister;
|
||||
import org.apache.skywalking.oap.server.core.register.service.INetworkAddressInventoryRegister;
|
||||
import org.apache.skywalking.oap.server.core.register.service.IServiceInstanceInventoryRegister;
|
||||
import org.apache.skywalking.oap.server.core.register.service.IServiceInventoryRegister;
|
||||
import org.apache.skywalking.oap.server.core.*;
|
||||
import org.apache.skywalking.oap.server.core.cache.*;
|
||||
import org.apache.skywalking.oap.server.core.register.*;
|
||||
import org.apache.skywalking.oap.server.core.register.service.*;
|
||||
import org.apache.skywalking.oap.server.core.source.DetectPoint;
|
||||
import org.apache.skywalking.oap.server.library.module.ModuleManager;
|
||||
import org.apache.skywalking.oap.server.library.server.grpc.GRPCHandler;
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtils;
|
||||
import org.apache.skywalking.oap.server.receiver.register.provider.handler.v5.grpc.InstanceDiscoveryServiceHandler;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.*;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
|
|
@ -125,7 +106,7 @@ public class RegisterServiceHandler extends RegisterGrpc.RegisterImplBase implem
|
|||
if (agentOsInfo.getProcessNo() != 0) {
|
||||
instanceName += "-pid:" + agentOsInfo.getProcessNo();
|
||||
}
|
||||
if (StringUtils.isNotEmpty(agentOsInfo.getHostname())) {
|
||||
if (!Strings.isNullOrEmpty(agentOsInfo.getHostname())) {
|
||||
instanceName += "@" + agentOsInfo.getHostname();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
package org.apache.skywalking.oap.server.receiver.register.provider.handler.v5;
|
||||
|
||||
import io.grpc.*;
|
||||
import io.grpc.stub.MetadataUtils;
|
||||
import org.apache.skywalking.apm.network.language.agent.*;
|
||||
import org.slf4j.*;
|
||||
|
||||
|
|
@ -34,6 +35,10 @@ public class ApplicationRegisterHandlerTestCase {
|
|||
|
||||
ApplicationRegisterServiceGrpc.ApplicationRegisterServiceBlockingStub stub = ApplicationRegisterServiceGrpc.newBlockingStub(channel);
|
||||
|
||||
Metadata authHeader = new Metadata();
|
||||
authHeader.put(Metadata.Key.of("Authentication", Metadata.ASCII_STRING_MARSHALLER), "c4a4baabf931f2379bdfe53a450ecb89");
|
||||
stub = MetadataUtils.attachHeaders(stub, authHeader);
|
||||
|
||||
Application.Builder application = Application.newBuilder();
|
||||
application.setApplicationCode("dubbox-consumer");
|
||||
|
||||
|
|
|
|||
|
|
@ -18,12 +18,12 @@
|
|||
|
||||
package org.apache.skywalking.oap.server.receiver.trace.provider.parser.standardization;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import org.apache.skywalking.oap.server.core.*;
|
||||
import org.apache.skywalking.oap.server.core.cache.ServiceInstanceInventoryCache;
|
||||
import org.apache.skywalking.oap.server.core.register.service.*;
|
||||
import org.apache.skywalking.oap.server.core.source.DetectPoint;
|
||||
import org.apache.skywalking.oap.server.library.module.ModuleManager;
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtils;
|
||||
import org.apache.skywalking.oap.server.receiver.trace.provider.parser.decorator.ReferenceDecorator;
|
||||
import org.slf4j.*;
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ public class ReferenceIdExchanger implements IdExchanger<ReferenceDecorator> {
|
|||
|
||||
@Override public boolean exchange(ReferenceDecorator standardBuilder, int serviceId) {
|
||||
if (standardBuilder.getEntryEndpointId() == 0) {
|
||||
String entryEndpointName = StringUtils.isNotEmpty(standardBuilder.getEntryEndpointName()) ? standardBuilder.getEntryEndpointName() : Const.DOMAIN_OPERATION_NAME;
|
||||
String entryEndpointName = Strings.isNullOrEmpty(standardBuilder.getEntryEndpointName()) ? Const.DOMAIN_OPERATION_NAME : standardBuilder.getEntryEndpointName();
|
||||
int entryEndpointId = endpointInventoryRegister.get(serviceInstanceInventoryCache.get(standardBuilder.getEntryServiceInstanceId()).getServiceId(), entryEndpointName, DetectPoint.SERVER.ordinal());
|
||||
|
||||
if (entryEndpointId == 0) {
|
||||
|
|
@ -71,7 +71,7 @@ public class ReferenceIdExchanger implements IdExchanger<ReferenceDecorator> {
|
|||
}
|
||||
|
||||
if (standardBuilder.getParentEndpointId() == 0) {
|
||||
String parentEndpointName = StringUtils.isNotEmpty(standardBuilder.getParentEndpointName()) ? standardBuilder.getParentEndpointName() : Const.DOMAIN_OPERATION_NAME;
|
||||
String parentEndpointName = Strings.isNullOrEmpty(standardBuilder.getParentEndpointName()) ? Const.DOMAIN_OPERATION_NAME : standardBuilder.getParentEndpointName();
|
||||
int parentEndpointId = endpointInventoryRegister.get(serviceInstanceInventoryCache.get(standardBuilder.getParentServiceInstanceId()).getServiceId(), parentEndpointName, DetectPoint.SERVER.ordinal());
|
||||
|
||||
if (parentEndpointId == 0) {
|
||||
|
|
@ -87,7 +87,7 @@ public class ReferenceIdExchanger implements IdExchanger<ReferenceDecorator> {
|
|||
}
|
||||
}
|
||||
|
||||
if (standardBuilder.getNetworkAddressId() == 0 && StringUtils.isNotEmpty(standardBuilder.getNetworkAddress())) {
|
||||
if (standardBuilder.getNetworkAddressId() == 0 && !Strings.isNullOrEmpty(standardBuilder.getNetworkAddress())) {
|
||||
int networkAddressId = networkAddressInventoryRegister.getOrCreate(standardBuilder.getNetworkAddress());
|
||||
|
||||
if (networkAddressId == 0) {
|
||||
|
|
|
|||
|
|
@ -18,12 +18,12 @@
|
|||
|
||||
package org.apache.skywalking.oap.server.receiver.trace.provider.parser.standardization;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import org.apache.skywalking.oap.server.core.*;
|
||||
import org.apache.skywalking.oap.server.core.config.IComponentLibraryCatalogService;
|
||||
import org.apache.skywalking.oap.server.core.register.service.*;
|
||||
import org.apache.skywalking.oap.server.core.source.DetectPoint;
|
||||
import org.apache.skywalking.oap.server.library.module.ModuleManager;
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtils;
|
||||
import org.apache.skywalking.oap.server.receiver.trace.provider.parser.decorator.SpanDecorator;
|
||||
import org.slf4j.*;
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ public class SpanIdExchanger implements IdExchanger<SpanDecorator> {
|
|||
}
|
||||
|
||||
@Override public boolean exchange(SpanDecorator standardBuilder, int serviceId) {
|
||||
if (standardBuilder.getComponentId() == 0 && StringUtils.isNotEmpty(standardBuilder.getComponent())) {
|
||||
if (standardBuilder.getComponentId() == 0 && !Strings.isNullOrEmpty(standardBuilder.getComponent())) {
|
||||
int componentId = componentLibraryCatalogService.getComponentId(standardBuilder.getComponent());
|
||||
|
||||
if (componentId == 0) {
|
||||
|
|
@ -68,7 +68,7 @@ public class SpanIdExchanger implements IdExchanger<SpanDecorator> {
|
|||
}
|
||||
}
|
||||
|
||||
if (standardBuilder.getPeerId() == 0 && StringUtils.isNotEmpty(standardBuilder.getPeer())) {
|
||||
if (standardBuilder.getPeerId() == 0 && !Strings.isNullOrEmpty(standardBuilder.getPeer())) {
|
||||
int peerId = networkAddressInventoryRegister.getOrCreate(standardBuilder.getPeer());
|
||||
|
||||
if (peerId == 0) {
|
||||
|
|
@ -87,7 +87,7 @@ public class SpanIdExchanger implements IdExchanger<SpanDecorator> {
|
|||
}
|
||||
|
||||
if (standardBuilder.getOperationNameId() == 0) {
|
||||
String endpointName = StringUtils.isNotEmpty(standardBuilder.getOperationName()) ? standardBuilder.getOperationName() : Const.DOMAIN_OPERATION_NAME;
|
||||
String endpointName = Strings.isNullOrEmpty(standardBuilder.getOperationName()) ? Const.DOMAIN_OPERATION_NAME : standardBuilder.getOperationName();
|
||||
int endpointId = endpointInventoryRegister.getOrCreate(serviceId, endpointName, DetectPoint.fromSpanType(standardBuilder.getSpanType()));
|
||||
|
||||
if (endpointId == 0) {
|
||||
|
|
|
|||
|
|
@ -18,30 +18,17 @@
|
|||
|
||||
package org.apache.skywalking.oap.server.receiver.zipkin.transform;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import com.google.common.base.Strings;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.apache.skywalking.apm.network.common.KeyStringValuePair;
|
||||
import org.apache.skywalking.apm.network.language.agent.RefType;
|
||||
import org.apache.skywalking.apm.network.language.agent.SpanType;
|
||||
import org.apache.skywalking.apm.network.language.agent.UniqueId;
|
||||
import org.apache.skywalking.apm.network.language.agent.v2.Log;
|
||||
import org.apache.skywalking.apm.network.language.agent.v2.SegmentObject;
|
||||
import org.apache.skywalking.apm.network.language.agent.v2.SegmentReference;
|
||||
import org.apache.skywalking.apm.network.language.agent.v2.SpanObjectV2;
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtils;
|
||||
import org.apache.skywalking.oap.server.receiver.zipkin.CoreRegisterLinker;
|
||||
import org.apache.skywalking.oap.server.receiver.zipkin.ZipkinTraceOSInfoBuilder;
|
||||
import org.apache.skywalking.apm.network.language.agent.*;
|
||||
import org.apache.skywalking.apm.network.language.agent.v2.*;
|
||||
import org.apache.skywalking.oap.server.receiver.zipkin.*;
|
||||
import org.apache.skywalking.oap.server.receiver.zipkin.data.SkyWalkingTrace;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import zipkin2.Endpoint;
|
||||
import zipkin2.Span;
|
||||
import zipkin2.*;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
|
|
@ -87,7 +74,7 @@ public class SegmentBuilder {
|
|||
// Ignore the whole trace.
|
||||
// :P Hope anyone could provide better solution.
|
||||
// Wu Sheng.
|
||||
if (StringUtils.isNotEmpty(applicationCode)) {
|
||||
if (!Strings.isNullOrEmpty(applicationCode)) {
|
||||
timestamp = rootSpan.timestampAsLong();
|
||||
builder.context.addApp(applicationCode, rootSpan.timestampAsLong() / 1000);
|
||||
|
||||
|
|
@ -158,7 +145,7 @@ public class SegmentBuilder {
|
|||
spanBuilder.setParentSpanId(parentSegmentSpan.getSpanId());
|
||||
}
|
||||
Span.Kind kind = span.kind();
|
||||
String opName = Strings.isBlank(span.name()) ? "-" : span.name();
|
||||
String opName = Strings.isNullOrEmpty(span.name()) ? "-" : span.name();
|
||||
spanBuilder.setOperationName(opName);
|
||||
ClientSideSpan clientSideSpan;
|
||||
switch (kind) {
|
||||
|
|
@ -287,10 +274,10 @@ public class SegmentBuilder {
|
|||
Integer port = 0;
|
||||
|
||||
if (endpoint != null) {
|
||||
if (StringUtils.isNotEmpty(endpoint.ipv4())) {
|
||||
if (!Strings.isNullOrEmpty(endpoint.ipv4())) {
|
||||
ip = endpoint.ipv4();
|
||||
port = endpoint.port();
|
||||
} else if (StringUtils.isNotEmpty(endpoint.ipv6())) {
|
||||
} else if (!Strings.isNullOrEmpty(endpoint.ipv6())) {
|
||||
ip = endpoint.ipv6();
|
||||
port = endpoint.port();
|
||||
}
|
||||
|
|
@ -309,7 +296,7 @@ public class SegmentBuilder {
|
|||
private LinkedList<Segment> segmentsStack = new LinkedList<>();
|
||||
|
||||
private boolean isAppChanged(String applicationCode) {
|
||||
return StringUtils.isNotEmpty(applicationCode) && !applicationCode.equals(currentIDs().applicationCode);
|
||||
return !Strings.isNullOrEmpty(applicationCode) && !applicationCode.equals(currentIDs().applicationCode);
|
||||
}
|
||||
|
||||
private Segment addApp(String serviceCode, long registerTime) throws Exception {
|
||||
|
|
@ -394,9 +381,9 @@ public class SegmentBuilder {
|
|||
|
||||
private void addSpan(SpanObjectV2.Builder spanBuilder) {
|
||||
String operationName = spanBuilder.getOperationName();
|
||||
if (entryEndpointId == 0 && StringUtils.isNotEmpty(operationName)) {
|
||||
if (entryEndpointId == 0 && !Strings.isNullOrEmpty(operationName)) {
|
||||
if (SpanType.Entry == spanBuilder.getSpanType()) {
|
||||
if (StringUtils.isNotEmpty(operationName)) {
|
||||
if (!Strings.isNullOrEmpty(operationName)) {
|
||||
entryEndpointName = operationName;
|
||||
} else {
|
||||
entryEndpointId = spanBuilder.getOperationNameId();
|
||||
|
|
@ -406,7 +393,7 @@ public class SegmentBuilder {
|
|||
|
||||
// init by root span
|
||||
if (spanBuilder.getSpanId() == 1 && entryEndpointId == 0) {
|
||||
if (StringUtils.isNotEmpty(operationName)) {
|
||||
if (!Strings.isNullOrEmpty(operationName)) {
|
||||
entryEndpointName = operationName;
|
||||
} else {
|
||||
entryEndpointId = spanBuilder.getOperationNameId();
|
||||
|
|
|
|||
|
|
@ -66,6 +66,11 @@
|
|||
<artifactId>cluster-kubernetes-plugin</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.skywalking</groupId>
|
||||
<artifactId>cluster_consul_plugin</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<!-- cluster module -->
|
||||
|
||||
<!-- receiver module -->
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ cluster:
|
|||
# Please check your ZooKeeper is 3.5+, However, it is also compatible with ZooKeeper 3.4.x. Replace the ZooKeeper 3.5+
|
||||
# library the oap-libs folder with your ZooKeeper 3.4.x library.
|
||||
# zookeeper:
|
||||
# nameSpace: ${SW_NAMESPACE:""}
|
||||
# hostPort: ${SW_CLUSTER_ZK_HOST_PORT:localhost:2181}
|
||||
# #Retry Policy
|
||||
# baseSleepTimeMs: ${SW_CLUSTER_ZK_SLEEP_TIME:1000} # initial amount of time to wait between retries
|
||||
|
|
@ -28,6 +29,10 @@ cluster:
|
|||
# namespace: ${SW_CLUSTER_K8S_NAMESPACE:default}
|
||||
# labelSelector: ${SW_CLUSTER_K8S_LABEL:app=collector,release=skywalking}
|
||||
# uidEnvName: ${SW_CLUSTER_K8S_UID:SKYWALKING_COLLECTOR_UID}
|
||||
# consul:
|
||||
# serviceName: ${SW_SERVICE_NAME:"SkyWalking_OAP_Cluster"}
|
||||
# Consul cluster nodes, example: 10.0.0.1:8500,10.0.0.2:8500,10.0.0.3:8500
|
||||
# hostPort: ${SW_CLUSTER_CONSUL_HOST_PORT:localhost:8500}
|
||||
core:
|
||||
default:
|
||||
restHost: ${SW_CORE_REST_HOST:0.0.0.0}
|
||||
|
|
@ -72,14 +77,14 @@ receiver-trace:
|
|||
sampleRate: ${SW_TRACE_SAMPLE_RATE:10000} # The sample rate precision is 1/10000. 10000 means 100% sample in default.
|
||||
receiver-jvm:
|
||||
default:
|
||||
service-mesh:
|
||||
default:
|
||||
bufferPath: ${SW_SERVICE_MESH_BUFFER_PATH:../mesh-buffer/} # Path to trace buffer files, suggest to use absolute path
|
||||
bufferOffsetMaxFileSize: ${SW_SERVICE_MESH_OFFSET_MAX_FILE_SIZE:100} # Unit is MB
|
||||
bufferDataMaxFileSize: ${SW_SERVICE_MESH_BUFFER_DATA_MAX_FILE_SIZE:500} # Unit is MB
|
||||
bufferFileCleanWhenRestart: ${SW_SERVICE_MESH_BUFFER_FILE_CLEAN_WHEN_RESTART:false}
|
||||
istio-telemetry:
|
||||
default:
|
||||
#service-mesh:
|
||||
# default:
|
||||
# bufferPath: ${SW_SERVICE_MESH_BUFFER_PATH:../mesh-buffer/} # Path to trace buffer files, suggest to use absolute path
|
||||
# bufferOffsetMaxFileSize: ${SW_SERVICE_MESH_OFFSET_MAX_FILE_SIZE:100} # Unit is MB
|
||||
# bufferDataMaxFileSize: ${SW_SERVICE_MESH_BUFFER_DATA_MAX_FILE_SIZE:500} # Unit is MB
|
||||
# bufferFileCleanWhenRestart: ${SW_SERVICE_MESH_BUFFER_FILE_CLEAN_WHEN_RESTART:false}
|
||||
#istio-telemetry:
|
||||
# default:
|
||||
#receiver_zipkin:
|
||||
# default:
|
||||
# host: ${SW_RECEIVER_ZIPKIN_HOST:0.0.0.0}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,10 @@ cluster:
|
|||
# namespace: ${SW_CLUSTER_K8S_NAMESPACE:default}
|
||||
# labelSelector: ${SW_CLUSTER_K8S_LABEL:app=collector,release=skywalking}
|
||||
# uidEnvName: ${SW_CLUSTER_K8S_UID:SKYWALKING_COLLECTOR_UID}
|
||||
# consul:
|
||||
# serviceName: ${SW_SERVICE_NAME:"SkyWalking_OAP_Cluster"}
|
||||
# Consul cluster nodes, example: 10.0.0.1:8500,10.0.0.2:8500,10.0.0.3:8500
|
||||
# hostPort: ${SW_CLUSTER_CONSUL_HOST_PORT:localhost:8500}
|
||||
core:
|
||||
default:
|
||||
restHost: ${SW_CORE_REST_HOST:0.0.0.0}
|
||||
|
|
@ -37,9 +41,9 @@ core:
|
|||
gRPCHost: ${SW_CORE_GRPC_HOST:0.0.0.0}
|
||||
gRPCPort: ${SW_CORE_GRPC_PORT:11800}
|
||||
downsampling:
|
||||
- Hour
|
||||
- Day
|
||||
- Month
|
||||
- Hour
|
||||
- Day
|
||||
- Month
|
||||
# Set a timeout on metric data. After the timeout has expired, the metric data will automatically be deleted.
|
||||
recordDataTTL: ${SW_CORE_RECORD_DATA_TTL:90} # Unit is minute
|
||||
minuteMetricsDataTTL: ${SW_CORE_MINUTE_METRIC_DATA_TTL:90} # Unit is minute
|
||||
|
|
@ -49,7 +53,7 @@ core:
|
|||
storage:
|
||||
elasticsearch:
|
||||
nameSpace: ${SW_NAMESPACE:""}
|
||||
clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:10.67.27.213:9200}
|
||||
clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:localhost:9200}
|
||||
indexShardsNumber: ${SW_STORAGE_ES_INDEX_SHARDS_NUMBER:2}
|
||||
indexReplicasNumber: ${SW_STORAGE_ES_INDEX_REPLICAS_NUMBER:0}
|
||||
# Batch process setting, refer to https://www.elastic.co/guide/en/elasticsearch/client/java-api/5.5/java-docs-bulk-processor.html
|
||||
|
|
@ -81,11 +85,11 @@ service-mesh:
|
|||
bufferFileCleanWhenRestart: ${SW_SERVICE_MESH_BUFFER_FILE_CLEAN_WHEN_RESTART:false}
|
||||
istio-telemetry:
|
||||
default:
|
||||
receiver_zipkin:
|
||||
default:
|
||||
host: ${SW_RECEIVER_ZIPKIN_HOST:0.0.0.0}
|
||||
port: ${SW_RECEIVER_ZIPKIN_PORT:9411}
|
||||
contextPath: ${SW_RECEIVER_ZIPKIN_CONTEXT_PATH:/}
|
||||
#receiver_zipkin:
|
||||
# default:
|
||||
# host: ${SW_RECEIVER_ZIPKIN_HOST:0.0.0.0}
|
||||
# port: ${SW_RECEIVER_ZIPKIN_PORT:9411}
|
||||
# contextPath: ${SW_RECEIVER_ZIPKIN_CONTEXT_PATH:/}
|
||||
query:
|
||||
graphql:
|
||||
path: ${SW_QUERY_GRAPHQL_PATH:/graphql}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
package org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import org.apache.skywalking.oap.server.core.alarm.AlarmRecord;
|
||||
|
|
@ -25,7 +26,6 @@ import org.apache.skywalking.oap.server.core.query.entity.*;
|
|||
import org.apache.skywalking.oap.server.core.source.Scope;
|
||||
import org.apache.skywalking.oap.server.core.storage.query.IAlarmQueryDAO;
|
||||
import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient;
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtils;
|
||||
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.*;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.index.query.*;
|
||||
|
|
@ -52,7 +52,7 @@ public class AlarmQueryEsDAO extends EsDAO implements IAlarmQueryDAO {
|
|||
boolQueryBuilder.must().add(QueryBuilders.termQuery(AlarmRecord.SCOPE, scope.ordinal()));
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(keyword)) {
|
||||
if (!Strings.isNullOrEmpty(keyword)) {
|
||||
String matchCName = MatchCNameBuilder.INSTANCE.build(AlarmRecord.ALARM_MESSAGE);
|
||||
boolQueryBuilder.must().add(QueryBuilders.matchQuery(matchCName, keyword));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
package org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.*;
|
||||
|
|
@ -25,7 +26,7 @@ import org.apache.skywalking.oap.server.core.register.*;
|
|||
import org.apache.skywalking.oap.server.core.source.DetectPoint;
|
||||
import org.apache.skywalking.oap.server.core.storage.query.IMetadataQueryDAO;
|
||||
import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient;
|
||||
import org.apache.skywalking.oap.server.library.util.*;
|
||||
import org.apache.skywalking.oap.server.library.util.BooleanUtils;
|
||||
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.*;
|
||||
import org.elasticsearch.action.get.GetResponse;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
|
|
@ -107,7 +108,7 @@ public class MetadataQueryEsDAO extends EsDAO implements IMetadataQueryDAO {
|
|||
boolQueryBuilder.must().add(timeRangeQueryBuild(startTimestamp, endTimestamp));
|
||||
boolQueryBuilder.must().add(QueryBuilders.termQuery(ServiceInventory.IS_ADDRESS, BooleanUtils.FALSE));
|
||||
|
||||
if (StringUtils.isNotEmpty(keyword)) {
|
||||
if (!Strings.isNullOrEmpty(keyword)) {
|
||||
String matchCName = MatchCNameBuilder.INSTANCE.build(ServiceInventory.NAME);
|
||||
boolQueryBuilder.must().add(QueryBuilders.matchQuery(matchCName, keyword));
|
||||
}
|
||||
|
|
@ -139,7 +140,7 @@ public class MetadataQueryEsDAO extends EsDAO implements IMetadataQueryDAO {
|
|||
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
||||
boolQueryBuilder.must().add(QueryBuilders.termQuery(EndpointInventory.SERVICE_ID, serviceId));
|
||||
|
||||
if (StringUtils.isNotEmpty(keyword)) {
|
||||
if (!Strings.isNullOrEmpty(keyword)) {
|
||||
String matchCName = MatchCNameBuilder.INSTANCE.build(EndpointInventory.NAME);
|
||||
boolQueryBuilder.must().add(QueryBuilders.matchQuery(matchCName, keyword));
|
||||
}
|
||||
|
|
@ -189,11 +190,11 @@ public class MetadataQueryEsDAO extends EsDAO implements IMetadataQueryDAO {
|
|||
serviceInstance.setLanguage(LanguageTrans.INSTANCE.value(languageId));
|
||||
|
||||
String osName = (String)sourceAsMap.get(ServiceInstanceInventory.OS_NAME);
|
||||
if (StringUtils.isNotEmpty(osName)) {
|
||||
if (!Strings.isNullOrEmpty(osName)) {
|
||||
serviceInstance.getAttributes().add(new Attribute(ServiceInstanceInventory.OS_NAME, osName));
|
||||
}
|
||||
String hostName = (String)sourceAsMap.get(ServiceInstanceInventory.HOST_NAME);
|
||||
if (StringUtils.isNotEmpty(hostName)) {
|
||||
if (!Strings.isNullOrEmpty(hostName)) {
|
||||
serviceInstance.getAttributes().add(new Attribute(ServiceInstanceInventory.HOST_NAME, hostName));
|
||||
}
|
||||
serviceInstance.getAttributes().add(new Attribute(ServiceInstanceInventory.PROCESS_NO, String.valueOf(((Number)sourceAsMap.get(ServiceInstanceInventory.PROCESS_NO)).intValue())));
|
||||
|
|
|
|||
|
|
@ -18,25 +18,17 @@
|
|||
|
||||
package org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import org.apache.skywalking.oap.server.core.analysis.manual.segment.SegmentRecord;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.BasicTrace;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.QueryOrder;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.TraceBrief;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.TraceState;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.*;
|
||||
import org.apache.skywalking.oap.server.core.storage.query.ITraceQueryDAO;
|
||||
import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient;
|
||||
import org.apache.skywalking.oap.server.library.util.BooleanUtils;
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtils;
|
||||
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.EsDAO;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.index.query.RangeQueryBuilder;
|
||||
import org.elasticsearch.index.query.*;
|
||||
import org.elasticsearch.search.SearchHit;
|
||||
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||
import org.elasticsearch.search.sort.SortOrder;
|
||||
|
|
@ -74,7 +66,7 @@ public class TraceQueryEsDAO extends EsDAO implements ITraceQueryDAO {
|
|||
}
|
||||
boolQueryBuilder.must().add(rangeQueryBuilder);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(endpointName)) {
|
||||
if (!Strings.isNullOrEmpty(endpointName)) {
|
||||
mustQueryList.add(QueryBuilders.matchPhraseQuery(SegmentRecord.ENDPOINT_NAME, endpointName));
|
||||
}
|
||||
if (serviceId != 0) {
|
||||
|
|
@ -83,7 +75,7 @@ public class TraceQueryEsDAO extends EsDAO implements ITraceQueryDAO {
|
|||
if (endpointId != 0) {
|
||||
boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentRecord.ENDPOINT_ID, endpointId));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(traceId)) {
|
||||
if (!Strings.isNullOrEmpty(traceId)) {
|
||||
boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentRecord.TRACE_ID, traceId));
|
||||
}
|
||||
switch (traceState) {
|
||||
|
|
@ -144,7 +136,7 @@ public class TraceQueryEsDAO extends EsDAO implements ITraceQueryDAO {
|
|||
segmentRecord.setLatency(((Number)searchHit.getSourceAsMap().get(SegmentRecord.LATENCY)).intValue());
|
||||
segmentRecord.setIsError(((Number)searchHit.getSourceAsMap().get(SegmentRecord.IS_ERROR)).intValue());
|
||||
String dataBinaryBase64 = (String)searchHit.getSourceAsMap().get(SegmentRecord.DATA_BINARY);
|
||||
if (StringUtils.isNotEmpty(dataBinaryBase64)) {
|
||||
if (!Strings.isNullOrEmpty(dataBinaryBase64)) {
|
||||
segmentRecord.setDataBinary(Base64.getDecoder().decode(dataBinaryBase64));
|
||||
}
|
||||
segmentRecord.setVersion(((Number)searchHit.getSourceAsMap().get(SegmentRecord.VERSION)).intValue());
|
||||
|
|
|
|||
|
|
@ -19,18 +19,14 @@
|
|||
package org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import org.apache.skywalking.oap.server.core.alarm.AlarmRecord;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.AlarmMessage;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.Alarms;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.*;
|
||||
import org.apache.skywalking.oap.server.core.source.Scope;
|
||||
import org.apache.skywalking.oap.server.core.storage.query.IAlarmQueryDAO;
|
||||
import org.apache.skywalking.oap.server.library.client.jdbc.hikaricp.JDBCHikariCPClient;
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtils;
|
||||
import org.elasticsearch.common.Strings;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
|
|
@ -57,7 +53,7 @@ public class H2AlarmQueryDAO implements IAlarmQueryDAO {
|
|||
parameters.add(endTB);
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(keyword)) {
|
||||
if (!Strings.isNullOrEmpty(keyword)) {
|
||||
sql.append(" and ").append(AlarmRecord.ALARM_MESSAGE).append(" like '%").append(keyword).append("%' ");
|
||||
}
|
||||
sql.append(" order by ").append(AlarmRecord.START_TIME).append(" desc ");
|
||||
|
|
|
|||
|
|
@ -18,27 +18,16 @@
|
|||
|
||||
package org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.Attribute;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.Endpoint;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.LanguageTrans;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.Service;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.ServiceInstance;
|
||||
import org.apache.skywalking.oap.server.core.register.EndpointInventory;
|
||||
import org.apache.skywalking.oap.server.core.register.NetworkAddressInventory;
|
||||
import org.apache.skywalking.oap.server.core.register.RegisterSource;
|
||||
import org.apache.skywalking.oap.server.core.register.ServiceInstanceInventory;
|
||||
import org.apache.skywalking.oap.server.core.register.ServiceInventory;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.*;
|
||||
import org.apache.skywalking.oap.server.core.register.*;
|
||||
import org.apache.skywalking.oap.server.core.source.DetectPoint;
|
||||
import org.apache.skywalking.oap.server.core.storage.query.IMetadataQueryDAO;
|
||||
import org.apache.skywalking.oap.server.library.client.jdbc.hikaricp.JDBCHikariCPClient;
|
||||
import org.apache.skywalking.oap.server.library.util.BooleanUtils;
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
|
|
@ -134,7 +123,7 @@ public class H2MetadataQueryDAO implements IMetadataQueryDAO {
|
|||
setTimeRangeCondition(sql, condition, startTimestamp, endTimestamp);
|
||||
sql.append(" and ").append(ServiceInventory.IS_ADDRESS).append("=?");
|
||||
condition.add(BooleanUtils.FALSE);
|
||||
if (StringUtils.isNotEmpty(keyword)) {
|
||||
if (!Strings.isNullOrEmpty(keyword)) {
|
||||
sql.append(" and ").append(ServiceInventory.NAME).append(" like \"%").append(keyword).append("%\"");
|
||||
}
|
||||
sql.append(" limit 100");
|
||||
|
|
@ -181,7 +170,7 @@ public class H2MetadataQueryDAO implements IMetadataQueryDAO {
|
|||
sql.append("select * from ").append(EndpointInventory.MODEL_NAME).append(" where ");
|
||||
sql.append(EndpointInventory.SERVICE_ID).append("=?");
|
||||
condition.add(serviceId);
|
||||
if (StringUtils.isNotEmpty(keyword)) {
|
||||
if (!Strings.isNullOrEmpty(keyword)) {
|
||||
sql.append(" and ").append(EndpointInventory.NAME).append(" like \"%").append(keyword).append("%\" ");
|
||||
}
|
||||
sql.append(" and ").append(EndpointInventory.DETECT_POINT).append(" = ?");
|
||||
|
|
@ -226,11 +215,11 @@ public class H2MetadataQueryDAO implements IMetadataQueryDAO {
|
|||
serviceInstance.setLanguage(LanguageTrans.INSTANCE.value(languageId));
|
||||
|
||||
String osName = resultSet.getString(ServiceInstanceInventory.OS_NAME);
|
||||
if (StringUtils.isNotEmpty(osName)) {
|
||||
if (!Strings.isNullOrEmpty(osName)) {
|
||||
serviceInstance.getAttributes().add(new Attribute(ServiceInstanceInventory.OS_NAME, osName));
|
||||
}
|
||||
String hostName = resultSet.getString(ServiceInstanceInventory.HOST_NAME);
|
||||
if (StringUtils.isNotEmpty(hostName)) {
|
||||
if (!Strings.isNullOrEmpty(hostName)) {
|
||||
serviceInstance.getAttributes().add(new Attribute(ServiceInstanceInventory.HOST_NAME, hostName));
|
||||
}
|
||||
serviceInstance.getAttributes().add(new Attribute(ServiceInstanceInventory.PROCESS_NO, resultSet.getString(ServiceInstanceInventory.PROCESS_NO)));
|
||||
|
|
|
|||
|
|
@ -18,22 +18,15 @@
|
|||
|
||||
package org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import org.apache.skywalking.oap.server.core.analysis.manual.segment.SegmentRecord;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.BasicTrace;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.QueryOrder;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.TraceBrief;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.TraceState;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.*;
|
||||
import org.apache.skywalking.oap.server.core.storage.query.ITraceQueryDAO;
|
||||
import org.apache.skywalking.oap.server.library.client.jdbc.hikaricp.JDBCHikariCPClient;
|
||||
import org.apache.skywalking.oap.server.library.util.BooleanUtils;
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtils;
|
||||
import org.elasticsearch.search.sort.SortOrder;
|
||||
|
||||
/**
|
||||
|
|
@ -71,7 +64,7 @@ public class H2TraceQueryDAO implements ITraceQueryDAO {
|
|||
parameters.add(maxDuration);
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotEmpty(endpointName)) {
|
||||
if (!Strings.isNullOrEmpty(endpointName)) {
|
||||
sql.append(" and ").append(SegmentRecord.ENDPOINT_NAME).append(" like '%" + endpointName + "%'");
|
||||
}
|
||||
if (serviceId != 0) {
|
||||
|
|
@ -82,7 +75,7 @@ public class H2TraceQueryDAO implements ITraceQueryDAO {
|
|||
sql.append(" and ").append(SegmentRecord.ENDPOINT_ID).append(" = ?");
|
||||
parameters.add(endpointId);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(traceId)) {
|
||||
if (!Strings.isNullOrEmpty(traceId)) {
|
||||
sql.append(" and ").append(SegmentRecord.TRACE_ID).append(" = ?");
|
||||
parameters.add(traceId);
|
||||
}
|
||||
|
|
@ -156,7 +149,7 @@ public class H2TraceQueryDAO implements ITraceQueryDAO {
|
|||
segmentRecord.setLatency(resultSet.getInt(SegmentRecord.LATENCY));
|
||||
segmentRecord.setIsError(resultSet.getInt(SegmentRecord.IS_ERROR));
|
||||
String dataBinaryBase64 = resultSet.getString(SegmentRecord.DATA_BINARY);
|
||||
if (StringUtils.isNotEmpty(dataBinaryBase64)) {
|
||||
if (!Strings.isNullOrEmpty(dataBinaryBase64)) {
|
||||
segmentRecord.setDataBinary(Base64.getDecoder().decode(dataBinaryBase64));
|
||||
}
|
||||
segmentRecord.setVersion(resultSet.getInt(SegmentRecord.VERSION));
|
||||
|
|
|
|||
|
|
@ -19,18 +19,14 @@
|
|||
package org.apache.skywalking.oap.server.storage.plugin.jdbc.mysql;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import org.apache.skywalking.oap.server.core.alarm.AlarmRecord;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.AlarmMessage;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.Alarms;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.*;
|
||||
import org.apache.skywalking.oap.server.core.source.Scope;
|
||||
import org.apache.skywalking.oap.server.core.storage.query.IAlarmQueryDAO;
|
||||
import org.apache.skywalking.oap.server.library.client.jdbc.hikaricp.JDBCHikariCPClient;
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtils;
|
||||
import org.elasticsearch.common.Strings;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
|
|
@ -58,7 +54,7 @@ public class MySQLAlarmQueryDAO implements IAlarmQueryDAO {
|
|||
parameters.add(endTB);
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(keyword)) {
|
||||
if (!Strings.isNullOrEmpty(keyword)) {
|
||||
sql.append(" and ").append(AlarmRecord.ALARM_MESSAGE).append(" like '%").append(keyword).append("%' ");
|
||||
}
|
||||
sql.append(" order by ").append(AlarmRecord.START_TIME).append(" desc ");
|
||||
|
|
|
|||
|
|
@ -18,27 +18,21 @@
|
|||
|
||||
package org.apache.skywalking.oap.server.storage.plugin.jdbc.mysql;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import org.apache.skywalking.oap.server.core.analysis.manual.segment.SegmentRecord;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.BasicTrace;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.QueryOrder;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.TraceBrief;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.TraceState;
|
||||
import org.apache.skywalking.oap.server.core.query.entity.*;
|
||||
import org.apache.skywalking.oap.server.library.client.jdbc.hikaricp.JDBCHikariCPClient;
|
||||
import org.apache.skywalking.oap.server.library.util.BooleanUtils;
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtils;
|
||||
import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2TraceQueryDAO;
|
||||
import org.elasticsearch.search.sort.SortOrder;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
*/
|
||||
public class MySQLTraceQueryDAO extends H2TraceQueryDAO {
|
||||
public class MySQLTraceQueryDAO extends H2TraceQueryDAO {
|
||||
public MySQLTraceQueryDAO(JDBCHikariCPClient mysqlClient) {
|
||||
super(mysqlClient);
|
||||
}
|
||||
|
|
@ -68,7 +62,7 @@ public class MySQLTraceQueryDAO extends H2TraceQueryDAO {
|
|||
parameters.add(maxDuration);
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotEmpty(endpointName)) {
|
||||
if (!Strings.isNullOrEmpty(endpointName)) {
|
||||
sql.append(" and ").append(SegmentRecord.ENDPOINT_NAME).append(" like '%" + endpointName + "%'");
|
||||
}
|
||||
if (serviceId != 0) {
|
||||
|
|
@ -79,7 +73,7 @@ public class MySQLTraceQueryDAO extends H2TraceQueryDAO {
|
|||
sql.append(" and ").append(SegmentRecord.ENDPOINT_ID).append(" = ?");
|
||||
parameters.add(endpointId);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(traceId)) {
|
||||
if (!Strings.isNullOrEmpty(traceId)) {
|
||||
sql.append(" and ").append(SegmentRecord.TRACE_ID).append(" = ?");
|
||||
parameters.add(traceId);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue