Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
b646682d
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dbeaver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b646682d
编写于
6月 12, 2018
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#3616 Query cancel refactoring
Former-commit-id:
aa2fb8cd
上级
ab21ce70
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
50 addition
and
49 deletion
+50
-49
plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/model/OracleDataSource.java
.../org/jkiss/dbeaver/ext/oracle/model/OracleDataSource.java
+20
-0
plugins/org.jkiss.dbeaver.ext.wmi/src/org/jkiss/dbeaver/ext/wmi/model/WMISession.java
...t.wmi/src/org/jkiss/dbeaver/ext/wmi/model/WMISession.java
+2
-1
plugins/org.jkiss.dbeaver.ext.wmi/src/org/jkiss/dbeaver/ext/wmi/model/WMIStatement.java
...wmi/src/org/jkiss/dbeaver/ext/wmi/model/WMIStatement.java
+2
-1
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/exec/jdbc/JDBCSession.java
...el/src/org/jkiss/dbeaver/model/exec/jdbc/JDBCSession.java
+4
-0
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/jdbc/JDBCDataSource.java
...src/org/jkiss/dbeaver/model/impl/jdbc/JDBCDataSource.java
+10
-0
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/jdbc/exec/JDBCConnectionImpl.java
...kiss/dbeaver/model/impl/jdbc/exec/JDBCConnectionImpl.java
+2
-2
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/jdbc/exec/JDBCStatementImpl.java
...jkiss/dbeaver/model/impl/jdbc/exec/JDBCStatementImpl.java
+3
-7
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/runtime/BlockCanceler.java
...el/src/org/jkiss/dbeaver/model/runtime/BlockCanceler.java
+2
-37
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/runtime/DBRBlockingObject.java
...rc/org/jkiss/dbeaver/model/runtime/DBRBlockingObject.java
+5
-1
未找到文件。
plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/model/OracleDataSource.java
浏览文件 @
b646682d
...
...
@@ -547,6 +547,26 @@ public class OracleDataSource extends JDBCDataSource
return
super
.
getAdapter
(
adapter
);
}
@Override
public
void
cancelStatementExecute
(
DBRProgressMonitor
monitor
,
JDBCStatement
statement
)
throws
DBException
{
if
(
driverSupportsQueryCancel
())
{
super
.
cancelStatementExecute
(
monitor
,
statement
);
}
else
{
// Oracle server doesn't support single query cancel?
// But we could try to cancel all
try
{
Connection
connection
=
statement
.
getConnection
().
getOriginal
();
BeanUtils
.
invokeObjectMethod
(
connection
,
"cancel"
);
}
catch
(
Throwable
e
)
{
throw
new
DBException
(
"Can't cancel session queries"
,
e
,
this
);
}
}
}
private
boolean
driverSupportsQueryCancel
()
{
return
true
;
}
@NotNull
@Override
public
OracleDataSource
getDataSource
()
{
...
...
plugins/org.jkiss.dbeaver.ext.wmi/src/org/jkiss/dbeaver/ext/wmi/model/WMISession.java
浏览文件 @
b646682d
...
...
@@ -17,6 +17,7 @@
package
org.jkiss.dbeaver.ext.wmi.model
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.model.exec.*
;
import
org.jkiss.dbeaver.model.impl.AbstractSession
;
...
...
@@ -56,7 +57,7 @@ public class WMISession extends AbstractSession {
}
@Override
public
void
cancelBlock
()
throws
DBException
public
void
cancelBlock
(
@NotNull
DBRProgressMonitor
monitor
,
@Nullable
Thread
blockThread
)
throws
DBException
{
// Cancel WMI async call
}
...
...
plugins/org.jkiss.dbeaver.ext.wmi/src/org/jkiss/dbeaver/ext/wmi/model/WMIStatement.java
浏览文件 @
b646682d
...
...
@@ -20,6 +20,7 @@ import org.jkiss.code.NotNull;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.model.exec.*
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.wmi.service.WMIConstants
;
import
org.jkiss.wmi.service.WMIException
;
import
org.jkiss.wmi.service.WMIObject
;
...
...
@@ -165,7 +166,7 @@ public class WMIStatement implements DBCStatement {
}
@Override
public
void
cancelBlock
()
throws
DBException
public
void
cancelBlock
(
@NotNull
DBRProgressMonitor
monitor
,
@Nullable
Thread
blockThread
)
throws
DBException
{
}
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/exec/jdbc/JDBCSession.java
浏览文件 @
b646682d
...
...
@@ -19,9 +19,11 @@ package org.jkiss.dbeaver.model.exec.jdbc;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.model.exec.DBCException
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContext
;
import
org.jkiss.dbeaver.model.exec.DBCSession
;
import
org.jkiss.dbeaver.model.exec.DBCStatementType
;
import
org.jkiss.dbeaver.model.impl.jdbc.JDBCDataSource
;
import
org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext
;
import
java.sql.Connection
;
import
java.sql.SQLException
;
...
...
@@ -38,6 +40,8 @@ public interface JDBCSession extends DBCSession, Connection {
Connection
getOriginal
()
throws
SQLException
;
JDBCExecutionContext
getExecutionContext
();
@Override
@NotNull
JDBCStatement
prepareStatement
(
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/jdbc/JDBCDataSource.java
浏览文件 @
b646682d
...
...
@@ -31,6 +31,7 @@ import org.jkiss.dbeaver.model.exec.*;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCDatabaseMetaData
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCFactory
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCSession
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCStatement
;
import
org.jkiss.dbeaver.model.impl.jdbc.data.handlers.JDBCObjectValueHandler
;
import
org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCConnectionImpl
;
import
org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCFactoryDefault
;
...
...
@@ -722,4 +723,13 @@ public abstract class JDBCDataSource
public
DBDValueHandler
getDefaultValueHandler
()
{
return
JDBCObjectValueHandler
.
INSTANCE
;
}
public
void
cancelStatementExecute
(
DBRProgressMonitor
monitor
,
JDBCStatement
statement
)
throws
DBException
{
try
{
statement
.
cancel
();
}
catch
(
SQLException
e
)
{
throw
new
DBException
(
e
,
this
);
}
}
}
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/jdbc/exec/JDBCConnectionImpl.java
浏览文件 @
b646682d
...
...
@@ -63,7 +63,7 @@ public class JDBCConnectionImpl extends AbstractSession implements JDBCSession,
@NotNull
@Override
public
DBCExecutionContext
getExecutionContext
()
{
public
J
DBCExecutionContext
getExecutionContext
()
{
return
context
;
}
...
...
@@ -672,7 +672,7 @@ public class JDBCConnectionImpl extends AbstractSession implements JDBCSession,
}
@Override
public
void
cancelBlock
()
public
void
cancelBlock
(
@NotNull
DBRProgressMonitor
monitor
,
@Nullable
Thread
blockThread
)
throws
DBException
{
try
{
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/jdbc/exec/JDBCStatementImpl.java
浏览文件 @
b646682d
...
...
@@ -29,6 +29,7 @@ import org.jkiss.dbeaver.model.exec.jdbc.JDBCSession;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCStatement
;
import
org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils
;
import
org.jkiss.dbeaver.model.qm.QMUtils
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.utils.CommonUtils
;
import
java.sql.*
;
...
...
@@ -88,15 +89,10 @@ public class JDBCStatementImpl<STATEMENT extends Statement> implements JDBCState
}
@Override
public
void
cancelBlock
()
public
void
cancelBlock
(
@NotNull
DBRProgressMonitor
monitor
,
@Nullable
Thread
blockThread
)
throws
DBException
{
try
{
this
.
cancel
();
}
catch
(
SQLException
e
)
{
throw
new
DBException
(
e
,
connection
.
getDataSource
());
}
getConnection
().
getDataSource
().
cancelStatementExecute
(
monitor
,
this
);
}
@NotNull
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/runtime/BlockCanceler.java
浏览文件 @
b646682d
...
...
@@ -16,56 +16,21 @@
*/
package
org.jkiss.dbeaver.model.runtime
;
import
org.eclipse.core.runtime.IProgressMonitor
;
import
org.eclipse.core.runtime.IStatus
;
import
org.eclipse.core.runtime.Status
;
import
org.eclipse.core.runtime.jobs.Job
;
import
org.jkiss.dbeaver.DBException
;
/**
* Abstract Database Job
*/
public
class
BlockCanceler
extends
Job
public
class
BlockCanceler
{
private
static
final
long
INTERRUPT_TIMEOUT
=
2000
;
private
final
Thread
thread
;
private
boolean
blockCanceled
=
false
;
public
BlockCanceler
(
Thread
thread
)
{
super
(
"Interrupter of "
+
thread
.
getName
());
setSystem
(
true
);
setUser
(
false
);
this
.
thread
=
thread
;
}
@Override
protected
IStatus
run
(
IProgressMonitor
monitor
)
{
if
(!
blockCanceled
)
{
thread
.
interrupt
();
}
return
Status
.
OK_STATUS
;
}
public
static
void
cancelBlock
(
DBRProgressMonitor
monitor
,
Thread
blockActiveThread
)
throws
DBException
{
BlockCanceler
canceler
=
null
;
if
(
blockActiveThread
!=
null
)
{
// Schedule thread interrupt job
canceler
=
new
BlockCanceler
(
blockActiveThread
);
canceler
.
schedule
(
INTERRUPT_TIMEOUT
);
}
DBRBlockingObject
block
=
monitor
.
getActiveBlock
();
if
(
block
!=
null
)
{
final
Thread
thread
=
Thread
.
currentThread
();
final
String
threadOldName
=
thread
.
getName
();
thread
.
setName
(
"Operation cancel ["
+
block
+
"]"
);
try
{
block
.
cancelBlock
();
if
(
canceler
!=
null
)
{
canceler
.
blockCanceled
=
true
;
}
block
.
cancelBlock
(
monitor
,
blockActiveThread
);
}
catch
(
Throwable
e
)
{
throw
new
DBException
(
"Cancel error"
,
e
);
}
finally
{
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/runtime/DBRBlockingObject.java
浏览文件 @
b646682d
...
...
@@ -17,6 +17,8 @@
package
org.jkiss.dbeaver.model.runtime
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
/**
...
...
@@ -30,7 +32,9 @@ public interface DBRBlockingObject {
* In actual implementation this object may not block process at the moment of invocation
* of this method. Implementor should check object's state and cancel blocking on demand.
* @throws DBException on error
* @param monitor monitor
* @param blockThread thread which initiated the block. Can be null.
*/
void
cancelBlock
()
throws
DBException
;
void
cancelBlock
(
@NotNull
DBRProgressMonitor
monitor
,
@Nullable
Thread
blockThread
)
throws
DBException
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录