Browse Source
【问题原因】测试用sleep来模拟取数慢,在取列名的时候会造成一些奇怪的错误 【改动思路】1.因为计算列名里做了异常处理,所以跟产品沟通后确定逻辑为列名为空时,就不展示整个数据集节点了;2.产品让把最大搜索时间的限制去掉 【review建议】无feature/x
Yvan
3 years ago
4 changed files with 4 additions and 99 deletions
@ -1,64 +0,0 @@
|
||||
package com.fr.design.data.datapane.management.search.time; |
||||
|
||||
import com.fr.concurrent.NamedThreadFactory; |
||||
import com.fr.general.ComparatorUtils; |
||||
|
||||
import java.util.concurrent.Executors; |
||||
import java.util.concurrent.ScheduledExecutorService; |
||||
import java.util.concurrent.TimeUnit; |
||||
|
||||
/** |
||||
* 搜索任务定时器 |
||||
* |
||||
* @author Yvan |
||||
*/ |
||||
public class TableDataSearchTimer { |
||||
|
||||
/** |
||||
* 定时器 |
||||
*/ |
||||
private static ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory(TableDataSearchTimer.class)); |
||||
|
||||
/** |
||||
* 定时任务 |
||||
*/ |
||||
private TableDataSearchTimerTask timeTask; |
||||
|
||||
/** |
||||
* 最大单次startSearch的时间 |
||||
*/ |
||||
public static final long MAX_SEARCH_TIME = 5000; |
||||
|
||||
private TableDataSearchTimer() { |
||||
} |
||||
|
||||
private static class Holder { |
||||
private static final TableDataSearchTimer INSTANCE = new TableDataSearchTimer(); |
||||
} |
||||
|
||||
public static TableDataSearchTimer getInstance() { |
||||
return Holder.INSTANCE; |
||||
} |
||||
|
||||
public void startClock() { |
||||
this.timeTask = new TableDataSearchTimerTask(); |
||||
scheduler.schedule(timeTask, MAX_SEARCH_TIME, TimeUnit.MILLISECONDS); |
||||
} |
||||
|
||||
public void stopClock() { |
||||
this.timeTask = null; |
||||
} |
||||
|
||||
public void shutdown() { |
||||
scheduler.shutdown(); |
||||
} |
||||
|
||||
/** |
||||
* 判断是不是当前的Timer中的task,为了避免shutdownNow()之后原task仍在执行,可能会 |
||||
* @param task |
||||
* @return |
||||
*/ |
||||
public boolean isCurrentTask(TableDataSearchTimerTask task) { |
||||
return ComparatorUtils.equals(this.timeTask, task); |
||||
} |
||||
} |
@ -1,22 +0,0 @@
|
||||
package com.fr.design.data.datapane.management.search.time; |
||||
|
||||
import com.fr.design.data.datapane.management.search.TableDataTreeSearchManager; |
||||
import com.fr.design.data.datapane.management.search.searcher.TreeSearchStatus; |
||||
|
||||
/** |
||||
* @author Yvan |
||||
*/ |
||||
public class TableDataSearchTimerTask implements Runnable { |
||||
|
||||
public TableDataSearchTimerTask() { |
||||
} |
||||
|
||||
@Override |
||||
public void run() { |
||||
// 最大单次搜索时间过后,将结束搜索
|
||||
if (TableDataTreeSearchManager.getInstance().getTreeSearchStatus() == TreeSearchStatus.SEARCHING && |
||||
TableDataSearchTimer.getInstance().isCurrentTask(this)) { |
||||
TableDataTreeSearchManager.getInstance().completeSearch(); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue