Skip to content

Commit 4ac5aac

Browse files
committed
added an async manager panel for visualizing running tasks
1 parent a73769e commit 4ac5aac

File tree

6 files changed

+177
-1
lines changed

6 files changed

+177
-1
lines changed

ModuleConfig.cfc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ component {
112112
expanded : false,
113113
// Log the binding parameters
114114
logParams : true
115+
},
116+
// Async Manager Reporting
117+
async : {
118+
enabled : true,
119+
expanded : false
115120
}
116121
};
117122

readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ moduleSettings = {
151151
expanded : false,
152152
// Log the binding parameters
153153
logParams : true
154+
},
155+
// Async Manager Reporting
156+
async : {
157+
enabled : true,
158+
expanded : false
154159
}
155160
}
156161
}

resources/assets/sass/App.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@
294294

295295
.cbd-bg-light-red{ background-color: #f7e9e9 !important;}
296296
.cbd-bg-light-gray{ background-color: #f7f7f7; }
297+
.cbd-bg-gray{ background-color: #bcbbbb; }
297298

298299
.cbd-center { text-align:center !important; margin:auto !important; }
299300

test-harness/config/Coldbox.cfc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
includedInterceptions : [ "ORMPostLoad", "ORMPostNew" ],
9797
// Control the execution timers
9898
executionTimers : {
99-
expanded : true,
99+
expanded : false,
100100
// Slow transaction timers in milliseconds, if execution time of the timer is above it, we mark it
101101
slowTimerThreshold : 250
102102
},
@@ -142,6 +142,16 @@
142142
}
143143
}
144144
};
145+
146+
executors = {
147+
"debugger-tasks" : {
148+
"type" : "scheduled",
149+
"threads" : 5
150+
},
151+
"cachebound-tasks" : {
152+
"type" : "cached"
153+
}
154+
};
145155
}
146156

