Compare commits

...

237 Commits

Author SHA1 Message Date
Akshay Jagadish
ea9a9d6292 WIFI-3471 Update SDK master to use image tag 1.3.0-SNAPSHOT 2021-08-13 11:57:10 -04:00
Mike Hansen
b41e35a536 Merge pull request #151 from Telecominfraproject/WIFI-3404
[WIFI-3404] Clean up unused schema definition in yaml files
2021-08-11 08:33:02 -04:00
Mike Hansen
64bd468ade Merge pull request #149 from Telecominfraproject/WIFI-3358
[WIFI-3358] remove more unused attributes in ClientMetrics
2021-08-11 08:32:01 -04:00
Mike Hansen
fe488e9d5f Merge pull request #148 from Telecominfraproject/WIFI-3403
[WIFI-3403] remove unused attributes in RadioStatistics
2021-08-11 08:31:01 -04:00
norm-traxler
a79778b083 Merge pull request #150 from Telecominfraproject/WIFI-3397
Fix to not remove the active sessions.
2021-08-10 22:18:54 -04:00
Thomas-Leung2021
d5b86d0c8d [WIFI-3404] Clean up unused schema definitions for RadioStatistics 2021-08-10 18:43:02 -04:00
Rahul Sharma
15698e99cb Fix to not remove the active sessions.
Also added some more logging
2021-08-10 18:29:47 -04:00
Thomas-Leung2021
e06c28e85a [WIFI-3404] Clean up unused schema definition in yaml files 2021-08-10 18:08:13 -04:00
Thomas-Leung2021
c307f59e8a [WIFI-3358] remove more unused attributes in ClientMetrics 2021-08-10 17:35:38 -04:00
Thomas-Leung2021
1e23a691d7 [WIFI-3403] remove unused attributes in RadioStatistics 2021-08-10 14:11:32 -04:00
Mike Hansen
015e662e68 Merge pull request #147 from Telecominfraproject/revert-146-revert-144-WIFI-3358
Revert "Revert "[WIFI 3358] Client Metrics report performance improvements""
2021-08-09 19:26:14 -04:00
Mike Hansen
9f3af6773b Revert "Revert "[WIFI 3358] Client Metrics report performance improvements"" 2021-08-09 19:26:00 -04:00
Mike Hansen
b7eedf6b8c Merge pull request #146 from Telecominfraproject/revert-144-WIFI-3358
Revert "[WIFI 3358] Client Metrics report performance improvements"
2021-08-09 19:14:01 -04:00
Mike Hansen
468e7bcddb Revert "[WIFI 3358] Client Metrics report performance improvements" 2021-08-09 19:13:50 -04:00
Mike Hansen
9b712d6fb5 Merge pull request #145 from Telecominfraproject/WIFI-3397
Adding more logging to find the cause of Remote-SSH sessions drop
2021-08-09 18:52:01 -04:00
Mike Hansen
99475d3f2f Merge pull request #144 from Telecominfraproject/WIFI-3358
[WIFI 3358] Client Metrics report performance improvements
2021-08-09 18:49:46 -04:00
Rahul Sharma
7216b08ac7 Adding more logging to find the cause of Remote-SSH sessions drop 2021-08-09 18:35:33 -04:00
Thomas-Leung2021
34da98b9a8 [WIFI-3358] remove unused methods in ClientRadioUtils.java 2021-08-09 17:20:21 -04:00
Thomas-Leung2021
65aeadeaa7 [WIFI-3358] remove WmmQueueStats.java 2021-08-09 17:06:15 -04:00
Thomas-Leung2021
148a6762dc [WIFI-3358] remove McsType.java 2021-08-09 17:06:15 -04:00
Thomas-Leung2021
178378f8b6 [WIFI-3358] remove McsStats.java 2021-08-09 17:06:15 -04:00
Thomas-Leung2021
d0e6866345 [WIFI-3358] remove unused attributes in McsStats 2021-08-09 17:06:15 -04:00
Thomas-Leung2021
a2b3e711ea [WIFI-3358] remove ClientQoEMetrics.java 2021-08-09 17:06:15 -04:00
Thomas-Leung2021
b5f5c6d19f [WIFI-3358] remove unused attributes for SsidStatistics 2021-08-09 17:06:15 -04:00
Thomas-Leung2021
a5079d04a7 [WIFI-3358] remove unused attributes in ClientMetrics 2021-08-09 17:06:15 -04:00
Mike Hansen
35d89a1cf0 Merge pull request #143 from Telecominfraproject/WIFI-3358-id
[WIFI-3358] remove sessionId in ClientMetrics
2021-08-09 15:56:07 -04:00
Thomas-Leung2021
534ed3e9c0 [WIFI-3358] remove sessionId in ClientMetrics 2021-08-09 14:42:14 -04:00
Mike Hansen
a6ec1d6e7f Merge pull request #142 from Telecominfraproject/WIFI-3344
[WIFI-3344] remove ClientSessionMetricDetails
2021-08-04 19:35:16 -04:00
Thomas-Leung2021
a19fc425c2 [WIFI-3344] remove ClientSessionMetricDetails 2021-08-04 16:57:40 -04:00
Mike Hansen
fc8cab6a50 Merge pull request #141 from Telecominfraproject/NETEXP-2677
[NETEXP-2677] set clients disconnected in current client list when moving AP to another SP
2021-08-04 10:27:58 -04:00
Thomas-Leung2021
daabf38510 [NETEXP-2677] set clients disconnected in current client list when moving AP to another SP 2021-08-03 18:05:31 -04:00
Mike Hansen
78c4d3a862 Merge pull request #140 from Telecominfraproject/WIFI-3285
WIFI-3285 Use base channel as default value on 5G for backupChannelNu…
2021-08-03 18:04:42 -04:00
Lynn Shi
3f3e40d2dd WIFI-3285 Use base channel as default value on 5G for backupChannelNumber and manualBackupChannelNumber in Equipment Config 2021-08-03 14:08:29 -04:00
Mike Hansen
91877f5305 Merge pull request #139 from Telecominfraproject/WIFI-3259-portal-user-event-payload-fix
[WIFI-3259] Adding default constructor to PortalUserEventPayload for …
2021-07-29 10:10:39 -04:00
ralphlee
11314e3395 [WIFI-3259] Adding default constructor to PortalUserEventPayload for serialization, updated yamls 2021-07-28 12:58:46 -04:00
Mike Hansen
fa6795369c Merge pull request #138 from Telecominfraproject/NETEXP-1632-temp
fix missing RADIO_CHANNEL status
2021-07-27 08:41:07 -04:00
Thomas-Leung2021
e6e06d7b70 fix missing RADIO_CHANNEL status 2021-07-26 17:29:49 -04:00
Mike Hansen
1e15e3cd94 Merge pull request #137 from Telecominfraproject/WIFI-3218-add-null-checks-to-rrm-bulk-update
[WIFI-3218] Adding null checks to RrmBulkUpdateItem
2021-07-22 17:25:38 -04:00
ralphlee
02e03780db [WIFI-3218] Adding null checks to RrmBulkUpdateItem 2021-07-22 17:19:03 -04:00
Mike Hansen
aac34150b2 APs running into Backoff shows as connected
Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-07-22 15:31:58 -04:00
Mike Hansen
3085c34cde Merge pull request #135 from Telecominfraproject/WIFI-3180-portal-user-search-case-insensitive
[WIFI-3180] Adding case insensitivity to Portal User API Search
2021-07-20 11:53:47 -04:00
Mike Hansen
35fd038113 [WIFI-3166] Session ID is a -ve number in opensyncgw logs and on UI logs
Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-07-20 11:31:07 -04:00
ralphlee
7c387f1940 [WIFI-3180] Adding case insensitivity to Portal User API Search 2021-07-20 10:38:04 -04:00
Mike Hansen
abb9b59659 Gateway pushes the threshholds as empty which causes AP not to connect any client
Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-07-20 10:02:59 -04:00
norm-traxler
7f0497754c Merge pull request #134 from Telecominfraproject/WIFI-3042-alarm-remote-fix
[WIFI-3042] Fix alarmCode get url parameter
2021-07-20 08:30:40 -04:00
Norm Traxler
82095510f7 [WIFI-3042] Fix alarmCode get url parameter 2021-07-20 08:23:58 -04:00
Mike Hansen
0afd414870 Merge pull request #133 from Telecominfraproject/change_sessionId_to_String
[WIFI-3166] Session ID is a -ve number in opensyncgw logs and on UI logs
2021-07-19 19:30:42 -04:00
Mike Hansen
772beab902 [WIFI-3166] Session ID is a -ve number in opensyncgw logs and on UI logs
Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-07-19 19:10:37 -04:00
Mike Hansen
4a764db007 [WIFI-3166] Session ID is a -ve number in opensyncgw logs and on UI logs
Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-07-19 18:03:13 -04:00
Mike Hansen
41add1922b Merge pull request #132 from Telecominfraproject/WIFI-3041
[WIFI-3041] move if statusment for custmerId check to a different location
2021-07-19 17:54:58 -04:00
Thomas-Leung2021
90ac57b988 [WIFI-3041] move if statement to make it more logical 2021-07-19 17:52:49 -04:00
Thomas-Leung2021
0cc90764c6 [WIFI-3041] move if statusment for custmerId check to a different location 2021-07-19 17:00:54 -04:00
Mike Hansen
1e277f5650 [WIFI-3165] Keep last stats received timestamp in gateway client session map
Adding API call to gateway controller

Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-07-19 14:13:19 -04:00
Mike Hansen
716ba7e043 Merge pull request #131 from Telecominfraproject/WIFI-3041
[Wifi 3041] A disconnected Alarm is raised when a disconnected AP is moved out of a Customer Inventory.
2021-07-16 16:28:16 -04:00
Thomas-Leung2021
3d2f4db32a [WIFI-3041] remove unnecessary dependencies 2021-07-16 12:22:23 -04:00
Thomas-Leung2021
c75d44ff03 [WIFI-3041] create a new EquipmentCustomerChangedEvent to handle status and alarm migration 2021-07-16 10:44:23 -04:00
Mike Hansen
f9dbe12c8c Merge pull request #130 from Telecominfraproject/WIFI-3056-event-stats
[WIFI-3056] Add API to get system event statistics
2021-07-16 07:44:06 -04:00
Norm Traxler
910a2cbe0c [WIFI-3056] Add API to get system event statistics 2021-07-15 22:15:01 -04:00
Thomas-Leung2021
799b243cc4 [WIFI-3041] move alarms to new customerId if customerId changed 2021-07-15 16:45:07 -04:00
Mike Hansen
8834c33d90 Merge pull request #129 from Telecominfraproject/WIFI-3042-alarms-by-alarmcode
[WIFI-3042] Add Alarm endpoint for get alarms by AlarmCode
2021-07-15 09:26:20 -04:00
Norm Traxler
e9c54a892b [WIFI-3042] Add Alarm endpoint for get alarms by AlarmCode 2021-07-14 20:18:22 -04:00
Mike Hansen
8353dd375f Control LED off via Equipment AP profile
Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-07-14 18:45:33 -04:00
Mike Hansen
46de84b28b Add NULL check in EquipmentController
Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-07-14 18:00:10 -04:00
Mike Hansen
9edca1fd9d CloudBackend:
Control LED off via Equipment AP profile

Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-07-14 17:30:06 -04:00
Mike Hansen
5714c9bf32 CloudBackend:
Control LED off via Equipment AP profile and Show LED status in EQUIPMENT_ADMIN status

Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-07-14 16:03:39 -04:00
Mike Hansen
2b2e34a064 Merge pull request #128 from Telecominfraproject/WIFI-2987
[WIFI-2987] add protocol status when switching customer
2021-07-13 14:09:02 -04:00
Thomas-Leung2021
d7a75faf4c check when status is null 2021-07-13 12:10:04 -04:00
Thomas-Leung2021
5fd977f064 [WIFI-2987] add protocol status when switching customer 2021-07-12 14:47:36 -04:00
Mike Hansen
bafec1fdd8 Merge pull request #127 from Telecominfraproject/hotfix/wifi-2970
[WIFI-2970] add equipment admin status when switching customer
2021-07-09 10:52:49 -04:00
Thomas-Leung2021
6b046e0a7a [WIFI-2970] remove unnecessary comments 2021-07-09 10:48:40 -04:00
Thomas-Leung2021
fb6604cdf5 add required dependencies in tests for new changes in EquipmentController 2021-07-08 17:48:20 -04:00
Thomas-Leung2021
2c1c60344e add equipment admin status when switching customer 2021-07-08 17:47:26 -04:00
Mike Hansen
9e959e258f Merge pull request #126 from Telecominfraproject/WIFI-2932-Client-ip-event
[WIFI-2932] Change IP event ipAddress from byte[] to InetAddress
2021-07-06 10:21:04 -04:00
Norm Traxler
2410233046 [WIFI-2932] Change IP event ipAddress from byte[] to InetAddress 2021-07-05 17:58:01 -04:00
norm-traxler
a7f91a29f8 Merge pull request #125 from Telecominfraproject/updateAPI
Update APIs to reflect new map in EquipmentChannelStatusData
2021-06-28 16:23:39 -04:00
Thomas-Leung2021
80cd0abd58 Update APIs to reflect new map in EquipmentChannelStatusData 2021-06-28 11:50:49 -04:00
Mike Hansen
4555ff339b Merge pull request #124 from Telecominfraproject/feature/netexp-2237
add tx_power status
2021-06-25 13:07:27 -04:00
Thomas-Leung2021
04a13877d1 add tx_power status 2021-06-25 12:39:30 -04:00
Mike Hansen
e148bab291 Merge pull request #123 from Telecominfraproject/WIFI-2699-modify-GET-/portal/profile/equipmentCounts-to-support-child-profiles-for-the-count
WIFI-2699  Modify GET /portal/profile/equipmentCounts to support child profiles for the count
2021-06-24 10:09:38 -04:00
Thomas Currie
9ad3cec4af rework top level profile tracking, so as to not include any profiles that were not in the Set argument 2021-06-23 11:30:06 -04:00
Thomas Currie
dc0b838f83 complete the test case cleanup 2021-06-23 11:11:54 -04:00
Thomas Currie
7cac7fff3f rework the algorithm at endpoint /portal/profile/equipmentCounts to include the correct child profile count for equipment 2021-06-23 10:58:02 -04:00
Mike Hansen
b48340b709 Merge pull request #122 from Telecominfraproject/disable_eq_alarms_sp
disable equipment-alarms-sp functionality, part of task to move the r…
2021-06-22 16:03:36 -04:00
Mike Hansen
44b3836758 disable equipment-alarms-sp functionality, part of task to move the raising and clearing of the threshold alarms into the gateway controller when the device information is received
Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-06-22 15:43:09 -04:00
Mike Hansen
4f0b032549 Merge branch 'disable_eq_alarms_sp' of github.com:Telecominfraproject/wlan-cloud-services into disable_eq_alarms_sp 2021-06-22 15:40:54 -04:00
Mike Hansen
5ba0c4c242 Merge pull request #121 from Telecominfraproject/WIFI-2698-Update-visibility-of-fields-in-PortalUserDAO
WIFI-2698-Update-visibility-of-fields-in-PortalUserDAO
2021-06-22 10:42:01 -04:00
Mike Hansen
304e80332a disable equipment-alarms-sp functionality, part of task to move the raising and clearing of the threshold alarms into the gateway controller when the device information is received
Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-06-22 10:19:41 -04:00
Thomas Currie
9fd3e73398 increase visibility of some fields in PortalUserDAO to allow classes to extend upon without duplication of values 2021-06-21 19:59:45 -04:00
Mike Hansen
b9db744aee Merge pull request #120 from Telecominfraproject/updateAPI
[WIFI-2646] update API to support WPA3-EAP-192
2021-06-17 13:43:53 -04:00
norm-traxler
1eee65d284 Merge pull request #119 from Telecominfraproject/WIFI-2670_2
[WIFI-2670] Add more counters to the ClientSessionCounts
2021-06-17 13:11:18 -04:00
Norm Traxler
75c943211a [WIFI-2670] Add more counters to the ClientSessionCounts 2021-06-17 12:14:38 -04:00
Thomas-Leung2021
d0a0ed59fe update API to support WPA3-EAP-192 2021-06-17 12:14:12 -04:00
norm-traxler
a200fcc12e Merge pull request #118 from Telecominfraproject/WIFI-2664
WIFI-2664 added private macs to return map
2021-06-17 12:12:39 -04:00
Kareem Dabbour
1f6996abb2 Merge branch 'master' of github.com:Telecominfraproject/wlan-cloud-services into WIFI-2664 2021-06-17 11:46:20 -04:00
Kareem Dabbour
1ebaa4a539 WIFI-2664 added private macs to return map 2021-06-17 11:44:02 -04:00
norm-traxler
f1e1bdffd7 Merge pull request #117 from Telecominfraproject/WIFI-2664
WIFI-2664 added private mac address filtering to /oui/list endpoint
2021-06-16 13:36:26 -04:00
Kareem Dabbour
37f5872552 Merge branch 'master' of github.com:Telecominfraproject/wlan-cloud-services into WIFI-2664 2021-06-16 12:59:23 -04:00
Kareem Dabbour
367b9ec428 WIFI-2664 adjusting unit tests to reflect added oui of ffffff 2021-06-16 12:55:57 -04:00
Kareem Dabbour
87ca619ad5 WIFI-2664 added private mac address filtering to /oui/list endpoint 2021-06-16 12:28:01 -04:00
norm-traxler
622f78f681 Merge pull request #116 from Telecominfraproject/WIFI-2664
WIFI-2664 Non-global mac addresses will now return an Uknown (private address) rather than null
2021-06-15 16:44:59 -04:00
Kareem Dabbour
faeb65d8d6 Merge branch 'master' of github.com:Telecominfraproject/wlan-cloud-services into WIFI-2664 2021-06-15 16:43:14 -04:00
Kareem Dabbour
34841a3a04 WIFI-2664 moving logic from in memory and DAO to controller 2021-06-15 16:37:30 -04:00
Kareem Dabbour
4fc8bc4018 WIFI-2664 renamed group to global address and did some refractoring 2021-06-15 15:26:51 -04:00
Kareem Dabbour
cce36019fe WIFI-2664 Non-global mac addresses will now return an Uknown (private address) rather than null 2021-06-15 14:46:14 -04:00
norm-traxler
4596280090 Merge pull request #115 from Telecominfraproject/WIFI-2670
[WIFI-2670] Client Session API support OUI attribute and count query
2021-06-15 14:44:44 -04:00
Norm Traxler
caaa8fb4e3 [WIFI-2670] Client Session API support OUI attribute and count query 2021-06-15 14:15:52 -04:00
Mike Hansen
b957c8bf72 Merge branch 'master' of github.com:Telecominfraproject/wlan-cloud-services 2021-06-14 11:55:58 -04:00
Mike Hansen
b797cc392f WIFI-2639: CloudBackend: upgrade CEGWBlinkRequest definition
Adding API call to portal, /portal/equipmentGateway/requestApBlinkLEDs

Adding RequestMapping to EquipmentPortalGatewayController

Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-06-14 11:53:54 -04:00
norm-traxler
5fc9715649 Merge pull request #114 from Telecominfraproject/WIFI-2601-Add-check-for-valid-equipment-ID-when-creating-new-alarms-via-the-alarm-prov-controller
add check for validity of equipment ID when creating new alarms
2021-06-14 11:07:28 -04:00
Mike Hansen
0a66897e48 WIFI-2639: CloudBackend: upgrade CEGWBlinkRequest definition
Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-06-11 15:58:30 -04:00
Mike Hansen
8d77fcb090 WIFI-2607: CloudBackend: add dynamicDiscovery attribute to RadiusProxyConfiguration
Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-06-09 15:10:02 -04:00
Thomas Currie
256d9fbd16 throw better exception when equipment ID does not exist. 2021-06-09 09:20:30 -04:00
Thomas Currie
39e14da2e6 add check for validity of equipment ID when creating new alarms 2021-06-09 08:55:16 -04:00
Mike Hansen
996c60adf6 Merge pull request #113 from Telecominfraproject/alarmImprovement1516
Changed AccessPointIsUnreachable to NoMetricsReceived Alarm
2021-06-08 21:29:50 -04:00
Thomas-Leung2021
879abe3beb Changed AccessPointIsUnreachable to NoMetricsReceived Alarm 2021-06-08 17:51:12 -04:00
norm-traxler
796d657952 Merge pull request #112 from Telecominfraproject/WIFI-2543
WIFI-2543 Added delete methods and API endpoints for bulk deletion of client and client sessions
2021-06-08 11:45:10 -04:00
Kareem Dabbour
52ed5f6344 WIFI-2543 Added delete methods and API endpoints for bulk deletion of client and client sessions 2021-06-07 21:42:15 -04:00
Mike Hansen
f5869961b2 WIFI-2081: AP: ON_CHANNEL survey report sometimes has no information
Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-06-07 15:47:30 -04:00
Mike Hansen
f02cadbdc3 WIFI-2081: AP: ON_CHANNEL survey report sometimes has no information
Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-06-07 15:27:40 -04:00
Mike Hansen
c45cabf607 WIFI-2081: AP: ON_CHANNEL survey report sometimes has no information
Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-06-07 15:25:55 -04:00
norm-traxler
c9faf138da Merge pull request #111 from Telecominfraproject/WIFI-2525
WIFI-2525 Set default value for MaxAutoCellSize in RF Config
2021-06-03 18:05:57 -04:00
Lynn Shi
f6b96fc566 WIFI-2525 Set default value for MaxAutoCellSize in RF Config 2021-06-02 14:03:15 -04:00
Mike Hansen
a089e7b748 AP: ON_CHANNEL survey report sometimes has no information
Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-06-02 09:07:37 -04:00
norm-traxler
e790db2c2b Merge pull request #110 from Telecominfraproject/WIFI-2508
WIFI-2508 added delete endpoint for systemevents that are older than a given timestamp
2021-05-31 17:43:18 -04:00
Kareem Dabbour
b03dccc63f WIFI-2508 added delete endpoint for systemevents that are older than a given time stamp 2021-05-31 17:23:12 -04:00
norm-traxler
03eccfa448 Merge pull request #109 from Telecominfraproject/WIFI-2434
WIFI 2434: Update SDK master to use image tag 1.2.0-SNAPSHOT
2021-05-26 21:27:38 -04:00
Akshay Jagadish
18eeaffa13 Update SDK master to use image tag 1.2.0-SNAPSHOT 2021-05-26 17:59:41 -04:00
Mike Hansen
40aaeb33f4 WIFI-2425: RADSEC: Cloud doesn't send the radius secret as set in the radiusProxyConfigurations
Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-05-25 14:19:40 -04:00
Mike Hansen
fb4ff772e4 Merge branch 'master' of github.com:Telecominfraproject/wlan-cloud-services 2021-05-20 17:00:44 -04:00
Mike Hansen
d9076562d4 WIFI-2030: SDK Gateway/BE: Proxy-ARP service
Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-05-20 17:00:19 -04:00
norm-traxler
5ee517df81 Merge pull request #108 from Telecominfraproject/WIFI-2411-portal-user-event-payload
[NETEXP-2411] Adding new simplified PortalUser model for events
2021-05-20 16:35:13 -04:00
ralphlee
492406b56f [WIFI-2411] Updating yaml 2021-05-20 16:21:37 -04:00
ralphlee
c5648961c4 [NETEXP-2411] Adding new simplified PortalUser model for events 2021-05-20 13:25:52 -04:00
norm-traxler
c2540266d6 Merge pull request #107 from Telecominfraproject/WIFI-2398
WIFI-2398 Adding ClientMac to client session system events
2021-05-19 19:11:27 -04:00
Kareem Dabbour
35047c4fe7 WIFI-2398 Adding ClientMac to client session system events 2021-05-19 18:39:52 -04:00
Mike Hansen
deae54b4e9 WIFI-2397: Add ApcElectionEvent values to EquipmentProtocolStatusData
Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-05-19 17:30:45 -04:00
Mike Hansen
e957cf5a3b WIFI-2120: AP: Support 8x8 MIMO and Max Tx Power
Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-05-19 15:23:59 -04:00
Mike Hansen
09a9002962 Merge branch 'master' of github.com:Telecominfraproject/wlan-cloud-services 2021-05-19 13:10:06 -04:00
Mike Hansen
48040b3cba WIFI-2395: CloudBackend: Universal (Auto) Radio Mode For Configuration
Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-05-19 13:09:32 -04:00
Mike Hansen
a29b6636b8 Merge pull request #106 from Telecominfraproject/WIFI-2380
[WIFI-2380] Fix Event created timestamps for GW and Debug events.
2021-05-18 10:21:22 -04:00
Norm Traxler
9d558695ae [WIFI-2380] Fix Event created timestamps for GW and Debug events. 2021-05-17 15:29:08 -04:00
norm-traxler
81e100b210 Merge pull request #105 from Telecominfraproject/WIFI-2373-Add-getOrNull-API-to-location-service
Wifi 2373 add get or null api to location service
2021-05-13 12:08:46 -04:00
Thomas Currie
5fddfcbdc9 add unit test for new getOrNull api. 2021-05-13 11:50:49 -04:00
Thomas Currie
d86c4e2b0c Add getOrNull API to location service at endpoint /api/location/orNull . 2021-05-13 11:47:04 -04:00
Mike Hansen
5881a00657 Merge pull request #104 from Telecominfraproject/WIFI-2112
Wifi-2112 Support Equipment ApImpacting Provisioning Changes to AP
2021-05-11 09:44:04 -04:00
Lynn Shi
56b0dc08ba Merge branch 'master' of github.com:Telecominfraproject/wlan-cloud-services into WIFI-2112 2021-05-07 15:55:25 -04:00
Lynn Shi
5ec68adc99 WIFI-2112 Support Equipment ApImpacting Provisioning Changes to AP 2021-05-07 15:47:58 -04:00
Mike Hansen
0357f2d3a4 WIFI-2060: Service - Update equipment_ap profile with additional RadiusProxy data for accounting server and port
Adding acctSharedSecret

Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-05-07 10:47:30 -04:00
Mike Hansen
40c7439a60 Merge pull request #103 from Telecominfraproject/WIFI-2096
WIFI-2096 Add Portal support for cell size management
2021-05-07 10:24:03 -04:00
Lynn Shi
901f1c4517 WIFI-2096 Add Portal support for cell size management, fix test case 2021-05-06 16:44:44 -04:00
Lynn Shi
9c58fda584 WIFI-2096 Add Portal support for cell size management, throw exception for updateCellSizeAttributes on disabled autoCellSizeSelection 2021-05-06 11:06:47 -04:00
Lynn Shi
982ccfdd0e WIFI-2096 Add Portal support for cell size management 2021-05-05 16:18:42 -04:00
Mike Hansen
535df0041e Merge pull request #102 from Telecominfraproject/WIFI-2080
WIFI-2080 Add support for cell size attributes lightweight provisioni…
2021-05-04 12:52:33 -04:00
Lynn Shi
4b100290a7 WIFI-2080 Minor update 2021-04-30 14:08:54 -04:00
Lynn Shi
660326974c WIFI-2080 Update based on review comments 2021-04-30 13:49:58 -04:00
Mike Hansen
ce8ff0885f WIFI-2083: Fix Enum labels on Backend
Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-04-30 12:09:14 -04:00
norm-traxler
5c85997548 Merge pull request #99 from Telecominfraproject/WIFI-2074-equipment-search-profileid
[WIFI-2074] Adding profileId to /equipment/forCustomerWithFilter
2021-04-30 10:35:19 -04:00
Lynn Shi
1d77f9f7f2 WIFI-2080 Add support for cell size attributes lightweight provisioning changes to AP 2021-04-29 18:15:38 -04:00
ralphlee
ffc8ffe5e7 Merge branch 'master' of github.com:Telecominfraproject/wlan-cloud-services into WIFI-2074-equipment-search-profileid 2021-04-29 18:04:55 -04:00
norm-traxler
b0f76cb984 Merge pull request #101 from Telecominfraproject/WIFI-2077_2
[WIFI-2077] Fix for 2 alarm events created at the same time
2021-04-29 14:05:20 -04:00
Norm Traxler
dc88bc43b8 [WIFI-2077] Fix for 2 alarm events created at the same time 2021-04-29 13:29:35 -04:00
ralphlee
1e7e29540d Merge branch 'master' of github.com:Telecominfraproject/wlan-cloud-services into WIFI-2074-equipment-search-profileid 2021-04-29 12:14:06 -04:00
norm-traxler
ae23c46570 Merge pull request #100 from Telecominfraproject/WIFI-2077
[WIFI-2077] Fix location event timestamps and others
2021-04-29 11:03:36 -04:00
Norm Traxler
ab1695a183 [WIFI-2077] Fix location event timestamps and others 2021-04-28 17:28:53 -04:00
ralphlee
8e9db0c95e [WIFI-2074] Adding profileId to /equipment/forCustomerWithFilter 2021-04-27 14:54:59 -04:00
norm-traxler
a4232049d0 Merge pull request #98 from Telecominfraproject/WIFI-2068
[WIFI-2068] Change client session TTL to 24 hours
2021-04-27 10:51:16 -04:00
Mike Hansen
0a65d2e8ca WIFI-2067: Enable setting default reporting interval for on and off-channel wifi stats as VM args 2021-04-26 14:04:14 -04:00
Norm Traxler
dca76d8a6e [WIFI-2068] Change client session TTL to 24 hours 2021-04-26 12:00:28 -04:00
Mike Hansen
02d2e1cef4 WIFI-2060: Service - Update equipment_ap profile with additional RadiusProxy data for accounting server and port -- fix mistake for sharedSecret name in api file 2021-04-23 16:54:55 -04:00
Mike Hansen
dc0593d2ee WIFI-2060: Service - Update equipment_ap profile with additional RadiusProxy data for accounting server and port
WIFI-2061: Service - Update ApcMode enums to handle AP enum changes
2021-04-23 16:44:02 -04:00
norm-traxler
f923587d1e Merge pull request #97 from Telecominfraproject/WIFI-2043
[WIFI-2043] Fix Dashboard count summary
2021-04-20 19:39:05 -04:00
Norm Traxler
62369d210e [WIFI-2043] Fix Dashboard count summary 2021-04-20 19:27:56 -04:00
Mike Hansen
5c21848004 Merge branch 'master' of github.com:Telecominfraproject/wlan-cloud-services 2021-04-20 14:10:13 -04:00
norm-traxler
81616bb4aa Merge pull request #96 from Telecominfraproject/WIFI-2038-alarms-count-by-severity
[WIFI-2038] Adding countsBySeverity to AlarmCounts
2021-04-20 14:05:52 -04:00
Mike Hansen
f275c87290 WIFI-2040: ECW5211, ECW5410, WF194C, WF188N in backoff after upgrade 2021-04-20 14:03:39 -04:00
ralphlee
03f5522cac [WIFI-2038] Adding countsBySeverity to AlarmCounts 2021-04-20 10:42:30 -04:00
norm-traxler
0d5e4b4035 Merge pull request #94 from Telecominfraproject/WIFI-2025-acknowledged-alarm-counts
[WIFI-2025] Adding acknowledged filter to /portal/alarm/counts
2021-04-19 19:34:17 -04:00
ralphlee
a2b159943a [WIFI-2025] Removing unused alarm count tables from cassandra 2021-04-19 16:55:49 -04:00
ralphlee
1a85f976e4 Merge branch 'master' of github.com:Telecominfraproject/wlan-cloud-services into WIFI-2025-acknowledged-alarm-counts 2021-04-19 16:22:21 -04:00
ralphlee
82cdbdbc68 [WIFI-2025] Updating alarm cassandra to do client side filtering on alarm counts 2021-04-19 16:21:42 -04:00
norm-traxler
ae0bd303dd Merge pull request #95 from Telecominfraproject/WIFI-2026
WIFI-2026 Changed pom versions from 0.0.1-SNAPSHOT to 1.1.0-SNAPSHOT
2021-04-16 17:08:23 -04:00
Akshay Jagadish
782d221a70 WIFI-2026 Changed pom versions from 0.0.1-SNAPSHOT to 1.1.0-SNAPSHOT 2021-04-16 15:28:34 -04:00
ralphlee
bc5b0cad5a [WIFI-2025] Adding comments 2021-04-16 11:22:00 -04:00
ralphlee
16ff64b5b9 [WIFI-2025] Adding acknowledged filter to /portal/alarm/counts 2021-04-16 11:12:52 -04:00
Mike Hansen
9d639ccb0c WIFI-1994: NAS-ID use BSSID as default, to support EAP with 11r 2021-04-08 12:06:56 -04:00
Mike Hansen
e7fcaeffc7 Merge pull request #93 from Telecominfraproject/WIFI-1897
WIFI-1897 Add support for channel lightweight provisioning changes to AP
2021-03-30 12:12:25 -04:00
Lynn Shi
b7560bd519 WIFI-1897 update based on review comments 2021-03-30 11:55:28 -04:00
Lynn Shi
800fa9781c WIFI-1897 introduce EquipmentChannelsChangedEvent 2021-03-29 20:21:29 -04:00
Lynn Shi
d8bdb51b21 WIFI-1897 update based on review comments 2021-03-29 15:56:52 -04:00
Mike Hansen
ee5377c2af Merge pull request #92 from Telecominfraproject/WIFI-1893
WIFI-1893 Filter clientMac with address 0 (00:00:00:00:00:00) for Ser…
2021-03-29 10:08:15 -04:00
Lynn Shi
9d1e09c3c9 WIFI-1897 Add support for channel lightweight provisioning changes to AP 2021-03-28 17:13:50 -04:00
Dmitry Toptygin
23d5c9b513 WIFI-1896 - apply client-side filtering for the queries of system events and service metrics in cassandra datastore if the search parameters include locationIds. This is not a full solution. There is still a possibility that entries in the main tables could be overwritten if two location-level events of the same type are stored at exactly the same millisecond for the same customer.In order to fully address the issue, the primary keys of service_metric and wlan_system_event tables need to be changed to include the locationId, and the queries have to be adjusted accordingly, and more index tables would be needed to accommodate all possible combinations of search parameters 2021-03-26 18:27:36 -04:00
Lynn Shi
bf1d76a7c7 WIFI-1893 update based on review comments 2021-03-26 13:43:31 -04:00
Lynn Shi
8dd7c99d11 WIFI-1893 Filter clientMac with address 0 (00:00:00:00:00:00) for ServiceMetricDatastoreInMemory and SystemEventDatastoreInMemory 2021-03-26 11:39:01 -04:00
Mike Hansen
be6b3f69a3 WIFI-1851: Backend: Modelling manufacturing identity data
Pre work for removing ManufacturerName enum.
2021-03-25 15:13:26 -04:00
Mike Hansen
d37b5a55c2 WIFI-1851: Backend: Modelling manufacturing identity data
Pre work for removing ManufacturerName enum.
2021-03-25 14:31:50 -04:00
Mike Hansen
694bb8dc05 WIFI-1851: Backend: Modelling manufacturing identity data -- get EquipmentManufacturer by manufacturer name, not just enum name 2021-03-23 17:36:23 -04:00
Mike Hansen
32d4fb1197 WIFI-1732: Acct-Interim-Interval config not working when configured from radius 2021-03-23 15:12:43 -04:00
Mike Hansen
ac3b928a85 WIFI-1851: Backend: Modelling manufacturing identity data
WIFI-1850: Backend: API Support for manufacturing identity data
2021-03-23 14:39:34 -04:00
Dmitry Toptygin
1693b61c9f Merge branch 'master' of github.com:Telecominfraproject/wlan-cloud-services 2021-03-22 12:28:21 -04:00
Dmitry Toptygin
7a5cde65f2 WIFI-1877 - add topics in kafka where messages are partitioned by locationId - location_metrics and location_events 2021-03-22 12:27:59 -04:00
Mike Hansen
e43663a290 WIFI-1850: Backend: API Support for manufacturing identity data
WIFI-1851: Backend: Modelling manufacturing identity data
2021-03-19 14:43:06 -04:00
Mike Hansen
bd35d28c70 WIFI-1851: Backend: Modelling manufacturing identity data 2021-03-18 17:52:42 -04:00
Mike Hansen
be9fd94bfc WIFI-1808: AP-NOS Passpoint : Access type and internet value is not getting set Interworking element in Beacon for passpoint SSID
Change PasspointProfile qosMapSetConfiguration from Set to List to allow
for duplicate String values.
2021-03-18 09:39:53 -04:00
Mike Hansen
e9283c85d4 WIFI-1803: Design changes/refactoring based on SME feedback and AP design iterations 2021-03-16 12:02:47 -04:00
Mike Hansen
4cdd220874 WIFI-1803: Design changes/refactoring based on SME feedback and AP design iterations 2021-03-16 11:49:11 -04:00
Mike Hansen
eeeb1d1df6 WIFI-1692: Services: Event support for APC Election
update hash code and equals
2021-03-12 10:15:49 -05:00
Mike Hansen
b47fdab224 WIFI-1691: OpenAPI updates for APC/RadSEC Configuration 2021-03-12 10:13:59 -05:00
Mike Hansen
c93c8b01f2 WIFI-1692: Services: Event support for APC Election 2021-03-12 09:49:45 -05:00
ralphlee3
35620415fc [WIFI-1746] Updating the client SASI indexes to NonTokenizingAnalyzer (#91)
* [WIFI-1746] Updating the client SASI indexes to NonTokenizingAnalyzer

* [WIFI-1746] Updating index names

* [WIFI-1746] Specifying keyspace in client index delete
2021-03-11 17:00:35 -05:00
ralphlee3
659fc5bc9e WIFI 1739 client session forcustomer max items (#90)
* [WIFI-1739] Changing client forCustomer cassandra filtering to get 1 session per returned row

* [WIFI-1739] Fix spacing
2021-03-11 13:53:14 -05:00
Mike Hansen
818cfeb4f0 Merge branch 'master' of github.com:Telecominfraproject/wlan-cloud-services 2021-03-10 15:22:08 -05:00
Mike Hansen
6e6a7d53d3 WIFI-453: CloudSDK : Support for APC / Radius Proxy (Back End)
WIFI-1690: SSID Profile: APC/RadSEC enable/disable
 adding separate boolean for proxy and for radsec

WIFI-1698: Services - RadSEC certificates
 adding FileType and FileCategory for Certificates to use with
 ManagedFileInfo

WIFI-1689: AP Profile: APC/RadSEC Configuration information
 adding name and passphrase

WIFI-1691: OpenAPI updates for APC/RadSEC Configuration
2021-03-10 15:11:37 -05:00
Kareem Dabbour
dfa5b71a79 WIFI-1718 Updated getAverageSignalStrenght for neighboring APs (#87)
* WIFI-1718 Updated getAverageSignalStrenght for neighboring APs

* WIFI-1718 added null checks and used new overloaded averaging function

* WIFI-1718 updated to use lamda foreach

Co-authored-by: Kareem Dabbour <kareemdabbour@Kareems-MacBook-Pro.local>
2021-03-10 11:42:41 -05:00
ralphlee3
7b657acee7 Wifi 1729 alarm acknowledged update table (#88)
* [WIFI-1729] Adding update to alarm acknowledged cassandra tables and unit test

* [WIFI-1729] Removing comments
2021-03-10 09:54:31 -05:00
Mike Hansen
db5c1bb6c1 WIFI-1689: AP Profile: APC/RadSEC Configuration information 2021-03-09 10:27:23 -05:00
Mike Hansen
8c4ac0e282 WIFI-835: Captive Portal: User List Authentication feature does not work unless user list is pushed to cloud manually. Update AllCloudInOne for local testing 2021-03-05 15:43:16 -05:00
Mike Hansen
f71e6804fa WIFI-1690: SSID Profile: APC/RadSEC enable/disable 2021-03-04 15:29:32 -05:00
Mike Hansen
a3eac7942a WIFI-1689: AP Profile: APC/RadSEC Configuration information 2021-03-04 15:28:58 -05:00
Mike Hansen
e84f7b7765 WIFI-1691: OpenAPI updates for APC/RadSEC Configuration 2021-03-04 15:27:32 -05:00
Dmitry Toptygin
6d133ae448 fixed merge conflict in SsidConfiguration 2021-03-03 17:42:44 -05:00
tomrcurrie
f30d70ae81 Make constants BANDWIDTH_LIMIT_MAX, RADIUS_ACCOUNTING_SERVICE_INTERVAL_MIN, RADIUS_ACCOUNTING_SERVICE_INTERVAL_MAX, MAX_SSID_LENGTH configurable via system properties (#84) 2021-03-03 17:24:39 -05:00
Mike Hansen
d4a516199a Merge pull request #83 from Telecominfraproject/WIFI-1440-Radius-Accounting-Interval-is-not-configurable-by-user
UX/UI: Radius Accounting Interval is not configurable by user
2021-03-03 10:50:19 -05:00
tomrcurrie
ea94c14e63 WIFI-1616 SSID character length too long causes AP to not pull configuration (#79)
* Add validator for ClientSession, add ssid length check to validator.

* Add null check for ClientSessionDetaiks.Ssid in the validator

* Add some null checking for ClientSession. Undo auto formatting changes (hopefully)

* add ssid length validation to Profile provisioning. Improved exception and error behaviour for ssid error scenarios by using a RuntimeException and logger.

* remove ssid length validator from client session controller
2021-03-03 09:55:46 -05:00
Thomas Currie
a35e2deb84 Fix setter method to use actual provided value for radiusAcountingServiceInterval instead of default min value of 60. 2021-03-03 08:33:07 -05:00
ralphlee3
4c0d39860b [WIFI-1681] Adding macSubstring filter to client API forCustomer (#81)
* [WIFI-1681] Adding macSubstring filter to client API forCustomer

* [WIFI-1681] Client forCustomer to use client session API only when equipmentIds is present
2021-03-02 13:28:20 -05:00
ralphlee3
40a1e597c1 [WIFI-1687] client session api macsubtring empty (#82)
* [WIFI-1687] Adding empty check for macSubstring

* [WIFI-1687] Adding empty checks to rdbms and inmemory
2021-03-02 12:24:01 -05:00
ralphlee3
b10b511c64 [WIFI-1358] Adding macSubstring to client session API forCustomer (#56)
* [WIFI-1358] Initial commit

* [WIFI-1358] Fixing cassandra indexing and added unit tests

* [WIFI-1358] Updated openapi yaml

* [WIFI-1358] Adding customerId filter to macSubstring query to Cassandra

* [WIFI-1358] Adding macAddressString column to postgresql table if not exists

* [WIFI-1358] Updating client session remote unit tests

* [WIFI-1358] Reorder client postgresql sql table initialization lines
2021-03-01 15:22:16 -05:00
Dmitry Toptygin
3ee708925f WIFI-1609 fixed comments in the cassandra schema for alarms 2021-02-25 17:14:40 -05:00
Mike Hansen
e7b40a1be6 Merge pull request #77 from Telecominfraproject/WIFI-1658-2
WIFI-1658 correct one field name for EquipmentChannelStatusData in yaml
2021-02-25 14:44:56 -05:00
Lynn Shi
b00fb6d287 WIFI-1658 correct one field name for EquipmentChannelStatusData in yaml 2021-02-25 14:39:55 -05:00
Mike Hansen
6e8977365a Merge pull request #76 from Telecominfraproject/WIFI-1658
WIFI-1658 Add Channel Number Status Support
2021-02-25 12:00:24 -05:00
Lynn Shi
ea794940a9 WIFI-1658 update based on review comments 2021-02-25 11:54:01 -05:00
ralphlee3
cdebd4485e [WIFI-1609] alarm forcustomer acknowledged filter (#69)
* [WIFI-1609] Added acknowledged flag to forCustomer parameters and support in datastore

* [WIFI-1609] Ignore cassandra tests

* [WIFI-1609] Added handling acknowledged filter with equipmentId, alarmCode, and timestamp
2021-02-25 10:41:49 -05:00
Lynn Shi
272b6836a1 WIFI-1658 Add Channel Number Status Support 2021-02-25 09:03:54 -05:00
Dmitry Toptygin
074f51ea8d WIFI-1652 - implement performance counters for ovsdb, cassandra, and kafka 2021-02-23 19:40:01 -05:00
AkshayJagadish-ne
f26dc9758b WIFI-1641: Dashboard: Number of "In service APs" is not accurate (#75) 2021-02-23 09:41:26 -05:00
640 changed files with 10551 additions and 32640 deletions

View File

@@ -0,0 +1 @@
/target/

View File

@@ -1,10 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
@@ -16,7 +15,7 @@
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>adoption-metrics-datastore-interface</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>

View File

@@ -0,0 +1 @@
/target/

View File

@@ -1,10 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
@@ -16,19 +15,19 @@
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-datastore-inmemory</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>adoption-metrics-datastore-interface</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>adoption-metrics-datastore-common-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
</dependencies>

View File

@@ -0,0 +1 @@
/target/

View File

@@ -1,10 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
@@ -16,12 +15,12 @@
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>adoption-metrics-models</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-exceptions</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
</dependencies>

View File

@@ -0,0 +1 @@
/target/

View File

@@ -1,10 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
@@ -16,26 +15,26 @@
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-jdbc</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>adoption-metrics-datastore-interface</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-jdbc-tests</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>adoption-metrics-datastore-common-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>

1
adoption-metrics-models/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target/

View File

@@ -1,10 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
@@ -16,7 +15,7 @@
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-models</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
</dependencies>

View File

@@ -0,0 +1 @@
/target/

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
@@ -15,7 +15,7 @@
<dependency>
<artifactId>adoption-metrics-models</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
</dependencies>

View File

@@ -0,0 +1 @@
/target/

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
@@ -16,13 +16,13 @@
<dependency>
<artifactId>adoption-metrics-service-interface</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>adoption-metrics-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
</dependencies>

View File

@@ -0,0 +1 @@
/target/

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
@@ -15,41 +15,41 @@
<dependency>
<artifactId>adoption-metrics-service-interface</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>base-client</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<!-- Dependencies for the unit tests -->
<dependency>
<artifactId>base-remote-tests</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<artifactId>adoption-metrics-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<artifactId>adoption-metrics-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<artifactId>cloud-event-dispatcher-empty</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>

1
adoption-metrics-service/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target/

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
@@ -15,29 +15,29 @@
<dependency>
<artifactId>base-container</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>cloud-event-dispatcher-interface</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>adoption-metrics-models</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>adoption-metrics-datastore-interface</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>adoption-metrics-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
@@ -45,7 +45,7 @@
<dependency>
<artifactId>cloud-event-dispatcher-empty</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>

1
adoption-metrics-sp/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target/

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
@@ -15,25 +15,25 @@
<dependency>
<artifactId>base-stream-consumer</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>service-metric-models</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>system-event-models</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>adoption-metrics-service-interface</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
</dependencies>

1
alarm-datastore-cassandra/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target/

View File

@@ -1,10 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
@@ -16,26 +15,26 @@
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-cassandra</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>alarm-datastore-interface</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-cassandra-tests</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>alarm-datastore-common-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>

View File

@@ -7,12 +7,9 @@ import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import javax.annotation.PostConstruct;
@@ -36,6 +33,7 @@ import com.telecominfraproject.wlan.alarm.models.AlarmCounts;
import com.telecominfraproject.wlan.core.model.pagination.ColumnAndSort;
import com.telecominfraproject.wlan.core.model.pagination.PaginationContext;
import com.telecominfraproject.wlan.core.model.pagination.PaginationResponse;
import com.telecominfraproject.wlan.core.server.cassandra.CassandraUtils;
import com.telecominfraproject.wlan.core.server.cassandra.RowMapper;
import com.telecominfraproject.wlan.datastore.exceptions.DsConcurrentModificationException;
import com.telecominfraproject.wlan.datastore.exceptions.DsEntityNotFoundException;
@@ -118,14 +116,15 @@ public class AlarmDatastoreCassandra implements AlarmDatastore {
" from "+TABLE_NAME+" " +
" where customerId = ? and equipmentId = ? and alarmCode = ? and createdTimestamp = ?";
private static final String CQL_GET_ALL_NO_DETAILS =
"select customerId, equipmentId, alarmCode, createdTimestamp from alarm " ;
private static final String CQL_GET_BY_CUSTOMER_ID =
"select " + ALL_COLUMNS +
" from " + TABLE_NAME + " " +
" where customerId = ? ";
private static final String CQL_GET_ALL =
"select " + ALL_COLUMNS +
" from " + TABLE_NAME + " ";
private static final String CQL_GET_LASTMOD_BY_ID =
"select lastModifiedTimestamp " +
" from "+TABLE_NAME+" " +
@@ -151,27 +150,28 @@ public class AlarmDatastoreCassandra implements AlarmDatastore {
+ " IF lastModifiedTimestamp = ? "
;
private static final String CQL_COUNTS_BY_EQUIPMENT_AND_ALARM_CODE_HEADER = "select equipmentId, alarmCode, count(1) from alarm where customerId = ? ";
private static final String CQL_COUNTS_BY_EQUIPMENT_AND_ALARM_CODE_FOOTER = " group by equipmentId, alarmCode";
private static final String CQL_INSERT_INTO_BY_ACKNOWLEDGED_TABLE = "insert into alarm_by_acknowledged(customerId, equipmentId, alarmCode, createdTimestamp, acknowledged) values ( ?, ?, ?, ?, ?) ";
private static final String CQL_DELETE_FROM_BY_ACKNOWLEDGED_TABLE = "delete from alarm_by_acknowledged where customerId = ? and equipmentId = ? and alarmCode = ? and createdTimestamp = ? and acknowledged = ? ";
private static final String CQL_INSERT_INTO_BY_ACKNOWLEDGED_EQUIPMENTID_TABLE = "insert into alarm_by_acknowledged_equipmentId(customerId, equipmentId, alarmCode, createdTimestamp, acknowledged) values ( ?, ?, ?, ?, ?) ";
private static final String CQL_DELETE_FROM_BY_ACKNOWLEDGED_EQUIPMENTID_TABLE = "delete from alarm_by_acknowledged_equipmentId where customerId = ? and equipmentId = ? and alarmCode = ? and createdTimestamp = ? and acknowledged = ? ";
private static final String CQL_INSERT_INTO_BY_ACKNOWLEDGED_ALARMCODE_TABLE = "insert into alarm_by_acknowledged_alarmCode(customerId, equipmentId, alarmCode, createdTimestamp, acknowledged) values ( ?, ?, ?, ?, ?) ";
private static final String CQL_DELETE_FROM_BY_ACKNOWLEDGED_ALARMCODE_TABLE = "delete from alarm_by_acknowledged_alarmCode where customerId = ? and equipmentId = ? and alarmCode = ? and createdTimestamp = ? and acknowledged = ? ";
private static final String CQL_INSERT_INTO_BY_ACKNOWLEDGED_TIMESTAMP_TABLE = "insert into alarm_by_acknowledged_timestamp(customerId, equipmentId, alarmCode, createdTimestamp, acknowledged) values ( ?, ?, ?, ?, ?) ";
private static final String CQL_DELETE_FROM_BY_ACKNOWLEDGED_TIMESTAMP_TABLE = "delete from alarm_by_acknowledged_timestamp where customerId = ? and equipmentId = ? and alarmCode = ? and createdTimestamp = ? and acknowledged = ? ";
//Cassandra has a difficulty running this:
// message="Group by currently only support groups of columns following their declared order in the PRIMARY KEY"
//private static final String CQL_COUNTS_BY_ALARM_CODE_HEADER = "select alarmCode, count(1) from alarm where customerId = ? ";
//private static final String CQL_COUNTS_BY_ALARM_CODE_FOOTER = " group by alarmCode";
private static final String CQL_INCREMENT_EQUIPMENT_ALARM_COUNT = "update alarm_counts_by_equipment set alarmCount = alarmCount + 1 where customerId = ? and equipmentId = ? and alarmCode = ? ";
private static final String CQL_DECREMENT_EQUIPMENT_ALARM_COUNT = "update alarm_counts_by_equipment set alarmCount = alarmCount - 1 where customerId = ? and equipmentId = ? and alarmCode = ? ";
// CQL statements for counts
private static final String CQL_GET_CUSTOMER_ALARM_COUNT_BY_CUSTOMER_ID = "select equipmentId, alarmCode from alarm where customerId = ? ";
private static final String CQL_GET_EQUIPMENT_ALARM_COUNT_BY_CUSTOMER_ID = "select equipmentId, alarmCode, alarmCount from alarm_counts_by_equipment where customerId = ? ";
private static final String CQL_INCREMENT_CUSTOMER_ALARM_COUNT = "update alarm_counts_by_customer set alarmCount = alarmCount + 1 where customerId = ? and alarmCode = ? ";
private static final String CQL_DECREMENT_CUSTOMER_ALARM_COUNT = "update alarm_counts_by_customer set alarmCount = alarmCount - 1 where customerId = ? and alarmCode = ? ";
private static final String CQL_GET_CUSTOMER_ACKNOWLEDGED_ALARM_COUNT_BY_CUSTOMER_ID = "select equipmentId, alarmCode from alarm_by_acknowledged where customerId = ? and acknowledged = ? ";
private static final String CQL_GET_CUSTOMER_ALARM_COUNT_BY_CUSTOMER_ID = "select alarmCode, alarmCount from alarm_counts_by_customer where customerId = ? ";
private static final String CQL_UPDATE_CUSTOMER_ALARM_COUNT = "update alarm_counts_by_customer set alarmCount = alarmCount + ? where customerId = ? and alarmCode = ? ";
private static final String CQL_UPDATE_EQUIPMENT_ALARM_COUNT = "update alarm_counts_by_equipment set alarmCount = alarmCount + ? where customerId = ? and equipmentId = ? and alarmCode = ? ";
private static final RowMapper<Alarm> alarmRowMapper = new AlarmRowMapper();
@@ -179,38 +179,39 @@ public class AlarmDatastoreCassandra implements AlarmDatastore {
private CqlSession cqlSession;
private PreparedStatement preparedStmt_getOrNull;
private PreparedStatement preparedStmt_getAllNoDetails;
private PreparedStatement preparedStmt_create;
private PreparedStatement preparedStmt_update;
private PreparedStatement preparedStmt_getLastmod;
private PreparedStatement preparedStmt_delete;
private PreparedStatement preparedStmt_deleteByEquipment;
private PreparedStatement preparedStmt_incrementAlarmCountByEquipment;
private PreparedStatement preparedStmt_decrementAlarmCountByEquipment;
private PreparedStatement preparedStmt_incrementAlarmCountByCustomer;
private PreparedStatement preparedStmt_decrementAlarmCountByCustomer;
private PreparedStatement preparedStmt_updateAlarmCountByEquipment;
private PreparedStatement preparedStmt_updateAlarmCountByCustomer;
// filter by acknowledged statements
private PreparedStatement preparedStmt_insertIntoAlarmByAcknowledged;
private PreparedStatement preparedStmt_deleteFromAlarmByAcknowledged;
private PreparedStatement preparedStmt_insertIntoAlarmByAcknowledgedEquipmentId;
private PreparedStatement preparedStmt_deleteFromAlarmByAcknowledgedEquipmentId;
private PreparedStatement preparedStmt_insertIntoAlarmByAcknowledgedAlarmCode;
private PreparedStatement preparedStmt_deleteFromAlarmByAcknowledgedAlarmCode;
private PreparedStatement preparedStmt_insertIntoAlarmByAcknowledgedTimestamp;
private PreparedStatement preparedStmt_deleteFromAlarmByAcknowledgedTimestamp;
@PostConstruct
private void postConstruct(){
preparedStmt_getOrNull = cqlSession.prepare(CQL_GET_BY_ID);
preparedStmt_getAllNoDetails = cqlSession.prepare(CQL_GET_ALL_NO_DETAILS);
preparedStmt_create = cqlSession.prepare(CQL_INSERT);
preparedStmt_update = cqlSession.prepare(CQL_UPDATE);
preparedStmt_getLastmod = cqlSession.prepare(CQL_GET_LASTMOD_BY_ID);
preparedStmt_delete = cqlSession.prepare(CQL_DELETE);
preparedStmt_deleteByEquipment = cqlSession.prepare(CQL_DELETE_BY_EQUIPMENT);
preparedStmt_incrementAlarmCountByEquipment = cqlSession.prepare(CQL_INCREMENT_EQUIPMENT_ALARM_COUNT);
preparedStmt_decrementAlarmCountByEquipment = cqlSession.prepare(CQL_DECREMENT_EQUIPMENT_ALARM_COUNT);
preparedStmt_incrementAlarmCountByCustomer= cqlSession.prepare(CQL_INCREMENT_CUSTOMER_ALARM_COUNT);
preparedStmt_decrementAlarmCountByCustomer = cqlSession.prepare(CQL_DECREMENT_CUSTOMER_ALARM_COUNT);
preparedStmt_updateAlarmCountByEquipment = cqlSession.prepare(CQL_UPDATE_EQUIPMENT_ALARM_COUNT);
preparedStmt_updateAlarmCountByCustomer= cqlSession.prepare(CQL_UPDATE_CUSTOMER_ALARM_COUNT);
preparedStmt_insertIntoAlarmByAcknowledged = cqlSession.prepare(CQL_INSERT_INTO_BY_ACKNOWLEDGED_TABLE);
preparedStmt_deleteFromAlarmByAcknowledged = cqlSession.prepare(CQL_DELETE_FROM_BY_ACKNOWLEDGED_TABLE);
preparedStmt_insertIntoAlarmByAcknowledgedEquipmentId = cqlSession.prepare(CQL_INSERT_INTO_BY_ACKNOWLEDGED_EQUIPMENTID_TABLE);
preparedStmt_deleteFromAlarmByAcknowledgedEquipmentId = cqlSession.prepare(CQL_DELETE_FROM_BY_ACKNOWLEDGED_EQUIPMENTID_TABLE);
preparedStmt_insertIntoAlarmByAcknowledgedAlarmCode = cqlSession.prepare(CQL_INSERT_INTO_BY_ACKNOWLEDGED_ALARMCODE_TABLE);
preparedStmt_deleteFromAlarmByAcknowledgedAlarmCode = cqlSession.prepare(CQL_DELETE_FROM_BY_ACKNOWLEDGED_ALARMCODE_TABLE);
preparedStmt_insertIntoAlarmByAcknowledgedTimestamp = cqlSession.prepare(CQL_INSERT_INTO_BY_ACKNOWLEDGED_TIMESTAMP_TABLE);
preparedStmt_deleteFromAlarmByAcknowledgedTimestamp = cqlSession.prepare(CQL_DELETE_FROM_BY_ACKNOWLEDGED_TIMESTAMP_TABLE);
}
@@ -244,17 +245,38 @@ public class AlarmDatastoreCassandra implements AlarmDatastore {
));
LOG.debug("Stored Alarm {}", alarm);
//update alarm count
cqlSession.execute(preparedStmt_incrementAlarmCountByEquipment.bind(
//insert entry into acknowledged tables
cqlSession.execute(preparedStmt_insertIntoAlarmByAcknowledged.bind(
alarm.getCustomerId(),
alarm.getEquipmentId(),
alarm.getAlarmCode().getId()
alarm.getAlarmCode().getId(),
alarm.getCreatedTimestamp(),
alarm.isAcknowledged()
));
cqlSession.execute(preparedStmt_incrementAlarmCountByCustomer.bind(
cqlSession.execute(preparedStmt_insertIntoAlarmByAcknowledgedEquipmentId.bind(
alarm.getCustomerId(),
alarm.getAlarmCode().getId()
alarm.getEquipmentId(),
alarm.getAlarmCode().getId(),
alarm.getCreatedTimestamp(),
alarm.isAcknowledged()
));
cqlSession.execute(preparedStmt_insertIntoAlarmByAcknowledgedAlarmCode.bind(
alarm.getCustomerId(),
alarm.getEquipmentId(),
alarm.getAlarmCode().getId(),
alarm.getCreatedTimestamp(),
alarm.isAcknowledged()
));
cqlSession.execute(preparedStmt_insertIntoAlarmByAcknowledgedTimestamp.bind(
alarm.getCustomerId(),
alarm.getEquipmentId(),
alarm.getAlarmCode().getId(),
alarm.getCreatedTimestamp(),
alarm.isAcknowledged()
));
return alarm.clone();
@@ -309,6 +331,8 @@ public class AlarmDatastoreCassandra implements AlarmDatastore {
@Override
public Alarm update(Alarm alarm) {
Alarm original = getOrNull(alarm.getCustomerId(), alarm.getEquipmentId(), alarm.getAlarmCode(), alarm.getCreatedTimestamp());
long newLastModifiedTs = System.currentTimeMillis();
long incomingLastModifiedTs = alarm.getLastModifiedTimestamp();
@@ -378,6 +402,78 @@ public class AlarmDatastoreCassandra implements AlarmDatastore {
}
}
// if the acknowledged boolean value has been updated (typically false -> true, but opposite could happen too)
// then we need to update the values in the supporting acknowledged tables as well.
// Since they are part of the primary key to properly filter, we cannot simply update the acknowledged value in these tables.
// We need to delete those rows (in acknowledged tables) and recreate them with the new acknowledged value (in alarm)
if (original.isAcknowledged() != alarm.isAcknowledged()) {
//delete entry into acknowledged tables
cqlSession.execute(preparedStmt_deleteFromAlarmByAcknowledged.bind(
original.getCustomerId(),
original.getEquipmentId(),
original.getAlarmCode().getId(),
original.getCreatedTimestamp(),
original.isAcknowledged()
));
cqlSession.execute(preparedStmt_deleteFromAlarmByAcknowledgedEquipmentId.bind(
original.getCustomerId(),
original.getEquipmentId(),
original.getAlarmCode().getId(),
original.getCreatedTimestamp(),
original.isAcknowledged()
));
cqlSession.execute(preparedStmt_deleteFromAlarmByAcknowledgedAlarmCode.bind(
original.getCustomerId(),
original.getEquipmentId(),
original.getAlarmCode().getId(),
original.getCreatedTimestamp(),
original.isAcknowledged()
));
cqlSession.execute(preparedStmt_deleteFromAlarmByAcknowledgedTimestamp.bind(
original.getCustomerId(),
original.getEquipmentId(),
original.getAlarmCode().getId(),
original.getCreatedTimestamp(),
original.isAcknowledged()
));
// recreate rows in supporting acknowledged tables with the new acknowledged value
cqlSession.execute(preparedStmt_insertIntoAlarmByAcknowledged.bind(
alarm.getCustomerId(),
alarm.getEquipmentId(),
alarm.getAlarmCode().getId(),
alarm.getCreatedTimestamp(),
alarm.isAcknowledged()
));
cqlSession.execute(preparedStmt_insertIntoAlarmByAcknowledgedEquipmentId.bind(
alarm.getCustomerId(),
alarm.getEquipmentId(),
alarm.getAlarmCode().getId(),
alarm.getCreatedTimestamp(),
alarm.isAcknowledged()
));
cqlSession.execute(preparedStmt_insertIntoAlarmByAcknowledgedAlarmCode.bind(
alarm.getCustomerId(),
alarm.getEquipmentId(),
alarm.getAlarmCode().getId(),
alarm.getCreatedTimestamp(),
alarm.isAcknowledged()
));
cqlSession.execute(preparedStmt_insertIntoAlarmByAcknowledgedTimestamp.bind(
alarm.getCustomerId(),
alarm.getEquipmentId(),
alarm.getAlarmCode().getId(),
alarm.getCreatedTimestamp(),
alarm.isAcknowledged()
));
}
//make a copy so that we don't accidentally update caller's version by reference
Alarm alarmCopy = alarm.clone();
@@ -398,17 +494,38 @@ public class AlarmDatastoreCassandra implements AlarmDatastore {
cqlSession.execute(preparedStmt_delete.bind(customerId, equipmentId, alarmCode.getId(), createdTimestamp));
LOG.debug("Deleted Alarm {}", ret);
//update alarm count
cqlSession.execute(preparedStmt_decrementAlarmCountByEquipment.bind(
//delete entry into acknowledged tables
cqlSession.execute(preparedStmt_deleteFromAlarmByAcknowledged.bind(
ret.getCustomerId(),
ret.getEquipmentId(),
ret.getAlarmCode().getId()
ret.getAlarmCode().getId(),
ret.getCreatedTimestamp(),
ret.isAcknowledged()
));
cqlSession.execute(preparedStmt_decrementAlarmCountByCustomer.bind(
cqlSession.execute(preparedStmt_deleteFromAlarmByAcknowledgedEquipmentId.bind(
ret.getCustomerId(),
ret.getAlarmCode().getId()
ret.getEquipmentId(),
ret.getAlarmCode().getId(),
ret.getCreatedTimestamp(),
ret.isAcknowledged()
));
cqlSession.execute(preparedStmt_deleteFromAlarmByAcknowledgedAlarmCode.bind(
ret.getCustomerId(),
ret.getEquipmentId(),
ret.getAlarmCode().getId(),
ret.getCreatedTimestamp(),
ret.isAcknowledged()
));
cqlSession.execute(preparedStmt_deleteFromAlarmByAcknowledgedTimestamp.bind(
ret.getCustomerId(),
ret.getEquipmentId(),
ret.getAlarmCode().getId(),
ret.getCreatedTimestamp(),
ret.isAcknowledged()
));
return ret;
@@ -424,153 +541,43 @@ public class AlarmDatastoreCassandra implements AlarmDatastore {
LOG.debug("Deleted Alarms {}", ret);
ret.forEach(al -> {
//TODO: replace with one update of a counter
//update alarm count
cqlSession.execute(preparedStmt_decrementAlarmCountByEquipment.bind(
//delete entry into acknowledged tables
cqlSession.execute(preparedStmt_deleteFromAlarmByAcknowledged.bind(
al.getCustomerId(),
al.getEquipmentId(),
al.getAlarmCode().getId()
al.getAlarmCode().getId(),
al.getCreatedTimestamp(),
al.isAcknowledged()
));
cqlSession.execute(preparedStmt_decrementAlarmCountByCustomer.bind(
cqlSession.execute(preparedStmt_deleteFromAlarmByAcknowledgedEquipmentId.bind(
al.getCustomerId(),
al.getAlarmCode().getId()
));
al.getEquipmentId(),
al.getAlarmCode().getId(),
al.getCreatedTimestamp(),
al.isAcknowledged()
));
cqlSession.execute(preparedStmt_deleteFromAlarmByAcknowledgedAlarmCode.bind(
al.getCustomerId(),
al.getEquipmentId(),
al.getAlarmCode().getId(),
al.getCreatedTimestamp(),
al.isAcknowledged()
));
cqlSession.execute(preparedStmt_deleteFromAlarmByAcknowledgedTimestamp.bind(
al.getCustomerId(),
al.getEquipmentId(),
al.getAlarmCode().getId(),
al.getCreatedTimestamp(),
al.isAcknowledged()
));
});
return ret;
}
@Override
public void resetAlarmCounters() {
LOG.debug("Resetting Alarm counters ");
//count real alarms per-customer and per equipment
Map<Integer, AlarmCounts> alarmCountsPerCustomerMap = new HashMap<>();
//select customerId, equipmentId, alarmCode, createdTimestamp from alarm
ResultSet rs = cqlSession.execute(preparedStmt_getAllNoDetails.bind());
rs.forEach(row -> {
int customerId = row.getInt(0);
long equipmentId = row.getLong(1);
AlarmCode alarmCode = AlarmCode.getById(row.getInt(2));
AlarmCounts alarmCounts = alarmCountsPerCustomerMap.get(customerId);
if(alarmCounts == null) {
alarmCounts = new AlarmCounts();
alarmCounts.setCustomerId(customerId);
alarmCountsPerCustomerMap.put(customerId, alarmCounts);
}
alarmCounts.addToCounter(equipmentId, alarmCode, 1);
});
//read existing counters alarms per-customer
Map<Integer, AlarmCounts> existingCustomerCountsPerCustomerMap = new HashMap<>();
rs = cqlSession.execute(cqlSession.prepare("select customerid, alarmcode, alarmcount from alarm_counts_by_customer ").bind());
rs.forEach(row -> {
int customerId = row.getInt(0);
AlarmCode alarmCode = AlarmCode.getById(row.getInt(1));
long count = row.getLong(2);
AlarmCounts alarmCounts = existingCustomerCountsPerCustomerMap.get(customerId);
if(alarmCounts == null) {
alarmCounts = new AlarmCounts();
alarmCounts.setCustomerId(customerId);
existingCustomerCountsPerCustomerMap.put(customerId, alarmCounts);
}
alarmCounts.addToCounter(0, alarmCode, (int) count);
});
//read existing counters alarms per equipment
Map<Integer, AlarmCounts> existingEquipmentCountsPerCustomerMap = new HashMap<>();
rs = cqlSession.execute(cqlSession.prepare("select customerid, equipmentid, alarmcode, alarmcount from alarm_counts_by_equipment ").bind());
rs.forEach(row -> {
int customerId = row.getInt(0);
long equipmentId = row.getLong(1);
AlarmCode alarmCode = AlarmCode.getById(row.getInt(2));
long count = row.getLong(3);
AlarmCounts alarmCounts = existingEquipmentCountsPerCustomerMap.get(customerId);
if(alarmCounts == null) {
alarmCounts = new AlarmCounts();
alarmCounts.setCustomerId(customerId);
existingEquipmentCountsPerCustomerMap.put(customerId, alarmCounts);
}
alarmCounts.addToCounter(equipmentId, alarmCode, (int) count);
});
//set existing counters per customer - first to 0, then to new computed values
existingCustomerCountsPerCustomerMap.values().forEach(customerCounts -> {
AlarmCounts realAlarmCounts = alarmCountsPerCustomerMap.get(customerCounts.getCustomerId());
customerCounts.getTotalCountsPerAlarmCodeMap().forEach((alarmCode, existingCount) -> {
int realCount = realAlarmCounts != null ? realAlarmCounts.getTotalCountsPerAlarmCodeMap().getOrDefault(alarmCode, new AtomicInteger(0)).get(): 0;
//update alarm_counts_by_customer set alarmCount = alarmCount + ? where customerId = ? and alarmCode = ?
cqlSession.execute(preparedStmt_updateAlarmCountByCustomer.bind( (long) (0L - existingCount.get() + realCount), customerCounts.getCustomerId(), alarmCode.getId()));
});
});
//set existing counters per equipment - first to 0, then to new computed values
existingEquipmentCountsPerCustomerMap.values().forEach(customerCounts -> {
int customerId = customerCounts.getCustomerId();
AlarmCounts realAlarmCounts = alarmCountsPerCustomerMap.get(customerId);
customerCounts.getCountsPerEquipmentIdMap().forEach((eqId, perAlarmCodeMap) -> {
perAlarmCodeMap.forEach((alarmCode, existingCount) -> {
int realCount = 0;
if(realAlarmCounts != null && realAlarmCounts.getCountsPerEquipmentIdMap().get(eqId)!=null ) {
realCount = realAlarmCounts.getCountsPerEquipmentIdMap().get(eqId).getOrDefault(alarmCode, new AtomicInteger(0)).get();
}
//update alarm_counts_by_equipment set alarmCount = alarmCount + ? where customerId = ? and equipmentId = ? and alarmCode = ?
cqlSession.execute(preparedStmt_updateAlarmCountByEquipment.bind( (long) ( 0L - existingCount.get() + realCount), customerId, eqId, alarmCode.getId()));
});
});
});
//process new customer counts that are not present in existing counts
alarmCountsPerCustomerMap.values().forEach(customerCounts -> {
AlarmCounts existingAlarmCounts = existingCustomerCountsPerCustomerMap.get(customerCounts.getCustomerId());
if(existingAlarmCounts == null) {
customerCounts.getTotalCountsPerAlarmCodeMap().forEach((alarmCode, newCount) -> {
//update alarm_counts_by_customer set alarmCount = alarmCount + ? where customerId = ? and alarmCode = ?
cqlSession.execute(preparedStmt_updateAlarmCountByCustomer.bind((long) newCount.get(), customerCounts.getCustomerId(), alarmCode.getId()));
});
}
});
//process new equipment counts that are not present in existing counts
alarmCountsPerCustomerMap.values().forEach(customerCounts -> {
int customerId = customerCounts.getCustomerId();
AlarmCounts existingAlarmCounts = existingEquipmentCountsPerCustomerMap.get(customerId);
customerCounts.getCountsPerEquipmentIdMap().forEach((eqId, perAlarmCodeMap) -> {
if(existingAlarmCounts == null || existingAlarmCounts.getCountsPerEquipmentIdMap().get(eqId) == null) {
perAlarmCodeMap.forEach((alarmCode, existingCount) -> {
//update alarm_counts_by_equipment set alarmCount = alarmCount + ? where customerId = ? and equipmentId = ? and alarmCode = ?
cqlSession.execute(preparedStmt_updateAlarmCountByEquipment.bind((long) existingCount.get(), customerId, eqId, alarmCode.getId()));
});
}
});
});
LOG.debug("Completed resetting Alarm counters ");
}
@Override
public List<Alarm> get(int customerId, Set<Long> equipmentIds, Set<AlarmCode> alarmCodes,
@@ -651,11 +658,12 @@ public class AlarmDatastoreCassandra implements AlarmDatastore {
return ret;
}
private static enum FilterOptions{ customer_only, customer_and_equipment, customer_and_alarmCode, customer_and_timestamp, customer_and_acknowledged }
@Override
public PaginationResponse<Alarm> getForCustomer(int customerId, Set<Long> equipmentIds,
Set<AlarmCode> alarmCodes, long createdAfterTimestamp, List<ColumnAndSort> sortBy,
Set<AlarmCode> alarmCodes, long createdAfterTimestamp, Boolean acknowledged, List<ColumnAndSort> sortBy,
PaginationContext<Alarm> context) {
PaginationResponse<Alarm> ret = new PaginationResponse<>();
ret.setContext(context.clone());
@@ -671,7 +679,8 @@ public class AlarmDatastoreCassandra implements AlarmDatastore {
LOG.debug("Looking up Alarms for customer {} with last returned page number {}",
customerId, context.getLastReturnedPageNumber());
String query = CQL_GET_BY_CUSTOMER_ID;
String query_head = CQL_GET_BY_CUSTOMER_ID;
String query = "";
if((alarmCodes==null || alarmCodes.isEmpty()) && createdAfterTimestamp>0) {
//if alarm codes not specified (means all) - explicitly list all of them, otherwise the following exception if thrown:
@@ -680,6 +689,8 @@ public class AlarmDatastoreCassandra implements AlarmDatastore {
alarmCodes = new HashSet<>(Arrays.asList(AlarmCode.validValues()));
}
FilterOptions filterOptions = FilterOptions.customer_only;
// add filters for the query
ArrayList<Object> queryArgs = new ArrayList<>();
queryArgs.add(customerId);
@@ -688,39 +699,52 @@ public class AlarmDatastoreCassandra implements AlarmDatastore {
if (equipmentIds != null && !equipmentIds.isEmpty()) {
queryArgs.addAll(equipmentIds);
StringBuilder strb = new StringBuilder(100);
strb.append("and equipmentId in (");
for (int i = 0; i < equipmentIds.size(); i++) {
strb.append("?");
if (i < equipmentIds.size() - 1) {
strb.append(",");
}
}
strb.append(") ");
query += " and equipmentId in" + CassandraUtils.getBindPlaceholders(equipmentIds);
query += strb.toString();
filterOptions = FilterOptions.customer_and_equipment;
}
//add alarmCodes filters
if (alarmCodes != null && !alarmCodes.isEmpty()) {
alarmCodes.forEach(ac -> queryArgs.add(ac.getId()));
StringBuilder strb = new StringBuilder(100);
strb.append("and alarmCode in (");
for (int i = 0; i < alarmCodes.size(); i++) {
strb.append("?");
if (i < alarmCodes.size() - 1) {
strb.append(",");
}
}
strb.append(") ");
query += " and alarmCode in" + CassandraUtils.getBindPlaceholders(alarmCodes);
query += strb.toString();
filterOptions = FilterOptions.customer_and_alarmCode;
}
if(createdAfterTimestamp > 0) {
query += " and createdTimestamp > ?" ;
queryArgs.add(createdAfterTimestamp);
filterOptions = FilterOptions.customer_and_timestamp;
}
if (acknowledged != null) {
queryArgs.clear();
queryArgs.add(customerId);
queryArgs.add(acknowledged);
query_head = "select customerId, equipmentId, alarmCode, createdTimestamp from alarm_by_acknowledged where customerId = ? ";
if (equipmentIds != null && !equipmentIds.isEmpty()) {
query_head = "select customerId, equipmentId, alarmCode, createdTimestamp from alarm_by_acknowledged_equipmentId where customerId = ? ";
queryArgs.addAll(equipmentIds);
}
if (alarmCodes != null && !alarmCodes.isEmpty()) {
query_head = "select customerId, equipmentId, alarmCode, createdTimestamp from alarm_by_acknowledged_alarmCode where customerId = ? ";
alarmCodes.forEach(ac -> queryArgs.add(ac.getId()));
}
if (createdAfterTimestamp > 0) {
query_head = "select customerId, equipmentId, alarmCode, createdTimestamp from alarm_by_acknowledged_timestamp where customerId = ? ";
queryArgs.add(createdAfterTimestamp);
if (equipmentIds != null && !equipmentIds.isEmpty()) {
query_head = "select customerId, equipmentId, alarmCode, createdTimestamp from alarm_by_acknowledged where customerId = ? ";
}
}
query = " and acknowledged = ? " + query;
filterOptions = FilterOptions.customer_and_acknowledged;
}
// add sorting options for the query
@@ -734,7 +758,7 @@ public class AlarmDatastoreCassandra implements AlarmDatastore {
//TODO: create a cache of these prepared statements, keyed by the numberOfEquipmentIds_numberOfAlarmCodes
PreparedStatement preparedStmt_getPageForCustomer;
try {
preparedStmt_getPageForCustomer = cqlSession.prepare(query);
preparedStmt_getPageForCustomer = cqlSession.prepare(query_head + query);
} catch(InvalidQueryException e) {
LOG.error("Cannot prepare cassandra query '{}'", query, e);
throw e;
@@ -755,10 +779,30 @@ public class AlarmDatastoreCassandra implements AlarmDatastore {
List<Alarm> pageItems = new ArrayList<>();
// iterate through the current page
while (rs.getAvailableWithoutFetching() > 0) {
pageItems.add(alarmRowMapper.mapRow(rs.one()));
switch(filterOptions) {
case customer_only:
case customer_and_equipment:
case customer_and_alarmCode:
case customer_and_timestamp:
// iterate through the current page
while (rs.getAvailableWithoutFetching() > 0) {
pageItems.add(alarmRowMapper.mapRow(rs.one()));
}
break;
case customer_and_acknowledged:
while (rs.getAvailableWithoutFetching() > 0) {
Row row = rs.one();
long equipmentIdPostQuery = row.getLong("equipmentId");
int alarmCodePostQuery = row.getInt("alarmCode");
long createdTimestampPostQuery = row.getLong("createdTimestamp");
pageItems.add(getOrNull(customerId, equipmentIdPostQuery, AlarmCode.getById(alarmCodePostQuery), createdTimestampPostQuery));
}
break;
default:
LOG.warn("Unknown filter option:", filterOptions);
throw new IllegalArgumentException("Unknown filter option " + filterOptions);
}
if (pageItems.isEmpty()) {
LOG.debug("Cannot find Alarms for customer {} with last returned page number {}",
@@ -802,7 +846,7 @@ public class AlarmDatastoreCassandra implements AlarmDatastore {
*
*/
@Override
public AlarmCounts getAlarmCounts(int customerId, Set<Long> equipmentIds, Set<AlarmCode> alarmCodes) {
public AlarmCounts getAlarmCounts(int customerId, Set<Long> equipmentIds, Set<AlarmCode> alarmCodes, Boolean acknowledged) {
ArrayList<Object> queryArgs = new ArrayList<>();
queryArgs.add(customerId);
@@ -810,11 +854,13 @@ public class AlarmDatastoreCassandra implements AlarmDatastore {
StringBuilder query = new StringBuilder();
if (equipmentIds != null && !equipmentIds.isEmpty()) {
query.append(CQL_GET_EQUIPMENT_ALARM_COUNT_BY_CUSTOMER_ID);
} else {
if (acknowledged == null) {
query.append(CQL_GET_CUSTOMER_ALARM_COUNT_BY_CUSTOMER_ID);
}
} else {
queryArgs.add(acknowledged);
query.append(CQL_GET_CUSTOMER_ACKNOWLEDGED_ALARM_COUNT_BY_CUSTOMER_ID);
}
//add alarmCodes filters
@@ -823,23 +869,28 @@ public class AlarmDatastoreCassandra implements AlarmDatastore {
//add equipmentId filters
if (equipmentIds != null && !equipmentIds.isEmpty()) {
queryArgs.addAll(equipmentIds);
StringBuilder strb = new StringBuilder(100);
strb.append("and equipmentId in (");
for (int i = 0; i < equipmentIds.size(); i++) {
strb.append("?");
if (i < equipmentIds.size() - 1) {
strb.append(",");
if (equipmentIds.size() == 1) {
query.append("and equipmentId = ? ");
} else {
StringBuilder strb = new StringBuilder(100);
strb.append("and equipmentId in (");
for (int i = 0; i < equipmentIds.size(); i++) {
strb.append("?");
if (i < equipmentIds.size() - 1) {
strb.append(",");
}
}
strb.append(") ");
query.append(strb);
}
strb.append(") ");
query.append(strb);
}
AlarmCounts alarmCounts = new AlarmCounts();
alarmCounts.setCustomerId(customerId);
alarmCounts.setAcknowledged(acknowledged);
//TODO: create a cache of these prepared statements, keyed by the numberOfEquipmentIds_numberOfAlarmCodes
PreparedStatement preparedStmt_getCounts;
@@ -850,21 +901,11 @@ public class AlarmDatastoreCassandra implements AlarmDatastore {
throw e;
}
ResultSet rs = cqlSession.execute(preparedStmt_getCounts.bind(queryArgs.toArray() ));
ResultSet rs = cqlSession.execute(preparedStmt_getCounts.bind(queryArgs.toArray()));
int alarmCodeColIdx;
int equipmentIdColIdx;
int countColIdx;
if (equipmentIds == null || equipmentIds.isEmpty()) {
alarmCodeColIdx = 0;
equipmentIdColIdx = 0;
countColIdx = 1;
} else {
alarmCodeColIdx = 1;
equipmentIdColIdx = 0;
countColIdx = 2;
}
int equipmentIdColIdx = 0;
int alarmCodeColIdx = 1;
rs.forEach(row -> {
//we will do the client-side filtering for the AlarmCodes, because querying for it as part of CQL does not seem to work
@@ -872,86 +913,64 @@ public class AlarmDatastoreCassandra implements AlarmDatastore {
//the amount of distinct alarm codes per equipment is very small
AlarmCode ac = AlarmCode.getById(row.getInt(alarmCodeColIdx));
if (alarmCodes != null && !alarmCodes.isEmpty() && alarmCodes.contains(ac)
|| alarmCodes == null || alarmCodes.isEmpty() )
if (alarmCodes != null && !alarmCodes.isEmpty() && alarmCodes.contains(ac) || alarmCodes == null || alarmCodes.isEmpty() )
{
if(equipmentIds == null || equipmentIds.isEmpty()) {
alarmCounts.addToCounter(0, ac, (int) row.getLong(countColIdx));
alarmCounts.addToCounter(0, ac, 1);
} else {
alarmCounts.addToCounter(row.getLong(equipmentIdColIdx), ac, (int) row.getLong(countColIdx));
alarmCounts.addToCounter(row.getLong(equipmentIdColIdx), ac, 1);
}
}
});
return alarmCounts;
}
public AlarmCounts getAlarmCounts_raw(int customerId, Set<Long> equipmentIds, Set<AlarmCode> alarmCodes) {
@Override
public List<Alarm> get(Set<AlarmCode> alarmCodes, long createdAfterTimestamp) {
if (alarmCodes == null || alarmCodes.isEmpty()) {
throw new IllegalArgumentException("alarmCodes must be provided");
}
LOG.debug("Looking up Alarms for alarmCodes {} createdAfter {}", alarmCodes, createdAfterTimestamp);
String query = CQL_GET_ALL;
// add filters for the query
ArrayList<Object> queryArgs = new ArrayList<>();
queryArgs.add(customerId);
//build the query
StringBuilder query = new StringBuilder();
// add alarmCodes filters
alarmCodes.forEach(ac -> queryArgs.add(ac.getId()));
query.append(CQL_COUNTS_BY_EQUIPMENT_AND_ALARM_CODE_HEADER);
//add alarmCodes filters
//we will do the client-side filtering for the AlarmCodes, see below
//add equipmentId filters
if (equipmentIds != null && !equipmentIds.isEmpty()) {
queryArgs.addAll(equipmentIds);
StringBuilder strb = new StringBuilder(100);
strb.append("and equipmentId in (");
for (int i = 0; i < equipmentIds.size(); i++) {
strb.append("?");
if (i < equipmentIds.size() - 1) {
strb.append(",");
}
StringBuilder strb = new StringBuilder(100);
strb.append("where alarmCode in (");
for (int i = 0; i < alarmCodes.size(); i++) {
strb.append("?");
if (i < alarmCodes.size() - 1) {
strb.append(",");
}
strb.append(") ");
query.append(strb);
}
strb.append(") ");
query.append(CQL_COUNTS_BY_EQUIPMENT_AND_ALARM_CODE_FOOTER);
AlarmCounts alarmCounts = new AlarmCounts();
alarmCounts.setCustomerId(customerId);
//TODO: create a cache of these prepared statements, keyed by the numberOfEquipmentIds_numberOfAlarmCodes
PreparedStatement preparedStmt_getCounts;
try {
preparedStmt_getCounts = cqlSession.prepare(query.toString());
} catch(InvalidQueryException e) {
LOG.error("Cannot prepare cassandra query '{}'", query.toString(), e);
throw e;
if (createdAfterTimestamp > 0) {
strb.append(" and createdTimestamp > ?");
queryArgs.add(createdAfterTimestamp);
}
ResultSet rs = cqlSession.execute(preparedStmt_getCounts.bind(queryArgs.toArray() ));
rs.forEach(row -> {
//we will do the client-side filtering for the AlarmCodes, because querying for it as part of CQL does not seem to work
//we can afford it because there are not that many different alarm codes in total, and during normal operations
//the amount of distinct alarm codes per equipment is very small
AlarmCode ac = AlarmCode.getById(row.getInt(1));
if (alarmCodes != null && !alarmCodes.isEmpty() && alarmCodes.contains(ac)
|| alarmCodes == null || alarmCodes.isEmpty() )
{
if(equipmentIds == null || equipmentIds.isEmpty()) {
alarmCounts.addToCounter(0, ac, (int) row.getLong(2));
} else {
alarmCounts.addToCounter(row.getLong(0), ac, (int) row.getLong(2));
}
}
});
strb.append(" allow filtering");
query += strb.toString();
return alarmCounts;
}
List<Alarm> ret = new ArrayList<>();
PreparedStatement preparedStmt_getListForCustomer = cqlSession.prepare(query);
ResultSet rs = cqlSession.execute(preparedStmt_getListForCustomer.bind(queryArgs.toArray()));
rs.forEach(row -> ret.add(alarmRowMapper.mapRow(row)));
LOG.debug("Found {} Alarms for alarmCodes {} createdAfter {}", ret.size(), alarmCodes, createdAfterTimestamp);
return ret;
}
}

View File

@@ -20,25 +20,50 @@ CREATE TABLE IF NOT EXISTS tip_wlan_keyspace.alarm (
-- this is needed to support retrieval of all alarms for a customer
CREATE INDEX IF NOT EXISTS idx_alarm_customerId ON tip_wlan_keyspace.alarm (customerId);
/*
# Experiment with a separate alarm_counts table because raw alarms table generates warnings like these:
# Query '[5 values] select equipmentId, alarmCode, count(1) from alarm where customerId = ? and equipmentId in (?,?,?,?) group by equipmentId, alarmCode [customerid=2, equipmentid=4, equipmentid=6, equipmentid=8, equipmentid=10]' generated server side warning(s): Aggregation query used on multiple partition keys (IN restriction)
# See https://cassandra.apache.org/doc/latest/cql/types.html#counters
#
*/
CREATE TABLE IF NOT EXISTS tip_wlan_keyspace.alarm_counts_by_customer (
customerId int,
alarmCode int,
alarmCount counter,
PRIMARY KEY ((customerId), alarmCode)
) WITH comment='Counts of Alarms for a Customer generated by the TIP WLAN CloudSDK';
CREATE TABLE IF NOT EXISTS tip_wlan_keyspace.alarm_counts_by_equipment (
CREATE TABLE IF NOT EXISTS tip_wlan_keyspace.alarm_by_acknowledged (
customerId int,
equipmentId bigint,
alarmCode int,
alarmCount counter,
alarmCode int,
createdTimestamp bigint,
acknowledged boolean,
PRIMARY KEY ((customerId, equipmentId), alarmCode)
) WITH comment='Counts of Alarms for Equipment generated by the TIP WLAN CloudSDK';
PRIMARY KEY ((customerId, acknowledged), equipmentId, alarmCode, createdTimestamp)
) WITH comment='Index Table to look up alarms by acknowledged used by TIP WLAN CloudSDK';
CREATE TABLE IF NOT EXISTS tip_wlan_keyspace.alarm_by_acknowledged_equipmentId (
customerId int,
equipmentId bigint,
alarmCode int,
createdTimestamp bigint,
acknowledged boolean,
PRIMARY KEY ((customerId, acknowledged, equipmentId), alarmCode, createdTimestamp)
) WITH comment='Index Table to look up alarms by acknowledged and equipmentId used by TIP WLAN CloudSDK';
CREATE TABLE IF NOT EXISTS tip_wlan_keyspace.alarm_by_acknowledged_alarmCode (
customerId int,
equipmentId bigint,
alarmCode int,
createdTimestamp bigint,
acknowledged boolean,
PRIMARY KEY ((customerId, acknowledged, alarmCode), equipmentId, createdTimestamp)
) WITH comment='Index Table to look up alarms by acknowledged and alarmCode used by TIP WLAN CloudSDK';
CREATE TABLE IF NOT EXISTS tip_wlan_keyspace.alarm_by_acknowledged_timestamp (
customerId int,
equipmentId bigint,
alarmCode int,
createdTimestamp bigint,
acknowledged boolean,
PRIMARY KEY ((customerId, acknowledged), alarmCode, createdTimestamp, equipmentId)
) WITH comment='Index Table to look up alarms by acknowledged and createdTimestamp used by TIP WLAN CloudSDK';
/*
# COPY tip_wlan_keyspace.alarm(customerId, equipmentId, alarmCode, createdTimestamp, acknowledged) TO 'alarmToAcknowledgedTable.csv';
# COPY tip_wlan_keyspace.alarm_by_acknowledged(customerId, equipmentId, alarmCode, createdTimestamp, acknowledged) FROM 'alarmToAcknowledgedTable.csv';
# COPY tip_wlan_keyspace.alarm_by_acknowledged_equipmentId(customerId, equipmentId, alarmCode, createdTimestamp, acknowledged) FROM 'alarmToAcknowledgedTable.csv';
# COPY tip_wlan_keyspace.alarm_by_acknowledged_alarmCode(customerId, equipmentId, alarmCode, createdTimestamp, acknowledged) FROM 'alarmToAcknowledgedTable.csv';
# COPY tip_wlan_keyspace.alarm_by_acknowledged_timestamp(customerId, equipmentId, alarmCode, createdTimestamp, acknowledged) FROM 'alarmToAcknowledgedTable.csv';
*/

View File

@@ -28,12 +28,12 @@ public class AlarmDatastoreCassandraTests extends BaseAlarmDatastoreTest {
@Override
protected List<String> getAlarmPagination_expectedPage3Strings(){
//in cassandra the sort order is weird but consistent - although it may change on the cassandra server restart
return Arrays.asList(new String[]{"qr_6", "qr_2", "qr_26", "qr_43", "qr_41", "qr_3", "qr_49", "qr_40", "qr_24", "qr_28" });
return Arrays.asList(new String[]{"qr_12", "qr_49", "qr_21", "qr_39", "qr_1", "qr_25", "qr_42", "qr_9", "qr_29", "qr_7" });
}
@Override
protected List<String> getAlarmPagination_expectedPage1EmptySortStrings() {
return Arrays.asList(new String[]{"qr_17", "qr_14", "qr_9", "qr_38", "qr_18", "qr_30", "qr_0", "qr_7", "qr_25", "qr_19" });
return Arrays.asList(new String[]{"qr_30", "qr_17", "qr_13", "qr_15", "qr_14", "qr_32", "qr_11", "qr_2", "qr_8", "qr_5" });
}
@Override

View File

@@ -0,0 +1 @@
/target/

View File

@@ -1,10 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
@@ -16,7 +15,7 @@
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>alarm-datastore-interface</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>

View File

@@ -30,6 +30,7 @@ import com.telecominfraproject.wlan.core.model.pagination.PaginationResponse;
import com.telecominfraproject.wlan.core.model.pagination.SortOrder;
import com.telecominfraproject.wlan.datastore.exceptions.DsConcurrentModificationException;
import com.telecominfraproject.wlan.datastore.exceptions.DsEntityNotFoundException;
import com.telecominfraproject.wlan.status.models.StatusCode;
/**
* @author dtoptygin
@@ -209,9 +210,7 @@ public abstract class BaseAlarmDatastoreTest {
Set<AlarmCode> alarmCodes = new HashSet<>(Arrays.asList(AlarmCode.AccessPointIsUnreachable, AlarmCode.AssocFailure));
long pastTimestamp = 0;
Set<Long> equipmentIds_c2 = new HashSet<>();
testInterface.resetAlarmCounters();
for(int i = 0; i< 50; i++){
mdl = createAlarmObject();
mdl.setCustomerId(customerId_1);
@@ -223,13 +222,16 @@ public abstract class BaseAlarmDatastoreTest {
mdl.setCreatedTimestamp(mdl.getCreatedTimestamp() - 10000);
pastTimestamp = mdl.getCreatedTimestamp();
}
if (i < 20) {
mdl.setAcknowledged(true);
} else {
mdl.setAcknowledged(false);
}
apNameIdx++;
testInterface.create(mdl);
}
testInterface.resetAlarmCounters();
for(int i = 0; i< 50; i++){
mdl = createAlarmObject();
mdl.setCustomerId(customerId_2);
@@ -246,13 +248,13 @@ public abstract class BaseAlarmDatastoreTest {
//get active alarms for all equipment and all alarmCodes for the customer since the beginning of time
PaginationContext<Alarm> context = new PaginationContext<>(10);
PaginationResponse<Alarm> page1 = testInterface.getForCustomer(customerId_1, null, null, -1, sortBy, context);
PaginationResponse<Alarm> page2 = testInterface.getForCustomer(customerId_1, null, null, -1, sortBy, page1.getContext());
PaginationResponse<Alarm> page3 = testInterface.getForCustomer(customerId_1, null, null, -1, sortBy, page2.getContext());
PaginationResponse<Alarm> page4 = testInterface.getForCustomer(customerId_1, null, null, -1, sortBy, page3.getContext());
PaginationResponse<Alarm> page5 = testInterface.getForCustomer(customerId_1, null, null, -1, sortBy, page4.getContext());
PaginationResponse<Alarm> page6 = testInterface.getForCustomer(customerId_1, null, null, -1, sortBy, page5.getContext());
PaginationResponse<Alarm> page7 = testInterface.getForCustomer(customerId_1, null, null, -1, sortBy, page6.getContext());
PaginationResponse<Alarm> page1 = testInterface.getForCustomer(customerId_1, null, null, -1, null, sortBy, context);
PaginationResponse<Alarm> page2 = testInterface.getForCustomer(customerId_1, null, null, -1, null, sortBy, page1.getContext());
PaginationResponse<Alarm> page3 = testInterface.getForCustomer(customerId_1, null, null, -1, null, sortBy, page2.getContext());
PaginationResponse<Alarm> page4 = testInterface.getForCustomer(customerId_1, null, null, -1, null, sortBy, page3.getContext());
PaginationResponse<Alarm> page5 = testInterface.getForCustomer(customerId_1, null, null, -1, null, sortBy, page4.getContext());
PaginationResponse<Alarm> page6 = testInterface.getForCustomer(customerId_1, null, null, -1, null, sortBy, page5.getContext());
PaginationResponse<Alarm> page7 = testInterface.getForCustomer(customerId_1, null, null, -1, null, sortBy, page6.getContext());
//verify returned pages
assertEquals(10, page1.getItems().size());
@@ -285,9 +287,99 @@ public abstract class BaseAlarmDatastoreTest {
assertEquals(expectedPage3Strings, actualPage3Strings);
// testing Acknowledged filter (alarm_by_acknowledged)
PaginationResponse<Alarm> page1Acknowledged = testInterface.getForCustomer(customerId_1, null, null, -1, true, sortBy, context);
PaginationResponse<Alarm> page2Acknowledged = testInterface.getForCustomer(customerId_1, null, null, -1, true, sortBy, page1Acknowledged.getContext());
PaginationResponse<Alarm> page3Acknowledged = testInterface.getForCustomer(customerId_1, null, null, -1, true, sortBy, page2Acknowledged.getContext());
PaginationResponse<Alarm> page4Acknowledged = testInterface.getForCustomer(customerId_1, null, null, -1, true, sortBy, page3Acknowledged.getContext());
//verify returned pages
assertEquals(10, page1Acknowledged.getItems().size());
assertEquals(10, page2Acknowledged.getItems().size());
assertEquals(0, page3Acknowledged.getItems().size());
assertEquals(0, page4Acknowledged.getItems().size());
// testing Acknowledged filter with equipmentIds (alarm_by_acknowledged_equipmentId)
PaginationResponse<Alarm> page1AcknowledgedAndEquipment = testInterface.getForCustomer(customerId_1, equipmentIds, null, -1, true, sortBy, context);
PaginationResponse<Alarm> page2AcknowledgedAndEquipment = testInterface.getForCustomer(customerId_1, equipmentIds, null, -1, true, sortBy, page1AcknowledgedAndEquipment.getContext());
PaginationResponse<Alarm> page3AcknowledgedAndEquipment = testInterface.getForCustomer(customerId_1, equipmentIds, null, -1, true, sortBy, page2AcknowledgedAndEquipment.getContext());
PaginationResponse<Alarm> page4AcknowledgedAndEquipment = testInterface.getForCustomer(customerId_1, equipmentIds, null, -1, true, sortBy, page3AcknowledgedAndEquipment.getContext());
page1AcknowledgedAndEquipment.getItems().forEach(e -> assertEquals(true, e.isAcknowledged()) );
page2AcknowledgedAndEquipment.getItems().forEach(e -> assertEquals(true, e.isAcknowledged()) );
page1AcknowledgedAndEquipment.getItems().forEach(e -> assertTrue(equipmentIds.contains(e.getEquipmentId())));
page2AcknowledgedAndEquipment.getItems().forEach(e -> assertTrue(equipmentIds.contains(e.getEquipmentId())));
assertTrue(page3AcknowledgedAndEquipment.getContext().isLastPage());
assertTrue(page4AcknowledgedAndEquipment.getContext().isLastPage());
// testing Acknowledged filter with alarmCodes (alarm_by_acknowledged_alarmCode)
PaginationResponse<Alarm> page1AcknowledgedAndAlarmCode = testInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, -1, true, sortBy, context);
PaginationResponse<Alarm> page2AcknowledgedAndAlarmCode = testInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, -1, true, sortBy, page1AcknowledgedAndAlarmCode.getContext());
PaginationResponse<Alarm> page3AcknowledgedAndAlarmCode = testInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, -1, true, sortBy, page2AcknowledgedAndAlarmCode.getContext());
PaginationResponse<Alarm> page4AcknowledgedAndAlarmCode = testInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, -1, true, sortBy, page3AcknowledgedAndAlarmCode.getContext());
page1AcknowledgedAndAlarmCode.getItems().forEach(e -> assertEquals(true, e.isAcknowledged()) );
page2AcknowledgedAndAlarmCode.getItems().forEach(e -> assertEquals(true, e.isAcknowledged()) );
page1AcknowledgedAndAlarmCode.getItems().forEach(e -> assertEquals(AlarmCode.AccessPointIsUnreachable, e.getAlarmCode()));
page2AcknowledgedAndAlarmCode.getItems().forEach(e -> assertEquals(AlarmCode.AccessPointIsUnreachable, e.getAlarmCode()));
assertTrue(page3AcknowledgedAndAlarmCode.getContext().isLastPage());
assertTrue(page4AcknowledgedAndAlarmCode.getContext().isLastPage());
// testing Acknowledged filter with failure alarm code (no alarms initialized with failure code, should return empty page)
PaginationResponse<Alarm> page1AcknowledgedAndAlarmCodeFailure = testInterface.getForCustomer(customerId_1, equipmentIds, Collections.singleton(AlarmCode.AssocFailure), -1, true, sortBy, context);
assertTrue(page1AcknowledgedAndAlarmCodeFailure.getContext().isLastPage());
long checkTimestamp = pastTimestamp;
// testing Acknowledged filter with timestamp (alarm_by_acknowledged_timestamp)
PaginationResponse<Alarm> page1AcknowledgedAndTimestamp = testInterface.getForCustomer(customerId_1, null, null, pastTimestamp, true, sortBy, context);
PaginationResponse<Alarm> page2AcknowledgedAndTimestamp = testInterface.getForCustomer(customerId_1, null, null, pastTimestamp, true, sortBy, page1AcknowledgedAndTimestamp.getContext());
PaginationResponse<Alarm> page3AcknowledgedAndTimestamp = testInterface.getForCustomer(customerId_1, null, null, pastTimestamp, true, sortBy, page2AcknowledgedAndTimestamp.getContext());
PaginationResponse<Alarm> page4AcknowledgedAndTimestamp = testInterface.getForCustomer(customerId_1, null, null, pastTimestamp, true, sortBy, page3AcknowledgedAndTimestamp.getContext());
assertEquals(10, page1AcknowledgedAndTimestamp.getItems().size());
assertEquals(9, page2AcknowledgedAndTimestamp.getItems().size());
assertEquals(0, page3AcknowledgedAndTimestamp.getItems().size());
assertEquals(0, page4AcknowledgedAndTimestamp.getItems().size());
page1AcknowledgedAndTimestamp.getItems().forEach(e -> assertEquals(true, e.isAcknowledged()) );
page2AcknowledgedAndTimestamp.getItems().forEach(e -> assertEquals(true, e.isAcknowledged()) );
page1AcknowledgedAndTimestamp.getItems().forEach(e -> assertTrue(e.getCreatedTimestamp() > checkTimestamp));
page2AcknowledgedAndTimestamp.getItems().forEach(e -> assertTrue(e.getCreatedTimestamp() > checkTimestamp));
assertTrue(page3AcknowledgedAndTimestamp.getContext().isLastPage());
assertTrue(page4AcknowledgedAndTimestamp.getContext().isLastPage());
// testing Acknowledged with equipmentId and timestamp
// With timestamp, alarmCodes will be set to AlarmCode.validValues, so these calls will be equivalent to having all filters included.
// Because all filters are included, the alarm_by_acknowledged will be used instead of alarm_by_acknowledged_timestamp
PaginationResponse<Alarm> page1AcknowledgedEquipmentIdAndTimestamp = testInterface.getForCustomer(customerId_1, equipmentIds, null, pastTimestamp, true, sortBy, context);
PaginationResponse<Alarm> page2AcknowledgedEquipmentIdAndTimestamp = testInterface.getForCustomer(customerId_1, equipmentIds, null, pastTimestamp, true, sortBy, page1AcknowledgedEquipmentIdAndTimestamp.getContext());
PaginationResponse<Alarm> page3AcknowledgedEquipmentIdAndTimestamp = testInterface.getForCustomer(customerId_1, equipmentIds, null, pastTimestamp, true, sortBy, page2AcknowledgedEquipmentIdAndTimestamp.getContext());
assertEquals(10, page1AcknowledgedEquipmentIdAndTimestamp.getItems().size());
assertEquals(9, page2AcknowledgedEquipmentIdAndTimestamp.getItems().size());
assertEquals(0, page3AcknowledgedEquipmentIdAndTimestamp.getItems().size());
page1AcknowledgedEquipmentIdAndTimestamp.getItems().forEach(e -> assertEquals(true, e.isAcknowledged()) );
page2AcknowledgedEquipmentIdAndTimestamp.getItems().forEach(e -> assertEquals(true, e.isAcknowledged()) );
page1AcknowledgedEquipmentIdAndTimestamp.getItems().forEach(e -> assertTrue(equipmentIds.contains(e.getEquipmentId())));
page2AcknowledgedEquipmentIdAndTimestamp.getItems().forEach(e -> assertTrue(equipmentIds.contains(e.getEquipmentId())));
page1AcknowledgedEquipmentIdAndTimestamp.getItems().forEach(e -> assertTrue(e.getCreatedTimestamp() > checkTimestamp));
page2AcknowledgedEquipmentIdAndTimestamp.getItems().forEach(e -> assertTrue(e.getCreatedTimestamp() > checkTimestamp));
assertTrue(page3AcknowledgedEquipmentIdAndTimestamp.getContext().isLastPage());
//test first page of the results with empty sort order -> default sort order (by Id ascending)
PaginationResponse<Alarm> page1EmptySort = testInterface.getForCustomer(customerId_1, null, null, -1, Collections.emptyList(), context);
PaginationResponse<Alarm> page1EmptySort = testInterface.getForCustomer(customerId_1, null, null, -1, null, Collections.emptyList(), context);
assertEquals(10, page1EmptySort.getItems().size());
List<String> expectedPage1EmptySortStrings = getAlarmPagination_expectedPage1EmptySortStrings();
@@ -297,7 +389,7 @@ public abstract class BaseAlarmDatastoreTest {
assertEquals(expectedPage1EmptySortStrings, actualPage1EmptySortStrings);
//test first page of the results with null sort order -> default sort order (by Id ascending)
PaginationResponse<Alarm> page1NullSort = testInterface.getForCustomer(customerId_1, null, null, -1, null, context);
PaginationResponse<Alarm> page1NullSort = testInterface.getForCustomer(customerId_1, null, null, -1, null, null, context);
assertEquals(10, page1NullSort.getItems().size());
List<String> expectedPage1NullSortStrings = expectedPage1EmptySortStrings;
@@ -308,7 +400,7 @@ public abstract class BaseAlarmDatastoreTest {
//test first page of the results with sort descending order by a equipmentId property
PaginationResponse<Alarm> page1SingleSortDesc = testInterface.getForCustomer(customerId_1, null, null, -1, Collections.singletonList(new ColumnAndSort("equipmentId", SortOrder.desc)), context);
PaginationResponse<Alarm> page1SingleSortDesc = testInterface.getForCustomer(customerId_1, null, null, -1, null, Collections.singletonList(new ColumnAndSort("equipmentId", SortOrder.desc)), context);
assertEquals(10, page1SingleSortDesc.getItems().size());
List<String> expectedPage1SingleSortDescStrings = getAlarmPagination_expectedPage1SingleSortDescStrings();
@@ -320,13 +412,13 @@ public abstract class BaseAlarmDatastoreTest {
//test with explicit list of equipmentIds and explicit list of AlarmCodes
long createdAfterTs = pastTimestamp + 10;
context = new PaginationContext<>(10);
page1 = testInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, createdAfterTs, sortBy, context);
page2 = testInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, createdAfterTs, sortBy, page1.getContext());
page3 = testInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, createdAfterTs, sortBy, page2.getContext());
page4 = testInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, createdAfterTs, sortBy, page3.getContext());
page5 = testInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, createdAfterTs, sortBy, page4.getContext());
page6 = testInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, createdAfterTs, sortBy, page5.getContext());
page7 = testInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, createdAfterTs, sortBy, page6.getContext());
page1 = testInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, createdAfterTs, null, sortBy, context);
page2 = testInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, createdAfterTs, null, sortBy, page1.getContext());
page3 = testInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, createdAfterTs, null, sortBy, page2.getContext());
page4 = testInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, createdAfterTs, null, sortBy, page3.getContext());
page5 = testInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, createdAfterTs, null, sortBy, page4.getContext());
page6 = testInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, createdAfterTs, null, sortBy, page5.getContext());
page7 = testInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, createdAfterTs, null, sortBy, page6.getContext());
//verify returned pages
assertEquals(10, page1.getItems().size());
@@ -344,17 +436,13 @@ public abstract class BaseAlarmDatastoreTest {
//test with explicit list of equipmentIds of one element and explicit list of AlarmCodes of one element
context = new PaginationContext<>(10);
page1 = testInterface.getForCustomer(customerId_1, Collections.singleton(equipmentIds.iterator().next()), Collections.singleton(AlarmCode.AccessPointIsUnreachable), -1, sortBy, context);
page1 = testInterface.getForCustomer(customerId_1, Collections.singleton(equipmentIds.iterator().next()), Collections.singleton(AlarmCode.AccessPointIsUnreachable), -1, null, sortBy, context);
assertEquals(1, page1.getItems().size());
testInterface.resetAlarmCounters();
//clean up after the test
equipmentIds.forEach(eqId -> testInterface.delete(customerId_1, eqId));
equipmentIds_c2.forEach(eqId -> testInterface.delete(customerId_2, eqId));
testInterface.resetAlarmCounters();
}
protected List<String> getAlarmPagination_expectedPage3Strings(){
@@ -369,6 +457,54 @@ public abstract class BaseAlarmDatastoreTest {
return Arrays.asList(new String[]{"qr_49", "qr_48", "qr_47", "qr_46", "qr_45", "qr_44", "qr_43", "qr_42", "qr_41", "qr_40" });
}
@Test
public void testAlarmAcknowledgedPaginationWithUpdate() {
Alarm alarm = createAlarmObject();
//create
Alarm created = testInterface.create(alarm);
assertNotNull(created);
assertEquals(alarm.getCustomerId(), created.getCustomerId());
assertEquals(alarm.getEquipmentId(), created.getEquipmentId());
assertEquals(alarm.getAlarmCode(), created.getAlarmCode());
assertEquals(alarm.getCreatedTimestamp(), created.getCreatedTimestamp());
assertNotNull(created.getDetails());
assertEquals(alarm.getDetails(), created.getDetails());
List<ColumnAndSort> sortBy = new ArrayList<>();
sortBy.addAll(Arrays.asList(new ColumnAndSort("equipmentId")));
PaginationContext<Alarm> context = new PaginationContext<>(10);
PaginationResponse<Alarm> page1CheckFalse = testInterface.getForCustomer(created.getCustomerId(), null, null, -1, false, sortBy, context);
assertEquals(1, page1CheckFalse.getItems().size());
page1CheckFalse.getItems().forEach(e -> assertFalse(e.isAcknowledged()));
PaginationResponse<Alarm> page1CheckTrue = testInterface.getForCustomer(created.getCustomerId(), null, null, -1, true, sortBy, context);
assertEquals(0, page1CheckTrue.getItems().size());
// update
created.setAcknowledged(true);
Alarm updated = testInterface.update(created);
assertNotNull(updated);
assertTrue(updated.isAcknowledged());
page1CheckFalse = testInterface.getForCustomer(created.getCustomerId(), null, null, -1, false, sortBy, context);
assertEquals(0, page1CheckFalse.getItems().size());
page1CheckTrue = testInterface.getForCustomer(created.getCustomerId(), null, null, -1, true, sortBy, context);
assertEquals(1, page1CheckTrue.getItems().size());
page1CheckTrue.getItems().forEach(e -> assertTrue(e.isAcknowledged()));
//delete
created = testInterface.delete(created.getCustomerId(), created.getEquipmentId(), created.getAlarmCode(), created.getCreatedTimestamp());
assertNotNull(created);
created = testInterface.getOrNull(created.getCustomerId(), created.getEquipmentId(), created.getAlarmCode(), created.getCreatedTimestamp());
assertNull(created);
}
@Test
public void testAlarmCountsModel() {
@@ -406,6 +542,7 @@ public abstract class BaseAlarmDatastoreTest {
mdl.setScopeId("qr_"+apNameIdx);
if((i%2) == 0) {
mdl.setAlarmCode(AlarmCode.CPUUtilization);
mdl.setAcknowledged(true);
equipmentIds_CPUUtilization.add(mdl.getEquipmentId());
} else {
equipmentIds_AccessPointIsUnreachable.add(mdl.getEquipmentId());
@@ -417,21 +554,21 @@ public abstract class BaseAlarmDatastoreTest {
testInterface.create(mdl);
}
{
mdl = createAlarmObject();
mdl.setCustomerId(customerId_1);
mdl.setEquipmentId(0);
mdl.setAlarmCode(AlarmCode.GenericError);
equipmentIds_c1.add(mdl.getEquipmentId());
testInterface.create(mdl);
}
mdl = createAlarmObject();
mdl.setCustomerId(customerId_1);
mdl.setEquipmentId(0);
mdl.setAlarmCode(AlarmCode.GenericError);
equipmentIds_c1.add(mdl.getEquipmentId());
testInterface.create(mdl);
for(int i = 0; i< 50; i++){
mdl = createAlarmObject();
mdl.setCustomerId(customerId_2);
mdl.setScopeId("qr_"+apNameIdx);
equipmentIds_c2.add(mdl.getEquipmentId());
mdl.setAcknowledged(false);
mdl.setAlarmCode(AlarmCode.GenericError);
apNameIdx++;
testInterface.create(mdl);
@@ -439,33 +576,71 @@ public abstract class BaseAlarmDatastoreTest {
Set<AlarmCode> alarmCodes = new HashSet<>(Arrays.asList(AlarmCode.AccessPointIsUnreachable, AlarmCode.GenericError, AlarmCode.CPUUtilization));
AlarmCounts alarmCounts = testInterface.getAlarmCounts(customerId_1, equipmentIds, alarmCodes);
AlarmCounts alarmCounts = testInterface.getAlarmCounts(customerId_1, equipmentIds, alarmCodes, null);
assertEquals(0, alarmCounts.getCounter(0, AlarmCode.GenericError));
assertEquals(25, alarmCounts.getCounter(0, AlarmCode.CPUUtilization));
assertEquals(25, alarmCounts.getCounter(0, AlarmCode.AccessPointIsUnreachable));
assertEquals(25, alarmCounts.getSeverityCounter(StatusCode.requiresAttention));
assertEquals(25, alarmCounts.getSeverityCounter(StatusCode.error));
equipmentIds_CPUUtilization.forEach(eqId -> assertEquals(1, alarmCounts.getCounter(eqId, AlarmCode.CPUUtilization)));
equipmentIds_AccessPointIsUnreachable.forEach(eqId -> assertEquals(1, alarmCounts.getCounter(eqId, AlarmCode.AccessPointIsUnreachable)) );
AlarmCounts alarmCounts_noEq = testInterface.getAlarmCounts(customerId_1, null, alarmCodes);
AlarmCounts alarmCounts_noEq = testInterface.getAlarmCounts(customerId_1, null, alarmCodes, null);
assertEquals(1, alarmCounts_noEq.getCounter(0, AlarmCode.GenericError));
assertEquals(25, alarmCounts_noEq.getCounter(0, AlarmCode.CPUUtilization));
assertEquals(25, alarmCounts_noEq.getCounter(0, AlarmCode.AccessPointIsUnreachable));
assertEquals(25, alarmCounts_noEq.getSeverityCounter(StatusCode.requiresAttention));
assertEquals(26, alarmCounts_noEq.getSeverityCounter(StatusCode.error));
assertTrue(alarmCounts_noEq.getCountsPerEquipmentIdMap().isEmpty());
assertEquals(3, alarmCounts_noEq.getTotalCountsPerAlarmCodeMap().size());
AlarmCounts alarmCounts_noEq_1code = testInterface.getAlarmCounts(customerId_1, null, Collections.singleton(AlarmCode.CPUUtilization));
AlarmCounts alarmCounts_noEq_1code = testInterface.getAlarmCounts(customerId_1, null, Collections.singleton(AlarmCode.CPUUtilization), null);
assertEquals(0, alarmCounts_noEq_1code.getCounter(0, AlarmCode.GenericError));
assertEquals(25, alarmCounts_noEq_1code.getCounter(0, AlarmCode.CPUUtilization));
assertEquals(0, alarmCounts_noEq_1code.getCounter(0, AlarmCode.AccessPointIsUnreachable));
assertEquals(25, alarmCounts_noEq_1code.getSeverityCounter(StatusCode.requiresAttention));
assertEquals(0, alarmCounts_noEq_1code.getSeverityCounter(StatusCode.error));
assertTrue(alarmCounts_noEq_1code.getCountsPerEquipmentIdMap().isEmpty());
assertEquals(1, alarmCounts_noEq_1code.getTotalCountsPerAlarmCodeMap().size());
AlarmCounts alarmCounts_1Eq_1code = testInterface.getAlarmCounts(customerId_1, Collections.singleton(equipmentIds.iterator().next()), Collections.singleton(AlarmCode.CPUUtilization));
AlarmCounts alarmCounts_acknowledgedT = testInterface.getAlarmCounts(customerId_1, null, Collections.singleton(AlarmCode.CPUUtilization), true);
assertTrue(alarmCounts_acknowledgedT.getAcknowledged());
assertEquals(0, alarmCounts_acknowledgedT.getCounter(0, AlarmCode.GenericError));
assertEquals(25, alarmCounts_acknowledgedT.getCounter(0, AlarmCode.CPUUtilization));
assertEquals(0, alarmCounts_acknowledgedT.getCounter(0, AlarmCode.AccessPointIsUnreachable));
assertEquals(25, alarmCounts_acknowledgedT.getSeverityCounter(StatusCode.requiresAttention));
assertEquals(0, alarmCounts_acknowledgedT.getSeverityCounter(StatusCode.error));
assertTrue(alarmCounts_acknowledgedT.getCountsPerEquipmentIdMap().isEmpty());
assertEquals(1, alarmCounts_acknowledgedT.getTotalCountsPerAlarmCodeMap().size());
AlarmCounts alarmCounts_acknowledgedF = testInterface.getAlarmCounts(customerId_1, null, Collections.singleton(AlarmCode.CPUUtilization), false);
assertFalse(alarmCounts_acknowledgedF.getAcknowledged());
assertEquals(0, alarmCounts_acknowledgedF.getCounter(0, AlarmCode.GenericError));
assertEquals(0, alarmCounts_acknowledgedF.getCounter(0, AlarmCode.CPUUtilization));
assertEquals(0, alarmCounts_acknowledgedF.getCounter(0, AlarmCode.AccessPointIsUnreachable));
assertEquals(0, alarmCounts_acknowledgedF.getSeverityCounter(StatusCode.requiresAttention));
assertEquals(0, alarmCounts_acknowledgedF.getSeverityCounter(StatusCode.error));
assertTrue(alarmCounts_acknowledgedF.getCountsPerEquipmentIdMap().isEmpty());
assertEquals(0, alarmCounts_acknowledgedF.getTotalCountsPerAlarmCodeMap().size());
AlarmCounts alarmCounts_acknowledgedF2 = testInterface.getAlarmCounts(customerId_2, null, Collections.singleton(AlarmCode.GenericError), false);
assertFalse(alarmCounts_acknowledgedF2.getAcknowledged());
assertEquals(50, alarmCounts_acknowledgedF2.getCounter(0, AlarmCode.GenericError));
assertEquals(0, alarmCounts_acknowledgedF2.getCounter(0, AlarmCode.CPUUtilization));
assertEquals(0, alarmCounts_acknowledgedF2.getCounter(0, AlarmCode.AccessPointIsUnreachable));
assertEquals(0, alarmCounts_acknowledgedF2.getSeverityCounter(StatusCode.requiresAttention));
assertEquals(50, alarmCounts_acknowledgedF2.getSeverityCounter(StatusCode.error));
assertTrue(alarmCounts_acknowledgedF2.getCountsPerEquipmentIdMap().isEmpty());
assertEquals(1, alarmCounts_acknowledgedF2.getTotalCountsPerAlarmCodeMap().size());
AlarmCounts alarmCounts_1Eq_1code = testInterface.getAlarmCounts(customerId_1, Collections.singleton(equipmentIds.iterator().next()), Collections.singleton(AlarmCode.CPUUtilization), null);
assertEquals(0, alarmCounts_1Eq_1code.getCounter(0, AlarmCode.GenericError));
assertEquals(1, alarmCounts_1Eq_1code.getCounter(equipmentIds.iterator().next(), AlarmCode.CPUUtilization));
assertEquals(1, alarmCounts_1Eq_1code.getCounter(0, AlarmCode.CPUUtilization));
assertEquals(0, alarmCounts_1Eq_1code.getCounter(0, AlarmCode.AccessPointIsUnreachable));
assertEquals(1, alarmCounts_1Eq_1code.getSeverityCounter(StatusCode.requiresAttention));
assertEquals(0, alarmCounts_1Eq_1code.getSeverityCounter(StatusCode.error));
assertEquals(1, alarmCounts_1Eq_1code.getCountsPerEquipmentIdMap().size());
assertEquals(1, alarmCounts_1Eq_1code.getTotalCountsPerAlarmCodeMap().size());
@@ -475,10 +650,12 @@ public abstract class BaseAlarmDatastoreTest {
for(int i=0; i< 4; i++) {
smallEqIds.add(iter.next());
}
AlarmCounts alarmCounts_small = testInterface.getAlarmCounts(customerId_1, smallEqIds, alarmCodes);
AlarmCounts alarmCounts_small = testInterface.getAlarmCounts(customerId_1, smallEqIds, alarmCodes, null);
assertEquals(0, alarmCounts_small.getCounter(0, AlarmCode.GenericError));
assertEquals(2, alarmCounts_small.getCounter(0, AlarmCode.CPUUtilization));
assertEquals(2, alarmCounts_small.getCounter(0, AlarmCode.AccessPointIsUnreachable));
assertEquals(2, alarmCounts_small.getSeverityCounter(StatusCode.requiresAttention));
assertEquals(2, alarmCounts_small.getSeverityCounter(StatusCode.error));
//clean up after the test
equipmentIds_c1.forEach(eqId -> testInterface.delete(customerId_1, eqId));
@@ -486,6 +663,38 @@ public abstract class BaseAlarmDatastoreTest {
}
@Test
public void testAlarmCountsForSingleEquipment() {
//create some Alarms
Alarm mdl;
int customerId = (int) testSequence.incrementAndGet();
long equipmentId = testSequence.incrementAndGet();
mdl = createAlarmObject();
mdl.setCustomerId(customerId);
mdl.setEquipmentId(equipmentId);
mdl.setAlarmCode(AlarmCode.CPUUtilization);
testInterface.create(mdl);
mdl.setAlarmCode(AlarmCode.AccessPointIsUnreachable);
testInterface.create(mdl);
Set<AlarmCode> alarmCodes = new HashSet<>(Arrays.asList(AlarmCode.AccessPointIsUnreachable, AlarmCode.GenericError, AlarmCode.CPUUtilization));
AlarmCounts alarmCounts = testInterface.getAlarmCounts(customerId, Collections.singleton(equipmentId), alarmCodes, null);
assertEquals(0, alarmCounts.getCounter(0, AlarmCode.GenericError));
assertEquals(1, alarmCounts.getCounter(0, AlarmCode.CPUUtilization));
assertEquals(1, alarmCounts.getCounter(0, AlarmCode.AccessPointIsUnreachable));
assertEquals(2, alarmCounts.getCounter(equipmentId, null));
assertEquals(1, alarmCounts.getSeverityCounter(StatusCode.requiresAttention));
assertEquals(1, alarmCounts.getSeverityCounter(StatusCode.error));
//clean up after the test
testInterface.delete(customerId, equipmentId);
}
protected Alarm createAlarmObject() {
Alarm result = new Alarm();
@@ -493,6 +702,7 @@ public abstract class BaseAlarmDatastoreTest {
result.setEquipmentId(testSequence.getAndIncrement());
result.setAlarmCode(AlarmCode.AccessPointIsUnreachable);
result.setCreatedTimestamp(System.currentTimeMillis());
result.setAcknowledged(false);
result.setScopeId("test-scope-" + result.getEquipmentId());

1
alarm-datastore-inmemory/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target/

View File

@@ -1,10 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
@@ -16,19 +15,19 @@
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-datastore-inmemory</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>alarm-datastore-interface</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>alarm-datastore-common-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
</dependencies>

View File

@@ -204,7 +204,7 @@ public class AlarmDatastoreInMemory extends BaseInMemoryDatastore implements Ala
@Override
public PaginationResponse<Alarm> getForCustomer(int customerId, Set<Long> equipmentIdSet, Set<AlarmCode> alarmCodeSet,
long createdAfterTimestamp, List<ColumnAndSort> sortBy, PaginationContext<Alarm> context) {
long createdAfterTimestamp, Boolean acknowledged, List<ColumnAndSort> sortBy, PaginationContext<Alarm> context) {
if(context == null) {
context = new PaginationContext<>();
@@ -226,6 +226,7 @@ public class AlarmDatastoreInMemory extends BaseInMemoryDatastore implements Ala
&& ( equipmentIdSet == null || equipmentIdSet.isEmpty() || equipmentIdSet.contains(a.getEquipmentId()) )
&& ( alarmCodeSet ==null || alarmCodeSet.isEmpty() || alarmCodeSet.contains(a.getAlarmCode()) )
&& a.getCreatedTimestamp() > createdAfterTimestamp
&& (acknowledged == null || a.isAcknowledged() == acknowledged.booleanValue())
) {
items.add(a.clone());
}
@@ -321,23 +322,59 @@ public class AlarmDatastoreInMemory extends BaseInMemoryDatastore implements Ala
}
@Override
public AlarmCounts getAlarmCounts(int customerId, Set<Long> equipmentIdSet, Set<AlarmCode> alarmCodeSet) {
public AlarmCounts getAlarmCounts(int customerId, Set<Long> equipmentIdSet, Set<AlarmCode> alarmCodeSet, Boolean acknowledged) {
AlarmCounts alarmCounts = new AlarmCounts();
alarmCounts.setCustomerId(customerId);
alarmCounts.setAcknowledged(acknowledged);
idToAlarmMap.values().forEach(a -> {
if(a.getCustomerId() == customerId) {
if( alarmCodeSet ==null || alarmCodeSet.isEmpty() || alarmCodeSet.contains(a.getAlarmCode()) ) {
if( equipmentIdSet != null && !equipmentIdSet.isEmpty() && equipmentIdSet.contains(a.getEquipmentId()) ) {
alarmCounts.addToCounter(a.getEquipmentId(), a.getAlarmCode(), 1);
} else if( equipmentIdSet == null || equipmentIdSet.isEmpty()) {
alarmCounts.addToCounter(0, a.getAlarmCode(), 1);
}
}
}
});
if (acknowledged == null) {
idToAlarmMap.values().forEach(a -> {
if(a.getCustomerId() == customerId) {
if( alarmCodeSet ==null || alarmCodeSet.isEmpty() || alarmCodeSet.contains(a.getAlarmCode()) ) {
if( equipmentIdSet != null && !equipmentIdSet.isEmpty() && equipmentIdSet.contains(a.getEquipmentId()) ) {
alarmCounts.addToCounter(a.getEquipmentId(), a.getAlarmCode(), 1);
} else if (equipmentIdSet == null || equipmentIdSet.isEmpty()) {
alarmCounts.addToCounter(0, a.getAlarmCode(), 1);
}
}
}
});
} else {
idToAlarmMap.values().forEach(a -> {
if(a.getCustomerId() == customerId && acknowledged.equals(a.isAcknowledged())) {
if( alarmCodeSet ==null || alarmCodeSet.isEmpty() || alarmCodeSet.contains(a.getAlarmCode()) ) {
if( equipmentIdSet != null && !equipmentIdSet.isEmpty() && equipmentIdSet.contains(a.getEquipmentId()) ) {
alarmCounts.addToCounter(a.getEquipmentId(), a.getAlarmCode(), 1);
} else if (equipmentIdSet == null || equipmentIdSet.isEmpty()) {
alarmCounts.addToCounter(0, a.getAlarmCode(), 1);
}
}
}
});
}
return alarmCounts;
}
@Override
public List<Alarm> get(Set<AlarmCode> alarmCodeSet, long createdAfterTimestamp) {
if (alarmCodeSet == null || alarmCodeSet.isEmpty()) {
throw new IllegalArgumentException("alarmCodeSet must be provided");
}
List<Alarm> ret = new ArrayList<>();
idToAlarmMap.values().forEach(a -> {
if (alarmCodeSet.contains(a.getAlarmCode()) && a.getCreatedTimestamp() > createdAfterTimestamp) {
ret.add(a.clone());
}
});
LOG.debug("Found Alarms {}", ret);
return ret;
}
}

1
alarm-datastore-interface/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target/

View File

@@ -1,10 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
@@ -16,12 +15,12 @@
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>alarm-models</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-exceptions</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
</dependencies>

View File

@@ -60,22 +60,25 @@ public interface AlarmDatastore {
* @param createdAfterTimestamp
* @return next page of matching Alarm objects.
*/
PaginationResponse<Alarm> getForCustomer(int customerId, Set<Long> equipmentIdSet, Set<AlarmCode> alarmCodeSet, long createdAfterTimestamp, List<ColumnAndSort> sortBy, PaginationContext<Alarm> context);
PaginationResponse<Alarm> getForCustomer(int customerId, Set<Long> equipmentIdSet, Set<AlarmCode> alarmCodeSet, long createdAfterTimestamp, Boolean acknowledged, List<ColumnAndSort> sortBy, PaginationContext<Alarm> context);
/**
* @param customerId
* @param equipmentIdSet - if empty, then only total counts of all alarms for customer per alarm code will be counted
* @param alarmCodeSet - can be empty, in which case all alarm codes will be counted
* @param acknowledged - can by empty, in which case acknowledged will be ignored
* @return alarm counts for the given filters
*/
AlarmCounts getAlarmCounts(int customerId, Set<Long> equipmentIdSet, Set<AlarmCode> alarmCodeSet);
AlarmCounts getAlarmCounts(int customerId, Set<Long> equipmentIdSet, Set<AlarmCode> alarmCodeSet, Boolean acknowledged);
/**
* In some datastores (i.e. Cassandra) it makes sense to store counts of alarms in a separate table for fast retrieval by UI.
* Unfortunately, there are some situations where those counters get out of sync with the real alarm counts.
* This method is here to re-calculate the counter values and bring them in-sync with the real alarms.
* Retrieves a list of Alarms for the given alarm codes.
*
* @param alarmCodeSet - null or empty means include all alarm codes
* @param createdAfterTimestamp
* @return list of matching Alarm objects.
* @throws IllegalArgumentException if supplied alarmCodeSet is null or empty
*/
default void resetAlarmCounters() {
//only Cassandra datastore needs to implement this
}
List<Alarm> get(Set<AlarmCode> alarmCodeSet, long createdAfterTimestamp);
}

View File

@@ -1,44 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
<artifactId>alarm-datastore-rdbms</artifactId>
<name>alarm-datastore-rdbms</name>
<description>SQL implementation of the data store</description>
<dependencies>
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-jdbc</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>alarm-datastore-interface</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-jdbc-tests</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>alarm-datastore-common-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@@ -1,646 +0,0 @@
package com.telecominfraproject.wlan.alarm.datastore.rdbms;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.sql.DataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.PreparedStatementCreator;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.telecominfraproject.wlan.alarm.models.Alarm;
import com.telecominfraproject.wlan.alarm.models.AlarmCode;
import com.telecominfraproject.wlan.alarm.models.AlarmCounts;
import com.telecominfraproject.wlan.core.model.pagination.ColumnAndSort;
import com.telecominfraproject.wlan.core.model.pagination.PaginationContext;
import com.telecominfraproject.wlan.core.model.pagination.PaginationResponse;
import com.telecominfraproject.wlan.core.model.pagination.SortOrder;
import com.telecominfraproject.wlan.core.server.jdbc.BaseJdbcDao;
import com.telecominfraproject.wlan.datastore.exceptions.DsConcurrentModificationException;
import com.telecominfraproject.wlan.datastore.exceptions.DsDuplicateEntityException;
import com.telecominfraproject.wlan.datastore.exceptions.DsEntityNotFoundException;
/**
* @author dtoptygin
*
*/
@Repository
@Transactional(propagation = Propagation.MANDATORY)
public class AlarmDAO extends BaseJdbcDao {
private static final Logger LOG = LoggerFactory.getLogger(AlarmDatastoreRdbms.class);
private static final String[] GENERATED_KEY_COLS = { };
private static final String[] ALL_COLUMNS_LIST = {
//TODO: add colums from properties Alarm in here
"customerId",
"equipmentId",
"alarmCode",
"createdTimestamp",
"originatorType",
"severity",
"scopeType",
"scopeId",
"details",
"acknowledged",
//make sure the order of properties matches this list and list in AlarmRowMapper and list in create/update methods
"lastModifiedTimestamp"
};
private static final Set<String> columnsToSkipForInsert = new HashSet<>(Arrays.asList());
private static final Set<String> columnsToSkipForUpdate = new HashSet<>(Arrays.asList(
"customerId",
"equipmentId",
"alarmCode",
"createdTimestamp"));
private static final String TABLE_NAME = "alarm";
private static final String TABLE_PREFIX = "s.";
private static final String ALL_COLUMNS;
private static final Set<String> ALL_COLUMNS_LOWERCASE = new HashSet<>();
@SuppressWarnings("unused")
//use this for queries where multiple tables are involved
private static final String ALL_COLUMNS_WITH_PREFIX;
private static final String ALL_COLUMNS_FOR_INSERT;
private static final String BIND_VARS_FOR_INSERT;
private static final String ALL_COLUMNS_UPDATE;
static{
StringBuilder strbAllColumns = new StringBuilder(1024);
StringBuilder strbAllColumnsWithPrefix = new StringBuilder(1024);
StringBuilder strbAllColumnsForInsert = new StringBuilder(1024);
StringBuilder strbBindVarsForInsert = new StringBuilder(128);
StringBuilder strbColumnsForUpdate = new StringBuilder(512);
for(String colName: ALL_COLUMNS_LIST){
ALL_COLUMNS_LOWERCASE.add(colName.toLowerCase());
strbAllColumns.append(colName).append(",");
strbAllColumnsWithPrefix.append(TABLE_PREFIX).append(colName).append(",");
if(!columnsToSkipForInsert.contains(colName)){
strbAllColumnsForInsert.append(colName).append(",");
strbBindVarsForInsert.append("?,");
}
if(!columnsToSkipForUpdate.contains(colName)){
strbColumnsForUpdate.append(colName).append("=?,");
}
}
// remove trailing ','
strbAllColumns.deleteCharAt(strbAllColumns.length() - 1);
strbAllColumnsWithPrefix.deleteCharAt(strbAllColumnsWithPrefix.length() - 1);
strbAllColumnsForInsert.deleteCharAt(strbAllColumnsForInsert.length() - 1);
strbBindVarsForInsert.deleteCharAt(strbBindVarsForInsert.length() - 1);
strbColumnsForUpdate.deleteCharAt(strbColumnsForUpdate.length() - 1);
ALL_COLUMNS = strbAllColumns.toString();
ALL_COLUMNS_WITH_PREFIX = strbAllColumnsWithPrefix.toString();
ALL_COLUMNS_FOR_INSERT = strbAllColumnsForInsert.toString();
BIND_VARS_FOR_INSERT = strbBindVarsForInsert.toString();
ALL_COLUMNS_UPDATE = strbColumnsForUpdate.toString();
}
private static final String SQL_GET_BY_ID =
"select " + ALL_COLUMNS +
" from "+TABLE_NAME+" " +
" where customerId = ? and equipmentId = ? and alarmCode = ? and createdTimestamp = ?";
private static final String SQL_GET_BY_CUSTOMER_ID =
"select " + ALL_COLUMNS +
" from " + TABLE_NAME + " " +
" where customerId = ? ";
private static final String SQL_GET_LASTMOD_BY_ID =
"select lastModifiedTimestamp " +
" from "+TABLE_NAME+" " +
" where customerId = ? and equipmentId = ? and alarmCode = ? and createdTimestamp = ?";
private static final String SQL_INSERT =
"insert into "+TABLE_NAME+" ( "
+ ALL_COLUMNS_FOR_INSERT
+ " ) values ( "+BIND_VARS_FOR_INSERT+" ) ";
private static final String SQL_DELETE =
"delete from "+TABLE_NAME+
" where customerId = ? and equipmentId = ? and alarmCode = ? and createdTimestamp = ?";
private static final String SQL_DELETE_BY_EQUIPMENT =
"delete from "+TABLE_NAME+
" where customerId = ? and equipmentId = ? ";
private static final String SQL_UPDATE =
"update "+TABLE_NAME+" set "
+ ALL_COLUMNS_UPDATE +
" where customerId = ? and equipmentId = ? and alarmCode = ? and createdTimestamp = ?"
+ " and ( lastModifiedTimestamp = ? or ? = true) " //last parameter will allow us to skip check for concurrent modification, if necessary
;
private static final String SQL_PAGING_SUFFIX = " LIMIT ? OFFSET ? ";
private static final String SORT_SUFFIX = "";
private static final String SQL_COUNTS_BY_EQUIPMENT_AND_ALARM_CODE_HEADER = "select equipmentId, alarmCode, count(1) from alarm where customerId = ? ";
private static final String SQL_COUNTS_BY_EQUIPMENT_AND_ALARM_CODE_FOOTER = " group by equipmentId, alarmCode";
private static final String SQL_COUNTS_BY_ALARM_CODE_HEADER = "select alarmCode, count(1) from alarm where customerId = ? ";
private static final String SQL_COUNTS_BY_ALARM_CODE_FOOTER = " group by alarmCode";
private static final RowMapper<Alarm> alarmRowMapper = new AlarmRowMapper();
@Autowired(required=false)
public void setDataSource(AlarmDataSourceInterface dataSource) {
setDataSource((DataSource)dataSource);
}
public Alarm create(final Alarm alarm) {
final long ts = System.currentTimeMillis();
if(alarm.getCreatedTimestamp()<=0) {
alarm.setCreatedTimestamp(ts);
}
alarm.setLastModifiedTimestamp(ts);
try{
jdbcTemplate.update(
new PreparedStatementCreator() {
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
PreparedStatement ps = connection.prepareStatement(SQL_INSERT );
int colIdx = 1;
//TODO: add remaining properties from Alarm here
ps.setInt(colIdx++, alarm.getCustomerId());
ps.setLong(colIdx++, alarm.getEquipmentId());
ps.setInt(colIdx++, alarm.getAlarmCode().getId());
ps.setLong(colIdx++, alarm.getCreatedTimestamp());
ps.setInt(colIdx++, alarm.getOriginatorType().getId());
ps.setInt(colIdx++, alarm.getSeverity().getId());
ps.setInt(colIdx++, alarm.getScopeType().getId());
ps.setString(colIdx++, alarm.getScopeId());
ps.setBytes(colIdx++, (alarm.getDetails()!=null)?alarm.getDetails().toZippedBytes():null);
ps.setBoolean(colIdx++, alarm.isAcknowledged());
ps.setLong(colIdx++, alarm.getLastModifiedTimestamp());
return ps;
}
});
}catch (DuplicateKeyException e) {
throw new DsDuplicateEntityException(e);
}
LOG.debug("Stored Alarm {}", alarm);
return alarm.clone();
}
public Alarm get(int customerId, long equipmentId, AlarmCode alarmCode, long createdTimestamp) {
LOG.debug("Looking up Alarm for id {} {} {} {}", customerId, equipmentId, alarmCode, createdTimestamp);
try {
Alarm alarm = this.jdbcTemplate.queryForObject(
SQL_GET_BY_ID,
alarmRowMapper, customerId, equipmentId, alarmCode.getId(), createdTimestamp);
LOG.debug("Found Alarm {}", alarm);
return alarm;
}catch (EmptyResultDataAccessException e) {
throw new DsEntityNotFoundException(e);
}
}
@Transactional(noRollbackFor = { EmptyResultDataAccessException.class })
public Alarm getOrNull(int customerId, long equipmentId, AlarmCode alarmCode, long createdTimestamp) {
LOG.debug("Looking up Alarm for id {} {} {} {}", customerId, equipmentId, alarmCode, createdTimestamp);
try{
Alarm alarm = this.jdbcTemplate.queryForObject(
SQL_GET_BY_ID,
alarmRowMapper, customerId, equipmentId, alarmCode.getId(), createdTimestamp);
LOG.debug("Found Alarm {}", alarm);
return alarm;
}catch (EmptyResultDataAccessException e) {
LOG.debug("Could not find Alarm for id {} {} {} {}", customerId, equipmentId, alarmCode, createdTimestamp);
return null;
}
}
public Alarm update(Alarm alarm) {
long newLastModifiedTs = System.currentTimeMillis();
long incomingLastModifiedTs = alarm.getLastModifiedTimestamp();
int updateCount = this.jdbcTemplate.update(SQL_UPDATE, new Object[]{
//TODO: add remaining properties from Alarm here
alarm.getOriginatorType().getId(),
alarm.getSeverity().getId(),
alarm.getScopeType().getId(),
alarm.getScopeId(),
(alarm.getDetails()!=null)?alarm.getDetails().toZippedBytes():null ,
alarm.isAcknowledged(),
newLastModifiedTs,
// use id for update operation
alarm.getCustomerId(),
alarm.getEquipmentId(),
alarm.getAlarmCode().getId(),
alarm.getCreatedTimestamp(),
// use lastModifiedTimestamp for data protection against concurrent modifications
incomingLastModifiedTs,
isSkipCheckForConcurrentUpdates()
});
if(updateCount==0){
try{
if(isSkipCheckForConcurrentUpdates()){
//in this case we did not request protection against concurrent updates,
//so the updateCount is 0 because record in db was not found
throw new EmptyResultDataAccessException(1);
}
//find out if record could not be updated because it does not exist or because it was modified concurrently
long recordTimestamp = this.jdbcTemplate.queryForObject(
SQL_GET_LASTMOD_BY_ID,
Long.class,
alarm.getCustomerId(),
alarm.getEquipmentId(),
alarm.getAlarmCode().getId(),
alarm.getCreatedTimestamp()
);
LOG.debug("Concurrent modification detected for Alarm with id {} {} {} {} expected version is {} but version in db was {}",
alarm.getCustomerId(),
alarm.getEquipmentId(),
alarm.getAlarmCode().getId(),
alarm.getCreatedTimestamp(),
incomingLastModifiedTs,
recordTimestamp
);
throw new DsConcurrentModificationException("Concurrent modification detected for Alarm with id " +
alarm.getCustomerId() + " " +
alarm.getEquipmentId() + " " +
alarm.getAlarmCode().getId() + " " +
alarm.getCreatedTimestamp() + " "
+" expected version is " + incomingLastModifiedTs
+" but version in db was " + recordTimestamp
);
}catch (EmptyResultDataAccessException e) {
LOG.debug("Cannot find Alarm for {} {} {} {} ", alarm.getCustomerId(),
alarm.getEquipmentId(),
alarm.getAlarmCode().getId(),
alarm.getCreatedTimestamp());
throw new DsEntityNotFoundException("Alarm not found " +
alarm.getCustomerId() + " " +
alarm.getEquipmentId() + " " +
alarm.getAlarmCode().getId() + " " +
alarm.getCreatedTimestamp());
}
}
//make a copy so that we don't accidentally update caller's version by reference
Alarm alarmCopy = alarm.clone();
alarmCopy.setLastModifiedTimestamp(newLastModifiedTs);
LOG.debug("Updated Alarm {}", alarmCopy);
return alarmCopy;
}
public Alarm delete(int customerId, long equipmentId, AlarmCode alarmCode, long createdTimestamp) {
Alarm ret = get(customerId, equipmentId, alarmCode, createdTimestamp);
this.jdbcTemplate.update(SQL_DELETE, customerId, equipmentId, alarmCode.getId(), createdTimestamp);
LOG.debug("Deleted Alarm {}", ret);
return ret;
}
public List<Alarm> delete(int customerId, long equipmentId) {
List<Alarm> ret = get(customerId, Collections.singleton(equipmentId), null, -1);
this.jdbcTemplate.update(SQL_DELETE_BY_EQUIPMENT, customerId, equipmentId);
LOG.debug("Deleted Alarms {}", ret);
return ret;
}
public List<Alarm> get(int customerId, Set<Long> equipmentIds, Set<AlarmCode> alarmCodes,
long createdAfterTimestamp) {
if(equipmentIds == null || equipmentIds.isEmpty()) {
throw new IllegalArgumentException("equipmentIds must be provided");
}
LOG.debug("Looking up Alarms for customer {} equipment {} codes {} createdAfter {}",
customerId, equipmentIds, alarmCodes, createdAfterTimestamp);
String query = SQL_GET_BY_CUSTOMER_ID;
// add filters for the query
ArrayList<Object> queryArgs = new ArrayList<>();
queryArgs.add(customerId);
//add equipmentId filters
if (equipmentIds != null && !equipmentIds.isEmpty()) {
queryArgs.addAll(equipmentIds);
StringBuilder strb = new StringBuilder(100);
strb.append("and equipmentId in (");
for (int i = 0; i < equipmentIds.size(); i++) {
strb.append("?");
if (i < equipmentIds.size() - 1) {
strb.append(",");
}
}
strb.append(") ");
query += strb.toString();
}
//add alarmCodes filters
if (alarmCodes != null && !alarmCodes.isEmpty()) {
alarmCodes.forEach(ac -> queryArgs.add(ac.getId()));
StringBuilder strb = new StringBuilder(100);
strb.append("and alarmCode in (");
for (int i = 0; i < alarmCodes.size(); i++) {
strb.append("?");
if (i < alarmCodes.size() - 1) {
strb.append(",");
}
}
strb.append(") ");
query += strb.toString();
}
if(createdAfterTimestamp > 0) {
query += " and createdTimestamp > ?" ;
queryArgs.add(createdAfterTimestamp);
}
List<Alarm> ret = this.jdbcTemplate.query(query, queryArgs.toArray(),
alarmRowMapper);
LOG.debug("Found {} Alarms for customer {} equipment {} codes {} createdAfter {}",
ret.size(),
customerId, equipmentIds, alarmCodes, createdAfterTimestamp);
return ret;
}
public List<Alarm> getAllForCustomer(int customerId) {
LOG.debug("Looking up Alarms for customer {}", customerId);
List<Alarm> ret = this.jdbcTemplate.query(SQL_GET_BY_CUSTOMER_ID,
alarmRowMapper, customerId);
LOG.debug("Found Alarms for customer {} : {}", customerId, ret);
return ret;
}
public PaginationResponse<Alarm> getForCustomer(int customerId,
Set<Long> equipmentIds, Set<AlarmCode> alarmCodes, long createdAfterTimestamp,
List<ColumnAndSort> sortBy, PaginationContext<Alarm> context) {
PaginationResponse<Alarm> ret = new PaginationResponse<>();
ret.setContext(context.clone());
if (ret.getContext().isLastPage()) {
// no more pages available according to the context
LOG.debug(
"No more pages available when looking up Alarms for customer {} with last returned page number {}",
customerId, context.getLastReturnedPageNumber());
return ret;
}
LOG.debug("Looking up Alarms for customer {} with last returned page number {}",
customerId, context.getLastReturnedPageNumber());
String query = SQL_GET_BY_CUSTOMER_ID;
// add filters for the query
ArrayList<Object> queryArgs = new ArrayList<>();
queryArgs.add(customerId);
//add equipmentId filters
if (equipmentIds != null && !equipmentIds.isEmpty()) {
queryArgs.addAll(equipmentIds);
StringBuilder strb = new StringBuilder(100);
strb.append("and equipmentId in (");
for (int i = 0; i < equipmentIds.size(); i++) {
strb.append("?");
if (i < equipmentIds.size() - 1) {
strb.append(",");
}
}
strb.append(") ");
query += strb.toString();
}
//add alarmCodes filters
if (alarmCodes != null && !alarmCodes.isEmpty()) {
alarmCodes.forEach(ac -> queryArgs.add(ac.getId()));
StringBuilder strb = new StringBuilder(100);
strb.append("and alarmCode in (");
for (int i = 0; i < alarmCodes.size(); i++) {
strb.append("?");
if (i < alarmCodes.size() - 1) {
strb.append(",");
}
}
strb.append(") ");
query += strb.toString();
}
if(createdAfterTimestamp > 0) {
query += " and createdTimestamp > ?" ;
queryArgs.add(createdAfterTimestamp);
}
// add sorting options for the query
StringBuilder strbSort = new StringBuilder(100);
strbSort.append(" order by ");
if (sortBy != null && !sortBy.isEmpty()) {
// use supplied sorting options
for (ColumnAndSort column : sortBy) {
if (!ALL_COLUMNS_LOWERCASE.contains(column.getColumnName().toLowerCase())) {
// unknown column, skip it
continue;
}
strbSort.append(column.getColumnName());
if (column.getSortOrder() == SortOrder.desc) {
strbSort.append(" desc");
}
strbSort.append(",");
}
// remove last ','
strbSort.deleteCharAt(strbSort.length() - 1);
} else {
// no sort order was specified - sort by id to have consistent
// paging
strbSort.append(" equipmentId, createdTimestamp");
}
query += strbSort.toString();
// add pagination parameters for the query
query += SQL_PAGING_SUFFIX ;
queryArgs.add(context.getMaxItemsPerPage());
queryArgs.add(context.getTotalItemsReturned());
/*
* https://www.citusdata.com/blog/2016/03/30/five-ways-to-paginate/
* Choosing offset=1000 makes cost about 19 and has a 0.609 ms execution
* time. Once offset=5,000,000 the cost goes up to 92734 and execution
* time is 758.484 ms. - DT: still acceptable for our use case
*/
List<Alarm> pageItems = this.jdbcTemplate.query(query, queryArgs.toArray(),
alarmRowMapper);
LOG.debug("Found {} Alarms for customer {} with last returned page number {}",
pageItems.size(), customerId, context.getLastReturnedPageNumber());
ret.setItems(pageItems);
// adjust context for the next page
ret.prepareForNextPage();
// startAfterItem is not used in RDBMS datastores, set it to null
ret.getContext().setStartAfterItem(null);
return ret;
}
public AlarmCounts getAlarmCounts(int customerId, Set<Long> equipmentIds, Set<AlarmCode> alarmCodes) {
ArrayList<Object> queryArgs = new ArrayList<>();
queryArgs.add(customerId);
//build the query
StringBuilder query = new StringBuilder();
if(equipmentIds == null || equipmentIds.isEmpty()) {
query.append(SQL_COUNTS_BY_ALARM_CODE_HEADER);
} else {
query.append(SQL_COUNTS_BY_EQUIPMENT_AND_ALARM_CODE_HEADER);
}
//add alarmCodes filters
if (alarmCodes != null && !alarmCodes.isEmpty()) {
alarmCodes.forEach(ac -> queryArgs.add(ac.getId()));
StringBuilder strb = new StringBuilder(100);
strb.append("and alarmCode in (");
for (int i = 0; i < alarmCodes.size(); i++) {
strb.append("?");
if (i < alarmCodes.size() - 1) {
strb.append(",");
}
}
strb.append(") ");
query.append(strb);
}
//add equipmentId filters
if (equipmentIds != null && !equipmentIds.isEmpty()) {
queryArgs.addAll(equipmentIds);
StringBuilder strb = new StringBuilder(100);
strb.append("and equipmentId in (");
for (int i = 0; i < equipmentIds.size(); i++) {
strb.append("?");
if (i < equipmentIds.size() - 1) {
strb.append(",");
}
}
strb.append(") ");
query.append(strb);
}
if(equipmentIds == null || equipmentIds.isEmpty()) {
query.append(SQL_COUNTS_BY_ALARM_CODE_FOOTER);
} else {
query.append(SQL_COUNTS_BY_EQUIPMENT_AND_ALARM_CODE_FOOTER);
}
AlarmCounts alarmCounts = new AlarmCounts();
alarmCounts.setCustomerId(customerId);
this.jdbcTemplate.query(query.toString(), queryArgs.toArray(),
new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
if(equipmentIds == null || equipmentIds.isEmpty()) {
alarmCounts.addToCounter(0, AlarmCode.getById(rs.getInt(1)), rs.getInt(2));
} else {
alarmCounts.addToCounter(rs.getLong(1), AlarmCode.getById(rs.getInt(2)), rs.getInt(3));
}
}
});
return alarmCounts;
}
}

View File

@@ -1,31 +0,0 @@
package com.telecominfraproject.wlan.alarm.datastore.rdbms;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
import com.telecominfraproject.wlan.core.server.jdbc.BaseDataSourceConfig;
/**
* @author dtoptygin
*
*/
@Component
@Profile("!use_single_ds")
@PropertySource({ "${alarm-ds.props:classpath:alarm-ds.properties}" })
public class AlarmDataSourceConfig extends BaseDataSourceConfig {
@Bean
public AlarmDataSourceInterface alarmDataSourceInterface(){
AlarmDataSourceInterface ret = new AlarmDataSourceImpl(getDataSource(), getKeyColumnConverter());
return ret;
}
@Override
public String getDataSourceName() {
return "alarm-ds";
}
}

View File

@@ -1,18 +0,0 @@
package com.telecominfraproject.wlan.alarm.datastore.rdbms;
import javax.sql.DataSource;
import com.telecominfraproject.wlan.core.server.jdbc.BaseJDbcDataSource;
import com.telecominfraproject.wlan.core.server.jdbc.BaseKeyColumnConverter;
/**
* @author dtoptygin
* SQL DataSource that is used by Alarm Service
*/
public class AlarmDataSourceImpl extends BaseJDbcDataSource implements AlarmDataSourceInterface {
public AlarmDataSourceImpl(DataSource targetDataSource, BaseKeyColumnConverter keyColumnConverter){
super(targetDataSource, keyColumnConverter);
}
}

View File

@@ -1,11 +0,0 @@
package com.telecominfraproject.wlan.alarm.datastore.rdbms;
import javax.sql.DataSource;
/**
* @author dtoptygin
* Marker interface to distinguish SQL DataSource that is used by Alarm Service
*/
public interface AlarmDataSourceInterface extends DataSource {
}

View File

@@ -1,76 +0,0 @@
package com.telecominfraproject.wlan.alarm.datastore.rdbms;
import java.util.List;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import com.telecominfraproject.wlan.core.model.pagination.ColumnAndSort;
import com.telecominfraproject.wlan.core.model.pagination.PaginationContext;
import com.telecominfraproject.wlan.core.model.pagination.PaginationResponse;
import com.telecominfraproject.wlan.alarm.datastore.AlarmDatastore;
import com.telecominfraproject.wlan.alarm.models.Alarm;
import com.telecominfraproject.wlan.alarm.models.AlarmCode;
import com.telecominfraproject.wlan.alarm.models.AlarmCounts;
/**
* @author dtoptygin
*
*/
@Configuration
public class AlarmDatastoreRdbms implements AlarmDatastore {
@Autowired AlarmDAO alarmDAO;
@Override
public Alarm create(Alarm alarm) {
return alarmDAO.create(alarm);
}
@Override
public Alarm getOrNull(int customerId, long equipmentId, AlarmCode alarmCode, long createdTimestamp) {
return alarmDAO.getOrNull(customerId, equipmentId, alarmCode, createdTimestamp);
}
@Override
public Alarm update(Alarm alarm) {
return alarmDAO.update(alarm);
}
@Override
public Alarm delete(int customerId, long equipmentId, AlarmCode alarmCode, long createdTimestamp) {
return alarmDAO.delete(customerId, equipmentId, alarmCode, createdTimestamp);
}
@Override
public List<Alarm> delete(int customerId, long equipmentId) {
return alarmDAO.delete(customerId, equipmentId);
}
@Override
public List<Alarm> get(int customerId, Set<Long> equipmentIdSet, Set<AlarmCode> alarmCodeSet,
long createdAfterTimestamp) {
return alarmDAO.get(customerId, equipmentIdSet, alarmCodeSet, createdAfterTimestamp);
}
@Override
public PaginationResponse<Alarm> getForCustomer(int customerId, Set<Long> equipmentIdSet,
Set<AlarmCode> alarmCodeSet, long createdAfterTimestamp, List<ColumnAndSort> sortBy,
PaginationContext<Alarm> context) {
if(context == null) {
context = new PaginationContext<>();
}
return alarmDAO.getForCustomer(customerId, equipmentIdSet,
alarmCodeSet, createdAfterTimestamp, sortBy,
context);
}
@Override
public AlarmCounts getAlarmCounts(int customerId, Set<Long> equipmentIdSet, Set<AlarmCode> alarmCodeSet) {
return alarmDAO.getAlarmCounts(customerId, equipmentIdSet, alarmCodeSet);
}
}

View File

@@ -1,58 +0,0 @@
package com.telecominfraproject.wlan.alarm.datastore.rdbms;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.RowMapper;
import com.telecominfraproject.wlan.alarm.models.Alarm;
import com.telecominfraproject.wlan.alarm.models.AlarmCode;
import com.telecominfraproject.wlan.alarm.models.AlarmDetails;
import com.telecominfraproject.wlan.alarm.models.AlarmScopeType;
import com.telecominfraproject.wlan.alarm.models.OriginatorType;
import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;
import com.telecominfraproject.wlan.status.models.StatusCode;
/**
* @author dtoptygin
*
*/
public class AlarmRowMapper implements RowMapper<Alarm> {
private static final Logger LOG = LoggerFactory.getLogger(AlarmRowMapper.class);
public Alarm mapRow(ResultSet rs, int rowNum) throws SQLException {
Alarm alarm = new Alarm();
int colIdx=1;
//TODO: add columns from properties Alarm in here.
//make sure order of fields is the same as defined in Alarm
alarm.setCustomerId(rs.getInt(colIdx++));
alarm.setEquipmentId(rs.getLong(colIdx++));
alarm.setAlarmCode(AlarmCode.getById(rs.getInt(colIdx++)));
alarm.setCreatedTimestamp(rs.getLong(colIdx++));
alarm.setOriginatorType(OriginatorType.getById(rs.getInt(colIdx++)));
alarm.setSeverity(StatusCode.getById(rs.getInt(colIdx++)));
alarm.setScopeType(AlarmScopeType.getById(rs.getInt(colIdx++)));
alarm.setScopeId(rs.getString(colIdx++));
byte[] zippedBytes = rs.getBytes(colIdx++);
if (zippedBytes !=null) {
try {
AlarmDetails details = BaseJsonModel.fromZippedBytes(zippedBytes, AlarmDetails.class);
alarm.setDetails(details);
} catch (RuntimeException exp) {
LOG.error("Failed to decode AlarmDetails from database for {}", alarm);
}
}
alarm.setAcknowledged(rs.getBoolean(colIdx++));
alarm.setLastModifiedTimestamp(rs.getLong(colIdx++));
return alarm;
}
}

View File

@@ -1,22 +0,0 @@
create table if not exists alarm (
customerId int not null,
equipmentId bigint default 0 not null,
alarmCode int not null,
createdTimestamp bigint not null,
originatorType int not null,
severity int not null,
scopeType int not null,
scopeId varchar(255) not null,
details bytea,
acknowledged boolean,
lastModifiedTimestamp bigint not null,
primary key (customerId, equipmentId, alarmCode, createdTimestamp)
);
create index if not exists idx_alarm_customerId on alarm (customerId);
create index if not exists idx_alarm_equipmentId on alarm (equipmentId );

View File

@@ -1,70 +0,0 @@
package com.telecominfraproject.wlan.alarm.datastore.rdbms;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Import;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
import com.telecominfraproject.wlan.core.server.jdbc.test.BaseJdbcTest;
import com.telecominfraproject.wlan.core.server.jdbc.test.TestWithEmbeddedDB;
import com.telecominfraproject.wlan.alarm.models.Alarm;
import com.telecominfraproject.wlan.alarm.models.AlarmCode;
/**
* @author dtoptygin
*
*/
@Import(value = {
AlarmDatastoreRdbms.class,
AlarmDataSourceConfig.class,
AlarmDAO.class,
BaseJdbcTest.Config.class
})
@TestWithEmbeddedDB
public class AlarmDatastoreRdbmsPlumbingTests extends BaseJdbcTest {
@Autowired(required=false) private EmbeddedDatabase db;
@Autowired private AlarmDatastoreRdbms alarmDatastore;
@Autowired private AlarmDAO alarmDAO;
@Before
public void setUp() {
}
@Test
public void testDataAccess() {
if(db!=null){
//this is a simple test to see if embedded db is working in test environment
JdbcTemplate jdbcTemplate = new JdbcTemplate(db);
Long ret = jdbcTemplate.queryForObject(
"select equipmentId from alarm where customerId = ? and equipmentId = ? and alarmCode = ? and createdTimestamp = ?",
Long.class, 1, 1L, 4, 1L);
assertEquals((Long)1L, ret);
}
}
@Test
public void testCreateUpdateDeleteAlarm() {
//GET by Id test
assertNotNull(alarmDatastore.getOrNull(1, 1L, AlarmCode.AccessPointIsUnreachable, 1L));
//DELETE Test
alarmDatastore.delete(1, 1L, AlarmCode.AccessPointIsUnreachable, 1L);
assertNull(alarmDatastore.getOrNull(1, 1L, AlarmCode.AccessPointIsUnreachable, 1L));
}
}

View File

@@ -1,29 +0,0 @@
package com.telecominfraproject.wlan.alarm.datastore.rdbms;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.context.annotation.Import;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import com.telecominfraproject.wlan.core.server.jdbc.test.BaseJdbcTest;
import com.telecominfraproject.wlan.core.server.jdbc.test.TestWithEmbeddedDB;
import com.telecominfraproject.wlan.alarm.datastore.BaseAlarmDatastoreTest;
/**
* @author dtoptygin
*
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.NONE, classes = BaseJdbcTest.Config.class)
@Rollback(value = true)
@Transactional
@Import(value = { AlarmDatastoreRdbms.class, AlarmDataSourceConfig.class,
AlarmDAO.class, BaseJdbcTest.Config.class })
@TestWithEmbeddedDB
public class AlarmDatastoreRdbmsTests extends BaseAlarmDatastoreTest {
}

View File

@@ -1,41 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<conversionRule conversionWord="filteredStack"
converterClass="com.telecominfraproject.wlan.server.exceptions.logback.ExceptionCompressingConverter" />
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n%filteredStack%nopex</pattern>
<!-- See http://logback.qos.ch/manual/layouts.html for details -->
<!-- %ex{5} - add at the end to display only 5 levels of the exception stack trace -->
<!-- %nopex - add at the end to not display any of the exception stack traces -->
<!-- %ex{full} - add at the end to display all the levels of the exception stack trace -->
</encoder>
</appender>
<!--
details: http://logback.qos.ch/manual/configuration.html#auto_configuration
runtime configuration, if need to override the defaults:
-Dlogging.config=file:///home/ec2-user/opensync/logback.xml
for log configuration debugging - use
-Dlogback.statusListenerClass=ch.qos.logback.core.status.OnConsoleStatusListener
log levels:
OFF ERROR WARN INFO DEBUG TRACE
-->
<logger name="org.apache.catalina.startup.DigesterFactory" level="ERROR"/>
<logger name="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" level="INFO"/>
<logger name="org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer" level="INFO"/>
<logger name="org.springframework.security.web.authentication.preauth" level="OFF"/>
<logger name="com.netflix.servo.tag.aws.AwsInjectableTag" level="OFF"/>
<logger name="com.telecominfraproject" level="WARN"/>
<root level="WARN">
<appender-ref ref="stdout"/>
</root>
</configuration>

View File

@@ -1,24 +0,0 @@
drop table alarm if exists;
create table alarm (
customerId int not null,
equipmentId bigint default 0 not null,
alarmCode int not null,
createdTimestamp bigint not null,
originatorType int not null,
severity int not null,
scopeType int not null,
scopeId varchar(255) not null,
details varbinary(65535),
acknowledged boolean,
lastModifiedTimestamp bigint not null,
primary key (customerId, equipmentId, alarmCode, createdTimestamp)
);
create index idx_alarm_customerId on alarm (customerId);
create index idx_alarm_equipmentId on alarm (equipmentId );

View File

@@ -1,23 +0,0 @@
insert into alarm (
customerId,
equipmentId,
alarmCode,
createdTimestamp,
originatorType,
severity,
scopeType,
scopeId,
details,
acknowledged,
lastModifiedTimestamp
) values (
1,1,4,1,
1,1,1, '-1',
null,
false,0
);

1
alarm-models/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target/

View File

@@ -1,10 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
@@ -16,17 +15,17 @@
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-models</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>status-models</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>system-event-models</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
</dependencies>

View File

@@ -53,7 +53,7 @@ public class AlarmCode implements EnumWithId {
public static final AlarmCode
LimitedCloudConnectivity = new AlarmCode(3, "LimitedCloudConnectivity", "Equipment is connected, however it's not reporting status or metrics", StatusCode.error, "Service AP and verify networking path to cloud"),
AccessPointIsUnreachable = new AlarmCode(4, "AccessPointIsUnreachable", "Equipment is not reachable from cloud", StatusCode.error, "Service AP and verify networking path to cloud"),
NoMetricsReceived = new AlarmCode(6, "NoMetricsReceived", "Equipment is not report metrics"),
NoMetricsReceived = new AlarmCode(6, "NoMetricsReceived", "Metrics are not received from the equipment"),
NoiseFloor2G = new AlarmCode(7, "NoiseFloor2G", "Noise floor is too high on 2G radio", StatusCode.requiresAttention, "Investigate interference sources"),
ChannelUtilization2G = new AlarmCode(8, "ChannelUtilization2G", "Channel utilization is too high on 2G radio", StatusCode.requiresAttention, "Consider adding more APs"),
NoiseFloor5G = new AlarmCode(9, "NoiseFloor5G", "Noise floor is too high on 5G radio", StatusCode.requiresAttention, "Investigate interference sources"),

View File

@@ -5,14 +5,18 @@ import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;
import com.telecominfraproject.wlan.status.models.StatusCode;
public class AlarmCounts extends BaseJsonModel {
private static final long serialVersionUID = -8513006445975878351L;
private int customerId;
private Boolean acknowledged;
private Map<Long, Map<AlarmCode, AtomicInteger>> countsPerEquipmentIdMap = new HashMap<>();
private Map<Long, AtomicInteger> totalCountsPerEquipmentIdMap = new HashMap<>();
private Map<AlarmCode, AtomicInteger> totalCountsPerAlarmCodeMap = new HashMap<>();
private Map<StatusCode, AtomicInteger> totalCountsBySeverityMap = new HashMap<>();
public int getCustomerId() {
return customerId;
@@ -20,20 +24,38 @@ public class AlarmCounts extends BaseJsonModel {
public void setCustomerId(int customerId) {
this.customerId = customerId;
}
public Map<Long, Map<AlarmCode, AtomicInteger>> getCountsPerEquipmentIdMap() {
public Boolean getAcknowledged() {
return acknowledged;
}
public void setAcknowledged(Boolean acknowledged) {
this.acknowledged = acknowledged;
}
public Map<Long, Map<AlarmCode, AtomicInteger>> getCountsPerEquipmentIdMap() {
return countsPerEquipmentIdMap;
}
public void setCountsPerEquipmentIdMap(Map<Long, Map<AlarmCode, AtomicInteger>> countsPerEquipmentIdMap) {
this.countsPerEquipmentIdMap = countsPerEquipmentIdMap;
}
public Map<Long, AtomicInteger> getTotalCountsPerEquipmentIdMap() {
return totalCountsPerEquipmentIdMap;
}
public void setTotalCountsPerEquipmentIdMap(Map<Long, AtomicInteger> totalCountsPerEquipmentIdMap) {
this.totalCountsPerEquipmentIdMap = totalCountsPerEquipmentIdMap;
}
public Map<AlarmCode, AtomicInteger> getTotalCountsPerAlarmCodeMap() {
return totalCountsPerAlarmCodeMap;
}
public void setTotalCountsPerAlarmCodeMap(Map<AlarmCode, AtomicInteger> totalCountsPerAlarmCodeMap) {
this.totalCountsPerAlarmCodeMap = totalCountsPerAlarmCodeMap;
}
public void addToCounter(long equipmentId, AlarmCode alarmCode, int valueToAdd) {
public Map<StatusCode, AtomicInteger> getTotalCountsBySeverityMap() {
return totalCountsBySeverityMap;
}
public void setTotalCountsBySeverityMap(Map<StatusCode, AtomicInteger> totalCountsBySeverityMap) {
this.totalCountsBySeverityMap = totalCountsBySeverityMap;
}
public void addToCounter(long equipmentId, AlarmCode alarmCode, int valueToAdd) {
//update total counts
AtomicInteger totalCount = totalCountsPerAlarmCodeMap.get(alarmCode);
if (totalCount == null) {
@@ -42,7 +64,23 @@ public class AlarmCounts extends BaseJsonModel {
}
totalCount.addAndGet(valueToAdd);
//update total counts by severity
AtomicInteger totalBySeverityCount = totalCountsBySeverityMap.get(alarmCode.getSeverity());
if (totalBySeverityCount == null) {
totalBySeverityCount = new AtomicInteger();
totalCountsBySeverityMap.put(alarmCode.getSeverity(), totalBySeverityCount);
}
totalBySeverityCount.addAndGet(valueToAdd);
if(equipmentId>0) {
//update total counts by equipmentId
AtomicInteger totalEquipmentIdCount = totalCountsPerEquipmentIdMap.get(equipmentId);
if (totalEquipmentIdCount == null) {
totalEquipmentIdCount = new AtomicInteger();
totalCountsPerEquipmentIdMap.put(equipmentId, totalEquipmentIdCount);
}
totalEquipmentIdCount.addAndGet(valueToAdd);
//update per-equipmentId counts only for real equipmentIds
Map<AlarmCode, AtomicInteger> perEquipmentMap = countsPerEquipmentIdMap.get(equipmentId);
if(perEquipmentMap == null) {
@@ -50,6 +88,7 @@ public class AlarmCounts extends BaseJsonModel {
countsPerEquipmentIdMap.put(equipmentId, perEquipmentMap);
}
//update counts by equipmentId and alarmCode
AtomicInteger perEqCount = perEquipmentMap.get(alarmCode);
if(perEqCount == null) {
perEqCount = new AtomicInteger();
@@ -63,6 +102,14 @@ public class AlarmCounts extends BaseJsonModel {
public int getCounter(long equipmentId, AlarmCode alarmCode) {
if(equipmentId>0) {
if (alarmCode == null) {
AtomicInteger perEqTotalCount = totalCountsPerEquipmentIdMap.get(equipmentId);
if (perEqTotalCount == null) {
return 0;
}
return perEqTotalCount.get();
}
//get from per-equipmentId counts only for real equipmentIds
Map<AlarmCode, AtomicInteger> perEquipmentMap = countsPerEquipmentIdMap.get(equipmentId);
if(perEquipmentMap == null) {
@@ -88,6 +135,12 @@ public class AlarmCounts extends BaseJsonModel {
}
}
public int getSeverityCounter(StatusCode severity) {
AtomicInteger ret = totalCountsBySeverityMap.get(severity);
if (ret == null) {
return 0;
}
return ret.get();
}
}

View File

@@ -10,10 +10,29 @@ import com.telecominfraproject.wlan.systemevent.models.EquipmentEventWithPayload
public class AlarmAddedEvent extends EquipmentEventWithPayload<Alarm> {
private static final long serialVersionUID = 7142208487917559985L;
/**
* Constructor with current event time stamp
* @param alarm
*/
public AlarmAddedEvent(Alarm alarm){
super(alarm.getCustomerId(), alarm.getEquipmentId(), alarm.getLastModifiedTimestamp(), alarm);
super(alarm.getCustomerId(), alarm.getEquipmentId(), alarm);
}
/**
* Constructor with explicit event time stamp. This constructor is used to
* workaround the issue with how the System events are defined in the cassandra
* schema: No two events can have the same combination of
* customerId+equipmentId+dataType+eventTimestamp, so the application code must
* work around this limitation by creating unique event time stamps if 2
* alarms are raised at the same time.
*
* @param alarm
* @param eventTimestamp
*/
public AlarmAddedEvent(Alarm alarm, long eventTimestamp){
super(alarm.getCustomerId(), alarm.getEquipmentId(), eventTimestamp, alarm);
}
/**
* Constructor used by JSON
*/

View File

@@ -11,7 +11,7 @@ public class AlarmChangedEvent extends EquipmentEventWithPayload<Alarm> {
private static final long serialVersionUID = 7142209997917559985L;
public AlarmChangedEvent(Alarm alarm){
super(alarm.getCustomerId(), alarm.getEquipmentId(), alarm.getLastModifiedTimestamp(), alarm);
super(alarm.getCustomerId(), alarm.getEquipmentId(), alarm);
}
/**

View File

@@ -11,7 +11,7 @@ public class AlarmRemovedEvent extends EquipmentEventWithPayload<Alarm> {
private static final long serialVersionUID = 7142208488887559985L;
public AlarmRemovedEvent(Alarm alarm){
super(alarm.getCustomerId(), alarm.getEquipmentId(), System.currentTimeMillis(), alarm);
super(alarm.getCustomerId(), alarm.getEquipmentId(), alarm);
}
/**

1
alarm-service-interface/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target/

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
@@ -15,7 +15,7 @@
<dependency>
<artifactId>alarm-models</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
</dependencies>

View File

@@ -3,7 +3,6 @@ package com.telecominfraproject.wlan.alarm;
import java.util.List;
import java.util.Set;
import com.telecominfraproject.wlan.core.model.json.GenericResponse;
import com.telecominfraproject.wlan.core.model.pagination.ColumnAndSort;
import com.telecominfraproject.wlan.core.model.pagination.PaginationContext;
import com.telecominfraproject.wlan.core.model.pagination.PaginationResponse;
@@ -104,21 +103,26 @@ public interface AlarmServiceInterface {
* @param createdAfterTimestamp
* @return next page of matching Alarm objects.
*/
PaginationResponse<Alarm> getForCustomer(int customerId, Set<Long> equipmentIdSet, Set<AlarmCode> alarmCodeSet, long createdAfterTimestamp, List<ColumnAndSort> sortBy, PaginationContext<Alarm> context);
PaginationResponse<Alarm> getForCustomer(int customerId, Set<Long> equipmentIdSet, Set<AlarmCode> alarmCodeSet, long createdAfterTimestamp, Boolean acknowledged, List<ColumnAndSort> sortBy, PaginationContext<Alarm> context);
/**
* @param customerId
* @param equipmentIdSet - if empty, then only total counts of all alarms for customer per alarm code will be counted
* @param alarmCodeSet - can be empty, in which case all alarm codes will be counted
* @param acknowledged - can be empty, in which case acknowledged would be ignored
* @return alarm counts for the given filters
*/
AlarmCounts getAlarmCounts(int customerId, Set<Long> equipmentIdSet, Set<AlarmCode> alarmCodeSet);
AlarmCounts getAlarmCounts(int customerId, Set<Long> equipmentIdSet, Set<AlarmCode> alarmCodeSet, Boolean acknowledged);
/**
* In some datastores (i.e. Cassandra) it makes sense to store counts of alarms in a separate table for fast retrieval by UI.
* Unfortunately, there are some situations where those counters get out of sync with the real alarm counts.
* This method is here to re-calculate the counter values and bring them in-sync with the real alarms.
* Retrieves a list of Alarms for the given alarm codes.
*
* @param alarmCodeSet - null or empty means include all alarm codes
* @param createdAfterTimestamp
* @return list of matching Alarm objects.
* @throws IllegalArgumentException if supplied alarmCodeSet is null or empty
*/
GenericResponse resetAlarmCounters() ;
List<Alarm> get(Set<AlarmCode> alarmCodeSet, long createdAfterTimestamp);
}

1
alarm-service-local/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target/

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
@@ -16,13 +16,13 @@
<dependency>
<artifactId>alarm-service-interface</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>alarm-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
</dependencies>

View File

@@ -8,7 +8,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.telecominfraproject.wlan.core.model.json.GenericResponse;
import com.telecominfraproject.wlan.core.model.pagination.ColumnAndSort;
import com.telecominfraproject.wlan.core.model.pagination.PaginationContext;
import com.telecominfraproject.wlan.core.model.pagination.PaginationResponse;
@@ -48,6 +47,10 @@ public class AlarmServiceLocal implements AlarmServiceInterface {
return alarmController.getAllForEquipment(customerId, equipmentIdSet, alarmCodeSet, createdAfterTimestamp);
}
@Override
public List<Alarm> get(Set<AlarmCode> alarmCodeSet, long createdAfterTimestamp) {
return alarmController.getAllForAlarmCode(alarmCodeSet, createdAfterTimestamp);
}
@Override
public Alarm update(Alarm alarm) {
@@ -69,20 +72,16 @@ public class AlarmServiceLocal implements AlarmServiceInterface {
@Override
public PaginationResponse<Alarm> getForCustomer(int customerId, Set<Long> equipmentIdSet,
Set<AlarmCode> alarmCodeSet, long createdAfterTimestamp, List<ColumnAndSort> sortBy,
Set<AlarmCode> alarmCodeSet, long createdAfterTimestamp, Boolean acknowledged, List<ColumnAndSort> sortBy,
PaginationContext<Alarm> context) {
return alarmController.getForCustomer(customerId, equipmentIdSet,
alarmCodeSet, createdAfterTimestamp, sortBy, context);
alarmCodeSet, createdAfterTimestamp, acknowledged, sortBy, context);
}
@Override
public AlarmCounts getAlarmCounts(int customerId, Set<Long> equipmentIdSet, Set<AlarmCode> alarmCodeSet) {
return alarmController.getAlarmCounts(customerId, equipmentIdSet, alarmCodeSet);
public AlarmCounts getAlarmCounts(int customerId, Set<Long> equipmentIdSet, Set<AlarmCode> alarmCodeSet, Boolean acknowledged) {
return alarmController.getAlarmCounts(customerId, equipmentIdSet, alarmCodeSet, acknowledged);
}
@Override
public GenericResponse resetAlarmCounters() {
return alarmController.resetAlarmCounters();
}
}

1
alarm-service-remote/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target/

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
@@ -15,43 +15,54 @@
<dependency>
<artifactId>alarm-service-interface</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>base-client</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<!-- Dependencies for the unit tests -->
<dependency>
<artifactId>base-remote-tests</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<artifactId>alarm-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<artifactId>alarm-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<artifactId>cloud-event-dispatcher-empty</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<artifactId>equipment-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>1.3.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<artifactId>equipment-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>1.3.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@@ -17,7 +17,6 @@ import com.telecominfraproject.wlan.alarm.models.AlarmCode;
import com.telecominfraproject.wlan.alarm.models.AlarmCounts;
import com.telecominfraproject.wlan.core.client.BaseRemoteClient;
import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;
import com.telecominfraproject.wlan.core.model.json.GenericResponse;
import com.telecominfraproject.wlan.core.model.pagination.ColumnAndSort;
import com.telecominfraproject.wlan.core.model.pagination.PaginationContext;
import com.telecominfraproject.wlan.core.model.pagination.PaginationResponse;
@@ -62,22 +61,6 @@ public class AlarmServiceRemote extends BaseRemoteClient implements AlarmService
return ret;
}
@Override
public GenericResponse resetAlarmCounters() {
LOG.debug("calling resetAlarmCounters ");
ResponseEntity<GenericResponse> responseEntity = restTemplate.postForEntity(
getBaseUrl() + "/resetCounts",
null, GenericResponse.class);
GenericResponse ret = responseEntity.getBody();
LOG.debug("completed resetAlarmCounters {} ", ret);
return ret;
}
@Override
public Alarm getOrNull(int customerId, long equipmentId, AlarmCode alarmCode, long createdTimestamp) {
@@ -137,9 +120,9 @@ public class AlarmServiceRemote extends BaseRemoteClient implements AlarmService
}
@Override
public AlarmCounts getAlarmCounts(int customerId, Set<Long> equipmentIdSet, Set<AlarmCode> alarmCodeSet) {
public AlarmCounts getAlarmCounts(int customerId, Set<Long> equipmentIdSet, Set<AlarmCode> alarmCodeSet, Boolean acknowledged) {
LOG.debug("getAlarmCounts({}, {}, {})", customerId, equipmentIdSet, alarmCodeSet);
LOG.debug("getAlarmCounts({}, {}, {}, {})", customerId, equipmentIdSet, alarmCodeSet, acknowledged);
String equipmentIdSetStr = null;
if (equipmentIdSet != null && !equipmentIdSet.isEmpty()) {
@@ -158,8 +141,8 @@ public class AlarmServiceRemote extends BaseRemoteClient implements AlarmService
}
ResponseEntity<AlarmCounts> responseEntity = restTemplate.exchange(
getBaseUrl() + "/counts?customerId={customerId}&equipmentIdSet={equipmentIdSetStr}&alarmCodeSet={alarmCodeSetStr}", HttpMethod.GET,
null, AlarmCounts.class, customerId, equipmentIdSetStr, alarmCodeSetStr);
getBaseUrl() + "/counts?customerId={customerId}&equipmentIdSet={equipmentIdSetStr}&alarmCodeSet={alarmCodeSetStr}&acknowledged={acknowledged}", HttpMethod.GET,
null, AlarmCounts.class, customerId, equipmentIdSetStr, alarmCodeSetStr, acknowledged);
AlarmCounts ret = responseEntity.getBody();
LOG.debug("completed getAlarmCounts {} ", ret);
@@ -170,10 +153,10 @@ public class AlarmServiceRemote extends BaseRemoteClient implements AlarmService
@Override
public PaginationResponse<Alarm> getForCustomer(int customerId, Set<Long> equipmentIdSet,
Set<AlarmCode> alarmCodeSet, long createdAfterTimestamp, List<ColumnAndSort> sortBy,
Set<AlarmCode> alarmCodeSet, long createdAfterTimestamp, Boolean acknowledged, List<ColumnAndSort> sortBy,
PaginationContext<Alarm> context) {
LOG.debug("calling getForCustomer( {}, {}, {}, {}, {}, {} )", customerId, equipmentIdSet, alarmCodeSet, createdAfterTimestamp, sortBy, context);
LOG.debug("calling getForCustomer( {}, {}, {}, {}, {}, {}, {} )", customerId, equipmentIdSet, alarmCodeSet, createdAfterTimestamp, acknowledged, sortBy, context);
String equipmentIdSetStr = null;
if (equipmentIdSet != null && !equipmentIdSet.isEmpty()) {
@@ -193,9 +176,9 @@ public class AlarmServiceRemote extends BaseRemoteClient implements AlarmService
ResponseEntity<PaginationResponse<Alarm>> responseEntity = restTemplate.exchange(
getBaseUrl()
+ "/forCustomer?customerId={customerId}&equipmentIdSet={equipmentIdSetStr}&alarmCodeSet={alarmCodeSetStr}&createdAfterTimestamp={createdAfterTimestamp}&sortBy={sortBy}&paginationContext={paginationContext}",
+ "/forCustomer?customerId={customerId}&equipmentIdSet={equipmentIdSetStr}&alarmCodeSet={alarmCodeSetStr}&createdAfterTimestamp={createdAfterTimestamp}&acknowledged={acknowledged}&sortBy={sortBy}&paginationContext={paginationContext}",
HttpMethod.GET,
null, Alarm_PAGINATION_RESPONSE_CLASS_TOKEN, customerId, equipmentIdSetStr, alarmCodeSetStr, createdAfterTimestamp, sortBy, context);
null, Alarm_PAGINATION_RESPONSE_CLASS_TOKEN, customerId, equipmentIdSetStr, alarmCodeSetStr, createdAfterTimestamp, acknowledged, sortBy, context);
PaginationResponse<Alarm> ret = responseEntity.getBody();
LOG.debug("completed getForCustomer {} ", ret.getItems().size());
@@ -258,14 +241,45 @@ public class AlarmServiceRemote extends BaseRemoteClient implements AlarmService
return ret;
}
@Override
public List<Alarm> get(Set<AlarmCode> alarmCodeSet, long createdAfterTimestamp) {
LOG.debug("get({},{})", alarmCodeSet, createdAfterTimestamp);
if (alarmCodeSet == null || alarmCodeSet.isEmpty()) {
throw new IllegalArgumentException("alarmCodeSet must be provided");
}
String alarmCodeSetStr = alarmCodeSet.toString();
// remove [] around the string, otherwise will get:
// Failed to convert value of type 'java.lang.String' to required
// type 'java.util.Set'; nested exception is
// java.lang.NumberFormatException: For input string: "[690]"
alarmCodeSetStr = alarmCodeSetStr.substring(1, alarmCodeSetStr.length() - 1);
try {
ResponseEntity<List<Alarm>> responseEntity =
restTemplate.exchange(getBaseUrl() + "/forAlarmCode?alarmCode={alarmCodeSetStr}&createdAfterTimestamp={createdAfterTimestamp}",
HttpMethod.GET, null, Alarm_LIST_CLASS_TOKEN, alarmCodeSetStr, createdAfterTimestamp);
List<Alarm> result = responseEntity.getBody();
if (null == result) {
result = Collections.emptyList();
}
LOG.debug("get({},{}) return {} entries", alarmCodeSet, createdAfterTimestamp, result.size());
return result;
} catch (Exception exp) {
LOG.error("getAllInSet({},{}) exception ", alarmCodeSet, createdAfterTimestamp, exp);
throw exp;
}
}
public String getBaseUrl() {
if(baseUrl==null) {
baseUrl = environment.getProperty("tip.wlan.alarmServiceBaseUrl").trim()+"/api/alarm";
}
return baseUrl;
return baseUrl;
}
}

View File

@@ -19,6 +19,7 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
@@ -26,13 +27,19 @@ import com.telecominfraproject.wlan.alarm.models.Alarm;
import com.telecominfraproject.wlan.alarm.models.AlarmCode;
import com.telecominfraproject.wlan.alarm.models.AlarmCounts;
import com.telecominfraproject.wlan.alarm.models.AlarmDetails;
import com.telecominfraproject.wlan.cloudeventdispatcher.CloudEventDispatcherEmpty;
import com.telecominfraproject.wlan.core.model.equipment.EquipmentType;
import com.telecominfraproject.wlan.core.model.pagination.ColumnAndSort;
import com.telecominfraproject.wlan.core.model.pagination.PaginationContext;
import com.telecominfraproject.wlan.core.model.pagination.PaginationResponse;
import com.telecominfraproject.wlan.core.model.pagination.SortOrder;
import com.telecominfraproject.wlan.datastore.exceptions.DsConcurrentModificationException;
import com.telecominfraproject.wlan.datastore.exceptions.DsEntityNotFoundException;
import com.telecominfraproject.wlan.equipment.EquipmentServiceLocal;
import com.telecominfraproject.wlan.equipment.datastore.inmemory.EquipmentDatastoreInMemory;
import com.telecominfraproject.wlan.equipment.models.Equipment;
import com.telecominfraproject.wlan.remote.tests.BaseRemoteTest;
import com.telecominfraproject.wlan.status.models.StatusCode;
/**
* @author dtoptygin
@@ -43,10 +50,16 @@ import com.telecominfraproject.wlan.remote.tests.BaseRemoteTest;
"integration_test",
"no_ssl","http_digest_auth","rest-template-single-user-per-service-digest-auth",
}) //NOTE: these profiles will be ADDED to the list of active profiles
@Import(value = {
EquipmentServiceLocal.class,
EquipmentDatastoreInMemory.class,
CloudEventDispatcherEmpty.class
})
public class AlarmServiceRemoteTest extends BaseRemoteTest {
@Autowired AlarmServiceRemote remoteInterface;
@Autowired EquipmentServiceLocal equipmentServicelocal;
@Before public void urlSetup(){
configureBaseUrl("tip.wlan.alarmServiceBaseUrl");
@@ -232,6 +245,11 @@ public class AlarmServiceRemoteTest extends BaseRemoteTest {
mdl.setCreatedTimestamp(mdl.getCreatedTimestamp() - 10000);
pastTimestamp = mdl.getCreatedTimestamp();
}
if (i < 20) {
mdl.setAcknowledged(true);
} else {
mdl.setAcknowledged(false);
}
apNameIdx++;
remoteInterface.create(mdl);
@@ -252,13 +270,13 @@ public class AlarmServiceRemoteTest extends BaseRemoteTest {
//get active alarms for all equipment and all alarmCodes for the customer since the beginning of time
PaginationContext<Alarm> context = new PaginationContext<>(10);
PaginationResponse<Alarm> page1 = remoteInterface.getForCustomer(customerId_1, null, null, -1, sortBy, context);
PaginationResponse<Alarm> page2 = remoteInterface.getForCustomer(customerId_1, null, null, -1, sortBy, page1.getContext());
PaginationResponse<Alarm> page3 = remoteInterface.getForCustomer(customerId_1, null, null, -1, sortBy, page2.getContext());
PaginationResponse<Alarm> page4 = remoteInterface.getForCustomer(customerId_1, null, null, -1, sortBy, page3.getContext());
PaginationResponse<Alarm> page5 = remoteInterface.getForCustomer(customerId_1, null, null, -1, sortBy, page4.getContext());
PaginationResponse<Alarm> page6 = remoteInterface.getForCustomer(customerId_1, null, null, -1, sortBy, page5.getContext());
PaginationResponse<Alarm> page7 = remoteInterface.getForCustomer(customerId_1, null, null, -1, sortBy, page6.getContext());
PaginationResponse<Alarm> page1 = remoteInterface.getForCustomer(customerId_1, null, null, -1, null, sortBy, context);
PaginationResponse<Alarm> page2 = remoteInterface.getForCustomer(customerId_1, null, null, -1, null, sortBy, page1.getContext());
PaginationResponse<Alarm> page3 = remoteInterface.getForCustomer(customerId_1, null, null, -1, null, sortBy, page2.getContext());
PaginationResponse<Alarm> page4 = remoteInterface.getForCustomer(customerId_1, null, null, -1, null, sortBy, page3.getContext());
PaginationResponse<Alarm> page5 = remoteInterface.getForCustomer(customerId_1, null, null, -1, null, sortBy, page4.getContext());
PaginationResponse<Alarm> page6 = remoteInterface.getForCustomer(customerId_1, null, null, -1, null, sortBy, page5.getContext());
PaginationResponse<Alarm> page7 = remoteInterface.getForCustomer(customerId_1, null, null, -1, null, sortBy, page6.getContext());
//verify returned pages
assertEquals(10, page1.getItems().size());
@@ -291,9 +309,99 @@ public class AlarmServiceRemoteTest extends BaseRemoteTest {
assertEquals(expectedPage3Strings, actualPage3Strings);
// testing Acknowledged filter (alarm_by_acknowledged)
PaginationResponse<Alarm> page1Acknowledged = remoteInterface.getForCustomer(customerId_1, null, null, -1, true, sortBy, context);
PaginationResponse<Alarm> page2Acknowledged = remoteInterface.getForCustomer(customerId_1, null, null, -1, true, sortBy, page1Acknowledged.getContext());
PaginationResponse<Alarm> page3Acknowledged = remoteInterface.getForCustomer(customerId_1, null, null, -1, true, sortBy, page2Acknowledged.getContext());
PaginationResponse<Alarm> page4Acknowledged = remoteInterface.getForCustomer(customerId_1, null, null, -1, true, sortBy, page3Acknowledged.getContext());
//verify returned pages
assertEquals(10, page1Acknowledged.getItems().size());
assertEquals(10, page2Acknowledged.getItems().size());
assertEquals(0, page3Acknowledged.getItems().size());
assertEquals(0, page4Acknowledged.getItems().size());
// testing Acknowledged filter with equipmentIds (alarm_by_acknowledged_equipmentId)
PaginationResponse<Alarm> page1AcknowledgedAndEquipment = remoteInterface.getForCustomer(customerId_1, equipmentIds, null, -1, true, sortBy, context);
PaginationResponse<Alarm> page2AcknowledgedAndEquipment = remoteInterface.getForCustomer(customerId_1, equipmentIds, null, -1, true, sortBy, page1AcknowledgedAndEquipment.getContext());
PaginationResponse<Alarm> page3AcknowledgedAndEquipment = remoteInterface.getForCustomer(customerId_1, equipmentIds, null, -1, true, sortBy, page2AcknowledgedAndEquipment.getContext());
PaginationResponse<Alarm> page4AcknowledgedAndEquipment = remoteInterface.getForCustomer(customerId_1, equipmentIds, null, -1, true, sortBy, page3AcknowledgedAndEquipment.getContext());
page1AcknowledgedAndEquipment.getItems().forEach(e -> assertEquals(true, e.isAcknowledged()) );
page2AcknowledgedAndEquipment.getItems().forEach(e -> assertEquals(true, e.isAcknowledged()) );
page1AcknowledgedAndEquipment.getItems().forEach(e -> assertTrue(equipmentIds.contains(e.getEquipmentId())));
page2AcknowledgedAndEquipment.getItems().forEach(e -> assertTrue(equipmentIds.contains(e.getEquipmentId())));
assertTrue(page3AcknowledgedAndEquipment.getContext().isLastPage());
assertTrue(page4AcknowledgedAndEquipment.getContext().isLastPage());
// testing Acknowledged filter with alarmCodes (alarm_by_acknowledged_alarmCode)
PaginationResponse<Alarm> page1AcknowledgedAndAlarmCode = remoteInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, -1, true, sortBy, context);
PaginationResponse<Alarm> page2AcknowledgedAndAlarmCode = remoteInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, -1, true, sortBy, page1AcknowledgedAndAlarmCode.getContext());
PaginationResponse<Alarm> page3AcknowledgedAndAlarmCode = remoteInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, -1, true, sortBy, page2AcknowledgedAndAlarmCode.getContext());
PaginationResponse<Alarm> page4AcknowledgedAndAlarmCode = remoteInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, -1, true, sortBy, page3AcknowledgedAndAlarmCode.getContext());
page1AcknowledgedAndAlarmCode.getItems().forEach(e -> assertEquals(true, e.isAcknowledged()) );
page2AcknowledgedAndAlarmCode.getItems().forEach(e -> assertEquals(true, e.isAcknowledged()) );
page1AcknowledgedAndAlarmCode.getItems().forEach(e -> assertEquals(AlarmCode.AccessPointIsUnreachable, e.getAlarmCode()));
page2AcknowledgedAndAlarmCode.getItems().forEach(e -> assertEquals(AlarmCode.AccessPointIsUnreachable, e.getAlarmCode()));
assertTrue(page3AcknowledgedAndAlarmCode.getContext().isLastPage());
assertTrue(page4AcknowledgedAndAlarmCode.getContext().isLastPage());
// testing Acknowledged filter with failure alarm code (no alarms initialized with failure code, should return empty page)
PaginationResponse<Alarm> page1AcknowledgedAndAlarmCodeFailure = remoteInterface.getForCustomer(customerId_1, equipmentIds, Collections.singleton(AlarmCode.AssocFailure), -1, true, sortBy, context);
assertTrue(page1AcknowledgedAndAlarmCodeFailure.getContext().isLastPage());
long checkTimestamp = pastTimestamp;
// testing Acknowledged filter with timestamp (alarm_by_acknowledged_timestamp)
PaginationResponse<Alarm> page1AcknowledgedAndTimestamp = remoteInterface.getForCustomer(customerId_1, null, null, pastTimestamp, true, sortBy, context);
PaginationResponse<Alarm> page2AcknowledgedAndTimestamp = remoteInterface.getForCustomer(customerId_1, null, null, pastTimestamp, true, sortBy, page1AcknowledgedAndTimestamp.getContext());
PaginationResponse<Alarm> page3AcknowledgedAndTimestamp = remoteInterface.getForCustomer(customerId_1, null, null, pastTimestamp, true, sortBy, page2AcknowledgedAndTimestamp.getContext());
PaginationResponse<Alarm> page4AcknowledgedAndTimestamp = remoteInterface.getForCustomer(customerId_1, null, null, pastTimestamp, true, sortBy, page3AcknowledgedAndTimestamp.getContext());
assertEquals(10, page1AcknowledgedAndTimestamp.getItems().size());
assertEquals(9, page2AcknowledgedAndTimestamp.getItems().size());
assertEquals(0, page3AcknowledgedAndTimestamp.getItems().size());
assertEquals(0, page4AcknowledgedAndTimestamp.getItems().size());
page1AcknowledgedAndTimestamp.getItems().forEach(e -> assertEquals(true, e.isAcknowledged()) );
page2AcknowledgedAndTimestamp.getItems().forEach(e -> assertEquals(true, e.isAcknowledged()) );
page1AcknowledgedAndTimestamp.getItems().forEach(e -> assertTrue(e.getCreatedTimestamp() > checkTimestamp));
page2AcknowledgedAndTimestamp.getItems().forEach(e -> assertTrue(e.getCreatedTimestamp() > checkTimestamp));
assertTrue(page3AcknowledgedAndTimestamp.getContext().isLastPage());
assertTrue(page4AcknowledgedAndTimestamp.getContext().isLastPage());
// testing Acknowledged with equipmentId and timestamp
// With timestamp, alarmCodes will be set to AlarmCode.validValues, so these calls will be equivalent to having all filters included.
// Because all filters are included, the alarm_by_acknowledged will be used instead of alarm_by_acknowledged_timestamp
PaginationResponse<Alarm> page1AcknowledgedEquipmentIdAndTimestamp = remoteInterface.getForCustomer(customerId_1, equipmentIds, null, pastTimestamp, true, sortBy, context);
PaginationResponse<Alarm> page2AcknowledgedEquipmentIdAndTimestamp = remoteInterface.getForCustomer(customerId_1, equipmentIds, null, pastTimestamp, true, sortBy, page1AcknowledgedEquipmentIdAndTimestamp.getContext());
PaginationResponse<Alarm> page3AcknowledgedEquipmentIdAndTimestamp = remoteInterface.getForCustomer(customerId_1, equipmentIds, null, pastTimestamp, true, sortBy, page2AcknowledgedEquipmentIdAndTimestamp.getContext());
assertEquals(10, page1AcknowledgedEquipmentIdAndTimestamp.getItems().size());
assertEquals(9, page2AcknowledgedEquipmentIdAndTimestamp.getItems().size());
assertEquals(0, page3AcknowledgedEquipmentIdAndTimestamp.getItems().size());
page1AcknowledgedEquipmentIdAndTimestamp.getItems().forEach(e -> assertEquals(true, e.isAcknowledged()) );
page2AcknowledgedEquipmentIdAndTimestamp.getItems().forEach(e -> assertEquals(true, e.isAcknowledged()) );
page1AcknowledgedEquipmentIdAndTimestamp.getItems().forEach(e -> assertTrue(equipmentIds.contains(e.getEquipmentId())));
page2AcknowledgedEquipmentIdAndTimestamp.getItems().forEach(e -> assertTrue(equipmentIds.contains(e.getEquipmentId())));
page1AcknowledgedEquipmentIdAndTimestamp.getItems().forEach(e -> assertTrue(e.getCreatedTimestamp() > checkTimestamp));
page2AcknowledgedEquipmentIdAndTimestamp.getItems().forEach(e -> assertTrue(e.getCreatedTimestamp() > checkTimestamp));
assertTrue(page3AcknowledgedEquipmentIdAndTimestamp.getContext().isLastPage());
//test first page of the results with empty sort order -> default sort order (by Id ascending)
PaginationResponse<Alarm> page1EmptySort = remoteInterface.getForCustomer(customerId_1, null, null, -1, Collections.emptyList(), context);
PaginationResponse<Alarm> page1EmptySort = remoteInterface.getForCustomer(customerId_1, null, null, -1, null, Collections.emptyList(), context);
assertEquals(10, page1EmptySort.getItems().size());
List<String> expectedPage1EmptySortStrings = new ArrayList<>(Arrays.asList(new String[]{"qr_0", "qr_1", "qr_2", "qr_3", "qr_4", "qr_5", "qr_6", "qr_7", "qr_8", "qr_9" }));
@@ -303,7 +411,7 @@ public class AlarmServiceRemoteTest extends BaseRemoteTest {
assertEquals(expectedPage1EmptySortStrings, actualPage1EmptySortStrings);
//test first page of the results with null sort order -> default sort order (by Id ascending)
PaginationResponse<Alarm> page1NullSort = remoteInterface.getForCustomer(customerId_1, null, null, -1, null, context);
PaginationResponse<Alarm> page1NullSort = remoteInterface.getForCustomer(customerId_1, null, null, -1, null, null, context);
assertEquals(10, page1NullSort.getItems().size());
List<String> expectedPage1NullSortStrings = new ArrayList<>(Arrays.asList(new String[]{"qr_0", "qr_1", "qr_2", "qr_3", "qr_4", "qr_5", "qr_6", "qr_7", "qr_8", "qr_9" }));
@@ -314,7 +422,7 @@ public class AlarmServiceRemoteTest extends BaseRemoteTest {
//test first page of the results with sort descending order by a equipmentId property
PaginationResponse<Alarm> page1SingleSortDesc = remoteInterface.getForCustomer(customerId_1, null, null, -1, Collections.singletonList(new ColumnAndSort("equipmentId", SortOrder.desc)), context);
PaginationResponse<Alarm> page1SingleSortDesc = remoteInterface.getForCustomer(customerId_1, null, null, -1, null, Collections.singletonList(new ColumnAndSort("equipmentId", SortOrder.desc)), context);
assertEquals(10, page1SingleSortDesc.getItems().size());
List<String> expectedPage1SingleSortDescStrings = new ArrayList< >(Arrays.asList(new String[]{"qr_49", "qr_48", "qr_47", "qr_46", "qr_45", "qr_44", "qr_43", "qr_42", "qr_41", "qr_40" }));
@@ -326,13 +434,13 @@ public class AlarmServiceRemoteTest extends BaseRemoteTest {
//test with explicit list of equipmentIds and explicit list of AlarmCodes
long createdAfterTs = pastTimestamp + 10;
context = new PaginationContext<>(10);
page1 = remoteInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, createdAfterTs, sortBy, context);
page2 = remoteInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, createdAfterTs, sortBy, page1.getContext());
page3 = remoteInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, createdAfterTs, sortBy, page2.getContext());
page4 = remoteInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, createdAfterTs, sortBy, page3.getContext());
page5 = remoteInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, createdAfterTs, sortBy, page4.getContext());
page6 = remoteInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, createdAfterTs, sortBy, page5.getContext());
page7 = remoteInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, createdAfterTs, sortBy, page6.getContext());
page1 = remoteInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, createdAfterTs, null, sortBy, context);
page2 = remoteInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, createdAfterTs, null, sortBy, page1.getContext());
page3 = remoteInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, createdAfterTs, null, sortBy, page2.getContext());
page4 = remoteInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, createdAfterTs, null, sortBy, page3.getContext());
page5 = remoteInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, createdAfterTs, null, sortBy, page4.getContext());
page6 = remoteInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, createdAfterTs, null, sortBy, page5.getContext());
page7 = remoteInterface.getForCustomer(customerId_1, equipmentIds, alarmCodes, createdAfterTs, null, sortBy, page6.getContext());
//verify returned pages
assertEquals(10, page1.getItems().size());
@@ -350,18 +458,69 @@ public class AlarmServiceRemoteTest extends BaseRemoteTest {
//test with explicit list of equipmentIds of one element and explicit list of AlarmCodes of one element
context = new PaginationContext<>(10);
page1 = remoteInterface.getForCustomer(customerId_1, Collections.singleton(equipmentIds.iterator().next()), Collections.singleton(AlarmCode.AccessPointIsUnreachable), -1, sortBy, context);
page1 = remoteInterface.getForCustomer(customerId_1, Collections.singleton(equipmentIds.iterator().next()), Collections.singleton(AlarmCode.AccessPointIsUnreachable), -1, null, sortBy, context);
assertEquals(1, page1.getItems().size());
}
@Test
public void testAlarmAcknowledgedPaginationWithUpdate() {
Alarm alarm = createAlarmObject();
//create
Alarm created = remoteInterface.create(alarm);
assertNotNull(created);
assertEquals(alarm.getCustomerId(), created.getCustomerId());
assertEquals(alarm.getEquipmentId(), created.getEquipmentId());
assertEquals(alarm.getAlarmCode(), created.getAlarmCode());
assertEquals(alarm.getCreatedTimestamp(), created.getCreatedTimestamp());
assertNotNull(created.getDetails());
assertEquals(alarm.getDetails(), created.getDetails());
List<ColumnAndSort> sortBy = new ArrayList<>();
sortBy.addAll(Arrays.asList(new ColumnAndSort("equipmentId")));
PaginationContext<Alarm> context = new PaginationContext<>(10);
PaginationResponse<Alarm> page1CheckFalse = remoteInterface.getForCustomer(created.getCustomerId(), null, null, -1, false, sortBy, context);
assertEquals(1, page1CheckFalse.getItems().size());
page1CheckFalse.getItems().forEach(e -> assertFalse(e.isAcknowledged()));
PaginationResponse<Alarm> page1CheckTrue = remoteInterface.getForCustomer(created.getCustomerId(), null, null, -1, true, sortBy, context);
assertEquals(0, page1CheckTrue.getItems().size());
// update
created.setAcknowledged(true);
Alarm updated = remoteInterface.update(created);
assertNotNull(updated);
assertTrue(updated.isAcknowledged());
page1CheckFalse = remoteInterface.getForCustomer(created.getCustomerId(), null, null, -1, false, sortBy, context);
assertEquals(0, page1CheckFalse.getItems().size());
page1CheckTrue = remoteInterface.getForCustomer(created.getCustomerId(), null, null, -1, true, sortBy, context);
assertEquals(1, page1CheckTrue.getItems().size());
page1CheckTrue.getItems().forEach(e -> assertTrue(e.isAcknowledged()));
//delete
created = remoteInterface.delete(created.getCustomerId(), created.getEquipmentId(), created.getAlarmCode(), created.getCreatedTimestamp());
assertNotNull(created);
created = remoteInterface.getOrNull(created.getCustomerId(), created.getEquipmentId(), created.getAlarmCode(), created.getCreatedTimestamp());
assertNull(created);
}
@Test
public void testAlarmCountsRetrieval() {
//create some Alarms
Alarm mdl;
int customerId_1 = getNextCustomerId();
int customerId_2 = getNextCustomerId();
final int customerId_1 = getNextCustomerId();
final int customerId_2 = getNextCustomerId();
final long equipmentId_1 = createEquipmentObject(customerId_1).getId();
int apNameIdx = 0;
Set<Long> equipmentIds = new HashSet<>();
@@ -369,11 +528,12 @@ public class AlarmServiceRemoteTest extends BaseRemoteTest {
Set<Long> equipmentIds_AccessPointIsUnreachable = new HashSet<>();
for(int i = 0; i< 50; i++){
mdl = createAlarmObject();
mdl.setCustomerId(customerId_1);
mdl = createAlarmObject(customerId_1, createEquipmentObject(customerId_1).getId());
mdl.setEquipmentId(createEquipmentObject(customerId_1).getId());
mdl.setScopeId("qr_"+apNameIdx);
if((i%2) == 0) {
mdl.setAlarmCode(AlarmCode.CPUUtilization);
mdl.setAcknowledged(true);
equipmentIds_CPUUtilization.add(mdl.getEquipmentId());
} else {
equipmentIds_AccessPointIsUnreachable.add(mdl.getEquipmentId());
@@ -384,70 +544,152 @@ public class AlarmServiceRemoteTest extends BaseRemoteTest {
remoteInterface.create(mdl);
}
{
mdl = createAlarmObject();
mdl.setCustomerId(customerId_1);
mdl.setEquipmentId(0);
mdl.setAlarmCode(AlarmCode.GenericError);
remoteInterface.create(mdl);
}
mdl = createAlarmObject(customerId_1, equipmentId_1);
mdl.setCustomerId(customerId_1);
mdl.setAlarmCode(AlarmCode.GenericError);
remoteInterface.create(mdl);
for(int i = 0; i< 50; i++){
mdl = createAlarmObject();
mdl.setCustomerId(customerId_2);
mdl.setScopeId("qr_"+apNameIdx);
mdl = createAlarmObject(customerId_2, createEquipmentObject(customerId_2).getId());
mdl.setScopeId("qr_"+apNameIdx);
mdl.setAcknowledged(false);
mdl.setAlarmCode(AlarmCode.GenericError);
apNameIdx++;
remoteInterface.create(mdl);
}
Set<AlarmCode> alarmCodes = new HashSet<>(Arrays.asList(AlarmCode.AccessPointIsUnreachable, AlarmCode.GenericError, AlarmCode.CPUUtilization));
AlarmCounts alarmCounts = remoteInterface.getAlarmCounts(customerId_1, equipmentIds, alarmCodes);
AlarmCounts alarmCounts = remoteInterface.getAlarmCounts(customerId_1, equipmentIds, alarmCodes, null);
assertEquals(0, alarmCounts.getCounter(0, AlarmCode.GenericError));
assertEquals(25, alarmCounts.getCounter(0, AlarmCode.CPUUtilization));
assertEquals(25, alarmCounts.getCounter(0, AlarmCode.AccessPointIsUnreachable));
assertEquals(25, alarmCounts.getSeverityCounter(StatusCode.requiresAttention));
assertEquals(25, alarmCounts.getSeverityCounter(StatusCode.error));
equipmentIds_CPUUtilization.forEach(eqId -> assertEquals(1, alarmCounts.getCounter(eqId, AlarmCode.CPUUtilization)));
equipmentIds_AccessPointIsUnreachable.forEach(eqId -> assertEquals(1, alarmCounts.getCounter(eqId, AlarmCode.AccessPointIsUnreachable)) );
AlarmCounts alarmCounts_noEq = remoteInterface.getAlarmCounts(customerId_1, null, alarmCodes);
AlarmCounts alarmCounts_noEq = remoteInterface.getAlarmCounts(customerId_1, null, alarmCodes, null);
assertEquals(1, alarmCounts_noEq.getCounter(0, AlarmCode.GenericError));
assertEquals(25, alarmCounts_noEq.getCounter(0, AlarmCode.CPUUtilization));
assertEquals(25, alarmCounts_noEq.getCounter(0, AlarmCode.AccessPointIsUnreachable));
assertEquals(25, alarmCounts_noEq.getSeverityCounter(StatusCode.requiresAttention));
assertEquals(26, alarmCounts_noEq.getSeverityCounter(StatusCode.error));
assertTrue(alarmCounts_noEq.getCountsPerEquipmentIdMap().isEmpty());
assertEquals(3, alarmCounts_noEq.getTotalCountsPerAlarmCodeMap().size());
AlarmCounts alarmCounts_noEq_1code = remoteInterface.getAlarmCounts(customerId_1, null, Collections.singleton(AlarmCode.CPUUtilization));
AlarmCounts alarmCounts_noEq_1code = remoteInterface.getAlarmCounts(customerId_1, null, Collections.singleton(AlarmCode.CPUUtilization), null);
assertEquals(0, alarmCounts_noEq_1code.getCounter(0, AlarmCode.GenericError));
assertEquals(25, alarmCounts_noEq_1code.getCounter(0, AlarmCode.CPUUtilization));
assertEquals(0, alarmCounts_noEq_1code.getCounter(0, AlarmCode.AccessPointIsUnreachable));
assertEquals(25, alarmCounts_noEq_1code.getSeverityCounter(StatusCode.requiresAttention));
assertEquals(0, alarmCounts_noEq_1code.getSeverityCounter(StatusCode.error));
assertTrue(alarmCounts_noEq_1code.getCountsPerEquipmentIdMap().isEmpty());
assertEquals(1, alarmCounts_noEq_1code.getTotalCountsPerAlarmCodeMap().size());
AlarmCounts alarmCounts_1Eq_1code = remoteInterface.getAlarmCounts(customerId_1, Collections.singleton(equipmentIds.iterator().next()), Collections.singleton(AlarmCode.CPUUtilization));
AlarmCounts alarmCounts_acknowledgedT = remoteInterface.getAlarmCounts(customerId_1, null, Collections.singleton(AlarmCode.CPUUtilization), true);
assertTrue(alarmCounts_acknowledgedT.getAcknowledged());
assertEquals(0, alarmCounts_acknowledgedT.getCounter(0, AlarmCode.GenericError));
assertEquals(25, alarmCounts_acknowledgedT.getCounter(0, AlarmCode.CPUUtilization));
assertEquals(0, alarmCounts_acknowledgedT.getCounter(0, AlarmCode.AccessPointIsUnreachable));
assertEquals(25, alarmCounts_acknowledgedT.getSeverityCounter(StatusCode.requiresAttention));
assertEquals(0, alarmCounts_acknowledgedT.getSeverityCounter(StatusCode.error));
assertTrue(alarmCounts_acknowledgedT.getCountsPerEquipmentIdMap().isEmpty());
assertEquals(1, alarmCounts_acknowledgedT.getTotalCountsPerAlarmCodeMap().size());
AlarmCounts alarmCounts_acknowledgedF = remoteInterface.getAlarmCounts(customerId_1, null, Collections.singleton(AlarmCode.CPUUtilization), false);
assertFalse(alarmCounts_acknowledgedF.getAcknowledged());
assertEquals(0, alarmCounts_acknowledgedF.getCounter(0, AlarmCode.GenericError));
assertEquals(0, alarmCounts_acknowledgedF.getCounter(0, AlarmCode.CPUUtilization));
assertEquals(0, alarmCounts_acknowledgedF.getCounter(0, AlarmCode.AccessPointIsUnreachable));
assertEquals(0, alarmCounts_acknowledgedF.getSeverityCounter(StatusCode.requiresAttention));
assertEquals(0, alarmCounts_acknowledgedF.getSeverityCounter(StatusCode.error));
assertTrue(alarmCounts_acknowledgedF.getCountsPerEquipmentIdMap().isEmpty());
assertEquals(0, alarmCounts_acknowledgedF.getTotalCountsPerAlarmCodeMap().size());
AlarmCounts alarmCounts_acknowledgedF2 = remoteInterface.getAlarmCounts(customerId_2, null, Collections.singleton(AlarmCode.GenericError), false);
assertFalse(alarmCounts_acknowledgedF2.getAcknowledged());
assertEquals(50, alarmCounts_acknowledgedF2.getCounter(0, AlarmCode.GenericError));
assertEquals(0, alarmCounts_acknowledgedF2.getCounter(0, AlarmCode.CPUUtilization));
assertEquals(0, alarmCounts_acknowledgedF2.getCounter(0, AlarmCode.AccessPointIsUnreachable));
assertEquals(0, alarmCounts_acknowledgedF2.getSeverityCounter(StatusCode.requiresAttention));
assertEquals(50, alarmCounts_acknowledgedF2.getSeverityCounter(StatusCode.error));
assertTrue(alarmCounts_acknowledgedF2.getCountsPerEquipmentIdMap().isEmpty());
assertEquals(1, alarmCounts_acknowledgedF2.getTotalCountsPerAlarmCodeMap().size());
AlarmCounts alarmCounts_1Eq_1code = remoteInterface.getAlarmCounts(customerId_1, Collections.singleton(equipmentIds.iterator().next()), Collections.singleton(AlarmCode.CPUUtilization), null);
assertEquals(0, alarmCounts_1Eq_1code.getCounter(0, AlarmCode.GenericError));
assertEquals(1, alarmCounts_1Eq_1code.getCounter(equipmentIds.iterator().next(), AlarmCode.CPUUtilization));
assertEquals(1, alarmCounts_1Eq_1code.getCounter(0, AlarmCode.CPUUtilization));
assertEquals(0, alarmCounts_1Eq_1code.getCounter(0, AlarmCode.AccessPointIsUnreachable));
assertEquals(1, alarmCounts_1Eq_1code.getSeverityCounter(StatusCode.requiresAttention));
assertEquals(0, alarmCounts_1Eq_1code.getSeverityCounter(StatusCode.error));
assertEquals(1, alarmCounts_1Eq_1code.getCountsPerEquipmentIdMap().size());
assertEquals(1, alarmCounts_1Eq_1code.getTotalCountsPerAlarmCodeMap().size());
}
@Test
public void testAlarmCountsForSingleEquipment() {
//create some Alarms
Alarm mdl;
int customerId = getNextCustomerId();
long equipmentId = getNextEquipmentId();
mdl = createAlarmObject();
mdl.setCustomerId(customerId);
mdl.setEquipmentId(equipmentId);
mdl.setAlarmCode(AlarmCode.CPUUtilization);
remoteInterface.create(mdl);
mdl.setAlarmCode(AlarmCode.AccessPointIsUnreachable);
remoteInterface.create(mdl);
Set<AlarmCode> alarmCodes = new HashSet<>(Arrays.asList(AlarmCode.AccessPointIsUnreachable, AlarmCode.GenericError, AlarmCode.CPUUtilization));
AlarmCounts alarmCounts = remoteInterface.getAlarmCounts(customerId, Collections.singleton(equipmentId), alarmCodes, null);
assertEquals(0, alarmCounts.getCounter(0, AlarmCode.GenericError));
assertEquals(1, alarmCounts.getCounter(0, AlarmCode.CPUUtilization));
assertEquals(1, alarmCounts.getCounter(0, AlarmCode.AccessPointIsUnreachable));
assertEquals(2, alarmCounts.getCounter(equipmentId, null));
assertEquals(1, alarmCounts.getSeverityCounter(StatusCode.requiresAttention));
assertEquals(1, alarmCounts.getSeverityCounter(StatusCode.error));
//clean up after the test
remoteInterface.delete(customerId, equipmentId);
}
private Alarm createAlarmObject() {
Alarm result = new Alarm();
result.setCustomerId(getNextCustomerId());
result.setEquipmentId(getNextEquipmentId());
int customerId = getNextCustomerId();
return createAlarmObject(customerId, createEquipmentObject(customerId).getId());
}
private Alarm createAlarmObject(int customerId, long equipmentId) {
Alarm result = new Alarm();
result.setCustomerId(customerId);
result.setAlarmCode(AlarmCode.AccessPointIsUnreachable);
result.setCreatedTimestamp(System.currentTimeMillis());
result.setEquipmentId(equipmentId);
result.setScopeId("test-scope-" + result.getEquipmentId());
AlarmDetails details = new AlarmDetails();
details.setMessage("test-details-" + result.getEquipmentId());
result.setDetails(details );
result.setDetails(details );
return result;
}
private Equipment createEquipmentObject(int customerId)
{
Equipment equipment = new Equipment();
equipment.setName("testName");
equipment.setInventoryId("test-inv");
equipment.setEquipmentType(EquipmentType.AP);
equipment.setCustomerId(customerId);
return equipmentServicelocal.create(equipment);
}
}

1
alarm-service/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target/

View File

@@ -1,53 +1,68 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
<artifactId>alarm-service</artifactId>
<name>alarm-service</name>
<description>Server side implementation of the service.</description>
<dependencies>
<dependency>
<artifactId>base-container</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>cloud-event-dispatcher-interface</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>alarm-models</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>alarm-datastore-interface</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>alarm-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<artifactId>alarm-service</artifactId>
<name>alarm-service</name>
<description>Server side implementation of the service.</description>
<dependencies>
<dependency>
<artifactId>base-container</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>cloud-event-dispatcher-empty</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<artifactId>cloud-event-dispatcher-interface</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>1.3.0-SNAPSHOT</version>
</dependency>
</dependencies>
<dependency>
<artifactId>alarm-models</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>alarm-datastore-interface</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>equipment-service-interface</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>alarm-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>1.3.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<artifactId>equipment-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>1.3.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<artifactId>equipment-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>1.3.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<artifactId>cloud-event-dispatcher-empty</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>1.3.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@@ -16,11 +16,11 @@ import org.springframework.web.bind.annotation.RestController;
import com.telecominfraproject.wlan.cloudeventdispatcher.CloudEventDispatcherInterface;
import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;
import com.telecominfraproject.wlan.core.model.json.GenericResponse;
import com.telecominfraproject.wlan.core.model.pagination.ColumnAndSort;
import com.telecominfraproject.wlan.core.model.pagination.PaginationContext;
import com.telecominfraproject.wlan.core.model.pagination.PaginationResponse;
import com.telecominfraproject.wlan.datastore.exceptions.DsDataValidationException;
import com.telecominfraproject.wlan.equipment.EquipmentServiceInterface;
import com.telecominfraproject.wlan.systemevent.models.SystemEvent;
import com.telecominfraproject.wlan.alarm.datastore.AlarmDatastore;
@@ -49,6 +49,7 @@ public class AlarmController {
@Autowired private AlarmDatastore alarmDatastore;
@Autowired private CloudEventDispatcherInterface cloudEventDispatcher;
@Autowired private EquipmentServiceInterface equipmentServiceInterface;
/**
@@ -67,9 +68,18 @@ public class AlarmController {
LOG.error("Failed to create Alarm, request contains unsupported value: {}", alarm);
throw new DsDataValidationException("Alarm contains unsupported value");
}
if (alarm.getEquipmentId() != 0)
{
if (equipmentServiceInterface.getOrNull(alarm.getEquipmentId()) == null)
{
throw new DsDataValidationException(String.format("Unable to create alarm for non-existant equipment ID: %d", alarm.getEquipmentId()));
}
}
long ts = System.currentTimeMillis();
if (alarm.getCreatedTimestamp() == 0) {
long ts = alarm.getCreatedTimestamp();
if (ts == 0) {
ts = System.currentTimeMillis();
alarm.setCreatedTimestamp(ts);
}
alarm.setLastModifiedTimestamp(ts);
@@ -78,10 +88,9 @@ public class AlarmController {
LOG.debug("Created Alarm {}", ret);
AlarmAddedEvent event = new AlarmAddedEvent(ret);
AlarmAddedEvent event = new AlarmAddedEvent(ret, ts);
publishEvent(event);
return ret;
}
@@ -120,13 +129,32 @@ public class AlarmController {
throw exp;
}
}
@RequestMapping(value = "/forAlarmCode", method = RequestMethod.GET)
public ListOfAlarms getAllForAlarmCode(
@RequestParam Set<AlarmCode> alarmCode,
@RequestParam long createdAfterTimestamp) {
LOG.debug("getAllForAlarmCode({}, {})", alarmCode, createdAfterTimestamp);
try {
List<Alarm> result = alarmDatastore.get(alarmCode, createdAfterTimestamp);
LOG.debug("getAllForAlarmCode({},{}) return {} entries", alarmCode, createdAfterTimestamp, result.size());
ListOfAlarms ret = new ListOfAlarms();
ret.addAll(result);
return ret;
} catch (Exception exp) {
LOG.error("getAllForAlarmCode({},{}) exception ", alarmCode, createdAfterTimestamp, exp);
throw exp;
}
}
@RequestMapping(value = "/forCustomer", method = RequestMethod.GET)
public PaginationResponse<Alarm> getForCustomer(@RequestParam int customerId,
@RequestParam Set<Long> equipmentIdSet,
@RequestParam Set<AlarmCode> alarmCodeSet,
@RequestParam long createdAfterTimestamp,
@RequestParam List<ColumnAndSort> sortBy,
@RequestParam(required = false) Set<Long> equipmentIdSet,
@RequestParam(required = false) Set<AlarmCode> alarmCodeSet,
@RequestParam(required = false) long createdAfterTimestamp,
@RequestParam(required = false) Boolean acknowledged,
@RequestParam(required = false) List<ColumnAndSort> sortBy,
@RequestParam(required = false) PaginationContext<Alarm> paginationContext) {
if(paginationContext == null) {
@@ -148,7 +176,7 @@ public class AlarmController {
}
PaginationResponse<Alarm> onePage = this.alarmDatastore
.getForCustomer(customerId, equipmentIdSet, alarmCodeSet, createdAfterTimestamp, sortBy, paginationContext);
.getForCustomer(customerId, equipmentIdSet, alarmCodeSet, createdAfterTimestamp, acknowledged, sortBy, paginationContext);
ret.setContext(onePage.getContext());
ret.getItems().addAll(onePage.getItems());
@@ -233,22 +261,17 @@ public class AlarmController {
@RequestMapping(value = "/counts", method = RequestMethod.GET)
public AlarmCounts getAlarmCounts(@RequestParam int customerId,
@RequestParam Set<Long> equipmentIdSet,
@RequestParam Set<AlarmCode> alarmCodeSet) {
@RequestParam Set<AlarmCode> alarmCodeSet,
@RequestParam Boolean acknowledged) {
LOG.debug("Getting Alarm counts for {} {} {}", customerId, equipmentIdSet, alarmCodeSet);
LOG.debug("Getting Alarm counts for {} {} {} {}", customerId, equipmentIdSet, alarmCodeSet, acknowledged);
AlarmCounts ret = alarmDatastore.getAlarmCounts(customerId, equipmentIdSet, alarmCodeSet);
AlarmCounts ret = alarmDatastore.getAlarmCounts(customerId, equipmentIdSet, alarmCodeSet, acknowledged);
LOG.debug("Alarm counts: {}", ret);
return ret;
}
@RequestMapping(value = "/resetCounts", method = RequestMethod.POST)
public GenericResponse resetAlarmCounters() {
alarmDatastore.resetAlarmCounters();
return new GenericResponse(true, "");
}
private void publishEvent(SystemEvent event) {
if (event == null) {
return;

View File

@@ -262,11 +262,17 @@ components:
customerId:
type: integer
format: int32
acknowledged:
type: boolean
countsPerEquipmentIdMap:
$ref: '#/components/schemas/CountsPerEquipmentIdPerAlarmCodeMap'
totalCountsPerAlarmCodeMap:
$ref: '#/components/schemas/CountsPerAlarmCodeMap'
totalCountsPerEquipmentIdMap:
$ref: '#/components/schemas/CountsPerEquipmentIdMap'
totalCountsBySeverityMap:
$ref: '#/components/schemas/CountsBySeverityMap'
CountsPerAlarmCodeMap:
description: map of AlarmCode to the integer count of alarms
type: object
@@ -279,6 +285,20 @@ components:
type: object
additionalProperties:
$ref: '#/components/schemas/CountsPerAlarmCodeMap'
CountsPerEquipmentIdMap:
description: map of equipmentId to integer count of alarms
type: object
additionalProperties:
type: integer
format: int32
CountsBySeverityMap:
description: map of severity to integer count of alarms
type: object
additionalProperties:
type: integer
format: int32
#
# Other related objects
@@ -534,7 +554,7 @@ paths:
- name: equipmentIdSet
in: query
description: Equipment ID Set
required: true
required: false
schema:
type: array
items:
@@ -543,7 +563,7 @@ paths:
- name: alarmCodeSet
in: query
description: Alarm Code Set
required: true
required: false
schema:
type: array
items:
@@ -551,14 +571,20 @@ paths:
- name: createdAfterTimestamp
in: query
description: Created After Timestamp
required: true
required: false
schema:
type: integer
format: int64
- name: acknowledged
in: query
description: Acknowledged flag
required: false
schema:
type: boolean
- name: sortBy
in: query
description: sort options
required: true
required: false
schema:
type: array
items:
@@ -623,6 +649,12 @@ paths:
type: array
items:
$ref: '#/components/schemas/AlarmCode'
- name: acknowledged
in: query
description: Acknowledged flag
required: true
schema:
type: boolean
responses:
200:
description: successful operation

View File

@@ -17,7 +17,11 @@ import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import com.telecominfraproject.wlan.cloudeventdispatcher.CloudEventDispatcherEmpty;
import com.telecominfraproject.wlan.core.model.equipment.EquipmentType;
import com.telecominfraproject.wlan.equipment.EquipmentServiceLocal;
import com.telecominfraproject.wlan.equipment.controller.EquipmentController;
import com.telecominfraproject.wlan.equipment.datastore.inmemory.EquipmentDatastoreInMemory;
import com.telecominfraproject.wlan.equipment.models.Equipment;
import com.telecominfraproject.wlan.alarm.datastore.inmemory.AlarmDatastoreInMemory;
import com.telecominfraproject.wlan.alarm.models.Alarm;
import com.telecominfraproject.wlan.alarm.models.AlarmCode;
@@ -39,10 +43,14 @@ import com.telecominfraproject.wlan.alarm.models.AlarmDetails;
CloudEventDispatcherEmpty.class,
AlarmDatastoreInMemory.class,
AlarmControllerTest.Config.class,
EquipmentServiceLocal.class,
EquipmentController.class,
EquipmentDatastoreInMemory.class
})
public class AlarmControllerTest {
@Autowired private AlarmController alarmController;
@Autowired EquipmentServiceLocal equipmentServicelocal;
@Configuration
@@ -59,8 +67,9 @@ public class AlarmControllerTest {
//Create new Alarm - success
Alarm alarm = new Alarm();
alarm.setCustomerId((int) testSequence.getAndIncrement());
alarm.setEquipmentId(testSequence.getAndIncrement());
int customerId = (int) testSequence.getAndIncrement();
alarm.setCustomerId(customerId);
alarm.setEquipmentId(createEquipmentObject(customerId).getId());
alarm.setAlarmCode(AlarmCode.AccessPointIsUnreachable);
alarm.setCreatedTimestamp(System.currentTimeMillis());
@@ -91,5 +100,14 @@ public class AlarmControllerTest {
assertEquals(expected.getDetails(), actual.getDetails());
//TODO: add more fields to check here
}
private Equipment createEquipmentObject(int customerId)
{
Equipment equipment = new Equipment();
equipment.setName("testName");
equipment.setInventoryId("test-inv");
equipment.setEquipmentType(EquipmentType.AP);
equipment.setCustomerId(customerId);
return equipmentServicelocal.create(equipment);
}
}

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
<artifactId>all-cloud-and-opensync-gw-in-one-docker</artifactId>
@@ -22,7 +22,7 @@
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>all-cloud-and-opensync-gw-in-one-process</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
</dependencies>

View File

@@ -57,6 +57,9 @@ OVSDB_DEVICE_RADIO_1="${OVSDB_DEVICE_RADIO_1:=radio1}"
echo $OVSDB_DEVICE_RADIO_1
OVSDB_DEVICE_RADIO_2="${OVSDB_DEVICE_RADIO_2:=radio2}"
echo $OVSDB_DEVICE_RADIO_2
OVSDB_OFF_CHANNEL_REPORTING_INTERVAL_SECONDS="${OVSDB_OFF_CHANNEL_REPORTING_INTERVAL_SECONDS:=120}"
OVSDB_REPORTING_INTERVAL_SECONDS="${OVSDB_REPORTING_INTERVAL_SECONDS:=60}"
echo Reading AP configuration from $OVSDB_CONFIG_FILE
@@ -150,6 +153,8 @@ OVSDB_PROPS="$OVSDB_PROPS -Dtip.wlan.ovsdb.wifi-iface.default_radio2=$OVSDB_IF_D
OVSDB_PROPS="$OVSDB_PROPS -Dtip.wlan.ovsdb.wifi-device.radio0=$OVSDB_DEVICE_RADIO_0"
OVSDB_PROPS="$OVSDB_PROPS -Dtip.wlan.ovsdb.wifi-device.radio1=$OVSDB_DEVICE_RADIO_1"
OVSDB_PROPS="$OVSDB_PROPS -Dtip.wlan.ovsdb.wifi-device.radio2=$OVSDB_DEVICE_RADIO_2"
OVSDB_PROPS="$OVSDB_PROPS -Dtip.wlan.defaultOffChannelReportingIntervalSeconds=$OVSDB_OFF_CHANNEL_REPORTING_INTERVAL_SECONDS"
OVSDB_PROPS="$OVSDB_PROPS -Dtip.wlan.defaultReportingIntervalSeconds=$OVSDB_REPORTING_INTERVAL_SECONDS"
echo OVSDB_PROPS $OVSDB_PROPS

View File

@@ -39,6 +39,8 @@ OVSDB_PROPS+=" -Dtip.wlan.ovsdb.wifi-iface.default_radio2=$OVSDB_IF_DEFAULT_RADI
OVSDB_PROPS+=" -Dtip.wlan.ovsdb.wifi-device.radio0=$OVSDB_DEVICE_RADIO_0"
OVSDB_PROPS+=" -Dtip.wlan.ovsdb.wifi-device.radio1=$OVSDB_DEVICE_RADIO_1"
OVSDB_PROPS+=" -Dtip.wlan.ovsdb.wifi-device.radio2=$OVSDB_DEVICE_RADIO_2"
OVSDB_PROPS+=" -Dtip.wlan.defaultOffChannelReportingIntervalSeconds=$OVSDB_OFF_CHANNEL_REPORTING_INTERVAL_SECONDS"
OVSDB_PROPS+=" -Dtip.wlan.defaultReportingIntervalSeconds=$OVSDB_REPORTING_INTERVAL_SECONDS"
echo OVSDB_PROPS $OVSDB_PROPS

View File

@@ -0,0 +1 @@
/target/

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
@@ -21,350 +21,344 @@
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>opensync-ext-cloud</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<!-- PortForwarding Gateway - to support remote ssh connections to APs -->
<dependency>
<artifactId>port-forwarding-gateway</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<!-- portal services -->
<dependency>
<artifactId>webtoken-auth-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>portal-services</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>customer-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>location-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>equipment-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>profile-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>portal-user-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>status-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>client-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>alarm-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>service-metric-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>system-event-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>routing-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>firmware-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>manufacturer-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>adoption-metrics-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>filestore-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<!-- prov services -->
<dependency>
<artifactId>customer-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- Use in-memory DS for now, later switch to RDBMS -->
<artifactId>customer-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>location-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- Use in-memory DS for now, later switch to RDBMS -->
<artifactId>location-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>equipment-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- Use in-memory DS for now, later switch to RDBMS -->
<artifactId>equipment-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>profile-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- Use in-memory DS for now, later switch to RDBMS -->
<artifactId>profile-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>portal-user-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- Use in-memory DS for now, later switch to RDBMS -->
<artifactId>portal-user-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>firmware-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- Use in-memory DS for now, later switch to RDBMS -->
<artifactId>firmware-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>manufacturer-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- Use in-memory DS for now, later switch to RDBMS -->
<artifactId>manufacturer-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>adoption-metrics-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- Use in-memory DS for now, later switch to RDBMS -->
<artifactId>adoption-metrics-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>cloud-event-dispatcher-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<!-- ssc services -->
<dependency>
<artifactId>cloud-event-dispatcher</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>service-metric-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- Use in-memory DS for now, later switch to RDBMS -->
<artifactId>service-metric-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>system-event-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- Use in-memory DS for now, later switch to RDBMS -->
<artifactId>system-event-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>alarm-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- Use in-memory DS for now, later switch to RDBMS -->
<artifactId>alarm-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>status-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- Use in-memory DS for now, later switch to RDBMS -->
<artifactId>status-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>client-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- Use in-memory DS for now, later switch to RDBMS -->
<artifactId>client-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>routing-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- Use in-memory DS for now, later switch to RDBMS -->
<artifactId>routing-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<!-- Stream Processors -->
<dependency>
<artifactId>single-process-streams</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>provisioning-sp</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>dashboard-sp</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>equipment-alarms-sp</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>adoption-metrics-sp</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>equipment-gateway-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
</dependencies>

View File

@@ -31,7 +31,6 @@ import com.telecominfraproject.wlan.client.models.Client;
import com.telecominfraproject.wlan.client.session.models.ClientDhcpDetails;
import com.telecominfraproject.wlan.client.session.models.ClientSession;
import com.telecominfraproject.wlan.client.session.models.ClientSessionDetails;
import com.telecominfraproject.wlan.client.session.models.ClientSessionMetricDetails;
import com.telecominfraproject.wlan.core.model.entity.CountryCode;
import com.telecominfraproject.wlan.core.model.entity.MinMaxAvgValueInt;
import com.telecominfraproject.wlan.core.model.equipment.EquipmentType;
@@ -86,6 +85,7 @@ import com.telecominfraproject.wlan.servicemetric.models.ServiceMetricDataType;
import com.telecominfraproject.wlan.status.StatusServiceInterface;
import com.telecominfraproject.wlan.status.dashboard.models.CustomerPortalDashboardStatus;
import com.telecominfraproject.wlan.status.equipment.models.EquipmentAdminStatusData;
import com.telecominfraproject.wlan.status.equipment.models.EquipmentChannelStatusData;
import com.telecominfraproject.wlan.status.equipment.models.EquipmentProtocolState;
import com.telecominfraproject.wlan.status.equipment.models.EquipmentProtocolStatusData;
import com.telecominfraproject.wlan.status.equipment.report.models.EquipmentCapacityDetails;
@@ -810,10 +810,10 @@ public class AllInOneWithGatewayStartListener implements ApplicationRunner {
sessionDetails.setRadioType(radioType);
sessionDetails.setSecurityType(SecurityType.PSK);
sessionDetails.setSsid(ssidConfig.getSsid());
sessionDetails.setSessionId(System.currentTimeMillis());
sessionDetails.setSessionId(Long.toUnsignedString(System.currentTimeMillis()));
sessionDetails.setAssocTimestamp(System.currentTimeMillis() - getRandomLong(10000, 1000000));
ClientDhcpDetails dhcpDetails = new ClientDhcpDetails(System.currentTimeMillis());
ClientDhcpDetails dhcpDetails = new ClientDhcpDetails(Long.toUnsignedString(System.currentTimeMillis()));
dhcpDetails.setLeaseStartTimestamp(System.currentTimeMillis() - getRandomLong(0, TimeUnit.HOURS.toMillis(4)));
dhcpDetails.setLeaseTimeInSeconds((int)TimeUnit.HOURS.toSeconds(4));
try {
@@ -828,16 +828,6 @@ public class AllInOneWithGatewayStartListener implements ApplicationRunner {
sessionDetails.setDhcpDetails(dhcpDetails );
ClientSessionMetricDetails metricDetails = new ClientSessionMetricDetails();
metricDetails.setRssi(getRandomInt(-60, -40));
metricDetails.setRxBytes(getRandomLong(10000, 10000000));
metricDetails.setTxBytes(getRandomLong(10000, 10000000));
metricDetails.setRxMbps(getRandomFloat(50, 100));
metricDetails.setTxMbps(getRandomFloat(50, 100));
metricDetails.setSnr(getRandomInt(-90, -50));
sessionDetails.setMetricDetails(metricDetails);
clientSession.setDetails(sessionDetails);
this.clientServiceInterface.updateSession(clientSession);
@@ -950,6 +940,21 @@ public class AllInOneWithGatewayStartListener implements ApplicationRunner {
status.setDetails(eqRadioUtilReport);
statusList.add(status);
status = new Status();
status.setCustomerId(equipment.getCustomerId());
status.setEquipmentId(equipment.getId());
EquipmentChannelStatusData eqChannelStatus = new EquipmentChannelStatusData();
Map<RadioType, Integer> channelStatusDataMap = new EnumMap<>(RadioType.class);
channelStatusDataMap.put(RadioType.is2dot4GHz, 6);
channelStatusDataMap.put(RadioType.is5GHzL, 36);
channelStatusDataMap.put(RadioType.is5GHzU, 157);
eqChannelStatus.setChannelNumberStatusDataMap(channelStatusDataMap);
status.setDetails(eqChannelStatus);
statusList.add(status);
statusServiceInterface.update(statusList);
}

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
@@ -23,7 +23,7 @@
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>all-cloud-in-one-process-with-persistence</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
</dependencies>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
@@ -23,7 +23,7 @@
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>all-cloud-in-one-process</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
</dependencies>

View File

@@ -0,0 +1 @@
/target/

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
@@ -22,322 +22,244 @@
<dependency>
<artifactId>webtoken-auth-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>portal-services</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>customer-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>location-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>equipment-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>profile-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>portal-user-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>status-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>client-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>alarm-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>service-metric-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>system-event-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>routing-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>firmware-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>manufacturer-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>adoption-metrics-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>filestore-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<!-- prov services -->
<dependency>
<artifactId>customer-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>customer-datastore-rdbms</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>location-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>location-datastore-rdbms</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>equipment-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>equipment-datastore-rdbms</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>profile-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>profile-datastore-rdbms</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>portal-user-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>portal-user-datastore-rdbms</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>firmware-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>firmware-datastore-rdbms</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>manufacturer-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>manufacturer-datastore-rdbms</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>adoption-metrics-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>adoption-metrics-datastore-rdbms</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>cloud-event-dispatcher-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<!-- ssc services -->
<dependency>
<artifactId>cloud-event-dispatcher</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>service-metric-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>service-metric-datastore-rdbms</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>system-event-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>system-event-datastore-rdbms</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>alarm-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>alarm-datastore-rdbms</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>status-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>status-datastore-rdbms</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>client-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>client-datastore-rdbms</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>routing-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>routing-datastore-rdbms</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<!-- Stream Processors -->
<dependency>
<artifactId>single-process-streams</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>provisioning-sp</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>dashboard-sp</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>equipment-alarms-sp</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>adoption-metrics-sp</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>equipment-gateway-service-remote</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
</dependencies>

1
all-cloud-in-one-process/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target/

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
@@ -21,343 +21,337 @@
<dependency>
<artifactId>webtoken-auth-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>portal-services</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>customer-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>location-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>equipment-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>profile-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>portal-user-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>status-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>client-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>alarm-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>service-metric-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>system-event-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>routing-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>firmware-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>manufacturer-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>adoption-metrics-service-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>filestore-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<!-- prov services -->
<dependency>
<artifactId>customer-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- Use in-memory DS for now, later switch to RDBMS -->
<artifactId>customer-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>location-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- Use in-memory DS for now, later switch to RDBMS -->
<artifactId>location-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>equipment-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- Use in-memory DS for now, later switch to RDBMS -->
<artifactId>equipment-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>profile-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- Use in-memory DS for now, later switch to RDBMS -->
<artifactId>profile-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>portal-user-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- Use in-memory DS for now, later switch to RDBMS -->
<artifactId>portal-user-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>firmware-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- Use in-memory DS for now, later switch to RDBMS -->
<artifactId>firmware-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>manufacturer-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- Use in-memory DS for now, later switch to RDBMS -->
<artifactId>manufacturer-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>adoption-metrics-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- Use in-memory DS for now, later switch to RDBMS -->
<artifactId>adoption-metrics-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>cloud-event-dispatcher-local</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<!-- ssc services -->
<dependency>
<artifactId>cloud-event-dispatcher</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>service-metric-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- Use in-memory DS for now, later switch to RDBMS -->
<artifactId>service-metric-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>system-event-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- Use in-memory DS for now, later switch to RDBMS -->
<artifactId>system-event-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>alarm-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- Use in-memory DS for now, later switch to RDBMS -->
<artifactId>alarm-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>status-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- Use in-memory DS for now, later switch to RDBMS -->
<artifactId>status-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>client-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- Use in-memory DS for now, later switch to RDBMS -->
<artifactId>client-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>routing-service</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<!-- Use in-memory DS for now, later switch to RDBMS -->
<artifactId>routing-datastore-inmemory</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<!-- Stream Processors -->
<dependency>
<artifactId>single-process-streams</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>provisioning-sp</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>dashboard-sp</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>equipment-alarms-sp</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>adoption-metrics-sp</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<artifactId>equipment-gateway-service-remote</artifactId>
<groupId>com.telecominfraproject.wlan</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>port-forwarding-gateway-local</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
</dependencies>

View File

@@ -1,11 +1,10 @@
package com.telecominfraproject.wlan.startuptasks;
import java.io.BufferedWriter;
import java.io.IOException;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -39,7 +38,6 @@ import com.telecominfraproject.wlan.client.models.Client;
import com.telecominfraproject.wlan.client.session.models.ClientDhcpDetails;
import com.telecominfraproject.wlan.client.session.models.ClientSession;
import com.telecominfraproject.wlan.client.session.models.ClientSessionDetails;
import com.telecominfraproject.wlan.client.session.models.ClientSessionMetricDetails;
import com.telecominfraproject.wlan.core.model.entity.CountryCode;
import com.telecominfraproject.wlan.core.model.entity.MinMaxAvgValueInt;
import com.telecominfraproject.wlan.core.model.equipment.EquipmentType;
@@ -111,6 +109,7 @@ import com.telecominfraproject.wlan.servicemetric.models.ServiceMetricDataType;
import com.telecominfraproject.wlan.status.StatusServiceInterface;
import com.telecominfraproject.wlan.status.dashboard.models.CustomerPortalDashboardStatus;
import com.telecominfraproject.wlan.status.equipment.models.EquipmentAdminStatusData;
import com.telecominfraproject.wlan.status.equipment.models.EquipmentChannelStatusData;
import com.telecominfraproject.wlan.status.equipment.models.EquipmentProtocolState;
import com.telecominfraproject.wlan.status.equipment.models.EquipmentProtocolStatusData;
import com.telecominfraproject.wlan.status.equipment.report.models.EquipmentCapacityDetails;
@@ -324,12 +323,6 @@ public class AllInOneStartListener implements ApplicationRunner {
rfConfig.getRfConfigMap().forEach((x, y) -> y.setRf("TipWlan-rf"));
profileRf.setDetails(rfConfig);
profileRf = profileServiceInterface.create(profileRf);
// create userlist file
Path path = constructCaptivePortalUserList();
LOG.debug("Path to userlist {}", path);
// Captive portal profile
Profile profileCaptivePortal = new Profile();
profileCaptivePortal.setCustomerId(customer.getId());
@@ -343,19 +336,15 @@ public class AllInOneStartListener implements ApplicationRunner {
ManagedFileInfo backgroundFile = new ManagedFileInfo();
backgroundFile.setFileCategory(FileCategory.CaptivePortalBackground);
backgroundFile.setFileType(FileType.PNG);
backgroundFile.setApExportUrl("/filestore/tip-logo.png");
backgroundFile.setApExportUrl("tip-logo.png");
ManagedFileInfo logoFile = new ManagedFileInfo();
logoFile.setFileCategory(FileCategory.CaptivePortalLogo);
logoFile.setFileType(FileType.PNG);
logoFile.setApExportUrl("/filestore/tip-logo-mobile.png");
ManagedFileInfo usernamePasswordFile = new ManagedFileInfo();
usernamePasswordFile.setFileCategory(FileCategory.UsernamePasswordList);
usernamePasswordFile.setFileType(FileType.TEXT);
usernamePasswordFile.setApExportUrl("/filestore/userlist.txt");
captivePortalConfig.setUsernamePasswordFile(usernamePasswordFile);
logoFile.setApExportUrl("tip-logo-mobile.png");
captivePortalConfig.setBackgroundFile(backgroundFile);
captivePortalConfig.setLogoFile(logoFile);
captivePortalConfig.setBrowserTitle(profileCaptivePortal.getName());
captivePortalConfig.setUserList(constructCaptivePortalUserList());
profileCaptivePortal.setDetails(captivePortalConfig);
profileCaptivePortal = profileServiceInterface.create(profileCaptivePortal);
@@ -856,7 +845,7 @@ public class AllInOneStartListener implements ApplicationRunner {
return hotspot20IdProviderProfile;
}
protected Path constructCaptivePortalUserList() {
protected List<TimedAccessUserRecord> constructCaptivePortalUserList() {
List<TimedAccessUserRecord> userList = new ArrayList<>();
@@ -941,22 +930,24 @@ public class AllInOneStartListener implements ApplicationRunner {
try {
Files.deleteIfExists(path);
} catch (Exception e) {
e.printStackTrace();
LOG.error("Cannot delete {}", path, e);
}
StringBuilder sb = new StringBuilder();
for (TimedAccessUserRecord userRecord : userList) {
sb.append("username=" + userRecord.getUsername() + ", password=" + userRecord.getPassword()
byte[] bytes = ("username=" + userRecord.getUsername() + ", password=" + userRecord.getPassword()
+ ", firstname=" + userRecord.getUserDetails().getFirstName() + ", lastname="
+ userRecord.getUserDetails().getLastName() + System.lineSeparator());
+ userRecord.getUserDetails().getLastName() + System.lineSeparator()).getBytes();
try {
Files.write(path, bytes, StandardOpenOption.APPEND);
LOG.debug("Successfully written data to the file {}", path);
} catch (IOException e) {
try {
Files.write(path, bytes);
} catch (IOException e1) {
throw new RuntimeException(e1);
}
}
}
try (BufferedWriter bw = Files.newBufferedWriter(path, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW)) {
bw.write(sb.toString());
System.out.println("Successfully written data to the file");
} catch (Exception e) {
e.printStackTrace();
}
return path;
return userList;
}
private void createFirmwareObjects(Customer customer) {
@@ -1246,8 +1237,6 @@ public class AllInOneStartListener implements ApplicationRunner {
clientMetrics.setNumRxBytes(getRandomLong(3000000, 7000000));
clientMetrics.setNumTxBytes(getRandomLong(3000000, 7000000));
clientMetrics.setSessionId(getRandomLong(3000000, 7000000));
clientMetrics.setTxRetries(getRandomInt(30, 70));
clientMetrics.setRxDuplicatePackets(getRandomInt(30, 70));
clientMetrics.setSnr(getRandomInt(-70, -30));
@@ -1273,8 +1262,6 @@ public class AllInOneStartListener implements ApplicationRunner {
clientMetrics.setNumRxBytes(getRandomLong(3000000, 7000000));
clientMetrics.setNumTxBytes(getRandomLong(3000000, 7000000));
clientMetrics.setSessionId(getRandomLong(3000000, 7000000));
clientMetrics.setTxRetries(getRandomInt(30, 70));
clientMetrics.setRxDuplicatePackets(getRandomInt(30, 70));
clientMetrics.setSnr(getRandomInt(-70, -30));
@@ -1300,8 +1287,6 @@ public class AllInOneStartListener implements ApplicationRunner {
clientMetrics.setNumRxBytes(getRandomLong(3000000, 7000000));
clientMetrics.setNumTxBytes(getRandomLong(3000000, 7000000));
clientMetrics.setSessionId(getRandomLong(3000000, 7000000));
clientMetrics.setTxRetries(getRandomInt(30, 70));
clientMetrics.setRxDuplicatePackets(getRandomInt(30, 70));
clientMetrics.setSnr(getRandomInt(-70, -30));
@@ -1369,10 +1354,10 @@ public class AllInOneStartListener implements ApplicationRunner {
sessionDetails.setRadioType(radioType);
sessionDetails.setSecurityType(SecurityType.PSK);
sessionDetails.setSsid(ssidConfig.getSsid());
sessionDetails.setSessionId(System.currentTimeMillis());
sessionDetails.setSessionId(Long.toUnsignedString(System.currentTimeMillis()));
sessionDetails.setAssocTimestamp(System.currentTimeMillis() - getRandomLong(10000, 1000000));
ClientDhcpDetails dhcpDetails = new ClientDhcpDetails(System.currentTimeMillis());
ClientDhcpDetails dhcpDetails = new ClientDhcpDetails(Long.toUnsignedString(System.currentTimeMillis()));
dhcpDetails
.setLeaseStartTimestamp(System.currentTimeMillis() - getRandomLong(0, TimeUnit.HOURS.toMillis(4)));
dhcpDetails.setLeaseTimeInSeconds((int) TimeUnit.HOURS.toSeconds(4));
@@ -1388,16 +1373,6 @@ public class AllInOneStartListener implements ApplicationRunner {
sessionDetails.setDhcpDetails(dhcpDetails);
ClientSessionMetricDetails metricDetails = new ClientSessionMetricDetails();
metricDetails.setRssi(getRandomInt(-60, -40));
metricDetails.setRxBytes(getRandomLong(10000, 10000000));
metricDetails.setTxBytes(getRandomLong(10000, 10000000));
metricDetails.setRxMbps(getRandomFloat(50, 100));
metricDetails.setTxMbps(getRandomFloat(50, 100));
metricDetails.setSnr(getRandomInt(-90, -50));
sessionDetails.setMetricDetails(metricDetails);
clientSession.setDetails(sessionDetails);
this.clientServiceInterface.updateSession(clientSession);
@@ -1511,6 +1486,21 @@ public class AllInOneStartListener implements ApplicationRunner {
status.setDetails(eqRadioUtilReport);
statusList.add(status);
status = new Status();
status.setCustomerId(equipment.getCustomerId());
status.setEquipmentId(equipment.getId());
EquipmentChannelStatusData eqChannelStatus = new EquipmentChannelStatusData();
Map<RadioType, Integer> channelStatusDataMap = new EnumMap<>(RadioType.class);
channelStatusDataMap.put(RadioType.is2dot4GHz, 6);
channelStatusDataMap.put(RadioType.is5GHzL, 36);
channelStatusDataMap.put(RadioType.is5GHzU, 157);
eqChannelStatus.setChannelNumberStatusDataMap(channelStatusDataMap);
status.setDetails(eqChannelStatus);
statusList.add(status);
statusServiceInterface.update(statusList);
}

1
client-datastore-cassandra/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target/

View File

@@ -1,10 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
@@ -16,26 +15,26 @@
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-cassandra</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>client-datastore-interface</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-cassandra-tests</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>client-datastore-common-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>

View File

@@ -142,10 +142,7 @@ public class ClientDAO {
private static final String CQL_DELETE_BLOCKED_LIST =
"delete from client_blocklist where customerId = ? and macAddress = ?";
// Statements using client_by_mac_string table
private static final String CQL_GET_CLIENT_MAC_BY_CUSTOMER_ID =
"select customerId, macAddress from client_by_mac_string where customerId = ?";
// Statements using client_by_mac_string table
private static final String CQL_GET_CLIENT_MAC_LIKE_MAC_SUBSTRING =
"select customerId, macAddress from client_by_mac_string where customerId = ? and macAddressString like ?";
@@ -169,7 +166,6 @@ public class ClientDAO {
private PreparedStatement preparedStmt_getBlockedListForCustomer;
private PreparedStatement preparedStmt_insertBlockedList;
private PreparedStatement preparedStmt_deleteBlockedList;
private PreparedStatement preparedStmt_getClientMacByCustomerId;
private PreparedStatement preparedStmt_getClientMacLikeMacString;
private PreparedStatement preparedStmt_insertMacString;
private PreparedStatement preparedStmt_deleteMacString;
@@ -188,7 +184,6 @@ public class ClientDAO {
preparedStmt_getBlockedListForCustomer = cqlSession.prepare(CQL_GET_BLOCKED_LIST_BY_CUSTOMER_ID);
preparedStmt_insertBlockedList = cqlSession.prepare(CQL_INSERT_BLOCKED_LIST);
preparedStmt_deleteBlockedList = cqlSession.prepare(CQL_DELETE_BLOCKED_LIST);
preparedStmt_getClientMacByCustomerId = cqlSession.prepare(CQL_GET_CLIENT_MAC_BY_CUSTOMER_ID);
preparedStmt_getClientMacLikeMacString = cqlSession.prepare(CQL_GET_CLIENT_MAC_LIKE_MAC_SUBSTRING);
preparedStmt_insertMacString = cqlSession.prepare(CQL_INSERT_INTO_CLIENT_MAC_STRING);
preparedStmt_deleteMacString = cqlSession.prepare(CQL_DELETE_FROM_CLIENT_MAC_STRING);
@@ -412,9 +407,10 @@ public class ClientDAO {
return results;
}
public PaginationResponse<Client> searchByMacAddress(int customerId, String macSubstring,
List<ColumnAndSort> sortBy, PaginationContext<Client> context) {
LOG.debug("calling searchByMacAddress({}, {})", customerId, macSubstring);
private static enum FilterOptions{ customer_only, customer_and_macAddress}
public PaginationResponse<Client> getForCustomer(int customerId, String macSubstring,
List<ColumnAndSort> sortBy, PaginationContext<Client> context) {
PaginationResponse<Client> ret = new PaginationResponse<>();
ret.setContext(context.clone());
@@ -422,108 +418,27 @@ public class ClientDAO {
if (ret.getContext().isLastPage()) {
// no more pages available according to the context
LOG.debug(
"No more pages available when looking up Clients for customer {} and macSubstring {} with last returned page number {}",
"No more pages available when looking up Clients for customer {} macSubstring {} with last returned page number {}",
customerId, macSubstring, context.getLastReturnedPageNumber());
return ret;
}
LOG.debug("Looking up Clients for customer {} and macSubstring {} with last returned page number {}",
LOG.debug("Looking up Clients for customer {} macSubstring {} with last returned page number {}",
customerId, macSubstring, context.getLastReturnedPageNumber());
// add sorting options for the query
// Cassandra allows very limited support for ordering results
// See https://cassandra.apache.org/doc/latest/cql/dml.html#select
// In here allowed orderings are the order induced by the clustering columns and the reverse of that one.
// also, order by with secondary indexes is not supported
// ***** We will ignore the order supplied by the caller for this datastore
ArrayList<Object> bindVars = new ArrayList<>();
BoundStatement boundStmt;
String query = CQL_GET_BY_CUSTOMER_ID;
FilterOptions filterOptions = FilterOptions.customer_only;
// add filters for the query
ArrayList<Object> queryArgs = new ArrayList<>();
queryArgs.add(customerId);
if (macSubstring != null && !macSubstring.isEmpty()) {
bindVars.add(customerId);
bindVars.add("%" + macSubstring.toLowerCase() + "%");
queryArgs.add("%" + macSubstring.toLowerCase() + "%");
boundStmt = preparedStmt_getClientMacLikeMacString.bind(bindVars.toArray());
} else {
bindVars.add(customerId);
boundStmt = preparedStmt_getClientMacByCustomerId.bind(bindVars.toArray());
query = CQL_GET_CLIENT_MAC_LIKE_MAC_SUBSTRING;
filterOptions = FilterOptions.customer_and_macAddress;
}
//have to do it this way - setPageSize creates new object
boundStmt = boundStmt.setPageSize(context.getMaxItemsPerPage());
if(context.getThirdPartyPagingState()!=null) {
ByteBuffer currentPagingState = ByteBuffer.wrap(context.getThirdPartyPagingState());
//have to do it this way - setPagingState creates new object
boundStmt = boundStmt.setPagingState(currentPagingState);
}
ResultSet rs = cqlSession.execute(boundStmt);
ByteBuffer nextPagingState = rs.getExecutionInfo().getPagingState();
List<Client> pageItems = new ArrayList<>();
Set<MacAddress> macSet = new HashSet<>();
// iterate through the current page
while (rs.getAvailableWithoutFetching() > 0) {
// macSet will contain MACs of paginated items to get Client objects via macSet
macSet.add(new MacAddress(rs.one().getLong("macAddress")));
}
pageItems.addAll(get(customerId, macSet));
if (pageItems.isEmpty()) {
LOG.debug("Cannot find Clients for customer {} and macSubstring {} with last returned page number {}",
customerId, macSubstring, context.getLastReturnedPageNumber());
} else {
LOG.debug("Found {} Clients for customer {} and macSubstring {} with last returned page number {}",
pageItems.size(), customerId, macSubstring, context.getLastReturnedPageNumber());
}
ret.setItems(pageItems);
// adjust context for the next page
ret.prepareForNextPage();
if(nextPagingState!=null) {
ret.getContext().setThirdPartyPagingState(nextPagingState.array());
} else {
ret.getContext().setThirdPartyPagingState(null);
}
// startAfterItem is not used in Cassandra datastores, set it to null
ret.getContext().setStartAfterItem(null);
//in cassandra we will rely only on nextPagingState to set the lastPage indicator
ret.getContext().setLastPage(false);
if(nextPagingState == null) {
//in cassandra, if there are no more pages available, the pagingState is returned as null by the driver
//this overrides all other heuristics related to guessing the indication of the last page
ret.getContext().setLastPage(true);
}
return ret;
}
public PaginationResponse<Client> getForCustomer(int customerId, List<ColumnAndSort> sortBy,
PaginationContext<Client> context) {
PaginationResponse<Client> ret = new PaginationResponse<>();
ret.setContext(context.clone());
if (ret.getContext().isLastPage()) {
// no more pages available according to the context
LOG.debug(
"No more pages available when looking up Clients for customer {} with last returned page number {}",
customerId, context.getLastReturnedPageNumber());
return ret;
}
LOG.debug("Looking up Clients for customer {} with last returned page number {}",
customerId, context.getLastReturnedPageNumber());
// add sorting options for the query
// Cassandra allows very limited support for ordering results
@@ -531,8 +446,18 @@ public class ClientDAO {
// In here allowed orderings are the order induced by the clustering columns and the reverse of that one.
// also, order by with secondary indexes is not supported
// ***** We will ignore the order supplied by the caller for this datastore
BoundStatement boundStmt = preparedStmt_getPageForCustomer.bind(customerId );
PreparedStatement preparedStmt_getPageForCustomer;
try {
preparedStmt_getPageForCustomer = cqlSession.prepare(query);
} catch(InvalidQueryException e) {
LOG.error("Cannot prepare cassandra query '{}'", query, e);
throw e;
}
// add pagination parameters for the query
BoundStatement boundStmt = preparedStmt_getPageForCustomer.bind(queryArgs.toArray() );
//have to do it this way - setPageSize creates new object
boundStmt = boundStmt.setPageSize(context.getMaxItemsPerPage());
@@ -547,17 +472,36 @@ public class ClientDAO {
List<Client> pageItems = new ArrayList<>();
// iterate through the current page
while (rs.getAvailableWithoutFetching() > 0) {
pageItems.add(clientRowMapper.mapRow(rs.one()));
switch(filterOptions) {
case customer_only:
// iterate through the current page
while (rs.getAvailableWithoutFetching() > 0) {
pageItems.add(clientRowMapper.mapRow(rs.one()));
}
break;
case customer_and_macAddress:
//the query was against client_by_mac_string table
//find all the macAddresses for the page, then retrieve records for them from client table
Set<MacAddress> macAddrSet = new HashSet<>();
while (rs.getAvailableWithoutFetching() > 0) {
macAddrSet.add(new MacAddress(rs.one().getLong("macAddress")));
}
//get all clients for the involved mac addresses
pageItems = get(customerId, macAddrSet);
break;
default:
LOG.warn("Unknown filter option:", filterOptions);
throw new IllegalArgumentException("Unknown filter option " + filterOptions);
}
if (pageItems.isEmpty()) {
LOG.debug("Cannot find Clients for customer {} with last returned page number {}",
customerId, context.getLastReturnedPageNumber());
LOG.debug("Cannot find Clients for customer {} macSubstring {} with last returned page number {}",
customerId, macSubstring, context.getLastReturnedPageNumber());
} else {
LOG.debug("Found {} Clients for customer {} with last returned page number {}",
pageItems.size(), customerId, context.getLastReturnedPageNumber());
LOG.debug("Found {} Clients for customer {} macSubstring {} with last returned page number {}",
pageItems.size(), customerId, macSubstring, context.getLastReturnedPageNumber());
}
ret.setItems(pageItems);

View File

@@ -12,6 +12,7 @@ import com.telecominfraproject.wlan.core.model.pagination.PaginationContext;
import com.telecominfraproject.wlan.core.model.pagination.PaginationResponse;
import com.telecominfraproject.wlan.client.datastore.ClientDatastore;
import com.telecominfraproject.wlan.client.info.models.ClientSessionCounts;
import com.telecominfraproject.wlan.client.models.Client;
import com.telecominfraproject.wlan.client.session.models.ClientSession;
@@ -46,30 +47,30 @@ public class ClientDatastoreCassandra implements ClientDatastore {
}
@Override
public List<Client> get(int customerId, Set<MacAddress> clientMacSet) {
return clientDAO.get(customerId, clientMacSet);
public void delete(long createdBeforeTimestamp) {
//This should be handled by Cassandra's life cycle for data.
return;
}
@Override
public PaginationResponse<Client> searchByMacAddress(int customerId, String macSubstring,
List<ColumnAndSort> sortBy, PaginationContext<Client> context) {
return clientDAO.searchByMacAddress(customerId, macSubstring, sortBy, context);
public List<Client> get(int customerId, Set<MacAddress> clientMacSet) {
return clientDAO.get(customerId, clientMacSet);
}
@Override
public List<Client> getBlockedClients(int customerId) {
return clientDAO.getBlockedClients(customerId);
}
@Override
public PaginationResponse<Client> getForCustomer(int customerId, List<ColumnAndSort> sortBy,
PaginationContext<Client> context) {
public PaginationResponse<Client> getForCustomer(int customerId, String macSubstring,
List<ColumnAndSort> sortBy, PaginationContext<Client> context) {
if(context == null) {
context = new PaginationContext<>();
}
return clientDAO.getForCustomer( customerId, sortBy, context);
return clientDAO.getForCustomer(customerId, macSubstring, sortBy, context);
}
@Override
@@ -86,6 +87,12 @@ public class ClientDatastoreCassandra implements ClientDatastore {
public ClientSession deleteSession(int customerId, long equipmentId, MacAddress clientMac) {
return clientSessionDAO.deleteSession(customerId, equipmentId, clientMac);
}
@Override
public void deleteSessions(long createdBeforeTimestamp) {
//This should be handled by Cassandra's lifecycle for data.
return;
}
@Override
public List<ClientSession> getSessions(int customerId, Set<MacAddress> clientMacSet) {
@@ -94,14 +101,21 @@ public class ClientDatastoreCassandra implements ClientDatastore {
@Override
public PaginationResponse<ClientSession> getSessionsForCustomer(int customerId, Set<Long> equipmentIds, Set<Long> locationIds,
List<ColumnAndSort> sortBy, PaginationContext<ClientSession> context) {
String macSubstring, List<ColumnAndSort> sortBy, PaginationContext<ClientSession> context) {
if(context == null) {
context = new PaginationContext<>();
}
return clientSessionDAO.getSessionsForCustomer(customerId, equipmentIds, locationIds, sortBy, context);
return clientSessionDAO.getSessionsForCustomer(customerId, equipmentIds, locationIds, macSubstring, sortBy, context);
}
@Override
public ClientSessionCounts getSessionCounts(int customerId) {
// Not yet supported.
ClientSessionCounts counts = new ClientSessionCounts();
return counts;
}
}

View File

@@ -26,6 +26,7 @@ import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
import com.telecominfraproject.wlan.core.model.pagination.ColumnAndSort;
import com.telecominfraproject.wlan.core.model.pagination.PaginationContext;
import com.telecominfraproject.wlan.core.model.pagination.PaginationResponse;
import com.telecominfraproject.wlan.core.server.cassandra.CassandraUtils;
import com.telecominfraproject.wlan.core.server.cassandra.RowMapper;
import com.telecominfraproject.wlan.datastore.exceptions.DsEntityNotFoundException;
@@ -134,6 +135,12 @@ public class ClientSessionDAO {
private static final String CQL_INSERT_INTO_BY_LOCATION_TABLE = "insert into client_session_by_location(customerId, locationId, equipmentId, macAddress) values ( ?, ?, ?, ?) ";
private static final String CQL_DELETE_FROM_BY_LOCATION_TABLE = "delete from client_session_by_location where locationId = ? and equipmentId = ? and macAddress = ? ";
private static final String CQL_INSERT_INTO_CLIENT_SESSION_MAC = "insert into client_session_by_mac (customerId, locationId, equipmentId, macAddress, macAddressString) values (?, ?, ?, ?, ?)";
private static final String CQL_DELETE_FROM_CLIENT_SESSION_MAC = "delete from client_session_by_mac where locationId = ? and equipmentId = ? and macAddress = ?";
private static final String CQL_INSERT_INTO_CLIENT_SESSION_MAC_AND_EQUIPMENT = "insert into client_session_by_mac_and_equipment (customerId, locationId, equipmentId, macAddress, macAddressString) values (?, ?, ?, ?, ?)";
private static final String CQL_DELETE_FROM_CLIENT_SESSION_MAC_AND_EQUIPMENT = "delete from client_session_by_mac_and_equipment where locationId = ? and equipmentId = ? and macAddress = ?";
private static final RowMapper<ClientSession> clientSessionRowMapper = new ClientSessionRowMapper();
@@ -151,6 +158,11 @@ public class ClientSessionDAO {
private PreparedStatement preparedStmt_deleteByEquipment;
private PreparedStatement preparedStmt_createByLocation;
private PreparedStatement preparedStmt_deleteByLocation;
private PreparedStatement preparedStmt_createByMac;
private PreparedStatement preparedStmt_deleteByMac;
private PreparedStatement preparedStmt_createByMacAndEquipment;
private PreparedStatement preparedStmt_deleteByMacAndEquipment;
@PostConstruct
private void postConstruct(){
@@ -166,6 +178,10 @@ public class ClientSessionDAO {
preparedStmt_deleteByEquipment = cqlSession.prepare(CQL_DELETE_FROM_BY_EQUIPMENT_TABLE);
preparedStmt_createByLocation = cqlSession.prepare(CQL_INSERT_INTO_BY_LOCATION_TABLE);
preparedStmt_deleteByLocation = cqlSession.prepare(CQL_DELETE_FROM_BY_LOCATION_TABLE);
preparedStmt_createByMac = cqlSession.prepare(CQL_INSERT_INTO_CLIENT_SESSION_MAC);
preparedStmt_deleteByMac = cqlSession.prepare(CQL_DELETE_FROM_CLIENT_SESSION_MAC);
preparedStmt_createByMacAndEquipment = cqlSession.prepare(CQL_INSERT_INTO_CLIENT_SESSION_MAC_AND_EQUIPMENT);
preparedStmt_deleteByMacAndEquipment = cqlSession.prepare(CQL_DELETE_FROM_CLIENT_SESSION_MAC_AND_EQUIPMENT);
} catch (InvalidQueryException e) {
LOG.error("Cannot prepare query", e);
@@ -203,6 +219,22 @@ public class ClientSessionDAO {
clientSession.getLocationId(),
clientSession.getEquipmentId(),
clientSession.getMacAddress().getAddressAsLong()));
cqlSession.execute(preparedStmt_createByMac.bind(
clientSession.getCustomerId(),
clientSession.getLocationId(),
clientSession.getEquipmentId(),
clientSession.getMacAddress().getAddressAsLong(),
clientSession.getMacAddress().getAddressAsString()
));
cqlSession.execute(preparedStmt_createByMacAndEquipment.bind(
clientSession.getCustomerId(),
clientSession.getLocationId(),
clientSession.getEquipmentId(),
clientSession.getMacAddress().getAddressAsLong(),
clientSession.getMacAddress().getAddressAsString()
));
LOG.debug("Stored Client session {}", clientSession);
@@ -297,6 +329,16 @@ public class ClientSessionDAO {
clientSession.getLocationId(),
clientSession.getEquipmentId(),
clientSession.getMacAddress().getAddressAsLong()));
cqlSession.execute(preparedStmt_deleteByMac.bind(
clientSession.getLocationId(),
clientSession.getEquipmentId(),
clientSession.getMacAddress().getAddressAsLong()));
cqlSession.execute(preparedStmt_deleteByMacAndEquipment.bind(
clientSession.getLocationId(),
clientSession.getEquipmentId(),
clientSession.getMacAddress().getAddressAsLong()));
return clientSession;
@@ -336,9 +378,9 @@ public class ClientSessionDAO {
return results;
}
private static enum FilterOptions{ customer_only, customer_and_equipment, customer_and_location}
private static enum FilterOptions{ customer_only, customer_and_equipment, customer_and_location, customer_and_macAddress}
public PaginationResponse<ClientSession> getSessionsForCustomer(int customerId, Set<Long> equipmentIds, Set<Long> locationIds, List<ColumnAndSort> sortBy,
public PaginationResponse<ClientSession> getSessionsForCustomer(int customerId, Set<Long> equipmentIds, Set<Long> locationIds, String macSubstring, List<ColumnAndSort> sortBy,
PaginationContext<ClientSession> context) {
PaginationResponse<ClientSession> ret = new PaginationResponse<>();
@@ -367,18 +409,8 @@ public class ClientSessionDAO {
if (equipmentIds != null && !equipmentIds.isEmpty()) {
queryArgs.addAll(equipmentIds);
StringBuilder strb = new StringBuilder(100);
strb.append("and equipmentId in (");
for (int i = 0; i < equipmentIds.size(); i++) {
strb.append("?");
if (i < equipmentIds.size() - 1) {
strb.append(",");
}
}
strb.append(") ");
query += strb.toString();
query_head = "select macAddress from client_session_by_equipment where customerId = ? ";
query += "and equipmentId in " + CassandraUtils.getBindPlaceholders(equipmentIds);
query_head = "select macAddress, equipmentId from client_session_by_equipment where customerId = ? ";
filterOptions = FilterOptions.customer_and_equipment;
}
@@ -392,21 +424,32 @@ public class ClientSessionDAO {
queryArgs.addAll(equipmentIds);
}
StringBuilder strb = new StringBuilder(100);
strb.append(" locationId in (");
for (int i = 0; i < locationIds.size(); i++) {
strb.append("?");
if (i < locationIds.size() - 1) {
strb.append(",");
}
}
strb.append(") ");
query = strb.toString() + query;
query_head = "select macAddress from client_session_by_location where ";
query = " locationId in " + CassandraUtils.getBindPlaceholders(locationIds) + query;
query_head = "select macAddress, equipmentId from client_session_by_location where ";
filterOptions = FilterOptions.customer_and_location;
}
//add macSubstring filters
if (macSubstring != null && !macSubstring.isEmpty()) {
queryArgs.clear();
queryArgs.add(customerId);
queryArgs.add("%" + macSubstring.toLowerCase() + "%");
query_head = "select macAddress, equipmentId from client_session_by_mac where customerId = ? ";
if (locationIds != null && !locationIds.isEmpty()) {
queryArgs.addAll(locationIds);
query = "and " + query;
}
if (equipmentIds != null && !equipmentIds.isEmpty()) {
queryArgs.addAll(equipmentIds);
query_head = "select macAddress, equipmentId from client_session_by_mac_and_equipment where customerId = ? ";
}
query = " and macAddressString like ? " + query + " allow filtering";
filterOptions = FilterOptions.customer_and_macAddress;
}
// add sorting options for the query
// Cassandra allows very limited support for ordering results
@@ -450,25 +493,25 @@ public class ClientSessionDAO {
break;
case customer_and_equipment:
case customer_and_location:
//the query was against client_session_by_equipment or client_session_by_location table
//find all the macAddresses for the page, then retrieve records for them from client_session table
Set<MacAddress> macAddrSet = new HashSet<>();
case customer_and_macAddress:
//the query was against client_session_by_equipment, client_session_by_location, or client_session_by_mac(_and_equipment) table
//find all the macAddresses and equipmentId for the page, then retrieve records for them from client_session table
while (rs.getAvailableWithoutFetching() > 0) {
macAddrSet.add(new MacAddress(rs.one().getLong("macAddress")));
}
//get all the sessions for the involved mac addresses
List<ClientSession> pageSessions = getSessions(customerId, macAddrSet);
//apply local filtering because retrieved sessions may be from different equipments and locations
pageSessions.forEach(cs -> {
//apply locationId and equipmentId filtering in here
if ((locationIds == null || locationIds.isEmpty() || locationIds.contains(cs.getLocationId()))
&& (equipmentIds == null || equipmentIds.isEmpty() || equipmentIds.contains(cs.getEquipmentId())) )
Row row = rs.one();
MacAddress macAddr = new MacAddress(row.getLong("macAddress"));
long eqId = row.getLong("equipmentId");
// get a single client session per customerId, returned equipmentId, and returned macAddress from filter tables
ClientSession retSession = getSessionOrNull(customerId, eqId, macAddr);
if (retSession != null
&& (locationIds == null || locationIds.isEmpty() || locationIds.contains(retSession.getLocationId()))
&& (equipmentIds == null || equipmentIds.isEmpty() || equipmentIds.contains(retSession.getEquipmentId()))
&& (macSubstring == null || macSubstring.isEmpty() || retSession.getMacAddress().getAddressAsString().toLowerCase().contains(macSubstring.toLowerCase()))
)
{
pageItems.add(cs);
}
});
pageItems.add(retSession);
}
}
break;
default:

View File

@@ -26,7 +26,8 @@ CREATE TABLE IF NOT EXISTS tip_wlan_keyspace.client_by_mac_string (
PRIMARY KEY (customerId, macAddressString)
) WITH comment='Index Table to look up wireless client details by macAddress in text form used by TIP WLAN CloudSDK';
CREATE CUSTOM INDEX IF NOT EXISTS idx_client_macAddressString ON tip_wlan_keyspace.client_by_mac_string (macAddressString) USING 'org.apache.cassandra.index.sasi.SASIIndex' WITH OPTIONS = {'mode': 'CONTAINS', 'analyzer_class': 'org.apache.cassandra.index.sasi.analyzer.StandardAnalyzer', 'case_sensitive': 'false'};
DROP INDEX IF EXISTS tip_wlan_keyspace.idx_client_macAddressString;
CREATE CUSTOM INDEX IF NOT EXISTS idx_client_macAddressString_nonTokenizing ON tip_wlan_keyspace.client_by_mac_string (macAddressString) USING 'org.apache.cassandra.index.sasi.SASIIndex' WITH OPTIONS = {'mode': 'CONTAINS', 'analyzer_class': 'org.apache.cassandra.index.sasi.analyzer.NonTokenizingAnalyzer', 'case_sensitive': 'false'};
CREATE TABLE IF NOT EXISTS tip_wlan_keyspace.client_session (
@@ -41,8 +42,8 @@ CREATE TABLE IF NOT EXISTS tip_wlan_keyspace.client_session (
details blob,
PRIMARY KEY ((customerId, macAddress), equipmentId)
) WITH comment='Wireless client sessions used by TIP WLAN CloudSDK. Records automatically expire after 30 days'
AND default_time_to_live = 2592000;
) WITH comment='Wireless client sessions used by TIP WLAN CloudSDK. Records automatically expire after 24 hours'
AND default_time_to_live = 86400;
CREATE INDEX IF NOT EXISTS idx_client_session_customerId ON tip_wlan_keyspace.client_session (customerId);
@@ -52,16 +53,43 @@ CREATE TABLE IF NOT EXISTS tip_wlan_keyspace.client_session_by_equipment (
macAddress bigint ,
PRIMARY KEY ((customerId, equipmentId), macAddress)
) WITH comment='Index Table to look up wireless client sessions by equipmentId used by TIP WLAN CloudSDK. Records automatically expire after 30 days'
AND default_time_to_live = 2592000;
) WITH comment='Index Table to look up wireless client sessions by equipmentId used by TIP WLAN CloudSDK. Records automatically expire after 24 hours'
AND default_time_to_live = 86400;
CREATE TABLE IF NOT EXISTS tip_wlan_keyspace.client_session_by_location (
customerId int,
locationId bigint,
equipmentId bigint,
macAddress bigint ,
macAddress bigint,
PRIMARY KEY ((locationId), equipmentId, macAddress)
) WITH comment='Index Table to look up wireless client sessions by location and equipment used by TIP WLAN CloudSDK. Records automatically expire after 30 days'
AND default_time_to_live = 2592000;
) WITH comment='Index Table to look up wireless client sessions by location and equipment used by TIP WLAN CloudSDK. Records automatically expire after 24 hours'
AND default_time_to_live = 86400;
CREATE TABLE IF NOT EXISTS tip_wlan_keyspace.client_session_by_mac (
customerId int,
locationId bigint,
equipmentId bigint,
macAddress bigint,
macAddressString text,
PRIMARY KEY ((macAddress), locationId, equipmentId, macAddressString)
) WITH comment='Index Table to look up wireless client sessions by macAddressString, location, and equipment by TIP WLAN CloudSDK. Records automatically expire after 24 hours'
AND default_time_to_live = 86400;
CREATE TABLE IF NOT EXISTS tip_wlan_keyspace.client_session_by_mac_and_equipment (
customerId int,
locationId bigint,
equipmentId bigint,
macAddress bigint,
macAddressString text,
PRIMARY KEY ((macAddress), equipmentId, locationId, macAddressString)
) WITH comment='Index Table to look up wireless client sessions by macAddressString, location, and equipment by TIP WLAN CloudSDK. Records automatically expire after 24 hours'
AND default_time_to_live = 86400;
DROP INDEX IF EXISTS tip_wlan_keyspace.idx_client_session_by_mac_macAddressString;
DROP INDEX IF EXISTS tip_wlan_keyspace.idx_client_session_by_mac_and_equipment_macAddressString;
CREATE CUSTOM INDEX IF NOT EXISTS idx_client_session_by_mac_macAddressString_nonTokenizing ON tip_wlan_keyspace.client_session_by_mac (macAddressString) USING 'org.apache.cassandra.index.sasi.SASIIndex' WITH OPTIONS = {'mode': 'CONTAINS', 'analyzer_class': 'org.apache.cassandra.index.sasi.analyzer.NonTokenizingAnalyzer', 'case_sensitive': 'false'};
CREATE CUSTOM INDEX IF NOT EXISTS idx_client_session_by_mac_and_equipment_macAddressString_nonTokenizing ON tip_wlan_keyspace.client_session_by_mac_and_equipment (macAddressString) USING 'org.apache.cassandra.index.sasi.SASIIndex' WITH OPTIONS = {'mode': 'CONTAINS', 'analyzer_class': 'org.apache.cassandra.index.sasi.analyzer.NonTokenizingAnalyzer', 'case_sensitive': 'false'};

View File

@@ -30,22 +30,16 @@ public class ClientDatastoreCassandraTests extends BaseClientDatastoreTest {
@Override
protected List<String> getClientPagination_ExpectedPage3Strings() {
//in cassandra the sort order is weird but consistent - although it may change on the cassandra server restart
return new ArrayList<>(Arrays.asList(new String[]{"qr_0", "qr_13", "qr_47", "qr_4", "qr_36", "qr_21", "qr_12", "qr_27", "qr_20", "qr_19" }));
return new ArrayList<>(Arrays.asList(new String[]{"qr_10", "qr_13", "qr_8", "qr_18", "qr_42", "qr_30", "qr_35", "qr_28", "qr_14", "qr_22" }));
}
@Override
protected List<String> getClientPagination_ExpectedPage1EmptySortStrings(){
return new ArrayList<>(Arrays.asList(new String[]{"qr_46", "qr_9", "qr_3", "qr_6", "qr_1", "qr_26", "qr_10", "qr_40", "qr_14", "qr_42" }));
return new ArrayList<>(Arrays.asList(new String[]{"qr_32", "qr_0", "qr_12", "qr_25", "qr_40", "qr_39", "qr_29", "qr_41", "qr_4", "qr_44" }));
}
@Override
protected List<String> getSearchByMac_ExpectedPage1SingleSortDescStrings() {
return new ArrayList<>(Arrays.asList(new String[]{"qr_0", "qr_1", "qr_2", "qr_3", "qr_4", "qr_5", "qr_6", "qr_7", "qr_8", "qr_9" }));
}
@Override
protected List<String> getClientPagination_ExpectedPage1SingleSortDescStrings() {
return getClientPagination_ExpectedPage1EmptySortStrings();
@@ -54,12 +48,12 @@ public class ClientDatastoreCassandraTests extends BaseClientDatastoreTest {
@Override
protected List<String> getClientSessionPagination_expectedPage1EmptySortStrings(){
return new ArrayList<>(Arrays.asList(new String[]{"qr_30", "qr_43", "qr_18", "qr_9", "qr_10", "qr_23", "qr_20", "qr_47", "qr_1", "qr_40" }));
return new ArrayList<>(Arrays.asList(new String[]{"qr_12", "qr_47", "qr_4", "qr_1", "qr_21", "qr_42", "qr_45", "qr_35", "qr_14", "qr_0" }));
}
@Override
protected List<String> getClientSessionPagination_expectedPage3Strings(){
return new ArrayList<>(Arrays.asList(new String[]{"qr_42", "qr_16", "qr_27", "qr_36", "qr_48", "qr_13", "qr_39", "qr_28", "qr_15", "qr_29" }));
return new ArrayList<>(Arrays.asList(new String[]{"qr_28", "qr_32", "qr_6", "qr_19", "qr_49", "qr_31", "qr_33", "qr_25", "qr_7", "qr_40" }));
}
@Override

View File

@@ -125,13 +125,42 @@ select * from client_session_by_location where locationId in (1,2,3) and equipme
select customerId, locationId, equipmentId, macAddress from client_session_by_location where locationId in (1,2,3) and equipmentId in (1,2,3);
-- Index table for looking up client sessions by macAddress substring:
-- insert into it when client record is inserted
-- delete from it when client record is deleted
-- no update
insert into client_session_by_mac (customerId, locationId, equipmentId, macAddress, macAddressString) values ( 1, 1, 1, 1, 'A1:1');
insert into client_session_by_mac (customerId, locationId, equipmentId, macAddress, macAddressString) values ( 1, 1, 2, 2, 'A1:2');
insert into client_session_by_mac (customerId, locationId, equipmentId, macAddress, macAddressString) values ( 1, 2, 1, 3, 'A1:3');
insert into client_session_by_mac (customerId, locationId, equipmentId, macAddress, macAddressString) values ( 1, 2, 2, 3, 'B1:3');
insert into client_session_by_mac (customerId, locationId, equipmentId, macAddress, macAddressString) values ( 1, 3, 2, 3, 'B1:3');
insert into client_session_by_mac_and_equipment (customerId, locationId, equipmentId, macAddress, macAddressString) values ( 1, 1, 1, 1, 'A1:1');
insert into client_session_by_mac_and_equipment (customerId, locationId, equipmentId, macAddress, macAddressString) values ( 1, 1, 2, 2, 'A1:2');
insert into client_session_by_mac_and_equipment (customerId, locationId, equipmentId, macAddress, macAddressString) values ( 1, 2, 1, 3, 'A1:3');
insert into client_session_by_mac_and_equipment (customerId, locationId, equipmentId, macAddress, macAddressString) values ( 1, 2, 2, 3, 'B1:3');
insert into client_session_by_mac_and_equipment (customerId, locationId, equipmentId, macAddress, macAddressString) values ( 1, 3, 2, 3, 'B1:3');
select macAddress from client_session_by_mac where macAddressString like '%A1%';
select macAddress from client_session_by_mac where macAddressString like '%A1%' and locationId in (2);
select macAddress from client_session_by_mac where macAddressString like '%A1%' and locationId in (1,2);
select macAddress from client_session_by_mac_and_equipment where macAddressString like '%A1%' and equipmentId in (2);
select macAddress from client_session_by_mac_and_equipment where macAddressString like '%A1%' and equipmentId in (1,3);
delete from client_session_by_mac where locationId = 1 and equipmentId = 1 and macAddressString = 'A1:1';
delete from client_session_by_mac_and_equipment where locationId = 1 and equipmentId = 1 and macAddressString = 'A1:1';
--------------------------------------------------------------------------------
-- Commands to clean up after the test
--------------------------------------------------------------------------------
TRUNCATE TABLE client_session_by_location ;
TRUNCATE TABLE client_session_by_equipment ;
TRUNCATE TABLE client_session_by_location;
TRUNCATE TABLE client_session_by_equipment;
TRUNCATE TABLE client_session_by_mac;
TRUNCATE TABLE client_session_by_mac_and_equipment;
TRUNCATE TABLE client_session;
TRUNCATE TABLE client_by_mac_string;
TRUNCATE TABLE client;

View File

@@ -0,0 +1 @@
/target/

View File

@@ -1,10 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
@@ -16,7 +15,7 @@
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>client-datastore-interface</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>

View File

@@ -158,214 +158,6 @@ public abstract class BaseClientDatastoreTest {
}
@Test
public void testSearchByMacAddress() {
//create 100 Clients
Client mdl;
int customerId_1 = (int) testSequence.incrementAndGet();
List<Client> created_models = new ArrayList<>();
int apNameIdx = 0;
for(int i = 0; i< 50; i++){
mdl = new Client();
mdl.setCustomerId(customerId_1);
ClientInfoDetails details = new ClientInfoDetails();
details.setAlias("qr_"+apNameIdx);
mdl.setDetails(details);
mdl.setMacAddress(new MacAddress("A1:FF:FF:FF:FF:" + Integer.toHexString(i)));
apNameIdx++;
mdl = testInterface.create(mdl);
created_models.add(mdl);
}
for(int i = 0; i< 50; i++){
mdl = new Client();
mdl.setCustomerId(customerId_1);
ClientInfoDetails details = new ClientInfoDetails();
details.setAlias("cr_"+apNameIdx);
mdl.setDetails(details );
mdl.setMacAddress(new MacAddress("B1:FF:FF:FF:FF:" + Integer.toHexString(i)));
apNameIdx++;
mdl = testInterface.create(mdl);
created_models.add(mdl);
}
//paginate over Clients
List<ColumnAndSort> sortBy = new ArrayList<>();
sortBy.addAll(Arrays.asList(new ColumnAndSort("macAddress")));
PaginationContext<Client> context = new PaginationContext<>(10);
PaginationResponse<Client> page1 = testInterface.searchByMacAddress(customerId_1, "A1", sortBy, context);
PaginationResponse<Client> page2 = testInterface.searchByMacAddress(customerId_1, "A1", sortBy, page1.getContext());
PaginationResponse<Client> page3 = testInterface.searchByMacAddress(customerId_1, "A1", sortBy, page2.getContext());
PaginationResponse<Client> page4 = testInterface.searchByMacAddress(customerId_1, "A1", sortBy, page3.getContext());
PaginationResponse<Client> page5 = testInterface.searchByMacAddress(customerId_1, "A1", sortBy, page4.getContext());
PaginationResponse<Client> page6 = testInterface.searchByMacAddress(customerId_1, "A1", sortBy, page5.getContext());
PaginationResponse<Client> page7 = testInterface.searchByMacAddress(customerId_1, "A1", sortBy, page6.getContext());
//verify returned pages
assertEquals(10, page1.getItems().size());
assertEquals(10, page2.getItems().size());
assertEquals(10, page3.getItems().size());
assertEquals(10, page4.getItems().size());
assertEquals(10, page5.getItems().size());
page1.getItems().forEach(e -> assertEquals(customerId_1, e.getCustomerId()) );
page2.getItems().forEach(e -> assertEquals(customerId_1, e.getCustomerId()) );
page3.getItems().forEach(e -> assertEquals(customerId_1, e.getCustomerId()) );
page4.getItems().forEach(e -> assertEquals(customerId_1, e.getCustomerId()) );
page5.getItems().forEach(e -> assertEquals(customerId_1, e.getCustomerId()) );
assertEquals(0, page6.getItems().size());
assertEquals(0, page7.getItems().size());
assertFalse(page1.getContext().isLastPage());
assertFalse(page2.getContext().isLastPage());
assertFalse(page3.getContext().isLastPage());
assertFalse(page4.getContext().isLastPage());
assertFalse(page5.getContext().isLastPage());
assertTrue(page6.getContext().isLastPage());
assertTrue(page7.getContext().isLastPage());
List<String> expectedPage3Strings = new ArrayList<>(Arrays.asList(new String[]{"qr_20", "qr_21", "qr_22", "qr_23", "qr_24", "qr_25", "qr_26", "qr_27", "qr_28", "qr_29" }));
List<String> actualPage3Strings = new ArrayList<>();
page3.getItems().stream().forEach( ce -> actualPage3Strings.add(((ClientInfoDetails)ce.getDetails()).getAlias()) );
assertEquals(expectedPage3Strings, actualPage3Strings);
//test first page of the results with empty sort order -> default sort order (by Id ascending)
PaginationResponse<Client> page1EmptySort = testInterface.searchByMacAddress(customerId_1, "A1", Collections.emptyList(), context);
assertEquals(10, page1EmptySort.getItems().size());
List<String> expectedPage1EmptySortStrings = new ArrayList<>(Arrays.asList(new String[]{"qr_0", "qr_1", "qr_2", "qr_3", "qr_4", "qr_5", "qr_6", "qr_7", "qr_8", "qr_9" }));
List<String> actualPage1EmptySortStrings = new ArrayList<>();
page1EmptySort.getItems().stream().forEach( ce -> actualPage1EmptySortStrings.add(((ClientInfoDetails)ce.getDetails()).getAlias()) );
assertEquals(expectedPage1EmptySortStrings, actualPage1EmptySortStrings);
//test first page of the results with null sort order -> default sort order (by Id ascending)
PaginationResponse<Client> page1NullSort = testInterface.searchByMacAddress(customerId_1, "A1", null, context);
assertEquals(10, page1NullSort.getItems().size());
List<String> expectedPage1NullSortStrings = new ArrayList<>(Arrays.asList(new String[]{"qr_0", "qr_1", "qr_2", "qr_3", "qr_4", "qr_5", "qr_6", "qr_7", "qr_8", "qr_9" }));
List<String> actualPage1NullSortStrings = new ArrayList<>();
page1NullSort.getItems().stream().forEach( ce -> actualPage1NullSortStrings.add(((ClientInfoDetails)ce.getDetails()).getAlias()) );
assertEquals(expectedPage1NullSortStrings, actualPage1NullSortStrings);
//test first page of the results with sort descending order by a macAddress property
PaginationResponse<Client> page1SingleSortDesc = testInterface.searchByMacAddress(customerId_1, "A1", Collections.singletonList(new ColumnAndSort("macAddress", SortOrder.desc)), context);
assertEquals(10, page1SingleSortDesc.getItems().size());
List<String> expectedPage1SingleSortDescStrings = getSearchByMac_ExpectedPage1SingleSortDescStrings();
List<String> actualPage1SingleSortDescStrings = new ArrayList<>();
page1SingleSortDesc.getItems().stream().forEach( ce -> actualPage1SingleSortDescStrings.add(((ClientInfoDetails)ce.getDetails()).getAlias()) );
assertEquals(expectedPage1SingleSortDescStrings, actualPage1SingleSortDescStrings);
created_models.forEach(m -> testInterface.delete(m.getCustomerId(), m.getMacAddress()));
}
/**
* This method is overridden in the cassandra datastore because cassandra does not handle sort order
*/
protected List<String> getSearchByMac_ExpectedPage1SingleSortDescStrings(){
return new ArrayList<>(Arrays.asList(new String[]{"qr_49", "qr_48", "qr_47", "qr_46", "qr_45", "qr_44", "qr_43", "qr_42", "qr_41", "qr_40" }));
}
@Test
public void testEmptyNullSearchMacSubstring() {
Client mdl;
int customerId = (int) testSequence.incrementAndGet();
int apNameIdx = 0;
List<Client> created_models = new ArrayList<>();
for(int i = 0; i< 50; i++){
mdl = new Client();
mdl.setCustomerId(customerId);
ClientInfoDetails details = new ClientInfoDetails();
details.setAlias("qr_"+apNameIdx);
mdl.setDetails(details);
mdl.setMacAddress(new MacAddress("A1:FF:FF:FF:FF:" + Integer.toHexString(i)));
apNameIdx++;
mdl = testInterface.create(mdl);
created_models.add(mdl);
}
for(int i = 0; i< 50; i++){
mdl = new Client();
mdl.setCustomerId(customerId);
ClientInfoDetails details = new ClientInfoDetails();
details.setAlias("cr_"+apNameIdx);
mdl.setDetails(details );
mdl.setMacAddress(new MacAddress("B1:FF:FF:FF:FF:" + Integer.toHexString(i)));
apNameIdx++;
mdl = testInterface.create(mdl);
created_models.add(mdl);
}
List<ColumnAndSort> sortBy = new ArrayList<>();
PaginationContext<Client> context = new PaginationContext<>(10);
//test null and empty string macSubstring inputs, expecting to get all results
PaginationResponse<Client> emptySubstringPage1 = testInterface.searchByMacAddress(customerId, "", sortBy, context);
PaginationResponse<Client> emptySubstringPage2 = testInterface.searchByMacAddress(customerId, "", sortBy, emptySubstringPage1.getContext());
PaginationResponse<Client> emptySubstringPage3 = testInterface.searchByMacAddress(customerId, "", sortBy, emptySubstringPage2.getContext());
PaginationResponse<Client> emptySubstringPage4 = testInterface.searchByMacAddress(customerId, "", sortBy, emptySubstringPage3.getContext());
PaginationResponse<Client> emptySubstringPage5 = testInterface.searchByMacAddress(customerId, "", sortBy, emptySubstringPage4.getContext());
PaginationResponse<Client> emptySubstringPage6 = testInterface.searchByMacAddress(customerId, "", sortBy, emptySubstringPage5.getContext());
PaginationResponse<Client> emptySubstringPage7 = testInterface.searchByMacAddress(customerId, "", sortBy, emptySubstringPage6.getContext());
PaginationResponse<Client> emptySubstringPage8 = testInterface.searchByMacAddress(customerId, "", sortBy, emptySubstringPage7.getContext());
PaginationResponse<Client> emptySubstringPage9 = testInterface.searchByMacAddress(customerId, "", sortBy, emptySubstringPage8.getContext());
PaginationResponse<Client> emptySubstringPage10 = testInterface.searchByMacAddress(customerId, "", sortBy, emptySubstringPage9.getContext());
PaginationResponse<Client> emptySubstringPage11 = testInterface.searchByMacAddress(customerId, "", sortBy, emptySubstringPage10.getContext());
assertEquals(10, emptySubstringPage1.getItems().size());
assertEquals(10, emptySubstringPage2.getItems().size());
assertEquals(10, emptySubstringPage3.getItems().size());
assertEquals(10, emptySubstringPage4.getItems().size());
assertEquals(10, emptySubstringPage5.getItems().size());
assertEquals(10, emptySubstringPage6.getItems().size());
assertEquals(10, emptySubstringPage7.getItems().size());
assertEquals(10, emptySubstringPage8.getItems().size());
assertEquals(10, emptySubstringPage9.getItems().size());
assertEquals(10, emptySubstringPage10.getItems().size());
assertEquals(0, emptySubstringPage11.getItems().size());
PaginationResponse<Client> nullSubstringPage1 = testInterface.searchByMacAddress(customerId, null, sortBy, context);
PaginationResponse<Client> nullSubstringPage2 = testInterface.searchByMacAddress(customerId, null, sortBy, nullSubstringPage1.getContext());
PaginationResponse<Client> nullSubstringPage3 = testInterface.searchByMacAddress(customerId, null, sortBy, nullSubstringPage2.getContext());
PaginationResponse<Client> nullSubstringPage4 = testInterface.searchByMacAddress(customerId, null, sortBy, nullSubstringPage3.getContext());
PaginationResponse<Client> nullSubstringPage5 = testInterface.searchByMacAddress(customerId, null, sortBy, nullSubstringPage4.getContext());
PaginationResponse<Client> nullSubstringPage6 = testInterface.searchByMacAddress(customerId, null, sortBy, nullSubstringPage5.getContext());
PaginationResponse<Client> nullSubstringPage7 = testInterface.searchByMacAddress(customerId, null, sortBy, nullSubstringPage6.getContext());
PaginationResponse<Client> nullSubstringPage8 = testInterface.searchByMacAddress(customerId, null, sortBy, nullSubstringPage7.getContext());
PaginationResponse<Client> nullSubstringPage9 = testInterface.searchByMacAddress(customerId, null, sortBy, nullSubstringPage8.getContext());
PaginationResponse<Client> nullSubstringPage10 = testInterface.searchByMacAddress(customerId, null, sortBy, nullSubstringPage9.getContext());
PaginationResponse<Client> nullSubstringPage11 = testInterface.searchByMacAddress(customerId, null, sortBy, nullSubstringPage10.getContext());
assertEquals(10, nullSubstringPage1.getItems().size());
assertEquals(10, nullSubstringPage2.getItems().size());
assertEquals(10, nullSubstringPage3.getItems().size());
assertEquals(10, nullSubstringPage4.getItems().size());
assertEquals(10, nullSubstringPage5.getItems().size());
assertEquals(10, nullSubstringPage6.getItems().size());
assertEquals(10, nullSubstringPage7.getItems().size());
assertEquals(10, nullSubstringPage8.getItems().size());
assertEquals(10, nullSubstringPage9.getItems().size());
assertEquals(10, nullSubstringPage10.getItems().size());
assertEquals(0, nullSubstringPage11.getItems().size());
created_models.forEach(m -> testInterface.delete(m.getCustomerId(), m.getMacAddress()));
}
@Test
public void testClientPagination()
{
@@ -383,8 +175,12 @@ public abstract class BaseClientDatastoreTest {
mdl.setCustomerId(customerId_1);
ClientInfoDetails details = new ClientInfoDetails();
details.setAlias("qr_"+apNameIdx);
mdl.setDetails(details );
mdl.setMacAddress(new MacAddress((long)i));
mdl.setDetails(details);
if (i < 20) {
mdl.setMacAddress(new MacAddress("A1:FF:FF:FF:FF:" + Integer.toHexString(i)));
} else {
mdl.setMacAddress(new MacAddress("B1:FF:FF:FF:FF:" + Integer.toHexString(i)));
}
apNameIdx++;
mdl = testInterface.create(mdl);
@@ -396,8 +192,8 @@ public abstract class BaseClientDatastoreTest {
mdl.setCustomerId(customerId_2);
ClientInfoDetails details = new ClientInfoDetails();
details.setAlias("qr_"+apNameIdx);
mdl.setDetails(details );
mdl.setMacAddress(new MacAddress((long)i));
mdl.setDetails(details);
mdl.setMacAddress(new MacAddress("B1:FF:FF:FF:FF:" + Integer.toHexString(i)));
apNameIdx++;
mdl = testInterface.create(mdl);
@@ -410,13 +206,13 @@ public abstract class BaseClientDatastoreTest {
sortBy.addAll(Arrays.asList(new ColumnAndSort("macAddress")));
PaginationContext<Client> context = new PaginationContext<>(10);
PaginationResponse<Client> page1 = testInterface.getForCustomer(customerId_1, sortBy, context);
PaginationResponse<Client> page2 = testInterface.getForCustomer(customerId_1, sortBy, page1.getContext());
PaginationResponse<Client> page3 = testInterface.getForCustomer(customerId_1, sortBy, page2.getContext());
PaginationResponse<Client> page4 = testInterface.getForCustomer(customerId_1, sortBy, page3.getContext());
PaginationResponse<Client> page5 = testInterface.getForCustomer(customerId_1, sortBy, page4.getContext());
PaginationResponse<Client> page6 = testInterface.getForCustomer(customerId_1, sortBy, page5.getContext());
PaginationResponse<Client> page7 = testInterface.getForCustomer(customerId_1, sortBy, page6.getContext());
PaginationResponse<Client> page1 = testInterface.getForCustomer(customerId_1, null, sortBy, context);
PaginationResponse<Client> page2 = testInterface.getForCustomer(customerId_1, null, sortBy, page1.getContext());
PaginationResponse<Client> page3 = testInterface.getForCustomer(customerId_1, null, sortBy, page2.getContext());
PaginationResponse<Client> page4 = testInterface.getForCustomer(customerId_1, null, sortBy, page3.getContext());
PaginationResponse<Client> page5 = testInterface.getForCustomer(customerId_1, null, sortBy, page4.getContext());
PaginationResponse<Client> page6 = testInterface.getForCustomer(customerId_1, null, sortBy, page5.getContext());
PaginationResponse<Client> page7 = testInterface.getForCustomer(customerId_1, null, sortBy, page6.getContext());
//verify returned pages
assertEquals(10, page1.getItems().size());
@@ -448,10 +244,47 @@ public abstract class BaseClientDatastoreTest {
page3.getItems().stream().forEach( ce -> actualPage3Strings.add(((ClientInfoDetails)ce.getDetails()).getAlias()) );
assertEquals(expectedPage3Strings, actualPage3Strings);
// empty and null substring should return the same result
PaginationResponse<Client> page1EmptySubstring = testInterface.getForCustomer(customerId_1, "", sortBy, context);
PaginationResponse<Client> page2EmptySubstring = testInterface.getForCustomer(customerId_1, "", sortBy, page1EmptySubstring.getContext());
PaginationResponse<Client> page3EmptySubstring = testInterface.getForCustomer(customerId_1, "", sortBy, page2EmptySubstring.getContext());
PaginationResponse<Client> page4EmptySubstring = testInterface.getForCustomer(customerId_1, "", sortBy, page3EmptySubstring.getContext());
PaginationResponse<Client> page5EmptySubstring = testInterface.getForCustomer(customerId_1, "", sortBy, page4EmptySubstring.getContext());
//verify returned pages
assertEquals(10, page1EmptySubstring.getItems().size());
assertEquals(10, page2EmptySubstring.getItems().size());
assertEquals(10, page3EmptySubstring.getItems().size());
assertEquals(10, page4EmptySubstring.getItems().size());
assertEquals(10, page5EmptySubstring.getItems().size());
assertEquals(page1.getItems(), page1EmptySubstring.getItems());
assertEquals(page2.getItems(), page2EmptySubstring.getItems());
assertEquals(page3.getItems(), page3EmptySubstring.getItems());
assertEquals(page4.getItems(), page4EmptySubstring.getItems());
assertEquals(page5.getItems(), page5EmptySubstring.getItems());
// Test macAddress search
PaginationResponse<Client> page1SearchMac = testInterface.getForCustomer(customerId_1, "A1", sortBy, context);
PaginationResponse<Client> page2SearchMac = testInterface.getForCustomer(customerId_1, "A1", sortBy, page1SearchMac.getContext());
PaginationResponse<Client> page3SearchMac = testInterface.getForCustomer(customerId_1, "A1", sortBy, page2SearchMac.getContext());
//verify returned pages
assertEquals(10, page1SearchMac.getItems().size());
assertEquals(10, page2SearchMac.getItems().size());
assertEquals(0, page3SearchMac.getItems().size());
page1SearchMac.getItems().forEach(e -> assertEquals(customerId_1, e.getCustomerId()));
page2SearchMac.getItems().forEach(e -> assertEquals(customerId_1, e.getCustomerId()));
page1SearchMac.getItems().forEach(e -> assertTrue(e.getMacAddress().getAddressAsString().contains("A1".toLowerCase())));
page2SearchMac.getItems().forEach(e -> assertTrue(e.getMacAddress().getAddressAsString().contains("A1".toLowerCase())));
assertTrue(page3SearchMac.getContext().isLastPage());
//test first page of the results with empty sort order -> default sort order (by Id ascending)
PaginationResponse<Client> page1EmptySort = testInterface.getForCustomer(customerId_1, Collections.emptyList(), context);
PaginationResponse<Client> page1EmptySort = testInterface.getForCustomer(customerId_1, null, Collections.emptyList(), context);
assertEquals(10, page1EmptySort.getItems().size());
List<String> expectedPage1EmptySortStrings = getClientPagination_ExpectedPage1EmptySortStrings();
@@ -461,7 +294,7 @@ public abstract class BaseClientDatastoreTest {
assertEquals(expectedPage1EmptySortStrings, actualPage1EmptySortStrings);
//test first page of the results with null sort order -> default sort order (by Id ascending)
PaginationResponse<Client> page1NullSort = testInterface.getForCustomer(customerId_1, null, context);
PaginationResponse<Client> page1NullSort = testInterface.getForCustomer(customerId_1, null, null, context);
assertEquals(10, page1NullSort.getItems().size());
List<String> expectedPage1NullSortStrings = new ArrayList<>(expectedPage1EmptySortStrings);
@@ -472,7 +305,7 @@ public abstract class BaseClientDatastoreTest {
//test first page of the results with sort descending order by a macAddress property
PaginationResponse<Client> page1SingleSortDesc = testInterface.getForCustomer(customerId_1, Collections.singletonList(new ColumnAndSort("macAddress", SortOrder.desc)), context);
PaginationResponse<Client> page1SingleSortDesc = testInterface.getForCustomer(customerId_1, null, Collections.singletonList(new ColumnAndSort("macAddress", SortOrder.desc)), context);
assertEquals(10, page1SingleSortDesc.getItems().size());
List<String> expectedPage1SingleSortDescStrings = getClientPagination_ExpectedPage1SingleSortDescStrings();
@@ -787,17 +620,19 @@ public abstract class BaseClientDatastoreTest {
if(i<10) {
mdl.setEquipmentId(equipmentId_1);
mdl.setLocationId(locationId_1);
mdl.setMacAddress(new MacAddress("A1:FF:FF:FF:FF:" + Integer.toHexString(i)));
} else if(i<20) {
mdl.setEquipmentId(equipmentId_2);
mdl.setLocationId(locationId_2);
mdl.setMacAddress(new MacAddress("A1:FF:FF:FF:FF:" + Integer.toHexString(i)));
} else {
mdl.setEquipmentId(testSequence.incrementAndGet());
mdl.setMacAddress(new MacAddress("B1:FF:FF:FF:FF:" + Integer.toHexString(i)));
}
ClientSessionDetails details = new ClientSessionDetails();
details.setApFingerprint("qr_"+apNameIdx);
mdl.setDetails(details );
mdl.setMacAddress(new MacAddress((long)i));
apNameIdx++;
@@ -836,13 +671,13 @@ public abstract class BaseClientDatastoreTest {
sortBy.addAll(Arrays.asList(new ColumnAndSort("macAddress")));
PaginationContext<ClientSession> context = new PaginationContext<>(10);
PaginationResponse<ClientSession> page1 = testInterface.getSessionsForCustomer(customerId_1, null, null, sortBy, context);
PaginationResponse<ClientSession> page2 = testInterface.getSessionsForCustomer(customerId_1, null, null, sortBy, page1.getContext());
PaginationResponse<ClientSession> page3 = testInterface.getSessionsForCustomer(customerId_1, null, null, sortBy, page2.getContext());
PaginationResponse<ClientSession> page4 = testInterface.getSessionsForCustomer(customerId_1, null, null, sortBy, page3.getContext());
PaginationResponse<ClientSession> page5 = testInterface.getSessionsForCustomer(customerId_1, null, null, sortBy, page4.getContext());
PaginationResponse<ClientSession> page6 = testInterface.getSessionsForCustomer(customerId_1, null, null, sortBy, page5.getContext());
PaginationResponse<ClientSession> page7 = testInterface.getSessionsForCustomer(customerId_1, null, null, sortBy, page6.getContext());
PaginationResponse<ClientSession> page1 = testInterface.getSessionsForCustomer(customerId_1, null, null, null, sortBy, context);
PaginationResponse<ClientSession> page2 = testInterface.getSessionsForCustomer(customerId_1, null, null, null, sortBy, page1.getContext());
PaginationResponse<ClientSession> page3 = testInterface.getSessionsForCustomer(customerId_1, null, null, null, sortBy, page2.getContext());
PaginationResponse<ClientSession> page4 = testInterface.getSessionsForCustomer(customerId_1, null, null, null, sortBy, page3.getContext());
PaginationResponse<ClientSession> page5 = testInterface.getSessionsForCustomer(customerId_1, null, null, null, sortBy, page4.getContext());
PaginationResponse<ClientSession> page6 = testInterface.getSessionsForCustomer(customerId_1, null, null, null, sortBy, page5.getContext());
PaginationResponse<ClientSession> page7 = testInterface.getSessionsForCustomer(customerId_1, null, null, null, sortBy, page6.getContext());
//verify returned pages
assertEquals(10, page1.getItems().size());
@@ -868,6 +703,26 @@ public abstract class BaseClientDatastoreTest {
assertTrue(page6.getContext().isLastPage());
assertTrue(page7.getContext().isLastPage());
// when remote interface receives macSubstring = null, it will pass on macSubstring = "" instead.
PaginationResponse<ClientSession> page1EmptySubstring = testInterface.getSessionsForCustomer(customerId_1, null, null, "", sortBy, context);
PaginationResponse<ClientSession> page2EmptySubstring = testInterface.getSessionsForCustomer(customerId_1, null, null, "", sortBy, page1.getContext());
PaginationResponse<ClientSession> page3EmptySubstring = testInterface.getSessionsForCustomer(customerId_1, null, null, "", sortBy, page2.getContext());
PaginationResponse<ClientSession> page4EmptySubstring = testInterface.getSessionsForCustomer(customerId_1, null, null, "", sortBy, page3.getContext());
PaginationResponse<ClientSession> page5EmptySubstring = testInterface.getSessionsForCustomer(customerId_1, null, null, "", sortBy, page4.getContext());
//verify returned pages
assertEquals(10, page1EmptySubstring.getItems().size());
assertEquals(10, page2EmptySubstring.getItems().size());
assertEquals(10, page3EmptySubstring.getItems().size());
assertEquals(10, page4EmptySubstring.getItems().size());
assertEquals(10, page5EmptySubstring.getItems().size());
assertEquals(page1.getItems(), page1EmptySubstring.getItems());
assertEquals(page2.getItems(), page2EmptySubstring.getItems());
assertEquals(page3.getItems(), page3EmptySubstring.getItems());
assertEquals(page4.getItems(), page4EmptySubstring.getItems());
assertEquals(page5.getItems(), page5EmptySubstring.getItems());
Set<String> expectedAllPagesStrings = new HashSet<>();
for(int i=0; i<50; i++) {
@@ -888,10 +743,62 @@ public abstract class BaseClientDatastoreTest {
page3.getItems().stream().forEach( ce -> actualPage3Strings.add(((ClientSessionDetails)ce.getDetails()).getApFingerprint()) );
assertEquals(expectedPage3Strings, actualPage3Strings);
// Test macAddress search
PaginationResponse<ClientSession> page1SearchMac = testInterface.getSessionsForCustomer(customerId_1, null, null, "A1", sortBy, context);
PaginationResponse<ClientSession> page2SearchMac = testInterface.getSessionsForCustomer(customerId_1, null, null, "A1", sortBy, page1SearchMac.getContext());
PaginationResponse<ClientSession> page3SearchMac = testInterface.getSessionsForCustomer(customerId_1, null, null, "A1", sortBy, page2SearchMac.getContext());
//verify returned pages
assertEquals(10, page1SearchMac.getItems().size());
assertEquals(10, page2SearchMac.getItems().size());
assertEquals(0, page3SearchMac.getItems().size());
page1SearchMac.getItems().forEach(e -> assertTrue(e.getMacAddress().getAddressAsString().contains("A1".toLowerCase())));
page2SearchMac.getItems().forEach(e -> assertTrue(e.getMacAddress().getAddressAsString().contains("A1".toLowerCase())));
// Test macAddress search with locationId
Set<Long> locationSearchSet = new HashSet<Long>(Arrays.asList(locationId_1));
PaginationResponse<ClientSession> page1SearchMacAndLocation = testInterface.getSessionsForCustomer(customerId_1, null, locationSearchSet, "A1", sortBy, context);
PaginationResponse<ClientSession> page2SearchMacAndLocation = testInterface.getSessionsForCustomer(customerId_1, null, locationSearchSet, "A1", sortBy, page1SearchMacAndLocation.getContext());
PaginationResponse<ClientSession> page3SearchMacAndLocation = testInterface.getSessionsForCustomer(customerId_1, null, locationSearchSet, "A1", sortBy, page2SearchMacAndLocation.getContext());
//verify returned pages
assertEquals(10, page1SearchMacAndLocation.getItems().size());
assertEquals(0, page2SearchMacAndLocation.getItems().size());
assertEquals(0, page3SearchMacAndLocation.getItems().size());
page1SearchMacAndLocation.getItems().forEach(e -> assertTrue(e.getMacAddress().getAddressAsString().contains("A1".toLowerCase())));
page1SearchMacAndLocation.getItems().forEach(e -> assertEquals(locationId_1, e.getLocationId()));
// Test macAddress search with equipmentId
Set<Long> equipmentSearchSet = new HashSet<Long>(Arrays.asList(equipmentId_1, equipmentId_2));
PaginationResponse<ClientSession> page1SearchMacAndEquipment = testInterface.getSessionsForCustomer(customerId_1, equipmentSearchSet, null, "A1", sortBy, context);
PaginationResponse<ClientSession> page2SearchMacAndEquipment = testInterface.getSessionsForCustomer(customerId_1, equipmentSearchSet, null, "A1", sortBy, page1SearchMacAndEquipment.getContext());
PaginationResponse<ClientSession> page3SearchMacAndEquipment = testInterface.getSessionsForCustomer(customerId_1, equipmentSearchSet, null, "A1", sortBy, page2SearchMacAndEquipment.getContext());
//verify returned pages
assertEquals(10, page1SearchMacAndEquipment.getItems().size());
assertEquals(10, page2SearchMacAndEquipment.getItems().size());
assertEquals(0, page3SearchMacAndEquipment.getItems().size());
page1SearchMacAndEquipment.getItems().forEach(e -> assertTrue(e.getMacAddress().getAddressAsString().contains("A1".toLowerCase())));
page1SearchMacAndEquipment.getItems().forEach(e -> assertTrue(equipmentSearchSet.contains(e.getEquipmentId())));
// Test macAddress search with equipmentId and locationId
PaginationResponse<ClientSession> page1SearchMacAndEquipmentAndLocation = testInterface.getSessionsForCustomer(customerId_1, equipmentSearchSet, locationSearchSet, "A1", sortBy, context);
PaginationResponse<ClientSession> page2SearchMacAndEquipmentAndLocation = testInterface.getSessionsForCustomer(customerId_1, equipmentSearchSet, locationSearchSet, "A1", sortBy, page1SearchMacAndEquipmentAndLocation.getContext());
PaginationResponse<ClientSession> page3SearchMacAndEquipmentAndLocation = testInterface.getSessionsForCustomer(customerId_1, equipmentSearchSet, locationSearchSet, "A1", sortBy, page2SearchMacAndEquipmentAndLocation.getContext());
//verify returned pages
assertEquals(10, page1SearchMacAndEquipmentAndLocation.getItems().size());
assertEquals(0, page2SearchMacAndEquipmentAndLocation.getItems().size());
assertEquals(0, page3SearchMacAndEquipmentAndLocation.getItems().size());
page1SearchMacAndEquipmentAndLocation.getItems().forEach(e -> assertTrue(e.getMacAddress().getAddressAsString().contains("A1".toLowerCase())));
page1SearchMacAndEquipmentAndLocation.getItems().forEach(e -> assertEquals(equipmentId_1, e.getEquipmentId()));
page1SearchMacAndEquipmentAndLocation.getItems().forEach(e -> assertEquals(locationId_1, e.getLocationId()));
//test first page of the results with empty sort order -> default sort order (by Id ascending)
PaginationResponse<ClientSession> page1EmptySort = testInterface.getSessionsForCustomer(customerId_1, null, null, Collections.emptyList(), context);
PaginationResponse<ClientSession> page1EmptySort = testInterface.getSessionsForCustomer(customerId_1, null, null, null, Collections.emptyList(), context);
assertEquals(10, page1EmptySort.getItems().size());
List<String> expectedPage1EmptySortStrings = getClientSessionPagination_expectedPage1EmptySortStrings();
@@ -901,7 +808,7 @@ public abstract class BaseClientDatastoreTest {
assertEquals(expectedPage1EmptySortStrings, actualPage1EmptySortStrings);
//test first page of the results with null sort order -> default sort order (by Id ascending)
PaginationResponse<ClientSession> page1NullSort = testInterface.getSessionsForCustomer(customerId_1, null, null, null, context);
PaginationResponse<ClientSession> page1NullSort = testInterface.getSessionsForCustomer(customerId_1, null, null, null, null, context);
assertEquals(10, page1NullSort.getItems().size());
List<String> expectedPage1NullSortStrings = getClientSessionPagination_expectedPage1EmptySortStrings();
@@ -912,7 +819,7 @@ public abstract class BaseClientDatastoreTest {
//test first page of the results with sort descending order by a macAddress property
PaginationResponse<ClientSession> page1SingleSortDesc = testInterface.getSessionsForCustomer(customerId_1, null, null, Collections.singletonList(new ColumnAndSort("macAddress", SortOrder.desc)), context);
PaginationResponse<ClientSession> page1SingleSortDesc = testInterface.getSessionsForCustomer(customerId_1, null, null, null, Collections.singletonList(new ColumnAndSort("macAddress", SortOrder.desc)), context);
assertEquals(10, page1SingleSortDesc.getItems().size());
List<String> expectedPage1SingleSortDescStrings = getClientSessionPagination_expectedPage1SingleSortDescStrings();
@@ -922,8 +829,8 @@ public abstract class BaseClientDatastoreTest {
assertEquals(expectedPage1SingleSortDescStrings, actualPage1SingleSortDescStrings);
//test the results for equipment_1 only
PaginationResponse<ClientSession> page1Eq_1 = testInterface.getSessionsForCustomer(customerId_1, new HashSet<Long>(Arrays.asList(equipmentId_1)), null, Collections.emptyList(), context);
PaginationResponse<ClientSession> page2Eq_1 = testInterface.getSessionsForCustomer(customerId_1, new HashSet<Long>(Arrays.asList(equipmentId_1)), null, Collections.emptyList(), page1Eq_1.getContext());
PaginationResponse<ClientSession> page1Eq_1 = testInterface.getSessionsForCustomer(customerId_1, new HashSet<Long>(Arrays.asList(equipmentId_1)), null, null, Collections.emptyList(), context);
PaginationResponse<ClientSession> page2Eq_1 = testInterface.getSessionsForCustomer(customerId_1, new HashSet<Long>(Arrays.asList(equipmentId_1)), null, null, Collections.emptyList(), page1Eq_1.getContext());
assertEquals(10, page1Eq_1.getItems().size());
assertEquals(0, page2Eq_1.getItems().size());
@@ -937,8 +844,8 @@ public abstract class BaseClientDatastoreTest {
assertEquals(expectedPage1Eq_1Strings, actualPage1Eq_1Strings);
//test the results for equipment_2 only
PaginationResponse<ClientSession> page1Eq_2 = testInterface.getSessionsForCustomer(customerId_1, new HashSet<Long>(Arrays.asList(equipmentId_2)), null, Collections.emptyList(), context);
PaginationResponse<ClientSession> page2Eq_2 = testInterface.getSessionsForCustomer(customerId_1, new HashSet<Long>(Arrays.asList(equipmentId_2)), null, Collections.emptyList(), page1Eq_2.getContext());
PaginationResponse<ClientSession> page1Eq_2 = testInterface.getSessionsForCustomer(customerId_1, new HashSet<Long>(Arrays.asList(equipmentId_2)), null, null, Collections.emptyList(), context);
PaginationResponse<ClientSession> page2Eq_2 = testInterface.getSessionsForCustomer(customerId_1, new HashSet<Long>(Arrays.asList(equipmentId_2)), null, null, Collections.emptyList(), page1Eq_2.getContext());
assertEquals(10, page1Eq_2.getItems().size());
assertEquals(0, page2Eq_2.getItems().size());
@@ -953,9 +860,9 @@ public abstract class BaseClientDatastoreTest {
//test the results for equipment_1 or equipment_2 only
PaginationResponse<ClientSession> page1Eq_1or2 = testInterface.getSessionsForCustomer(customerId_1, new HashSet<Long>(Arrays.asList(equipmentId_1, equipmentId_2)), null, Collections.emptyList(), context);
PaginationResponse<ClientSession> page2Eq_1or2 = testInterface.getSessionsForCustomer(customerId_1, new HashSet<Long>(Arrays.asList(equipmentId_1, equipmentId_2)), null, Collections.emptyList(), page1Eq_1or2.getContext());
PaginationResponse<ClientSession> page3Eq_1or2 = testInterface.getSessionsForCustomer(customerId_1, new HashSet<Long>(Arrays.asList(equipmentId_1, equipmentId_2)), null, Collections.emptyList(), page2Eq_1or2.getContext());
PaginationResponse<ClientSession> page1Eq_1or2 = testInterface.getSessionsForCustomer(customerId_1, new HashSet<Long>(Arrays.asList(equipmentId_1, equipmentId_2)), null, null, Collections.emptyList(), context);
PaginationResponse<ClientSession> page2Eq_1or2 = testInterface.getSessionsForCustomer(customerId_1, new HashSet<Long>(Arrays.asList(equipmentId_1, equipmentId_2)), null, null, Collections.emptyList(), page1Eq_1or2.getContext());
PaginationResponse<ClientSession> page3Eq_1or2 = testInterface.getSessionsForCustomer(customerId_1, new HashSet<Long>(Arrays.asList(equipmentId_1, equipmentId_2)), null, null, Collections.emptyList(), page2Eq_1or2.getContext());
assertEquals(10, page1Eq_1or2.getItems().size());
assertEquals(10, page2Eq_1or2.getItems().size());
@@ -981,8 +888,8 @@ public abstract class BaseClientDatastoreTest {
//
//test the results for location_1 only
page1Eq_1 = testInterface.getSessionsForCustomer(customerId_1, null, new HashSet<Long>(Arrays.asList(locationId_1)), Collections.emptyList(), context);
page2Eq_1 = testInterface.getSessionsForCustomer(customerId_1, null, new HashSet<Long>(Arrays.asList(locationId_1)), Collections.emptyList(), page1Eq_1.getContext());
page1Eq_1 = testInterface.getSessionsForCustomer(customerId_1, null, new HashSet<Long>(Arrays.asList(locationId_1)), null, Collections.emptyList(), context);
page2Eq_1 = testInterface.getSessionsForCustomer(customerId_1, null, new HashSet<Long>(Arrays.asList(locationId_1)), null, Collections.emptyList(), page1Eq_1.getContext());
assertEquals(10, page1Eq_1.getItems().size());
assertEquals(0, page2Eq_1.getItems().size());
@@ -996,8 +903,8 @@ public abstract class BaseClientDatastoreTest {
assertEquals(expectedPage1Eq_1Strings, actualPage1Loc_1Strings);
//test the results for location_2 only
page1Eq_2 = testInterface.getSessionsForCustomer(customerId_1, null, new HashSet<Long>(Arrays.asList(locationId_2)), Collections.emptyList(), context);
page2Eq_2 = testInterface.getSessionsForCustomer(customerId_1, null, new HashSet<Long>(Arrays.asList(locationId_2)), Collections.emptyList(), page1Eq_2.getContext());
page1Eq_2 = testInterface.getSessionsForCustomer(customerId_1, null, new HashSet<Long>(Arrays.asList(locationId_2)), null, Collections.emptyList(), context);
page2Eq_2 = testInterface.getSessionsForCustomer(customerId_1, null, new HashSet<Long>(Arrays.asList(locationId_2)), null, Collections.emptyList(), page1Eq_2.getContext());
assertEquals(10, page1Eq_2.getItems().size());
assertEquals(0, page2Eq_2.getItems().size());
@@ -1012,9 +919,9 @@ public abstract class BaseClientDatastoreTest {
//test the results for location_1 or location_2 only
page1Eq_1or2 = testInterface.getSessionsForCustomer(customerId_1, null, new HashSet<Long>(Arrays.asList(locationId_1, locationId_2)), Collections.emptyList(), context);
page2Eq_1or2 = testInterface.getSessionsForCustomer(customerId_1, null, new HashSet<Long>(Arrays.asList(locationId_1, locationId_2)), Collections.emptyList(), page1Eq_1or2.getContext());
page3Eq_1or2 = testInterface.getSessionsForCustomer(customerId_1, null, new HashSet<Long>(Arrays.asList(locationId_1, locationId_2)), Collections.emptyList(), page2Eq_1or2.getContext());
page1Eq_1or2 = testInterface.getSessionsForCustomer(customerId_1, null, new HashSet<Long>(Arrays.asList(locationId_1, locationId_2)), null, Collections.emptyList(), context);
page2Eq_1or2 = testInterface.getSessionsForCustomer(customerId_1, null, new HashSet<Long>(Arrays.asList(locationId_1, locationId_2)), null, Collections.emptyList(), page1Eq_1or2.getContext());
page3Eq_1or2 = testInterface.getSessionsForCustomer(customerId_1, null, new HashSet<Long>(Arrays.asList(locationId_1, locationId_2)), null, Collections.emptyList(), page2Eq_1or2.getContext());
assertEquals(10, page1Eq_1or2.getItems().size());
assertEquals(10, page2Eq_1or2.getItems().size());
@@ -1036,8 +943,8 @@ public abstract class BaseClientDatastoreTest {
assertEquals(expectedPage2Eq_1or2Strings, actualPage2Loc_1or2Strings);
//test the results for ( location_1 or location_2 ) and equipment_1only
page1Eq_1 = testInterface.getSessionsForCustomer(customerId_1, new HashSet<Long>(Arrays.asList(equipmentId_1)), new HashSet<Long>(Arrays.asList(locationId_1, locationId_2)), Collections.emptyList(), context);
page2Eq_1 = testInterface.getSessionsForCustomer(customerId_1, new HashSet<Long>(Arrays.asList(equipmentId_1)), new HashSet<Long>(Arrays.asList(locationId_1, locationId_2)), Collections.emptyList(), page1Eq_1.getContext());
page1Eq_1 = testInterface.getSessionsForCustomer(customerId_1, new HashSet<Long>(Arrays.asList(equipmentId_1)), new HashSet<Long>(Arrays.asList(locationId_1, locationId_2)), null, Collections.emptyList(), context);
page2Eq_1 = testInterface.getSessionsForCustomer(customerId_1, new HashSet<Long>(Arrays.asList(equipmentId_1)), new HashSet<Long>(Arrays.asList(locationId_1, locationId_2)), null, Collections.emptyList(), page1Eq_1.getContext());
assertEquals(10, page1Eq_1.getItems().size());
assertEquals(0, page2Eq_1.getItems().size());
@@ -1066,6 +973,63 @@ public abstract class BaseClientDatastoreTest {
return new ArrayList<>(Arrays.asList(new String[]{"qr_49", "qr_48", "qr_47", "qr_46", "qr_45", "qr_44", "qr_43", "qr_42", "qr_41", "qr_40" }));
}
@Test
public void testClientSessionPaginationMaxItems()
{
//create 100 Client sessions
ClientSession mdl;
int customerId = (int) testSequence.incrementAndGet();
long locationId = testSequence.incrementAndGet();
int apNameIdx = 0;
List<ClientSession> sessionsToCreate = new ArrayList<>();
for(int i = 0; i< 10; i++){
mdl = new ClientSession();
mdl.setCustomerId(customerId);
mdl.setLocationId(locationId);
mdl.setEquipmentId(testSequence.incrementAndGet());
mdl.setMacAddress(new MacAddress("A1:FF:FF:FF:FF:FF"));
ClientSessionDetails details = new ClientSessionDetails();
details.setApFingerprint("qr_"+apNameIdx);
mdl.setDetails(details );
apNameIdx++;
sessionsToCreate.add(mdl);
}
List<ClientSession> createdList = testInterface.updateSessions(sessionsToCreate);
List<ClientSessionDetails> createdDetailsList = new ArrayList<>();
List<ClientSessionDetails> detailsToCreateList = new ArrayList<>();
sessionsToCreate.forEach(s -> detailsToCreateList.add(s.getDetails()));
createdList.forEach(s -> createdDetailsList.add(s.getDetails()));
assertEquals(detailsToCreateList, createdDetailsList);
PaginationContext<ClientSession> context = new PaginationContext<>(5);
PaginationResponse<ClientSession> page1 = testInterface.getSessionsForCustomer(customerId, null, new HashSet<Long>(Arrays.asList(locationId)), null, Collections.emptyList(), context);
assertEquals(5, page1.getItems().size());
page1 = testInterface.getSessionsForCustomer(customerId, null, null, "A1", Collections.emptyList(), context);
assertEquals(5, page1.getItems().size());
context = new PaginationContext<>(10);
page1 = testInterface.getSessionsForCustomer(customerId, null, new HashSet<Long>(Arrays.asList(locationId)), null, Collections.emptyList(), context);
assertEquals(10, page1.getItems().size());
context = new PaginationContext<>(20);
page1 = testInterface.getSessionsForCustomer(customerId, null, new HashSet<Long>(Arrays.asList(locationId)), null, Collections.emptyList(), context);
assertEquals(10, page1.getItems().size());
createdList.forEach(c -> testInterface.deleteSession(c.getCustomerId(), c.getEquipmentId(), c.getMacAddress()));
}
protected ClientSession createClientSessionObject() {
ClientSession result = new ClientSession();

1
client-datastore-inmemory/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target/

View File

@@ -1,10 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
@@ -16,19 +15,19 @@
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-datastore-inmemory</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>client-datastore-interface</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>client-datastore-common-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
</dependencies>

View File

@@ -3,6 +3,7 @@ package com.telecominfraproject.wlan.client.datastore.inmemory;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -15,6 +16,7 @@ import org.springframework.context.annotation.Configuration;
import com.telecominfraproject.wlan.client.datastore.ClientDatastore;
import com.telecominfraproject.wlan.client.info.models.ClientInfoDetails;
import com.telecominfraproject.wlan.client.info.models.ClientSessionCounts;
import com.telecominfraproject.wlan.client.models.Client;
import com.telecominfraproject.wlan.client.session.models.ClientSession;
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
@@ -156,6 +158,11 @@ public class ClientDatastoreInMemory extends BaseInMemoryDatastore implements Cl
//client is already cloned by the getOrNull method
return client;
}
@Override
public void delete(long createdBeforeTimestamp) {
return;
}
@Override
public List<Client> get(int customerId, Set<MacAddress> clientMacSet) {
@@ -176,113 +183,6 @@ public class ClientDatastoreInMemory extends BaseInMemoryDatastore implements Cl
return ret;
}
@Override
public PaginationResponse<Client> searchByMacAddress(int customerId, String macSubstring,
final List<ColumnAndSort> sortBy, PaginationContext<Client> context) {
if(context == null) {
context = new PaginationContext<>();
}
PaginationResponse<Client> ret = new PaginationResponse<>();
ret.setContext(context.clone());
if (ret.getContext().isLastPage()) {
// no more pages available according to the context
return ret;
}
List<Client> items = new LinkedList<>();
if(macSubstring != null) {
idToClientMap.forEach(
(k, c) -> {
if(k.customerId == customerId && k.mac.getAddressAsString().toLowerCase().contains(macSubstring.toLowerCase())) {
items.add(c.clone());
}
}
);
} else {
idToClientMap.forEach(
(k, c) -> {
if(k.customerId == customerId) {
items.add(c.clone());
}
}
);
}
// apply sortBy columns
Collections.sort(items, new Comparator<Client>() {
@Override
public int compare(Client o1, Client o2) {
if (sortBy == null || sortBy.isEmpty()) {
// sort ascending by id by default
return o1.getMacAddress().compareTo(o2.getMacAddress());
} else {
int cmp;
for (ColumnAndSort column : sortBy) {
switch (column.getColumnName()) {
case "macAddress":
cmp = o1.getMacAddress().compareTo(o2.getMacAddress());
break;
default:
// skip unknown column
continue;
}
if (cmp != 0) {
return (column.getSortOrder() == SortOrder.asc) ? cmp : (-cmp);
}
}
}
return 0;
}
});
// now select only items for the requested page
// find first item to add
int fromIndex = 0;
if (context.getStartAfterItem() != null) {
for (Client mdl : items) {
fromIndex++;
if (mdl.getCustomerId() == context.getStartAfterItem().getCustomerId()
&& mdl.getMacAddress().equals(context.getStartAfterItem().getMacAddress())) {
break;
}
}
}
// find last item to add
int toIndexExclusive = fromIndex + context.getMaxItemsPerPage();
if (toIndexExclusive > items.size()) {
toIndexExclusive = items.size();
}
// copy page items into result
List<Client> selectedItems = new ArrayList<>(context.getMaxItemsPerPage());
for (Client mdl : items.subList(fromIndex, toIndexExclusive)) {
selectedItems.add(mdl.clone());
}
ret.setItems(selectedItems);
// adjust context for the next page
ret.prepareForNextPage();
if(ret.getContext().getStartAfterItem()!=null) {
//this datastore is only interested in the last item's id, so we'll clear all other fields on the startAfterItem in the pagination context
Client newStartAfterItem = new Client();
newStartAfterItem.setCustomerId(ret.getContext().getStartAfterItem().getCustomerId());
newStartAfterItem.setMacAddress(ret.getContext().getStartAfterItem().getMacAddress());
ret.getContext().setStartAfterItem(newStartAfterItem);
}
return ret;
}
@Override
public List<Client> getBlockedClients(int customerId) {
@@ -305,7 +205,7 @@ public class ClientDatastoreInMemory extends BaseInMemoryDatastore implements Cl
}
@Override
public PaginationResponse<Client> getForCustomer(int customerId,
public PaginationResponse<Client> getForCustomer(int customerId, String macSubstring,
final List<ColumnAndSort> sortBy, PaginationContext<Client> context) {
if(context == null) {
@@ -328,8 +228,11 @@ public class ClientDatastoreInMemory extends BaseInMemoryDatastore implements Cl
if (mdl.getCustomerId() != customerId) {
continue;
}
items.add(mdl);
if (macSubstring == null ||
mdl.getMacAddress().getAddressAsString().toLowerCase().contains(macSubstring.toLowerCase())) {
items.add(mdl);
}
}
// apply sortBy columns
@@ -466,6 +369,10 @@ public class ClientDatastoreInMemory extends BaseInMemoryDatastore implements Cl
return clientSession.clone();
}
@Override
public void deleteSessions(long createdBeforeTimestamp) {
return;
}
@Override
public List<ClientSession> getSessions(int customerId, Set<MacAddress> clientMacSet) {
@@ -491,6 +398,7 @@ public class ClientDatastoreInMemory extends BaseInMemoryDatastore implements Cl
public PaginationResponse<ClientSession> getSessionsForCustomer(int customerId,
Set<Long> equipmentIds,
Set<Long> locationIds,
String macSubstring,
final List<ColumnAndSort> sortBy, PaginationContext<ClientSession> context) {
if(context == null) {
@@ -520,7 +428,12 @@ public class ClientDatastoreInMemory extends BaseInMemoryDatastore implements Cl
locationIds == null
|| locationIds.isEmpty()
|| locationIds.contains(mdl.getLocationId())
)
) &&
(
macSubstring == null
|| macSubstring.isEmpty()
|| mdl.getMacAddress().getAddressAsString().toLowerCase().contains(macSubstring.toLowerCase())
)
) {
items.add(mdl);
}
@@ -601,4 +514,56 @@ public class ClientDatastoreInMemory extends BaseInMemoryDatastore implements Cl
return ret;
}
@Override
public ClientSessionCounts getSessionCounts(int customerId) {
ClientSessionCounts counts = new ClientSessionCounts();
counts.setCustomerId(customerId);
long totalCount = 0;
Map<String, Long> perEquipmentMap = new HashMap<>();
Map<String, Long> perOuiMap = new HashMap<>();
Map<String, Long> perRadioMap = new HashMap<>();
for (ClientSession session : idToClientSessionMap.values()) {
if (session.getCustomerId() == customerId) {
totalCount++;
String equipmentIdString = Long.toString(session.getEquipmentId());
Long cnt = perEquipmentMap.get(equipmentIdString);
if (cnt == null) {
cnt = 0L;
} else {
cnt++;
}
perEquipmentMap.put(equipmentIdString, cnt);
if (session.getOui() != null) {
cnt = perOuiMap.get(session.getOui());
if (cnt == null) {
cnt = 0L;
} else {
cnt++;
}
perOuiMap.put(session.getOui(), cnt);
}
if (session.getDetails() != null && session.getDetails().getRadioType() != null) {
String radioTypeString = session.getDetails().getRadioType().toString();
cnt = perRadioMap.get(radioTypeString);
if (cnt == null) {
cnt = 0L;
} else {
cnt++;
}
perRadioMap.put(radioTypeString, cnt);
}
}
}
counts.setTotalCount(totalCount);
counts.setEquipmentCounts(perEquipmentMap);
counts.setOuiCounts(perOuiMap);
counts.setRadioCounts(perRadioMap);
return counts;
}
}

1
client-datastore-interface/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target/

View File

@@ -1,10 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath>
</parent>
@@ -16,12 +15,12 @@
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>client-models</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-exceptions</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
</dependencies>

View File

@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import com.telecominfraproject.wlan.client.info.models.ClientSessionCounts;
import com.telecominfraproject.wlan.client.models.Client;
import com.telecominfraproject.wlan.client.session.models.ClientSession;
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
@@ -21,6 +22,7 @@ public interface ClientDatastore {
Client getOrNull(int customerId, MacAddress clientMac);
Client update(Client client);
Client delete(int customerId, MacAddress clientMac);
void delete(long createdBeforeTimestamp);
/**
* Retrieves a list of Client records that which have their mac address in the provided set.
@@ -29,17 +31,9 @@ public interface ClientDatastore {
* @return list of matching Client objects.
*/
List<Client> get(int customerId, Set<MacAddress> clientMacSet);
/**
* Retrieves a list of Client records that have mac addresses that match a given substring.
*
* @param macSubstring
* @return next page of matching Client objects.
*/
PaginationResponse<Client> searchByMacAddress(int customerId, String macSubstring, List<ColumnAndSort> sortBy, PaginationContext<Client> context);
/**
* <br>Retrieves all of the Client records that are mapped to the provided customerId.
* <br>Retrieves all of the Client records that are mapped to the provided customerId and optional macSubstring filter.
* Results are returned in pages.
*
* <br>When changing sort order or filters, pagination should be restarted again from the first page.
@@ -52,9 +46,10 @@ public interface ClientDatastore {
*<li> "macAddress"
*<br>
* @param customerId
* @param macSubstring
* @return next page of matching Client objects.
*/
PaginationResponse<Client> getForCustomer(int customerId, List<ColumnAndSort> sortBy, PaginationContext<Client> context);
PaginationResponse<Client> getForCustomer(int customerId, String macSubstring, List<ColumnAndSort> sortBy, PaginationContext<Client> context);
/**
* @param customerId
@@ -79,7 +74,7 @@ public interface ClientDatastore {
ClientSession deleteSession(int customerId, long equipmentId, MacAddress clientMac);
void deleteSessions(long createdBeforeTimestamp);
/**
* Retrieves a list of Client sessions that which have their mac address in the provided set.
*
@@ -105,10 +100,18 @@ public interface ClientDatastore {
* @param customerId
* @param equipmentIds - set of equipment ids for which to retrieve session objects. Empty set or null means retrieve for all customer's equipment.
* @param locationIds - set of location ids for which to retrieve session objects. Empty set or null means retrieve for all customer's locations.
* @param macSubstring - To match with MacAddress
*
* @return next page of matching Client session objects.
*/
PaginationResponse<ClientSession> getSessionsForCustomer(int customerId, Set<Long> equipmentIds, Set<Long> locationIds, List<ColumnAndSort> sortBy, PaginationContext<ClientSession> context);
PaginationResponse<ClientSession> getSessionsForCustomer(int customerId, Set<Long> equipmentIds, Set<Long> locationIds, String macSubstring, List<ColumnAndSort> sortBy, PaginationContext<ClientSession> context);
/**
* Get Client Session counts for the given customerId.
*
* @param customerId
* @return
*/
ClientSessionCounts getSessionCounts(int customerId);
}

Some files were not shown because too many files have changed in this diff Show More