Skip to content

Commit

Permalink
优化单个connection的获取,添加getconnection busy的提示,针对track支持复杂类型 0.9.9
Browse files Browse the repository at this point in the history
  • Loading branch information
xuejmnet committed May 28, 2023
1 parent bf15bf3 commit 7cc6737
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 42 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>com.easy-query</groupId>
<artifactId>easy-query-all</artifactId>
<packaging>pom</packaging>
<version>0.9.8</version>
<version>0.9.9</version>
<name>easy-query</name>
<description>java object query distributed connector</description>
<url>https://github.com/xuejmnet/easy-query</url>
Expand Down
2 changes: 1 addition & 1 deletion samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>easy-query-all</artifactId>
<groupId>com.easy-query</groupId>
<version>0.9.8</version>
<version>0.9.9</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion samples/springbootdemo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<dependency>
<groupId>com.easy-query</groupId>
<artifactId>sql-springboot-starter</artifactId>
<version>0.9.8</version>
<version>0.9.9</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion sql-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>easy-query-all</artifactId>
<groupId>com.easy-query</groupId>
<version>0.9.8</version>
<version>0.9.9</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private Object createAndCopyValue(Object entity, EntityMetadata entityMetadata){
Class<?> propertyType = columnMetadata.getPropertyType();
Property<Object, ?> beanGetter = fastBean.getBeanGetter(property);
Object value = beanGetter.apply(entity);
if(EasyClassUtil.isBasicType(propertyType)){
if(EasyClassUtil.isBasicType(propertyType)||EasyClassUtil.isEnumType(propertyType)){

beanSetter.call(original,value);
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,15 @@ protected List<Connection> getConnections(int count) throws SQLException {
protected SemaphoreReleaseOnlyOnce tryAcquire(int count, long timeout, TimeUnit unit) {

try {
long startTime =warningBusy? System.currentTimeMillis():0L;
long startTime = warningBusy ? System.currentTimeMillis() : 0L;
boolean acquire = semaphore.tryAcquire(count, timeout, unit);
if (acquire) {
if (warningBusy) {
long endTime = System.currentTimeMillis();
long constTime = endTime - startTime;
if (constTime > (unit.toMillis(timeout) * 0.8)) {
log.warn("get connection is busy. you can try increasing the connection pool size or reducing the number of access requests.");
long timeoutMillis = unit.toMillis(timeout);
if (constTime >= (timeoutMillis * 0.8)) {
log.warn("get connection use time:" + constTime + "(ms),timeout:" + timeoutMillis + "(ms). you can try increasing the connection pool size or reducing the number of access requests.");
}
}
return new SemaphoreReleaseOnlyOnce(count, semaphore);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.easy.query.core.expression.segment.factory;

/**
* create time 2023/5/28 22:26
* 文件说明
*
* @author xuejiaming
*/
public interface SQLSegmentFactory {
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,37 +28,10 @@ public void addTable(TableAvailable table) {
aliasMapping.put(table, new TableAliasSchema(table, size));
}

public String getTableAlias(TableAvailable table, String alias) {
if (table == null) {
throw new IllegalArgumentException("table is null");
}
int mappingSize = aliasMapping.size();
if (mappingSize == 0) {
return null;
}
if (mappingSize == 1) {
TableAliasSchema tableAliasSchema = getTableAliasSchema(table);
if (tableAliasSchema.getTable().isAnonymous()||tableAliasSchema.getTable().hasAlias()) {
return tableAliasSchema.getTableAlias(alias);
}
return null;
}
return getTableAliasSchema(table).getTableAlias(alias);
}

public boolean isEmpty() {
return aliasMapping.isEmpty();
}

public TableAliasSchema getTableAliasSchema(TableAvailable table) {

TableAliasSchema tableAliasSchema = aliasMapping.get(table);
if (tableAliasSchema == null) {
throw new EasyQueryInvalidOperationException("unknown table:" + EasyClassUtil.getSimpleName(table.getEntityClass()) + "." + table.getTableName());
}
return tableAliasSchema;
}

public void copyTo(TableContext tableContext){
for (Map.Entry<TableAvailable, TableAliasSchema> aliasSchemaEntry : aliasMapping.entrySet()) {
tableContext.addTable(aliasSchemaEntry.getKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ public static boolean isBasicType(Class<?> clazz) {
} else {
return false;
}

}
public static boolean isEnumType(Class<?> clazz) {
return clazz.isEnum();
}

public static <T> T newInstance(Class<T> clazz) {
Expand Down
2 changes: 1 addition & 1 deletion sql-h2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.easy-query</groupId>
<artifactId>easy-query-all</artifactId>
<version>0.9.8</version>
<version>0.9.9</version>
</parent>

<artifactId>sql-h2</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion sql-mssql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.easy-query</groupId>
<artifactId>easy-query-all</artifactId>
<version>0.9.8</version>
<version>0.9.9</version>
</parent>

<artifactId>sql-mssql</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion sql-mysql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>easy-query-all</artifactId>
<groupId>com.easy-query</groupId>
<version>0.9.8</version>
<version>0.9.9</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sql-pgsql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.easy-query</groupId>
<artifactId>easy-query-all</artifactId>
<version>0.9.8</version>
<version>0.9.9</version>
</parent>

<artifactId>sql-pgsql</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion sql-springboot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>easy-query-all</artifactId>
<groupId>com.easy-query</groupId>
<version>0.9.8</version>
<version>0.9.9</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion sql-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>easy-query-all</artifactId>
<groupId>com.easy-query</groupId>
<version>0.9.8</version>
<version>0.9.9</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down

0 comments on commit 7cc6737

Please sign in to comment.