-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3bfdef8
commit dfb436b
Showing
165 changed files
with
8,747 additions
and
5,001 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...tmq-connect-doris/src/main/java/org/apache/rocketmq/connect/doris/DorisSinkConnector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.rocketmq.connect.doris; | ||
|
||
import io.openmessaging.KeyValue; | ||
import io.openmessaging.connector.api.component.task.Task; | ||
import io.openmessaging.connector.api.component.task.sink.SinkConnector; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.apache.rocketmq.connect.doris.cfg.DorisSinkConnectorConfig; | ||
import org.apache.rocketmq.connect.doris.utils.ConfigCheckUtils; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class DorisSinkConnector extends SinkConnector { | ||
private static final Logger LOG = LoggerFactory.getLogger(DorisSinkConnector.class); | ||
private KeyValue keyValue; | ||
|
||
@Override | ||
public void start(KeyValue keyValue) { | ||
this.keyValue = DorisSinkConnectorConfig.convertToLowercase(keyValue); | ||
DorisSinkConnectorConfig.setDefaultValues(this.keyValue); | ||
} | ||
|
||
/** | ||
* stop DorisSinkConnector | ||
*/ | ||
@Override | ||
public void stop() { | ||
LOG.info("doris sink connector stop"); | ||
} | ||
|
||
@Override | ||
public Class<? extends Task> taskClass() { | ||
return DorisSinkTask.class; | ||
} | ||
|
||
@Override | ||
public List<KeyValue> taskConfigs(final int maxTasks) { | ||
List<KeyValue> taskConfigs = new ArrayList<>(maxTasks); | ||
for (int i = 0; i < maxTasks; i++) { | ||
keyValue.put("task_id", i + ""); | ||
taskConfigs.add(this.keyValue); | ||
} | ||
return taskConfigs; | ||
} | ||
|
||
@Override | ||
public void validate(KeyValue config) { | ||
LOG.info("start validate connector config"); | ||
ConfigCheckUtils.validateConfig(config); | ||
} | ||
|
||
} |
66 changes: 66 additions & 0 deletions
66
...rocketmq-connect-doris/src/main/java/org/apache/rocketmq/connect/doris/DorisSinkTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.rocketmq.connect.doris; | ||
|
||
import io.openmessaging.KeyValue; | ||
import io.openmessaging.connector.api.component.task.sink.SinkTask; | ||
import io.openmessaging.connector.api.data.ConnectRecord; | ||
import io.openmessaging.connector.api.data.RecordOffset; | ||
import io.openmessaging.connector.api.data.RecordPartition; | ||
import io.openmessaging.connector.api.errors.ConnectException; | ||
import java.util.List; | ||
import java.util.Map; | ||
import org.apache.rocketmq.connect.doris.service.DorisSinkService; | ||
import org.apache.rocketmq.connect.doris.service.DorisSinkServiceFactory; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class DorisSinkTask extends SinkTask { | ||
private static final Logger LOG = LoggerFactory.getLogger(DorisSinkTask.class); | ||
private DorisSinkService sink; | ||
|
||
@Override | ||
public void start(KeyValue keyValue) { | ||
LOG.info("rocketmq doris sink task start"); | ||
this.sink = DorisSinkServiceFactory.getDorisSinkService(keyValue); | ||
} | ||
|
||
@Override | ||
public void put(List<ConnectRecord> sinkRecords) throws ConnectException { | ||
LOG.info("Read {} records from Kafka", sinkRecords.size()); | ||
sink.insert(sinkRecords); | ||
} | ||
|
||
/** | ||
* Support doris's two-phase commit | ||
*/ | ||
@Override | ||
public void flush(Map<RecordPartition, RecordOffset> currentOffsets) throws ConnectException { | ||
if (sink == null || sink.getDorisWriterSize() == 0) { | ||
return; | ||
} | ||
sink.commit(currentOffsets); | ||
} | ||
|
||
@Override | ||
public void stop() { | ||
LOG.info("rocketmq doris sink task stopped"); | ||
} | ||
} |
Oops, something went wrong.