1 |
mojays |
2 |
package appl.parallel.spmd.split; |
2 |
|
|
|
3 |
|
|
import java.io.Serializable; |
4 |
|
|
|
5 |
|
|
import appl.data.DataLoader; |
6 |
|
|
import appl.parallel.data.PartitionDataHandler; |
7 |
|
|
|
8 |
|
|
// fuer Doku |
9 |
|
|
import javax.activation.DataHandler; |
10 |
|
|
import appl.parallel.client.DataServer; |
11 |
|
|
import appl.parallel.data.XuluClientLoader; |
12 |
|
|
|
13 |
|
|
/** |
14 |
|
|
* This class collects the metadata of a partitioning |
15 |
|
|
* The following information is encapsulated in a SinglePartitionInfo Object: |
16 |
|
|
* <ul> |
17 |
|
|
* <li> |
18 |
|
|
* The <b>ID</b>of the {@link SplittableResource SplittableResource} |
19 |
|
|
* </li> |
20 |
|
|
* <li>The <b>baseResourceName</b> of the resource (given by the parallel programmer)</li> |
21 |
|
|
* <li>The <b>{@link DataHandler}</b>, which loads the data of the partition. This is a very important aspect. |
22 |
|
|
* The handler defines how the data is actually loaded. It may for example be loaded |
23 |
|
|
* from a {@link DataServer} using a {@link XuluClientLoader}, but it may also be used |
24 |
|
|
* to load data from local disk, databases etc. without communication with the client. |
25 |
|
|
* The {@link DataHandler} is also responsible for writing the the data back to the source |
26 |
|
|
* </li> |
27 |
|
|
* <li> |
28 |
|
|
* The <b>{@link SplitMap}</b> which represents the current partitioning. |
29 |
|
|
* </li> |
30 |
|
|
* <li> |
31 |
|
|
* A <b>splitmap position</b>, which identifies the partition number in the split. |
32 |
|
|
* </li> |
33 |
|
|
* |
34 |
|
|
* @author Dominik Appl |
35 |
|
|
* |
36 |
|
|
* |
37 |
|
|
*/ |
38 |
|
|
public class SinglePartitionInfo implements Serializable, PartitionInfo{ |
39 |
|
|
|
40 |
|
|
private final int baseResourceID; |
41 |
|
|
private final PartitionDataHandler handler; |
42 |
|
|
private final SplitMap splitMap; |
43 |
|
|
private final int splitMapPos; |
44 |
|
|
private final String baseResourceName; |
45 |
|
|
|
46 |
|
|
/** |
47 |
|
|
* The constructor. |
48 |
|
|
* |
49 |
|
|
* @param baseResourceID the root id (see {@link DataPartition#getRootID()}) |
50 |
|
|
* @param baseResourceName the name of the resource (given by parallel programmer) |
51 |
|
|
* @param handler {@link PartitionDataHandler} |
52 |
|
|
* which is responsible for loading and unloading |
53 |
|
|
* @param splitMap splitmap describing the partitioning |
54 |
|
|
* @param splitMapPos the position inside the splitmap |
55 |
|
|
*/ |
56 |
|
|
public SinglePartitionInfo(int baseResourceID, String baseResourceName, PartitionDataHandler handler, SplitMap splitMap, int splitMapPos){ |
57 |
|
|
this.baseResourceID = baseResourceID; |
58 |
|
|
this.baseResourceName = baseResourceName; |
59 |
|
|
this.handler = handler; |
60 |
|
|
this.splitMap = splitMap; |
61 |
|
|
this.splitMapPos = splitMapPos; |
62 |
|
|
} |
63 |
|
|
|
64 |
|
|
/** |
65 |
|
|
* @return the baseResourceID |
66 |
|
|
*/ |
67 |
|
|
public int getBaseResourceID() { |
68 |
|
|
return baseResourceID; |
69 |
|
|
} |
70 |
|
|
/** |
71 |
|
|
* @return the handler |
72 |
|
|
*/ |
73 |
|
|
public PartitionDataHandler getPartitionDataHandler() { |
74 |
|
|
return handler; |
75 |
|
|
} |
76 |
|
|
/* (non-Javadoc) |
77 |
|
|
* @see appl.parallel.spmd.split.PartitionInfo#getSplitMap() |
78 |
|
|
*/ |
79 |
|
|
public SplitMap getSplitMap() { |
80 |
|
|
return splitMap; |
81 |
|
|
} |
82 |
|
|
/* (non-Javadoc) |
83 |
|
|
* @see appl.parallel.spmd.split.PartitionInfo#getSplitMapPos() |
84 |
|
|
*/ |
85 |
|
|
public int getSplitMapPos() { |
86 |
|
|
return splitMapPos; |
87 |
|
|
} |
88 |
|
|
|
89 |
|
|
/* (non-Javadoc) |
90 |
|
|
* @see appl.parallel.spmd.split.PartitionInfo#getBaseResourceName() |
91 |
|
|
*/ |
92 |
|
|
public String getBaseResourceName() { |
93 |
|
|
return baseResourceName; |
94 |
|
|
} |
95 |
|
|
|
96 |
|
|
public PartitionInfo clone(int newRootID){ |
97 |
|
|
PartitionDataHandler clonedHandler = handler.clone(); |
98 |
|
|
clonedHandler.setRootID(newRootID); |
99 |
|
|
return new SinglePartitionInfo(newRootID, |
100 |
|
|
this.baseResourceName,clonedHandler,this.splitMap, |
101 |
|
|
this.splitMapPos); |
102 |
|
|
} |
103 |
|
|
|
104 |
|
|
} |