Revision 6135
Added by ben leinfelder over 13 years ago
lib/style/skins/dev/replMain.html | ||
---|---|---|
99 | 99 |
<input size="30" name="server" > <br> |
100 | 100 |
Replicate xml doc To server (1 or 0)?: <input size="2" name="replicate"> <br> |
101 | 101 |
Replicate data file To server (1 or 0)?: <input size="2" name="datareplicate"> <br> |
102 |
Replicate system metadata To server (1 or 0)?: <input size="2" name="systemmetadatareplicate"> <br> |
|
102 | 103 |
Localhost is a hub to server (1 or 0)?: <input size="2" name="hub"> <br> |
103 | 104 |
Download certificate from<br> |
104 | 105 |
<input type="text" size="30" name="certificate"> |
src/edu/ucsb/nceas/metacat/replication/ReplicationServer.java | ||
---|---|---|
42 | 42 |
//it is relative to replcation |
43 | 43 |
//if replication is false, it should |
44 | 44 |
//be false |
45 |
private boolean systemMetadataReplication = false; //replicate system metadata or not |
|
45 | 46 |
private boolean hub = false; //it is hub or not. Hub means the localhost can |
46 | 47 |
//replcate documents to the server if the |
47 | 48 |
//document's home server is not localhost |
48 | 49 |
/** |
49 |
* Consturctor of ReplicationServer
|
|
50 |
* Constructor of ReplicationServer
|
|
50 | 51 |
*/ |
51 | 52 |
public ReplicationServer() |
52 | 53 |
{ |
... | ... | |
125 | 126 |
this.dataReplication = myDataReplication; |
126 | 127 |
}//setDataReplication |
127 | 128 |
|
128 |
/** |
|
129 |
public boolean isSystemMetadataReplication() { |
|
130 |
return systemMetadataReplication; |
|
131 |
} |
|
132 |
|
|
133 |
public void setSystemMetadataReplication(boolean systemMetadataReplication) { |
|
134 |
this.systemMetadataReplication = systemMetadataReplication; |
|
135 |
} |
|
136 |
|
|
137 |
/** |
|
129 | 138 |
* Get hub option |
130 | 139 |
*/ |
131 | 140 |
public boolean getHub() |
src/edu/ucsb/nceas/metacat/replication/ReplicationService.java | ||
---|---|---|
291 | 291 |
String replicate = null; |
292 | 292 |
String server = null; |
293 | 293 |
String dataReplicate = null; |
294 |
String systemMetadataReplicate = null; |
|
294 | 295 |
String hub = null; |
295 | 296 |
Writer out = null; |
296 | 297 |
try { |
... | ... | |
309 | 310 |
|
310 | 311 |
//Get data replication value |
311 | 312 |
dataReplicate = ((String[]) params.get("datareplicate"))[0]; |
313 |
//Get system metadata replication value |
|
314 |
systemMetadataReplicate = ((String[]) params.get("systemmetadatareplicate"))[0]; |
|
312 | 315 |
//Get hub value |
313 | 316 |
hub = ((String[]) params.get("hub"))[0]; |
314 | 317 |
|
315 | 318 |
String toDateSql = DatabaseService.getInstance().getDBAdapter().toDate("01/01/1980","MM/DD/YYYY"); |
316 | 319 |
String sql = "INSERT INTO xml_replication " |
317 |
+ "(server, last_checked, replicate, datareplicate, hub) " |
|
318 |
+ "VALUES (?," + toDateSql + ",?,?,?)"; |
|
320 |
+ "(server, last_checked, replicate, datareplicate, systemmetadatareplicate, hub) "
|
|
321 |
+ "VALUES (?," + toDateSql + ",?,?,?,?)";
|
|
319 | 322 |
|
320 | 323 |
pstmt = dbConn.prepareStatement(sql); |
321 | 324 |
|
322 | 325 |
pstmt.setString(1, server); |
323 | 326 |
pstmt.setInt(2, Integer.parseInt(replicate)); |
324 | 327 |
pstmt.setInt(3, Integer.parseInt(dataReplicate)); |
325 |
pstmt.setInt(4, Integer.parseInt(hub)); |
|
328 |
pstmt.setInt(4, Integer.parseInt(systemMetadataReplicate)); |
|
329 |
pstmt.setInt(5, Integer.parseInt(hub)); |
|
326 | 330 |
|
327 | 331 |
String sqlReport = "XMLAccessAccess.getXMLAccessForDoc - SQL: " + sql; |
328 | 332 |
sqlReport += " [" + server + "," + replicate + |
... | ... | |
336 | 340 |
out.write("Server " + server + " added"); |
337 | 341 |
response.setContentType("text/html"); |
338 | 342 |
out.write("<html><body><table border=\"1\">"); |
339 |
out.write("<tr><td><b>server</b></td><td><b>last_checked</b></td><td>"); |
|
340 |
out.write("<b>replicate</b></td>"); |
|
343 |
out.write("<tr><td><b>server</b></td>"); |
|
344 |
out.write("<td><b>last_checked</b></td>"); |
|
345 |
out.write("<td><b>replicate</b></td>"); |
|
341 | 346 |
out.write("<td><b>datareplicate</b></td>"); |
347 |
out.write("<td><b>systemmetadatareplicate</b></td>"); |
|
342 | 348 |
out.write("<td><b>hub</b></td></tr>"); |
343 |
pstmt = dbConn.prepareStatement("SELECT * FROM xml_replication");
|
|
349 |
pstmt = dbConn.prepareStatement("SELECT serverid, server, last_checked, replicate, datareplicate, systemmetadatareplicate, hub FROM xml_replication");
|
|
344 | 350 |
//increase dbconnection usage |
345 | 351 |
dbConn.increaseUsageCount(1); |
346 | 352 |
|
... | ... | |
352 | 358 |
out.write(rs.getString(3) + "</td><td>"); |
353 | 359 |
out.write(rs.getString(4) + "</td><td>"); |
354 | 360 |
out.write(rs.getString(5) + "</td><td>"); |
355 |
out.write(rs.getString(6) + "</td></tr>"); |
|
361 |
out.write(rs.getString(6) + "</td><td>"); |
|
362 |
out.write(rs.getString(7) + "</td></tr>"); |
|
356 | 363 |
|
357 | 364 |
tablehasrows = rs.next(); |
358 | 365 |
} |
... | ... | |
376 | 383 |
out.write("Server " + server + " deleted"); |
377 | 384 |
response.setContentType("text/html"); |
378 | 385 |
out.write("<html><body><table border=\"1\">"); |
379 |
out.write("<tr><td><b>server</b></td><td><b>last_checked</b></td><td>"); |
|
380 |
out.write("<b>replicate</b></td>"); |
|
386 |
out.write("<tr><td><b>server</b></td>"); |
|
387 |
out.write("<td><b>last_checked</b></td>"); |
|
388 |
out.write("<td><b>replicate</b></td>"); |
|
381 | 389 |
out.write("<td><b>datareplicate</b></td>"); |
390 |
out.write("<td><b>systemmetadatareplicate</b></td>"); |
|
382 | 391 |
out.write("<td><b>hub</b></td></tr>"); |
383 | 392 |
|
384 |
pstmt = dbConn.prepareStatement("SELECT * FROM xml_replication");
|
|
393 |
pstmt = dbConn.prepareStatement("SELECT serverid, server, last_checked, replicate, datareplicate, systemmetadatareplicate, hub FROM xml_replication");
|
|
385 | 394 |
//increase dbconnection usage |
386 | 395 |
dbConn.increaseUsageCount(1); |
387 | 396 |
pstmt.execute(); |
... | ... | |
392 | 401 |
out.write(rs.getString(3) + "</td><td>"); |
393 | 402 |
out.write(rs.getString(4) + "</td><td>"); |
394 | 403 |
out.write(rs.getString(5) + "</td><td>"); |
395 |
out.write(rs.getString(6) + "</td></tr>"); |
|
404 |
out.write(rs.getString(6) + "</td><td>"); |
|
405 |
out.write(rs.getString(7) + "</td></tr>"); |
|
396 | 406 |
tablehasrows = rs.next(); |
397 | 407 |
} |
398 | 408 |
out.write("</table></body></html>"); |
... | ... | |
401 | 411 |
} else if (subaction.equals("list")) { |
402 | 412 |
response.setContentType("text/html"); |
403 | 413 |
out.write("<html><body><table border=\"1\">"); |
404 |
out.write("<tr><td><b>server</b></td><td><b>last_checked</b></td><td>"); |
|
405 |
out.write("<b>replicate</b></td>"); |
|
414 |
out.write("<tr><td><b>server</b></td>"); |
|
415 |
out.write("<td><b>last_checked</b></td>"); |
|
416 |
out.write("<td><b>replicate</b></td>"); |
|
406 | 417 |
out.write("<td><b>datareplicate</b></td>"); |
418 |
out.write("<td><b>systemmetadatareplicate</b></td>"); |
|
407 | 419 |
out.write("<td><b>hub</b></td></tr>"); |
408 |
pstmt = dbConn.prepareStatement("SELECT * FROM xml_replication");
|
|
420 |
pstmt = dbConn.prepareStatement("SELECT serverid, server, last_checked, replicate, datareplicate, systemmetadatareplicate, hub FROM xml_replication");
|
|
409 | 421 |
pstmt.execute(); |
410 | 422 |
ResultSet rs = pstmt.getResultSet(); |
411 | 423 |
boolean tablehasrows = rs.next(); |
... | ... | |
414 | 426 |
out.write(rs.getString(3) + "</td><td>"); |
415 | 427 |
out.write(rs.getString(4) + "</td><td>"); |
416 | 428 |
out.write(rs.getString(5) + "</td><td>"); |
417 |
out.write(rs.getString(6) + "</td></tr>"); |
|
429 |
out.write(rs.getString(6) + "</td><td>"); |
|
430 |
out.write(rs.getString(7) + "</td></tr>"); |
|
431 |
|
|
418 | 432 |
tablehasrows = rs.next(); |
419 | 433 |
} |
420 | 434 |
out.write("</table></body></html>"); |
... | ... | |
1505 | 1519 |
doclist.append(prepareRevisionDoc(dbConn, revisionSql.toString(), |
1506 | 1520 |
replicateData)); |
1507 | 1521 |
|
1508 |
// add the system metadata entries |
|
1509 |
Date since = new Date(System.currentTimeMillis()); |
|
1510 |
since = serverList.getLastCheckedDate(server); |
|
1511 |
List<String> systemMetadataEntries = |
|
1512 |
IdentifierManager.getInstance().getUpdatedSystemMetadataIds(since); |
|
1513 |
for (int i = 0; i < systemMetadataEntries.size(); i++) { |
|
1514 |
String guid = systemMetadataEntries.get(i); |
|
1515 |
doclist.append("<updatedSystemMetadata>"); |
|
1516 |
doclist.append("<guid>"); |
|
1517 |
doclist.append(guid); |
|
1518 |
doclist.append("</guid>"); |
|
1519 |
doclist.append("</updatedSystemMetadata>"); |
|
1522 |
// add the system metadata entries if configured to replicate them |
|
1523 |
boolean replicateSystemMetadata = serverList.getSystemMetadataReplicationValue(server); |
|
1524 |
if (replicateSystemMetadata) { |
|
1525 |
Date since = new Date(System.currentTimeMillis()); |
|
1526 |
since = serverList.getLastCheckedDate(server); |
|
1527 |
List<String> systemMetadataEntries = |
|
1528 |
IdentifierManager.getInstance().getUpdatedSystemMetadataIds(since); |
|
1529 |
for (int i = 0; i < systemMetadataEntries.size(); i++) { |
|
1530 |
String guid = systemMetadataEntries.get(i); |
|
1531 |
doclist.append("<updatedSystemMetadata>"); |
|
1532 |
doclist.append("<guid>"); |
|
1533 |
doclist.append(guid); |
|
1534 |
doclist.append("</guid>"); |
|
1535 |
doclist.append("</updatedSystemMetadata>"); |
|
1536 |
} |
|
1520 | 1537 |
} |
1521 | 1538 |
|
1522 | 1539 |
doclist.append("</updates></replication>"); |
src/edu/ucsb/nceas/metacat/replication/ForceReplicationSystemMetadataHandler.java | ||
---|---|---|
113 | 113 |
// If the server is the notification server, we don't notify it back |
114 | 114 |
// again, if server is null we don't replicate to |
115 | 115 |
if (server != null && !server.equals(notificationServer)) { |
116 |
if (replicationServer.isSystemMetadataReplication()) { |
|
117 |
comeAndGetIt = new URL("https://" + server |
|
118 |
+ "?action=forcereplicatesystemmetadata" |
|
119 |
+ "&guid=" + guid + "&server=" |
|
120 |
+ MetacatUtil.getLocalReplicationServerName()); |
|
116 | 121 |
|
117 |
comeAndGetIt = new URL("https://" + server |
|
118 |
+ "?action=forcereplicatesystemmetadata" |
|
119 |
+ "&guid=" + guid + "&server=" |
|
120 |
+ MetacatUtil.getLocalReplicationServerName()); |
|
121 |
|
|
122 |
// Make sure comeAndGetIt is not empty |
|
123 |
if (comeAndGetIt != null && !comeAndGetIt.equals("")) { |
|
124 | 122 |
logReplication.warn("Sending message: " + comeAndGetIt.toString()); |
125 | 123 |
String message = ReplicationService.getURLContent(comeAndGetIt); |
126 | 124 |
} |
src/edu/ucsb/nceas/metacat/replication/ReplicationServerList.java | ||
---|---|---|
75 | 75 |
ResultSet rs = null; |
76 | 76 |
boolean hasReplication = false;//Replication xml or not |
77 | 77 |
boolean hasDataReplication = false;//Replication data file or not |
78 |
boolean hasSystemMetadataReplication = false;//Replication for system metadata or not |
|
78 | 79 |
boolean isHub = false;//local host is the hub for this server or not |
79 | 80 |
|
80 | 81 |
try |
... | ... | |
85 | 86 |
serialNumber=dbConn.getCheckOutSerialNumber(); |
86 | 87 |
//Select fields from xml_replication table |
87 | 88 |
pstmt = dbConn.prepareStatement("select server, last_checked, replicate,"+ |
88 |
" datareplicate, hub from xml_replication"); |
|
89 |
" datareplicate, systemmetadatareplicate, hub from xml_replication");
|
|
89 | 90 |
//Execute prepare statement |
90 | 91 |
pstmt.execute(); |
91 | 92 |
//Get result set |
... | ... | |
106 | 107 |
//Data replication value |
107 | 108 |
int dataReplication = rs.getInt(4); |
108 | 109 |
logMetacat.info("DataReplication value: "+dataReplication); |
110 |
//Data replication value |
|
111 |
int systemMetadataReplication = rs.getInt(5); |
|
112 |
logMetacat.info("DataReplication value: "+dataReplication); |
|
109 | 113 |
//Hub value |
110 |
int hubValue = rs.getInt(5);
|
|
114 |
int hubValue = rs.getInt(6);
|
|
111 | 115 |
logMetacat.info("Hub value: "+hubValue); |
112 | 116 |
//Get rid of local host |
113 | 117 |
if(!serverName.equals("localhost")) |
... | ... | |
149 | 153 |
}//else |
150 | 154 |
//Set data replciation value |
151 | 155 |
server.setDataReplication(hasDataReplication); |
156 |
if (systemMetadataReplication == 1) { |
|
157 |
hasSystemMetadataReplication = true; |
|
158 |
} |
|
159 |
server.setSystemMetadataReplication(hasSystemMetadataReplication); |
|
152 | 160 |
|
153 | 161 |
//Detemine isHub by hubValue |
154 | 162 |
if (hubValue ==1) |
... | ... | |
381 | 389 |
//Return this object's data replication value |
382 | 390 |
return server.getDataReplication(); |
383 | 391 |
}//getDataReplicationValue |
392 |
|
|
393 |
/** |
|
394 |
* To a given server name, try to get its data file replciation option |
|
395 |
* If couldn't find the server in the server list, false will return |
|
396 |
* @param givenServerName, the server's name which we want to get data file |
|
397 |
* replication value |
|
398 |
*/ |
|
399 |
public synchronized boolean getSystemMetadataReplicationValue(String givenServerName) |
|
400 |
{ |
|
401 |
int index = -1;//Variable to store the index |
|
402 |
ReplicationServer server = null;//Variable for replication server |
|
403 |
|
|
404 |
//Get the server's index in server list |
|
405 |
index = findIndexInServerList(givenServerName); |
|
406 |
//If index = -1, couldn't find this server, null will return |
|
407 |
if (index == -1) |
|
408 |
{ |
|
409 |
return false; |
|
410 |
}//if |
|
411 |
//Get Replication server object |
|
412 |
server = (ReplicationServer) serverList.elementAt(index); |
|
413 |
//Return this object's data replication value |
|
414 |
return server.isSystemMetadataReplication(); |
|
415 |
} |
|
384 | 416 |
|
385 | 417 |
/** |
386 | 418 |
* To a given server name, try to get its hub option |
Also available in: Unified diff
add option for replicating system metadata (dataone)
https://redmine.dataone.org/issues/1626