Skip to content

Issue #1981: WIP MultiProvider RC extension #2007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 9, 2017

Conversation

abdulazizali77
Copy link
Contributor

@gvagenas @deruelle I thought about possible ways to make account specific mappings to RC configurations with the currect RC Extensions API.

Abstractly i believe any plugin/extension API should allow its consumers to modify aspects of the system at predefined levels/modules. In reference to SMSC MProc API, it allows Messages and anything related to the Message, network id etc to be customized.
I believe with RC we can abstract that out even more, from Message to Session to Transaction to SystemNode to System, which is why i decided to subclass the ExtensionsResponse as i did.

Implementation wise, we couldve chosen between two options

  1. Pass in an/several Interface/s to the Extension handler interface and expose certain parts of our System/Node/Tx/Session/Message to be customized by the extension provider/implementor.
    This is sort of how SMSC does it, it passes specific factories in specific handlers which expose specific configurations to be modified by the MProcRule implementations.
  2. Return specific class/Interface/es to the calling method and handle appropriately. The class/interface would be subclasses/subinterfaces of the ExtensionResponse and RC would handle them all differently.

In the PR changes ive opted to go with 2) so we can leverage the existing ExtensionResponse.
Additionally we also need to pass in more information to the extension than just a message object, because in our example of the MultiProvider specification it needs to map Account to custom database configurations. So abstractly we also need to create a new class/interface to pass in to the handlers, maybe something like ExtensionRequest ?
What do you think? If you think this is in sort of the correct direction, i will proceed with defining an ExtensionRequest and writing the actual MultiProvider extension itself.

@deruelle
Copy link
Member

@abdulazizali77 that seems to make sense to me for defining multiple layers of Response but I think we should really describe what each level means in the context of Restcomm so it's clear and documentation be updated on that as well.

Seems to Makes sense to provide an ExtensionRequest as well to me.

@gvagenas will take the final call on this as he has more insights.

import java.io.IOException;
import java.net.URI;
import java.util.List;
import java.util.concurrent.TimeUnit;

import javolution.util.FastList;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abdulazizali77 this looks like a new dependency. Not sure what policy is, just want to raise the issue here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scottbarstow unsure myself, should find out. Smsc common-library is dependent on this library so license MIGHT be permissible.
However we can cast this to Collection<Tlv> .

@@ -47,13 +46,20 @@
private final Direction direction;
private final BigDecimal price;
private final Currency priceUnit;
private final String tlvTag;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we support array here, like TlvSet, rather than just a single key/value pair? @abdulazizali77 what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scottbarstow I do agree, currently as per your comment on Slack the SmsService only fetches tlv 1550 which is why its only adding one tlv. However the code youre pointing at is the for-test-only Sms REST API tlv modification which im going to clean out.

CREATE MEMORY TABLE "restcomm_geolocation"("sid" VARCHAR(34) NOT NULL PRIMARY KEY, "date_created" DATETIME NOT NULL, "date_updated" DATETIME NOT NULL, "date_executed" DATETIME NOT NULL, "account_sid" VARCHAR(34) NOT NULL, "source" VARCHAR(30), "device_identifier" VARCHAR(30) NOT NULL, "geolocation_type" VARCHAR(15) NOT NULL, "response_status" VARCHAR(30), "cell_id" VARCHAR(10), "location_area_code" VARCHAR(10), "mobile_country_code" INTEGER, "mobile_network_code" VARCHAR(3), "network_entity_address" BIGINT, "age_of_location_info" INTEGER, "device_latitude" VARCHAR(15), "device_longitude" VARCHAR(15), "accuracy" BIGINT, "physical_address" VARCHAR(50), "internet_address" VARCHAR(50), "formatted_address" VARCHAR(200), "location_timestamp" DATETIME, "event_geofence_latitude" VARCHAR(15), "event_geofence_longitude" VARCHAR(15), "radius" BIGINT, "geolocation_positioning_type" VARCHAR(15), "last_geolocation_response" VARCHAR(10), "cause" VARCHAR(150), "api_version" VARCHAR(10) NOT NULL, "uri" LONGVARCHAR NOT NULL)
CREATE USER SA PASSWORD ""
GRANT DBA TO SA
SET WRITE_DELAY 10
SET SCHEMA PUBLIC
INSERT INTO "restcomm_accounts" VALUES('ACae6e420f425248d6a26948c17a9e2acf','2012-04-24 00:00:00.000000000','2012-04-24 00:00:00.000000000','[email protected]','Default Administrator Account',NULL,'Full','uninitialized','77f8c12cc7b8f8423e5c38b035249166','Administrator','/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf')
INSERT INTO "restcomm_accounts" VALUES('ACae6e420f425248d6a26948c17a9e2acg','2012-04-24 00:00:00.000000000','2012-04-24 00:00:00.000000000','[email protected]','Second Administrator Account',NULL,'Full','uninitialized','77f8c12cc7b8f8423e5c38b035249166','Administrator','/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acg')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doubt we want to add new default admin accounts just to demonstrate the capabilities of this particular feature. Should have George weigh in on this for sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scottbarstow agreed, this was only for test purposes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with @scottbarstow , we shouldn't add new accounts here

