root / src / gZFS / zreplicas.java @ 23
Historique | Voir | Annoter | Télécharger (12,78 ko)
1 |
package gZFS; |
---|---|
2 |
|
3 |
import java.text.DateFormat; |
4 |
import java.text.ParseException; |
5 |
import java.text.SimpleDateFormat; |
6 |
import java.util.Calendar; |
7 |
import java.util.Date; |
8 |
import java.util.GregorianCalendar; |
9 |
import java.util.Hashtable; |
10 |
|
11 |
public class zreplicas { |
12 |
public Hashtable<String,zProperties> zProperties = new Hashtable<String, zProperties>(); |
13 |
public Hashtable<String,zProperties> zSchedulerProperties = new Hashtable<String, zProperties>(); |
14 |
|
15 |
private Hashtable<Object, Object> cronMinute = new Hashtable<Object, Object>(); |
16 |
private Hashtable<Object, Object> cronHour= new Hashtable<Object, Object>(); |
17 |
private Hashtable<Object, Object> cronMonth= new Hashtable<Object, Object>(); |
18 |
private Hashtable<Object, Object> cronDayOfMonth = new Hashtable<Object, Object>(); |
19 |
private Hashtable<Object, Object> cronDayOfWeek = new Hashtable<Object, Object>(); |
20 |
|
21 |
zreplicas(){ |
22 |
String valueForHash = null; |
23 |
for (int i=1;i<61;i++){ |
24 |
|
25 |
if ( i<10){ |
26 |
valueForHash="0"+String.valueOf(i); |
27 |
}else{
|
28 |
valueForHash=String.valueOf(i);
|
29 |
} |
30 |
cronMinute.put(String.valueOf(i), valueForHash);
|
31 |
if ( i ==1){ |
32 |
cronMinute.put("*", "All"); |
33 |
}else{
|
34 |
cronMinute.put("*/"+i, "Every "+valueForHash+" Minutes"); |
35 |
} |
36 |
} |
37 |
|
38 |
for (int i=0;i<24;i++){ |
39 |
if ( i<10){ |
40 |
valueForHash="0"+String.valueOf(i); |
41 |
}else{
|
42 |
valueForHash=String.valueOf(i);
|
43 |
} |
44 |
cronHour.put(String.valueOf(i), valueForHash);
|
45 |
if ( i ==1){ |
46 |
cronHour.put("*", "All"); |
47 |
}else{
|
48 |
cronHour.put("*/"+i, "Every "+valueForHash+" Hours"); |
49 |
} |
50 |
} |
51 |
|
52 |
cronMonth.put("01", "January"); |
53 |
cronMonth.put("02", "February"); |
54 |
cronMonth.put("03", "March"); |
55 |
cronMonth.put("04", "April"); |
56 |
cronMonth.put("05", "May"); |
57 |
cronMonth.put("06", "June"); |
58 |
cronMonth.put("07", "July"); |
59 |
cronMonth.put("08", "August"); |
60 |
cronMonth.put("09", "September"); |
61 |
cronMonth.put("10", "October"); |
62 |
cronMonth.put("11", "November"); |
63 |
cronMonth.put("12", "December"); |
64 |
cronMonth.put("*", "All"); |
65 |
|
66 |
cronDayOfWeek.put("0", "Sunday"); |
67 |
cronDayOfWeek.put("1", "Monday"); |
68 |
cronDayOfWeek.put("2", "Tuesday"); |
69 |
cronDayOfWeek.put("3", "Wednesday"); |
70 |
cronDayOfWeek.put("4", "Thursday"); |
71 |
cronDayOfWeek.put("5", "Friday"); |
72 |
cronDayOfWeek.put("6", "Saturday"); |
73 |
cronDayOfWeek.put("*", "All"); |
74 |
|
75 |
|
76 |
for (int i=1;i<31;i++){ |
77 |
if ( i<10){ |
78 |
valueForHash="0"+String.valueOf(i); |
79 |
}else{
|
80 |
valueForHash=String.valueOf(i);
|
81 |
} |
82 |
cronDayOfMonth.put(String.valueOf(i), valueForHash);
|
83 |
if ( i ==1){ |
84 |
cronDayOfMonth.put("*", "All"); |
85 |
}else{
|
86 |
cronDayOfMonth.put("*/"+i, "Every "+valueForHash+" Days"); |
87 |
} |
88 |
} |
89 |
|
90 |
Hashtable<Object, Object> permitValueNameVolFS = new Hashtable<Object, Object>(); |
91 |
zProperties zPropertyNameVolFS = new zProperties();
|
92 |
permitValueNameVolFS.clear(); |
93 |
zPropertyNameVolFS.setNameProperty("name");
|
94 |
zPropertyNameVolFS.setLabelProperty("Name Volume/FileSystem replicated");
|
95 |
zPropertyNameVolFS.setType("noupdateable");
|
96 |
zPropertyNameVolFS.setValue("");
|
97 |
zPropertyNameVolFS.setPermitValue(null);
|
98 |
zPropertyNameVolFS.setMultivalues(null);
|
99 |
zSchedulerProperties.put("name", zPropertyNameVolFS);
|
100 |
|
101 |
Hashtable<Object, Object> permitValueFileConf = new Hashtable<Object, Object>(); |
102 |
zProperties zPropertyFileConf = new zProperties();
|
103 |
permitValueFileConf.clear(); |
104 |
zPropertyFileConf.setNameProperty("fileconf");
|
105 |
zPropertyFileConf.setLabelProperty("Configuration File");
|
106 |
zPropertyFileConf.setType("noupdateable");
|
107 |
zPropertyFileConf.setValue("");
|
108 |
zPropertyFileConf.setPermitValue(null);
|
109 |
zPropertyFileConf.setMultivalues(null);
|
110 |
zSchedulerProperties.put("fileconf", zPropertyFileConf);
|
111 |
|
112 |
Hashtable<Object, Object> permitValueNameReplica = new Hashtable<Object, Object>(); |
113 |
zProperties zPropertyNameReplica = new zProperties();
|
114 |
permitValueNameReplica.clear(); |
115 |
zPropertyNameReplica.setNameProperty("namereplica");
|
116 |
zPropertyNameReplica.setLabelProperty("Replica Name");
|
117 |
zPropertyNameReplica.setType("noupdateable");
|
118 |
zPropertyNameReplica.setValue("");
|
119 |
zPropertyNameReplica.setPermitValue(null);
|
120 |
zPropertyNameReplica.setMultivalues(null);
|
121 |
zSchedulerProperties.put("namereplica", zPropertyNameReplica);
|
122 |
|
123 |
Hashtable<Object, Object> permitValueNbReplicas = new Hashtable<Object, Object>(); |
124 |
zProperties zPropertyNbReplicas = new zProperties();
|
125 |
permitValueNbReplicas.clear(); |
126 |
zPropertyNbReplicas.setNameProperty("nbreplica");
|
127 |
zPropertyNbReplicas.setLabelProperty("Number replicas to keep");
|
128 |
zPropertyNbReplicas.setType("freeentry");
|
129 |
zPropertyNbReplicas.setValue("");
|
130 |
zPropertyNbReplicas.setPermitValue(null);
|
131 |
zPropertyNbReplicas.setMultivalues(null);
|
132 |
zSchedulerProperties.put("nbreplica", zPropertyNbReplicas);
|
133 |
|
134 |
Hashtable<Object, Object> permitValueLastSnapshotReplicated = new Hashtable<Object, Object>(); |
135 |
zProperties zPropertyLastSnapshotReplicated = new zProperties();
|
136 |
permitValueLastSnapshotReplicated.clear(); |
137 |
zPropertyLastSnapshotReplicated.setNameProperty("lastsnapshotreplicated");
|
138 |
zPropertyLastSnapshotReplicated.setLabelProperty("Last Snapshot Replicated");
|
139 |
zPropertyLastSnapshotReplicated.setType("noupdateable");
|
140 |
zPropertyLastSnapshotReplicated.setValue("");
|
141 |
zPropertyLastSnapshotReplicated.setPermitValue(null);
|
142 |
zPropertyLastSnapshotReplicated.setMultivalues(null);
|
143 |
zSchedulerProperties.put("lastsnapshotreplicated", zPropertyLastSnapshotReplicated);
|
144 |
|
145 |
Hashtable<Object, Object> permitValueMinutesOfSReplicas = new Hashtable<Object, Object>(); |
146 |
zProperties zPropertyMinutesOfSReplicas = new zProperties();
|
147 |
permitValueMinutesOfSReplicas.clear(); |
148 |
zPropertyMinutesOfSReplicas.setNameProperty("minutesofreplicas");
|
149 |
zPropertyMinutesOfSReplicas.setLabelProperty("Minutes of replication [0-60]");
|
150 |
zPropertyMinutesOfSReplicas.setType("nofreeentry");
|
151 |
zPropertyMinutesOfSReplicas.setValue("");
|
152 |
zPropertyMinutesOfSReplicas.setPermitValue(cronMinute); |
153 |
zPropertyMinutesOfSReplicas.setMultivalues(null);
|
154 |
zSchedulerProperties.put("minutesofreplicas", zPropertyMinutesOfSReplicas);
|
155 |
|
156 |
Hashtable<Object, Object> permitValueReplicaServer = new Hashtable<Object, Object>(); |
157 |
zProperties zPropertyReplicaServer = new zProperties();
|
158 |
permitValueReplicaServer.clear(); |
159 |
zPropertyReplicaServer.setNameProperty("server");
|
160 |
zPropertyReplicaServer.setLabelProperty("Server For Replication");
|
161 |
zPropertyReplicaServer.setType("nofreeentry");
|
162 |
zPropertyReplicaServer.setValue("");
|
163 |
zPropertyReplicaServer.setPermitValue(null);
|
164 |
zPropertyReplicaServer.setMultivalues(null);
|
165 |
zSchedulerProperties.put("server", zPropertyReplicaServer);
|
166 |
|
167 |
Hashtable<Object, Object> permitValueReplicaPool = new Hashtable<Object, Object>(); |
168 |
zProperties zPropertyReplicaPool = new zProperties();
|
169 |
permitValueReplicaPool.clear(); |
170 |
zPropertyReplicaPool.setNameProperty("replicapool");
|
171 |
zPropertyReplicaPool.setLabelProperty("Pool For Replication");
|
172 |
zPropertyReplicaPool.setType("nofreeentry");
|
173 |
zPropertyReplicaPool.setValue("");
|
174 |
zPropertyReplicaPool.setPermitValue(null);
|
175 |
zPropertyReplicaPool.setMultivalues(null);
|
176 |
zSchedulerProperties.put("replicapool", zPropertyReplicaPool);
|
177 |
|
178 |
|
179 |
Hashtable<Object, Object> permitValueReplicasHours = new Hashtable<Object, Object>(); |
180 |
zProperties zPropertyReplicasHours = new zProperties();
|
181 |
permitValueReplicasHours.clear(); |
182 |
zPropertyReplicasHours.setNameProperty("hoursofreplicas");
|
183 |
zPropertyReplicasHours.setLabelProperty("Hour of replication [0-23]");
|
184 |
zPropertyReplicasHours.setType("nofreeentry");
|
185 |
zPropertyReplicasHours.setValue("");
|
186 |
zPropertyReplicasHours.setPermitValue(cronHour); |
187 |
zPropertyReplicasHours.setMultivalues(null);
|
188 |
zSchedulerProperties.put("hoursofreplicas", zPropertyReplicasHours);
|
189 |
|
190 |
Hashtable<Object, Object> permitValueDayOfWeekReplicas = new Hashtable<Object, Object>(); |
191 |
zProperties zPropertyDayOfWeekReplicas = new zProperties();
|
192 |
permitValueDayOfWeekReplicas.clear(); |
193 |
zPropertyDayOfWeekReplicas.setNameProperty("dayofweekreplicas");
|
194 |
zPropertyDayOfWeekReplicas.setLabelProperty("Day of week of Replication [0-6] 0 for Sunday");
|
195 |
zPropertyDayOfWeekReplicas.setType("nofreeentry");
|
196 |
zPropertyDayOfWeekReplicas.setValue("");
|
197 |
zPropertyDayOfWeekReplicas.setPermitValue(cronDayOfWeek); |
198 |
zPropertyDayOfWeekReplicas.setMultivalues(null);
|
199 |
zSchedulerProperties.put("dayofweekreplicas", zPropertyDayOfWeekReplicas);
|
200 |
|
201 |
Hashtable<Object, Object> permitValueDayOfMonthReplicas = new Hashtable<Object, Object>(); |
202 |
zProperties zPropertyDayOfMonthReplicas = new zProperties();
|
203 |
permitValueDayOfMonthReplicas.clear(); |
204 |
zPropertyDayOfMonthReplicas.setNameProperty("dayofmonthreplicas");
|
205 |
zPropertyDayOfMonthReplicas.setLabelProperty("Day of Month of Snapshots [1-30]");
|
206 |
zPropertyDayOfMonthReplicas.setType("nofreeentry");
|
207 |
zPropertyDayOfMonthReplicas.setValue("");
|
208 |
zPropertyDayOfMonthReplicas.setPermitValue(cronDayOfMonth); |
209 |
zPropertyDayOfMonthReplicas.setMultivalues(null);
|
210 |
zSchedulerProperties.put("dayofmonthreplicas", zPropertyDayOfMonthReplicas);
|
211 |
|
212 |
Hashtable<Object, Object> permitValueMonthReplicas = new Hashtable<Object, Object>(); |
213 |
zProperties zPropertyMonthReplicas = new zProperties();
|
214 |
permitValueMonthReplicas.clear(); |
215 |
zPropertyMonthReplicas.setNameProperty("monthreplicas");
|
216 |
zPropertyMonthReplicas.setLabelProperty("Month");
|
217 |
zPropertyMonthReplicas.setType("nofreeentry");
|
218 |
zPropertyMonthReplicas.setValue("");
|
219 |
zPropertyMonthReplicas.setPermitValue(cronMonth); |
220 |
zPropertyMonthReplicas.setMultivalues(null);
|
221 |
zSchedulerProperties.put("monthreplicas", zPropertyMonthReplicas);
|
222 |
|
223 |
/*Hashtable<Object, Object> permitValueFreqSnapshots = new Hashtable<Object, Object>();
|
224 |
zProperties zPropertyFreqSnapshots = new zProperties();
|
225 |
permitValueFreqSnapshots.clear();
|
226 |
zPropertyFreqSnapshots.setNameProperty("frequency");
|
227 |
zPropertyFreqSnapshots.setLabelProperty("Frequency");
|
228 |
zPropertyFreqSnapshots.setType("internaluse");
|
229 |
zPropertyFreqSnapshots.setValue("");
|
230 |
zPropertyFreqSnapshots.setPermitValue(null);
|
231 |
zSchedulerProperties.put("frequency", zPropertyFreqSnapshots);*/
|
232 |
|
233 |
|
234 |
} |
235 |
|
236 |
public void formatCronValue(String frequency, String DaySnapshot){ |
237 |
String cronValue =""; |
238 |
|
239 |
if (frequency.contains("Hours")){ |
240 |
this.zSchedulerProperties.get("minutesofsnaphots").setValue("*"); |
241 |
this.zSchedulerProperties.get("hoursofsnaphots").setValue("*/"+frequency.replaceAll("Every", "").replaceAll("Hours", "")); |
242 |
this.zSchedulerProperties.get("dayofmonthsnapshots").setValue("*"); |
243 |
this.zSchedulerProperties.get("monthsnapshots").setValue("*"); |
244 |
this.zSchedulerProperties.get("dayofweeksnapshots").setValue("*"); |
245 |
|
246 |
}else{
|
247 |
this.zSchedulerProperties.get("hour").setValue(this.zSchedulerProperties.get("time").getValue().split(":")[0]); |
248 |
this.zSchedulerProperties.get("minutes").setValue(this.zSchedulerProperties.get("time").getValue().split(":")[1]); |
249 |
if (frequency.contains("Days")){ |
250 |
this.zSchedulerProperties.get("dayofmonthsnapshots").setValue("*/"+frequency.replaceAll("Every", "").replaceAll("Days", "")); |
251 |
this.zSchedulerProperties.get("monthsnapshots").setValue("*"); |
252 |
this.zSchedulerProperties.get("dayofweeksnapshots").setValue("*"); |
253 |
|
254 |
}else{
|
255 |
if (frequency.contains("Months")){ |
256 |
this.zSchedulerProperties.get("dayofmonthsnapshots").setValue(this.zSchedulerProperties.get("dayofmonthsnapshots").getValue()); |
257 |
this.zSchedulerProperties.get("monthsnapshots").setValue("*/"+frequency.replaceAll("Every", "").replaceAll("Months", "")); |
258 |
this.zSchedulerProperties.get("dayofweeksnapshots").setValue("*"); |
259 |
|
260 |
}else{
|
261 |
if (frequency.contains("Hour")){ |
262 |
this.zSchedulerProperties.get("minutes").setValue("*"); |
263 |
this.zSchedulerProperties.get("hours").setValue("*/"+frequency.replaceAll("Every", "").replaceAll("Hour", "")); |
264 |
this.zSchedulerProperties.get("dayofmonthsnapshots").setValue("*"); |
265 |
this.zSchedulerProperties.get("monthsnapshots").setValue("*"); |
266 |
this.zSchedulerProperties.get("dayofweeksnapshots").setValue("*"); |
267 |
}else{
|
268 |
if (frequency.contains("Day")){ |
269 |
this.zSchedulerProperties.get("dayofmonthsnapshots").setValue("*/"+frequency.replaceAll("Every", "").replaceAll("Day", "")); |
270 |
this.zSchedulerProperties.get("monthsnapshots").setValue("*"); |
271 |
this.zSchedulerProperties.get("dayofweeksnapshots").setValue("*"); |
272 |
}else{
|
273 |
if (frequency.contains("Month")){ |
274 |
this.zSchedulerProperties.get("dayofmonthsnapshots").setValue(this.zSchedulerProperties.get("dayofmonthsnapshots").getValue()); |
275 |
this.zSchedulerProperties.get("monthsnapshots").setValue("*/"+frequency.replaceAll("Every", "").replaceAll("Month", "")); |
276 |
this.zSchedulerProperties.get("dayofweeksnapshots").setValue("*"); |
277 |
} |
278 |
} |
279 |
} |
280 |
} |
281 |
} |
282 |
} |
283 |
} |
284 |
|
285 |
public static int getIntDayOfWeek(String dayOfWeek) |
286 |
{ |
287 |
try
|
288 |
{ |
289 |
DateFormat formatter ;
|
290 |
Date date ;
|
291 |
formatter = new SimpleDateFormat("EEE"); |
292 |
date = (Date)formatter.parse(dayOfWeek);
|
293 |
GregorianCalendar g = new GregorianCalendar(); |
294 |
g.setTime(date); |
295 |
return g.get(Calendar.DAY_OF_WEEK); |
296 |
} |
297 |
catch (ParseException e) |
298 |
{ |
299 |
System.out.println("Exception :"+e); |
300 |
} |
301 |
return 0; |
302 |
} |
303 |
|
304 |
|
305 |
|
306 |
|
307 |
|
308 |
} |