Repository navigation
Expand file tree
/
Copy pathdeployment_AllAppsScps_2.java
More file actions
185 lines (163 loc) · 6.41 KB
/
Copy pathdeployment_AllAppsScps_2.java
File metadata and controls
185 lines (163 loc) · 6.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
public class LinkEnsemble extends Ensemble {
private static final long serialVersionUID = 1L;
private static final int appGroupSize = 5;
private static final int scpGroupSize = 5;
// The filters apply prior to the membership, that allows the user for more restrictions on the input ids
// instead of letting the framework implementing it. (this would weaken the core pretty much, as well as the user abilities)
// They follow the same pattern structure as the membership, with the constraints below :
// - they can use (or not) the coordinator
// - they are no other outputs than a list of strings, no inOut and out parameters
// - they can reference only one group member (this explains why we do not need an identifier after the members ensemble party for the paths),
// the reference is seen in the member group annotation of the membership
// so then it guarantees the filter to be applied for different input atomic group members
/**
* Filter for the application component
*/
@Filter
public static List<String> appFilter(
@In("coord.id") String cId,
@In("coord.runningOn") String cRunningOn,
// the size of these two arrays is taken from the member group annotation of the membership
// so then the filter can be applied on different group members with different sizes
@In("members.id") List<String> mIds,
@In("members.runningOn") List<String> runningOns){
// apply filtering however the user wants on the different latency parameters,
// this way, it gives a high flexibility for selecting the desired id
// the filters can be strongly constrained by the framework, by disallowing some operations
// it only applies to the knowledge of a single member type as the paths are local to a node
List<String> filteredIds = new ArrayList<String> ();
// filter the input mIds, and returning appGroupSize number of ids
// the coordinator is running on machine X,
// all the other members must be also running on machine X, chekc this out in some condition
// if the output size does not match the size in the annotation, an exception is thrown
return filteredIds;
}
/**
* Filter for the scp component
*/
@Filter
public static List<String> scpFilter(
@In("members.id") List<String> scpIds,
@In("members.latency") List<Map<String, Object>> scpLatencies){
List<String> filteredIds = new ArrayList<String> ();
// can use intermediate user-defined functions to manipulate the latencies
// until getting a strict and limited set of filtered scpIds
// the input and output are declared
return filteredIds;
}
/**
* Membership function
*/
@Membership
@Members({
// we state which filters are to be considered
// this way, we can have the possibility to use the same filter for different member groups
@MemberGroup(identifier="App", filter="appFilter", size=appGroupSize),
@MemberGroup(identifier="Scp", filter="scpFilter", size=scpGroupSize)
})
public static Boolean membership(
// AppComponent coordinator
@In("coord.id") String cAppId,
@In("coord.scpId") String cAppScpId,
@In("coord.isDeployed") Boolean cAppIsDeployed,
// AppComponent members
@In("members.App.id") List<String> msAppIds,
@In("members.App.scpId") List<String> msAppScpIds,
@In("members.App.isDeployed") List<Boolean> msAppIsDeployed,
// ScpComponent members
@In("members.Scp.id") List<String> msScpIds,
@In("members.Scp.appIds") List<List<String>> msScpAppIds
) {
// the condition would be here only about the coordinator, as it is the only triggerer here
// and all the other members are filtered, if the filters fail, the membership is not called, and
// another case can be estimated
if (!cAppIsDeployed){
return true;
}
return false;
}
@KnowledgeExchange
@PeriodicScheduling(3000)
public static void map(
// AppComponent coordinator (1)
@In("coord.id") String cAppId,
@InOut("coord.scpId") OutWrapper<String> cAppScpId,
@Out("coord.isDeployed") OutWrapper<Boolean> cAppIsDeployed,
// AppComponent members (n-1)
@In("members.App.id") List<String> msAppIds,
@InOut("members.App.scpId") OutWrapper<List<String>> msAppScpIds,
@InOut("members.App.isDeployed") OutWrapper<List<Boolean>> msAppIsDeployed,
// ScpComponent members (n)
@In("members.Scp.id") List<String> msScpIds,
@InOut("members.Scp.appIds") OutWrapper<List<List<String>>> msScpAppIds) {
String appComponentIds = cAppId;
String scpComponentIds = msScpIds.get(0);
// all AppComponents are now deployed by ScpComponents
cAppScpId.value = msScpIds.get(0);
cAppIsDeployed.value = Boolean.TRUE;
msScpAppIds.value.get(0).add(cAppId);
// linkage
for (int i = 0; i < msAppIsDeployed.value.size(); i++){
msAppIsDeployed.value.set(i,Boolean.TRUE);
msAppScpIds.value.set(i, msScpIds.get(i+1));
// app component id registration into the scp component
// regarding of the first assigned id for the coordinator
msScpAppIds.value.get(i+1).add(msAppIds.get(i));
appComponentIds += " " + msAppIds.get(i);
scpComponentIds += " " + msScpIds.get(i+1);
}
System.out.println("coordinator="+cAppId+
" AppComponents=" + appComponentIds +
" ScpComponents=" +scpComponentIds);
}
}
////////AppComponent/////////
public class AppComponent extends Component {
public final static long serialVersionUID = 1L;
/**
* which application the app component is running on (the "ownerId", or vendorId)
*/
public String runningOn;
/**
* id of the SCP instance which the application component is processed by
*/
public String scpId;
/**
* flag for deployment
*/
public Boolean isDeployed;
//...
}
////////ScpComponent/////////
public class ScpComponent extends NetworkComponent {
public final static long serialVersionUID = 1L;
/**
* id of the application nodes which are linked to the scp
*/
public List<String> appIds;
/** latency with different mapped parameters
*/
Map<String, Object>> latency;
//...
}
////////NetworkComponent/////////
public class NetworkComponent extends Component {
private static final long serialVersionUID = 1L;
public ENetworkId networkId; // = which network does the component belong to
}
////////ENetworkId/////////
public enum ENetworkId {
LMU_MUNICH,
IMT_LUCCA,
EN_GARDEN
}
////////IdListType/////////
public class IdListType extends AbstractIdType {
public List<String> idList;
public IdListType(List<String> idList) {
this.idList = idList;
}
}
////////AbstractListType/////////
public abstract class AbstractIdType {
}