FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Gather Statistics from the Queues and Asterisk and monitor changes on… · asterisk-java/asterisk-java@26455a0 · GitHub

Repository navigation

Commit 26455a0

Browse files
Octavio Luna
committed
Gather Statistics from the Queues and Asterisk and monitor changes on Objects
1 parent 2438b73 commit 26455a0

15 files changed

Lines changed: 722 additions & 146 deletions

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ target
66
.project
77
.settings/*
88
.idea
9+
.gradle
910
classes

‎pom.xml‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@
3737
<organization>Bureau of Economic and Business Research, University of Florida</organization>
3838
<timezone>-5</timezone>
3939
</developer>
40+
<developer>
41+
<name>Octavio Luna</name>
42+
<id>itaqua</id>
43+
<email>octavio.luna at gmail.com</email>
44+
<organization>N4Utilus Take your Business to the Cloud</organization>
45+
<timezone>-6</timezone>
46+
</developer>
4047
</developers>
4148
<scm>
4249
<connection>scm:git:git://github.com/srt/asterisk-java.git</connection>
@@ -130,6 +137,12 @@ org.apache.log4j;resolution:=optional
130137
<version>1.2.16</version>
131138
<scope>compile</scope>
132139
</dependency>
140+
<dependency>
141+
<groupId>org.apache.commons</groupId>
142+
<artifactId>commons-lang3</artifactId>
143+
<version>3.1</version>
144+
<scope>compile</scope>
145+
</dependency>
133146
<dependency>
134147
<groupId>org.slf4j</groupId>
135148
<artifactId>slf4j-api</artifactId>

‎src/main/java/org/asteriskjava/live/AsteriskQueue.java‎

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
package org.asteriskjava.live;
1818

1919
import java.util.Collection;
20+
import java.util.Date;
2021
import java.util.List;
2122

2223
/**
2324
* An Asterisk ACD queue.
2425
*
2526
* @author srt
27+
* @author itaqua
2628
* @version $Id$
2729
*/
2830
public interface AsteriskQueue
@@ -134,4 +136,67 @@ public interface AsteriskQueue
134136
* @since 0.3
135137
*/
136138
void removeAsteriskQueueListener(AsteriskQueueListener listener);
139+
140+
/**
141+
* Returns the number of abandoned calls.
142+
* @author itaqua
143+
* @return the number of abandoned calls.
144+
*/
145+
Integer getAbandoned();
146+
147+
/**
148+
* Returns the ratio of calls answered within the specified service level per total completed
149+
* calls (in percent).
150+
* @author itaqua
151+
* @return the ratio of calls answered within the specified service level per total completed
152+
* calls (in percent).
153+
*/
154+
public Double getServiceLevelPerf();
155+
156+
/**
157+
* Returns the number of completed calls.
158+
* @author itaqua
159+
* @return the number of completed calls.
160+
*/
161+
public Integer getCompleted();
162+
163+
/**
164+
* Returns the current average talk time for this queue based on an exponential average.
165+
*
166+
* @return the current average talk time for this queue.
167+
*/
168+
public Integer getTalkTime();
169+
170+
/**
171+
* Returns the current average holdtime for this queue (in seconds).
172+
* @author itaqua
173+
* @return the current average holdtime for this queue (in seconds).
174+
*/
175+
public Integer getHoldTime();
176+
177+
/**
178+
* Returns the number of calls currently waiting in the queue.
179+
* Is better to use get Waiting()
180+
* @author itaqua
181+
* @see getWaiting()
182+
* @return the number of calls currently waiting in the queue.
183+
*/
184+
public Integer getCalls();
185+
186+
/**
187+
* Returns the number of calls currently waiting in the queue.
188+
* More verbose Method than getCalls()
189+
* @author itaqua
190+
* @return the number of calls currently waiting in the queue.
191+
*/
192+
public Integer getWaiting();
193+
194+
/**
195+
* timestamp (miliseconds) of last update of this object
196+
* @todo maybe change this to an immutable object
197+
* @author itaqua
198+
* @return
199+
*/
200+
long getLastUpdateMillis();
201+
137202
}

