Skip to content

Commit

Permalink
[improvement][project]Adapt docker related scripts to new version.
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryjzhang committed Dec 26, 2024
1 parent d04a086 commit a4d2df4
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 82 deletions.
4 changes: 1 addition & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# Use an official OpenJDK runtime as a parent image
FROM openjdk:8-jdk
FROM openjdk:21-jdk-bullseye

# Set the working directory in the container
WORKDIR /usr/src/app

# Argument to pass in the supersonic version at build time
ARG SUPERSONIC_VERSION

RUN apt-get update

# Install necessary packages, including Postgres client
RUN apt-get update && apt-get install -y postgresql-client

Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose-run.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

SUPERSONIC_VERSION=0.9.10-SNAPSHOT docker-compose -f docker-compose.yml -p supersonic up
SUPERSONIC_VERSION=latest docker-compose -f docker-compose.yml -p supersonic up
14 changes: 7 additions & 7 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ services:
POSTGRES_PASSWORD: supersonic_password
ports:
- "15432:5432"
volumes:
- postgres_data:/var/lib/postgresql
# volumes:
# - postgres_data:/var/lib/postgresql
networks:
- supersonic_network
dns:
Expand Down Expand Up @@ -72,9 +72,9 @@ services:
- 114.114.114.114
- 8.8.8.8
- 8.8.4.4
volumes:
#volumes:
#1.Named Volumes are best for persistent data managed by Docker.
- supersonic_data:/usr/src/app/supersonic-standalone-${SUPERSONIC_VERSION:-latest}
#- supersonic_data:/usr/src/app/supersonic-standalone-${SUPERSONIC_VERSION:-latest}
#2.Bind Mounts are suitable for frequent modifications and debugging.
# - ./conf/application-prd.yaml:/usr/src/app/supersonic-standalone-${SUPERSONIC_VERSION:-latest}/conf/application-prd.yaml
#3.Detailed Bind Mounts offer more control over the mount behavior.
Expand All @@ -84,9 +84,9 @@ services:
# bind:
# propagation: rprivate
# create_host_path: true
volumes:
postgres_data:
supersonic_data:
#volumes:
# postgres_data:
# supersonic_data:

