Skip to content

Support SSL authentication with Kafka in routine load job - #1235

Merged
imay merged 36 commits into
apache:masterfrom
morningman:kafka_ssl
Jun 7, 2019
Merged

Support SSL authentication with Kafka in routine load job#1235
imay merged 36 commits into
apache:masterfrom
morningman:kafka_ssl

Conversation

@morningman

@morningmanmorningman commented Jun 3, 2019

Copy link
Copy Markdown
Contributor
  1. Implement a Small File Manager which allows user to upload small files, save them in Doris and use them later. Details can be found in docs/documentation/cn/administrator-guide/small_file_mgr.md and docs/help/Contents/Administration/small_files.md.

  2. Support SSL authentication with Kafka in routine load job. Details can be found in docs/documentation/cn/administrator-guide/load-data/routine-load-manual.md and docs/help/Contents/Data Manipulation/routine_load.md

  3. Remove Kafka Java client. Now we only use librdkafka on BE to connect Kafka brokers.

  4. Fix bugs that invalid routine load task configuration may cause too many aborted transactions.

  5. Modify the get_log_file restful api on FE. Details can be found in docs/documentation/cn/administrator-guide/http-actions/fe_get_log_file.md.

  6. Optimize the error messages of CANCEL LOAD operation.

ISSUE #1234

Comment threaddocs/documentation/cn/administrator-guide/http-actions/fe_get_log_file.md Outdated
Comment threaddocs/documentation/cn/administrator-guide/load-data/routine-load-manual.md Outdated
morningmanand others added 2 commits June 3, 2019 14:31
…ad-manual.md
Co-Authored-By: kangpinghuang <40422952+kangpinghuang@users.noreply.github.com>
…log_file.md
Co-Authored-By: kangkaisen <kangkaisen@apache.org>

@kangkaisenkangkaisen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Save the small file content to FE metadata is necessary? could we save the small file content in FE disk or BE disk?

Comment threaddocs/help/Contents/Data Definition/ddl_stmt.md Outdated
Comment threadfe/src/main/java/org/apache/doris/analysis/CreateFileStmt.java Outdated
@@ -0,0 +1,71 @@
package org.apache.doris.common.util;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

licence header

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

done

@@ -0,0 +1,114 @@
package org.apache.doris.common.util;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

license header

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

done

Mingyu Chenand others added 2 commits June 4, 2019 09:10
Co-Authored-By: kangkaisen <kangkaisen@apache.org>
Co-Authored-By: kangkaisen <kangkaisen@apache.org>
@morningman

ghost commented Jun 4, 2019

Copy link
Copy Markdown
ContributorAuthor

@kangkaisen
Save the small file content to FE metadata is necessary? could we save the small file content in FE disk or BE disk?

I've been considered this problem, here are my thoughts:

  1. Limit the size and num of files so that FE memory is not a problem.
  2. If files be saved on disk, we may need another file manager to manage files on disks. If files are damaged or missing, there is no where to download them again. And I just want this light small file manager to be a certain level of 'Stateless'.
  3. BE also has a file cache, all downloaded files are saved on BE disks, and if file is missing, BE will downloaded file from FE again.
  4. I also add an option which allow user to just save file url in SmallFileMgr(You can see it in CreateFileStmt.java, but because it is not fully implemented yet, I currently forbid this feature). With this option, file in Doris will be represented as a URL. And the validation of URL is guaranteed by user themselves.

@kangkaisen

ghost commented Jun 4, 2019

Copy link
Copy Markdown
Contributor

@kangkaisen
Save the small file content to FE metadata is necessary? could we save the small file content in FE disk or BE disk?

I've been considered this problem, here are my thoughts:

  1. Limit the size and num of files so that FE memory is not a problem.
  2. If files be saved on disk, we may need another file manager to manage files on disks. If files are damaged or missing, there is no where to download them again. And I just want this light small file manager to be a certain level of 'Stateless'.
  3. BE also has a file cache, all downloaded files are saved on BE disks, and if file is missing, BE will downloaded file from FE again.
  4. I also add an option which allow user to just save file url in SmallFileMgr(You can see it in CreateFileStmt.java, but because it is not fully implemented yet, I currently forbid this feature). With this option, file in Doris will be represented as a URL. And the validation of URL is guaranteed by user themselves.

