-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathclearStreamingEnv.dos
More file actions
85 lines (78 loc) · 1.88 KB
/
clearStreamingEnv.dos
File metadata and controls
85 lines (78 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/* *
* @ brief
* This script is the implementation of clearing the enviroment.
* @ Author: DolphinDB
* @ Last modification time: 2023.02.02
* @ DolphinDB server version: 2.00.8
* @ FileName: clearStreamingEnv.dos
*/
login("admin", "123456")
// define function : ClearAllSharedTables
def existsShareVariable(varName){
return objs(true).name.find(varName)>=0
}
def ClearAllSharedTables(){
sharedTables = exec name from objs(true) where form="TABLE", shared=true
for(sharedTable in sharedTables){
print("Undef Shared Table: " + sharedTable)
try{
undef(sharedTable, SHARED)
}
catch(ex){
print(ex)
}
}
print("All shared table have been cleared !")
}
// define function : ClearAllSubscriptions
def ClearAllSubscriptions(){
if(getStreamingStat().pubTables.rows() > 0){
do{
try{
tableName = getStreamingStat().pubTables[0,0]
actionName = getStreamingStat().pubTables[0,3]
actionName = strReplace(actionName,"[","")
actionName = strReplace(actionName,"]","")
arr = actionName.split(',')
}
catch(ex){
print(ex)
}
for(actionName in arr){
try{
print("unsub: " + tableName + ", " + actionName)
unsubscribeTable(tableName=tableName, actionName=actionName)
sleep(10)
}
catch(ex){
print(ex)
}
}
}
while(getStreamingStat().pubTables.rows() != 0)
}
print("All subscriptions have been cleared !")
}
// define function : DropAllEngines
def DropAllEngines(){
if(getStreamEngineStat().rows() > 0){
engineTypes = getStreamEngineStat().keys()
for(engineType in engineTypes){
engineNames = getStreamEngineStat()[engineType].name
for(name in engineNames){
print("new Drop Stream Engine: " + name)
try{
dropStreamEngine(name)
}
catch(ex){
print(ex)
}
}
}
}
print("All engines have been dropped !")
}
// clear env
ClearAllSharedTables()
ClearAllSubscriptions()
DropAllEngines()