/// <summary> /// TM dies before receiving Done from all RMs, on recovery, TM should recommit /// </summary> public void TMFailsBeforeReceivingAllDone2PC() { StartUp(); Transaction t = WorkflowControl.Start(); TransactionManager.SelfDestruct(false, true); WorkflowControl.AddCars(t, "Seattle", 10, 100); ThreadPool.QueueUserWorkItem(o => WorkflowControl.Commit(t)); // TM shall be kill, now restart it Console.Write("TM is killed, next is to restart it"); Pause(); StartTM(); // Wait to make sure all recover job is done // shall see the transaction recommits. t = WorkflowControl.Start(); string actual = PrintCars(); Assert.AreEqual("Vegas,1,3;NewYork,10,30;", actual); actual = PrintRooms(); Assert.AreEqual("Vegas,2,1;NewYork,20,10;", actual); actual = PrintFlights(); Assert.AreEqual("SEA->LAX,10,2;LAX->LAV,12,3;SEA->JFK,8,4;", actual); actual = PrintCustomers(); Assert.AreEqual("", actual); }
/// <summary> /// All RM prepared, one RM dies before receiving Commit, on recovery, the RM should recover the transaction, WC shouldn’t notice this /// </summary> public void ReCommitAfterRmFailTransaction2PC() { StartUp(); CarsRM.SelfDestruct(0, 0, 1, 0); Customer c = new Customer("12345678-1234-1234-1234-123456789012"); string[] flights = new string[] { "SEA->LAX", "LAX->LAV" }; ThreadPool.QueueUserWorkItem(o => { Thread.Sleep(1000); CarsRM.SelfDestruct(0, 0, 0, 0); }); WorkflowControl.ReserveItinerary(c, flights, "Vegas", true, true); // We shall see some commit retry message from TM but the transaction shall success. Transaction t = WorkflowControl.Start(); string actual = WorkflowControl.QueryItinerary(t, c); Console.WriteLine(actual); Assert.AreEqual("F:SEA->LAX,F:LAX->LAV,C:Vegas,R:Vegas", actual); actual = PrintCars(); Assert.AreEqual("Vegas,0,3;NewYork,10,30;", actual); actual = PrintRooms(); Assert.AreEqual("Vegas,1,1;NewYork,20,10;", actual); actual = PrintFlights(); Assert.AreEqual("SEA->LAX,9,2;LAX->LAV,11,3;SEA->JFK,8,4;", actual); actual = PrintCustomers(); Assert.AreEqual("12345678-1234-1234-1234-123456789012;", actual); }
/// <summary> /// Add an itinerary, kill RM before commit. Restart the RMs and you can see nothing changed (still c1 state). Demo shadow copy works after failure /// </summary> public void UncommittedScenario() { StartUp(); Console.WriteLine("Flight RM shall terminate before transaction commits. "); Customer c = new Customer("12345678-1234-1234-1234-123456789012"); FlightsRM.SelfDestruct(2, 0, 0, 0); string[] flights = new string[] { "SEA->LAX", "LAX->LAV" }; try { WorkflowControl.ReserveItinerary(c, flights, "Vegas", true, true); } catch (WebException e) { // Expected error because one of the RM will be selfdestroyed. Console.WriteLine(e.Message); } Console.WriteLine("Restarting flight RM"); StartFlightsRM(); Transaction t = WorkflowControl.Start(); string actual = WorkflowControl.QueryItinerary(t, c); Console.WriteLine(actual); Assert.AreEqual("", actual); actual = PrintCars(); Assert.AreEqual("Vegas,1,3;NewYork,10,30;", actual); actual = PrintRooms(); Assert.AreEqual("Vegas,2,1;NewYork,20,10;", actual); actual = PrintFlights(); Assert.AreEqual("SEA->LAX,10,2;LAX->LAV,12,3;SEA->JFK,8,4;", actual); actual = PrintCustomers(); Assert.AreEqual("", actual); }
private void listaProcesosWorkflow_CellClick(object sender, DataGridViewCellEventArgs e) { this.ComboParametro.Items.Clear(); this.ComboParametro.Text = ""; this.labelSiguienteEstado.Text = ""; var index = this.listaProcesosWorkflow.SelectedCells[0].RowIndex; var parametro = ""; int idProcesoWorkflow = int.Parse(this.listaProcesosWorkflow.Rows[index].Cells[0].Value.ToString()); if (!(ComboParametro.SelectedItem == null)) { parametro = this.ComboParametro.SelectedValue.ToString(); } this.labelNombreParametro.Text = new WorkflowControl().getDescripcionParametrosSiguienteEstado(idProcesoWorkflow); var parametros = new WorkflowControl().getParametrosToSiguienteEstado(idProcesoWorkflow); if (parametros != null) { foreach (var par in parametros) { this.ComboParametro.Items.Add(par.valor_parametro); } } this.labelSiguienteEstado.Text = new WorkflowControl().getNombreEstadoToParametro(idProcesoWorkflow, parametro); }
public string IniciarWorkflow2(string[] args) { WorkflowControl wfcontrol = new WorkflowControl(); int response = wfcontrol.IniciarWorkflow(int.Parse(args[0])); return("IdProcesoWorkflow: " + response.ToString()); }
/// <summary> /// T1, T2 write R1, T1 commit, T2 abort, see only T1's change in. Demo abort. /// </summary> public void ConcurrentCommitAbort() { StartUp(); Transaction t1 = WorkflowControl.Start(); Transaction t2 = WorkflowControl.Start(); AutoResetEvent sync1 = new AutoResetEvent(false); AutoResetEvent sync2 = new AutoResetEvent(false); ThreadPool.QueueUserWorkItem(o => { WorkflowControl.AddCars(t1, "Seattle", 1, 3); WorkflowControl.Commit(t1); sync1.Set(); }); ThreadPool.QueueUserWorkItem(o => { WorkflowControl.AddCars(t2, "Seattle", 2, 2); WorkflowControl.Abort(t2); sync2.Set(); }); // here is just to make sure t2 commits before t1, so the price will be 2. sync1.WaitOne(); sync2.WaitOne(); string actual = PrintCars(); Assert.AreEqual("Vegas,1,3;NewYork,10,30;Seattle,1,3;", actual); }
/// <summary> /// All RMs returns prepared, except one fails to prepare, the transaction should abort /// </summary> public void RollbackAfterRmFailTransaction2PC() { StartUp(); CarsRM.SelfDestruct(0, 1, 0, 0); Customer c = new Customer("12345678-1234-1234-1234-123456789012"); string[] flights = new string[] { "SEA->LAX", "LAX->LAV" }; WorkflowControl.ReserveItinerary(c, flights, "Vegas", true, true); // We shall see some rollback message from TM. Console.WriteLine("One RM failed at prepare. TM will rollback all prepared RMs"); Pause(); Transaction t = WorkflowControl.Start(); string actual = WorkflowControl.QueryItinerary(t, c); Console.WriteLine(actual); Assert.AreEqual("", actual); actual = PrintCars(); Assert.AreEqual("Vegas,1,3;NewYork,10,30;", actual); actual = PrintRooms(); Assert.AreEqual("Vegas,2,1;NewYork,20,10;", actual); actual = PrintFlights(); Assert.AreEqual("SEA->LAX,10,2;LAX->LAV,12,3;SEA->JFK,8,4;", actual); actual = PrintCustomers(); Assert.AreEqual("", actual); }
private void btnActualizar_Click(object sender, EventArgs e) { var listapw = new WorkflowControl().GetProcesosWorkflow().Select(x => new { Id = x.id, Workflow = x.workflow.nombre, Estado_actual = x.id_estado_actual, nombre = x.estados.nombre }).ToList(); this.listaProcesosWorkflow.DataSource = listapw; this.listaProcesosWorkflow_CellClick("", null); }
private void InitInventory() { Transaction t = WorkflowControl.Start(); WorkflowControl.AddCars(t, "Vegas", 1, 3); WorkflowControl.AddRooms(t, "Vegas", 2, 1); WorkflowControl.AddCars(t, "NewYork", 10, 30); WorkflowControl.AddRooms(t, "NewYork", 20, 10); WorkflowControl.AddSeats(t, "SEA->LAX", 10, 2); WorkflowControl.AddSeats(t, "LAX->LAV", 12, 3); WorkflowControl.AddSeats(t, "SEA->JFK", 8, 4); WorkflowControl.Commit(t); }
private void btnCrear_Click(object sender, EventArgs e) { var wf = new WorkflowControl(); var idpw = wf.IniciarWorkflow(int.Parse(Convert.ToString(this.comboBox1.SelectedValue))); if (idpw > 0) { MessageBox.Show("El Proceso workflow con id: " + idpw + " fue creado exitosamente"); } else { MessageBox.Show("Existen errores al crear el proceso de workflow"); } }
public Form1() { InitializeComponent(); var wws = new WorkflowControl().GetWorkflows().Select(x => new { nombre = x.nombre, id = x.id }).ToList(); this.comboBox1.DataSource = wws; this.comboBox1.ValueMember = "id"; this.comboBox1.DisplayMember = "nombre"; this.labelSiguienteEstadoTitulo.Visible = false; }
public DockProcessDesigner() { InitializeComponent(); workflowControl = new WorkflowControl(); workflowControl.Dock = DockStyle.Fill; workflowControl.OnSave += new WorkflowControl.SaveEventHandler(process_Save); workflowControl.OnInit += new WorkflowControl.InitEventHandler(process_Init); this.Controls.Add(workflowControl); workflowEngine = new WorkflowEngine(); workflowControl.Document = workflowEngine.Document; workflowControl.RedrawAll(); }
private void btnSigEstado_Click(object sender, EventArgs e) { var index = this.listaProcesosWorkflow.SelectedCells[0].RowIndex; var parametro = ""; int idProcesoWorkflow = int.Parse(this.listaProcesosWorkflow.Rows[index].Cells[0].Value.ToString()); if (!(ComboParametro.SelectedItem == null)) { parametro = this.ComboParametro.Text; } string siguienteEstado = new WorkflowControl().SiguienteEstado(idProcesoWorkflow, parametro); this.btnActualizar_Click("", null); }
private string PrintFlights() { Transaction t = this.WorkflowControl.Start(); string[] items = WorkflowControl.ListFlights(t); string result = string.Empty; foreach (string r in items) { result += (r + ";"); } Console.WriteLine(result); return(result); }
private string PrintCustomers() { Transaction t = this.WorkflowControl.Start(); Customer[] items = WorkflowControl.ListCustomers(t); string result = string.Empty; foreach (var r in items) { result += (r.Id + ";"); } Console.WriteLine(result); return(result); }
/// <summary> /// Submit an itinerary with car, flight and hotel. Show the values are updated. Demo Read, write and commit. /// </summary> public void AddOneItinerary() { StartUp(); Customer c = new Customer("12345678-1234-1234-1234-123456789012"); string[] flights = new string[] { "SEA->LAX", "LAX->LAV" }; WorkflowControl.ReserveItinerary(c, flights, "Vegas", true, true); Transaction t = WorkflowControl.Start(); string actual = WorkflowControl.QueryItinerary(t, c); Console.WriteLine(actual); Assert.AreEqual("F:SEA->LAX,F:LAX->LAV,C:Vegas,R:Vegas", actual); actual = PrintCars(); Assert.AreEqual("Vegas,0,3;NewYork,10,30;", actual); actual = PrintRooms(); Assert.AreEqual("Vegas,1,1;NewYork,20,10;", actual); actual = PrintFlights(); Assert.AreEqual("SEA->LAX,9,2;LAX->LAV,11,3;SEA->JFK,8,4;", actual); actual = PrintCustomers(); Assert.AreEqual("12345678-1234-1234-1234-123456789012;", actual); }
public void AddDialogueButton(WorkflowControl workflowControl) { workflowControl.ShowLigthButton = false; workflowControl.ShowMainButton = false; AddDialogueButton(workflowControl.Text, workflowControl.GetClientStartScript()); }