├── images ├── client-image │ ├── VERSION │ ├── sql-client │ │ └── sql-client.sh │ ├── conf │ │ ├── flink-conf.yaml │ │ └── sql-client-conf.yaml │ ├── java │ │ ├── sql-training-data-producer │ │ │ ├── src │ │ │ │ └── main │ │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── ververica │ │ │ │ │ └── sql_training │ │ │ │ │ └── data_producer │ │ │ │ │ ├── records │ │ │ │ │ ├── TaxiRecord.java │ │ │ │ │ ├── DriverChange.java │ │ │ │ │ ├── Ride.java │ │ │ │ │ └── Fare.java │ │ │ │ │ ├── ConsolePrinter.java │ │ │ │ │ ├── json_serde │ │ │ │ │ ├── JsonDeserializer.java │ │ │ │ │ └── JsonSerializer.java │ │ │ │ │ ├── FileReader.java │ │ │ │ │ ├── KafkaProducer.java │ │ │ │ │ ├── Delayer.java │ │ │ │ │ └── TaxiRecordProducer.java │ │ │ ├── pom.xml │ │ │ └── LICENSE │ │ └── sql-training-udfs │ │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── ververica │ │ │ │ └── sql_training │ │ │ │ └── udfs │ │ │ │ ├── IsInNYC.java │ │ │ │ ├── ToAreaId.java │ │ │ │ ├── ToCoords.java │ │ │ │ └── util │ │ │ │ └── GeoUtils.java │ │ │ ├── pom.xml │ │ │ └── LICENSE │ ├── Dockerfile │ └── LICENSE └── flink-image │ └── Dockerfile ├── .gitignore ├── mysql └── create_tables.sql ├── slides ├── sql-training-03-queries-and-time.pdf ├── sql-training-05-pattern-matching.pdf ├── sql-training-06-DDL-INSERT_INTO.pdf ├── sql-training-01-intro-to-Flink-SQL.pdf ├── sql-training-02-querying-dynamic-tables.pdf └── sql-training-04-joining-dynamic-tables.pdf ├── README.md └── docker-compose.yml /images/client-image/VERSION: -------------------------------------------------------------------------------- 1 | 1.0 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/target 2 | **/dependency-reduced-pom.xml 3 | **/.idea 4 | **/*.iml 5 | -------------------------------------------------------------------------------- /mysql/create_tables.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE AreaCnts (areaId INT NOT NULL, cnt BIGINT NOT NULL, PRIMARY KEY (areaId)); 2 | -------------------------------------------------------------------------------- /slides/sql-training-03-queries-and-time.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loafer/sql-training/master/slides/sql-training-03-queries-and-time.pdf -------------------------------------------------------------------------------- /slides/sql-training-05-pattern-matching.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loafer/sql-training/master/slides/sql-training-05-pattern-matching.pdf -------------------------------------------------------------------------------- /slides/sql-training-06-DDL-INSERT_INTO.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loafer/sql-training/master/slides/sql-training-06-DDL-INSERT_INTO.pdf -------------------------------------------------------------------------------- /slides/sql-training-01-intro-to-Flink-SQL.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loafer/sql-training/master/slides/sql-training-01-intro-to-Flink-SQL.pdf -------------------------------------------------------------------------------- /slides/sql-training-02-querying-dynamic-tables.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loafer/sql-training/master/slides/sql-training-02-querying-dynamic-tables.pdf -------------------------------------------------------------------------------- /slides/sql-training-04-joining-dynamic-tables.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loafer/sql-training/master/slides/sql-training-04-joining-dynamic-tables.pdf -------------------------------------------------------------------------------- /images/client-image/sql-client/sql-client.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ${FLINK_HOME}/bin/sql-client.sh embedded -d ${FLINK_HOME}/conf/sql-client-conf.yaml -l ${SQL_CLIENT_HOME}/lib -------------------------------------------------------------------------------- /images/client-image/conf/flink-conf.yaml: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Copyright 2019 Ververica GmbH 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | ################################################################################ 16 | 17 | jobmanager.rpc.address: jobmanager 18 | -------------------------------------------------------------------------------- /images/client-image/java/sql-training-data-producer/src/main/java/com/ververica/sql_training/data_producer/records/TaxiRecord.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ververica GmbH 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.ververica.sql_training.data_producer.records; 18 | 19 | import java.util.Date; 20 | 21 | public interface TaxiRecord { 22 | 23 | Date getEventTime(); 24 | } 25 | -------------------------------------------------------------------------------- /images/client-image/java/sql-training-udfs/src/main/java/com/ververica/sql_training/udfs/IsInNYC.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ververica GmbH 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.ververica.sql_training.udfs; 18 | 19 | import org.apache.flink.table.functions.ScalarFunction; 20 | 21 | import static com.ververica.sql_training.udfs.util.GeoUtils.isInNYC; 22 | 23 | /** 24 | * Table API / SQL Scalar UDF to check if a coordinate is in NYC. 25 | */ 26 | public class IsInNYC extends ScalarFunction { 27 | 28 | public boolean eval(Float lon, Float lat) { 29 | return isInNYC(lon, lat); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /images/client-image/java/sql-training-udfs/src/main/java/com/ververica/sql_training/udfs/ToAreaId.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ververica GmbH 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.ververica.sql_training.udfs; 18 | 19 | import org.apache.flink.table.functions.ScalarFunction; 20 | 21 | import com.ververica.sql_training.udfs.util.GeoUtils; 22 | 23 | /** 24 | * Table API / SQL Scalar UDF to convert a lon/lat pair into a cell ID. 25 | */ 26 | public class ToAreaId extends ScalarFunction { 27 | 28 | public int eval(Float lon, Float lat) { 29 | return GeoUtils.mapToGridCell(lon, lat); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /images/client-image/java/sql-training-udfs/src/main/java/com/ververica/sql_training/udfs/ToCoords.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ververica GmbH 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.ververica.sql_training.udfs; 18 | 19 | import org.apache.flink.table.annotation.DataTypeHint; 20 | import org.apache.flink.table.functions.ScalarFunction; 21 | import org.apache.flink.types.Row; 22 | 23 | import com.ververica.sql_training.udfs.util.GeoUtils; 24 | 25 | /** 26 | * Table API / SQL Scalar UDF to convert a cell ID into a lon/lat pair. 27 | */ 28 | public class ToCoords extends ScalarFunction { 29 | 30 | @DataTypeHint("ROW") 31 | public Row eval(Integer cellId) { 32 | return Row.of( 33 | GeoUtils.getGridCellCenterLon(cellId), 34 | GeoUtils.getGridCellCenterLat(cellId) 35 | ); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /images/client-image/java/sql-training-data-producer/src/main/java/com/ververica/sql_training/data_producer/ConsolePrinter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ververica GmbH 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.ververica.sql_training.data_producer; 18 | 19 | import com.ververica.sql_training.data_producer.json_serde.JsonSerializer; 20 | import com.ververica.sql_training.data_producer.records.TaxiRecord; 21 | 22 | import java.util.function.Consumer; 23 | 24 | /** 25 | * Prints TaxiRecords as JSON strings on the standard output. 26 | */ 27 | public class ConsolePrinter implements Consumer { 28 | 29 | private final JsonSerializer serializer = new JsonSerializer<>(); 30 | 31 | @Override 32 | public void accept(TaxiRecord record) { 33 | String jsonString = serializer.toJSONString(record); 34 | System.out.println(jsonString); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /images/client-image/java/sql-training-udfs/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.ververica.sql-training 8 | sql-training-udfs 9 | 2-FLINK-1.11_2.11 10 | 11 | 12 | 1.11.1 13 | 14 | 15 | 16 | 17 | org.apache.flink 18 | flink-table-common 19 | ${flink.version} 20 | 21 | 22 | org.apache.flink 23 | flink-streaming-java_2.11 24 | ${flink.version} 25 | 26 | 27 | 28 | 29 | 30 | 31 | org.apache.maven.plugins 32 | maven-compiler-plugin 33 | 34 | 8 35 | 8 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /images/client-image/java/sql-training-data-producer/src/main/java/com/ververica/sql_training/data_producer/records/DriverChange.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ververica GmbH 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.ververica.sql_training.data_producer.records; 18 | 19 | import com.fasterxml.jackson.annotation.JsonFormat; 20 | 21 | import java.util.Date; 22 | 23 | /** 24 | * POJO for a DriverChange record. 25 | */ 26 | public class DriverChange implements TaxiRecord { 27 | 28 | @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'") 29 | private Date eventTime; 30 | @JsonFormat 31 | private long taxiId; 32 | @JsonFormat 33 | private long driverId; 34 | 35 | public DriverChange() {} 36 | 37 | public DriverChange(Date eventTime, long taxiId, long driverId) { 38 | this.eventTime = eventTime; 39 | this.taxiId = taxiId; 40 | this.driverId = driverId; 41 | } 42 | 43 | @Override 44 | public Date getEventTime() { 45 | return eventTime; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /images/client-image/java/sql-training-data-producer/src/main/java/com/ververica/sql_training/data_producer/json_serde/JsonDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ververica GmbH 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.ververica.sql_training.data_producer.json_serde; 18 | 19 | import com.fasterxml.jackson.databind.ObjectMapper; 20 | 21 | import java.io.IOException; 22 | 23 | /** 24 | * Deserializes a record from a JSON string. 25 | * 26 | * @param The type of the deserialized record. 27 | */ 28 | public class JsonDeserializer { 29 | 30 | private final Class recordClazz; 31 | private final ObjectMapper jsonMapper; 32 | 33 | public JsonDeserializer(Class recordClazz) { 34 | this.recordClazz = recordClazz; 35 | this.jsonMapper = new ObjectMapper(); 36 | } 37 | 38 | public T parseFromString(String line) { 39 | try { 40 | return jsonMapper.readValue(line, this.recordClazz); 41 | } catch (IOException e) { 42 | throw new IllegalArgumentException("Could not deserialize record: " + line + " as class " + recordClazz, e); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /images/client-image/java/sql-training-data-producer/src/main/java/com/ververica/sql_training/data_producer/json_serde/JsonSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ververica GmbH 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.ververica.sql_training.data_producer.json_serde; 18 | 19 | import com.fasterxml.jackson.core.JsonProcessingException; 20 | import com.fasterxml.jackson.databind.ObjectMapper; 21 | 22 | /** 23 | * Serializes a record as JSON string. 24 | * 25 | * @param The type for the records to serialize. 26 | */ 27 | public class JsonSerializer { 28 | 29 | private final ObjectMapper jsonMapper = new ObjectMapper(); 30 | 31 | public String toJSONString(T r) { 32 | try { 33 | return jsonMapper.writeValueAsString(r); 34 | } catch (JsonProcessingException e) { 35 | throw new IllegalArgumentException("Could not serialize record: " + r, e); 36 | } 37 | } 38 | 39 | public byte[] toJSONBytes(T r) { 40 | try { 41 | return jsonMapper.writeValueAsBytes(r); 42 | } catch (JsonProcessingException e) { 43 | throw new IllegalArgumentException("Could not serialize record: " + r, e); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /images/client-image/java/sql-training-data-producer/src/main/java/com/ververica/sql_training/data_producer/records/Ride.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ververica GmbH 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.ververica.sql_training.data_producer.records; 18 | 19 | import com.fasterxml.jackson.annotation.JsonFormat; 20 | 21 | import java.util.Date; 22 | 23 | /** 24 | * POJO for a Ride record. 25 | */ 26 | public class Ride implements TaxiRecord { 27 | 28 | @JsonFormat 29 | private long rideId; 30 | @JsonFormat 31 | private boolean isStart; 32 | @JsonFormat 33 | private long taxiId; 34 | @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'") 35 | private Date eventTime; 36 | @JsonFormat 37 | private double lon; 38 | @JsonFormat 39 | private double lat; 40 | @JsonFormat 41 | private byte psgCnt; 42 | 43 | public Ride() {} 44 | 45 | public Ride(long rideId, boolean isStart, long taxiId, Date eventTime, double lon, double lat, byte psgCnt) { 46 | this.rideId = rideId; 47 | this.isStart = isStart; 48 | this.taxiId = taxiId; 49 | this.eventTime = eventTime; 50 | this.lon = lon; 51 | this.lat = lat; 52 | this.psgCnt = psgCnt; 53 | } 54 | 55 | @Override 56 | public Date getEventTime() { 57 | return eventTime; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /images/flink-image/Dockerfile: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright 2020 Ververica GmbH 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | ############################################################################### 16 | 17 | ############################################################################### 18 | # Build Flink images with configured S3 plugin 19 | ############################################################################### 20 | 21 | FROM flink:1.11.1-scala_2.11 22 | 23 | # move and download dependencies 24 | RUN mkdir /opt/flink/plugins/s3; \ 25 | mv /opt/flink/opt/flink-s3-fs-hadoop-1.11.1.jar /opt/flink/plugins/s3; \ 26 | wget -P /opt/flink/lib https://repo.maven.apache.org/maven2/org/apache/flink/flink-shaded-hadoop-2-uber/2.7.5-8.0/flink-shaded-hadoop-2-uber-2.7.5-8.0.jar; 27 | 28 | # adjust configuration 29 | RUN echo "s3.access-key: flink-sql" >> /opt/flink/conf/flink-conf.yaml; \ 30 | echo "s3.secret-key: flink-sql" >> /opt/flink/conf/flink-conf.yaml; \ 31 | echo "fs.s3a.endpoint: http://minio:9000" >> /opt/flink/conf/flink-conf.yaml; \ 32 | echo "fs.s3a.path.style.access: true" >> /opt/flink/conf/flink-conf.yaml; \ 33 | sed -i -e 's/taskmanager.memory.process.size: 1568m/taskmanager.memory.process.size: 1728m/g' /opt/flink/conf/flink-conf.yaml; \ 34 | echo "taskmanager.memory.jvm-metaspace.size: 256m" >> /opt/flink/conf/flink-conf.yaml; 35 | -------------------------------------------------------------------------------- /images/client-image/java/sql-training-data-producer/src/main/java/com/ververica/sql_training/data_producer/records/Fare.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ververica GmbH 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.ververica.sql_training.data_producer.records; 18 | 19 | import com.fasterxml.jackson.annotation.JsonFormat; 20 | 21 | import java.util.Date; 22 | 23 | /** 24 | * POJO for a Fare record. 25 | */ 26 | public class Fare implements TaxiRecord { 27 | 28 | @JsonFormat 29 | private long rideId; 30 | @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'") 31 | private Date eventTime; 32 | @JsonFormat(shape = JsonFormat.Shape.STRING) 33 | private PayMethod payMethod; 34 | @JsonFormat 35 | private double fare; 36 | @JsonFormat 37 | private double toll; 38 | @JsonFormat 39 | private double tip; 40 | 41 | public Fare() {} 42 | 43 | public Fare(long rideId, Date eventTime, PayMethod payMethod, double fare, double toll, double tip) { 44 | this.rideId = rideId; 45 | this.eventTime = eventTime; 46 | this.payMethod = payMethod; 47 | this.fare = fare; 48 | this.toll = toll; 49 | this.tip = tip; 50 | } 51 | 52 | @Override 53 | public Date getEventTime() { 54 | return eventTime; 55 | } 56 | 57 | public static enum PayMethod { 58 | CSH, 59 | CRD, 60 | DIS, 61 | NOC, 62 | UNK 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Apache Flink® SQL Training 2 | 3 | **This repository provides a training for Flink's SQL API.** 4 | 5 | In this training you will learn to: 6 | 7 | * run SQL queries on streams. 8 | * use Flink's SQL CLI client. 9 | * perform window aggregations, stream joins, and pattern matching with SQL queries. 10 | * specify a continuous SQL query that maintain a dynamic result table. 11 | * write the result of streaming SQL queries to Kafka and MySQL. 12 | 13 | Please find the [training instructions](https://github.com/ververica/sql-training/wiki) in the Wiki of this repository. 14 | 15 | ### Requirements 16 | 17 | The training is based on Flink's SQL CLI client and uses Docker Compose to setup the training environment. 18 | 19 | You **only need [Docker](https://www.docker.com/)** to run this training.
20 | You don't need Java, Scala, or an IDE. 21 | 22 | ## What is Apache Flink? 23 | 24 | [Apache Flink](https://flink.apache.org) is a framework and distributed processing engine for stateful computations over unbounded and bounded data streams. Flink has been designed to run in all common cluster environments, perform computations at in-memory speed and at any scale. 25 | 26 | ## What is SQL on Apache Flink? 27 | 28 | Flink features multiple APIs with different levels of abstraction. SQL is supported by Flink as a unified API for batch and stream processing, i.e., queries are executed with the same semantics on unbounded, real-time streams or bounded, recorded streams and produce the same results. SQL on Flink is commonly used to ease the definition of data analytics, data pipelining, and ETL applications. 29 | 30 | The following example shows a SQL query that computes the number of departing taxi rides per hour. 31 | 32 | ```sql 33 | SELECT 34 | TUMBLE_START(rowTime, INTERVAL '1' HOUR) AS t, 35 | COUNT(*) AS cnt 36 | FROM Rides 37 | WHERE 38 | isStart 39 | GROUP BY 40 | TUMBLE(rowTime, INTERVAL '1' HOUR) 41 | ``` 42 | 43 | ---- 44 | 45 | *Apache Flink, Flink®, Apache®, the squirrel logo, and the Apache feather logo are either registered trademarks or trademarks of The Apache Software Foundation.* 46 | -------------------------------------------------------------------------------- /images/client-image/java/sql-training-data-producer/src/main/java/com/ververica/sql_training/data_producer/FileReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ververica GmbH 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.ververica.sql_training.data_producer; 18 | 19 | import com.ververica.sql_training.data_producer.json_serde.JsonDeserializer; 20 | import com.ververica.sql_training.data_producer.records.TaxiRecord; 21 | 22 | import java.io.*; 23 | import java.nio.charset.StandardCharsets; 24 | import java.util.Iterator; 25 | import java.util.NoSuchElementException; 26 | import java.util.function.Supplier; 27 | import java.util.stream.Stream; 28 | import java.util.zip.GZIPInputStream; 29 | 30 | /** 31 | * Reads JSON-encoded TaxiRecords from a gzipped text file. 32 | */ 33 | public class FileReader implements Supplier { 34 | 35 | private final Iterator records; 36 | private final String filePath; 37 | 38 | public FileReader(String filePath, Class recordClazz) throws IOException { 39 | 40 | this.filePath = filePath; 41 | JsonDeserializer deserializer = new JsonDeserializer<>(recordClazz); 42 | try { 43 | 44 | BufferedReader reader = new BufferedReader( 45 | new InputStreamReader(new GZIPInputStream(new FileInputStream(filePath)), StandardCharsets.UTF_8)); 46 | 47 | Stream lines = reader.lines().sequential(); 48 | records = lines.map(l -> (TaxiRecord) deserializer.parseFromString(l)).iterator(); 49 | 50 | } catch (IOException e) { 51 | throw new IOException("Error reading TaxiRecords from file: " + filePath, e); 52 | } 53 | } 54 | 55 | @Override 56 | public TaxiRecord get() { 57 | 58 | if (records.hasNext()) { 59 | return records.next(); 60 | } else { 61 | throw new NoSuchElementException("All records read from " + filePath); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2.1' 2 | services: 3 | sql-client: 4 | image: fhueske/flink-sql-training-client:2-FLINK-1.11-scala_2.11 5 | build: ./images/client-image 6 | command: "java -classpath /opt/data/data-producer.jar com.ververica.sql_training.data_producer.TaxiRecordProducer --input file /opt/data --output kafka kafka:9092 --speedup 10.0" 7 | depends_on: 8 | - kafka 9 | - jobmanager 10 | - mysql 11 | - minio 12 | environment: 13 | FLINK_JOBMANAGER_HOST: jobmanager 14 | ZOOKEEPER_CONNECT: zookeeper 15 | KAFKA_BOOTSTRAP: kafka 16 | MYSQL_HOST: mysql 17 | jobmanager: 18 | image: fhueske/flink-sql-training-flink-s3:1.11.1-scala_2.11 19 | build: ./images/flink-image 20 | hostname: "jobmanager" 21 | expose: 22 | - "6123" 23 | ports: 24 | - "8081:8081" 25 | command: jobmanager 26 | environment: 27 | - JOB_MANAGER_RPC_ADDRESS=jobmanager 28 | taskmanager: 29 | image: fhueske/flink-sql-training-flink-s3:1.11.1-scala_2.11 30 | build: ./images/flink-image 31 | expose: 32 | - "6121" 33 | - "6122" 34 | depends_on: 35 | - jobmanager 36 | command: taskmanager 37 | links: 38 | - jobmanager:jobmanager 39 | environment: 40 | - JOB_MANAGER_RPC_ADDRESS=jobmanager 41 | zookeeper: 42 | image: wurstmeister/zookeeper:3.4.6 43 | ports: 44 | - "2181:2181" 45 | kafka: 46 | image: wurstmeister/kafka:2.12-2.2.1 47 | ports: 48 | - "9092:9092" 49 | depends_on: 50 | - zookeeper 51 | environment: 52 | KAFKA_ADVERTISED_HOST_NAME: "kafka" 53 | KAFKA_ADVERTISED_PORT: "9092" 54 | HOSTNAME_COMMAND: "route -n | awk '/UG[ \t]/{print $$2}'" 55 | KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 56 | KAFKA_CREATE_TOPICS: "Rides:1:1, Fares:1:1, DriverChanges:1:1" 57 | volumes: 58 | - /var/run/docker.sock:/var/run/docker.sock 59 | mysql: 60 | image: mysql:8.0.19 61 | command: --default-authentication-plugin=mysql_native_password 62 | environment: 63 | MYSQL_USER: "flink" 64 | MYSQL_PASSWORD: "secret" 65 | MYSQL_DATABASE: "flinksql" 66 | MYSQL_RANDOM_ROOT_PASSWORD: "yes" 67 | volumes: 68 | - ./mysql:/docker-entrypoint-initdb.d 69 | minio: 70 | image: minio/minio:latest 71 | entrypoint: sh 72 | command: -c 'mkdir -p /data/sql-training && /usr/bin/minio server /data' 73 | environment: 74 | - MINIO_ACCESS_KEY=flink-sql 75 | - MINIO_SECRET_KEY=flink-sql 76 | expose: 77 | - "9000" 78 | ports: 79 | - "9000:9000" 80 | -------------------------------------------------------------------------------- /images/client-image/java/sql-training-data-producer/src/main/java/com/ververica/sql_training/data_producer/KafkaProducer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ververica GmbH 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.ververica.sql_training.data_producer; 18 | 19 | import com.ververica.sql_training.data_producer.json_serde.JsonSerializer; 20 | import com.ververica.sql_training.data_producer.records.TaxiRecord; 21 | import org.apache.kafka.clients.producer.ProducerConfig; 22 | import org.apache.kafka.clients.producer.ProducerRecord; 23 | import org.apache.kafka.common.serialization.ByteArraySerializer; 24 | 25 | import java.util.Properties; 26 | import java.util.function.Consumer; 27 | 28 | /** 29 | * Produces TaxiRecords into a Kafka topic. 30 | */ 31 | public class KafkaProducer implements Consumer { 32 | 33 | private final String topic; 34 | private final org.apache.kafka.clients.producer.KafkaProducer producer; 35 | private final JsonSerializer serializer; 36 | 37 | public KafkaProducer(String kafkaTopic, String kafkaBrokers) { 38 | this.topic = kafkaTopic; 39 | this.producer = new org.apache.kafka.clients.producer.KafkaProducer<>(createKafkaProperties(kafkaBrokers)); 40 | this.serializer = new JsonSerializer<>(); 41 | } 42 | 43 | @Override 44 | public void accept(TaxiRecord record) { 45 | // serialize record as JSON 46 | byte[] data = serializer.toJSONBytes(record); 47 | // create producer record and publish to Kafka 48 | ProducerRecord kafkaRecord = new ProducerRecord<>(topic, data); 49 | producer.send(kafkaRecord); 50 | } 51 | 52 | /** 53 | * Create configuration properties for Kafka producer. 54 | * 55 | * @param brokers The brokers to connect to. 56 | * @return A Kafka producer configuration. 57 | */ 58 | private static Properties createKafkaProperties(String brokers) { 59 | Properties kafkaProps = new Properties(); 60 | kafkaProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, brokers); 61 | kafkaProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, ByteArraySerializer.class.getCanonicalName()); 62 | kafkaProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, ByteArraySerializer.class.getCanonicalName()); 63 | return kafkaProps; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /images/client-image/Dockerfile: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright 2020 Ververica GmbH 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | ############################################################################### 16 | 17 | ############################################################################### 18 | # Build Click Count Job 19 | ############################################################################### 20 | 21 | FROM maven:3.6-jdk-8-slim AS builder 22 | 23 | # Get UDF code and compile it 24 | COPY ./java/sql-training-udfs /opt/sql-udfs 25 | RUN cd /opt/sql-udfs; \ 26 | mvn clean install 27 | 28 | # Get data producer code and compile it 29 | COPY ./java/sql-training-data-producer /opt/data-producer 30 | RUN cd /opt/data-producer; \ 31 | mvn clean install 32 | 33 | ############################################################################### 34 | # Build SQL Playground Image 35 | ############################################################################### 36 | 37 | FROM flink:1.11.1-scala_2.11 38 | 39 | ARG FLINK_VERSION=1.11.1 40 | 41 | ADD VERSION . 42 | 43 | # Copy sql-client configuration 44 | COPY sql-client/ /opt/sql-client 45 | 46 | # Copy playground UDFs 47 | COPY --from=builder /opt/sql-udfs/target/sql-training-udfs-*.jar /opt/sql-client/lib/ 48 | 49 | # Copy data producer 50 | COPY --from=builder /opt/data-producer/target/sql-training-data-producer-*.jar /opt/data/data-producer.jar 51 | 52 | # Download connector libraries 53 | RUN wget -P /opt/sql-client/lib/ https://repo.maven.apache.org/maven2/org/apache/flink/flink-json/${FLINK_VERSION}/flink-json-${FLINK_VERSION}.jar; \ 54 | wget -P /opt/sql-client/lib/ https://repo.maven.apache.org/maven2/org/apache/flink/flink-sql-connector-kafka_2.11/${FLINK_VERSION}/flink-sql-connector-kafka_2.11-${FLINK_VERSION}.jar; \ 55 | wget -P /opt/sql-client/lib/ https://repo.maven.apache.org/maven2/org/apache/flink/flink-connector-filesystem_2.11/${FLINK_VERSION}/flink-connector-filesystem_2.11-${FLINK_VERSION}.jar; \ 56 | wget -P /opt/flink/lib https://repo.maven.apache.org/maven2/org/apache/flink/flink-shaded-hadoop-2-uber/2.7.5-8.0/flink-shaded-hadoop-2-uber-2.7.5-8.0.jar; \ 57 | wget -P /opt/sql-client/lib/ https://repo.maven.apache.org/maven2/org/apache/flink/flink-connector-jdbc_2.11/${FLINK_VERSION}/flink-connector-jdbc_2.11-${FLINK_VERSION}.jar; \ 58 | wget -P /opt/sql-client/lib/ https://repo.maven.apache.org/maven2/mysql/mysql-connector-java/8.0.19/mysql-connector-java-8.0.19.jar; \ 59 | # Create data folders 60 | mkdir -p /opt/data; \ 61 | mkdir -p /opt/data/stream; \ 62 | # Download data files 63 | wget -O /opt/data/driverChanges.txt.gz 'https://drive.google.com/uc?export=download&id=1pf4tfv-YpoVQ9_O0948M8oXeCfVH-0MH'; \ 64 | wget -O /opt/data/fares.txt.gz 'https://drive.google.com/uc?export=download&id=1SriiwcIdMvY7uJsWSY4Hhh32iO3F4ND2'; \ 65 | wget -O /opt/data/rides.txt.gz 'https://drive.google.com/uc?export=download&id=1gY8W07OFvB7_4lHlAyingM4WQzs0_8lT'; 66 | 67 | # Copy configuration 68 | COPY conf/* /opt/flink/conf/ 69 | 70 | WORKDIR /opt/sql-client 71 | ENV SQL_CLIENT_HOME /opt/sql-client 72 | -------------------------------------------------------------------------------- /images/client-image/java/sql-training-udfs/src/main/java/com/ververica/sql_training/udfs/util/GeoUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ververica GmbH 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.ververica.sql_training.udfs.util; 18 | 19 | /** 20 | * GeoUtils provides utility methods to deal with locations in New York City. 21 | */ 22 | public class GeoUtils { 23 | 24 | // geo boundaries of the area of NYC 25 | private static double LON_EAST = -73.7; 26 | private static double LON_WEST = -74.05; 27 | private static double LAT_NORTH = 41.0; 28 | private static double LAT_SOUTH = 40.5; 29 | 30 | // delta step to create artificial grid overlay of NYC 31 | private static double DELTA_LON = 0.0014; 32 | private static double DELTA_LAT = 0.00125; 33 | 34 | // ( |LON_WEST| - |LON_EAST| ) / DELTA_LAT 35 | private static int NUMBER_OF_GRID_X = 250; 36 | // ( LAT_NORTH - LAT_SOUTH ) / DELTA_LON 37 | private static int NUMBER_OF_GRID_Y = 400; 38 | 39 | /** 40 | * Checks if a location specified by longitude and latitude values is 41 | * within the geo boundaries of New York City. 42 | * 43 | * @param lon longitude of the location to check 44 | * @param lat latitude of the location to check 45 | * 46 | * @return true if the location is within NYC boundaries, otherwise false. 47 | */ 48 | public static boolean isInNYC(float lon, float lat) { 49 | 50 | return !(lon > LON_EAST || lon < LON_WEST) && 51 | !(lat > LAT_NORTH || lat < LAT_SOUTH); 52 | } 53 | 54 | /** 55 | * Maps a location specified by latitude and longitude values to a cell of a 56 | * grid covering the area of NYC. 57 | * The grid cells are roughly 100 x 100 m and sequentially number from north-west 58 | * to south-east starting by zero. 59 | * 60 | * @param lon longitude of the location to map 61 | * @param lat latitude of the location to map 62 | * 63 | * @return id of mapped grid cell. 64 | */ 65 | public static int mapToGridCell(float lon, float lat) { 66 | int xIndex = (int) Math.floor((Math.abs(LON_WEST) - Math.abs(lon)) / DELTA_LON); 67 | int yIndex = (int) Math.floor((LAT_NORTH - lat) / DELTA_LAT); 68 | 69 | return xIndex + (yIndex * NUMBER_OF_GRID_X); 70 | } 71 | 72 | /** 73 | * Returns the longitude of the center of a grid cell. 74 | * 75 | * @param gridCellId The grid cell. 76 | * 77 | * @return The longitude value of the cell's center. 78 | */ 79 | public static float getGridCellCenterLon(int gridCellId) { 80 | 81 | int xIndex = gridCellId % NUMBER_OF_GRID_X; 82 | 83 | return (float) (Math.abs(LON_WEST) - (xIndex * DELTA_LON) - (DELTA_LON / 2)) * -1.0f; 84 | } 85 | 86 | /** 87 | * Returns the latitude of the center of a grid cell. 88 | * 89 | * @param gridCellId The grid cell. 90 | * 91 | * @return The latitude value of the cell's center. 92 | */ 93 | public static float getGridCellCenterLat(int gridCellId) { 94 | 95 | int xIndex = gridCellId % NUMBER_OF_GRID_X; 96 | int yIndex = (gridCellId - xIndex) / NUMBER_OF_GRID_X; 97 | 98 | return (float) (LAT_NORTH - (yIndex * DELTA_LAT) - (DELTA_LAT / 2)); 99 | } 100 | } 101 | 102 | -------------------------------------------------------------------------------- /images/client-image/java/sql-training-data-producer/src/main/java/com/ververica/sql_training/data_producer/Delayer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ververica GmbH 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.ververica.sql_training.data_producer; 18 | 19 | import com.ververica.sql_training.data_producer.records.TaxiRecord; 20 | 21 | import java.time.Instant; 22 | import java.util.function.UnaryOperator; 23 | 24 | /** 25 | * Delays forwarding of TaxiRecords based on their timestamp. 26 | * By default, records that have timestamps that are 10 minutes apart from each other are emitted 27 | * 10 minutes apart from each other. 28 | * 29 | * The emission rate can be adjusted by a speedup factor. With a speedup of 10.0, records that have 30 | * timestamps which are 10 minutes apart from each other are emitted with a 1 minute gap. 31 | * 32 | * The delayer assumes that records are provided with monotonically increasing timestamps. 33 | */ 34 | public class Delayer implements UnaryOperator { 35 | 36 | // the speedup factor 37 | private final double speedUp; 38 | // the machine time when the delayer was instantiated. 39 | private final long startTime; 40 | // the event time of the first processed record 41 | private long startEventTime = -1; 42 | // the event time of the last processed record 43 | private long prevEventTime; 44 | // a counter to sync emission on machine time 45 | private int syncCounter = 0; 46 | 47 | public Delayer() { 48 | this(1.0); 49 | } 50 | 51 | public Delayer(double speedUp) { 52 | this.speedUp = speedUp; 53 | this.startTime = Instant.now().toEpochMilli(); 54 | } 55 | 56 | @Override 57 | public TaxiRecord apply(TaxiRecord record) { 58 | long thisEventTime = record.getEventTime().getTime(); 59 | 60 | if (startEventTime < 0) { 61 | // remember event time of first record 62 | startEventTime = thisEventTime; 63 | } else { 64 | // how much time to wait between the previous and this record 65 | long gapTime = (long) ((thisEventTime - prevEventTime) / speedUp); 66 | 67 | if (gapTime > 0 || syncCounter > 1000) { 68 | // syncing on machine time at least every 1000 records 69 | 70 | // compute how many machine time ms to wait before emitting the record 71 | long currentTime = Instant.now().toEpochMilli(); 72 | long targetEmitTime = (long) ((thisEventTime - startEventTime) / speedUp) + startTime; 73 | long waitTime = targetEmitTime - currentTime; 74 | 75 | // wait if necessary 76 | if (waitTime > 0) { 77 | try { 78 | Thread.sleep(waitTime); 79 | } catch (InterruptedException e) { 80 | e.printStackTrace(); 81 | } 82 | } 83 | // reset sync counter 84 | syncCounter = 0; 85 | } else { 86 | // we emitted without syncing on time. Increment counter. 87 | syncCounter++; 88 | } 89 | } 90 | 91 | this.prevEventTime = thisEventTime; 92 | 93 | return record; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /images/client-image/java/sql-training-data-producer/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.ververica.sql-training 8 | sql-training-data-producer 9 | 2-FLINK-1.11_2.11 10 | 11 | 12 | UTF-8 13 | 1.11.1 14 | 2.2.0 15 | 1.8 16 | 2.11 17 | ${java.version} 18 | ${java.version} 19 | 20 | 21 | 22 | 23 | org.apache.kafka 24 | kafka-clients 25 | ${kafka.version} 26 | 27 | 28 | 29 | com.fasterxml.jackson.core 30 | jackson-databind 31 | 2.10.4 32 | 33 | 34 | 35 | 36 | org.slf4j 37 | slf4j-log4j12 38 | 1.7.7 39 | runtime 40 | 41 | 42 | log4j 43 | log4j 44 | 1.2.17 45 | runtime 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | org.apache.maven.plugins 55 | maven-compiler-plugin 56 | 3.1 57 | 58 | ${java.version} 59 | ${java.version} 60 | 61 | 62 | 63 | 64 | 65 | org.apache.maven.plugins 66 | maven-shade-plugin 67 | 3.0.0 68 | 69 | 70 | 71 | package 72 | 73 | shade 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 84 | *:* 85 | 86 | META-INF/*.SF 87 | META-INF/*.DSA 88 | META-INF/*.RSA 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /images/client-image/java/sql-training-data-producer/src/main/java/com/ververica/sql_training/data_producer/TaxiRecordProducer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Ververica GmbH 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.ververica.sql_training.data_producer; 18 | 19 | import com.ververica.sql_training.data_producer.records.DriverChange; 20 | import com.ververica.sql_training.data_producer.records.Fare; 21 | import com.ververica.sql_training.data_producer.records.Ride; 22 | import com.ververica.sql_training.data_producer.records.TaxiRecord; 23 | 24 | import java.io.IOException; 25 | import java.util.function.Consumer; 26 | import java.util.function.Supplier; 27 | import java.util.stream.Stream; 28 | 29 | /** 30 | * Produces TaxiRecords (Ride, Fare, DriverChange) into Kafka topics. 31 | */ 32 | public class TaxiRecordProducer { 33 | 34 | public static void main(String[] args) throws InterruptedException { 35 | 36 | boolean areSuppliersConfigured = false; 37 | boolean areConsumersConfigured = false; 38 | 39 | Supplier rideSupplier = null; 40 | Supplier fareSupplier = null; 41 | Supplier driverChangeSupplier = null; 42 | 43 | Consumer rideConsumer = null; 44 | Consumer fareConsumer = null; 45 | Consumer driverChangeConsumer = null; 46 | 47 | double speedup = 1.0d; 48 | 49 | // parse arguments 50 | int argOffset = 0; 51 | while(argOffset < args.length) { 52 | 53 | String arg = args[argOffset++]; 54 | switch (arg) { 55 | case "--input": 56 | String source = args[argOffset++]; 57 | switch (source) { 58 | case "file": 59 | String basePath = args[argOffset++]; 60 | try { 61 | rideSupplier = new FileReader(basePath + "/rides.txt.gz", Ride.class); 62 | fareSupplier = new FileReader(basePath + "/fares.txt.gz", Fare.class); 63 | driverChangeSupplier = new FileReader(basePath + "/driverChanges.txt.gz", DriverChange.class); 64 | } catch (IOException e) { 65 | e.printStackTrace(); 66 | } 67 | break; 68 | default: 69 | throw new IllegalArgumentException("Unknown input configuration"); 70 | } 71 | areSuppliersConfigured = true; 72 | break; 73 | case "--output": 74 | String sink = args[argOffset++]; 75 | switch (sink) { 76 | case "console": 77 | rideConsumer = new ConsolePrinter(); 78 | fareConsumer = new ConsolePrinter(); 79 | driverChangeConsumer = new ConsolePrinter(); 80 | break; 81 | case "kafka": 82 | String brokers = args[argOffset++]; 83 | rideConsumer = new KafkaProducer("Rides", brokers); 84 | fareConsumer = new KafkaProducer("Fares", brokers); 85 | driverChangeConsumer = new KafkaProducer("DriverChanges", brokers); 86 | break; 87 | default: 88 | throw new IllegalArgumentException("Unknown output configuration"); 89 | } 90 | areConsumersConfigured = true; 91 | break; 92 | case "--speedup": 93 | speedup = Double.parseDouble(args[argOffset++]); 94 | break; 95 | default: 96 | throw new IllegalArgumentException("Unknown parameter"); 97 | } 98 | } 99 | 100 | // check if we have a source and a sink 101 | if (!areSuppliersConfigured) { 102 | throw new IllegalArgumentException("Input sources were not properly configured."); 103 | } 104 | if (!areConsumersConfigured) { 105 | throw new IllegalArgumentException("Output sinks were not properly configured"); 106 | } 107 | 108 | // create three threads for each record type 109 | Thread ridesFeeder = new Thread(new TaxiRecordFeeder(rideSupplier, new Delayer(speedup), rideConsumer)); 110 | Thread faresFeeder = new Thread(new TaxiRecordFeeder(fareSupplier, new Delayer(speedup), fareConsumer)); 111 | Thread driverChangesFeeder = new Thread(new TaxiRecordFeeder(driverChangeSupplier, new Delayer(speedup), driverChangeConsumer)); 112 | 113 | // start emitting data 114 | ridesFeeder.start(); 115 | faresFeeder.start(); 116 | driverChangesFeeder.start(); 117 | 118 | // wait for threads to complete 119 | ridesFeeder.join(); 120 | faresFeeder.join(); 121 | driverChangesFeeder.join(); 122 | } 123 | 124 | public static class TaxiRecordFeeder implements Runnable { 125 | 126 | private final Supplier source; 127 | private final Delayer delayer; 128 | private final Consumer sink; 129 | 130 | TaxiRecordFeeder(Supplier source, Delayer delayer, Consumer sink) { 131 | this.source = source; 132 | this.delayer = delayer; 133 | this.sink = sink; 134 | } 135 | 136 | @Override 137 | public void run() { 138 | Stream.generate(source).sequential() 139 | .map(delayer) 140 | .forEachOrdered(sink); 141 | } 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /images/client-image/conf/sql-client-conf.yaml: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Copyright 2019 Ververica GmbH 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | ################################################################################ 16 | 17 | 18 | # This file defines the default environment for Flink's SQL Client. 19 | # Defaults might be overwritten by a session specific environment. 20 | 21 | 22 | #============================================================================== 23 | # Table Sources 24 | #============================================================================== 25 | 26 | # Define table sources here. See the Table API & SQL documentation for details. 27 | 28 | tables: 29 | - name: Rides 30 | type: source 31 | update-mode: append 32 | schema: 33 | - name: rideId 34 | type: LONG 35 | - name: taxiId 36 | type: LONG 37 | - name: isStart 38 | type: BOOLEAN 39 | - name: lon 40 | type: FLOAT 41 | - name: lat 42 | type: FLOAT 43 | - name: rideTime 44 | type: TIMESTAMP 45 | rowtime: 46 | timestamps: 47 | type: "from-field" 48 | from: "eventTime" 49 | watermarks: 50 | type: "periodic-bounded" 51 | delay: "60000" 52 | - name: psgCnt 53 | type: INT 54 | connector: 55 | property-version: 1 56 | type: kafka 57 | version: universal 58 | topic: Rides 59 | startup-mode: earliest-offset 60 | properties: 61 | - key: zookeeper.connect 62 | value: zookeeper:2181 63 | - key: bootstrap.servers 64 | value: kafka:9092 65 | - key: group.id 66 | value: testGroup 67 | format: 68 | property-version: 1 69 | type: json 70 | schema: "ROW(rideId LONG, isStart BOOLEAN, eventTime TIMESTAMP, lon FLOAT, lat FLOAT, psgCnt INT, taxiId LONG)" 71 | - name: Fares 72 | type: source 73 | update-mode: append 74 | schema: 75 | - name: rideId 76 | type: LONG 77 | - name: payTime 78 | type: TIMESTAMP 79 | rowtime: 80 | timestamps: 81 | type: "from-field" 82 | from: "eventTime" 83 | watermarks: 84 | type: "periodic-bounded" 85 | delay: "60000" 86 | - name: payMethod 87 | type: STRING 88 | - name: tip 89 | type: FLOAT 90 | - name: toll 91 | type: FLOAT 92 | - name: fare 93 | type: FLOAT 94 | connector: 95 | property-version: 1 96 | type: kafka 97 | version: universal 98 | topic: Fares 99 | startup-mode: earliest-offset 100 | properties: 101 | - key: zookeeper.connect 102 | value: zookeeper:2181 103 | - key: bootstrap.servers 104 | value: kafka:9092 105 | - key: group.id 106 | value: testGroup 107 | format: 108 | property-version: 1 109 | type: json 110 | schema: "ROW(rideId LONG, eventTime TIMESTAMP, payMethod STRING, tip FLOAT, toll FLOAT, fare FLOAT)" 111 | - name: DriverChanges 112 | type: source 113 | update-mode: append 114 | schema: 115 | - name: taxiId 116 | type: LONG 117 | - name: driverId 118 | type: LONG 119 | - name: usageStartTime 120 | type: TIMESTAMP 121 | rowtime: 122 | timestamps: 123 | type: "from-field" 124 | from: "eventTime" 125 | watermarks: 126 | type: "periodic-bounded" 127 | delay: "60000" 128 | connector: 129 | property-version: 1 130 | type: kafka 131 | version: universal 132 | topic: DriverChanges 133 | startup-mode: earliest-offset 134 | properties: 135 | - key: zookeeper.connect 136 | value: zookeeper:2181 137 | - key: bootstrap.servers 138 | value: kafka:9092 139 | - key: group.id 140 | value: testGroup 141 | format: 142 | property-version: 1 143 | type: json 144 | schema: "ROW(eventTime TIMESTAMP, taxiId LONG, driverId LONG)" 145 | - name: Drivers 146 | type: temporal-table 147 | history-table: DriverChanges 148 | primary-key: taxiId 149 | time-attribute: usageStartTime 150 | 151 | functions: 152 | - name: isInNYC 153 | from: class 154 | class: com.ververica.sql_training.udfs.IsInNYC 155 | - name: toAreaId 156 | from: class 157 | class: com.ververica.sql_training.udfs.ToAreaId 158 | - name: toCoords 159 | from: class 160 | class: com.ververica.sql_training.udfs.ToCoords 161 | 162 | #============================================================================== 163 | # Execution properties 164 | #============================================================================== 165 | 166 | # Execution properties allow for changing the behavior of a table program. 167 | 168 | execution: 169 | planner: blink # using the Blink planner 170 | type: streaming # 'batch' or 'streaming' execution 171 | result-mode: table # 'changelog' or 'table' presentation of results 172 | parallelism: 1 # parallelism of the program 173 | max-parallelism: 128 # maximum parallelism 174 | min-idle-state-retention: 0 # minimum idle state retention in ms 175 | max-idle-state-retention: 0 # maximum idle state retention in ms 176 | 177 | #============================================================================== 178 | # Execution properties 179 | #============================================================================== 180 | 181 | # Flink configuration parameters 182 | 183 | configuration: 184 | execution.checkpointing.interval: 1s 185 | 186 | #============================================================================== 187 | # Deployment properties 188 | #============================================================================== 189 | 190 | # Deployment properties allow for describing the cluster to which table 191 | # programs are submitted to. 192 | 193 | deployment: 194 | type: standalone # only the 'standalone' deployment is supported 195 | response-timeout: 5000 # general cluster communication timeout in ms 196 | gateway-address: "" # (optional) address from cluster to gateway 197 | gateway-port: 0 # (optional) port from cluster to gateway 198 | 199 | 200 | -------------------------------------------------------------------------------- /images/client-image/java/sql-training-udfs/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /images/client-image/java/sql-training-data-producer/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /images/client-image/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | 204 | This distribution has a binary dependency on jersey, which is available under the CDDL 205 | License as described below. 206 | 207 | COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL - Version 1.1) 208 | 1. Definitions. 209 | 1.1. “Contributor” means each individual or entity that creates or contributes to the creation of Modifications. 210 | 211 | 1.2. “Contributor Version” means the combination of the Original Software, prior Modifications used by a Contributor (if any), and the Modifications made by that particular Contributor. 212 | 213 | 1.3. “Covered Software” means (a) the Original Software, or (b) Modifications, or (c) the combination of files containing Original Software with files containing Modifications, in each case including portions thereof. 214 | 215 | 1.4. “Executable” means the Covered Software in any form other than Source Code. 216 | 217 | 1.5. “Initial Developer” means the individual or entity that first makes Original Software available under this License. 218 | 219 | 1.6. “Larger Work” means a work which combines Covered Software or portions thereof with code not governed by the terms of this License. 220 | 221 | 1.7. “License” means this document. 222 | 223 | 1.8. “Licensable” means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein. 224 | 225 | 1.9. “Modifications” means the Source Code and Executable form of any of the following: 226 | 227 | A. Any file that results from an addition to, deletion from or modification of the contents of a file containing Original Software or previous Modifications; 228 | 229 | B. Any new file that contains any part of the Original Software or previous Modification; or 230 | 231 | C. Any new file that is contributed or otherwise made available under the terms of this License. 232 | 233 | 1.10. “Original Software” means the Source Code and Executable form of computer software code that is originally released under this License. 234 | 235 | 1.11. “Patent Claims” means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor. 236 | 237 | 1.12. “Source Code” means (a) the common form of computer software code in which modifications are made and (b) associated documentation included in or with such code. 238 | 239 | 1.13. “You” (or “Your”) means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, “You” includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, “control” means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. 240 | 241 | 2. License Grants. 242 | 2.1. The Initial Developer Grant. 243 | 244 | Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, the Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license: 245 | 246 | (a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer, to use, reproduce, modify, display, perform, sublicense and distribute the Original Software (or portions thereof), with or without Modifications, and/or as part of a Larger Work; and 247 | 248 | (b) under Patent Claims infringed by the making, using or selling of Original Software, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Software (or portions thereof). 249 | 250 | (c) The licenses granted in Sections 2.1(a) and (b) are effective on the date Initial Developer first distributes or otherwise makes the Original Software available to a third party under the terms of this License. 251 | 252 | (d) Notwithstanding Section 2.1(b) above, no patent license is granted: (1) for code that You delete from the Original Software, or (2) for infringements caused by: (i) the modification of the Original Software, or (ii) the combination of the Original Software with other software or devices. 253 | 254 | 2.2. Contributor Grant. 255 | 256 | Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license: 257 | 258 | (a) under intellectual property rights (other than patent or trademark) Licensable by Contributor to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof), either on an unmodified basis, with other Modifications, as Covered Software and/or as part of a Larger Work; and 259 | 260 | (b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: (1) Modifications made by that Contributor (or portions thereof); and (2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination). 261 | 262 | (c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first distributes or otherwise makes the Modifications available to a third party. 263 | 264 | (d) Notwithstanding Section 2.2(b) above, no patent license is granted: (1) for any code that Contributor has deleted from the Contributor Version; (2) for infringements caused by: (i) third party modifications of Contributor Version, or (ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or (3) under Patent Claims infringed by Covered Software in the absence of Modifications made by that Contributor. 265 | 266 | 3. Distribution Obligations. 267 | 3.1. Availability of Source Code. 268 | 269 | Any Covered Software that You distribute or otherwise make available in Executable form must also be made available in Source Code form and that Source Code form must be distributed only under the terms of this License. You must include a copy of this License with every copy of the Source Code form of the Covered Software You distribute or otherwise make available. You must inform recipients of any such Covered Software in Executable form as to how they can obtain such Covered Software in Source Code form in a reasonable manner on or through a medium customarily used for software exchange. 270 | 271 | 3.2. Modifications. 272 | 273 | The Modifications that You create or to which You contribute are governed by the terms of this License. You represent that You believe Your Modifications are Your original creation(s) and/or You have sufficient rights to grant the rights conveyed by this License. 274 | 275 | 3.3. Required Notices. 276 | 277 | You must include a notice in each of Your Modifications that identifies You as the Contributor of the Modification. You may not remove or alter any copyright, patent or trademark notices contained within the Covered Software, or any notices of licensing or any descriptive text giving attribution to any Contributor or the Initial Developer. 278 | 279 | 3.4. Application of Additional Terms. 280 | 281 | You may not offer or impose any terms on any Covered Software in Source Code form that alters or restricts the applicable version of this License or the recipients’ rights hereunder. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, you may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear that any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer. 282 | 283 | 3.5. Distribution of Executable Versions. 284 | 285 | You may distribute the Executable form of the Covered Software under the terms of this License or under the terms of a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable form does not attempt to limit or alter the recipient’s rights in the Source Code form from the rights set forth in this License. If You distribute the Covered Software in Executable form under a different license, You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer. 286 | 287 | 3.6. Larger Works. 288 | 289 | You may create a Larger Work by combining Covered Software with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Software. 290 | 291 | 4. Versions of the License. 292 | 4.1. New Versions. 293 | 294 | Oracle is the initial license steward and may publish revised and/or new versions of this License from time to time. Each version will be given a distinguishing version number. Except as provided in Section 4.3, no one other than the license steward has the right to modify this License. 295 | 296 | 4.2. Effect of New Versions. 297 | 298 | You may always continue to use, distribute or otherwise make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. If the Initial Developer includes a notice in the Original Software prohibiting it from being distributed or otherwise made available under any subsequent version of the License, You must distribute and make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. Otherwise, You may also choose to use, distribute or otherwise make the Covered Software available under the terms of any subsequent version of the License published by the license steward. 299 | 300 | 4.3. Modified Versions. 301 | 302 | When You are an Initial Developer and You want to create a new license for Your Original Software, You may create and use a modified version of this License if You: (a) rename the license and remove any references to the name of the license steward (except to note that the license differs from this License); and (b) otherwise make it clear that the license contains terms which differ from this License. 303 | 304 | 5. DISCLAIMER OF WARRANTY. 305 | COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN “AS IS” BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. 306 | 307 | 6. TERMINATION. 308 | 6.1. This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive. 309 | 310 | 6.2. If You assert a patent infringement claim (excluding declaratory judgment actions) against Initial Developer or a Contributor (the Initial Developer or Contributor against whom You assert such claim is referred to as “Participant”) alleging that the Participant Software (meaning the Contributor Version where the Participant is a Contributor or the Original Software where the Participant is the Initial Developer) directly or indirectly infringes any patent, then any and all rights granted directly or indirectly to You by such Participant, the Initial Developer (if the Initial Developer is not the Participant) and all Contributors under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively and automatically at the expiration of such 60 day notice period, unless if within such 60 day period You withdraw Your claim with respect to the Participant Software against such Participant either unilaterally or pursuant to a written agreement with Participant. 311 | 312 | 6.3. If You assert a patent infringement claim against Participant alleging that the Participant Software directly or indirectly infringes any patent where such claim is resolved (such as by license or settlement) prior to the initiation of patent infringement litigation, then the reasonable value of the licenses granted by such Participant under Sections 2.1 or 2.2 shall be taken into account in determining the amount or value of any payment or license. 313 | 314 | 6.4. In the event of termination under Sections 6.1 or 6.2 above, all end user licenses that have been validly granted by You or any distributor hereunder prior to termination (excluding licenses granted to You by any distributor) shall survive termination. 315 | 316 | 7. LIMITATION OF LIABILITY. 317 | UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY’S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. 318 | 319 | 8. U.S. GOVERNMENT END USERS. 320 | The Covered Software is a “commercial item,” as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of “commercial computer software” (as that term is defined at 48 C.F.R. § 252.227-7014(a)(1)) and “commercial computer software documentation” as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Software with only those rights set forth herein. This U.S. Government Rights clause is in lieu of, and supersedes, any other FAR, DFAR, or other clause or provision that addresses Government rights in computer software under this License. 321 | 322 | 9. MISCELLANEOUS. 323 | This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by the law of the jurisdiction specified in a notice contained within the Original Software (except to the extent applicable law, if any, provides otherwise), excluding such jurisdiction’s conflict-of-law provisions. Any litigation relating to this License shall be subject to the jurisdiction of the courts located in the jurisdiction and venue specified in a notice contained within the Original Software, with the losing party responsible for costs, including, without limitation, court costs and reasonable attorneys’ fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. You agree that You alone are responsible for compliance with the United States export administration regulations (and the export control laws and regulation of any other countries) when You use, distribute or otherwise make available any Covered Software. 324 | 325 | 10. RESPONSIBILITY FOR CLAIMS. 326 | As between Initial Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability. 327 | 328 | NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) 329 | 330 | The code released under the CDDL shall be governed by the laws of the State of California (excluding conflict-of-law provisions). Any litigation relating to this License shall be subject to the jurisdiction of the Federal Courts of the Northern District of California and the state courts of the State of California, with venue lying in Santa Clara County, California. 331 | --------------------------------------------------------------------------------