Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
f9225ae
set up
XNX02 Mar 5, 2025
6dc8c23
Merge branch 'master' of https://github.com/apache/iotdb into externa…
XNX02 Mar 20, 2025
ca62da7
update
XNX02 Mar 23, 2025
67f581b
Merge branch 'master' of https://github.com/apache/iotdb into externa…
XNX02 Mar 25, 2025
ded4261
update
XNX02 Mar 25, 2025
8ff357f
Merge branch 'master' of https://github.com/apache/iotdb into externa…
XNX02 Mar 29, 2025
57baeb2
update blancer
XNX02 Mar 29, 2025
eb01779
update
XNX02 Mar 29, 2025
3ef7238
mqtt source
XNX02 Mar 30, 2025
5c020da
update
XNX02 Apr 1, 2025
243a376
kafka source
XNX02 Apr 2, 2025
d61fd1a
mqtt
XNX02 Apr 3, 2025
ecea9a7
update
XNX02 Apr 3, 2025
9a82d86
add header
XNX02 Apr 3, 2025
a07e703
update
XNX02 Apr 4, 2025
3dd79d6
fix
XNX02 Apr 7, 2025
bf4a871
alter pipe & loadbalancer
XNX02 Apr 11, 2025
94a4ae2
Merge branch 'master' of https://github.com/apache/iotdb into mqtt-so…
XNX02 Apr 11, 2025
5da03d3
update
XNX02 Apr 11, 2025
caa3907
update
XNX02 Apr 12, 2025
ddbdf69
update
XNX02 Apr 14, 2025
ae41e9c
update balance logic
XNX02 Apr 15, 2025
7b7dc32
update
XNX02 Apr 15, 2025
10ef051
fix
XNX02 Apr 15, 2025
fd9932a
Merge branch 'master' of https://github.com/apache/iotdb into mqtt-so…
XNX02 Apr 15, 2025
be7aeda
fix
XNX02 Apr 15, 2025
2fa9770
update
XNX02 Apr 16, 2025
528fd4c
update
XNX02 Apr 16, 2025
07f9585
fix
XNX02 Apr 16, 2025
8034b0e
update
XNX02 Apr 16, 2025
44a55e8
update
XNX02 Apr 17, 2025
559ce22
fix
XNX02 Apr 17, 2025
a331204
fix
XNX02 Apr 17, 2025
556cf82
address review comments
XNX02 Apr 21, 2025
9f80546
fix
XNX02 Apr 23, 2025
7b9c62d
update
XNX02 Apr 23, 2025
9ff2ff2
Merge branch 'master' of github.com:apache/iotdb into pr/15275
SteveYurongSu Apr 28, 2025
4ef2189
fix
XNX02 Apr 28, 2025
4a36fdd
fix
XNX02 May 8, 2025
cbe4866
Merge branch 'master' of https://github.com/apache/iotdb into pr/15275
SteveYurongSu May 13, 2025
06ef404
Update BuiltinPipePlugin.java
SteveYurongSu May 13, 2025
dc14966
热factor
SteveYurongSu May 13, 2025
9212b0f
Update PipeRuntimeMeta.java
SteveYurongSu May 13, 2025
678f119
Update PipeRuntimeMeta.java
SteveYurongSu May 13, 2025
a87d855
refactor
SteveYurongSu May 13, 2025
49ed24b
refactor
SteveYurongSu May 15, 2025
ef088f8
Update PipeDataNodeTaskBuilder.java
SteveYurongSu May 15, 2025
88771e7
refactor
SteveYurongSu May 15, 2025
303fe97
Merge branch 'master' of https://github.com/apache/iotdb into pr/15275
SteveYurongSu May 15, 2025
0746012
Update PipeExternalSourceLoadBalancer.java
SteveYurongSu May 15, 2025
7d4e82e
refactor
SteveYurongSu May 15, 2025
034ab6a
Update AlterPipeProcedureV2.java
SteveYurongSu May 15, 2025
12b263e
Update AlterPipeProcedureV2.java
SteveYurongSu May 15, 2025
9dff0b7
Update PipeStatementInsertionEvent.java
SteveYurongSu May 15, 2025
e9e33cb
refactor
SteveYurongSu May 15, 2025
13a8957
Update MQTTExtractor.java
SteveYurongSu May 15, 2025
63b4dbd
fix alter pipe
XNX02 May 15, 2025
8911680
update
XNX02 May 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update
  • Loading branch information
