Changeset 1170


Ignore:
Timestamp:
Feb 23, 2010, 12:20:11 PM (12 years ago)
Author:
arnold
Message:

P2PManager: Locking the Allocation of jobs, because some worker got more than one job, when two or more jobs ran into the function parallely.
@All other changes: Added some TODO comments in the head of the classes

Location:
trunk/CrypPlugins
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/PeerToPeerBase/PeerToPeerBase.cs

    r1144 r1170  
    3232using PeersAtPlay.Util.Logging;
    3333using Gears4Net;
     34
     35/* TODO:
     36 * - Catch errors, which can occur when using the DHT (network-based errors)
     37 */
    3438
    3539/* - Synchronous functions successfully tested (store, retrieve)
  • trunk/CrypPlugins/PeerToPeerManager_NEW/P2PManagerBase_NEW.cs

    r1166 r1170  
    2424
    2525/* TODO:
    26  * - Make Publisher-change possible ((de)serialize subscribers into DHT)
    27  * - Make Manager-change possible
     26 * - Publisher-change is possible, but catch old Publishers subscriber list
     27 *   isn't implemented yet ((de)serialization of the subscribers is
     28 *   implemented and tested)
     29 * - Make Manager-change possible ((de)serialization of job management lists)
    2830 * - Benchmarking the working peers
    2931 *   (this.distributableJobControl.SetResult() returns the TimeSpan for the result)
     32 * - Insert internal Start-/Stop-Button, so Manager can stop its works without
     33 *   loosing any Job-Information (this happens at present, when pressing the Stop
     34 *   button of the CrypTool Workspace)
    3035 */
    3136
     
    342347            }
    343348            else
     349            {
    344350                AllocateJobs();
     351            }
    345352
    346353            GetProgressInformation();
     
    407414                this.startWorkingTime = DateTime.Now;
    408415
    409             foreach (PeerId worker in freePeers)
    410             {
    411                 byte[] serializedNewJob = this.distributableJobControl.Pop(out temp_jobId);
    412                 if (serializedNewJob != null) // if this is null, there are no more JobParts on the main stack!
     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)
    413424                {
    414                     this.jobsWaitingForAcceptanceInfo.Add(temp_jobId, worker);
    415                     // get actual subscriber/worker and send the new job
    416                     base.p2pControl.SendToPeer(JobMessages.CreateJobPartMessage(temp_jobId, serializedNewJob), worker);
    417 
    418                     if (OnNewJobAllocated != null)
    419                         OnNewJobAllocated(temp_jobId);
    420 
    421                     // set free worker to busy in the peerManagement class
    422                     ((WorkersManagement)this.peerManagement).SetFreeWorkerToBusy(worker);
    423 
    424                     GuiLogging("Job '" + temp_jobId.ToString() + "' were sent to worker id '" + worker.ToString() + "'", NotificationLevel.Info);
    425                     i++;
    426                 }
    427                 else
    428                 {
    429                     GuiLogging("No more jobs left. So wait for the last results, than close this task.", NotificationLevel.Debug);
    430                     if (OnNoMoreJobsLeft != null)
    431                         OnNoMoreJobsLeft();
    432                 }
    433                 GuiLogging(i + " Job(s) allocated to worker(s).", NotificationLevel.Debug);
    434             } // end foreach
     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            }
    435450        }
    436451
  • trunk/CrypPlugins/PeerToPeerManager_NEW/P2PManager_KeyPattern.cs

    r1167 r1170  
    2929using Cryptool.Plugins.PeerToPeer.Jobs;
    3030
    31 /*TODO: Execute: If InitVector is null, try to create a fitting InitVector with the format 0...0 */
     31/*TODO:
     32 * - Execute: If InitVector is null, try to create a fitting InitVector with the format 0...0
     33 * - No linebreaks in the global result list
     34 * - 2 Output values (Top1-Key and Top1-Decryption)
     35 * - Display the job stati in a kind of a defragmentation list
     36 */
    3237
    3338namespace Cryptool.Plugins.PeerToPeer
Note: See TracChangeset for help on using the changeset viewer.