Skip to content
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

Oracle Sink (11g and 12c) #2207

Merged
merged 15 commits into from
Dec 2, 2022
Merged

Oracle Sink (11g and 12c) #2207

merged 15 commits into from
Dec 2, 2022

Conversation

AlvaroVega
Copy link
Member

@AlvaroVega AlvaroVega commented Nov 30, 2022

issue #2195

This new sinks is based on SQL and implements:

Tested using this instance: Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production

iot-oracle:
  container_name: iot-oracle
  hostname: iot-oracle
  image: oracleinanutshell/oracle-xe-11g:latest
  ports:
   - 1521:1521
   - 5500:8080
  environment:
   - ORACLE_ALLOW_REMOTE=true
   - ORACLE_DISABLE_ASYNCH_IO=true
   - ORACLE_ENABLE_XDB=true
   - NLS_TIMESTAMP_FORMAT=YYYY-MM-DD HH24:MI:SS.FF6
   - NLS_TIMESTAMP_TZ_FORMAT=YYYY-MM-DD"T"HH24:MI:SS.FF6 TZR
   - NLS_DATE_FORMAT=YYYY-MM-DD HH24:MI:SS
   - NLS_LANG=SPANISH_SPAIN.UTF8   
   #system/oracle
   # databasename: xe
  log_driver: json-file
  log_opt:
    max-size: "250m"

Typical oracle-sink config:

# # NGSIOracleSink configuration
cygnus-ngsi.sinks.oracle-sink.type = com.telefonica.iot.cygnus.sinks.NGSIOracleSQLSink
cygnus-ngsi.sinks.oracle-sink.channel = oracle-channel
#cygnus-ngsi.sinks.oracle-sink.enable_encoding = false
cygnus-ngsi.sinks.oracle-sink.enable_grouping = false
cygnus-ngsi.sinks.oracle-sink.enable_name_mappings = true
#cygnus-ngsi.sinks.oracle-sink.enable_lowercase = false
cygnus-ngsi.sinks.oracle-sink.data_model = dm-by-entity-type
cygnus-ngsi.sinks.oracle-sink.oracle_host = iot-oracle
cygnus-ngsi.sinks.oracle-sink.oracle_port = 1521
cygnus-ngsi.sinks.oracle-sink.oracle_database = xe
cygnus-ngsi.sinks.oracle-sink.oracle_username = system
cygnus-ngsi.sinks.oracle-sink.oracle_password = oracle
cygnus-ngsi.sinks.oracle-sink.attr_persistence = column
cygnus-ngsi.sinks.oracle-sink.attr_native_types = true
cygnus-ngsi.sinks.oracle-sink.batch_size = 1
cygnus-ngsi.sinks.oracle-sink.batch_timeout = 10

New optional sink configuration options:

cygnus-ngsi.sinks.oracle-sink.nls_timestamp_format=YYYY-MM-DD HH24:MI:SS.FF6
cygnus-ngsi.sinks.oracle-sink.nls_timestamp_tz_format=YYYY-MM-DDTHH24:MI:SS.FF6 TZR
cygnus-ngsi.sinks.oracle-sink.oracle_locator=false 

Example of table creation for column and dm-by-entity-type:

CREATE TABLE thing (
    entityid varchar2(40) NOT NULL,
    entitytype varchar2(40) NOT NULL,
    recvtime timestamp,
    timeinstant timestamp with time zone,
    timeinstant_md varchar2(40),
    fiwareservicepath varchar2(40) NOT NULL,
    st1 varchar2(40),
    st1_md varchar2(40),
    st2 varchar2(40),
    st2_md varchar2(40),
    location SDO_GEOMETRY,
    location_md varchar2(40),
    CONSTRAINT tmp1_pk PRIMARY KEY (entityid, entitytype, recvtime)
);

@AlvaroVega AlvaroVega changed the title [WIP] Task/oracle sink Oracle Sink (11g and 12c) Dec 1, 2022
@AlvaroVega AlvaroVega requested review from mrutid and fgalan and removed request for mrutid December 2, 2022 11:03
Co-authored-by: Fermín Galán Márquez <[email protected]>
@@ -16,6 +16,7 @@
* [Last Data Functionality](./last_data_function.md)
* [NGSIPostGISSink](./ngsi_postgis_sink.md)
* [Last Data Functionality](./last_data_function.md)
* [NGSIOracleSQLSink](./ngsi_oracle_sink.md)
Copy link
Member

Choose a reason for hiding this comment

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

No "Last Data Functionality" sub-bullet? Does that means that lastdata is not yet implemented in the OracleSink?

Copy link
Member

Choose a reason for hiding this comment

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

In the ngsi_oracle_sink.md file I see:

| last\_data\_mode | no | insert | <i>insert</i>  to set last data mode. Check this [link](./last_data_function.md) for more details. In oracle sink <i>both</i> and <i>upsert</i> are not avaiable |

so maybe it's just a typo here.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's: Column support (no upsert mode support for lastdata, just insert)

Copy link
Member

Choose a reason for hiding this comment

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

Clarified at skype. NTC

Copy link
Member

@fgalan fgalan left a comment

Choose a reason for hiding this comment

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

LGTM

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.

2 participants