Ok. I See. Thank you.

Comment threadbe/src/runtime/routine_load/data_consumer.cpp Outdated
Comment threadbe/src/runtime/routine_load/data_consumer.cpp Outdated
Comment threadgensrc/thrift/BackendService.thrift Outdated

Status.TStatus submit_routine_load_task(1:list<TRoutineLoadTask> tasks);
// This is used for getting some information via Backend
TProxyResult get_info(1:TProxyRequest request);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually, new interface should use Brpc, and old interface should be changed to Brpc.
Because Brpc is better for example it support async, connection reused

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

OK, I will change it

// check md5sum if necessary
String checksum = Hex.encodeHexString(digest.digest());
if (!Strings.isNullOrEmpty(md5sum)) {
if (!checksum.equals(md5sum)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ignore case?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

ok

throw new DdlException("Failed to check md5 of file: " + file.getName());
}

return md5sum.equals(expectedMd5);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ignore case?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

ok

SmallFileMgr fileMgr = Catalog.getCurrentCatalog().getSmallFileMgr();
String filePath;
try {
filePath = fileMgr.saveToFile(fileId);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why do we need to save it in a file? I think we can get in memory and send the result.

if (entry.getValue().startsWith("FILE:")) {
String file = entry.getValue().substring(entry.getValue().indexOf(":") + 1);
// check and save file to disk
smallFileMgr.saveToFile(dbId, KAFKA_FILE_CATALOG, file);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't know why we should save it to file?

Mingyu Chenand others added 2 commits June 5, 2019 09:08
Co-Authored-By: ZHAO Chun <buaa.zhaoc@gmail.com>
Co-Authored-By: ZHAO Chun <buaa.zhaoc@gmail.com>
@morningman

ghost commented Jun 5, 2019

Copy link
Copy Markdown
ContributorAuthor

temporary close

} else {
errMsg = "process loading finished fail";
processCancelled(job, cancelType, errMsg);
processCancelled(job, cancelType, errMsg, failedMsg);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please keep neat

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

ok

break;
case CANCELLED:
processCancelled(job, cancelType, errMsg);
processCancelled(job, cancelType, errMsg, failedMsg);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please keep neat

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

ok

CREATE FILE "ca.pem"
PROPERTIES
(
"url" = "https://test.bj.bcebos.com/kafka-key/ca.pem",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

http or https?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

this is just an example. both https and http is OK


// this is the kafka consumer which is used to fetch the number of partitions
private KafkaConsumer<String, String> consumer;
private Map<String, String> convertedCustomProperties = Maps.newHashMap();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why don't you merge convertedCustomProperties into customKafkaProperties

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

convertedCustomProperties is just a temporary data struct, and it should be re-created if file changed

return result;
private List<Integer> getAllKafkaPartitions() throws UserException {
convertCustomProperties();
return KafkaUtil.getAllKafkaPartitions(brokerList, topic, convertedCustomProperties);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If the convertedCustomProperties is incorrect, the job will not be cancelled? The connection timeout and certification failed need to be distinguish.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Yes, if convertedCustomProperties is incorrect, the job will be paused.
And it is not easy to distinguish timeout and other failure. for example, if ssl authentication failed, kafka client on BE will retry again and again , while in FE, it looks like timeout.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Of cause, you remind me that convertedCustomProperties should be re-created when routine load job transfer from PAUSE to NEED_SCHEDULE, because some files may be re-created anytime.


/*
* Author: Chenmingyu
* Date: May 29, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

em... Is author necessary ?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

No, this is just the IDE's auto adding

private static final Logger LOG = LogManager.getLogger(KafkaRoutineLoadJob.class);

private static final int FETCH_PARTITIONS_TIMEOUT_SECOND = 5;
public static final String KAFKA_FILE_CATALOG = "kafka";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The catalog is a static param of job while the catalog of file is created by user.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Yes, in my design , catalog named 'kafka' is a reserved keyword, which is exactly used by kafka client.

@morningmanmorningman reopened this Jun 6, 2019
Comment threadgensrc/proto/internal_service.proto Outdated
imay
imay approved these changes Jun 7, 2019
@imay
imay merged commit ff0dd0d into apache:masterJun 7, 2019
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@morningman@kangkaisen@imay@EmmyMiao87@kangpinghuang