147157
/**

views/main/debugger.cfm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,24 @@ We use cfinclude to be fast and sneaky
1717
<cfinclude template="panels/modulesPanel.cfm">
1818
</cfif>
1919

20+
<!--- **************************************************************--->
21+
<!--- ASYNC PANEL --->
22+
<!--- **************************************************************--->
23+
<cfif args.debuggerConfig.async.enabled>
24+
<cfinclude template="panels/asyncPanel.cfm">
25+
</cfif>
26+
2027
<!--- **************************************************************--->
2128
<!--- CACHE PANEL --->
2229
<!--- **************************************************************--->
2330
<cfif args.debuggerConfig.cachebox.enabled>
2431
<cfinclude template="panels/cacheBoxPanel.cfm">
2532
</cfif>
2633

34+
<!--- **************************************************************--->
35+
<!--- FOOTER --->
36+
<!--- **************************************************************--->
37+
2738
<!--- Debugger Version --->
2839
<span class="mt10 mb10 cbd-floatRight">
2940
ColdBox Debugger v#getModuleConfig( "cbdebugger" ).version#

views/main/panels/asyncPanel.cfm

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
<cfscript>
2+
asyncManager = controller.getAsyncManager();
3+
executors = asyncManager.getExecutors();
4+
executorKeys = executors.keyArray();
5+
arraySort( executorKeys, "textnocase" );
6+
</cfscript>
7+
<cfoutput>
8+
<!--- Title --->
9+
<div class="cbd-titles" onClick="cbdToggle( 'cbdAsync' )">
10+
&nbsp;
11+
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
12+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" />
13+
</svg>
14+
ColdBox Async Manager
15+
</div>
16+
17+
<!--- Panel --->
18+
<div
19+
class="cbd-contentView<cfif args.debuggerConfig.async.expanded> cbd-show<cfelse> cbd-hide</cfif>"
20+
id="cbdAsync"
21+
>
22+
23+
<!--- Info Bar --->
24+
<div class="mt10 mb10">
25+
<div>
26+
<strong>Total Executors:</strong>
27+
<div class="cbd-badge-light">
28+
#executors.count()#
29+
</div>
30+
</div>
31+
</div>
32+
33+
<!--- Executor Reports --->
34+
<table border="0" align="center" cellpadding="0" cellspacing="1" class="cbd-tables">
35+
<tr>
36+
<th align="left" >Name</th>
37+
<th width="200" align="left" >Type</th>
38+
<th width="75" align="center" >Pool Size</th>
39+
<th width="75" align="center" >Core Size</th>
40+
<th width="75" align="center" >Active Tasks</th>
41+
<th width="75" align="center" >Scheduled Tasks</th>
42+
<th width="75" align="center" >Completed Tasks</th>
43+
<th width="50" align="center" >Actions</th>
44+
</tr>
45+
46+
<cfloop array="#executorKeys#" index="executorName">
47+
<cfset thisExecutor = executors[ executorName ]>
48+
<cfset stats = thisExecutor.getStats()>
49+
<tr>
50+
<td>
51+
#executorName#
52+
</td>
53+
<td>
54+
#listLast( thisExecutor.getNative().getClass().getName(), "." )#
55+
</td>
56+
<td align="center">
57+
#stats.poolSize#
58+
</td>
59+
<td align="center">
60+
#stats.corePoolSize#
61+
</td>
62+
<td align="center">
63+
#stats.activeCount#
64+
</td>
65+
<td align="center">
66+
#stats.taskCount#
67+
</td>
68+
<td align="center">
69+
#numberFormat( stats.completedTaskCount )#
70+
</td>
71+
<td align="center">
72+
<button
73+
title="View Tasks"
74+
onclick="cbdToggle( 'cbdExecutorReport-#executorName#' )"
75+
>
76+
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
77+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16l2.879-2.879m0 0a3 3 0 104.243-4.242 3 3 0 00-4.243 4.242zM21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
78+
</svg>
79+
</button>
80+
</td>
81+
</tr>
82+
83+
<!--- Task Report --->
84+
<tr class="cbd-hide cbd-bg-gray" id="cbdExecutorReport-#executorName#">
85+
<td colspan="8" class="p20">
86+
<cfset queue = thisExecutor.getQueue().toArray()>
87+
<cfif arrayLen( queue )>
88+
<table border="0" align="center" cellpadding="0" cellspacing="1" class="cbd-tables">
89+
<tr>
90+
<th align="left" >Task Id</th>
91+
<th align="left" width="75">Periodic</th>
92+
<th align="left" width="75">Delay (sec)</th>
93+
<th align="left" width="75">Done</th>
94+
<th align="left" width="75">Cancelled</th>
95+
</tr>
96+
97+
<cfloop array="#queue#" index="thisTask">
98+
<cfset isScheduledFuture = findNoCase( "ScheduledFuture", thisTask.getClass().getName() )>
99+
<tr>
100+
<td>
101+
#thisTask.hashCode()#
102+
</td>
103+
104+
<!--- Periodic? --->
105+
<td>
106+
<cfif isScheduledFuture>
107+
#yesNoFormat( thisTask.isPeriodic() )#
108+
<cfelse>
109+
<em>n/a</em>
110+
</cfif>
111+
</td>
112+
<!--- Get Delay --->
113+
<td>
114+
<cfif isScheduledFuture>
115+
#numberFormat( thisTask.getDelay( thisExecutor.$timeUnit.get( "seconds" ) ) )#
116+
<cfelse>
117+
<em>n/a</em>
118+
</cfif>
119+
</td>
120+
<!--- Done --->
121+
<td>
122+
#yesNoFormat( thisTask.isDone() )#
123+
</td>
124+
<!--- Cancelled --->
125+
<td>
126+
#yesNoFormat( thisTask.isCancelled() )#
127+
</td>
128+
</tr>
129+
</cfloop>
130+
131+
</table>
132+
<cfelse>
133+
<em class="cbd-text-red">
134+
No running tasks
135+
</em>
136+
</cfif>
137+
</td>
138+
</tr>
139+
</cfloop>
140+
141+
</table>
142+
143+
</div>
144+
</cfoutput>

0 commit comments

Comments
 (0)