nizhikov commented on code in PR #11044:
URL: https://github.com/apache/ignite/pull/11044#discussion_r1401038909


##########
modules/core/src/main/java/org/apache/ignite/internal/cdc/CdcUtilityActiveCdcManager.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.ignite.internal.cdc;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.pagemem.wal.record.CdcManagerStopRecord;
+import 
org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter;
+import org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.jetbrains.annotations.Nullable;
+
+import static org.apache.ignite.internal.cdc.CdcMain.stateDirFile;
+
+/**
+ * CDC manager that delegates consuming CDC events to the {@link CdcMain} 
utility.
+ */
+public class CdcUtilityActiveCdcManager extends GridCacheSharedManagerAdapter 
implements CdcManager {
+    /** If {@code true} then should notify {@link CdcMain} to start consuming 
WAL segments. */
+    private boolean writeStopRecord;
+
+    /** {@inheritDoc} */
+    @Override protected void start0() throws IgniteCheckedException {
+        try {
+            Path stateDir = stateDirFile(cctx).toPath();
+
+            Files.createDirectories(stateDir);
+
+            CdcConsumerState state = new CdcConsumerState(log, stateDir);
+
+            state.saveCdcMode(CdcMode.CDC_UTILITY_ACTIVE);

Review Comment:
   Why do we need to write this file by the node process?
   It seems like we must have the following flow:
   
   1. `CdcManager` starts active, by default.
   2. If cdcMode file exists then `CdcManager` switches off.
   
   ===
   
   1. `ignite-cdc.sh` start passive, by default.
   2. If cdcMode file exists then `ignite-cdc.sh` switch on
   3. If `ignite-cdc.sh` finds `CdcManagerStorRecord` then `ignite-cdc.sh` 
switch on
   3a. On activate `ignite-cdc.sh` write cdcMode file.
   
   So
   
   Node - writes CdcManagerStopreRecord, read cdcMode file
   ignite-cdc.sh - read CdcManagerStopreRecord, read/write cdcMode file.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to