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