Changeset 1173


Ignore:
Timestamp:
Feb 23, 2010, 7:42:55 PM (12 years ago)
Author:
arnold
Message:

some bug fixes.

Location:
trunk/CrypPlugins
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/PeerToPeerManager_NEW/P2PManagerBase_NEW.cs

    r1170 r1173  
    348348            else
    349349            {
    350                 AllocateJobs();
     350                /* edited by Arnold - 2010.02.23 */
     351                // because parallel incoming free workers could run
     352                // into concurrence in this method, so some workers
     353                // could get more than one job - so they have to
     354                // queue the additional jobs.
     355                lock (this)
     356                {
     357                    AllocateJobs();
     358                }
    351359            }
    352360
     
    414422                this.startWorkingTime = DateTime.Now;
    415423
    416             /* edited by Arnold - 2010.02.23 */
    417             // because parallel incoming free workers could run
    418             // into concurrence in this method, so some workers
    419             // could get more than one job - so they have to
    420             // queue the additional jobs.
    421             lock (freePeers)
    422             {
    423                 foreach (PeerId worker in freePeers)
    424                 {
    425                     byte[] serializedNewJob = this.distributableJobControl.Pop(out temp_jobId);
    426                     if (serializedNewJob != null) // if this is null, there are no more JobParts on the main stack!
    427                     {
    428                         this.jobsWaitingForAcceptanceInfo.Add(temp_jobId, worker);
    429                         // get actual subscriber/worker and send the new job
    430                         base.p2pControl.SendToPeer(JobMessages.CreateJobPartMessage(temp_jobId, serializedNewJob), worker);
    431 
    432                         if (OnNewJobAllocated != null)
    433                             OnNewJobAllocated(temp_jobId);
    434 
    435                         // set free worker to busy in the peerManagement class
    436                         ((WorkersManagement)this.peerManagement).SetFreeWorkerToBusy(worker);
    437 
    438                         GuiLogging("Job '" + temp_jobId.ToString() + "' were sent to worker id '" + worker.ToString() + "'", NotificationLevel.Info);
    439                         i++;
    440                     }
    441                     else
    442                     {
    443                         GuiLogging("No more jobs left. So wait for the last results, than close this task.", NotificationLevel.Debug);
    444                         if (OnNoMoreJobsLeft != null)
    445                             OnNoMoreJobsLeft();
    446                     }
    447                     GuiLogging(i + " Job(s) allocated to worker(s).", NotificationLevel.Debug);
    448                 } // end foreach
    449             }
     424            foreach (PeerId worker in freePeers)
     425            {
     426                byte[] serializedNewJob = this.distributableJobControl.Pop(out temp_jobId);
     427                if (serializedNewJob != null) // if this is null, there are no more JobParts on the main stack!
     428                {
     429                    this.jobsWaitingForAcceptanceInfo.Add(temp_jobId, worker);
     430                    // get actual subscriber/worker and send the new job
     431                    base.p2pControl.SendToPeer(JobMessages.CreateJobPartMessage(temp_jobId, serializedNewJob), worker);
     432
     433                    if (OnNewJobAllocated != null)
     434                        OnNewJobAllocated(temp_jobId);
     435
     436                    // set free worker to busy in the peerManagement class
     437                    ((WorkersManagement)this.peerManagement).SetFreeWorkerToBusy(worker);
     438
     439                    GuiLogging("Job '" + temp_jobId.ToString() + "' were sent to worker id '" + worker.ToString() + "'", NotificationLevel.Info);
     440                    i++;
     441                }
     442                else
     443                {
     444                    GuiLogging("No more jobs left. So wait for the last results, than close this task.", NotificationLevel.Debug);
     445                    if (OnNoMoreJobsLeft != null)
     446                        OnNoMoreJobsLeft();
     447                }
     448                GuiLogging(i + " Job(s) allocated to worker(s).", NotificationLevel.Debug);
     449            } // end foreach
    450450        }
    451451
  • trunk/CrypPlugins/PeerToPeerManager_NEW/P2PManagerPresentation.xaml

    r1167 r1173  
    8585
    8686            <Expander Name="Expander_List" Header="Global Top 10 List" IsExpanded="True" FontSize="10" Grid.Row="1">
    87                 <ListView Name="ListView" ItemsSource="{Binding}" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" FontSize="8">
     87                <ListView Name="ListView" ItemsSource="{Binding}" ScrollViewer.HorizontalScrollBarVisibility="Auto"  ScrollViewer.VerticalScrollBarVisibility="Auto" FontSize="7" MaxWidth="200">
    8888                    <ListView.View>
    8989                        <GridView>
     
    9191                            <GridViewColumn Header="Value" DisplayMemberBinding="{Binding Path=Value}"></GridViewColumn>
    9292                            <GridViewColumn Header="Key" DisplayMemberBinding="{Binding Path=Key}"></GridViewColumn>
    93                             <GridViewColumn Header="Text" DisplayMemberBinding="{Binding Path=Text}"></GridViewColumn>
     93                            <GridViewColumn Header="Text" DisplayMemberBinding="{Binding Path=Text}" ></GridViewColumn>
    9494                        </GridView>
    9595                    </ListView.View>
  • trunk/CrypPlugins/PeerToPeerManager_NEW/P2PManagerPresentation.xaml.cs

    r1167 r1173  
    5151            this.SizeChanged += new SizeChangedEventHandler(P2PManagerPresentation_SizeChanged);
    5252            this.DataContext = entries;
     53            // when expanding Expanders, resize layout
     54            this.Expander_JobStatus.MouseLeftButtonUp += new MouseButtonEventHandler(Expander_JobStatus_MouseLeftButtonUp);
     55            this.Expander_List.MouseLeftButtonUp += new MouseButtonEventHandler(Expander_List_MouseLeftButtonUp);
     56            this.Expander_WorkerInfo.MouseLeftButtonUp += new MouseButtonEventHandler(Expander_WorkerInfo_MouseLeftButtonUp);
     57
     58
     59            this.SourceUpdated += new EventHandler<DataTransferEventArgs>(P2PManagerPresentation_SourceUpdated);
    5360            // when you uncomment this line, you burn 70% of the whole CPU time for Resizing this view...
    5461            //this.LayoutUpdated += new EventHandler(P2PManagerPresentation_LayoutUpdated);
     
    6673            this.Expander_WorkerInfo.Background = blueBrush;
    6774            this.Expander_List.Background = GetGradientGray();
     75        }
     76
     77        void Expander_WorkerInfo_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
     78        {
     79            FunnyResize();
     80        }
     81
     82        void Expander_List_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
     83        {
     84            FunnyResize();
     85        }
     86
     87        void Expander_JobStatus_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
     88        {
     89            FunnyResize();
     90        }
     91
     92        void txtTotal_TextChanged(object sender, TextChangedEventArgs e)
     93        {
     94            FunnyResize();
     95        }
     96
     97        void P2PManagerPresentation_SourceUpdated(object sender, DataTransferEventArgs e)
     98        {
     99            FunnyResize();
    68100        }
    69101
  • trunk/CrypPlugins/PeerToPeerManager_NEW/P2PManager_KeyPattern.cs

    r1170 r1173  
    260260                        entry.Value = "" + Math.Round(listNode.Value.value, 3);
    261261                        entry.Key = listNode.Value.key;
    262                         entry.Text = enc.GetString(listNode.Value.decryption, 0, this.bytesToUseForDecryption);
     262                        // remove all linebreaks, tabs and so on
     263                        string decryptText = enc.GetString(listNode.Value.decryption, 0, this.bytesToUseForDecryption);
     264                        decryptText = decryptText.Replace("\n", String.Empty);
     265                        decryptText = decryptText.Replace("\t", String.Empty);
     266                        decryptText = decryptText.Replace("\r", String.Empty);
     267                        entry.Text = decryptText;//enc.GetString(listNode.Value.decryption, 0, this.bytesToUseForDecryption);
    263268
    264269                        ((P2PManagerPresentation)QuickWatchPresentation).entries.Add(entry);
  • trunk/CrypPlugins/PeerToPeerSubscriber/P2PSubscriberBase.cs

    r1166 r1173  
    171171                    GuiLogging("Found a Publisher/Manager with ID '" + pid.ToString() + ", so register with it.", NotificationLevel.Info);
    172172                    SendMessage(pid, PubSubMessageType.Register);
    173                     this.timeoutForPublishersRegAccept.Start();
    174173                }
    175174                else if (actualPublisher == pid)
     
    186185                        + "' to '" + pid.ToString() + "'. Register with the new Publisher/Manager.", NotificationLevel.Info);
    187186                    SendMessage(pid, PubSubMessageType.Register);
    188                     this.timeoutForPublishersRegAccept.Start();
    189187                }
    190188                this.actualPublisher = pid;
     
    226224                    break;
    227225                case PubSubMessageType.Pong:
    228                     SendMessage(sender, PubSubMessageType.Register);
    229226                    this.timeoutForPublishersPong.Stop();
    230227                    break;
Note: See TracChangeset for help on using the changeset viewer.