source: trunk/CrypPlugins/PeerToPeerJobs/IDistributableJob.cs @ 1244

Last change on this file since 1244 was 1244, checked in by arnold, 12 years ago

For evaluation issues added a DateTime information to every LogMessage from P2P- and KeySearcher-PlugIns, because the LogMessages seems to be inaccurate and/or delayed in some cases

Additionally added a Begin- and End-Message into the KeySearcher with an TimeSpan information, how long the bruteforce process had taken

File size: 2.8 KB
Line 
1/* Copyright 2010 Team CrypTool (Christian Arnold), Uni Duisburg-Essen
2
3   Licensed under the Apache License, Version 2.0 (the "License");
4   you may not use this file except in compliance with the License.
5   You may obtain a copy of the License at
6
7       http://www.apache.org/licenses/LICENSE-2.0
8
9   Unless required by applicable law or agreed to in writing, software
10   distributed under the License is distributed on an "AS IS" BASIS,
11   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   See the License for the specific language governing permissions and
13   limitations under the License.
14*/
15
16using System;
17using System.Collections.Generic;
18using System.Linq;
19using System.Text;
20using Cryptool.PluginBase.Miscellaneous;
21
22namespace Cryptool.Plugins.PeerToPeer.Jobs
23{
24    public delegate void LastJobAllocated(BigInteger jobId);
25    public delegate void LastResultReceived(BigInteger jobId);
26
27    public interface IDistributableJob
28    {
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        /// <summary>
39        /// pops a new serialized JobPart and the JobParts' JobId.
40        /// Check the returned byte array. If it is null, there
41        /// are no more jobParts left on the JobPart-Stack
42        /// </summary>
43        /// <param name="jobId">the JobParts' JobId</param>
44        /// <returns>if this is null, there are no more JobParts left,
45        /// otherwise the serialized JobPart</returns>
46        byte[] Pop(out BigInteger jobId);
47        /// <summary>
48        /// Pushes an already distributed JobPart back
49        /// to the stack (e.g. a Worker, who was
50        /// processing the JobPart actually leaves the network)
51        /// </summary>
52        /// <param name="jobId"></param>
53        void Push(BigInteger jobId);
54        double ProcessProgress();
55        BigInteger TotalAmount{ get; set; }
56        BigInteger AllocatedAmount{ get; set; }
57        BigInteger FinishedAmount{ get; set; }
58        void JobAccepted(BigInteger jobId);
59        void JobDeclined(BigInteger jobId);
60        /// <summary>
61        /// If a result was received from a working peer, set the result here.
62        /// The job will be removed from the job stack and the result will be processed.
63        /// </summary>
64        /// <param name="jobId">JobId of an already allocated job</param>
65        /// <param name="result">a byte representation of the job result</param>
66        /// <returns>the TimeSpan of processing the job by the worker</returns>
67        TimeSpan SetResult(BigInteger jobId, byte[] result);
68    }
69}
Note: See TracBrowser for help on using the repository browser.