Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
058941fe
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,发现更多精彩内容 >>
提交
058941fe
编写于
5月 02, 2017
作者:
K
Karl Grießer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Lock Manager
Former-commit-id:
d8229ba5
上级
d27a4644
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
793 addition
and
1 deletion
+793
-1
plugins/org.jkiss.dbeaver.ext.exasol/META-INF/MANIFEST.MF
plugins/org.jkiss.dbeaver.ext.exasol/META-INF/MANIFEST.MF
+2
-1
plugins/org.jkiss.dbeaver.ext.exasol/plugin.properties
plugins/org.jkiss.dbeaver.ext.exasol/plugin.properties
+13
-0
plugins/org.jkiss.dbeaver.ext.exasol/plugin.xml
plugins/org.jkiss.dbeaver.ext.exasol/plugin.xml
+13
-0
plugins/org.jkiss.dbeaver.ext.exasol/plugin_de.properties
plugins/org.jkiss.dbeaver.ext.exasol/plugin_de.properties
+1
-0
plugins/org.jkiss.dbeaver.ext.exasol/src/org/jkiss/dbeaver/ext/exasol/editors/ExasolLockEditor.java
...rg/jkiss/dbeaver/ext/exasol/editors/ExasolLockEditor.java
+66
-0
plugins/org.jkiss.dbeaver.ext.exasol/src/org/jkiss/dbeaver/ext/exasol/model/lock/ExasolLock.java
...c/org/jkiss/dbeaver/ext/exasol/model/lock/ExasolLock.java
+172
-0
plugins/org.jkiss.dbeaver.ext.exasol/src/org/jkiss/dbeaver/ext/exasol/model/lock/ExasolLockItem.java
...g/jkiss/dbeaver/ext/exasol/model/lock/ExasolLockItem.java
+182
-0
plugins/org.jkiss.dbeaver.ext.exasol/src/org/jkiss/dbeaver/ext/exasol/model/lock/ExasolLockManager.java
...kiss/dbeaver/ext/exasol/model/lock/ExasolLockManager.java
+344
-0
未找到文件。
plugins/org.jkiss.dbeaver.ext.exasol/META-INF/MANIFEST.MF
浏览文件 @
058941fe
...
...
@@ -13,7 +13,8 @@ Require-Bundle: org.eclipse.ui,
org.jkiss.dbeaver.model,
org.jkiss.dbeaver.core,
org.eclipse.ui.workbench.texteditor,
org.eclipse.ui.editors
org.eclipse.ui.editors,
org.jkiss.dbeaver.ext.ui.locks
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-Vendor: JKISS
...
...
plugins/org.jkiss.dbeaver.ext.exasol/plugin.properties
浏览文件 @
058941fe
...
...
@@ -150,6 +150,18 @@ meta.org.jkiss.dbeaver.ext.exasol.model.plan.ExasolPlanNode.partInfo.name
meta.org.jkiss.dbeaver.ext.exasol.model.plan.ExasolPlanNode.partName.name
=
Part Name
meta.org.jkiss.dbeaver.ext.exasol.model.plan.ExasolPlanNode.stmtId.name
=
Statement Id
meta.org.jkiss.dbeaver.ext.exasol.model.plan.ExasolPlanNode.tempDbRamPeak.name
=
Temp DB Ram Peak MB
meta.org.jkiss.dbeaver.ext.exasol.model.lock.ExasolLock.status.name
=
Status
meta.org.jkiss.dbeaver.ext.exasol.model.lock.ExasolLock.hold_sid.name
=
Hold Session ID
meta.org.jkiss.dbeaver.ext.exasol.model.lock.ExasolLock.wait_user.name
=
Wait User
meta.org.jkiss.dbeaver.ext.exasol.model.lock.ExasolLock.oname.name
=
Wait OS
meta.org.jkiss.dbeaver.ext.exasol.model.lock.ExasolLock.wait_command.name
=
Wait Command
meta.org.jkiss.dbeaver.ext.exasol.model.lock.ExasolLock.wait_client.name
=
Wait Client
meta.org.jkiss.dbeaver.ext.exasol.model.lock.ExasolLock.hold_user.name
=
Hold User
meta.org.jkiss.dbeaver.ext.exasol.model.lock.ExasolLock.hold_client.name
=
Hold Client
meta.org.jkiss.dbeaver.ext.exasol.model.lock.ExasolLock.wait_sid.name
=
Wait Session ID
meta.org.jkiss.dbeaver.ext.exasol.model.lock.ExasolLock.wait_osuser.name
=
Wait OS User
meta.org.jkiss.dbeaver.ext.exasol.model.lock.ExasolLock.ltime.name
=
Login Time
tool.org.jkiss.dbeaver.ext.exasol.database.reorg.name
=
Reorganize Database...
tool.org.jkiss.dbeaver.ext.exasol.table.export.name
=
Export Table(s)
...
...
@@ -210,3 +222,4 @@ tree.viewsauths.node.name = Views Privileges
tree.virtualschema.node.name
=
Virtual Schema
tree.virtualschemaparameters.node.name
=
Virtual Schema Parameters
tree.virtualschemas.node.name
=
Virtual Schemas
tree.locks.node.name
=
Lock Manager
\ No newline at end of file
plugins/org.jkiss.dbeaver.ext.exasol/plugin.xml
浏览文件 @
058941fe
...
...
@@ -165,6 +165,13 @@
description=
"Server Session manager"
editor=
"org.jkiss.dbeaver.ext.exasol.model.app.ExasolServerSessionEditor"
/>
<object
description=
"Server locks manager"
editor=
"org.jkiss.dbeaver.ext.exasol.editors.ExasolLockEditor"
icon=
"#locks"
label=
"%tree.locks.node.name"
type=
"org.jkiss.dbeaver.ext.exasol.editors.ExasolLockEditor"
>
</object>
</folder>
<folder
description=
"Connections"
...
...
@@ -437,6 +444,12 @@
class=
"org.jkiss.dbeaver.ext.exasol.model.app.ExasolServerSessionEditor"
id=
"org.jkiss.dbeaver.ext.exasol.model.app.ExasolServerSessionEditor"
>
</editor>
<editor
name=
"Lock Manager"
class=
"org.jkiss.dbeaver.ext.exasol.editors.ExasolLockEditor"
id=
"org.jkiss.dbeaver.ext.exasol.editors.ExasolLockEditor"
>
</editor>
</extension>
<extension
point=
"org.jkiss.dbeaver.tools"
>
<tools>
...
...
plugins/org.jkiss.dbeaver.ext.exasol/plugin_de.properties
浏览文件 @
058941fe
...
...
@@ -206,3 +206,4 @@ tree.viewsauths.node.name = View Berechtigungen
tree.virtualschema.node.name
=
Virtuelles Schema
tree.virtualschemaparameters.node.name
=
Virtuelles Schema - Parameter
tree.virtualschemas.node.name
=
Virtuelle Schemata
tree.locks.node.name
=
Lock Manager
\ No newline at end of file
plugins/org.jkiss.dbeaver.ext.exasol/src/org/jkiss/dbeaver/ext/exasol/editors/ExasolLockEditor.java
0 → 100644
浏览文件 @
058941fe
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2017 Andrew Khitrin (ahitrin@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.jkiss.dbeaver.ext.exasol.editors
;
import
java.math.BigInteger
;
import
java.util.HashMap
;
import
org.eclipse.jface.action.IContributionManager
;
import
org.eclipse.jface.action.Separator
;
import
org.eclipse.swt.widgets.Composite
;
import
org.jkiss.dbeaver.ext.exasol.model.ExasolDataSource
;
import
org.jkiss.dbeaver.ext.exasol.model.lock.ExasolLock
;
import
org.jkiss.dbeaver.ext.exasol.model.lock.ExasolLockManager
;
import
org.jkiss.dbeaver.ext.ui.locks.edit.AbstractLockEditor
;
import
org.jkiss.dbeaver.ext.ui.locks.manage.LockManagerViewer
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContext
;
import
org.jkiss.dbeaver.model.admin.locks.DBAServerLock
;
import
org.jkiss.dbeaver.model.admin.locks.DBAServerLockItem
;
import
org.jkiss.dbeaver.model.admin.locks.DBAServerLockManager
;
public
class
ExasolLockEditor
extends
AbstractLockEditor
{
public
static
final
String
sidHold
=
"hsid"
;
public
static
final
String
sidWait
=
"wsid"
;
@Override
protected
LockManagerViewer
createLockViewer
(
DBCExecutionContext
executionContext
,
Composite
parent
)
{
DBAServerLockManager
<
DBAServerLock
<?>,
DBAServerLockItem
>
lockManager
=
(
DBAServerLockManager
)
new
ExasolLockManager
((
ExasolDataSource
)
executionContext
.
getDataSource
());
return
new
LockManagerViewer
(
this
,
parent
,
lockManager
)
{
@Override
protected
void
contributeToToolbar
(
DBAServerLockManager
<
DBAServerLock
<?>,
DBAServerLockItem
>
sessionManager
,
IContributionManager
contributionManager
)
{
contributionManager
.
add
(
new
Separator
());
}
@Override
protected
void
onLockSelect
(
final
DBAServerLock
<?>
lock
)
{
super
.
onLockSelect
(
lock
);
if
(
lock
!=
null
)
{
final
ExasolLock
pLock
=
(
ExasolLock
)
lock
;
super
.
refreshDetail
(
new
HashMap
<
String
,
Object
>()
{{
put
(
sidHold
,
BigInteger
.
valueOf
(
pLock
.
getHold_sid
()));
put
(
sidWait
,
BigInteger
.
valueOf
(
pLock
.
getWait_sid
().
longValue
()));
}});
}
}
};
}
}
plugins/org.jkiss.dbeaver.ext.exasol/src/org/jkiss/dbeaver/ext/exasol/model/lock/ExasolLock.java
0 → 100644
浏览文件 @
058941fe
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2016-2016 Karl Griesser (fullref@gmail.com)
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.jkiss.dbeaver.ext.exasol.model.lock
;
import
java.math.BigInteger
;
import
java.sql.ResultSet
;
import
java.sql.Timestamp
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.jkiss.dbeaver.model.admin.locks.DBAServerLock
;
import
org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils
;
import
org.jkiss.dbeaver.model.meta.Property
;
public
class
ExasolLock
implements
DBAServerLock
<
BigInteger
>
{
private
long
waitSessionId
;
private
String
waitUserName
;
private
String
waitCommandName
;
private
String
waitOsUser
;
private
String
waitClient
;
private
long
holdSessionId
;
private
String
holdClient
;
private
String
holdUserName
;
private
String
oname
;
private
String
status
;
private
Timestamp
waitLoginTime
;
DBAServerLock
<
BigInteger
>
hold
=
null
;
List
<
DBAServerLock
<
BigInteger
>>
waiters
=
new
ArrayList
<>(
0
);
public
ExasolLock
(
ResultSet
dbResult
)
{
this
.
waitSessionId
=
JDBCUtils
.
safeGetLong
(
dbResult
,
"W_SESSION_ID"
);
this
.
waitUserName
=
JDBCUtils
.
safeGetString
(
dbResult
,
"W_USER_NAME"
);
this
.
waitCommandName
=
JDBCUtils
.
safeGetString
(
dbResult
,
"W_COMMAND_NAME"
);
this
.
waitOsUser
=
JDBCUtils
.
safeGetString
(
dbResult
,
"W_OS_USER"
);
this
.
waitClient
=
JDBCUtils
.
safeGetString
(
dbResult
,
"W_CLIENT"
);
this
.
holdSessionId
=
JDBCUtils
.
safeGetLong
(
dbResult
,
"H_SESSION_ID"
);
this
.
holdClient
=
JDBCUtils
.
safeGetString
(
dbResult
,
"H_CLIENT"
);
this
.
oname
=
JDBCUtils
.
safeGetString
(
dbResult
,
"ONAME"
);
this
.
holdUserName
=
JDBCUtils
.
safeGetString
(
dbResult
,
"H_USER_NAME"
);
this
.
status
=
JDBCUtils
.
safeGetString
(
dbResult
,
"H_STATUS"
);
this
.
waitLoginTime
=
JDBCUtils
.
safeGetTimestamp
(
dbResult
,
"W_LOGIN_TIME"
);
}
@Override
public
String
getTitle
()
{
return
String
.
valueOf
(
waitSessionId
);
}
@Override
public
DBAServerLock
<
BigInteger
>
getHoldBy
()
{
return
hold
;
}
public
DBAServerLock
<
BigInteger
>
getHold
()
{
return
hold
;
}
@Override
public
BigInteger
getId
()
{
return
BigInteger
.
valueOf
(
waitSessionId
);
}
@Override
public
List
<
DBAServerLock
<
BigInteger
>>
waitThis
()
{
return
this
.
waiters
;
}
@Override
public
BigInteger
getHoldID
()
{
return
BigInteger
.
valueOf
(
holdSessionId
);
}
@SuppressWarnings
(
"unchecked"
)
@Override
public
void
setHoldBy
(
DBAServerLock
<?>
lock
)
{
this
.
hold
=
(
DBAServerLock
<
BigInteger
>)
lock
;
}
@Override
public
String
toString
()
{
return
String
.
format
(
"Wait %s - %d (%s) Hold - %d (%s)"
,
oname
,
waitSessionId
,
waitUserName
,
holdSessionId
,
holdUserName
);
}
@Property
(
viewable
=
true
,
order
=
1
)
public
BigInteger
getWait_sid
()
{
return
BigInteger
.
valueOf
(
waitSessionId
);
}
@Property
(
viewable
=
true
,
order
=
2
)
public
String
getWait_osuser
()
{
return
waitOsUser
;
}
@Property
(
viewable
=
true
,
order
=
3
)
public
String
getWait_user
()
{
return
waitUserName
;
}
@Property
(
viewable
=
true
,
order
=
4
)
public
String
getOname
()
{
return
oname
;
}
@Property
(
viewable
=
true
,
order
=
5
)
public
String
getWait_command
()
{
return
waitCommandName
;
}
@Property
(
viewable
=
true
,
order
=
6
)
public
String
getWait_client
()
{
return
waitClient
;
}
@Property
(
viewable
=
true
,
order
=
7
)
public
long
getHold_sid
()
{
return
holdSessionId
;
}
@Property
(
viewable
=
true
,
order
=
9
)
public
String
getHold_user
()
{
return
holdUserName
;
}
@Property
(
viewable
=
true
,
order
=
10
)
public
Timestamp
getLtime
()
{
return
waitLoginTime
;
}
@Property
(
viewable
=
true
,
order
=
11
)
public
String
getStatus
()
{
return
status
;
}
@Property
(
viewable
=
true
,
order
=
12
)
public
String
getHold_client
()
{
return
this
.
holdClient
;
}
}
plugins/org.jkiss.dbeaver.ext.exasol/src/org/jkiss/dbeaver/ext/exasol/model/lock/ExasolLockItem.java
0 → 100644
浏览文件 @
058941fe
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2016-2016 Karl Griesser (fullref@gmail.com)
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.jkiss.dbeaver.ext.exasol.model.lock
;
import
java.sql.ResultSet
;
import
java.sql.Timestamp
;
import
org.jkiss.dbeaver.model.admin.locks.DBAServerLockItem
;
import
org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils
;
import
org.jkiss.dbeaver.model.meta.Property
;
public
class
ExasolLockItem
implements
DBAServerLockItem
{
private
String
sqlText
;
private
String
userName
;
private
String
host
;
private
String
osUser
;
private
String
osName
;
private
String
scopeSchema
;
private
String
status
;
private
String
client
;
private
Integer
resources
;
private
String
priority
;
private
Timestamp
loginTime
;
private
String
driver
;
private
String
activity
;
private
String
commandName
;
private
String
evaluation
;
private
String
lockType
;
@Property
(
viewable
=
true
,
order
=
10
)
public
String
getLockType
()
{
return
lockType
;
}
ExasolLockItem
(
ResultSet
dbResult
)
{
this
.
sqlText
=
JDBCUtils
.
safeGetString
(
dbResult
,
"SQL_TEXT"
);
this
.
userName
=
JDBCUtils
.
safeGetString
(
dbResult
,
"USER_NAME"
);
this
.
host
=
JDBCUtils
.
safeGetString
(
dbResult
,
"HOST"
);
this
.
osUser
=
JDBCUtils
.
safeGetString
(
dbResult
,
"OS_USER"
);
this
.
scopeSchema
=
JDBCUtils
.
safeGetString
(
dbResult
,
"SCOPE_SCHEMA"
);
this
.
status
=
JDBCUtils
.
safeGetString
(
dbResult
,
"STATUS"
);
this
.
client
=
JDBCUtils
.
safeGetString
(
dbResult
,
"CLIENT"
);
this
.
resources
=
JDBCUtils
.
safeGetInteger
(
dbResult
,
"RESOURCES"
);
this
.
priority
=
JDBCUtils
.
safeGetString
(
dbResult
,
"PRIORITY"
);
this
.
loginTime
=
JDBCUtils
.
safeGetTimestamp
(
dbResult
,
"LOGIN_TIME"
);
this
.
driver
=
JDBCUtils
.
safeGetString
(
dbResult
,
"DRIVER"
);
this
.
activity
=
JDBCUtils
.
safeGetString
(
dbResult
,
"ACTIVITY"
);
this
.
evaluation
=
JDBCUtils
.
safeGetString
(
dbResult
,
"EVALUATION"
);
this
.
lockType
=
JDBCUtils
.
safeGetString
(
dbResult
,
"HAS_LOCKS"
);
}
@Property
(
viewable
=
true
,
order
=
150
)
public
String
getSqlText
()
{
return
sqlText
;
}
@Property
(
viewable
=
true
,
order
=
20
)
public
String
getUserName
()
{
return
userName
;
}
@Property
(
viewable
=
true
,
order
=
140
)
public
String
getHost
()
{
return
host
;
}
@Property
(
viewable
=
true
,
order
=
30
)
public
String
getOsUser
()
{
return
osUser
;
}
@Property
(
viewable
=
true
,
order
=
130
)
public
String
getOsName
()
{
return
osName
;
}
@Property
(
viewable
=
true
,
order
=
120
)
public
String
getScopeSchema
()
{
return
scopeSchema
;
}
@Property
(
viewable
=
true
,
order
=
40
)
public
String
getStatus
()
{
return
status
;
}
@Property
(
viewable
=
true
,
order
=
50
)
public
String
getClient
()
{
return
client
;
}
@Property
(
viewable
=
true
,
order
=
110
)
public
Integer
getResources
()
{
return
resources
;
}
@Property
(
viewable
=
true
,
order
=
100
)
public
String
getPriority
()
{
return
priority
;
}
@Property
(
viewable
=
true
,
order
=
60
)
public
Timestamp
getLoginTime
()
{
return
loginTime
;
}
public
String
getDriver
()
{
return
driver
;
}
@Property
(
viewable
=
true
,
order
=
90
)
public
String
getActivity
()
{
return
activity
;
}
@Property
(
viewable
=
true
,
order
=
70
)
public
String
getCommandName
()
{
return
commandName
;
}
@Property
(
viewable
=
true
,
order
=
80
)
public
String
getEvaluation
()
{
return
evaluation
;
}
public
Timestamp
ltime
()
{
return
this
.
loginTime
;
}
}
plugins/org.jkiss.dbeaver.ext.exasol/src/org/jkiss/dbeaver/ext/exasol/model/lock/ExasolLockManager.java
0 → 100644
浏览文件 @
058941fe
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2016-2016 Karl Griesser (fullref@gmail.com)
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.jkiss.dbeaver.ext.exasol.model.lock
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.ext.exasol.editors.ExasolLockEditor
;
import
org.jkiss.dbeaver.ext.exasol.model.ExasolDataSource
;
import
org.jkiss.dbeaver.ext.ui.locks.manage.LockGraphManager
;
import
org.jkiss.dbeaver.ext.ui.locks.manage.LockManagerViewer
;
import
org.jkiss.dbeaver.model.DBPDataSource
;
import
org.jkiss.dbeaver.model.admin.locks.DBAServerLockManager
;
import
org.jkiss.dbeaver.model.exec.DBCSession
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCSession
;
public
class
ExasolLockManager
extends
LockGraphManager
<
ExasolLock
,
BigInteger
>
implements
DBAServerLockManager
<
ExasolLock
,
ExasolLockItem
>
{
public
static
final
String
LOCK_QUERY
=
"WITH LOCKED AS (\r\n"
+
"SELECT \r\n"
+
"w.SESSION_ID AS w_session_id,w.login_time as w_login_time,\r\n"
+
"w.user_name AS w_user_name,\r\n"
+
"w.command_name AS w_command_name,\r\n"
+
"w.os_user AS w_os_user,\r\n"
+
"w.client AS w_client,\r\n"
+
"'-' AS oname,\r\n"
+
"h.session_id as h_session_id, h.CLIENT AS h_CLIENT,\r\n"
+
"h.USER_NAME AS H_USER_NAME, h.status as h_status\r\n"
+
"FROM SYS.EXA_DBA_SESSIONS w\r\n"
+
"INNER JOIN SYS.EXA_DBA_SESSIONS h\r\n"
+
"ON CASE\r\n"
+
" WHEN w.ACTIVITY LIKE 'Waiting for %' THEN CAST(\r\n"
+
" REPLACE(\r\n"
+
" w.ACTIVITY,\r\n"
+
" 'Waiting for session ',\r\n"
+
" ''\r\n"
+
" ) AS DECIMAL(\r\n"
+
" 20,\r\n"
+
" 0\r\n"
+
" )\r\n"
+
" )\r\n"
+
" ELSE NULL\r\n"
+
" END = h.SESSION_ID\r\n"
+
") \r\n"
+
"SELECT * FROM locked\r\n"
+
"UNION ALL\r\n"
+
"SELECT\r\n"
+
"w.SESSION_ID AS w_session_id,w.login_time as w_login_time,\r\n"
+
"w.user_name AS w_user_name,\r\n"
+
"w.command_name AS w_command_name,\r\n"
+
"w.os_user AS w_os_user,\r\n"
+
"w.client AS w_client,\r\n"
+
"'-' AS oname,\r\n"
+
"w.session_id as h_session_id, h.CLIENT AS h_CLIENT,\r\n"
+
"h.USER_NAME AS H_USER_NAME, h.status as h_status\r\n"
+
"FROM SYS.EXA_DBA_SESSIONS w \r\n"
+
"LEFT OUTER JOIN SYS.EXA_DBA_SESSIONS h\r\n"
+
"ON CASE\r\n"
+
" WHEN w.ACTIVITY LIKE 'Waiting for %' THEN CAST(\r\n"
+
" REPLACE(\r\n"
+
" w.ACTIVITY,\r\n"
+
" 'Waiting for session ',\r\n"
+
" ''\r\n"
+
" ) AS DECIMAL(\r\n"
+
" 20,\r\n"
+
" 0\r\n"
+
" )\r\n"
+
" )\r\n"
+
" ELSE NULL\r\n"
+
" END = h.SESSION_ID\r\n"
+
"WHERE w.SESSION_ID IN (SELECT h_session_id FROM locked)"
;
public
static
final
String
LOCK_ITEM_QUERY
=
"with\r\n"
+
" EXA_SQL as (\r\n"
+
" select\r\n"
+
" SESSION_ID,\r\n"
+
" STMT_ID,\r\n"
+
" COMMAND_CLASS,\r\n"
+
" COMMAND_NAME,\r\n"
+
" SUCCESS\r\n"
+
" from\r\n"
+
" --EXA_DBA_AUDIT_SQL -- delivers more exact results (if available)\r\n"
+
" EXA_SQL_LAST_DAY\r\n"
+
" where\r\n"
+
" SESSION_ID in (select SESSION_ID from EXA_DBA_SESSIONS)\r\n"
+
" ),\r\n"
+
" SESSION_RISKS as (\r\n"
+
" select\r\n"
+
" SESSION_ID,\r\n"
+
" HAS_LOCKS\r\n"
+
" from\r\n"
+
" (\r\n"
+
" select\r\n"
+
" SESSION_ID,\r\n"
+
" decode(\r\n"
+
" greatest(CURRENT_ACCESS, LAST_ACCESS),\r\n"
+
" 0,\r\n"
+
" 'NONE',\r\n"
+
" 1,\r\n"
+
" 'READ LOCKS',\r\n"
+
" 2,\r\n"
+
" 'WRITE LOCKS'\r\n"
+
" ) HAS_LOCKS\r\n"
+
" from\r\n"
+
" (\r\n"
+
" select\r\n"
+
" S.SESSION_ID,\r\n"
+
" case\r\n"
+
" when\r\n"
+
" (S.STATUS not in ('IDLE', 'DISCONNECTED')) OR\r\n"
+
" (\r\n"
+
" S.COMMAND_NAME not in ('COMMIT', 'ROLLBACK', 'NOT SPECIFIED')\r\n"
+
" )\r\n"
+
" then\r\n"
+
" case\r\n"
+
" when\r\n"
+
" S.COMMAND_NAME in (\r\n"
+
" 'SELECT', 'DESCRIBE', 'OPEN SCHEMA', 'CLOSE SCHEMA', 'FLUSH STATISTICS', 'EXECUTE SCRIPT'\r\n"
+
" )\r\n"
+
" then\r\n"
+
" 1\r\n"
+
" else\r\n"
+
" 2\r\n"
+
" end\r\n"
+
" else\r\n"
+
" 0\r\n"
+
" end CURRENT_ACCESS,\r\n"
+
" zeroifnull(A.ACCESS) LAST_ACCESS\r\n"
+
" from\r\n"
+
" EXA_DBA_SESSIONS S\r\n"
+
" left join\r\n"
+
" (\r\n"
+
" select\r\n"
+
" SESSION_ID,\r\n"
+
" max(ACCESS) ACCESS\r\n"
+
" FROM\r\n"
+
" (\r\n"
+
" select\r\n"
+
" SESSION_ID,\r\n"
+
" case\r\n"
+
" when\r\n"
+
" (\r\n"
+
" COMMAND_NAME not in ('COMMIT', 'ROLLBACK', 'NOT SPECIFIED')\r\n"
+
" )\r\n"
+
" then\r\n"
+
" case\r\n"
+
" when\r\n"
+
" COMMAND_NAME in (\r\n"
+
" 'SELECT',\r\n"
+
" 'DESCRIBE',\r\n"
+
" 'OPEN SCHEMA',\r\n"
+
" 'CLOSE SCHEMA',\r\n"
+
" 'FLUSH STATISTICS',\r\n"
+
" 'EXECUTE SCRIPT'\r\n"
+
" )\r\n"
+
" then\r\n"
+
" 1\r\n"
+
" else\r\n"
+
" 2\r\n"
+
" end\r\n"
+
" else\r\n"
+
" 0\r\n"
+
" end ACCESS\r\n"
+
" from\r\n"
+
" EXA_SQL C\r\n"
+
" where\r\n"
+
" C.COMMAND_CLASS <> 'TRANSACTION' and\r\n"
+
" SUCCESS and\r\n"
+
" not exists(\r\n"
+
" select\r\n"
+
" *\r\n"
+
" from\r\n"
+
" EXA_SQL E\r\n"
+
" where\r\n"
+
" E.SESSION_ID = C.SESSION_ID and\r\n"
+
" E.STMT_ID > C.STMT_ID and\r\n"
+
" E.COMMAND_CLASS = 'TRANSACTION'\r\n"
+
" )\r\n"
+
" )\r\n"
+
" group by\r\n"
+
" SESSION_ID\r\n"
+
" ) A\r\n"
+
" on\r\n"
+
" S.SESSION_ID = A.SESSION_ID\r\n"
+
" )\r\n"
+
" where\r\n"
+
" SESSION_ID <> 4\r\n"
+
" )\r\n"
+
" )\r\n"
+
"select\r\n"
+
" HAS_LOCKS,\r\n"
+
" case\r\n"
+
" when\r\n"
+
" DURATION > '1:00:00' and\r\n"
+
" STATUS = 'IDLE'\r\n"
+
" then\r\n"
+
" decode(\r\n"
+
" HAS_LOCKS,\r\n"
+
" 'READ LOCKS',\r\n"
+
" 'CRITICAL',\r\n"
+
" 'WRITE LOCKS',\r\n"
+
" 'VERY CRITICAL',\r\n"
+
" NULL\r\n"
+
" )\r\n"
+
" end EVALUATION,\r\n"
+
" S.*\r\n"
+
"from\r\n"
+
" EXA_DBA_SESSIONS S\r\n"
+
" left join\r\n"
+
" SESSION_RISKS R\r\n"
+
" on\r\n"
+
" (S.SESSION_ID = R.SESSION_ID) WHERE S.SESSION_ID = ?\r\n"
+
"order by\r\n"
+
" EVALUATION desc,\r\n"
+
" LOGIN_TIME;\r\n"
+
""
;
private
final
ExasolDataSource
dataSource
;
public
ExasolLockManager
(
ExasolDataSource
dataSource
)
{
this
.
dataSource
=
dataSource
;
}
@Override
public
DBPDataSource
getDataSource
()
{
return
this
.
dataSource
;
}
@Override
public
Map
<
BigInteger
,
ExasolLock
>
getLocks
(
DBCSession
session
,
Map
<
String
,
Object
>
options
)
throws
DBException
{
try
{
Map
<
BigInteger
,
ExasolLock
>
locks
=
new
HashMap
<
BigInteger
,
ExasolLock
>(
10
);
try
(
JDBCPreparedStatement
dbStat
=
((
JDBCSession
)
session
).
prepareStatement
(
LOCK_QUERY
))
{
try
(
JDBCResultSet
dbResult
=
dbStat
.
executeQuery
())
{
while
(
dbResult
.
next
())
{
ExasolLock
l
=
new
ExasolLock
(
dbResult
);
locks
.
put
(
l
.
getId
(),
l
);
}
}
}
super
.
buildGraphs
(
locks
);
return
locks
;
}
catch
(
SQLException
e
)
{
throw
new
DBException
(
e
,
session
.
getDataSource
());
}
}
@Override
public
Collection
<
ExasolLockItem
>
getLockItems
(
DBCSession
session
,
Map
<
String
,
Object
>
options
)
throws
DBException
{
try
{
List
<
ExasolLockItem
>
locks
=
new
ArrayList
<>();
try
(
JDBCPreparedStatement
dbStat
=
((
JDBCSession
)
session
).
prepareStatement
(
LOCK_ITEM_QUERY
))
{
String
otype
=
(
String
)
options
.
get
(
LockManagerViewer
.
keyType
);
switch
(
otype
)
{
case
LockManagerViewer
.
typeWait
:
dbStat
.
setBigDecimal
(
1
,
new
BigDecimal
((
BigInteger
)
options
.
get
(
ExasolLockEditor
.
sidWait
)));
break
;
case
LockManagerViewer
.
typeHold
:
dbStat
.
setBigDecimal
(
1
,
new
BigDecimal
((
BigInteger
)
options
.
get
(
ExasolLockEditor
.
sidHold
)));
break
;
default
:
return
locks
;
}
try
(
JDBCResultSet
dbResult
=
dbStat
.
executeQuery
())
{
while
(
dbResult
.
next
())
{
locks
.
add
(
new
ExasolLockItem
(
dbResult
));
}
}
}
return
locks
;
}
catch
(
SQLException
e
)
{
throw
new
DBException
(
e
,
session
.
getDataSource
());
}
}
@Override
public
void
alterSession
(
DBCSession
session
,
ExasolLock
lock
,
Map
<
String
,
Object
>
options
)
throws
DBException
{
try
{
StringBuilder
sql
=
new
StringBuilder
(
"KILL SESSION "
);
sql
.
append
(
lock
.
getHold_sid
());
try
(
JDBCPreparedStatement
dbStat
=
((
JDBCSession
)
session
).
prepareStatement
(
sql
.
toString
()))
{
dbStat
.
execute
();
}
}
catch
(
SQLException
e
)
{
throw
new
DBException
(
e
,
session
.
getDataSource
());
}
}
@Override
public
Class
<
ExasolLock
>
getLocksType
()
{
return
ExasolLock
.
class
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录