Changeset 1199


Ignore:
Timestamp:
Feb 26, 2010, 2:22:04 PM (12 years ago)
Author:
arnold
Message:

P2PManager

  • Enlarged KeyPatternSize range to 1.000, because the new DES/AES-Implementation runs so fast, that a KeyPattern with KeyPatternSize of 150 will be processed in approximately 40 seconds on a modern PC
  • Embellished Layout
  • Enhanced information display (total processing time)
  • Jobs in progress change their color every second between Yellow and LightGray

Samples:

  • Changed from CFB to CBC, because this modus is much faster than CFB!
  • Changed KeyPatternSize to 150, because the new DES/AES Implementation runs much faster
Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/KeyPatternJob/DistributableKeyPatternJob.cs

    r1182 r1199  
    2525    public class DistributableKeyPatternJob : IDistributableJob
    2626    {
     27        public event LastJobAllocated OnLastJobAllocated;
     28        public event LastResultReceived OnLastResultReceived;
     29
    2730        #region Variables and Properties
    2831
     
    136139                    serializedJob = jobPart.Serialize();
    137140                    this.allocatedPatterns.Add(jobId, jobPart);
     141
     142                    if (this.patternPool.Count() == 0)
     143                        if (OnLastJobAllocated != null)
     144                            OnLastJobAllocated(jobId);
    138145                }
    139146            }
     
    203210            //else
    204211            //    throw(new Exception("Received result from a job, which isn't in 'patternsInProgress' List."));
     212            if (this.patternPool.Count() == 0 && this.allocatedPatterns.Count == 0 && this.patternBuffer.Count == 0)
     213            {
     214                if (OnLastResultReceived != null)
     215                    OnLastResultReceived(jobId);
     216            }
     217
    205218            return returnTimeSpan;
    206219        }
  • trunk/CrypPlugins/PeerToPeerJobs/IDistributableJob.cs

    r1137 r1199  
    2222namespace Cryptool.Plugins.PeerToPeer.Jobs
    2323{
     24    public delegate void LastJobAllocated(BigInteger jobId);
     25    public delegate void LastResultReceived(BigInteger jobId);
     26
    2427    public interface IDistributableJob
    2528    {
     29        /// <summary>
     30        /// will be thrown after last job has been allocated
     31        /// </summary>
     32        event LastJobAllocated OnLastJobAllocated;
     33        /// <summary>
     34        /// will be thrown when last result has been received
     35        /// </summary>
     36        event LastResultReceived OnLastResultReceived;
     37
     38
    2639        /// <summary>
    2740        /// pops a new serialized JobPart and the JobParts' JobId.
  • trunk/CrypPlugins/PeerToPeerManager_NEW/P2PManagerBase_NEW.cs

    r1179 r1199  
    127127        }
    128128
     129        private bool lastJobAllocated = false;
     130
    129131        #endregion
    130132
     
    143145            if (this.distributableJobControl != null && this.p2pControl != null)
    144146            {
     147                this.distributableJobControl.OnLastResultReceived += new LastResultReceived(distributableJobControl_OnLastResultReceived);
     148
    145149                //set value to null, when restarting the manager
    146150                this.startWorkingTime = DateTime.MinValue;
     
    155159        }
    156160
     161        void distributableJobControl_OnLastResultReceived(BigInteger jobId)
     162        {
     163            if (OnAllJobResultsReceived != null)
     164                OnAllJobResultsReceived(jobId);
     165        }
     166
    157167        protected override void PeerCompletelyStarted()
    158168        {
     
    171181            ((WorkersManagement)this.peerManagement).OnFreeWorkersAvailable -= peerManagement_OnFreeWorkersAvailable;
    172182            ((WorkersManagement)this.peerManagement).OnSubscriberRemoved -= peerManagement_OnSubscriberRemoved;
     183            this.distributableJobControl.OnLastResultReceived -= distributableJobControl_OnLastResultReceived;
    173184
    174185            GuiLogging("P2PManager was stopped successully.", NotificationLevel.Info);
     
    272283                // set busy worker to free, because he delined the job
    273284
    274                 // TODO: maybe create a "black list" for peers, who had declined this kind of Job twice...
     285                // TODO: maybe create a "black list" for peers, who had declined this kind of Job twice or more...
    275286                ((WorkersManagement)this.peerManagement).SetBusyWorkerToFree(sender);
    276287                GuiLogging("JobId '" + jobId.ToString() + "' was declined by Peer '" + sender.ToString() + "'.", NotificationLevel.Info);
  • trunk/CrypPlugins/PeerToPeerManager_NEW/P2PManagerPresentation.xaml

    r1178 r1199  
    1919            </Grid.RowDefinitions>
    2020            <Grid.ColumnDefinitions>
    21                 <ColumnDefinition Width="14*"/>
    22                 <ColumnDefinition Width="139.16*" />
     21                <ColumnDefinition/>
     22                <ColumnDefinition/>
    2323            </Grid.ColumnDefinitions>
    2424
     
    4646                        <Grid.ColumnDefinitions>
    4747                            <ColumnDefinition/>
     48                            <ColumnDefinition/>
    4849                        </Grid.ColumnDefinitions>
    4950
    50                         <Label Grid.Row="0" Grid.Column="0" FontSize="10" FontWeight="Bold" VerticalContentAlignment="Bottom"
     51                       
     52                        <Label Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" FontSize="10" FontWeight="Bold" VerticalContentAlignment="Bottom"
    5153                           VerticalAlignment="Top" HorizontalContentAlignment="Center" >Total Progress:</Label>
    52                         <TextBox Name="txtProgressInPercent" Grid.Row="1" Grid.Column="0" TextAlignment="Center"
    53                              IsReadOnly="True" TextWrapping="WrapWithOverflow" FontSize="8" FontWeight="Bold"
    54                              BorderThickness="0" VerticalContentAlignment="Top" HorizontalContentAlignment="Center" Background="Transparent"/>
    55                         <!--<Label Name="txtProgressInPercent" Grid.Row="1" Grid.Column="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Top"
    56                                VerticalAlignment="Top" FontWeight="Bold" FontSize="8">0,00%</Label>-->
     54                        <TextBox Name="txtProgressInPercent" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" TextAlignment="Center"
     55                             IsReadOnly="True" TextWrapping="WrapWithOverflow" FontSize="10" FontWeight="Bold"
     56                             BorderThickness="0" VerticalContentAlignment="Top" HorizontalContentAlignment="Center"
     57                             Background="LightGray" Text="not started"/>
     58                       
     59                        <Label Grid.Row="2" Grid.Column="0" FontSize="8" VerticalContentAlignment="Center"
     60                               HorizontalContentAlignment="Left">Time in process:</Label>
     61                        <TextBox Grid.Row="2" Grid.Column="1" Name="txtTimeInProcess" TextAlignment="Left"
     62                             IsReadOnly="True" TextWrapping="WrapWithOverflow" FontSize="8" VerticalContentAlignment="Center"
     63                             BorderThickness="0" HorizontalContentAlignment="Left"
     64                                 Background="Transparent" Text="not started" />
    5765
    58                         <Label Grid.Row="2" Grid.Column="0" FontSize="10" FontWeight="Bold" FontStyle="Italic" VerticalContentAlignment="Bottom"
    59                            VerticalAlignment="Top" HorizontalContentAlignment="Center" >Estimated end time:</Label>
    60                         <TextBox Name="txtEstimatedEndTime" Text="no finished jobs" Grid.Row="3" Grid.Column="0" TextAlignment="Center"
    61                              IsReadOnly="True" TextWrapping="WrapWithOverflow" FontSize="8" FontWeight="Bold"
    62                              BorderThickness="0" VerticalContentAlignment="Top" HorizontalContentAlignment="Center" Background="Transparent"/>
     66                        <Label Grid.Row="3" Grid.Column="0" FontSize="8" FontStyle="Italic"
     67                               HorizontalContentAlignment="Left" Background="LightGray">Estimated end time:</Label>
     68                        <TextBox Grid.Row="3" Grid.Column="1"  Name="txtEstimatedEndTime" VerticalContentAlignment="Center"
     69                             HorizontalContentAlignment="Left" IsReadOnly="True" TextWrapping="WrapWithOverflow" FontSize="8"
     70                             BorderThickness="0" Text="no finished jobs" Background="LightGray"/>
    6371                    </Grid>
    6472
     
    8795
    8896            <Expander Name="Expander_List" Header="Global Top 10 List" IsExpanded="True" FontSize="10" Grid.Row="2">
    89                 <ListView Name="ListView" ItemsSource="{Binding}" ScrollViewer.HorizontalScrollBarVisibility="Auto"  ScrollViewer.VerticalScrollBarVisibility="Auto" FontSize="7" MaxWidth="200">
     97                <ListView Name="ListView" ItemsSource="{Binding}" ScrollViewer.HorizontalScrollBarVisibility="Auto"  ScrollViewer.VerticalScrollBarVisibility="Auto" FontSize="7" MaxWidth="255">
    9098                    <ListView.View>
    9199                        <GridView>
  • trunk/CrypPlugins/PeerToPeerManager_NEW/P2PManagerPresentation.xaml.cs

    r1178 r1199  
    7878            exp_chunk.FontSize = 10;
    7979            exp_chunk.Background = grayBrush;
     80            exp_chunk.SizeChanged += new SizeChangedEventHandler(exp_chunk_SizeChanged);
    8081            this.PrgChunks.Width = 200;
    8182            this.PrgChunks.Height = 55;
     
    8788        }
    8889
    89         //void txtTotal_TextChanged(object sender, TextChangedEventArgs e)
    90         //{
    91         //    int iResult;
    92         //    if (Int32.TryParse(this.txtTotal.Text, out iResult))
    93         //    {
    94         //        PrgChunks.JobCount = iResult;
    95         //        PrgChunks[0] = Brushes.HotPink;
    96         //        PrgChunks[iResult - 1] = Brushes.HotPink;
    97         //    }
    98         //}
     90        void exp_chunk_SizeChanged(object sender, SizeChangedEventArgs e)
     91        {
     92            FunnyResize();
     93        }
    9994
    10095        void txtTotal_SizeChanged(object sender, SizeChangedEventArgs e)
  • trunk/CrypPlugins/PeerToPeerManager_NEW/P2PManager_KeyPattern.cs

    r1179 r1199  
    2828using System.Windows.Threading;
    2929using Cryptool.Plugins.PeerToPeer.Jobs;
     30using System.Timers;
     31using System.Windows.Media;
    3032
    3133/*TODO:
     
    209211        }
    210212
     213        private void timerProcessingTimeReset()
     214        {
     215            this.timerProcessingTime.Stop();
     216            this.timerProcessingTime.Close();
     217            this.timerProcessingTime.Dispose();
     218            this.timerProcessingTime = null;
     219
     220            if (QuickWatchPresentation.IsVisible)
     221            {
     222                ((P2PManagerPresentation)QuickWatchPresentation).Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback)delegate
     223                {                   
     224                    ((P2PManagerPresentation)QuickWatchPresentation).txtTimeInProcess.Text = "not started";
     225                    ((P2PManagerPresentation)QuickWatchPresentation).txtProgressInPercent.Text = "not started";
     226                    ((P2PManagerPresentation)QuickWatchPresentation).txtEstimatedEndTime.Text = "no finished jobs";
     227                    ((P2PManagerPresentation)QuickWatchPresentation).PrgChunks.JobCount = 0;
     228                }, null);
     229            }
     230        }
     231
     232        void timerProcessingTime_Elapsed(object sender, ElapsedEventArgs e)
     233        {
     234            if (QuickWatchPresentation.IsVisible)
     235            {
     236                ((P2PManagerPresentation)QuickWatchPresentation).Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback)delegate
     237                {
     238                    // calculate and display current processing time span
     239                    TimeSpan processTime = DateTime.Now.Subtract(this.p2pManager.StartWorkingTime);
     240                    StringBuilder sbProcess = new StringBuilder();
     241                    if(processTime.Days != 0)
     242                        sbProcess.Append(processTime.Days.ToString() + " Days ");
     243                    if (processTime.Hours <= 9)
     244                        sbProcess.Append("0");
     245                    sbProcess.Append(processTime.Hours.ToString() + ":");
     246                    if (processTime.Minutes <= 9)
     247                        sbProcess.Append("0");
     248                    sbProcess.Append(processTime.Minutes.ToString() + ":");
     249                    if (processTime.Seconds <= 9)
     250                        sbProcess.Append("0");
     251                    sbProcess.Append(processTime.Seconds.ToString());
     252
     253                    ((P2PManagerPresentation)QuickWatchPresentation).txtTimeInProcess.Text = sbProcess.ToString() + " (hh:mm:ss)";
     254                    sbProcess = null;
     255
     256                    // change color of jobs in progress
     257                    Brush evenClr = System.Windows.Media.Brushes.LightGray;
     258                    Brush oddClr = System.Windows.Media.Brushes.Yellow;
     259                    if((Math.Round(processTime.TotalSeconds,0) % 2) == 0)
     260                    {
     261                        for (int i = 0; i < ((P2PManagerPresentation)QuickWatchPresentation).PrgChunks.JobCount; i++)
     262                                    {
     263                                    if(((P2PManagerPresentation)QuickWatchPresentation).PrgChunks[i] == oddClr)
     264                                ((P2PManagerPresentation)QuickWatchPresentation).PrgChunks[i] = evenClr;
     265                                    }
     266                    }
     267                    else
     268                    {
     269                        for (int i = 0; i < ((P2PManagerPresentation)QuickWatchPresentation).PrgChunks.JobCount; i++)
     270                                    {
     271                                    if(((P2PManagerPresentation)QuickWatchPresentation).PrgChunks[i] == evenClr)
     272                                ((P2PManagerPresentation)QuickWatchPresentation).PrgChunks[i] = oddClr;
     273                                    }
     274                    }
     275                }, null);
     276            }
     277        }
     278
    211279        private void UpdateQuickWatch(double progressInPercent)
    212280        {
     
    390458            if (this.p2pManager != null && this.p2pManager.Started)
    391459            {
     460                //stop processTime Timer
     461                timerProcessingTimeReset();
     462
    392463                this.p2pManager.Stop(PubSubMessageType.Unregister);
    393464                this.settings.MngStatusChanged(P2PManager_KeyPatternSettings.MngStatus.Neutral);
     
    516587                this.p2pManager.OnResultReceived += new P2PManagerBase_NEW.ResultReceived(p2pManager_OnResultReceived);
    517588                this.p2pManager.OnJobCanceled += new P2PManagerBase_NEW.JobCanceled(p2pManager_OnJobCanceled);
     589                this.p2pManager.OnAllJobResultsReceived += new P2PManagerBase_NEW.AllJobResultsReceived(p2pManager_OnAllJobResultsReceived);
    518590            }
    519591
     
    522594            this.p2pManager.StartManager(this.settings.TopicName, this.settings.SendAliveMessageInterval * 1000);
    523595
     596            //added 2010.02.26 for displaying actual processing time - this variables have to be reset when restarting manager
     597            firstTimeJobAllocated = true;
     598
    524599            this.settings.MngStatusChanged(P2PManager_KeyPatternSettings.MngStatus.Working);
    525600        }
    526601
     602        void p2pManager_OnAllJobResultsReceived(BigInteger lastJobId)
     603        {
     604            timerProcessingTimeReset();
     605        }
     606
    527607        void p2pManager_OnJobCanceled(BigInteger jobId)
    528608        {
     
    542622        }
    543623
     624
     625        private bool firstTimeJobAllocated = true;
     626        private System.Timers.Timer timerProcessingTime;
    544627        void p2pManager_OnNewJobAllocated(BigInteger jobId)
    545628        {
     629            if (firstTimeJobAllocated)
     630            {
     631                timerProcessingTime = new System.Timers.Timer(1000);
     632                timerProcessingTime.Elapsed += new ElapsedEventHandler(timerProcessingTime_Elapsed);
     633                timerProcessingTime.Start();
     634                firstTimeJobAllocated = false;
     635            }
    546636            UpdateProgressChunk(jobId, System.Windows.Media.Brushes.Yellow);
    547637
  • trunk/CrypPlugins/PeerToPeerManager_NEW/P2PManager_KeyPatternSettings.cs

    r1166 r1199  
    140140        }
    141141
    142         private int keyPatternSize = 10; // in hundred-thousand
     142        private int keyPatternSize = 120; // in hundred-thousand
    143143        [TaskPane("KeyPatternSize", "Choose the Size of the specific sub-KeyPattern (in hundred-thousand steps)"
    144             , null, 3, false, DisplayLevel.Beginner, ControlType.NumericUpDown, ValidationType.RangeInteger, 1, 200)]
     144            , null, 3, false, DisplayLevel.Beginner, ControlType.NumericUpDown, ValidationType.RangeInteger, 80, 1000)]
    145145        public int KeyPatternSize
    146146        {
  • trunk/CrypPlugins/PeerToPeerManager_NEW/ProgressChunks.xaml.cs

    r1180 r1199  
    5858            }
    5959        }
     60
    6061        private int count = 1;
    6162        public int JobCount
  • trunk/CrypPlugins/PeerToPeerPublisher/SubscribersManagement.cs

    r1137 r1199  
    5858        {
    5959            bool retValue = false;
    60             if (!this.checkList.ContainsKey(subscriberId))
    61             {
    62                 this.dateTimeNow = DateTime.Now;
    63                 // locking checkList instead of activeSubsList, because all other functions work on checkList, not on activeSubsList
    64                 lock (this.checkList)
    65                 {
    66                     this.checkList.Add(subscriberId, this.dateTimeNow);
    67                     retValue = true;
    68                 }
    69             }
     60
     61            lock (this.checkList)
     62            {
     63                if (!this.checkList.ContainsKey(subscriberId))
     64                {
     65                    this.dateTimeNow = DateTime.Now;
     66                    // locking checkList instead of activeSubsList, because all other functions work on checkList, not on activeSubsList
     67                    lock (this.checkList)
     68                    {
     69                        this.checkList.Add(subscriberId, this.dateTimeNow);
     70                        retValue = true;
     71                    }
     72                }
     73            } // end lock
    7074            return retValue;
    7175
Note: See TracChangeset for help on using the changeset viewer.