You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by ve...@apache.org on 2023/07/19 10:39:43 UTC
[inlong] branch branch-1.8 updated (a08a0b28f2 -> 1d93f8b5a9)
This is an automated email from the ASF dual-hosted git repository.
vernedeng pushed a change to branch branch-1.8
in repository https://gitbox.apache.org/repos/asf/inlong.git
from a08a0b28f2 [INLONG-8576][DataProxy] Adjust handling when messages are incomplete (#8577)
new f48e05853e [INLONG-8572][Manager] Fix missing information in InlongStreamBriefInfo (#8573)
new 1d93f8b5a9 [INLONG-8567][Manager] Add new role INLONG_SERVICE for internal service query (#8568)
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../dao/interceptor/MultiTenantInterceptor.java | 50 ++++++-
.../resources/mappers/DataNodeEntityMapper.xml | 68 ++++++---
.../mappers/InlongClusterEntityMapper.xml | 76 +++++++---
.../mappers/InlongClusterTagEntityMapper.xml | 45 ++++--
.../mappers/InlongConsumeEntityMapper.xml | 92 ++++++++----
.../resources/mappers/InlongGroupEntityMapper.xml | 155 +++++++++++++++------
.../manager/pojo/stream/InlongStreamBriefInfo.java | 39 ++++++
.../inlong/manager/pojo/user/UserRoleCode.java | 5 +
inlong-manager/manager-service/pom.xml | 2 +-
.../service/core/impl/SortSourceServiceImpl.java | 2 +-
.../service/tenant/InlongTenantServiceImpl.java | 12 +-
.../service/user/TenantRoleServiceImpl.java | 2 +-
.../manager/service/sort/SortServiceImplTest.java | 18 +++
.../web/auth/tenant/TenantAuthenticatingRealm.java | 8 +-
14 files changed, 445 insertions(+), 129 deletions(-)
[inlong] 02/02: [INLONG-8567][Manager] Add new role INLONG_SERVICE for internal service query (#8568)
Posted by ve...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
vernedeng pushed a commit to branch branch-1.8
in repository https://gitbox.apache.org/repos/asf/inlong.git
commit 1d93f8b5a97598677626a257bc133fec70ebf812
Author: vernedeng <ve...@apache.org>
AuthorDate: Wed Jul 19 18:21:02 2023 +0800
[INLONG-8567][Manager] Add new role INLONG_SERVICE for internal service query (#8568)
(cherry picked from commit 6bf6c69c6fe6b58daa4b953d01e1b2aa3321c636)
---
.../dao/interceptor/MultiTenantInterceptor.java | 50 ++++++-
.../resources/mappers/DataNodeEntityMapper.xml | 68 ++++++---
.../mappers/InlongClusterEntityMapper.xml | 76 +++++++---
.../mappers/InlongClusterTagEntityMapper.xml | 45 ++++--
.../mappers/InlongConsumeEntityMapper.xml | 92 ++++++++----
.../resources/mappers/InlongGroupEntityMapper.xml | 155 +++++++++++++++------
.../inlong/manager/pojo/user/UserRoleCode.java | 5 +
.../service/core/impl/SortSourceServiceImpl.java | 2 +-
.../service/tenant/InlongTenantServiceImpl.java | 12 +-
.../service/user/TenantRoleServiceImpl.java | 2 +-
.../manager/service/sort/SortServiceImplTest.java | 18 +++
.../web/auth/tenant/TenantAuthenticatingRealm.java | 8 +-
12 files changed, 405 insertions(+), 128 deletions(-)
diff --git a/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/interceptor/MultiTenantInterceptor.java b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/interceptor/MultiTenantInterceptor.java
index 7ba50a1ab2..4e79ede37a 100644
--- a/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/interceptor/MultiTenantInterceptor.java
+++ b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/interceptor/MultiTenantInterceptor.java
@@ -24,6 +24,7 @@ import org.apache.inlong.manager.pojo.user.LoginUserUtils;
import org.apache.inlong.manager.pojo.user.UserInfo;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.binding.MapperMethod;
import org.apache.ibatis.cache.CacheKey;
@@ -32,6 +33,7 @@ import org.apache.ibatis.executor.parameter.ParameterHandler;
import org.apache.ibatis.mapping.BoundSql;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.ParameterMapping;
+import org.apache.ibatis.ognl.ASTConst;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.plugin.Intercepts;
import org.apache.ibatis.plugin.Invocation;
@@ -44,8 +46,10 @@ import org.apache.ibatis.reflection.factory.DefaultObjectFactory;
import org.apache.ibatis.reflection.factory.ObjectFactory;
import org.apache.ibatis.reflection.wrapper.DefaultObjectWrapperFactory;
import org.apache.ibatis.reflection.wrapper.ObjectWrapperFactory;
+import org.apache.ibatis.scripting.xmltags.OgnlCache;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;
+import org.apache.ibatis.type.StringTypeHandler;
import java.lang.reflect.Field;
import java.sql.PreparedStatement;
@@ -54,6 +58,8 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
+import static org.apache.inlong.manager.pojo.user.UserRoleCode.INLONG_SERVICE;
+
/**
* This interceptor intercept those queries annotated by {@link MultiTenantQuery}.
*
@@ -74,6 +80,7 @@ import java.util.Properties;
public class MultiTenantInterceptor implements Interceptor {
private static final String KEY_TENANT = "tenant";
+ private static final String KEY_INLONG_SERVICE = "LoginUser.InlongService";
private static final ObjectFactory DEFAULT_OBJECT_FACTORY = new DefaultObjectFactory();
private static final ObjectWrapperFactory DEFAULT_OBJECT_WRAPPER_FACTORY = new DefaultObjectWrapperFactory();
private static final ReflectorFactory REFLECTOR_FACTORY = new DefaultReflectorFactory();
@@ -94,6 +101,7 @@ public class MultiTenantInterceptor implements Interceptor {
if (!MultiTenantQueryFilter.isMultiTenantQuery(fullMethodName.split(InlongConstants.UNDERSCORE)[0])) {
return invocation.proceed();
}
+ this.setExpressionCache();
try {
Object[] args = invocation.getArgs();
MappedStatement ms = (MappedStatement) args[0];
@@ -106,8 +114,9 @@ public class MultiTenantInterceptor implements Interceptor {
// 6 params
boundSql = (BoundSql) args[5];
}
-
List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
+
+ this.setTenantMapping(parameterMappings);
// new param mapping
Object newParameter = makeNewParameters(parameter, parameterMappings);
// update params
@@ -128,11 +137,11 @@ public class MultiTenantInterceptor implements Interceptor {
if (!MultiTenantQueryFilter.isMultiTenantQuery(fullMethodName.split(InlongConstants.UNDERSCORE)[0])) {
return invocation.proceed();
}
-
+ this.setExpressionCache();
Object parameterObject = metaResultSetHandler.getValue("parameterObject");
BoundSql boundSql = (BoundSql) metaResultSetHandler.getValue("boundSql");
Object newParams = makeNewParameters(parameterObject, boundSql.getParameterMappings());
-
+ this.setTenantMapping(boundSql.getParameterMappings());
metaResultSetHandler.setValue("parameterObject", newParams);
return invocation.proceed();
}
@@ -208,6 +217,41 @@ public class MultiTenantInterceptor implements Interceptor {
return tenant;
}
+ private boolean isInlongService() {
+ UserInfo userInfo = LoginUserUtils.getLoginUser();
+ if (userInfo == null) {
+ throw new BusinessException("Current user is null, please login first");
+ }
+ if (CollectionUtils.isEmpty(userInfo.getRoles())) {
+ return false;
+ }
+ return userInfo.getRoles().contains(INLONG_SERVICE);
+ }
+
+ private void setExpressionCache() throws NoSuchFieldException, IllegalAccessException {
+ Field cacheFiled = OgnlCache.class.getDeclaredField("expressionCache");
+ cacheFiled.setAccessible(true);
+ Map<String, Object> expressionCache = (Map<String, Object>) cacheFiled.get(null);
+ ASTConst node = new ASTConst(31);
+ node.setValue(this.isInlongService());
+ expressionCache.put(KEY_INLONG_SERVICE, node);
+ }
+
+ private void setTenantMapping(List<ParameterMapping> parameterMappings)
+ throws NoSuchFieldException, IllegalAccessException {
+ for (ParameterMapping mapping : parameterMappings) {
+ if (mapping.getProperty().equals(KEY_TENANT)) {
+ Field javaType = mapping.getClass().getDeclaredField("javaType");
+ javaType.setAccessible(true);
+ javaType.set(mapping, String.class);
+
+ Field typeHandler = mapping.getClass().getDeclaredField("typeHandler");
+ typeHandler.setAccessible(true);
+ typeHandler.set(mapping, new StringTypeHandler());
+ }
+ }
+ }
+
@Override
public Object plugin(Object target) {
return Plugin.wrap(target, this);
diff --git a/inlong-manager/manager-dao/src/main/resources/mappers/DataNodeEntityMapper.xml b/inlong-manager/manager-dao/src/main/resources/mappers/DataNodeEntityMapper.xml
index 8cc5ab30e3..954744839c 100644
--- a/inlong-manager/manager-dao/src/main/resources/mappers/DataNodeEntityMapper.xml
+++ b/inlong-manager/manager-dao/src/main/resources/mappers/DataNodeEntityMapper.xml
@@ -60,30 +60,43 @@
</insert>
<select id="selectById" resultMap="BaseResultMap">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
select
<include refid="Base_Column_List"/>
from data_node
- where tenant = #{tenant, jdbcType=VARCHAR}
- and is_deleted = 0
- and id = #{id, jdbcType=INTEGER}
+ <where>
+ <if test="_isInlongService == false">
+ tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ and is_deleted = 0
+ and id = #{id, jdbcType=INTEGER}
+ </where>
</select>
<select id="selectByUniqueKey" resultType="org.apache.inlong.manager.dao.entity.DataNodeEntity">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
select
<include refid="Base_Column_List"/>
from data_node
- where tenant = #{tenant, jdbcType=VARCHAR}
- and is_deleted = 0
- and name = #{name, jdbcType=VARCHAR}
- and type = #{type, jdbcType=VARCHAR}
+ <where>
+ <if test="_isInlongService == false">
+ tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ and is_deleted = 0
+ and name = #{name, jdbcType=VARCHAR}
+ and type = #{type, jdbcType=VARCHAR}
+ </where>
</select>
<select id="selectByCondition"
parameterType="org.apache.inlong.manager.pojo.node.DataNodePageRequest"
resultType="org.apache.inlong.manager.dao.entity.DataNodeEntity">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
select
<include refid="Base_Column_List"/>
from data_node
<where>
- tenant = #{tenant, jdbcType=VARCHAR}
+ <if test="_isInlongService == false">
+ tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
and is_deleted = 0
<if test="name != null and name != ''">
and name = #{name, jdbcType=VARCHAR}
@@ -106,12 +119,19 @@
order by modify_time desc
</select>
<select id="selectAllDataNodes" resultType="org.apache.inlong.manager.dao.entity.DataNodeEntity">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
select
<include refid="Base_Column_List"/>
from data_node
- where is_deleted = 0
+ <where>
+ <if test="_isInlongService == false">
+ tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ and is_deleted = 0
+ </where>
</select>
<update id="updateById" parameterType="org.apache.inlong.manager.dao.entity.DataNodeEntity">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
update data_node
set name = #{name, jdbcType=VARCHAR},
display_name = #{displayName, jdbcType=VARCHAR},
@@ -126,11 +146,16 @@
is_deleted = #{isDeleted, jdbcType=INTEGER},
modifier = #{modifier, jdbcType=VARCHAR},
version = #{version, jdbcType=INTEGER} + 1
- where tenant = #{tenant, jdbcType=VARCHAR}
- and id = #{id, jdbcType=INTEGER}
- and version = #{version, jdbcType=INTEGER}
+ <where>
+ id = #{id, jdbcType=INTEGER}
+ <if test="_isInlongService == false">
+ and tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ and version = #{version, jdbcType=INTEGER}
+ </where>
</update>
<update id="updateByIdSelective" parameterType="org.apache.inlong.manager.dao.entity.DataNodeEntity">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
update data_node
<set>
<if test="name != null">
@@ -171,16 +196,25 @@
</if>
version = #{version, jdbcType=INTEGER} + 1
</set>
- where tenant = #{tenant, jdbcType=VARCHAR}
- and id = #{id, jdbcType=INTEGER}
- and version = #{version, jdbcType=INTEGER}
+ <where>
+ id = #{id, jdbcType=INTEGER}
+ <if test="_isInlongService == false">
+ and tenant = #{tenant, jdbcType=VARCHAR}
+ </if>
+ and version = #{version, jdbcType=INTEGER}
+ </where>
</update>
<delete id="deleteById">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
delete
from data_node
- where tenant = #{tenant, jdbcType=VARCHAR}
- and id = #{id, jdbcType=INTEGER}
+ <where>
+ id = #{id, jdbcType=INTEGER}
+ <if test="_isInlongService == false">
+ and tenant = #{tenant, jdbcType=VARCHAR}
+ </if>
+ </where>
</delete>
</mapper>
diff --git a/inlong-manager/manager-dao/src/main/resources/mappers/InlongClusterEntityMapper.xml b/inlong-manager/manager-dao/src/main/resources/mappers/InlongClusterEntityMapper.xml
index e513afe492..9f8a21d851 100644
--- a/inlong-manager/manager-dao/src/main/resources/mappers/InlongClusterEntityMapper.xml
+++ b/inlong-manager/manager-dao/src/main/resources/mappers/InlongClusterEntityMapper.xml
@@ -67,38 +67,45 @@
insert into inlong_cluster (id, name, display_name, type,
url, cluster_tags, ext_tag,
token, ext_params, heartbeat,
- tenant, in_charges, status,
+ in_charges, status,
creator, modifier)
values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{displayName,jdbcType=VARCHAR},
#{type,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, #{clusterTags,jdbcType=VARCHAR},
#{extTag,jdbcType=VARCHAR},#{token,jdbcType=VARCHAR}, #{extParams,jdbcType=LONGVARCHAR},
- #{heartbeat,jdbcType=LONGVARCHAR}, #{tenant,jdbcType=VARCHAR}, #{inCharges,jdbcType=VARCHAR},
+ #{heartbeat,jdbcType=LONGVARCHAR}, #{inCharges,jdbcType=VARCHAR},
#{status,jdbcType=INTEGER}, #{creator,jdbcType=VARCHAR}, #{modifier,jdbcType=VARCHAR})
ON DUPLICATE KEY UPDATE cluster_tags = VALUES(cluster_tags),
ext_tag = VALUES(ext_tag),
token = VALUES(token),
ext_params = VALUES(ext_params),
heartbeat = VALUES(heartbeat),
- tenant = VALUES(tenant),
in_charges = VALUES(in_charges),
status = VALUES(status),
modifier = VALUES(modifier)
</insert>
<select id="selectById" resultMap="BaseResultMap">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
select
<include refid="Base_Column_List"/>
from inlong_cluster
- where tenant = #{tenant,jdbcType=VARCHAR}
- and is_deleted = 0
- and id = #{id,jdbcType=INTEGER}
+ <where>
+ <if test="_isInlongService == false">
+ tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ and is_deleted = 0
+ and id = #{id,jdbcType=INTEGER}
+ </where>
</select>
<select id="selectByKey" resultType="org.apache.inlong.manager.dao.entity.InlongClusterEntity">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
select
<include refid="Base_Column_List"/>
from inlong_cluster
<where>
- tenant = #{tenant,jdbcType=VARCHAR}
+ <if test="_isInlongService == false">
+ tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
and is_deleted = 0
<if test="type != null and type != ''">
and type = #{type, jdbcType=VARCHAR}
@@ -113,11 +120,14 @@
order by modify_time desc
</select>
<select id="selectByNameAndType" resultType="org.apache.inlong.manager.dao.entity.InlongClusterEntity">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
select
<include refid="Base_Column_List"/>
from inlong_cluster
<where>
- tenant = #{tenant,jdbcType=VARCHAR}
+ <if test="_isInlongService == false">
+ tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
and is_deleted = 0
<if test="type != null and type != ''">
and type = #{type, jdbcType=VARCHAR}
@@ -131,11 +141,14 @@
<select id="selectByCondition"
parameterType="org.apache.inlong.manager.pojo.cluster.ClusterPageRequest"
resultType="org.apache.inlong.manager.dao.entity.InlongClusterEntity">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
select
<include refid="Base_Column_List"/>
from inlong_cluster
<where>
- tenant = #{tenant,jdbcType=VARCHAR}
+ <if test="_isInlongService == false">
+ tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
and is_deleted = 0
<if test="name != null and name != ''">
and name = #{name, jdbcType=VARCHAR}
@@ -175,11 +188,14 @@
order by modify_time desc
</select>
<select id="selectByClusterTag" resultType="org.apache.inlong.manager.dao.entity.InlongClusterEntity">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
select
<include refid="Base_Column_List"/>
from inlong_cluster
<where>
- tenant = #{tenant,jdbcType=VARCHAR}
+ <if test="_isInlongService == false">
+ tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
and is_deleted = 0
<if test="clusterTag != null and clusterTag != ''">
and find_in_set(#{clusterTag, jdbcType=VARCHAR}, cluster_tags)
@@ -188,6 +204,7 @@
order by modify_time desc
</select>
<select id="selectAllClusters" resultType="org.apache.inlong.manager.pojo.sort.standalone.SortSourceClusterInfo">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
select name,
type,
url,
@@ -195,10 +212,16 @@
ext_tag,
ext_params
from inlong_cluster
- where is_deleted = 0
+ <where>
+ <if test="_isInlongService == false">
+ tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ and is_deleted = 0
+ </where>
</select>
<update id="updateById" parameterType="org.apache.inlong.manager.dao.entity.InlongClusterEntity">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
update inlong_cluster
set name = #{name,jdbcType=VARCHAR},
display_name = #{displayName,jdbcType=VARCHAR},
@@ -215,11 +238,16 @@
is_deleted = #{isDeleted,jdbcType=INTEGER},
modifier = #{modifier,jdbcType=VARCHAR},
version = #{version,jdbcType=INTEGER} + 1
- where tenant = #{tenant,jdbcType=VARCHAR}
- and id = #{id,jdbcType=INTEGER}
- and version = #{version,jdbcType=INTEGER}
+ <where>
+ <if test="_isInlongService == false">
+ tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ and id = #{id,jdbcType=INTEGER}
+ and version = #{version,jdbcType=INTEGER}
+ </where>
</update>
<update id="updateByIdSelective" parameterType="org.apache.inlong.manager.dao.entity.InlongClusterEntity">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
update inlong_cluster
<set>
<if test="name != null">
@@ -266,15 +294,25 @@
</if>
version = #{version,jdbcType=INTEGER} + 1
</set>
- where tenant = #{tenant,jdbcType=VARCHAR}
- and id = #{id,jdbcType=INTEGER}
- and version = #{version,jdbcType=INTEGER}
+ <where>
+ id = #{id,jdbcType=INTEGER}
+ <if test="_isInlongService == false">
+ and tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ and version = #{version,jdbcType=INTEGER}
+ </where>
+
</update>
<delete id="deleteByPrimaryKey">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
delete
from inlong_cluster
- where tenant = #{tenant,jdbcType=VARCHAR}
- and id = #{id,jdbcType=INTEGER}
+ <where>
+ id = #{id,jdbcType=INTEGER}
+ <if test="_isInlongService == false">
+ and tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ </where>
</delete>
</mapper>
diff --git a/inlong-manager/manager-dao/src/main/resources/mappers/InlongClusterTagEntityMapper.xml b/inlong-manager/manager-dao/src/main/resources/mappers/InlongClusterTagEntityMapper.xml
index 96160b856d..23fc343001 100644
--- a/inlong-manager/manager-dao/src/main/resources/mappers/InlongClusterTagEntityMapper.xml
+++ b/inlong-manager/manager-dao/src/main/resources/mappers/InlongClusterTagEntityMapper.xml
@@ -51,28 +51,41 @@
</insert>
<select id="selectById" resultMap="BaseResultMap">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
select
<include refid="Base_Column_List"/>
from inlong_cluster_tag
- where tenant = #{tenant,jdbcType=VARCHAR}
- and id = #{id,jdbcType=INTEGER}
+ <where>
+ id = #{id,jdbcType=INTEGER}
+ <if test="_isInlongService == false">
+ and tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ </where>
</select>
<select id="selectByTag" resultType="org.apache.inlong.manager.dao.entity.InlongClusterTagEntity">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
select
<include refid="Base_Column_List"/>
from inlong_cluster_tag
- where tenant = #{tenant,jdbcType=VARCHAR}
- and cluster_tag = #{clusterTag, jdbcType=VARCHAR}
- and is_deleted = 0
+ <where>
+ cluster_tag = #{clusterTag, jdbcType=VARCHAR}
+ <if test="_isInlongService == false">
+ and tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ and is_deleted = 0
+ </where>
</select>
<select id="selectByCondition"
parameterType="org.apache.inlong.manager.pojo.cluster.ClusterTagPageRequest"
resultType="org.apache.inlong.manager.dao.entity.InlongClusterTagEntity">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
select
<include refid="Base_Column_List"/>
from inlong_cluster_tag
<where>
- tenant = #{tenant,jdbcType=VARCHAR}
+ <if test="_isInlongService == false">
+ tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
and is_deleted = 0
<if test="keyword != null and keyword != ''">
and cluster_tag like CONCAT('%', #{keyword}, '%')
@@ -82,6 +95,7 @@
</select>
<update id="updateByIdSelective" parameterType="org.apache.inlong.manager.dao.entity.InlongClusterTagEntity">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
update inlong_cluster_tag
<set>
<if test="clusterTag != null">
@@ -107,15 +121,24 @@
</if>
version = #{version,jdbcType=INTEGER} + 1
</set>
- where tenant = #{tenant,jdbcType=VARCHAR}
- and id = #{id,jdbcType=INTEGER}
- and version = #{version,jdbcType=INTEGER}
+ <where>
+ <if test="_isInlongService == false">
+ tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ and id = #{id,jdbcType=INTEGER}
+ and version = #{version,jdbcType=INTEGER}
+ </where>
</update>
<delete id="deleteByPrimaryKey">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
delete
from inlong_cluster_tag
- where tenant = #{tenant,jdbcType=VARCHAR}
- and id = #{id,jdbcType=INTEGER}
+ <where>
+ id = #{id,jdbcType=INTEGER}
+ <if test="_isInlongService == false">
+ and tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ </where>
</delete>
</mapper>
\ No newline at end of file
diff --git a/inlong-manager/manager-dao/src/main/resources/mappers/InlongConsumeEntityMapper.xml b/inlong-manager/manager-dao/src/main/resources/mappers/InlongConsumeEntityMapper.xml
index e3047cc22d..22ba07f829 100644
--- a/inlong-manager/manager-dao/src/main/resources/mappers/InlongConsumeEntityMapper.xml
+++ b/inlong-manager/manager-dao/src/main/resources/mappers/InlongConsumeEntityMapper.xml
@@ -65,38 +65,56 @@
</insert>
<select id="selectById" resultMap="BaseResultMap">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
select
<include refid="Base_Column_List"/>
from inlong_consume
- where tenant = #{tenant, jdbcType=VARCHAR}
- and id = #{id, jdbcType=INTEGER}
+ <where>
+ id = #{id, jdbcType=INTEGER}
+ <if test="_isInlongService == false">
+ and tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ </where>
</select>
<select id="countByUser" resultType="org.apache.inlong.manager.pojo.common.CountInfo">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
select status as `key`, count(1) as `value`
from inlong_consume
- where tenant = #{tenant, jdbcType=VARCHAR}
- and is_deleted = 0
- and (creator = #{username, jdbcType=VARCHAR} or FIND_IN_SET(#{username, jdbcType=VARCHAR}, in_charges))
+ <where>
+ <if test="_isInlongService == false">
+ tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ and is_deleted = 0
+ and (creator = #{username, jdbcType=VARCHAR} or FIND_IN_SET(#{username, jdbcType=VARCHAR}, in_charges))
+ </where>
group by status
</select>
<select id="selectExists" resultType="org.apache.inlong.manager.dao.entity.InlongConsumeEntity">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
select
<include refid="Base_Column_List"/>
from inlong_consume
- where tenant = #{tenant, jdbcType=VARCHAR}
- and is_deleted = 0
- and consumer_group = #{consumerGroup, jdbcType=VARCHAR}
- and topic = #{topic, jdbcType=VARCHAR}
- and inlong_group_id = #{inlongGroupId, jdbcType=VARCHAR}
+ <where>
+ <if test="_isInlongService == false">
+ tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ and is_deleted = 0
+ and consumer_group = #{consumerGroup, jdbcType=VARCHAR}
+ and topic = #{topic, jdbcType=VARCHAR}
+ and inlong_group_id = #{inlongGroupId, jdbcType=VARCHAR}
+ </where>
limit 1
</select>
<select id="selectByCondition" resultMap="BaseResultMap"
parameterType="org.apache.inlong.manager.pojo.consume.InlongConsumePageRequest">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
select
<include refid="Base_Column_List"/>
from inlong_consume
<where>
- tenant = #{tenant, jdbcType=VARCHAR}
+ <if test="_isInlongService == false">
+ tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
and is_deleted = 0
<if test="keyword != null and keyword !=''">
and (consumer_group like CONCAT('%', #{keyword}, '%') or topic like CONCAT('%', #{keyword}, '%'))
@@ -134,11 +152,14 @@
</select>
<select id="selectBriefList" parameterType="org.apache.inlong.manager.pojo.consume.InlongConsumePageRequest"
resultType="org.apache.inlong.manager.pojo.consume.InlongConsumeBriefInfo">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
select id, consumer_group, mq_type, topic, inlong_group_id,
in_charges, status, creator, modifier, create_time, modify_time
from inlong_consume
<where>
- tenant = #{tenant, jdbcType=VARCHAR}
+ <if test="_isInlongService == false">
+ tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
and is_deleted = 0
<if test="keyword != null and keyword !=''">
and (consumer_group like CONCAT('%', #{keyword}, '%') or topic like CONCAT('%', #{keyword}, '%'))
@@ -176,6 +197,7 @@
</select>
<update id="updateById" parameterType="org.apache.inlong.manager.dao.entity.InlongConsumeEntity">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
update inlong_consume
set consumer_group = #{consumerGroup, jdbcType=VARCHAR},
description = #{description, jdbcType=VARCHAR},
@@ -191,14 +213,20 @@
modifier = #{modifier, jdbcType=VARCHAR},
is_deleted = #{isDeleted, jdbcType=INTEGER},
version = #{version, jdbcType=INTEGER} + 1
- where tenant = #{tenant, jdbcType=VARCHAR}
- and id = #{id, jdbcType=INTEGER}
- and is_deleted = 0
- and version = #{version, jdbcType=INTEGER}
+ <where>
+ id = #{id, jdbcType=INTEGER}
+ <if test="_isInlongService == false">
+ and tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ and is_deleted = 0
+ and version = #{version, jdbcType=INTEGER}
+ </where>
+
</update>
<update id="updateByIdSelective"
parameterType="org.apache.inlong.manager.dao.entity.InlongConsumeEntity">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
update inlong_consume
<set>
<if test="consumerGroup != null">
@@ -242,25 +270,39 @@
</if>
version = #{version, jdbcType=INTEGER} + 1
</set>
- where tenant = #{tenant, jdbcType=VARCHAR}
- and id = #{id, jdbcType=INTEGER}
- and is_deleted = 0
- and version = #{version, jdbcType=INTEGER}
+ <where>
+ id = #{id, jdbcType=INTEGER}
+ <if test="_isInlongService == false">
+ and tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ and is_deleted = 0
+ and version = #{version, jdbcType=INTEGER}
+ </where>
</update>
<update id="updateStatus">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
update inlong_consume
set previous_status = status,
status = #{status, jdbcType=INTEGER},
modifier = #{modifier, jdbcType=VARCHAR}
- where tenant = #{tenant, jdbcType=VARCHAR}
- and id = #{id,jdbcType=INTEGER}
- and is_deleted = 0
+ <where>
+ id = #{id,jdbcType=INTEGER}
+ <if test="_isInlongService == false">
+ and tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ and is_deleted = 0
+ </where>
</update>
<delete id="deleteById">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
delete
from inlong_consume
- where tenant = #{tenant, jdbcType=VARCHAR}
- and id = #{id,jdbcType=INTEGER}
+ <where>
+ id = #{id,jdbcType=INTEGER}
+ <if test="_isInlongService == false">
+ and tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ </where>
</delete>
</mapper>
diff --git a/inlong-manager/manager-dao/src/main/resources/mappers/InlongGroupEntityMapper.xml b/inlong-manager/manager-dao/src/main/resources/mappers/InlongGroupEntityMapper.xml
index 8237726115..6b763e475d 100644
--- a/inlong-manager/manager-dao/src/main/resources/mappers/InlongGroupEntityMapper.xml
+++ b/inlong-manager/manager-dao/src/main/resources/mappers/InlongGroupEntityMapper.xml
@@ -207,46 +207,70 @@
</insert>
<select id="selectByPrimaryKey" resultMap="BaseResultMap">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
select
<include refid="Base_Column_List"/>
from inlong_group
- where id = #{id,jdbcType=INTEGER}
- and tenant = #{tenant,jdbcType=VARCHAR}
+ <where>
+ id = #{id,jdbcType=INTEGER}
+ <if test="_isInlongService == false">
+ and tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ </where>
</select>
<select id="countGroupByUser" resultMap="statusCountMap">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
select count(*) as total, status
from inlong_group
- where is_deleted = 0
- and tenant = #{tenant,jdbcType=VARCHAR}
- <if test="inlongGroupMode != null">
- and inlong_group_mode = #{inlongGroupMode,jdbcType=TINYINT}
- </if>
- and (creator = #{username,jdbcType=VARCHAR} or find_in_set(#{username,jdbcType=VARCHAR}, in_charges))
+ <where>
+ <if test="_isInlongService == false">
+ tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ and is_deleted = 0
+ <if test="inlongGroupMode != null">
+ and inlong_group_mode = #{inlongGroupMode,jdbcType=TINYINT}
+ </if>
+ and (creator = #{username,jdbcType=VARCHAR} or find_in_set(#{username,jdbcType=VARCHAR}, in_charges))
+ </where>
group by status
</select>
<select id="selectByGroupId" resultMap="BaseResultMap">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
select
<include refid="Base_Column_List"/>
from inlong_group
- where inlong_group_id = #{groupId, jdbcType=VARCHAR}
- and tenant = #{tenant, jdbcType=VARCHAR}
- and is_deleted = 0
+ <where>
+ inlong_group_id = #{groupId, jdbcType=VARCHAR}
+ <if test="_isInlongService == false">
+ and tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ and is_deleted = 0
+ </where>
</select>
<select id="selectByGroupIdForUpdate" resultMap="BaseResultMap">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
select
<include refid="Base_Column_List"/>
from inlong_group
- where inlong_group_id = #{groupId, jdbcType=VARCHAR}
- and tenant = #{tenant,jdbcType=VARCHAR}
- and is_deleted = 0 for update
+ <where>
+ inlong_group_id = #{groupId, jdbcType=VARCHAR}
+ <if test="_isInlongService == false">
+ and tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ and is_deleted = 0
+ </where>
+ for update
</select>
<select id="selectByCondition" resultMap="BaseResultMap"
parameterType="org.apache.inlong.manager.pojo.group.InlongGroupPageRequest">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
select
<include refid="Base_Column_List"/>
from inlong_group
<where>
- tenant = #{tenant,jdbcType=VARCHAR}
+ <if test="_isInlongService == false">
+ tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
and is_deleted = 0
<if test="keyword != null and keyword != ''">
and (inlong_group_id like CONCAT('%',#{keyword},'%') or name like CONCAT('%',#{keyword},'%'))
@@ -290,12 +314,15 @@
</select>
<select id="selectBriefList" parameterType="org.apache.inlong.manager.pojo.group.InlongGroupPageRequest"
resultType="org.apache.inlong.manager.pojo.group.InlongGroupBriefInfo">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
select id, inlong_group_id, name, mq_type, mq_resource, inlong_cluster_tag, ext_params,
in_charges, status, creator, modifier, create_time, modify_time
from inlong_group
<where>
- is_deleted = 0
- and tenant = #{tenant,jdbcType=VARCHAR}
+ <if test="_isInlongService == false">
+ tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ and is_deleted = 0
<if test="mqType != null and mqType != ''">
and mq_type = #{mqType, jdbcType=VARCHAR}
</if>
@@ -317,12 +344,15 @@
</where>
</select>
<select id="selectByTopicRequest" resultType="org.apache.inlong.manager.dao.entity.InlongGroupEntity">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
select
<include refid="Base_Column_List"/>
from inlong_group
<where>
- is_deleted = 0
- and tenant = #{tenant,jdbcType=VARCHAR}
+ <if test="_isInlongService == false">
+ tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ and is_deleted = 0
<if test="groupIdList != null and groupIdList.size() > 0">
and inlong_group_id in
<foreach collection="groupIdList" item="inlongGroupId" index="index" open="(" close=")" separator=",">
@@ -332,34 +362,51 @@
</where>
</select>
<select id="selectByClusterTag" resultType="org.apache.inlong.manager.dao.entity.InlongGroupEntity">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
select
<include refid="Base_Column_List"/>
from inlong_group
- where is_deleted = 0
- and tenant = #{tenant,jdbcType=VARCHAR}
- and inlong_cluster_tag = #{inlongClusterTag, jdbcType=VARCHAR}
+ <where>
+ <if test="_isInlongService == false">
+ tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ and is_deleted = 0
+ and inlong_cluster_tag = #{inlongClusterTag, jdbcType=VARCHAR}
+ </where>
limit 10
</select>
<select id="selectAllGroups" resultType="org.apache.inlong.manager.pojo.sort.standalone.SortSourceGroupInfo">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
select inlong_group_id as groupId,
inlong_cluster_tag as clusterTag,
mq_resource as mqResource,
ext_params as extParams,
mq_type as mqType
from inlong_group
- where is_deleted = 0
+ <where>
+ <if test="_isInlongService == false">
+ tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ and is_deleted = 0
+ </where>
</select>
<select id="selectDeletedGroupIds" resultType="java.lang.String">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
select inlong_group_id
from inlong_group
- where modify_time <= #{timeBefore, jdbcType=TIMESTAMP}
- and tenant = #{tenant,jdbcType=VARCHAR}
+ <where>
+ <if test="_isInlongService == false">
+ tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ and modify_time <= #{timeBefore, jdbcType=TIMESTAMP}
+ </where>
group by inlong_group_id
having min(is_deleted) > 0
limit #{limit, jdbcType=INTEGER}
</select>
<update id="updateByPrimaryKey" parameterType="org.apache.inlong.manager.dao.entity.InlongGroupEntity">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
update inlong_group
set inlong_group_id = #{inlongGroupId,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
@@ -385,11 +432,16 @@
is_deleted = #{isDeleted,jdbcType=INTEGER},
modifier = #{modifier,jdbcType=VARCHAR},
version = #{version,jdbcType=INTEGER} + 1
- where id = #{id,jdbcType=INTEGER}
- and tenant = #{tenant,jdbcType=VARCHAR}
- and version = #{version,jdbcType=INTEGER}
+ <where>
+ <if test="_isInlongService == false">
+ tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ and id = #{id,jdbcType=INTEGER}
+ and version = #{version,jdbcType=INTEGER}
+ </where>
</update>
<update id="updateByIdentifierSelective" parameterType="org.apache.inlong.manager.dao.entity.InlongGroupEntity">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
update inlong_group
<set>
<if test="name != null">
@@ -454,34 +506,53 @@
</if>
version = #{version,jdbcType=INTEGER} + 1
</set>
- where inlong_group_id = #{inlongGroupId, jdbcType=VARCHAR}
- and tenant = #{tenant,jdbcType=VARCHAR}
- and is_deleted = 0
- and version = #{version, jdbcType=INTEGER}
+ <where>
+ inlong_group_id = #{inlongGroupId, jdbcType=VARCHAR}
+ <if test="_isInlongService == false">
+ and tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ and is_deleted = 0
+ and version = #{version, jdbcType=INTEGER}
+ </where>
</update>
<update id="updateStatus">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
update inlong_group
set previous_status = status,
status = #{status, jdbcType=INTEGER},
modifier = #{modifier, jdbcType=VARCHAR}
- where inlong_group_id = #{groupId, jdbcType=VARCHAR}
- and tenant = #{tenant,jdbcType=VARCHAR}
- and is_deleted = 0
+ <where>
+ inlong_group_id = #{groupId, jdbcType=VARCHAR}
+ <if test="_isInlongService == false">
+ and tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ and is_deleted = 0
+ </where>
</update>
<delete id="deleteByPrimaryKey">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
delete
from inlong_group
- where id = #{id,jdbcType=INTEGER}
- and tenant = #{tenant,jdbcType=VARCHAR}
+ <where>
+ id = #{id,jdbcType=INTEGER}
+ <if test="_isInlongService == false">
+ and tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ </where>
</delete>
<delete id="deleteByInlongGroupIds">
+ <bind name="_isInlongService" value="LoginUser.InlongService"/>
delete
from inlong_group
- where inlong_group_id in
- <foreach item="item" index="index" collection="groupIdList" open="(" close=")" separator=",">
- #{item}
- </foreach>
- and tenant = #{tenant,jdbcType=VARCHAR}
+ <where>
+ inlong_group_id in
+ <foreach item="item" index="index" collection="groupIdList" open="(" close=")" separator=",">
+ #{item}
+ </foreach>
+ <if test="_isInlongService == false">
+ and tenant = #{tenant,jdbcType=VARCHAR}
+ </if>
+ </where>
</delete>
</mapper>
diff --git a/inlong-manager/manager-pojo/src/main/java/org/apache/inlong/manager/pojo/user/UserRoleCode.java b/inlong-manager/manager-pojo/src/main/java/org/apache/inlong/manager/pojo/user/UserRoleCode.java
index e591fab23e..e6fdd545af 100644
--- a/inlong-manager/manager-pojo/src/main/java/org/apache/inlong/manager/pojo/user/UserRoleCode.java
+++ b/inlong-manager/manager-pojo/src/main/java/org/apache/inlong/manager/pojo/user/UserRoleCode.java
@@ -70,4 +70,9 @@ public class UserRoleCode {
*/
public static final String INLONG_OPERATOR = "INLONG_OPERATOR";
+ /**
+ * The requests from Inlong Service do not need to filter by tenant
+ */
+ public static final String INLONG_SERVICE = "INLONG_SERVICE";
+
}
diff --git a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortSourceServiceImpl.java b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortSourceServiceImpl.java
index 924a3815a3..39edbe3c41 100644
--- a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortSourceServiceImpl.java
+++ b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/impl/SortSourceServiceImpl.java
@@ -272,7 +272,7 @@ public class SortSourceServiceImpl implements SortSourceService {
task2Md5.put(taskName, md5);
} catch (Throwable t) {
LOGGER.warn("failed to parse sort source config of sortCluster={}, task={}",
- sortClusterName, taskName);
+ sortClusterName, taskName, t);
}
});
newConfigMap.put(sortClusterName, task2Config);
diff --git a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/tenant/InlongTenantServiceImpl.java b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/tenant/InlongTenantServiceImpl.java
index 746380c66a..018327d11f 100644
--- a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/tenant/InlongTenantServiceImpl.java
+++ b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/tenant/InlongTenantServiceImpl.java
@@ -111,12 +111,12 @@ public class InlongTenantServiceImpl implements InlongTenantService {
@Override
public PageResult<InlongTenantInfo> listByCondition(InlongTenantPageRequest request, UserInfo userInfo) {
- PageHelper.startPage(request.getPageNum(), request.getPageSize());
-
if (request.getListByLoginUser()) {
setTargetTenantList(request, userInfo);
}
+ PageHelper.startPage(request.getPageNum(), request.getPageSize());
+
Page<InlongTenantEntity> entityPage = inlongTenantEntityMapper.selectByCondition(request);
List<InlongTenantInfo> tenantList = CommonBeanUtils.copyListProperties(entityPage, InlongTenantInfo::new);
@@ -163,16 +163,18 @@ public class InlongTenantServiceImpl implements InlongTenantService {
}
private void setTargetTenantList(InlongTenantPageRequest request, UserInfo userInfo) {
- request.setKeyword(null);
if (isInlongRoles(userInfo)) {
+ // for inlong roles, they can get all tenant info.
request.setTenantList(null);
return;
}
List<String> tenants = tenantRoleService.listTenantByUsername(userInfo.getName());
if (CollectionUtils.isEmpty(tenants)) {
- request.setTenantList(null);
- return;
+ String errMsg = String.format("user=[%s] doesn't belong to any tenant, please contact administrator " +
+ "and get one tenant at least", userInfo.getName());
+ log.error(errMsg);
+ throw new BusinessException(errMsg);
}
request.setTenantList(tenants);
}
diff --git a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/user/TenantRoleServiceImpl.java b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/user/TenantRoleServiceImpl.java
index 618d014cec..d25d943113 100644
--- a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/user/TenantRoleServiceImpl.java
+++ b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/user/TenantRoleServiceImpl.java
@@ -98,7 +98,7 @@ public class TenantRoleServiceImpl implements TenantRoleService {
if (rowCount != InlongConstants.AFFECTED_ONE_ROW) {
throw new BusinessException(ErrorCodeEnum.CONFIG_EXPIRED,
String.format(
- "failure to update tenant user role with id=%d, request version=%d, updated row=%d",
+ "fail to update tenant user role with id=%d, request version=%d, updated row=%d",
request.getId(), request.getVersion(), rowCount));
}
return true;
diff --git a/inlong-manager/manager-service/src/test/java/org/apache/inlong/manager/service/sort/SortServiceImplTest.java b/inlong-manager/manager-service/src/test/java/org/apache/inlong/manager/service/sort/SortServiceImplTest.java
index 7fad5b6677..993ffd5734 100644
--- a/inlong-manager/manager-service/src/test/java/org/apache/inlong/manager/service/sort/SortServiceImplTest.java
+++ b/inlong-manager/manager-service/src/test/java/org/apache/inlong/manager/service/sort/SortServiceImplTest.java
@@ -39,6 +39,8 @@ import org.apache.inlong.manager.pojo.sink.SinkRequest;
import org.apache.inlong.manager.pojo.sink.hive.HiveSinkRequest;
import org.apache.inlong.manager.pojo.stream.InlongStreamExtInfo;
import org.apache.inlong.manager.pojo.stream.InlongStreamRequest;
+import org.apache.inlong.manager.pojo.user.LoginUserUtils;
+import org.apache.inlong.manager.pojo.user.UserInfo;
import org.apache.inlong.manager.service.ServiceBaseTest;
import org.apache.inlong.manager.service.cluster.InlongClusterService;
import org.apache.inlong.manager.service.core.SortService;
@@ -49,6 +51,7 @@ import org.apache.inlong.manager.service.stream.InlongStreamService;
import org.json.JSONObject;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
import org.junit.jupiter.api.Order;
@@ -60,8 +63,12 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
+
+import static org.apache.inlong.manager.pojo.user.UserRoleCode.INLONG_SERVICE;
/**
* Sort service test for {@link SortService}
@@ -106,6 +113,17 @@ public class SortServiceImplTest extends ServiceBaseTest {
@Autowired
private StreamSinkService streamSinkService;
+ @BeforeAll
+ public static void login() {
+ UserInfo userInfo = new UserInfo();
+ userInfo.setTenant(PUBLIC_TENANT);
+ userInfo.setName(GLOBAL_OPERATOR);
+ Set<String> roles = new HashSet<>();
+ roles.add(INLONG_SERVICE);
+ userInfo.setRoles(roles);
+ LoginUserUtils.setUserLoginInfo(userInfo);
+ }
+
@Test
@Order(1)
@Transactional
diff --git a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/auth/tenant/TenantAuthenticatingRealm.java b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/auth/tenant/TenantAuthenticatingRealm.java
index 6afeaaa442..d02d0b41f7 100644
--- a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/auth/tenant/TenantAuthenticatingRealm.java
+++ b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/auth/tenant/TenantAuthenticatingRealm.java
@@ -29,6 +29,7 @@ import org.apache.inlong.manager.service.user.TenantRoleService;
import org.apache.inlong.manager.service.user.UserService;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
@@ -122,10 +123,9 @@ public class TenantAuthenticatingRealm extends AuthenticatingRealm {
}
};
- if (userInfo.getRoles() == null) {
- userInfo.setRoles(roleSet);
- } else {
- userInfo.getRoles().addAll(roleSet);
+ if (CollectionUtils.isEmpty(userInfo.getRoles())) {
+ roleSet.addAll(userInfo.getRoles());
}
+ userInfo.setRoles(roleSet);
}
}
[inlong] 01/02: [INLONG-8572][Manager] Fix missing information in InlongStreamBriefInfo (#8573)
Posted by ve...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
vernedeng pushed a commit to branch branch-1.8
in repository https://gitbox.apache.org/repos/asf/inlong.git
commit f48e05853e62e5540c4a74868ddc114a4cd2344f
Author: fuweng11 <76...@users.noreply.github.com>
AuthorDate: Wed Jul 19 16:36:08 2023 +0800
[INLONG-8572][Manager] Fix missing information in InlongStreamBriefInfo (#8573)
* [INLONG-8572][Manager] Fix missing information in InlongStreamBriefInfo
(cherry picked from commit 489ee0d184cf68cbf14316b36bfd8c769308b16e)
---
.../manager/pojo/stream/InlongStreamBriefInfo.java | 39 ++++++++++++++++++++++
inlong-manager/manager-service/pom.xml | 2 +-
2 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/inlong-manager/manager-pojo/src/main/java/org/apache/inlong/manager/pojo/stream/InlongStreamBriefInfo.java b/inlong-manager/manager-pojo/src/main/java/org/apache/inlong/manager/pojo/stream/InlongStreamBriefInfo.java
index 59d6aa9e3d..28dadc2b53 100644
--- a/inlong-manager/manager-pojo/src/main/java/org/apache/inlong/manager/pojo/stream/InlongStreamBriefInfo.java
+++ b/inlong-manager/manager-pojo/src/main/java/org/apache/inlong/manager/pojo/stream/InlongStreamBriefInfo.java
@@ -46,9 +46,48 @@ public class InlongStreamBriefInfo {
@ApiModelProperty(value = "Inlong stream name")
private String name;
+ @ApiModelProperty(value = "Inlong stream description")
+ private String description;
+
@ApiModelProperty(value = "MQ resource")
private String mqResource;
+ @ApiModelProperty(value = "Data type, including: TEXT, KV, etc.")
+ private String dataType;
+
+ @ApiModelProperty(value = "Data encoding format: UTF-8, GBK")
+ private String dataEncoding;
+
+ @ApiModelProperty(value = "Data separator")
+ private String dataSeparator;
+
+ @ApiModelProperty(value = "Data field escape symbol")
+ private String dataEscapeChar;
+
+ @ApiModelProperty(value = "Whether to send synchronously, 0: no, 1: yes")
+ private Integer syncSend;
+
+ @ApiModelProperty(value = "Number of access items per day, unit: 10,000 items per day")
+ private Integer dailyRecords;
+
+ @ApiModelProperty(value = "Access size per day, unit: GB per day")
+ private Integer dailyStorage;
+
+ @ApiModelProperty(value = "peak access per second, unit: bars per second")
+ private Integer peakRecords;
+
+ @ApiModelProperty(value = "The maximum length of a single piece of data, unit: Byte")
+ private Integer maxLength;
+
+ @ApiModelProperty(value = "Data storage period, unit: day")
+ private Integer storagePeriod;
+
+ @ApiModelProperty(value = "Whether the message body wrapped with InlongMsg")
+ private Boolean wrapWithInlongMsg;
+
+ @ApiModelProperty(value = "Whether to ignore the parse errors of field value")
+ private Boolean ignoreParseError;
+
@ApiModelProperty(value = "Status")
private Integer status;
diff --git a/inlong-manager/manager-service/pom.xml b/inlong-manager/manager-service/pom.xml
index 01a5867766..be707469e9 100644
--- a/inlong-manager/manager-service/pom.xml
+++ b/inlong-manager/manager-service/pom.xml
@@ -672,7 +672,7 @@
<goals>
<goal>copy</goal>
</goals>
- <phase>pre-integration-test</phase>
+ <phase>process-test-resources</phase>
</execution>
</executions>
</plugin>