async void Initialize() { // TODO: Figure out how to verify the transition from // "old table only" to "in migration" to "new table only". // (I don't think this is the biggest risk, but I'm still // interested in verifying it.) // I assume once we do that, the possibility of insertions while // we're in "old table only" will model the ability to start // from a nonempty table. configService = new InMemoryConfigurationService <MTableConfiguration>( MasterMigratingTable.INITIAL_CONFIGURATION); oldTable = new InMemoryTable(); newTable = new InMemoryTable(); referenceTable = new InMemoryTableWithHistory(); #if false // Second partition from the example in: // https://microsoft.sharepoint.com/teams/toolsforeng/Shared%20Documents/ContentRepository/LiveMigration/Migration_slides.pptx MTableEntity eMeta = new MTableEntity { PartitionKey = MigrationModel.SINGLE_PARTITION_KEY, RowKey = MigratingTable.ROW_KEY_PARTITION_META, partitionState = MTablePartitionState.SWITCHED, }; MTableEntity e0 = TestUtils.CreateTestMTableEntity("0", "orange"); MTableEntity e1old = TestUtils.CreateTestMTableEntity("1", "red"); MTableEntity e2new = TestUtils.CreateTestMTableEntity("2", "green"); MTableEntity e3old = TestUtils.CreateTestMTableEntity("3", "blue"); MTableEntity e3new = TestUtils.CreateTestMTableEntity("3", "azure"); MTableEntity e4old = TestUtils.CreateTestMTableEntity("4", "yellow"); MTableEntity e4new = TestUtils.CreateTestMTableEntity("4", null, true); var oldBatch = new TableBatchOperation(); oldBatch.InsertOrReplace(eMeta); oldBatch.InsertOrReplace(e0); oldBatch.InsertOrReplace(e1old); oldBatch.InsertOrReplace(e3old); oldBatch.InsertOrReplace(e4old); IList <TableResult> oldTableResult = await oldTable.ExecuteBatchAsync(oldBatch); await ExecuteExportedMirrorBatchAsync(oldBatch, oldTableResult); var newBatch = new TableBatchOperation(); newBatch.InsertOrReplace(e0); newBatch.InsertOrReplace(e2new); newBatch.InsertOrReplace(e3new); newBatch.InsertOrReplace(e4new); IList <TableResult> newTableResult = await newTable.ExecuteBatchAsync(newBatch); // Allow rows to overwrite rather than composing the virtual ETags manually. // InsertOrReplace doesn't use the ETag, so we don't care that the ETag was mutated by the original batch. await ExecuteExportedMirrorBatchAsync(newBatch, newTableResult); #endif // Start with the old table now. var batch = new TableBatchOperation(); batch.InsertOrReplace(TestUtils.CreateTestEntity("0", "orange")); batch.InsertOrReplace(TestUtils.CreateTestEntity("1", "red")); batch.InsertOrReplace(TestUtils.CreateTestEntity("3", "blue")); batch.InsertOrReplace(TestUtils.CreateTestEntity("4", "yellow")); IList <TableResult> oldTableResult = await oldTable.ExecuteBatchAsync(batch); // InsertOrReplace doesn't use the ETag, so we don't care that the ETag was mutated by the original batch. await referenceTable.ExecuteMirrorBatchAsync(batch, oldTableResult); //CreateMonitor(typeof(RunningServiceMachinesMonitor)); for (int i = 0; i < MigrationModel.NUM_SERVICE_MACHINES; i++) { InitializeAppMachine(CreateMachine(typeof(ServiceMachine))); } InitializeAppMachine(CreateMachine(typeof(MigratorMachine))); Send(Id, new TablesMachineInitializedEvent()); }