|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + */ |
| 18 | + |
| 19 | + |
| 20 | +package com.dtstack.flink.sql.side.oracle; |
| 21 | + |
| 22 | +import com.dtstack.flink.sql.side.FieldInfo; |
| 23 | +import com.dtstack.flink.sql.side.JoinInfo; |
| 24 | +import com.dtstack.flink.sql.side.SideTableInfo; |
| 25 | +import com.dtstack.flink.sql.side.rdb.async.RdbAsyncReqRow; |
| 26 | +import com.dtstack.flink.sql.side.rdb.table.RdbSideTableInfo; |
| 27 | +import io.vertx.core.Vertx; |
| 28 | +import io.vertx.core.VertxOptions; |
| 29 | +import io.vertx.core.json.JsonObject; |
| 30 | +import io.vertx.ext.jdbc.JDBCClient; |
| 31 | +import org.apache.flink.api.java.typeutils.RowTypeInfo; |
| 32 | +import org.apache.flink.configuration.Configuration; |
| 33 | +import org.slf4j.Logger; |
| 34 | +import org.slf4j.LoggerFactory; |
| 35 | + |
| 36 | +import java.util.List; |
| 37 | + |
| 38 | + |
| 39 | +public class OracleAsyncReqRow extends RdbAsyncReqRow { |
| 40 | + |
| 41 | + private static final Logger LOG = LoggerFactory.getLogger(OracleAsyncReqRow.class); |
| 42 | + |
| 43 | + private static final String ORACLE_DRIVER = "oracle.jdbc.driver.OracleDriver"; |
| 44 | + |
| 45 | + public OracleAsyncReqRow(RowTypeInfo rowTypeInfo, JoinInfo joinInfo, List<FieldInfo> outFieldInfoList, SideTableInfo sideTableInfo) { |
| 46 | + super(rowTypeInfo, joinInfo, outFieldInfoList, sideTableInfo); |
| 47 | + } |
| 48 | + |
| 49 | + @Override |
| 50 | + public void open(Configuration parameters) throws Exception { |
| 51 | + super.open(parameters); |
| 52 | + JsonObject sqlserverClientConfig = new JsonObject(); |
| 53 | + RdbSideTableInfo rdbSideTableInfo = (RdbSideTableInfo) sideInfo.getSideTableInfo(); |
| 54 | + sqlserverClientConfig.put("url", rdbSideTableInfo.getUrl()) |
| 55 | + .put("driver_class", ORACLE_DRIVER) |
| 56 | + .put("max_pool_size", DEFAULT_MAX_DB_CONN_POOL_SIZE) |
| 57 | + .put("user", rdbSideTableInfo.getUserName()) |
| 58 | + .put("password", rdbSideTableInfo.getPassword()); |
| 59 | + |
| 60 | + VertxOptions vo = new VertxOptions(); |
| 61 | + vo.setEventLoopPoolSize(DEFAULT_VERTX_EVENT_LOOP_POOL_SIZE); |
| 62 | + vo.setWorkerPoolSize(DEFAULT_VERTX_WORKER_POOL_SIZE); |
| 63 | + Vertx vertx = Vertx.vertx(vo); |
| 64 | + setRdbSQLClient(JDBCClient.createNonShared(vertx, sqlserverClientConfig)); |
| 65 | + } |
| 66 | +} |
0 commit comments