public void run() { CancellationTokenRegistration ctr = proxytoken.Register(CancelAsync); connectToServers(); while (!proxytoken.IsCancellationRequested) { try { // Get command from Middleman and process it waitingForCommit = 0; commited = 0; commit = null; accepted = 0; Command cmd = monitor.Fetch(); processCommand(cmd); } catch (NullReferenceException nre) { //TEMP break; } } ctr.Dispose(); }
public CommitForm(CommandCommit gitCommand) { InitializeComponent(); _gitCommand = gitCommand; _items = new List <ListViewItem>(); _groups = new List <ListViewGroup>() { new ListViewGroup("VBDocuments", "Documents"), new ListViewGroup("VBForms", "Forms"), new ListViewGroup("VBModules", "Modules"), new ListViewGroup("VBClassModules", "Class Modules") }; CommitList.Groups.AddRange(_groups.ToArray()); ColumnName.Text = VBAGitUI.Name; ColumnExtension.Text = VBAGitUI.Extension; ColumnStatus.Text = VBAGitUI.Status; LabelCommit.Text = VBAGitUI.CommitForm_LabelCommit; NewBranch.Text = VBAGitUI.CommitForm_NewBranch; GroupMessage.Text = VBAGitUI.CommitForm_GroupMessage; SetAuthorDate.Text = VBAGitUI.CommitForm_SetAuthorDate; SetAuthor.Text = VBAGitUI.CommitForm_SetAuthor; AddSignedoffby.Text = VBAGitUI.CommitForm_AddSignedoffby; GroupChanges.Text = VBAGitUI.CommitForm_GroupChanges; LabelCheck.Text = VBAGitUI.CommitForm_LabelCheck; CheckAll.Text = VBAGitUI.CommitForm_CheckAll; CheckNone.Text = VBAGitUI.CommitForm_CheckNone; CheckUnversioned.Text = VBAGitUI.CommitForm_CheckUnversioned; CheckVersioned.Text = VBAGitUI.CommitForm_CheckVersioned; CheckAdded.Text = VBAGitUI.CommitForm_CheckAdded; CheckDeleted.Text = VBAGitUI.CommitForm_CheckDeleted; CheckModified.Text = VBAGitUI.CommitForm_CheckModified; ShowUnversionedFiles.Text = VBAGitUI.CommitForm_ShowUnversionedFiles; LabelSelected.Text = string.Format(VBAGitUI.CommitForm_LabelSelected, 0, 0); MessageOnly.Text = VBAGitUI.CommitForm_MessageOnly; EmptyCommitList.Text = VBAGitUI.CommitForm_WaitForUpdate; Commit.Text = VBAGitUI.CommitForm_Commit; Cancel.Text = VBAGitUI.Cancel; Author.Text = _gitCommand.Author; CommitBranch.Tag = string.Empty; CommitBranch.Text = _gitCommand.CurrentBranch; Application.Idle += Application_Idle; }
private void startOther(Command cmd) { // Pass command to every DHSs sendEveryone(cmd); if (!cmd.GetType().Equals(typeof(CommandRename)) && !cmd.GetType().Equals(typeof(CommandDelete))) { Console.WriteLine("Nieprawidlowy command"); return; } lock (schLock) { // Wait for CommitRdy from all servers while (waitingForCommit < serverList.Count && !token.IsCancellationRequested) { Monitor.Wait(schLock); } if (token.IsCancellationRequested) { return; } commit = new CommandCommit(); Console.WriteLine("Commit gotowy"); lock (dshLock) Monitor.PulseAll(dshLock); // Submit commit, wait for all CommitAcks while (commited < serverList.Count && !token.IsCancellationRequested) { Monitor.Wait(schLock); } if (token.IsCancellationRequested) { return; } waitingForCommit = 0; commited = 0; commit = null; Console.WriteLine("Dostarczono komende na kazdy serwer"); if (cmd.GetType().Equals(typeof(CommandRename))) { ((CommandRename)cmd).CmdProc.Incoming.Add(new CommandAccept(), token); } else if (cmd.GetType().Equals(typeof(CommandDelete))) { ((CommandDelete)cmd).CmdProc.Incoming.Add(new CommandAccept(), token); } } }
/// <summary> /// Commit changes to repository for project /// </summary> /// <param name="project">VBProject</param> public void Commit(VBProject project, IEnumerable <string> components = null) { try { EnableFileSystemWatcher = false; var repo = GetVBProjectRepository(project); using (var gitCommand = new CommandCommit(project, repo, components)) { gitCommand.Execute(); } } finally { EnableFileSystemWatcher = true; } }
private void commit() { // Let scheduler know you're ready for commit, wait for signal CommandCommit commit = scheduler.waitForCommit(); if (state == States.cancel) { rollback(); return; } cmdTrans.sendCmd(commit); Console.WriteLine("Wysylam commit..."); Command recvd = cmdTrans.getCmd(); if (!recvd.GetType().Equals(typeof(CommandCommitAck))) { if (state == States.cmdwait) { Console.WriteLine("DSH: Unexpected server response after cmd commit: " + recvd.GetType()); } else if (state == States.uplwait) { Console.WriteLine("DSH: Unexpected server response after upload commit: " + recvd.GetType()); } else { Console.WriteLine("DSH: Unexpected server response after commit: " + recvd.GetType()); } } else { Console.WriteLine("Potwierdzono commit."); scheduler.ConfirmCommit(); state = States.idle; } }
private void startUpload(CommandUpload cmd) { // Upload file on every server Console.WriteLine("Rozpoczynam upload"); foreach (DataServerHandler server in serverList) { server.addUpload(cmd); // Notify every server about upload } lock (schLock) { // Wait for Accept from every server while (accepted < serverList.Count) { Monitor.Wait(schLock); } } Console.WriteLine("Zaakceptowano upload na wszystkich serwerach"); // Prepare upload chunks for DSHs and wake them up cmd.CmdProc.Incoming.Add(new CommandAccept(), token); uplBuff = new CommandChunk[fileBufferSize]; maxFrag = (int)((cmd.Size + fragSizeUpl - 1) / fragSizeUpl); // Round up uplFrags = new byte[maxFrag]; lastSucc = 0; for (int i = 0; i < maxFrag; i++) { uplFrags[i] = 0; } for (int i = 0; i < fileBufferSize && i < maxFrag && !token.IsCancellationRequested; i++) { Console.WriteLine("SCH: Wstawiam do kolejki chunka " + i); uplBuff[i] = monitor.UploadChunkQueue.Take(token); // Ready chunks queue } Console.WriteLine("SCH: maxfrag = " + maxFrag + " caly size = " + cmd.Size); lock (dshLock) { Monitor.PulseAll(dshLock); } // Start uploading chunks while (!token.IsCancellationRequested) { try { lock (schLock) { // Wait for at least one DSH to complete/fail upload of one chunk Monitor.Wait(schLock); // Check if all chunks have been uploaded if (lastSucc >= maxFrag) { // All chunks taken by DSHs, wait for all CommitRdys while (waitingForCommit < serverList.Count && !token.IsCancellationRequested) { Monitor.Wait(schLock); } if (token.IsCancellationRequested) { break; } commit = new CommandCommit(); Console.WriteLine("Commit gotowy"); lock (dshLock) Monitor.PulseAll(dshLock); // Submit commit, wait for all CommitAcks while (commited < serverList.Count && !token.IsCancellationRequested) { Monitor.Wait(schLock); } if (token.IsCancellationRequested) { break; } Console.WriteLine("Zuploadowano plik na kazdy serwer"); cmd.CmdProc.Incoming.Add(new CommandAccept(), token); break; } // Check if one chunk has been uploaded by all DSHs lock (dshLock) { if ((int)uplFrags[lastSucc] == serverList.Count) { Console.WriteLine("SCH: Wszystkie zassały chunka " + lastSucc); // All DSHs uploaded one chunk, swap it with a new one uplFrags[lastSucc]++; if (lastSucc < maxFrag && maxFrag - lastSucc > fileBufferSize) { Console.WriteLine("SCH: Wstawiam chunka na miejsce " + lastSucc % fileBufferSize); uplBuff[lastSucc % fileBufferSize] = monitor.UploadChunkQueue.Take(token); } lastSucc++; } Monitor.PulseAll(dshLock); } } } catch (Exception e) { //TEMP } } // Token is cancelled }