source: trunk/CrypPlugins/PeerToPeerJobs/JobPart.cs @ 1137

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

Completely redesigned Manager-JobAdmin-Worker-infrastructure to distribute Jobs with a Peer-to-Peer infrastructure to remote CT2-Workspaces.

To test this infrastructure, open 2 instances of CT and load P2P_Manager_NEW_DES.cte and in the other instance P2P_Worker_NEW.cte.
HINT: Working with remote peers isn't possible every time, because the so called "SuperNode", which is necessary for relaying, sometimes goes down. But testing this infrastructure on different computers in the same network should work every time.

File size: 2.2 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 abstract class JobPart<JobType> : IJobPart
25    {
26        public JobPart(BigInteger jobId)
27        {
28            this.JobId = jobId;
29        }
30
31        public abstract byte[] Serialize();
32
33        public override bool Equals(object obj)
34        {
35            if (obj == null)
36                return false;
37
38            if (ReferenceEquals(this, obj))
39                return true;
40
41            if (this.GetType() != obj.GetType())
42                return false;
43
44            return this == (JobPart<JobType>)obj;
45        }
46
47        public static bool operator ==(JobPart<JobType> left, JobPart<JobType> right)
48        {
49            if ((object)left == (object)right)
50                return true;
51
52            if ((object)left == null || (object)right == null)
53                return false;
54
55            if (left.JobId == right.JobId)
56                return true;
57
58            return false;
59        }
60
61        public static bool operator !=(JobPart<JobType> left, JobPart<JobType> right)
62        {
63            return !(left == right);
64        }
65
66        public override int GetHashCode()
67        {
68            return this.JobId.GetHashCode();
69        }
70
71        #region IJobPart Members
72
73        private BigInteger jobId;
74        public BigInteger JobId
75        {
76            get { return this.jobId; }
77            set { this.jobId = value; }
78        }
79
80        #endregion
81    }
82}
Note: See TracBrowser for help on using the repository browser.