networks:
supersonic_network:
1 change: 1 addition & 0 deletions docker/docker-publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ TAGS="latest"
# If VERSION is provided, add it to TAGS and tag the image as latest
if [ -n "$VERSION" ]; then
TAGS="$TAGS $VERSION"
echo "Tagging Docker images $IMAGE_NAME:$VERSION to $IMAGE_NAME:latest"
docker tag $IMAGE_NAME:$VERSION $IMAGE_NAME:latest
fi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class QueryStatDO {
private String queryStructCmd;
@TableField("struct_cmd_md5")
private String queryStructCmdMd5;
@TableField("`sql`")
@TableField("query_sql")
private String sql;
private String sqlMd5;
private String queryEngine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,54 +16,21 @@
import com.tencent.supersonic.common.pojo.ChatApp;
import com.tencent.supersonic.common.pojo.JoinCondition;
import com.tencent.supersonic.common.pojo.ModelRela;
import com.tencent.supersonic.common.pojo.enums.AggOperatorEnum;
import com.tencent.supersonic.common.pojo.enums.AggregateTypeEnum;
import com.tencent.supersonic.common.pojo.enums.AppModule;
import com.tencent.supersonic.common.pojo.enums.FilterOperatorEnum;
import com.tencent.supersonic.common.pojo.enums.SensitiveLevelEnum;
import com.tencent.supersonic.common.pojo.enums.StatusEnum;
import com.tencent.supersonic.common.pojo.enums.TypeEnums;
import com.tencent.supersonic.common.pojo.enums.*;
import com.tencent.supersonic.common.util.ChatAppManager;
import com.tencent.supersonic.common.util.JsonUtil;
import com.tencent.supersonic.headless.api.pojo.DataSetDetail;
import com.tencent.supersonic.headless.api.pojo.DataSetModelConfig;
import com.tencent.supersonic.headless.api.pojo.Dimension;
import com.tencent.supersonic.headless.api.pojo.DimensionTimeTypeParams;
import com.tencent.supersonic.headless.api.pojo.Field;
import com.tencent.supersonic.headless.api.pojo.FieldParam;
import com.tencent.supersonic.headless.api.pojo.Identify;
import com.tencent.supersonic.headless.api.pojo.Measure;
import com.tencent.supersonic.headless.api.pojo.MeasureParam;
import com.tencent.supersonic.headless.api.pojo.MetricDefineByFieldParams;
import com.tencent.supersonic.headless.api.pojo.MetricDefineByMeasureParams;
import com.tencent.supersonic.headless.api.pojo.MetricDefineByMetricParams;
import com.tencent.supersonic.headless.api.pojo.MetricParam;
import com.tencent.supersonic.headless.api.pojo.ModelDetail;
import com.tencent.supersonic.headless.api.pojo.*;
import com.tencent.supersonic.headless.api.pojo.enums.DimensionType;
import com.tencent.supersonic.headless.api.pojo.enums.IdentifyType;
import com.tencent.supersonic.headless.api.pojo.enums.MetricDefineType;
import com.tencent.supersonic.headless.api.pojo.enums.SemanticType;
import com.tencent.supersonic.headless.api.pojo.request.DataSetReq;
import com.tencent.supersonic.headless.api.pojo.request.DimensionReq;
import com.tencent.supersonic.headless.api.pojo.request.DomainReq;
import com.tencent.supersonic.headless.api.pojo.request.MetricReq;
import com.tencent.supersonic.headless.api.pojo.request.ModelReq;
import com.tencent.supersonic.headless.api.pojo.request.TermReq;
import com.tencent.supersonic.headless.api.pojo.response.DataSetResp;
import com.tencent.supersonic.headless.api.pojo.response.DatabaseResp;
import com.tencent.supersonic.headless.api.pojo.response.DimensionResp;
import com.tencent.supersonic.headless.api.pojo.response.DomainResp;
import com.tencent.supersonic.headless.api.pojo.response.MetricResp;
import com.tencent.supersonic.headless.api.pojo.response.ModelResp;
import com.tencent.supersonic.headless.api.pojo.request.*;
import com.tencent.supersonic.headless.api.pojo.response.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.*;

@Component
@Slf4j
Expand All @@ -86,9 +53,7 @@ public void doRun() {

// create metrics and dimensions
DimensionResp departmentDimension = getDimension("department", userModel);
MetricResp metricUv = addMetric_uv(pvUvModel, departmentDimension);
MetricResp metricPv = getMetric("pv", pvUvModel);
addMetric_pv_avg(metricPv, metricUv, departmentDimension, pvUvModel);

DimensionResp pageDimension = getDimension("page", stayTimeModel);
updateDimension(stayTimeModel, pageDimension);
Expand Down Expand Up @@ -397,31 +362,6 @@ private MetricResp addMetric_uv(ModelResp uvModel, DimensionResp departmentDimen
return metricService.createMetric(metricReq, defaultUser);
}

private MetricResp addMetric_pv_avg(MetricResp metricPv, MetricResp metricUv,
DimensionResp departmentDimension, ModelResp pvModel) throws Exception {
MetricReq metricReq = new MetricReq();
metricReq.setModelId(pvModel.getId());
metricReq.setName("人均访问次数");
metricReq.setBizName("pv_avg");
metricReq.setSensitiveLevel(SensitiveLevelEnum.HIGH.getCode());
metricReq.setDescription("每个用户平均访问的次数");
metricReq.setClassifications(Collections.singletonList("核心指标"));
metricReq.setAlias("平均访问次数");
MetricDefineByMetricParams metricTypeParams = new MetricDefineByMetricParams();
metricTypeParams.setExpr("pv/uv");
List<MetricParam> metrics = new ArrayList<>();
MetricParam pv = new MetricParam(metricPv.getId(), metricPv.getBizName());
MetricParam uv = new MetricParam(metricUv.getId(), metricUv.getBizName());
metrics.add(pv);
metrics.add(uv);
metricTypeParams.setMetrics(metrics);
metricReq.setMetricDefineByMetricParams(metricTypeParams);
metricReq.setMetricDefineType(MetricDefineType.METRIC);
metricReq.setRelateDimension(
getRelateDimension(Lists.newArrayList(departmentDimension.getId())));
return metricService.createMetric(metricReq, defaultUser);
}

private DataSetResp addDataSet(DomainResp s2Domain) {
DataSetReq dataSetReq = new DataSetReq();
dataSetReq.setName("超音数数据集");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,4 +404,5 @@ ALTER TABLE s2_query_stat_info RENAME COLUMN `user` TO `query_user`;
ALTER TABLE s2_chat_context RENAME COLUMN `user` TO `query_user`;

--20241226
alter table s2_chat_memory add column `query_id` BIGINT DEFAULT NULL;
ALTER TABLE s2_chat_memory add column `query_id` BIGINT DEFAULT NULL;
ALTER TABLE s2_query_stat_info RENAME COLUMN `sql` TO `query_sql`;
2 changes: 1 addition & 1 deletion launchers/standalone/src/main/resources/db/schema-h2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ CREATE TABLE IF NOT EXISTS `s2_query_stat_info` (
`sql_cmd_md5` varchar(200) DEFAULT NULL, -- sql type request parameter md5
`query_struct_cmd`LONGVARCHAR , -- struct type request parameter
`struct_cmd_md5` varchar(200) DEFAULT NULL, -- struct type request parameter md5值
`sql`LONGVARCHAR ,
`query_sql` LONGVARCHAR ,
`sql_md5` varchar(200) DEFAULT NULL, -- sql md5
`query_engine` varchar(20) DEFAULT NULL,
`elapsed_ms` bigINT DEFAULT NULL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ CREATE TABLE IF NOT EXISTS `s2_query_stat_info` (
`sql_cmd_md5` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'sql md5值',
`query_struct_cmd` mediumtext COLLATE utf8mb4_unicode_ci COMMENT '对应查询的struct',
`struct_cmd_md5` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'sql md5值',
`sql` mediumtext COLLATE utf8mb4_unicode_ci COMMENT '对应查询的sql',
`query_sql` mediumtext COLLATE utf8mb4_unicode_ci COMMENT '对应查询的sql',
`sql_md5` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'sql md5值',
`query_engine` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '查询引擎',
`elapsed_ms` bigint(10) DEFAULT NULL COMMENT '查询耗时',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ CREATE TABLE IF NOT EXISTS s2_query_stat_info (
sql_cmd_md5 varchar(200) DEFAULT NULL,
query_struct_cmd text,
struct_cmd_md5 varchar(200) DEFAULT NULL,
sql text,
query_sql text,
sql_md5 varchar(200) DEFAULT NULL,
query_engine varchar(20) DEFAULT NULL,
elapsed_ms bigint DEFAULT NULL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void testGetUnAvailableItem() {
fieldRemovedReq.setModelId(2L);
fieldRemovedReq.setFields(Lists.newArrayList("pv"));
UnAvailableItemResp unAvailableItemResp = modelService.getUnAvailableItem(fieldRemovedReq);
List<Long> expectedUnAvailableMetricId = Lists.newArrayList(1L, 4L);
List<Long> expectedUnAvailableMetricId = Lists.newArrayList(1L);
List<Long> actualUnAvailableMetricId =
unAvailableItemResp.getMetricResps().stream().map(MetricResp::getId)
.sorted(Comparator.naturalOrder()).collect(Collectors.toList());
Expand Down

0 comments on commit a4d2df4

Please sign in to comment.