|
| 1 | +.. _c2c-api-commit: |
| 2 | + |
| 3 | +========== |
| 4 | +``commit`` |
| 5 | +========== |
| 6 | + |
| 7 | +.. default-domain:: mongodb |
| 8 | + |
| 9 | +.. contents:: On this page |
| 10 | + :local: |
| 11 | + :backlinks: none |
| 12 | + :depth: 2 |
| 13 | + :class: singlecol |
| 14 | + |
| 15 | +Description |
| 16 | +----------- |
| 17 | + |
| 18 | +Commits the synchronization operation to the destination cluster. |
| 19 | + |
| 20 | +Requirements |
| 21 | +------------ |
| 22 | + |
| 23 | +Before using the ``commit`` endpoint: |
| 24 | + |
| 25 | +- Stop your application. This ensures that no additional writes occur on |
| 26 | + the source cluster. |
| 27 | + |
| 28 | +- Use the :ref:`progress <c2c-api-progress>` endpoint to confirm the |
| 29 | + following values: |
| 30 | + |
| 31 | + - ``state: "RUNNING"`` |
| 32 | + - ``canCommit: true`` |
| 33 | + - ``lagTimeSeconds`` is near ``0`` (*Recommended, but not required*) |
| 34 | + |
| 35 | + .. note:: lagTimeSeconds |
| 36 | + |
| 37 | + ``lagTimeSeconds`` indicates the time between the last applied |
| 38 | + event and time of the current latest event. When you send a |
| 39 | + ``commit`` request, {+c2c-product-name+} enters the |
| 40 | + ``COMMITTING`` state for the amount of seconds reported by |
| 41 | + ``lagTimeSeconds``, and then transitions to the ``COMMITTED`` |
| 42 | + state. |
| 43 | + |
| 44 | + When ``lagTimeSeconds`` is ``0``, the source and destination |
| 45 | + clusters are in a consistent state. |
| 46 | + |
| 47 | +Request |
| 48 | +------- |
| 49 | + |
| 50 | +.. code-block:: http |
| 51 | + |
| 52 | + POST /api/v1/commit |
| 53 | + |
| 54 | +Request Body Parameters |
| 55 | +~~~~~~~~~~~~~~~~~~~~~~~ |
| 56 | + |
| 57 | +.. include:: includes/api/facts/no-body-parameters.rst |
| 58 | + |
| 59 | +Response |
| 60 | +-------- |
| 61 | + |
| 62 | +.. include:: /includes/api/tables/basic-response.rst |
| 63 | + |
| 64 | +Example |
| 65 | +------- |
| 66 | + |
| 67 | +The following example commits the synchronization operation to the |
| 68 | +destination cluster. |
| 69 | + |
| 70 | +Confirm that the Synchronization is Ready |
| 71 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 72 | + |
| 73 | +Before sending a request to the ``commit`` endpoint, use the |
| 74 | +:ref:`progress <c2c-api-progress>` endpoint to confirm that the |
| 75 | +synchronization is ready to be committed. |
| 76 | + |
| 77 | +Request |
| 78 | +``````` |
| 79 | + |
| 80 | +.. literalinclude:: /includes/api/requests/progress.sh |
| 81 | + :language: shell |
| 82 | + |
| 83 | +Response |
| 84 | +```````` |
| 85 | + |
| 86 | +.. literalinclude:: /includes/api/responses/progress.json |
| 87 | + :language: shell |
| 88 | + :emphasize-lines: 5 |
| 89 | + |
| 90 | +The ``progress`` endpoint returned ``"canCommit":true``, which means |
| 91 | +that the ``commit`` request can run successfully. |
| 92 | + |
| 93 | +Send the Commit Request |
| 94 | +~~~~~~~~~~~~~~~~~~~~~~~ |
| 95 | + |
| 96 | +The following command sends a request to the ``commit`` endpoint: |
| 97 | + |
| 98 | +Request |
| 99 | +``````` |
| 100 | + |
| 101 | +.. literalinclude:: /includes/api/requests/commit.sh |
| 102 | + :language: shell |
| 103 | + |
| 104 | +Response |
| 105 | +```````` |
| 106 | + |
| 107 | +.. literalinclude:: /includes/api/responses/success.json |
| 108 | + :language: json |
| 109 | + |
| 110 | +Behavior |
| 111 | +-------- |
| 112 | + |
| 113 | +If the ``commit`` request is successful, {+c2c-product-name+} enters the |
| 114 | +``COMMITTING`` state, then automatically transitions to the |
| 115 | +``COMMITTED`` state. |
0 commit comments