From 744c2e3e3e9a592f32bcb7bb185b109da4483042 Mon Sep 17 00:00:00 2001 From: Manuri Date: Wed, 24 Apr 2019 12:17:57 +0530 Subject: [PATCH] Sync with 0.991.0 version --- component/pom.xml | 4 +- .../src/main/ballerina/cassandra/Module.md | 3 +- .../src/main/ballerina/cassandra/endpoint.bal | 10 ++-- .../src/main/ballerina/cassandra/types.bal | 53 ++++++++----------- .../samples/cassandra-actions-test.bal | 16 +++--- .../cassandra-connection-init-test.bal | 16 +++--- pom.xml | 7 +-- 7 files changed, 51 insertions(+), 58 deletions(-) diff --git a/component/pom.xml b/component/pom.xml index d8a6f1b..41ffb2c 100644 --- a/component/pom.xml +++ b/component/pom.xml @@ -46,7 +46,7 @@ org.ballerinalang - ballerina-runtime + ballerina-runtime-api org.ballerinalang @@ -72,7 +72,7 @@ org.ballerinalang - ballerina-runtime + ballerina-runtime-api zip ballerina-binary-repo diff --git a/component/src/main/ballerina/cassandra/Module.md b/component/src/main/ballerina/cassandra/Module.md index 4ba1f69..5bd3f27 100644 --- a/component/src/main/ballerina/cassandra/Module.md +++ b/component/src/main/ballerina/cassandra/Module.md @@ -47,8 +47,7 @@ if (returned is ()) { var selectRet = conn->select("select id, name, salary from testballerina.person where salary = ? ALLOW FILTERING", Person, pSalary); -if (selectRet is table) { - table dt = selectRet; +if (selectRet is table) { // Processing logic } else { io:println("Select data from person table failed: " + selectRet.reason()); diff --git a/component/src/main/ballerina/cassandra/endpoint.bal b/component/src/main/ballerina/cassandra/endpoint.bal index df78963..491f2a1 100644 --- a/component/src/main/ballerina/cassandra/endpoint.bal +++ b/component/src/main/ballerina/cassandra/endpoint.bal @@ -29,14 +29,14 @@ public type Client client object { # + queryString - Query to be executed # + recordType - The Type result should be mapped to # + return - `table` representing the result of the select action or `error` if an error occurs - public remote extern function select(string queryString, typedesc recordType, Param... parameters) - returns (table|error); + public remote function select(string queryString, typedesc recordType, Param... parameters) + returns (table|error) = external; # Execute update query on cassandra datasource. # + queryString - Query to be executed # + return - `nil` or `error` if an error occurs - public remote extern function update(string queryString, Param... parameters) returns (error?); + public remote function update(string queryString, Param... parameters) returns (error?) = external; # Stops the registered service. public function stop() { @@ -47,6 +47,6 @@ public type Client client object { # An internal function used by clients to shutdown the connection pool. # # + cassandraClient - Client object that encapsulates the connection/connection pool -extern function close(Client cassandraClient); +function close(Client cassandraClient) = external; -extern function initClient(Client cassandraClient, ClientEndpointConfig clientEndpointConfig); +function initClient(Client cassandraClient, ClientEndpointConfig clientEndpointConfig) = external; diff --git a/component/src/main/ballerina/cassandra/types.bal b/component/src/main/ballerina/cassandra/types.bal index 7b761b4..7b6bfe7 100644 --- a/component/src/main/ballerina/cassandra/types.bal +++ b/component/src/main/ballerina/cassandra/types.bal @@ -15,31 +15,31 @@ // under the License. # The Datatype of the parameter. -public type Type "INT"|"BIGINT"|"VARINT"|"FLOAT"|"DOUBLE"|"TEXT"|"BOOLEAN"|"LIST"; +public type Type TYPE_INT | TYPE_BIGINT | TYPE_VARINT | TYPE_FLOAT | TYPE_DOUBLE | TYPE_TEXT | TYPE_BOOLEAN | TYPE_LIST; # A 32-bit signed integer. -public final Type TYPE_INT = "INT"; +public const TYPE_INT = "INT"; # A 64-bit signed long. -public final Type TYPE_BIGINT = "BIGINT"; +public const TYPE_BIGINT = "BIGINT"; # Arbitrary precision integer. -public final Type TYPE_VARINT = "VARINT"; +public const TYPE_VARINT = "VARINT"; # A 32-bit IEEE-754 floating point. -public final Type TYPE_FLOAT = "FLOAT"; +public const TYPE_FLOAT = "FLOAT"; # A 64-bit IEEE-754 floating point. -public final Type TYPE_DOUBLE = "DOUBLE"; +public const TYPE_DOUBLE = "DOUBLE"; # UTF-8 encoded string. -public final Type TYPE_TEXT = "TEXT"; +public const TYPE_TEXT = "TEXT"; # Boolean value either True or false. -public final Type TYPE_BOOLEAN = "BOOLEAN"; +public const TYPE_BOOLEAN = "BOOLEAN"; # A collection of one or more ordered elements. -public final Type TYPE_LIST = "LIST"; +public const TYPE_LIST = "LIST"; # Represents complex parameter passed to `select` or `update` operation. @@ -60,14 +60,13 @@ public type Param string|int|boolean|float|Parameter; # + username - Username for the database connection # + password - Password for the database connection # + options - Properties for the connection configuration -public type ClientEndpointConfig record { +public type ClientEndpointConfig record {| string host; int port; string username; string password; ConnectionProperties options = {}; - !...; -}; +|}; # ConnectionProperties type represents the properties which are used to configure Cassandra connection. # @@ -89,7 +88,7 @@ public type ClientEndpointConfig record { # + socketOptionsConfig - Options to configure low-level socket options for the connections kept to the Cassandra # hosts # + protocolOptionsConfig - Options of the Cassandra native binary protocol -public type ConnectionProperties record { +public type ConnectionProperties record {| string clusterName = ""; string loadBalancingPolicy = ""; string reconnectionPolicy = ""; @@ -108,8 +107,7 @@ public type ConnectionProperties record { PoolingOptionsConfig poolingOptionsConfig = {}; SocketOptionsConfig socketOptionsConfig = {}; ProtocolOptionsConfig protocolOptionsConfig = {}; - !...; -}; +|}; # Options of the Cassandra native binary protocol. # @@ -118,7 +116,7 @@ public type ConnectionProperties record { # + maxSchemaAgreementWaitSeconds - The maximum time to wait for schema agreement before returning from a DDL query # + initialProtocolVersion - Version of the native protocol supported by the driver # + compression - Compression supported by the Cassandra binary protocol -public type ProtocolOptionsConfig record { +public type ProtocolOptionsConfig record {| boolean sslEnabled = false; boolean noCompact = false; @@ -126,8 +124,7 @@ public type ProtocolOptionsConfig record { string initialProtocolVersion = ""; string compression = ""; - !...; -}; +|}; # Options related to defaults for individual queries. # @@ -158,7 +155,7 @@ public type ProtocolOptionsConfig record { # refresh requests # + refreshSchemaIntervalMillis - Determines the default window size in milliseconds used to debounce schema refresh # requests -public type QueryOptionsConfig record { +public type QueryOptionsConfig record {| string consistencyLevel = ""; string serialConsistencyLevel = ""; @@ -174,8 +171,7 @@ public type QueryOptionsConfig record { int refreshNodeListIntervalMillis = -1; int refreshNodeIntervalMillis = -1; int refreshSchemaIntervalMillis = -1; - !...; -}; +|}; # Options related to connection pooling. @@ -193,7 +189,7 @@ public type QueryOptionsConfig record { # + coreConnectionsPerHostRemote - The core number of connections per remote host # + maxConnectionsPerHostRemote - The maximum number of connections per remote host # + newConnectionThresholdRemote - The threshold that triggers the creation of a new connection to a remote host -public type PoolingOptionsConfig record { +public type PoolingOptionsConfig record {| int maxRequestsPerConnectionLocal = -1; int maxRequestsPerConnectionRemote = -1; int idleTimeoutSeconds = -1; @@ -206,8 +202,7 @@ public type PoolingOptionsConfig record { int coreConnectionsPerHostRemote = -1; int maxConnectionsPerHostRemote = -1; int newConnectionThresholdRemote = -1; - !...; -}; +|}; # Options to configure low-level socket options for the connections kept to the Cassandra hosts. # @@ -216,16 +211,14 @@ public type PoolingOptionsConfig record { # + soLinger - The linger-on-close timeout # + receiveBufferSize - A hint to the size of the underlying buffers for incoming network I/O # + sendBufferSize - A hint to the size of the underlying buffers for outgoing network I/O -public type SocketOptionsConfig record { +public type SocketOptionsConfig record {| int connectTimeoutMillis = -1; int readTimeoutMillis = -1; int soLinger = -1; int receiveBufferSize = -1; int sendBufferSize = -1; - !...; -}; +|}; -public type DatabaseErrorData record { +public type DatabaseErrorData record {| string message; - !...; -}; +|}; diff --git a/component/src/test/resources/samples/cassandra-actions-test.bal b/component/src/test/resources/samples/cassandra-actions-test.bal index 9f6b558..a020530 100644 --- a/component/src/test/resources/samples/cassandra-actions-test.bal +++ b/component/src/test/resources/samples/cassandra-actions-test.bal @@ -15,12 +15,12 @@ function testKeySpaceCreation() { password: "cassandra", options: {} }); - _ = conn->update("CREATE KEYSPACE dummyks WITH replication = {'class':'SimpleStrategy', 'replication_factor' + checkpanic conn->update("CREATE KEYSPACE dummyks WITH replication = {'class':'SimpleStrategy', 'replication_factor' :1}"); conn.stop(); } -function testDuplicateKeySpaceCreation() returns (any) { +function testDuplicateKeySpaceCreation() returns error? { c:Client conn = new({ host: "localhost", port: 9142, @@ -28,7 +28,7 @@ function testDuplicateKeySpaceCreation() returns (any) { password: "cassandra", options: {} }); - _ = conn->update("CREATE KEYSPACE duplicatekstest WITH replication = {'class':'SimpleStrategy', + checkpanic conn->update("CREATE KEYSPACE duplicatekstest WITH replication = {'class':'SimpleStrategy', 'replication_factor':1}"); var result = conn->update("CREATE KEYSPACE duplicatekstest WITH replication = {'class':'SimpleStrategy', @@ -46,7 +46,7 @@ function testTableCreation() { password: "cassandra", options: {} }); - _ = conn->update("CREATE TABLE peopleinfoks.student(id int PRIMARY KEY,name text, age int)"); + checkpanic conn->update("CREATE TABLE peopleinfoks.student(id int PRIMARY KEY,name text, age int)"); conn.stop(); } @@ -65,7 +65,7 @@ function testInsert() { c:Parameter pIncome = { cqlType: c:TYPE_DOUBLE, value: 1000.5 }; c:Parameter pMarried = { cqlType: c:TYPE_BOOLEAN, value: true }; - _ = conn->update("INSERT INTO peopleinfoks.person(id, name, salary, income, married) values (?,?,?,?,?)", + checkpanic conn->update("INSERT INTO peopleinfoks.person(id, name, salary, income, married) values (?,?,?,?,?)", pID, pName, pSalary, pIncome, pMarried); conn.stop(); } @@ -81,7 +81,7 @@ function testInsertRawParams() { c:Parameter pIncome = { cqlType: c:TYPE_DOUBLE, value: 1001.5 }; - _ = conn->update("INSERT INTO peopleinfoks.person(id, name, salary, income, married) values (?,?,?,?,?)", + checkpanic conn->update("INSERT INTO peopleinfoks.person(id, name, salary, income, married) values (?,?,?,?,?)", 10, "Tommy", 101.5, pIncome, false); conn.stop(); } @@ -155,7 +155,7 @@ function testSelect() returns (int, string, float) { return (id, name, salary); } -function testSelectNonExistentColumn() returns (any) { +function testSelectNonExistentColumn() returns any | error { c:Client conn = new({ host: "localhost", port: 9142, @@ -179,7 +179,7 @@ function testInsertWithNilParams() { options: {} }); - _ = conn->update("INSERT INTO peopleinfoks.person(id, name, salary, income, married) + checkpanic conn->update("INSERT INTO peopleinfoks.person(id, name, salary, income, married) values (10,'Jim',101.5,1001.5,false)"); conn.stop(); } diff --git a/component/src/test/resources/samples/cassandra-connection-init-test.bal b/component/src/test/resources/samples/cassandra-connection-init-test.bal index 9eb1350..a301e2c 100644 --- a/component/src/test/resources/samples/cassandra-connection-init-test.bal +++ b/component/src/test/resources/samples/cassandra-connection-init-test.bal @@ -13,7 +13,7 @@ function testConnectionInitWithLBPolicy() { password: "cassandra", options: { loadBalancingPolicy: "DCAwareRoundRobinPolicy" } }); - _ = conn->update("CREATE KEYSPACE lbtestkeyspace WITH replication = {'class': 'SimpleStrategy', + checkpanic conn->update("CREATE KEYSPACE lbtestkeyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor' :1}"); conn.stop(); } @@ -37,7 +37,7 @@ function testConnectionInitWithRetryPolicy() { options: { retryPolicy: "DefaultRetryPolicy" } }); - _ = conn->update("CREATE KEYSPACE retrytestkeyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': + checkpanic conn->update("CREATE KEYSPACE retrytestkeyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}"); conn.stop(); } @@ -62,7 +62,7 @@ function testConnectionInitWithReconnectionPolicy() { options: { reconnectionPolicy: "ConstantReconnectionPolicy", constantReconnectionPolicyDelay: 500 } }); - _ = conn->update("CREATE KEYSPACE reconnectiontestkeyspace WITH replication = {'class': 'SimpleStrategy', + checkpanic conn->update("CREATE KEYSPACE reconnectiontestkeyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}"); conn.stop(); } @@ -113,7 +113,7 @@ function testConnectionInitWithPoolingOptions() { coreConnectionsPerHostLocal: 2, maxConnectionsPerHostLocal: 2, newConnectionThresholdLocal: 100, coreConnectionsPerHostRemote: 1, maxConnectionsPerHostRemote: 8, newConnectionThresholdRemote: 100 } } }); - _ = conn->update("CREATE KEYSPACE poolingoptionstestkeyspace WITH replication = {'class': 'SimpleStrategy', + checkpanic conn->update("CREATE KEYSPACE poolingoptionstestkeyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}"); conn.stop(); @@ -129,7 +129,7 @@ function testConnectionInitWithSocketOptions() { options: { socketOptionsConfig: { connectTimeoutMillis: 5000, readTimeoutMillis: 12000, soLinger: 0 } } }); - _ = conn->update("CREATE KEYSPACE socketoptionstestkeyspace WITH replication = {'class': 'SimpleStrategy', + checkpanic conn->update("CREATE KEYSPACE socketoptionstestkeyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}"); conn.stop(); } @@ -146,7 +146,7 @@ function testConnectionInitWithQueryOptions() { maxPendingRefreshNodeRequests: 20, maxPendingRefreshSchemaRequests: 20, refreshNodeListIntervalMillis: 1000, refreshNodeIntervalMillis: 1000, refreshSchemaIntervalMillis: 1000 } } }); - _ = conn->update("CREATE KEYSPACE queryoptionstestkeyspace WITH replication = {'class': 'SimpleStrategy', + checkpanic conn->update("CREATE KEYSPACE queryoptionstestkeyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}"); conn.stop(); } @@ -162,7 +162,7 @@ function testConnectionInitWithProtocolOptions() { initialProtocolVersion: "V4" } } }); - _ = conn->update("CREATE KEYSPACE protocoloptionstestkeyspace WITH replication = {'class': 'SimpleStrategy', + checkpanic conn->update("CREATE KEYSPACE protocoloptionstestkeyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor' :1}"); conn.stop(); } @@ -177,7 +177,7 @@ function testConnectionInitWithAdditionalConnectionParams() { false, withoutJMXReporting: false, allowRemoteDCsForLocalConsistencyLevel: false } }); - _ = conn->update("CREATE KEYSPACE conparamtestkeyspace WITH replication = {'class': 'SimpleStrategy', + checkpanic conn->update("CREATE KEYSPACE conparamtestkeyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}"); conn.stop(); } diff --git a/pom.xml b/pom.xml index ce2fa2c..d78a409 100644 --- a/pom.xml +++ b/pom.xml @@ -130,7 +130,7 @@ org.ballerinalang - ballerina-runtime + ballerina-runtime-api ${ballerina.version} @@ -185,7 +185,7 @@ org.ballerinalang - ballerina-runtime + ballerina-runtime-api ${ballerina.version} zip ballerina-binary-repo @@ -244,6 +244,7 @@ ${wso2.maven.compiler.source} ${wso2.maven.compiler.target} + -proc:none @@ -329,7 +330,7 @@ my-scm-server - 0.990.3 + 0.991.0 3.6.0 19.0 3.1.2