[prev in list] [next in list] [prev in thread] [next in thread]
List: asterisk-dev
Subject: Re: [asterisk-dev] [Code Review] 464: Group Variables
From: "kobaz" <reviewboard () asterisk ! org>
Date: 2013-08-30 20:23:25
Message-ID: 20130830202325.1026.80468 () hotblack ! digium ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/464/#review9582
-----------------------------------------------------------
Since reviewboard lost my 300 word text after uploading a new diff here it is \
again...
Updated CHANGES to reflect new functionality added
Through testing and development I've noticed a bit of a problem with the \
implementation of GROUP_COUNT and GROUP_MATCH_COUNT
Say you have the following dialplan:
Set(GROUP()=foo);
Set(GROUP()=foo@bar);
Set(GROUP()=foo@baz);
DumpGroups();
NoOp(---GROUP_COUNT---);
NoOp(foo: ${GROUP_COUNT(foo)});
NoOp(foo@: ${GROUP_COUNT(foo@)});
NoOp(@bar: ${GROUP_COUNT(.*@bar)});
NoOp(@baz: ${GROUP_COUNT(.*@baz)});
NoOp(foo@bar: ${GROUP_COUNT(foo)});
NoOp(foo@baz: ${GROUP_COUNT(foo)});
When executed you get:
-- Executing [44@cos_internal+local+ld:1] Set("SIP/6255-00000000", \
"__DialedNumber=44") in new stack
-- Executing [44@cos_internal+local+ld:2] Goto("SIP/6255-00000000", \
"_cos_internal+local+ld,44,1") in new stack
-- Goto (_cos_internal+local+ld,44,1)
-- Executing [44@_cos_internal+local+ld:1] Set("SIP/6255-00000000", \
"GROUP()=foo") in new stack
-- Executing [44@_cos_internal+local+ld:2] Set("SIP/6255-00000000", \
"GROUP()=foo@bar") in new stack
-- Executing [44@_cos_internal+local+ld:3] Set("SIP/6255-00000000", \
"GROUP()=foo@baz") in new stack
-- Executing [44@_cos_internal+local+ld:4] DumpGroups("SIP/6255-00000000", "") in \
new stack ================================================================================
Channel Group Category
SIP/6255-00000000 foo (default)
SIP/6255-00000000 foo bar
SIP/6255-00000000 foo baz
3 active channels in groups
-----------------------------------
Group Variables Category
foo (default)
foo bar
foo baz
================================================================================
-- Executing [44@_cos_internal+local+ld:6] NoOp("SIP/6255-00000000", \
"---GROUP_COUNT---") in new stack
-- Executing [44@_cos_internal+local+ld:5] NoOp("SIP/6255-00000000", "foo: 3") in \
new stack
-- Executing [44@_cos_internal+local+ld:7] NoOp("SIP/6255-00000000", "foo@: 3") \
in new stack
-- Executing [44@_cos_internal+local+ld:8] NoOp("SIP/6255-00000000", "@bar: 0") \
in new stack
-- Executing [44@_cos_internal+local+ld:9] NoOp("SIP/6255-00000000", "@baz: 0") \
in new stack
-- Executing [44@_cos_internal+local+ld:10] NoOp("SIP/6255-00000000", "foo@bar: \
3") in new stack
-- Executing [44@_cos_internal+local+ld:11] NoOp("SIP/6255-00000000", "foo@baz: \
3") in new stack
The count returned is 3 !!!
To me this is clearly a bug, especially with the counts of foo@bar and foo@baz, which \
should be 1
There's a new function I added: GROUP_CHANNELS_MATCH_COUNT() which correctly counts \
channels in groups, versus occurrences of groups.
-- Executing [44@_cos_internal+local+ld:27] NoOp("SIP/6255-00000000", \
"---GROUP_CHANNELS_MATCH_COUNT---") in new stack
-- Executing [44@_cos_internal+local+ld:28] NoOp("SIP/6255-00000000", "foo: 1") \
in new stack
-- Executing [44@_cos_internal+local+ld:29] NoOp("SIP/6255-00000000", "foo@: 1") \
in new stack
-- Executing [44@_cos_internal+local+ld:30] NoOp("SIP/6255-00000000", "@bar: 1") \
in new stack
-- Executing [44@_cos_internal+local+ld:31] NoOp("SIP/6255-00000000", "@baz: 1") \
in new stack
-- Executing [44@_cos_internal+local+ld:32] NoOp("SIP/6255-00000000", "foo@bar: \
1") in new stack
-- Executing [44@_cos_internal+local+ld:33] NoOp("SIP/6255-00000000", "foo@baz: \
1") in new stack
-- Executing [44@_cos_internal+local+ld:34] NoOp("SIP/6255-00000000", "something: \
0") in new stack
-- Executing [44@_cos_internal+local+ld:35] NoOp("SIP/6255-00000000", \
"something@: 0") in new stack
-- Executing [44@_cos_internal+local+ld:36] NoOp("SIP/6255-00000000", \
"something@nothing: 0") in new stack
-- Executing [44@_cos_internal+local+ld:37] NoOp("SIP/6255-00000000", "@nothing: \
0") in new stack
I think the code behind GROUP_CHANNELS_MATCH_COUNT should replace GROUP_COUNT, \
especially because of the instructions from sip.conf which read: For call-limit:
; There is no combined call counter for a "friend"
; so there's currently no way in sip.conf to limit
; to one inbound or outbound call per phone. Use
; the group counters in the dial plan for that.
Case in point: If an asterisk user who does not understand the quirky internals of \
GROUP_COUNT wishes to use it to nail down strict capacity limits, they are in for \
some confusion if they are using group categories and the current GROUP_COUNT().
- kobaz
On Aug. 30, 2013, 8:10 p.m., kobaz wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/464/
> -----------------------------------------------------------
>
> (Updated Aug. 30, 2013, 8:10 p.m.)
>
>
> Review request for Asterisk Developers.
>
>
> Bugs: 16614
> https://issues.asterisk.org/jira/browse/16614
>
>
> Repository: Asterisk
>
>
> Description
> -------
>
> This patch allows for setting variables on a group of channels.
> First a channel is assigned a group via dialplan GROUP() or GroupSet via the ami \
> (new command) Then, variables can be set on that group with the GROUP_VAR() \
> dialplan function, or GroupVarSet in the manager
> This patch also adds manager events for channel group changes, and variable updates
>
> When a group is no longer used (all channels referencing the group are hung up, or \
> all channels referencing the group have their group changed/unset), variables are \
> destroyed
> new manager commands:
> GroupSet - adds functionality to the manager to be able to set a GROUP() on a \
> channel. GroupsShowChannels - show each channel and it's associated groups (a \
> channel will be repeated for each group@category it's a member of) \
> GroupsShowVariables - show variables in each group@category, one event per group, \
> all variables are contained in each group@category event GroupVarSet - set a group \
> variable (the group has to exist) GroupVarGet - get a group variable
>
> new manager events:
> GroupCreate
> GroupChannelAdd
> GroupChannelRemove
> GroupDestroy
> GroupVarSet
>
> Example AMI:
> Action: GroupVarSet
> Group: 1000
> Category: ConferenceBridge
> Variable: LastUpdateCheck
> Value: 1263502512
>
> Example CLI:
> demo1*CLI> group show variables
> Group Variables Category
> 1000 ConferenceBridge
> LastUpdateCheck=1263502512
> 1000 ConferenceModerator
> 2 active groups
>
>
> Adds support for:
> Group variables
> dialplan access: GROUP_VAR()
> cli access: group show variables
> manager access: GroupVarSet GroupVarGet
> Group information:
> manager access: GroupSet GroupsShow GroupsShowChannels GroupsShowVariables
>
>
>
> Diffs
> -----
>
> trunk/main/cli.c 397746
> trunk/main/app.c 397746
> trunk/include/asterisk/channel.h 397746
> trunk/include/asterisk/app.h 397746
> trunk/funcs/func_groupcount.c 397746
> trunk/configs/sip.conf.sample 397746
> trunk/CHANGES 397746
>
> Diff: https://reviewboard.asterisk.org/r/464/diff/
>
>
> Testing
> -------
>
> dialplan:
> Set(GROUP()=foo);
> Set(GROUP()=foobar@foocat);
>
> Set(GROUP_VAR(foo,myvar)=123);
> Set(GROUP_VAR(foo,myvar2)=456);
> NoOp(${GROUP_VAR(foo,myvar)});
> NoOp(${GROUP_VAR(foo,myvar2)});
>
> Set(GROUP_VAR(foobar@foocat,myvar)=123);
> NoOp(${GROUP_VAR(foobar@foocat,myvar)});
>
> Set(GROUP_VAR(something,myvar)=123);
> NoOp(${GROUP_VAR(something,myvar)});
>
> Wait(10000);
> Hangup();
>
>
> CLI:
> -------------------
> > group show channels
> -------------------
> channel Group Category
> IAX2/branch-15569 foo (default)
> IAX2/branch-15569 foobar foocat
> 2 active channels
>
> -------------------
> > group show variables
> -------------------
> Group Variables Category
> foo (Default)
> myvar2=456
> myvar=123
> foobar foocat
> myvar=123
> 2 active groups
>
>
> AMI:
> -------------------
> Action: GroupsShow
> -------------------
> Response: Success
> Eventlist: start
> Message: Groups will follow
>
> Event: GroupsShow
> Group: foo
> Category:
>
> Event: GroupsShow
> Group: foobar
> Category: foocat
>
> Event: GroupsShowComplete
> EventList: Complete
> ListItems: 2
>
>
> -------------------
> Action: GroupsShowChannels
> -------------------
> Response: Success
> Eventlist: start
> Message: Group channels will follow
>
> Event: GroupsShowChannels
> Group: foo
> Category:
> Channel: IAX2/branch-14981
>
> Event: GroupsShowChannels
> Group: foobar
> Category: foocat
> Channel: IAX2/branch-14981
>
> Event: GroupsShowChannelsComplete
> EventList: Complete
> ListItems: 2
>
>
> -------------------
> Action: GroupsShowVariables
> -------------------
> Response: Success
> Eventlist: start
> Message: Group variables will follow
>
> Event: GroupsShowVariables
> Group: foo
> Category:
> VariablesStart: Variables will follow
> myvar2: 456
> myvar: 123
>
>
> Event: GroupsShowVariables
> Group: foobar
> Category: foocat
> VariablesStart: Variables will follow
> myvar: 123
>
> Event: GroupsShowVariablesComplete
> EventList: Complete
> ListItems: 2
>
>
> -------------------
> Action: GroupVarGet
> Group: foo
> Variable: myvar
> -------------------
> Response: Success
> Message: Result will follow
>
> Event: GroupVarGetResponse
> Group: foo
> Category:
> Variable: myvar
> Value: 123
>
>
> -------------------
> Action: GroupVarSet
> Group: foobar
> Category: foocat
> Variable: something
> Value: 1238091283123
> -------------------
>
> Response: Success
> Message: Variable Set
>
>
> -------------------
> Action: GroupVarSet
> Group: doesntexist
> Category: foocat
> Variable: something
> Value: 1238091283123
> -------------------
>
> Response: Error
> Message: Variable set failed (group doesn't exist)
>
>
> Thanks,
>
> kobaz
>
>
[Attachment #5 (text/html)]
<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 \
solid;"> <tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://reviewboard.asterisk.org/r/464/">https://reviewboard.asterisk.org/r/464/</a>
</td>
</tr>
</table>
<br />
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Since reviewboard lost \
my 300 word text after uploading a new diff here it is again...
Updated CHANGES to reflect new functionality added
Through testing and development I've noticed a bit of a problem with the \
implementation of GROUP_COUNT and GROUP_MATCH_COUNT
Say you have the following dialplan:
Set(GROUP()=foo);
Set(GROUP()=foo@bar);
Set(GROUP()=foo@baz);
DumpGroups();
NoOp(---GROUP_COUNT---);
NoOp(foo: ${GROUP_COUNT(foo)});
NoOp(foo@: ${GROUP_COUNT(foo@)});
NoOp(@bar: ${GROUP_COUNT(.*@bar)});
NoOp(@baz: ${GROUP_COUNT(.*@baz)});
NoOp(foo@bar: ${GROUP_COUNT(foo)});
NoOp(foo@baz: ${GROUP_COUNT(foo)});
When executed you get:
-- Executing [44@cos_internal+local+ld:1] Set("SIP/6255-00000000", \
"__DialedNumber=44") in new stack
-- Executing [44@cos_internal+local+ld:2] Goto("SIP/6255-00000000", \
"_cos_internal+local+ld,44,1") in new stack
-- Goto (_cos_internal+local+ld,44,1)
-- Executing [44@_cos_internal+local+ld:1] Set("SIP/6255-00000000", \
"GROUP()=foo") in new stack
-- Executing [44@_cos_internal+local+ld:2] Set("SIP/6255-00000000", \
"GROUP()=foo@bar") in new stack
-- Executing [44@_cos_internal+local+ld:3] Set("SIP/6255-00000000", \
"GROUP()=foo@baz") in new stack
-- Executing [44@_cos_internal+local+ld:4] \
DumpGroups("SIP/6255-00000000", "") in new stack \
================================================================================ \
Channel Group Category
SIP/6255-00000000 foo (default)
SIP/6255-00000000 foo bar
SIP/6255-00000000 foo baz
3 active channels in groups
-----------------------------------
Group Variables Category
foo (default)
foo bar
foo baz
================================================================================
-- Executing [44@_cos_internal+local+ld:6] NoOp("SIP/6255-00000000", \
"---GROUP_COUNT---") in new stack
-- Executing [44@_cos_internal+local+ld:5] NoOp("SIP/6255-00000000", \
"foo: 3") in new stack
-- Executing [44@_cos_internal+local+ld:7] NoOp("SIP/6255-00000000", \
"foo@: 3") in new stack
-- Executing [44@_cos_internal+local+ld:8] NoOp("SIP/6255-00000000", \
"@bar: 0") in new stack
-- Executing [44@_cos_internal+local+ld:9] NoOp("SIP/6255-00000000", \
"@baz: 0") in new stack
-- Executing [44@_cos_internal+local+ld:10] NoOp("SIP/6255-00000000", \
"foo@bar: 3") in new stack
-- Executing [44@_cos_internal+local+ld:11] NoOp("SIP/6255-00000000", \
"foo@baz: 3") in new stack
The count returned is 3 !!!
To me this is clearly a bug, especially with the counts of foo@bar and foo@baz, which \
should be 1
There's a new function I added: GROUP_CHANNELS_MATCH_COUNT() which correctly \
counts channels in groups, versus occurrences of groups.
-- Executing [44@_cos_internal+local+ld:27] NoOp("SIP/6255-00000000", \
"---GROUP_CHANNELS_MATCH_COUNT---") in new stack
-- Executing [44@_cos_internal+local+ld:28] NoOp("SIP/6255-00000000", \
"foo: 1") in new stack
-- Executing [44@_cos_internal+local+ld:29] NoOp("SIP/6255-00000000", \
"foo@: 1") in new stack
-- Executing [44@_cos_internal+local+ld:30] NoOp("SIP/6255-00000000", \
"@bar: 1") in new stack
-- Executing [44@_cos_internal+local+ld:31] NoOp("SIP/6255-00000000", \
"@baz: 1") in new stack
-- Executing [44@_cos_internal+local+ld:32] NoOp("SIP/6255-00000000", \
"foo@bar: 1") in new stack
-- Executing [44@_cos_internal+local+ld:33] NoOp("SIP/6255-00000000", \
"foo@baz: 1") in new stack
-- Executing [44@_cos_internal+local+ld:34] NoOp("SIP/6255-00000000", \
"something: 0") in new stack
-- Executing [44@_cos_internal+local+ld:35] NoOp("SIP/6255-00000000", \
"something@: 0") in new stack
-- Executing [44@_cos_internal+local+ld:36] NoOp("SIP/6255-00000000", \
"something@nothing: 0") in new stack
-- Executing [44@_cos_internal+local+ld:37] NoOp("SIP/6255-00000000", \
"@nothing: 0") in new stack
I think the code behind GROUP_CHANNELS_MATCH_COUNT should replace GROUP_COUNT, \
especially because of the instructions from sip.conf which read: For call-limit:
; There is no combined call counter for a "friend"
; so there's currently no way in sip.conf to limit
; to one inbound or outbound call per phone. Use
; the group counters in the dial plan for that.
Case in point: If an asterisk user who does not understand the quirky internals of \
GROUP_COUNT wishes to use it to nail down strict capacity limits, they are in for \
some confusion if they are using group categories and the current \
GROUP_COUNT().</pre> <br />
<p>- kobaz</p>
<br />
<p>On August 30th, 2013, 8:10 p.m. UTC, kobaz wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" \
style="background-image: \
url('https://reviewboard.asterisk.org/static/rb/images/review_request_box_top_bg.png'); \
background-position: left top; background-repeat: repeat-x; border: 1px black \
solid;"> <tr>
<td>
<div>Review request for Asterisk Developers.</div>
<div>By kobaz.</div>
<p style="color: grey;"><i>Updated Aug. 30, 2013, 8:10 p.m.</i></p>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>
<a href="https://issues.asterisk.org/jira/browse/16614">16614</a>
</div>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt;">Repository: </b>
Asterisk
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" \
style="border: 1px solid #b8b5a0"> <tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">This patch allows for setting variables on a group of channels. First a \
channel is assigned a group via dialplan GROUP() or GroupSet via the ami (new \
command) Then, variables can be set on that group with the GROUP_VAR() dialplan \
function, or GroupVarSet in the manager
This patch also adds manager events for channel group changes, and variable updates
When a group is no longer used (all channels referencing the group are hung up, or \
all channels referencing the group have their group changed/unset), variables are \
destroyed
new manager commands:
GroupSet - adds functionality to the manager to be able to set a GROUP() on a \
channel. GroupsShowChannels - show each channel and it's associated groups (a \
channel will be repeated for each group@category it's a member of) \
GroupsShowVariables - show variables in each group@category, one event per group, all \
variables are contained in each group@category event GroupVarSet - set a group \
variable (the group has to exist) GroupVarGet - get a group variable
new manager events:
GroupCreate
GroupChannelAdd
GroupChannelRemove
GroupDestroy
GroupVarSet
Example AMI:
Action: GroupVarSet
Group: 1000
Category: ConferenceBridge
Variable: LastUpdateCheck
Value: 1263502512
Example CLI:
demo1*CLI> group show variables
Group Variables Category
1000 ConferenceBridge
LastUpdateCheck=1263502512
1000 ConferenceModerator
2 active groups
Adds support for:
Group variables
dialplan access: GROUP_VAR()
cli access: group show variables
manager access: GroupVarSet GroupVarGet
Group information:
manager access: GroupSet GroupsShow GroupsShowChannels GroupsShowVariables
</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: \
1px solid #b8b5a0"> <tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">dialplan: Set(GROUP()=foo);
Set(GROUP()=foobar@foocat);
Set(GROUP_VAR(foo,myvar)=123);
Set(GROUP_VAR(foo,myvar2)=456);
NoOp(${GROUP_VAR(foo,myvar)});
NoOp(${GROUP_VAR(foo,myvar2)});
Set(GROUP_VAR(foobar@foocat,myvar)=123);
NoOp(${GROUP_VAR(foobar@foocat,myvar)});
Set(GROUP_VAR(something,myvar)=123);
NoOp(${GROUP_VAR(something,myvar)});
Wait(10000);
Hangup();
CLI:
-------------------
> group show channels
-------------------
channel Group Category
IAX2/branch-15569 foo (default)
IAX2/branch-15569 foobar foocat
2 active channels
-------------------
> group show variables
-------------------
Group Variables Category
foo (Default)
myvar2=456
myvar=123
foobar foocat
myvar=123
2 active groups
AMI:
-------------------
Action: GroupsShow
-------------------
Response: Success
Eventlist: start
Message: Groups will follow
Event: GroupsShow
Group: foo
Category:
Event: GroupsShow
Group: foobar
Category: foocat
Event: GroupsShowComplete
EventList: Complete
ListItems: 2
-------------------
Action: GroupsShowChannels
-------------------
Response: Success
Eventlist: start
Message: Group channels will follow
Event: GroupsShowChannels
Group: foo
Category:
Channel: IAX2/branch-14981
Event: GroupsShowChannels
Group: foobar
Category: foocat
Channel: IAX2/branch-14981
Event: GroupsShowChannelsComplete
EventList: Complete
ListItems: 2
-------------------
Action: GroupsShowVariables
-------------------
Response: Success
Eventlist: start
Message: Group variables will follow
Event: GroupsShowVariables
Group: foo
Category:
VariablesStart: Variables will follow
myvar2: 456
myvar: 123
Event: GroupsShowVariables
Group: foobar
Category: foocat
VariablesStart: Variables will follow
myvar: 123
Event: GroupsShowVariablesComplete
EventList: Complete
ListItems: 2
-------------------
Action: GroupVarGet
Group: foo
Variable: myvar
-------------------
Response: Success
Message: Result will follow
Event: GroupVarGetResponse
Group: foo
Category:
Variable: myvar
Value: 123
-------------------
Action: GroupVarSet
Group: foobar
Category: foocat
Variable: something
Value: 1238091283123
-------------------
Response: Success
Message: Variable Set
-------------------
Action: GroupVarSet
Group: doesntexist
Category: foocat
Variable: something
Value: 1238091283123
-------------------
Response: Error
Message: Variable set failed (group doesn't exist)
</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>trunk/main/cli.c <span style="color: grey">(397746)</span></li>
<li>trunk/main/app.c <span style="color: grey">(397746)</span></li>
<li>trunk/include/asterisk/channel.h <span style="color: grey">(397746)</span></li>
<li>trunk/include/asterisk/app.h <span style="color: grey">(397746)</span></li>
<li>trunk/funcs/func_groupcount.c <span style="color: grey">(397746)</span></li>
<li>trunk/configs/sip.conf.sample <span style="color: grey">(397746)</span></li>
<li>trunk/CHANGES <span style="color: grey">(397746)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/464/diff/" style="margin-left: \
3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-dev
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic