Skip to content

Commit 4d2ee51

Browse files
committed
modification on Provision.rst [SKIP CI]
1 parent a86daa0 commit 4d2ee51

File tree

1 file changed

+58
-2
lines changed

1 file changed

+58
-2
lines changed

docs/Provision.rst

+58-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ First of all, if you are just using ``agent.SynchronizeAsync()``, everything wil
119119

120120
But you can use the **orchestrators** to do the job. It will allow you to migrate your setup, without having to make a synchronization.
121121

122-
You have 2 new methods on both orchestrators:
122+
You have one new method on both orchestrators:
123123

124124
On ``LocalOrchestrator``:
125125

@@ -192,7 +192,7 @@ For instance, the ``RemoteOrchestrator`` ``MigrationAsync`` could be really usef
192192

193193
Once migrated, all new clients, will get the new setup from the server, and will apply locally the migration, automatically.
194194

195-
What Setup migration doesn't do !
195+
What Setup migration does not do !
196196
-----------------------------------
197197

198198
Be careful, the migration stuff will **only** allows you to migrate your setup (adding or removing tables from your sync, renaming stored proc and so on ...)
@@ -214,6 +214,62 @@ But, it won't work if:
214214
If you have to deal with this kind of situation, the best solution is to handle this migration by yourself using ``ProvisionAsync`` and ``DeprovisionAsync`` methods.
215215

216216

217+
Last timestamp sync
218+
-----------------------
219+
220+
| What happens if you're adding a new table ?
221+
| What will happen on the next sync ?
222+
| Well as we said the new table will be provisioned (stored proc, triggers and tracking table) on both databases (server / client) and the table will be created on the client.
223+
224+
Then the **DMS** framework will make a sync ....
225+
226+
And this sync will get all the rows from the server side **that have changed since the last sucessful sync**
227+
228+
And your new table on the client database has ... **NO ROWS** !!!
229+
230+
| Because no rows have been marked as **changed** in the server tracking table since the last sync process.
231+
| Indeed, we've just created this tracking table on the server !!
232+
233+
So, if you're adding a new table, you **MUST** do a full sync, calling the ``SynchronizeAsync()`` method with a ``SyncType.Reinitialize`` or ``SyncType.ReinitializeWithUpload`` parameter.
234+
235+
| Adding a new table is not trivial.
236+
| Hopefully if you are using ``snapshots`` it should not be too heavy for your server database :)
237+
238+
Forcing Reinitialize sync type from server side.
239+
-------------------------------------------------
240+
241+
| As we saw, it could be useful to force a reinitialize from a client, to get all the needed data.
242+
| Unfortunatelly, you should have a *special* routine from the client side, to launch the synchronization with a ``SynchronizeAsync(SyntType.Reinitialize)``, like an admin button or whatever.
243+
244+
Fortunatelly, using an interceptor, from the **server side**, you are able to *force* the reinitialization from the client.
245+
246+
On the server side, from your controller, just modify the request `SyncContext` with the correct value, like this:
247+
248+
.. code-block:: csharp
249+
250+
[HttpPost]
251+
public async Task Post()
252+
{
253+
254+
// Get Orchestrator regarding the incoming scope name (from http context)
255+
var orchestrator = webServerManager.GetOrchestrator(this.HttpContext);
256+
257+
// override sync type to force a reinitialization from a particular client
258+
orchestrator.OnServerScopeLoaded(sla =>
259+
{
260+
// ClientId represents one client. If you want to reinitialize ALL clients,
261+
// just remove this condition
262+
if (sla.Context.ClientScopeId == clientId)
263+
{
264+
sla.Context.SyncType = SyncType.Reinitialize;
265+
}
266+
});
267+
268+
// handle request
269+
await webServerManager.HandleRequestAsync(this.HttpContext);
270+
}
271+
272+
217273
Provision / Deprovision
218274
^^^^^^^^^^^^^^^^^^^^^^^^
219275

0 commit comments

Comments
 (0)