flink-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Swapnil Chougule <the.swapni...@gmail.com>
Subject Flink JDBC JDBCOutputFormat Open
Date Mon, 12 Sep 2016 06:41:16 GMT
Hi Team,

I want to know how tasknumber & numtasks help in opening db connection in
Flink JDBC JDBCOutputFormat Open. I checked with docs where it says:
taskNumber - The number of the parallel instance.numTasks - The number of
parallel tasks.But couldn't get clear idea among parallel instance &
parallel tasks. How do they contribute in concurrency with JDBC Source/Sink?

I also checked with code but couldn't drill down further

/**
* Connects to the target database and initializes the prepared statement.
*
* @param taskNumber The number of the parallel instance.
* @throws IOException Thrown, if the output could not be opened due to an
* I/O problem.
*/
@Override
public void open(int taskNumber, int numTasks) throws IOException {
try {
establishConnection();
upload = dbConn.prepareStatement(query);
} catch (SQLException sqe) {
throw new IllegalArgumentException("open() failed.", sqe);
} catch (ClassNotFoundException cnfe) {
throw new IllegalArgumentException("JDBC driver class not found.", cnfe);
}
}
private void establishConnection() throws SQLException,
ClassNotFoundException {
Class.forName(drivername);
if (username == null) {
dbConn = DriverManager.getConnection(dbURL);
} else {
dbConn = DriverManager.getConnection(dbURL, username, password);
}
}

Thanks,
Swapnil

Mime
View raw message