You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "sandynz (via GitHub)" <gi...@apache.org> on 2023/06/01 12:32:12 UTC

[GitHub] [shardingsphere] sandynz opened a new pull request, #25994: Refactor CDC layer

sandynz opened a new pull request, #25994:
URL: https://github.com/apache/shardingsphere/pull/25994

   Related to #22500 
   
   Reduce CDC code layer, make it similar as migration etc.
   
   Purpose: 1) Cleaner code, 2) Prepare for unified code refactoring.
   
   Changes proposed in this pull request:
     - Add unified PipelineSink and impl: PipelineDataSourceSink and PipelineSocketSink
     - Add CDCImporter, CDCAckId; Remove SocketSinkImporter, SocketSinkImporterCreator, CDCAckHolder, CDCDataRecordUtils, DataRecordComparatorGenerator; Refactor PipelineChannel, PipelineSink and impls;
     - Add SingleChannelConsumerImporter for common usage
     - Add inventory and incremental task for CDC; Refactor CDCJobPreparer, CDCJob, CDCTasksRunner
   
   Part of general structure and process:
   - Use `1` job item of ejob, and sharding items are simulated by CDCJob, since task progress is binded in PipelineJobItemContext.
   - `1` importer will consume several dumpers for inventory and incremental tasks.
   - Incremental tasks will start after all inventory tasks are completed.
   
   
   ---
   
   Before committing this PR, I'm sure that I have checked the following options:
   - [ ] My code follows the [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) of this project.
   - [ ] I have self-reviewed the commit code.
   - [ ] I have (or in comment I request) added corresponding labels for the pull request.
   - [ ] I have passed maven check locally : `./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e`.
   - [ ] I have made corresponding changes to the documentation.
   - [ ] I have added corresponding unit tests for my changes.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] sandynz commented on pull request #25994: Refactor CDC layer

Posted by "sandynz (via GitHub)" <gi...@apache.org>.
sandynz commented on PR #25994:
URL: https://github.com/apache/shardingsphere/pull/25994#issuecomment-1573503171

   TODO: Improve XA support in next PR


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] azexcy commented on a diff in pull request #25994: Refactor CDC layer

Posted by "azexcy (via GitHub)" <gi...@apache.org>.
azexcy commented on code in PR #25994:
URL: https://github.com/apache/shardingsphere/pull/25994#discussion_r1213124198


##########
kernel/data-pipeline/cdc/core/src/main/java/org/apache/shardingsphere/data/pipeline/cdc/core/importer/CDCImporter.java:
##########
@@ -0,0 +1,214 @@
+/*
+ * 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.shardingsphere.data.pipeline.cdc.core.importer;
+
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.RandomStringUtils;
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.shardingsphere.data.pipeline.api.executor.AbstractLifecycleExecutor;
+import org.apache.shardingsphere.data.pipeline.api.importer.Importer;
+import org.apache.shardingsphere.data.pipeline.api.ingest.channel.PipelineChannel;
+import org.apache.shardingsphere.data.pipeline.api.ingest.record.DataRecord;
+import org.apache.shardingsphere.data.pipeline.api.ingest.record.FinishedRecord;
+import org.apache.shardingsphere.data.pipeline.api.ingest.record.PlaceholderRecord;
+import org.apache.shardingsphere.data.pipeline.api.ingest.record.Record;
+import org.apache.shardingsphere.data.pipeline.api.job.JobOperationType;
+import org.apache.shardingsphere.data.pipeline.api.job.progress.listener.PipelineJobProgressUpdatedParameter;
+import org.apache.shardingsphere.data.pipeline.cdc.core.ack.CDCAckId;
+import org.apache.shardingsphere.data.pipeline.cdc.core.ack.CDCAckPosition;
+import org.apache.shardingsphere.data.pipeline.spi.importer.sink.PipelineSink;
+import org.apache.shardingsphere.data.pipeline.spi.ratelimit.JobRateLimitAlgorithm;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.PriorityQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+/**
+ * CDC importer.
+ */
+@RequiredArgsConstructor
+@Slf4j
+public final class CDCImporter extends AbstractLifecycleExecutor implements Importer {
+    
+    @Getter
+    private final String importerId = RandomStringUtils.randomAlphanumeric(8);
+    
+    private final List<CDCChannelProgressPair> originalChannelProgressPairs;
+    
+    private final int batchSize;
+    
+    private final long timeout;
+    
+    private final TimeUnit timeUnit;
+    
+    private final PipelineSink sink;
+    
+    private final boolean needSorting;
+    
+    private final JobRateLimitAlgorithm rateLimitAlgorithm;
+    
+    private final PriorityQueue<CSNRecords> csnRecordsQueue = new PriorityQueue<>(new CSNRecordsComparator());
+    
+    private final Cache<String, Pair<CDCChannelProgressPair, CDCAckPosition>> ackCache = CacheBuilder.newBuilder().maximumSize(10000).expireAfterAccess(5, TimeUnit.MINUTES).build();

Review Comment:
   Maybe `caffeine` has better performance than `guava`
   https://medium.com/outbrain-engineering/oh-my-guava-we-are-moving-to-caffeine-99387819fdbb
   
   And do we need to print something when the expiration policy is triggered?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] azexcy merged pull request #25994: Refactor CDC layer

Posted by "azexcy (via GitHub)" <gi...@apache.org>.
azexcy merged PR #25994:
URL: https://github.com/apache/shardingsphere/pull/25994


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org