XNX02 committed Apr 12, 2025
commit caa3907a0cf8f68ad80b403f2d63352aa3d486f0
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,25 @@ public ExternalLoadBalancer(final String balanceStrategy) {
* @return a mapping from task index to leader node id
*/
public Map<Integer, Integer> balance(
int parallelCount, PipeStaticMeta pipeStaticMeta, ConfigManager configManager) {
final int parallelCount,
final PipeStaticMeta pipeStaticMeta,
final ConfigManager configManager) {
return strategy.balance(parallelCount, pipeStaticMeta, configManager);
}

public interface BalanceStrategy {
Map<Integer, Integer> balance(
int parallelCount, PipeStaticMeta pipeStaticMeta, ConfigManager configManager);
final int parallelCount,
final PipeStaticMeta pipeStaticMeta,
final ConfigManager configManager);
}

public static class ProportionalBalanceStrategy implements BalanceStrategy {
@Override
public Map<Integer, Integer> balance(
int parallelCount, PipeStaticMeta pipeStaticMeta, ConfigManager configManager) {
final int parallelCount,
final PipeStaticMeta pipeStaticMeta,
final ConfigManager configManager) {
final Map<TConsensusGroupId, Integer> regionLeaderMap =
configManager.getLoadManager().getRegionLeaderMap();
final Map<Integer, Integer> parallelAssignment = new HashMap<>();
Expand Down Expand Up @@ -135,7 +142,7 @@ public Map<Integer, Integer> balance(
final Map<Integer, Double> leaderRegionId2ExactShareMap = new HashMap<>();
final Map<Integer, Integer> leaderRegionId2AssignedCountMap = new HashMap<>();
for (Map.Entry<Integer, Integer> entry : leaderRegionId2DataRegionCountMap.entrySet()) {
double share = (parallelCount * entry.getValue()) / (double) totalRegions;
final double share = (parallelCount * entry.getValue()) / (double) totalRegions;
leaderRegionId2ExactShareMap.put(entry.getKey(), share);
leaderRegionId2AssignedCountMap.put(entry.getKey(), (int) Math.floor(share));
}
Expand All @@ -149,7 +156,7 @@ public Map<Integer, Integer> balance(
leaderRegionId2ExactShareMap.keySet().stream()
.sorted(
(l1, l2) -> {
double diff =
final double diff =
(leaderRegionId2ExactShareMap.get(l2)
- Math.floor(leaderRegionId2ExactShareMap.get(l2)))
- (leaderRegionId2ExactShareMap.get(l1)
Expand All @@ -163,11 +170,11 @@ public Map<Integer, Integer> balance(
leaderId, leaderRegionId2AssignedCountMap.get(leaderId) + 1);
}

List<Integer> stableLeaders = new ArrayList<>(leaderRegionId2AssignedCountMap.keySet());
final List<Integer> stableLeaders = new ArrayList<>(leaderRegionId2AssignedCountMap.keySet());
Collections.sort(stableLeaders);
Comment thread
XNX02 marked this conversation as resolved.
int taskIndex = 1;
for (final Integer leader : stableLeaders) {
int count = leaderRegionId2AssignedCountMap.get(leader);
final int count = leaderRegionId2AssignedCountMap.get(leader);
for (int i = 0; i < count; i++) {
parallelAssignment.put(-taskIndex, leader);
taskIndex++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public class MQTTExtractor implements PipeExtractor {
protected final AtomicBoolean isClosed = new AtomicBoolean(false);

@Override
public void validate(PipeParameterValidator validator) throws Exception {
public void validate(final PipeParameterValidator validator) throws Exception {
if (!validator
.getParameters()
.getBooleanOrDefault(
Expand All @@ -84,7 +84,8 @@ public void validate(PipeParameterValidator validator) throws Exception {
}

@Override
public void customize(PipeParameters parameters, PipeExtractorRuntimeConfiguration configuration)
public void customize(
final PipeParameters parameters, final PipeExtractorRuntimeConfiguration configuration)
throws Exception {
final PipeTaskExtractorRuntimeEnvironment environment =
(PipeTaskExtractorRuntimeEnvironment) configuration.getRuntimeEnvironment();
Expand Down Expand Up @@ -137,8 +138,8 @@ public void close() throws Exception {
}
}

private IConfig createBrokerConfig(PipeParameters pipeParameters) {
Properties properties = new Properties();
private IConfig createBrokerConfig(final PipeParameters pipeParameters) {
final Properties properties = new Properties();
properties.setProperty(
BrokerConstants.HOST_PROPERTY_NAME,
pipeParameters.getStringOrDefault(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ public class MQTTPublishHandler extends AbstractInterceptHandler {
private final PipeTaskMeta pipeTaskMeta;

public MQTTPublishHandler(
PipeParameters pipeParameters,
PipeTaskExtractorRuntimeEnvironment environment,
UnboundedBlockingPendingQueue<EnrichedEvent> pendingQueue) {
final PipeParameters pipeParameters,
final PipeTaskExtractorRuntimeEnvironment environment,
final UnboundedBlockingPendingQueue<EnrichedEvent> pendingQueue) {
this.payloadFormat =
PayloadFormatManager.getPayloadFormat(
pipeParameters.getStringOrDefault(
Expand All @@ -107,7 +107,7 @@ public String getID() {
@Override
public void onConnect(InterceptConnectMessage msg) {
if (!clientIdToSessionMap.containsKey(msg.getClientID())) {
MqttClientSession session = new MqttClientSession(msg.getClientID());
final MqttClientSession session = new MqttClientSession(msg.getClientID());
sessionManager.login(
session,
msg.getUsername(),
Expand All @@ -123,7 +123,7 @@ public void onConnect(InterceptConnectMessage msg) {

@Override
public void onDisconnect(InterceptDisconnectMessage msg) {
MqttClientSession session = clientIdToSessionMap.remove(msg.getClientID());
final MqttClientSession session = clientIdToSessionMap.remove(msg.getClientID());
if (null != session) {
sessionManager.removeCurrSession();
sessionManager.closeSession(session, Coordinator.getInstance()::cleanupQueryExecution);
Expand All @@ -133,15 +133,15 @@ public void onDisconnect(InterceptDisconnectMessage msg) {
@Override
public void onPublish(InterceptPublishMessage msg) {
try {
String clientId = msg.getClientID();
final String clientId = msg.getClientID();
if (!clientIdToSessionMap.containsKey(clientId)) {
return;
}
MqttClientSession session = clientIdToSessionMap.get(msg.getClientID());
ByteBuf payload = msg.getPayload();
String topic = msg.getTopicName();
String username = msg.getUsername();
MqttQoS qos = msg.getQos();
final MqttClientSession session = clientIdToSessionMap.get(msg.getClientID());
final ByteBuf payload = msg.getPayload();
final String topic = msg.getTopicName();
final String username = msg.getUsername();
final MqttQoS qos = msg.getQos();

LOGGER.debug(
"Receive publish message. clientId: {}, username: {}, qos: {}, topic: {}, payload: {}",
Expand All @@ -151,7 +151,7 @@ public void onPublish(InterceptPublishMessage msg) {
topic,
payload);

List<Message> messages = payloadFormat.format(payload);
final List<Message> messages = payloadFormat.format(payload);
if (messages == null) {
return;
}
Expand All @@ -161,9 +161,9 @@ public void onPublish(InterceptPublishMessage msg) {
continue;
}
if (useTableInsert) {
TableMessage tableMessage = (TableMessage) message;
final TableMessage tableMessage = (TableMessage) message;
// '/' previously defined as a database name
String database =
final String database =
!msg.getTopicName().contains("/")
? msg.getTopicName()
: msg.getTopicName().substring(0, msg.getTopicName().indexOf("/"));
Expand All @@ -182,12 +182,12 @@ public void onPublish(InterceptPublishMessage msg) {
}

/** Inserting table using tablet */
private void extractTable(TableMessage message, MqttClientSession session) {
private void extractTable(final TableMessage message, final MqttClientSession session) {
try {
TimestampPrecisionUtils.checkTimestampPrecision(message.getTimestamp());
session.setDatabaseName(message.getDatabase().toLowerCase());
session.setSqlDialect(IClientSession.SqlDialect.TABLE);
EnrichedEvent event = generateEvent(message);
final EnrichedEvent event = generateEvent(message);
if (!event.increaseReferenceCount(MQTTPublishHandler.class.getName())) {
LOGGER.warn("The reference count of the event {} cannot be increased, skipping it.", event);
Comment thread
XNX02 marked this conversation as resolved.
}
Expand All @@ -205,7 +205,7 @@ private void extractTable(TableMessage message, MqttClientSession session) {
}
}

private PipeRawTabletInsertionEvent generateEvent(TableMessage message) {
private PipeRawTabletInsertionEvent generateEvent(final TableMessage message) {
final List<String> measurements =
Stream.of(message.getFields(), message.getTagKeys(), message.getAttributeKeys())
.flatMap(List::stream)
Expand Down Expand Up @@ -242,7 +242,7 @@ private PipeRawTabletInsertionEvent generateEvent(TableMessage message) {
schemas[i] = new MeasurementSchema(measurements.get(i), dataTypes[i]);
}

Tablet eventTablet =
final Tablet eventTablet =
new Tablet(
message.getTable(),
Arrays.asList(schemas),
Expand All @@ -266,15 +266,15 @@ private PipeRawTabletInsertionEvent generateEvent(TableMessage message) {
false);
}

private void extractTree(TreeMessage message, MqttClientSession session) {
private void extractTree(final TreeMessage message, final MqttClientSession session) {
TSStatus tsStatus = null;
try {
TimestampPrecisionUtils.checkTimestampPrecision(message.getTimestamp());
tsStatus = checkAuthority(session);
if (tsStatus.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
LOGGER.warn(tsStatus.message);
} else {
EnrichedEvent event = generateEvent(message);
final EnrichedEvent event = generateEvent(message);
if (!event.increaseReferenceCount(MQTTPublishHandler.class.getName())) {
LOGGER.warn(
"The reference count of the event {} cannot be increased, skipping it.", event);
Comment thread
XNX02 marked this conversation as resolved.
Outdated
Expand All @@ -291,7 +291,7 @@ private void extractTree(TreeMessage message, MqttClientSession session) {
}
}

private EnrichedEvent generateEvent(TreeMessage message) throws QueryProcessException {
private EnrichedEvent generateEvent(final TreeMessage message) throws QueryProcessException {
final String deviceId = message.getDevice();
final List<String> measurements = message.getMeasurements();
final long[] timestamps = new long[] {message.getTimestamp()};
Expand Down Expand Up @@ -337,7 +337,7 @@ private EnrichedEvent generateEvent(TreeMessage message) throws QueryProcessExce
}
}

Tablet eventTablet =
final Tablet eventTablet =
new Tablet(deviceId, Arrays.asList(schemas), timestamps, inferredValues, bitMaps, 1);

return new PipeRawTabletInsertionEvent(
Expand All @@ -354,8 +354,8 @@ private EnrichedEvent generateEvent(TreeMessage message) throws QueryProcessExce
false);
}

private static TSStatus checkAuthority(MqttClientSession session) {
long startTime = System.nanoTime();
private static TSStatus checkAuthority(final MqttClientSession session) {
Comment thread
XNX02 marked this conversation as resolved.
Outdated
final long startTime = System.nanoTime();
try {
return AuthorityChecker.getTSStatus(
AuthorityChecker.SUPER_USER.equals(session.getUsername()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@
package org.apache.iotdb.commons.pipe.agent.plugin.builtin.extractor.mqtt;

import org.apache.iotdb.pipe.api.PipeExtractor;
import org.apache.iotdb.pipe.api.annotation.TableModel;
import org.apache.iotdb.pipe.api.annotation.TreeModel;
import org.apache.iotdb.pipe.api.customizer.configuration.PipeExtractorRuntimeConfiguration;
import org.apache.iotdb.pipe.api.customizer.parameter.PipeParameterValidator;
import org.apache.iotdb.pipe.api.customizer.parameter.PipeParameters;
import org.apache.iotdb.pipe.api.event.Event;

@TreeModel
@TableModel
public class MQTTExtractor implements PipeExtractor {
Comment thread
SteveYurongSu marked this conversation as resolved.

private static final String PLACEHOLDER_ERROR_MSG =
Expand Down