‎src/main/java/org/asteriskjava/live/AsteriskQueueMember.java‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
* </ul>
2828
*
2929
* @author <a href="mailto:patrick.breucking{@nospam}gonicus.de">Patrick Breucking</a>
30+
* @author itaqua
3031
* @version $Id$
3132
* @since 0.3.1
3233
*/
@@ -35,6 +36,8 @@ public interface AsteriskQueueMember extends LiveObject
3536
String PROPERTY_STATE = "state";
3637
String PROPERTY_PENALTY = "penalty";
3738
String PROPERTY_PAUSED = "paused";
39+
String PROPERTY_CALLSTAKEN = "callsTaken";
40+
String PROPERTY_LASTCALL = "lastCall";
3841

3942
/**
4043
* Returns the location of this member.
@@ -143,4 +146,18 @@ public interface AsteriskQueueMember extends LiveObject
143146
* @since 1.0.0
144147
*/
145148
void setPenalty(int penalty) throws IllegalArgumentException, ManagerCommunicationException, InvalidPenaltyException;
149+
150+
/**
151+
* get the timestamp when the last call was terminated
152+
* @author itaqua
153+
* @return
154+
*/
155+
public abstract Long getLastCall();
156+
157+
/**
158+
* total calls taken
159+
* @author itaqua
160+
* @return
161+
*/
162+
public abstract Integer getCallsTaken();
146163
}

‎src/main/java/org/asteriskjava/live/AsteriskServer.java‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.asteriskjava.live;
1818

1919
import java.util.Collection;
20+
import java.util.Date;
2021
import java.util.Map;
2122
import java.util.List;
2223

@@ -488,4 +489,34 @@ void setGlobalVariable(String variable, String value)
488489
* @throws ManagerCommunicationException if login fails
489490
*/
490491
void initialize() throws ManagerCommunicationException;
492+
493+
/**
494+
* get Asterisk Queue by name
495+
* @author itaqua
496+
* @param queueName Name of the queue to retrieve
497+
* @return
498+
*/
499+
public AsteriskQueue getQueueByName(String queueName);
500+
501+
/**
502+
* List of Queues Objects updated after certain date
503+
* @author itaqua
504+
* @param date
505+
* @return
506+
*/
507+
public List<AsteriskQueue> getQueuesUpdatedAfter(Date date);
508+
509+
/**
510+
* every time we get an event of a queue we reload the information about it from
511+
* the Asterisk Server
512+
* @author itaqua
513+
*/
514+
public void forceQueuesMonitor(boolean force);
515+
516+
/**
517+
* Check if the Queue Information is forced
518+
* @author itaqua
519+
* @return
520+
*/
521+
public boolean isQueuesMonitorForced();
491522
}

‎src/main/java/org/asteriskjava/live/DefaultAsteriskServer.java‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.asteriskjava.live;
1818

1919
import java.util.Collection;
20+
import java.util.Date;
2021
import java.util.Map;
2122
import java.util.List;
2223

@@ -313,4 +314,23 @@ public Collection<AsteriskAgent> getAgents() throws ManagerCommunicationExceptio
313314
{
314315
return impl.getAgents();
315316
}
317+
318+
public AsteriskQueue getQueueByName(String queueName) {
319+
return impl.getQueueByName(queueName);
320+
}
321+
322+
@Override
323+
public List<AsteriskQueue> getQueuesUpdatedAfter(Date date) {
324+
return impl.getQueuesUpdatedAfter(date);
325+
}
326+
327+
@Override
328+
public void forceQueuesMonitor(boolean force) {
329+
impl.forceQueuesMonitor(force);
330+
}
331+
332+
@Override
333+
public boolean isQueuesMonitorForced() {
334+
return impl.isQueuesMonitorForced();
335+
}
316336
}

‎src/main/java/org/asteriskjava/live/LiveObject.java‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,10 @@ public interface LiveObject
7272
* @param listener listener to remove
7373
*/
7474
void removePropertyChangeListener(String propertyName, PropertyChangeListener listener);
75+
76+
/**
77+
* Timestamp of last update of the Object
78+
* @return
79+
*/
80+
long getLastUpdateMillis();
7581
}

