This is an automated email from the ASF dual-hosted git repository.

sanpwc pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/main by this push:
     new b3cdd64101 IGNITE-18525 New PlacementDriver Ignite component is 
introduced (#1538)
b3cdd64101 is described below

commit b3cdd64101288cfdd51b7cf9909f6e0098747ef8
Author: Vladislav Pyatkov <[email protected]>
AuthorDate: Thu Jan 19 21:40:23 2023 +0400

    IGNITE-18525 New PlacementDriver Ignite component is introduced (#1538)
---
 modules/placement-driver/README.md                 |  30 +++++++++++
 modules/placement-driver/build.gradle              |  32 +++++++++++
 .../placement-driver/docs/initial-lease-grant.png  | Bin 0 -> 49994 bytes
 modules/placement-driver/docs/lease_renewal.png    | Bin 0 -> 39152 bytes
 .../placementdriver/PlacementDriverManager.java    |  60 +++++++++++++++++++++
 modules/runner/build.gradle                        |   1 +
 .../org/apache/ignite/internal/app/IgniteImpl.java |   7 +++
 settings.gradle                                    |   2 +
 8 files changed, 132 insertions(+)

diff --git a/modules/placement-driver/README.md 
b/modules/placement-driver/README.md
new file mode 100644
index 0000000000..13fcb97d62
--- /dev/null
+++ b/modules/placement-driver/README.md
@@ -0,0 +1,30 @@
+# Placement driver
+
+The module performs two functions:
+- responsible for a primary replica (member or replication group, which holds 
a lease) selection and fail-over;
+- provides an API in order to retrieve the information about available primary 
replicas along with corresponding meta such as leaseholder 
+interval.
+
+The primary replica is a replica which holds a lease. Only a primary replica 
can execute RW transaction operations (RW transaction is
+described in ignite-transaction module).
+
+## Leaseholder management
+Placement driver logically depends on the assignments and logical topology. 
The manager listens change of group members (due to a particular
+data zone shrink or growing) and appear / disappear nodes in logical topology. 
The list of possible leaseholders depends on nodes in 
+assignment according to nodes available in the current topology. The process 
of acquire lease:
+1. Any change of topology or assignment can be a trigger of lease providing.
+2. One replica among of available replica is chosen by the placement driver.
+3. An information about The chosen replica is spread across all cluster nodes.
+
+The leaseholder is able to be elected only when group members are enough. This 
is the reason for the placement driver to await all group
+members before primary replica selection.
+
+The initial lease grant process is represented in the diagram:
+![Query Preparation Flow](docs/initial-lease-grant.png)
+All members know that the lease is already released when a lease expired in 
placement driver, because it has correction on clock skew
+interval.
+
+After the primary replica is elected, it starts sending keep-alive messages in 
order to renew its lease interval. Otherwise, a new 
+leaseholder will be elected.
+
+![Query Preparation Flow](docs/lease_renewal.png)
\ No newline at end of file
diff --git a/modules/placement-driver/build.gradle 
b/modules/placement-driver/build.gradle
new file mode 100644
index 0000000000..3b51f0143b
--- /dev/null
+++ b/modules/placement-driver/build.gradle
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+apply from: "$rootDir/buildscripts/java-core.gradle"
+apply from: "$rootDir/buildscripts/publishing.gradle"
+apply from: "$rootDir/buildscripts/java-junit5.gradle"
+apply from: "$rootDir/buildscripts/java-integration-test.gradle"
+apply from: "$rootDir/buildscripts/java-test-fixtures.gradle"
+
+dependencies {
+    implementation project(':ignite-metastorage-api')
+
+    implementation project(':ignite-core')
+
+    implementation libs.jetbrains.annotations
+}
+
+description = 'ignite-placement-driver'
diff --git a/modules/placement-driver/docs/initial-lease-grant.png 
b/modules/placement-driver/docs/initial-lease-grant.png
new file mode 100644
index 0000000000..79fff2dbc8
Binary files /dev/null and 
b/modules/placement-driver/docs/initial-lease-grant.png differ
diff --git a/modules/placement-driver/docs/lease_renewal.png 
b/modules/placement-driver/docs/lease_renewal.png
new file mode 100644
index 0000000000..7390fde650
Binary files /dev/null and b/modules/placement-driver/docs/lease_renewal.png 
differ
diff --git 
a/modules/placement-driver/src/main/java/org/apache/ignite/internal/placementdriver/PlacementDriverManager.java
 
b/modules/placement-driver/src/main/java/org/apache/ignite/internal/placementdriver/PlacementDriverManager.java
new file mode 100644
index 0000000000..a30a9c040f
--- /dev/null
+++ 
b/modules/placement-driver/src/main/java/org/apache/ignite/internal/placementdriver/PlacementDriverManager.java
@@ -0,0 +1,60 @@
+/*
+ * 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.placementdriver;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.ignite.internal.manager.IgniteComponent;
+import org.apache.ignite.internal.metastorage.MetaStorageManager;
+import org.apache.ignite.internal.util.IgniteSpinBusyLock;
+
+/**
+ * Placement driver manager.
+ * The manager is a leaseholder tracker: response of renewal of the lease and 
discover of appear/disappear of a replication group member.
+ * The another role of the manager is providing a node, which is leaseholder 
at the moment, for a particular replication group.
+ */
+public class PlacementDriverManager implements IgniteComponent {
+    /** Busy lock to stop synchronously. */
+    private final IgniteSpinBusyLock busyLock = new IgniteSpinBusyLock();
+
+    /** Prevents double stopping of the component. */
+    private final AtomicBoolean isStopped = new AtomicBoolean();
+
+    /**
+     * The constructor.
+     *
+     * @param metaStorageMgr Meta Storage manager.
+     */
+    public PlacementDriverManager(MetaStorageManager metaStorageMgr) {
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void start() {
+
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void stop() throws Exception {
+        if (!isStopped.compareAndSet(false, true)) {
+            return;
+        }
+
+        busyLock.block();
+    }
+}
diff --git a/modules/runner/build.gradle b/modules/runner/build.gradle
index 09fb955754..14e500133f 100644
--- a/modules/runner/build.gradle
+++ b/modules/runner/build.gradle
@@ -54,6 +54,7 @@ dependencies {
     implementation project(':ignite-metrics')
     implementation project(':ignite-replicator')
     implementation project(':ignite-distribution-zones')
+    implementation project(':ignite-placement-driver')
     implementation libs.jetbrains.annotations
     implementation libs.micronaut.inject
     implementation libs.micronaut.validation
diff --git 
a/modules/runner/src/main/java/org/apache/ignite/internal/app/IgniteImpl.java 
b/modules/runner/src/main/java/org/apache/ignite/internal/app/IgniteImpl.java
index 97283c2e8d..e9d936e4ce 100644
--- 
a/modules/runner/src/main/java/org/apache/ignite/internal/app/IgniteImpl.java
+++ 
b/modules/runner/src/main/java/org/apache/ignite/internal/app/IgniteImpl.java
@@ -74,6 +74,7 @@ import 
org.apache.ignite.internal.metrics.rest.MetricRestFactory;
 import org.apache.ignite.internal.metrics.sources.JvmMetricSource;
 import org.apache.ignite.internal.network.configuration.NetworkConfiguration;
 import 
org.apache.ignite.internal.network.configuration.NetworkConfigurationSchema;
+import org.apache.ignite.internal.placementdriver.PlacementDriverManager;
 import org.apache.ignite.internal.raft.Loza;
 import org.apache.ignite.internal.raft.configuration.RaftConfiguration;
 import 
org.apache.ignite.internal.raft.storage.impl.VolatileLogStorageFactoryCreator;
@@ -189,6 +190,9 @@ public class IgniteImpl implements Ignite {
     /** Meta storage manager. */
     private final MetaStorageManager metaStorageMgr;
 
+    /** Placement driver manager. */
+    private final PlacementDriverManager placementDriverMgr;
+
     /** Configuration manager that handles cluster (distributed) 
configuration. */
     private final ConfigurationManager clusterCfgMgr;
 
@@ -341,6 +345,8 @@ public class IgniteImpl implements Ignite {
                 new 
RocksDbKeyValueStorage(workDir.resolve(METASTORAGE_DB_PATH))
         );
 
+        placementDriverMgr = new PlacementDriverManager(metaStorageMgr);
+
         this.cfgStorage = new DistributedConfigurationStorage(metaStorageMgr, 
vaultMgr);
 
         clusterCfgMgr = new ConfigurationManager(
@@ -570,6 +576,7 @@ public class IgniteImpl implements Ignite {
                         try {
                             lifecycleManager.startComponents(
                                     metaStorageMgr,
+                                    placementDriverMgr,
                                     clusterCfgMgr,
                                     metricManager,
                                     distributionZoneManager,
diff --git a/settings.gradle b/settings.gradle
index 9806f099fc..5ee56ae73d 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -64,6 +64,7 @@ include(':packaging-db')
 include(':packaging')
 include(':ignite-replicator')
 include(':ignite-distribution-zones')
+include(':ignite-placement-driver')
 
 project(":ignite-examples").projectDir = file('examples')
 project(":ignite-page-memory").projectDir = file('modules/page-memory')
@@ -113,6 +114,7 @@ project(":packaging-cli").projectDir = file('packaging/cli')
 project(":packaging-db").projectDir = file('packaging/db')
 project(":packaging").projectDir = file('packaging')
 project(":ignite-distribution-zones").projectDir = 
file('modules/distribution-zones')
+project(":ignite-placement-driver").projectDir = 
file('modules/placement-driver')
 
 ext.isCiServer = System.getenv().containsKey("IGNITE_CI")
 

Reply via email to