Skip to content

Commit 08e2bee

Browse files
[Meta] Remove casbin (lakesoul-io#574)
* remove casbin Signed-off-by: chenxu <chenxu@dmetasoul.com> * exclude slf4j-api 2.0 Signed-off-by: chenxu <chenxu@dmetasoul.com> * fix tests Signed-off-by: chenxu <chenxu@dmetasoul.com> * fix tests Signed-off-by: chenxu <chenxu@dmetasoul.com> * fix test Signed-off-by: chenxu <chenxu@dmetasoul.com> * fix test Signed-off-by: chenxu <chenxu@dmetasoul.com> --------- Signed-off-by: chenxu <chenxu@dmetasoul.com> Co-authored-by: chenxu <chenxu@dmetasoul.com>
1 parent d381b52 commit 08e2bee

28 files changed

+20
-977
lines changed

lakesoul-common/pom.xml

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,6 @@ SPDX-License-Identifier: Apache-2.0
2121
<version>${revision}</version>
2222
<build>
2323
<plugins>
24-
<!-- ajc -->
25-
<plugin>
26-
<groupId>org.codehaus.mojo</groupId>
27-
<artifactId>aspectj-maven-plugin</artifactId>
28-
<version>1.14.0</version>
29-
<configuration>
30-
<complianceLevel>1.8</complianceLevel>
31-
<source>1.8</source>
32-
<target>1.8</target>
33-
<showWeaveInfo>true</showWeaveInfo>
34-
<verbose>true</verbose>
35-
<Xlint>ignore</Xlint>
36-
<encoding>UTF-8</encoding>
37-
</configuration>
38-
<executions>
39-
<execution>
40-
<goals>
41-
<goal>compile</goal>
42-
<goal>test-compile</goal>
43-
</goals>
44-
</execution>
45-
</executions>
46-
</plugin>
47-
4824
<plugin>
4925
<groupId>org.xolstice.maven.plugins</groupId>
5026
<artifactId>protobuf-maven-plugin</artifactId>
@@ -287,52 +263,6 @@ SPDX-License-Identifier: Apache-2.0
287263
<artifactId>scala-reflect</artifactId>
288264
<version>${scala.version}</version>
289265
</dependency>
290-
<!-- casbin -->
291-
<dependency>
292-
<groupId>org.casbin</groupId>
293-
<artifactId>jdbc-adapter</artifactId>
294-
<version>2.4.1</version>
295-
<exclusions>
296-
<exclusion>
297-
<groupId>org.postgresql</groupId>
298-
<artifactId>postgresql</artifactId>
299-
</exclusion>
300-
<exclusion>
301-
<groupId>com.oracle.database.jdbc</groupId>
302-
<artifactId>ojdbc6</artifactId>
303-
</exclusion>
304-
<exclusion>
305-
<groupId>com.microsoft.sqlserver</groupId>
306-
<artifactId>mssql-jdbc</artifactId>
307-
</exclusion>
308-
<exclusion>
309-
<groupId>org.slf4j</groupId>
310-
<artifactId>slf4j-api</artifactId>
311-
</exclusion>
312-
<exclusion>
313-
<groupId>org.casbin</groupId>
314-
<artifactId>jcasbin</artifactId>
315-
</exclusion>
316-
</exclusions>
317-
</dependency>
318-
<dependency>
319-
<groupId>org.casbin</groupId>
320-
<artifactId>jcasbin</artifactId>
321-
<version>1.73.0</version>
322-
</dependency>
323-
<!-- aspectJ -->
324-
<dependency>
325-
<groupId>org.aspectj</groupId>
326-
<artifactId>aspectjrt</artifactId>
327-
<version>1.9.19</version>
328-
<scope>compile</scope>
329-
</dependency>
330-
<dependency>
331-
<groupId>org.aspectj</groupId>
332-
<artifactId>aspectjweaver</artifactId>
333-
<version>1.9.19</version>
334-
<scope>compile</scope>
335-
</dependency>
336266

337267
<!-- protobuf -->
338268
<dependency>

lakesoul-common/src/main/java/com/dmetasoul/lakesoul/meta/DBManager.java

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
import com.dmetasoul.lakesoul.meta.entity.*;
1111
import com.dmetasoul.lakesoul.meta.jnr.NativeMetadataJavaClient;
1212
import com.dmetasoul.lakesoul.meta.jnr.NativeUtils;
13-
import com.dmetasoul.lakesoul.meta.rbac.AuthZContext;
14-
import com.dmetasoul.lakesoul.meta.rbac.AuthZEnforcer;
1513
import org.apache.commons.lang3.StringUtils;
1614
import org.slf4j.Logger;
1715
import org.slf4j.LoggerFactory;
@@ -844,9 +842,6 @@ public void rollbackPartitionByVersion(String tableId, String partitionDesc, int
844842
}
845843

846844
private String getTableDomain(String tableId) {
847-
if (!AuthZEnforcer.authZEnabled()) {
848-
return "public";
849-
}
850845
TableInfo tableInfo = this.getTableInfoByTableId(tableId);
851846
if (tableInfo == null) {
852847
throw new IllegalStateException("target tableinfo does not exists");
@@ -855,9 +850,6 @@ private String getTableDomain(String tableId) {
855850
}
856851

857852
private String getNameSpaceDomain(String namespace) {
858-
if (!AuthZEnforcer.authZEnabled()) {
859-
return "public";
860-
}
861853
Namespace namespaceInfo = getNamespaceByNamespace(namespace);
862854
if (namespaceInfo == null) {
863855
throw new IllegalStateException("target namespace does not exists");
@@ -917,9 +909,7 @@ public void createNewNamespace(String name, String properties, String comment) {
917909
.setProperties(properties)
918910
.setComment(comment == null ? "" : comment);
919911

920-
namespace.setDomain(AuthZEnforcer.authZEnabled()
921-
? AuthZContext.getInstance().getDomain()
922-
: "public");
912+
namespace.setDomain(DBUtil.getDomain());
923913
namespaceDao.insert(namespace.build());
924914

925915
}
@@ -952,15 +942,11 @@ public void deleteNamespace(String namespace) {
952942
public void cleanMeta() {
953943
if (NativeUtils.NATIVE_METADATA_UPDATE_ENABLED) {
954944
NativeMetadataJavaClient.cleanMeta();
955-
if (!AuthZEnforcer.authZEnabled()) {
956-
namespaceDao.insert(NamespaceDao.DEFAULT_NAMESPACE);
957-
}
945+
namespaceDao.insert(NamespaceDao.DEFAULT_NAMESPACE);
958946
return;
959947
}
960948
namespaceDao.clean();
961-
if (!AuthZEnforcer.authZEnabled()) {
962-
namespaceDao.insert(NamespaceDao.DEFAULT_NAMESPACE);
963-
}
949+
namespaceDao.insert(NamespaceDao.DEFAULT_NAMESPACE);
964950
dataCommitInfoDao.clean();
965951
tableInfoDao.clean();
966952
tablePathIdDao.clean();

lakesoul-common/src/main/java/com/dmetasoul/lakesoul/meta/DBUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ public class DBUtil {
3939
public static final String urlKey = "lakesoul.pg.url";
4040
public static final String usernameKey = "lakesoul.pg.username";
4141
public static final String passwordKey = "lakesoul.pg.password";
42+
public static final String domainKey = "lakesoul.current.domain";
4243

4344
private static final String driverNameEnv = "LAKESOUL_PG_DRIVER";
4445
private static final String urlEnv = "LAKESOUL_PG_URL";
4546
private static final String usernameEnv = "LAKESOUL_PG_USERNAME";
4647
private static final String passwordEnv = "LAKESOUL_PG_PASSWORD";
4748
private static final String domainENV = "LAKESOUL_CURRENT_DOMAIN";
48-
public static final String domainKey = "lakesoul.current.domain";
4949

5050
private static final String lakeSoulHomeEnv = "LAKESOUL_HOME";
5151

@@ -287,7 +287,7 @@ public static void fillDataSourceConfig(HikariConfig config) {
287287
config.setConnectionTimeout(10000);
288288
config.setIdleTimeout(10000);
289289
config.setMaximumPoolSize(8);
290-
config.setKeepaliveTime(5000);
290+
config.setKeepaliveTime(60000);
291291
config.setMinimumIdle(0);
292292
config.setMaxLifetime(1800000);
293293
config.addDataSourceProperty("cachePrepStmts", "true");

lakesoul-common/src/main/java/com/dmetasoul/lakesoul/meta/dao/NamespaceDao.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
import com.dmetasoul.lakesoul.meta.entity.Namespace;
1111
import com.dmetasoul.lakesoul.meta.jnr.NativeMetadataJavaClient;
1212
import com.dmetasoul.lakesoul.meta.jnr.NativeUtils;
13-
import com.dmetasoul.lakesoul.meta.rbac.AuthZContext;
14-
import com.dmetasoul.lakesoul.meta.rbac.AuthZEnforcer;
15-
import dev.failsafe.internal.util.Lists;
1613

1714
import java.sql.Connection;
1815
import java.sql.PreparedStatement;
@@ -184,7 +181,7 @@ public static Namespace namespaceFromResultSet(ResultSet rs) throws SQLException
184181
.setNamespace(DBConfig.LAKESOUL_DEFAULT_NAMESPACE)
185182
.setProperties("{}")
186183
.setComment("")
187-
.setDomain(AuthZContext.getInstance().getDomain())
184+
.setDomain("public")
188185
.build();
189186

190187
}

lakesoul-common/src/main/java/com/dmetasoul/lakesoul/meta/jnr/NativeMetadataJavaClient.java

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@ public class NativeMetadataJavaClient implements AutoCloseable {
5050

5151
private final ReentrantReadWriteLock lock;
5252

53-
private static DataBaseProperty dataBaseProperty = null;
54-
55-
public static void setDataBaseProperty(DataBaseProperty dataBaseProperty) {
56-
NativeMetadataJavaClient.dataBaseProperty = dataBaseProperty;
57-
}
58-
5953
public NativeMetadataJavaClient() {
6054
this(5000L, 1 << 12);
6155
}
@@ -71,18 +65,17 @@ public NativeMetadataJavaClient(long timeout, int bufferSize) {
7165
initialize();
7266
}
7367

74-
public static NativeMetadataJavaClient getInstance() {
68+
public static synchronized NativeMetadataJavaClient getInstance() {
7569
if (instance == null) {
7670
instance = new NativeMetadataJavaClient();
7771
}
7872
return instance;
7973
}
8074

81-
public static void shutDownInstance() {
82-
instance = null;
75+
public static synchronized void shutDownInstance() {
76+
closeAll();
8377
}
8478

85-
8679
public Pointer getTokioPostgresClient() {
8780
return tokioPostgresClient;
8881
}
@@ -182,10 +175,7 @@ public void close() {
182175

183176
private void initialize() {
184177
libLakeSoulMetaData.rust_logger_init();
185-
DataBaseProperty dataBaseProperty = NativeMetadataJavaClient.dataBaseProperty;
186-
if (dataBaseProperty == null) {
187-
dataBaseProperty = DBUtil.getDBInfo();
188-
}
178+
DataBaseProperty dataBaseProperty = DBUtil.getDBInfo();
189179
tokioRuntime = libLakeSoulMetaData.create_tokio_runtime();
190180

191181
String config = String.format(
@@ -195,6 +185,7 @@ private void initialize() {
195185
dataBaseProperty.getDbName(),
196186
dataBaseProperty.getUsername(),
197187
dataBaseProperty.getPassword());
188+
System.out.println("initialize native metadata client: " + config);
198189
final CompletableFuture<Boolean> future = new CompletableFuture<>();
199190
tokioPostgresClient = libLakeSoulMetaData.create_tokio_postgres_client(
200191
new ReferencedBooleanCallback((bool, msg) -> {
@@ -522,7 +513,7 @@ public void close() {
522513
}
523514
}
524515

525-
public static void closeAll() {
516+
public static synchronized void closeAll() {
526517
if (instance != null) {
527518
instance.close();
528519
instance = null;

lakesoul-common/src/main/java/com/dmetasoul/lakesoul/meta/rbac/AuthZ.java

Lines changed: 0 additions & 17 deletions
This file was deleted.

lakesoul-common/src/main/java/com/dmetasoul/lakesoul/meta/rbac/AuthZAdvice.java

Lines changed: 0 additions & 25 deletions
This file was deleted.

lakesoul-common/src/main/java/com/dmetasoul/lakesoul/meta/rbac/AuthZAfter.java

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)