‎src/main/java/org/asteriskjava/live/QueueMemberState.java‎

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import org.asteriskjava.manager.event.QueueMemberEvent;
2020

2121
/**
22-
* Represents the status of a Queue memeber.
22+
* Represents the status of a Queue member.
2323
*
2424
* <p/>
2525
* Valid status codes are:
@@ -36,9 +36,16 @@
3636
* <dd>?</dd>
3737
* <dt>AST_DEVICE_UNAVAILABLE (5)</dt>
3838
* <dd>?</dd>
39+
* <dt>AST_DEVICE_RINGING (6)</dt>
40+
* <dd>?</dd>
41+
* <dt>AST_DEVICE_RINGINUSE (7)</dt>
42+
* <dd>?</dd>
43+
* <dt>AST_DEVICE_ONHOLD (8)</dt>
44+
* <dd>?</dd>
3945
* </dl>
4046
*
4147
* @author <a href="mailto:patrick.breucking{@nospam}gonicus.de">Patrick Breucking</a>
48+
* @author itaqua
4249
* @version $Id$
4350
* @since 0.3.1
4451
* @see org.asteriskjava.manager.event.QueueMemberEvent
@@ -62,9 +69,27 @@ public enum QueueMemberState
6269
DEVICE_INVALID(QueueMemberEvent.AST_DEVICE_INVALID),
6370

6471
/**
65-
* Device is not availible for call, eg. Agent is logged off.
72+
* Device is not available for call, eg. Agent is logged off.
73+
*/
74+
DEVICE_UNAVAILABLE(QueueMemberEvent.AST_DEVICE_UNAVAILABLE),
75+
76+
/**
77+
* Device is ringing.
6678
*/
67-
DEVICE_UNAVAILABLE(QueueMemberEvent.AST_DEVICE_UNAVAILABLE);
79+
DEVICE_RINGING(QueueMemberEvent.AST_DEVICE_RINGING),
80+
81+
/**
82+
* Device is ringing *and* in use.
83+
*/
84+
DEVICE_RINGINUSE(QueueMemberEvent.AST_DEVICE_RINGINUSE),
85+
86+
/**
87+
* Device is on hold
88+
*/
89+
DEVICE_ONHOLD(QueueMemberEvent.AST_DEVICE_ONHOLD);
90+
91+
92+
6893

6994
private final int status;
7095

‎src/main/java/org/asteriskjava/live/internal/AbstractLiveObject.java‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
*/
1717
package org.asteriskjava.live.internal;
1818

19-
import java.beans.PropertyChangeListener;
20-
import java.beans.PropertyChangeSupport;
21-
2219
import org.asteriskjava.live.AsteriskServer;
2320
import org.asteriskjava.live.LiveObject;
2421
import org.asteriskjava.util.Log;
2522
import org.asteriskjava.util.LogFactory;
2623

24+
import java.beans.PropertyChangeListener;
25+
import java.beans.PropertyChangeSupport;
26+
2727
/**
2828
* Abstract base class for all live objects.
2929
*
@@ -36,10 +36,14 @@ abstract class AbstractLiveObject implements LiveObject
3636
private final PropertyChangeSupport changes;
3737
protected final AsteriskServerImpl server;
3838

39+
//last time this object was updated
40+
private long lastUpdate;
41+
3942
AbstractLiveObject(AsteriskServerImpl server)
4043
{
4144
this.server = server;
4245
this.changes = new PropertyChangeSupport(this);
46+
stampLastUpdate();
4347
}
4448

4549
public AsteriskServer getServer()
@@ -71,6 +75,7 @@ protected void firePropertyChange(String propertyName, Object oldValue, Object n
7175
{
7276
if (oldValue != null || newValue != null)
7377
{
78+
stampLastUpdate();
7479
try
7580
{
7681
changes.firePropertyChange(propertyName, oldValue, newValue);
@@ -81,4 +86,13 @@ protected void firePropertyChange(String propertyName, Object oldValue, Object n
8186
}
8287
}
8388
}
89+
90+
@Override
91+
public long getLastUpdateMillis() {
92+
return lastUpdate;
93+
}
94+
95+
public void stampLastUpdate(){
96+
lastUpdate = System.currentTimeMillis();
97+
}
8498
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL