@ -26,6 +26,7 @@ import org.apache.dolphinscheduler.dao.mapper.QueueMapper;
import com.baomidou.mybatisplus.core.metadata.IPage ;
import com.baomidou.mybatisplus.core.metadata.IPage ;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page ;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page ;
import org.apache.commons.lang.StringUtils ;
import org.apache.commons.lang.StringUtils ;
import org.apache.dolphinscheduler.dao.mapper.UserMapper ;
import org.slf4j.Logger ;
import org.slf4j.Logger ;
import org.slf4j.LoggerFactory ;
import org.slf4j.LoggerFactory ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.beans.factory.annotation.Autowired ;
@ -47,6 +48,9 @@ public class QueueService extends BaseService {
@Autowired
@Autowired
private QueueMapper queueMapper ;
private QueueMapper queueMapper ;
@Autowired
private UserMapper userMapper ;
/ * *
/ * *
* query queue list
* query queue list
*
*
@ -187,6 +191,13 @@ public class QueueService extends BaseService {
}
}
}
}
// check old queue using by any user
if ( checkIfQueueIsInUsing ( queueObj . getQueueName ( ) , queueName ) ) {
//update user related old queue
Integer relatedUserNums = userMapper . updateUserQueue ( queueObj . getQueueName ( ) , queueName ) ;
logger . info ( "old queue have related {} user, exec update user success." , relatedUserNums ) ;
}
// update queue
// update queue
Date now = new Date ( ) ;
Date now = new Date ( ) ;
queueObj . setQueue ( queue ) ;
queueObj . setQueue ( queue ) ;
@ -194,6 +205,7 @@ public class QueueService extends BaseService {
queueObj . setUpdateTime ( now ) ;
queueObj . setUpdateTime ( now ) ;
queueMapper . updateById ( queueObj ) ;
queueMapper . updateById ( queueObj ) ;
putMsg ( result , Status . SUCCESS ) ;
putMsg ( result , Status . SUCCESS ) ;
return result ;
return result ;
@ -240,21 +252,35 @@ public class QueueService extends BaseService {
* check queue exist
* check queue exist
* if exists return true , not exists return false
* if exists return true , not exists return false
* check queue exist
* check queue exist
*
* @param queue queue
* @param queue queue
* @return true if the queue not exists , otherwise return false
* @return true if the queue not exists , otherwise return false
* /
* /
private boolean checkQueueExist ( String queue ) {
private boolean checkQueueExist ( String queue ) {
return queueMapper . queryAllQueueList ( queue , null ) . size ( ) > 0 ? true : false ;
return queueMapper . queryAllQueueList ( queue , null ) . size ( ) > 0 ;
}
}
/ * *
/ * *
* check queue name exist
* check queue name exist
* if exists return true , not exists return false
* if exists return true , not exists return false
*
* @param queueName queue name
* @param queueName queue name
* @return true if the queue name not exists , otherwise return false
* @return true if the queue name not exists , otherwise return false
* /
* /
private boolean checkQueueNameExist ( String queueName ) {
private boolean checkQueueNameExist ( String queueName ) {
return queueMapper . queryAllQueueList ( null , queueName ) . size ( ) > 0 ? true : false ;
return queueMapper . queryAllQueueList ( null , queueName ) . size ( ) > 0 ;
}
/ * *
* check old queue name using by any user
* if need to update user
*
* @param oldQueue old queue name
* @param newQueue new queue name
* @return true if need to update user
* /
private boolean checkIfQueueIsInUsing ( String oldQueue , String newQueue ) {
return ! oldQueue . equals ( newQueue ) & & userMapper . queryUserListByQueue ( oldQueue ) . size ( ) > 0 ;
}
}
}
}