Skip to content

Commit

Permalink
[#9569] Add Pinot Module
Browse files Browse the repository at this point in the history
  • Loading branch information
emeroad committed Dec 30, 2022
1 parent 310de7e commit 569d1a8
Show file tree
Hide file tree
Showing 29 changed files with 184 additions and 56 deletions.
1 change: 1 addition & 0 deletions commons-pinot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# pinpoint-commons-pinot
96 changes: 96 additions & 0 deletions commons-pinot/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2019 NAVER Corp.
~
~ 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.
-->

<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.navercorp.pinpoint</groupId>
<artifactId>pinpoint</artifactId>
<version>2.5.1-SNAPSHOT</version>
</parent>

<artifactId>pinpoint-commons-pinot</artifactId>
<name>pinpoint-commons-pinot</name>
<packaging>jar</packaging>

<properties>
<jdk.version>11</jdk.version>
<jdk.home>${env.JAVA_11_HOME}</jdk.home>
</properties>

<dependencies>
<dependency>
<groupId>com.navercorp.pinpoint</groupId>
<artifactId>pinpoint-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.navercorp.pinpoint</groupId>
<artifactId>pinpoint-commons</artifactId>
</dependency>

<dependency>
<groupId>org.apache.pinot</groupId>
<artifactId>pinot-jdbc-client</artifactId>
<version>${pinot.client.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
</dependency>

<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>


<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>

<!-- Logging dependencies -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.navercorp.pinpoint.metric.common.pinot;
package com.navercorp.pinpoint.common.pinot.datasource;

import org.apache.hadoop.hbase.shaded.org.apache.commons.codec.binary.Hex;
import org.apache.commons.codec.binary.Hex;
import org.apache.pinot.client.PreparedStatement;
import org.apache.pinot.client.base.AbstractBasePreparedStatement;
import org.apache.pinot.client.utils.DateTimeUtils;

Expand All @@ -15,9 +16,9 @@
import java.util.Objects;

public class ParameterRecorder extends AbstractBasePreparedStatement {
private org.apache.pinot.client.PreparedStatement preparedStatement;
private PreparedStatement preparedStatement;

public ParameterRecorder(org.apache.pinot.client.PreparedStatement preparedStatement) {
public ParameterRecorder(PreparedStatement preparedStatement) {
this.preparedStatement = Objects.requireNonNull(preparedStatement, "preparedStatement");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.navercorp.pinpoint.metric.common.pinot;
package com.navercorp.pinpoint.common.pinot.datasource;

import org.apache.pinot.client.PinotConnection;
import org.apache.pinot.client.PinotDriver;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.navercorp.pinpoint.metric.common.pinot;
package com.navercorp.pinpoint.common.pinot.datasource;

import org.apache.pinot.client.base.AbstractBaseStatement;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.navercorp.pinpoint.metric.common.pinot;
package com.navercorp.pinpoint.common.pinot.datasource;

import org.apache.pinot.client.PinotConnection;

Expand Down Expand Up @@ -43,7 +43,6 @@
*/
public class WrappedPinotConnection implements Connection {

private static final String QUERY_FORMAT = "sql";
private static final String LIMIT_STATEMENT = "LIMIT";

private final PinotConnection connection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.navercorp.pinpoint.metric.common.pinot;
package com.navercorp.pinpoint.common.pinot.datasource;

import org.apache.pinot.client.PinotConnection;
import org.apache.pinot.client.PinotPreparedStatement;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.navercorp.pinpoint.metric.common.pinot;
package com.navercorp.pinpoint.common.pinot.mybatis;

import com.navercorp.pinpoint.common.pinot.datasource.ParameterRecorder;
import com.navercorp.pinpoint.common.pinot.datasource.PinotDataSource;
import com.navercorp.pinpoint.common.pinot.datasource.StatementWrapper;
import com.navercorp.pinpoint.common.pinot.datasource.WrappedPinotConnection;
import com.navercorp.pinpoint.common.pinot.util.JdbcUtils;
import org.apache.ibatis.exceptions.PersistenceException;
import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.executor.parameter.ParameterHandler;
Expand All @@ -11,6 +16,8 @@
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.transaction.TransactionFactory;
import org.apache.ibatis.transaction.managed.ManagedTransactionFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.pinot.client.Connection;
import org.apache.pinot.client.PinotResultSet;
import org.apache.pinot.client.PreparedStatement;
Expand All @@ -19,7 +26,6 @@
import org.mybatis.spring.MyBatisExceptionTranslator;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.support.PersistenceExceptionTranslator;
import org.springframework.jdbc.support.JdbcUtils;

import java.sql.ResultSet;
import java.sql.SQLException;
Expand All @@ -31,6 +37,9 @@
import java.util.function.Function;

public class PinotAsyncTemplate {

private final Logger logger = LogManager.getLogger(this.getClass());

private final SqlSessionFactory sqlSessionFactory;
private final Configuration configuration;
private final PinotDataSource dataSource;
Expand Down Expand Up @@ -81,6 +90,7 @@ private <E> Future<List<E>> selectList(String statement, Object parameter, RowBo
}
}


private PreparedStatement preparedStatement(Connection session, MappedStatement mappedStatement, BoundSql boundSql) {
String sql = boundSql.getSql();
int fetchSize = getFetchSize(mappedStatement.getFetchSize());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.navercorp.pinpoint.metric.common.pinot;
package com.navercorp.pinpoint.common.pinot.mybatis;

import java.util.Objects;
import java.util.concurrent.ExecutionException;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.navercorp.pinpoint.common.pinot.util;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.sql.Connection;
import java.sql.SQLException;

public final class JdbcUtils {
private static final Logger logger = LogManager.getLogger(JdbcUtils.class);

private JdbcUtils() {
}

public static void closeConnection(Connection con) {
if (con != null) {
try {
con.close();
} catch (SQLException ex) {
logger.debug("Could not close JDBC Connection", ex);
} catch (Throwable ex) {
logger.debug("Unexpected exception on closing JDBC Connection", ex);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.navercorp.pinpoint.metric.common.pinot;
package com.navercorp.pinpoint.common.pinot.datasource;

import org.apache.pinot.client.PinotConnection;
import org.apache.pinot.client.PinotDriver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@
* limitations under the License.
*/

package com.navercorp.pinpoint.metric.common.pinot;
package com.navercorp.pinpoint.common.server.tenant;


/**
* @author minwoo.jung
*/
public class PinotTenantProvider implements TenantProvider {
public class SimpleTenantProvider implements TenantProvider {

private final String defaultTenantId;

public PinotTenantProvider(String defaultTenantId) {
public SimpleTenantProvider(String defaultTenantId) {
this.defaultTenantId = defaultTenantId;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.navercorp.pinpoint.metric.common.pinot;
package com.navercorp.pinpoint.common.server.tenant;

/**
* @author minwoo.jung
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
package com.navercorp.pinpoint.collector.service;

import com.navercorp.pinpoint.common.server.bo.stat.AgentUriStatBo;

import com.navercorp.pinpoint.common.server.bo.stat.EachUriStatBo;
import com.navercorp.pinpoint.common.server.bo.stat.UriStatHistogram;
import com.navercorp.pinpoint.common.server.tenant.TenantProvider;
import com.navercorp.pinpoint.metric.collector.MetricAppPropertySources;
import com.navercorp.pinpoint.metric.collector.dao.UriStatDao;
import com.navercorp.pinpoint.metric.common.model.UriStat;
import com.navercorp.pinpoint.metric.common.pinot.TenantProvider;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportResource;
Expand Down
21 changes: 4 additions & 17 deletions metric-module/metric/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@
<dependency>
<groupId>com.navercorp.pinpoint</groupId>
<artifactId>pinpoint-commons</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.navercorp.pinpoint</groupId>
<artifactId>pinpoint-commons-server</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.navercorp.pinpoint</groupId>
<artifactId>pinpoint-commons-pinot</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
Expand Down Expand Up @@ -159,21 +161,6 @@
<version>1.5.2-5</version>
</dependency>

<dependency>
<groupId>org.apache.pinot</groupId>
<artifactId>pinot-jdbc-client</artifactId>
<version>0.11.0</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.apache.kafka</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.navercorp.pinpoint.metric.collector.controller;

import com.navercorp.pinpoint.common.server.tenant.TenantProvider;
import com.navercorp.pinpoint.common.util.CollectionUtils;
import com.navercorp.pinpoint.metric.collector.model.TelegrafMetric;
import com.navercorp.pinpoint.metric.collector.model.TelegrafMetrics;
Expand All @@ -27,7 +28,6 @@
import com.navercorp.pinpoint.metric.common.model.SystemMetric;
import com.navercorp.pinpoint.metric.common.model.Tag;
import com.navercorp.pinpoint.metric.common.model.validation.SimpleErrorMessage;
import com.navercorp.pinpoint.metric.common.pinot.TenantProvider;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.http.ResponseEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package com.navercorp.pinpoint.metric.web.controller;

import com.navercorp.pinpoint.common.server.tenant.TenantProvider;
import com.navercorp.pinpoint.metric.common.model.Tag;
import com.navercorp.pinpoint.metric.common.pinot.TenantProvider;
import com.navercorp.pinpoint.metric.web.model.MetricDataSearchKey;
import com.navercorp.pinpoint.metric.web.model.MetricInfo;
import com.navercorp.pinpoint.metric.web.model.SystemMetricData;
Expand Down Expand Up @@ -53,7 +53,10 @@ public class SystemMetricController {

private final TagParser tagParser = new TagParser();

public SystemMetricController(SystemMetricDataService systemMetricDataService, SystemMetricHostInfoService systemMetricHostInfoService, YMLSystemMetricBasicGroupManager systemMetricBasicGroupManager, TenantProvider tenantProvider) {
public SystemMetricController(SystemMetricDataService systemMetricDataService,
SystemMetricHostInfoService systemMetricHostInfoService,
YMLSystemMetricBasicGroupManager systemMetricBasicGroupManager,
TenantProvider tenantProvider) {
this.systemMetricDataService = Objects.requireNonNull(systemMetricDataService, "systemMetricService");
this.systemMetricHostInfoService = Objects.requireNonNull(systemMetricHostInfoService, "systemMetricHostInfoService");
this.systemMetricBasicGroupManager = Objects.requireNonNull(systemMetricBasicGroupManager, "systemMetricBasicGroupManager");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package com.navercorp.pinpoint.metric.web.controller;

import com.navercorp.pinpoint.common.server.tenant.TenantProvider;
import com.navercorp.pinpoint.common.util.StringUtils;
import com.navercorp.pinpoint.metric.common.model.UriStat;
import com.navercorp.pinpoint.metric.common.pinot.TenantProvider;
import com.navercorp.pinpoint.metric.web.model.UriStatSummary;
import com.navercorp.pinpoint.metric.web.service.UriStatService;
import com.navercorp.pinpoint.metric.web.util.Range;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package com.navercorp.pinpoint.metric.web.dao.pinot;

import com.navercorp.pinpoint.common.pinot.mybatis.PinotAsyncTemplate;
import com.navercorp.pinpoint.metric.common.model.MetricTag;
import com.navercorp.pinpoint.metric.common.pinot.PinotAsyncTemplate;
import com.navercorp.pinpoint.metric.web.dao.SystemMetricDao;
import com.navercorp.pinpoint.metric.web.dao.model.SystemMetricDataSearchKey;
import com.navercorp.pinpoint.metric.web.model.MetricDataSearchKey;
Expand All @@ -26,7 +26,6 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mybatis.spring.SqlSessionTemplate;

import org.springframework.stereotype.Repository;

import java.util.List;
Expand Down
Loading

0 comments on commit 569d1a8

Please sign in to comment.