@scottbarstow
Copy link
Contributor

@abdulazizali77 are we ready for George to review this PR yet?

@abdulazizali77
Copy link
Contributor Author

@gvagenas This PR is ready. Please have a look,

CREATE TABLE restcomm_accounts_extensions (
account_sid VARCHAR(34) NOT NULL,
extension_sid VARCHAR(34) NOT NULL,
extension_blob CLOB,
Copy link

@maria-farooq maria-farooq Apr 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abdulazizali77 CLOB data type, did you chcked is it is supported in mySql

@maria-farooq
Copy link

@abdulazizali77 we need to add upgrade scripts in bitbucket RC to accomodate db schema changes. please check https://bitbucket.org/telestax/telscale-restcomm/src/master/restcomm/configuration/config-scripts/as7-config-scripts/restcomm/upgrade_scripts/?at=master

@deruelle
Copy link
Member

deruelle commented May 1, 2017

@gvagenas @abdulazizali77 can this be merged ?

@gvagenas gvagenas added this to the George 8.2.0 Sprint 2 milestone May 3, 2017
Copy link
Contributor

@gvagenas gvagenas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abdulazizali77 please check my comments for this PR.

Also, since we have issue for all pending tasks/TODO/FIXME and other comments, lets remove them before we merge to master.

Thanks
George

CREATE MEMORY TABLE "restcomm_geolocation"("sid" VARCHAR(34) NOT NULL PRIMARY KEY, "date_created" DATETIME NOT NULL, "date_updated" DATETIME NOT NULL, "date_executed" DATETIME NOT NULL, "account_sid" VARCHAR(34) NOT NULL, "source" VARCHAR(30), "device_identifier" VARCHAR(30) NOT NULL, "geolocation_type" VARCHAR(15) NOT NULL, "response_status" VARCHAR(30), "cell_id" VARCHAR(10), "location_area_code" VARCHAR(10), "mobile_country_code" INTEGER, "mobile_network_code" VARCHAR(3), "network_entity_address" BIGINT, "age_of_location_info" INTEGER, "device_latitude" VARCHAR(15), "device_longitude" VARCHAR(15), "accuracy" BIGINT, "physical_address" VARCHAR(50), "internet_address" VARCHAR(50), "formatted_address" VARCHAR(200), "location_timestamp" DATETIME, "event_geofence_latitude" VARCHAR(15), "event_geofence_longitude" VARCHAR(15), "radius" BIGINT, "geolocation_positioning_type" VARCHAR(15), "last_geolocation_response" VARCHAR(10), "cause" VARCHAR(150), "api_version" VARCHAR(10) NOT NULL, "uri" LONGVARCHAR NOT NULL)
CREATE USER SA PASSWORD ""
GRANT DBA TO SA
SET WRITE_DELAY 10
SET SCHEMA PUBLIC
INSERT INTO "restcomm_accounts" VALUES('ACae6e420f425248d6a26948c17a9e2acf','2012-04-24 00:00:00.000000000','2012-04-24 00:00:00.000000000','[email protected]','Default Administrator Account',NULL,'Full','uninitialized','77f8c12cc7b8f8423e5c38b035249166','Administrator','/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf')
INSERT INTO "restcomm_accounts" VALUES('ACae6e420f425248d6a26948c17a9e2acg','2012-04-24 00:00:00.000000000','2012-04-24 00:00:00.000000000','[email protected]','Second Administrator Account',NULL,'Full','uninitialized','77f8c12cc7b8f8423e5c38b035249166','Administrator','/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acg')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with @scottbarstow , we shouldn't add new accounts here

@@ -42,3 +45,7 @@ INSERT INTO "restcomm_incoming_phone_numbers" VALUES('PN46678e5b01d44973bf184f65
INSERT INTO "restcomm_incoming_phone_numbers" VALUES('PNb43ed9e641364277b6432547ff1109e9','2014-02-17 22:37:19.392000000','2014-02-17 22:37:19.392000000','RVD external services app, customer ID 1 or 2 ','ACae6e420f425248d6a26948c17a9e2acf','+1241','2012-04-24',FALSE,NULL,'POST',NULL,'POST',NULL,'POST','AP81cf45088cba4abcac1261385916d582',NULL,'POST',NULL,'POST',NULL,'/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/IncomingPhoneNumbers/PNb43ed9e641364277b6432547ff1109e9',NULL,NULL,NULL,NULL, TRUE,'0.0', NULL, NULL)
INSERT INTO "restcomm_clients" VALUES('CLa2b99142e111427fbb489c3de357f60a','2013-11-04 12:52:44.144000000','2013-11-04 12:52:44.144000000','ACae6e420f425248d6a26948c17a9e2acf','2012-04-24','alice','alice','1234',1,NULL,'POST',NULL,'POST',NULL,'/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/Clients/CLa2b99142e111427fbb489c3de357f60a')
INSERT INTO "restcomm_clients" VALUES('CL3003328d0de04ba68f38de85b732ed56','2013-11-04 16:33:39.248000000','2013-11-04 16:33:39.248000000','ACae6e420f425248d6a26948c17a9e2acf','2012-04-24','bob','bob','1234',1,NULL,'POST',NULL,'POST',NULL,'/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/Clients/CL3003328d0de04ba68f38de85b732ed56')
INSERT INTO "restcomm_accounts_extensions" VALUES('ACae6e420f425248d6a26948c17a9e2acf','EX00000000000000000000000000000005','{"outbound-sms": [{"destination_network_id": "1000"}]}')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abdulazizali77 we shouldn't add any configuration specific to the extension here. The restcomm_accounts_extensions and restcomm_extensions_configuration records should be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gvagenas removed


<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abdulazizali77 why we need this new dependency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gvagenas removed, it was initially because the ExtensionConfiguration requires it

@@ -97,4 +97,16 @@
* @return
*/
boolean validate(ExtensionConfiguration extensionConfiguration);

/**/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abdulazizali77 please add javadoc comments for the new methods, a short description will be fine

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gvagenas added

@@ -0,0 +1,3 @@
package org.restcomm.connect.extension.api;
public class MessageExtensionResponse extends ExtensionResponse {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abdulazizali77 please add short javadoc description here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gvagenas added

@@ -208,8 +218,8 @@ private void message(final Object message) throws IOException {

final SipServletResponse trying = request.createResponse(SipServletResponse.SC_TRYING);
trying.send();

ActorRef session = session();
//TODO:do extensions check here too?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abdulazizali77 yes we need extension check here also. Those requests are MESSAGE requests from registered clients that Restcomm will proxy out to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gvagenas I want to address this in a new Issue/PR because this Use Case was not actually covered in our testing.

//FIXME:fetch the tag value from the arbitrary key
this.tlvSet.addOptionalParameter(new Tlv(SmppConstants.TAG_DEST_NETWORK_ID,ByteArrayUtil.toByteArray(Integer.parseInt(valStr))));
} catch (Exception e) {
// TODO: handle exception
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abdulazizali77 please add a logger.error(...) here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gvagenas added.

}
}

if (accountSid!=null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abdulazizali77 I don't think this is proper here. As far as I understand, an extension can have a global configuration but also can have a configuration specific to an account. Thus we need to different methods, one to get the global configuration and one to get the configuration for a specific account

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gvagenas I want to address the REST design + implementation issues in #2127

@@ -97,4 +97,16 @@
* @return
*/
boolean validate(ExtensionConfiguration extensionConfiguration);

/**/
ExtensionConfiguration getAccountExtensionConfiguration(String accountSid, String extensionSid);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abdulazizali77 please add short description as javadoc comment to each one of the new methods here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gvagenas added

map.put("account_sid", DaoUtils.writeSid(accountSid));
map.put("extension_sid", DaoUtils.writeSid(extensionConfiguration.getSid()));

if (extensionConfiguration.getConfigurationData() != null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abdulazizali77 I believe that first thing we should do is to check that configuration data is not null and then proceed, if data is null we shouldn't attempt to do an insert in the DB.
Also, the check should be done at ExtensionsConfigurationEndpoint for add and update operations

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gvagenas I want to address the REST design + implementation issues in #2127

… to getAccountExtensionConfiguration

Issue RestComm#1981: Revert ExtensionsBootStrapper xml parsing

Issue RestComm#1981: modify mysql extensions sql

Issue RestComm#1981: Fix poms

Issue RestComm#1981: Add proper tlvs to outbound and sip request

Issue RestComm#1981: WIP. Fix Accounts Extensions DAO. Fix ExtensionConfig to json to XMLConfig mapping. Add example account mappings

Issue RestComm#1981: WIP. Dao changes. Table changes. SMSService changes.

Issue RestComm#1981: Make changes to SmsSession objects

Issue RestComm#1981: Add ExtensionResponse subclasses. Handle Session specific Extension customization by modifying the SmsSession configuration.
@abdulazizali77
Copy link
Contributor Author

@gvagenas Please have another look.
-I have addressed most of the comments
-I have added the common Extension handler functions to ExtensionController but have not done this for CallManager.
-I have moved also DefaultExtensionConfiguration from telscale to community
-I have deferred the REST design + implementation issues to be addressed in #2127. I think we should discuss about the design at first.
-I have deferred from adding the extension hook for "MESSAGE" use case as this seems to be a new scenario which was not even encountered during testing. Will open an Issue for this

…Change RestcommExtensionGeneric preOutboundAction method signature. Add getName,getVersion. Fix dependencies. Fix checkstyle. Remove mistaken CallResponse add.
@gvagenas gvagenas merged commit 771d389 into RestComm:master May 9, 2017
@abdulazizali77
Copy link
Contributor Author

thanks @gvagenas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants