Revision 6118
Added by ben leinfelder almost 13 years ago
ReplicationHandler.java | ||
---|---|---|
281 | 281 |
REVINSERTNUMBER = 1; |
282 | 282 |
REVERRORNUMBER = 1; |
283 | 283 |
|
284 |
// handle system metadata |
|
285 |
Vector<Vector<String>> systemMetadataList = message.getSystemMetadataVect(); |
|
286 |
for(int k = 0; k < systemMetadataList.size(); k++) { |
|
287 |
Vector<String> w = systemMetadataList.elementAt(k); |
|
288 |
String guid = (String) w.elementAt(0); |
|
289 |
String remoteserver = (String) w.elementAt(1); |
|
290 |
try { |
|
291 |
handleSystemMetadata(remoteserver, guid); |
|
292 |
} |
|
293 |
catch (Exception ee) { |
|
294 |
logMetacat.error("Error replicating system metedata for guid: " + guid, ee); |
|
295 |
continue; |
|
296 |
} |
|
297 |
} |
|
298 |
|
|
284 | 299 |
totalServerListParseTime += (System.currentTimeMillis() - startServerListParseTime); |
285 | 300 |
}//for response |
286 | 301 |
|
... | ... | |
796 | 811 |
DBConnectionPool.returnDBConnection(dbConn, serialNumber); |
797 | 812 |
}//finally |
798 | 813 |
} |
814 |
|
|
815 |
/** |
|
816 |
* Handle replicate system metadata |
|
817 |
* |
|
818 |
* @param remoteserver |
|
819 |
* @param guid |
|
820 |
* @throws HandlerException |
|
821 |
*/ |
|
822 |
private void handleSystemMetadata(String remoteserver, String guid) |
|
823 |
throws HandlerException { |
|
824 |
try { |
|
799 | 825 |
|
826 |
// Try get the system metadata from remote server |
|
827 |
String sysMetaURLStr = "https://" + remoteserver + "?server=" |
|
828 |
+ MetacatUtil.getLocalReplicationServerName() |
|
829 |
+ "&action=getsystemmetadata&guid=" + guid; |
|
830 |
sysMetaURLStr = MetacatUtil.replaceWhiteSpaceForURL(sysMetaURLStr); |
|
831 |
URL sysMetaUrl = new URL(sysMetaURLStr); |
|
832 |
logReplication.info("ReplicationHandler.handleSystemMetadata - Sending message: " |
|
833 |
+ sysMetaUrl.toString()); |
|
834 |
String systemMetadataXML = ReplicationService.getURLContent(sysMetaUrl); |
|
800 | 835 |
|
836 |
logReplication.info("ReplicationHandler.handleSystemMetadata - guid in repl: " + guid); |
|
801 | 837 |
|
838 |
// process system metadata |
|
839 |
if (systemMetadataXML != null) { |
|
840 |
SystemMetadata sysMeta = (SystemMetadata) ServiceTypeUtil |
|
841 |
.deserializeServiceType(SystemMetadata.class, |
|
842 |
new ByteArrayInputStream(systemMetadataXML |
|
843 |
.getBytes("UTF-8"))); |
|
844 |
// String guid = sysMeta.getIdentifier().getValue(); |
|
845 |
if (!IdentifierManager.getInstance().identifierExists(guid)) { |
|
846 |
logReplication.debug("Creating system metadata for guid: " + guid); |
|
847 |
IdentifierManager.getInstance().createSystemMetadata(sysMeta); |
|
848 |
} |
|
849 |
IdentifierManager.getInstance().updateSystemMetadata(sysMeta); |
|
850 |
} |
|
851 |
|
|
852 |
logReplication.info("ReplicationHandler.handleSystemMetadata - Successfully replicated system metadata for guid: " |
|
853 |
+ guid); |
|
854 |
|
|
855 |
String ip = getIpFromURL(sysMetaUrl); |
|
856 |
EventLog.getInstance().log(ip, ReplicationService.REPLICATIONUSER, guid, "systemMetadata"); |
|
857 |
|
|
858 |
} catch (Exception e) { |
|
859 |
logMetacat.error("ReplicationHandler.handleSystemMetadata - " |
|
860 |
+ ReplicationService.METACAT_REPL_ERROR_MSG); |
|
861 |
logReplication |
|
862 |
.error("ReplicationHandler.handleSystemMetadata - Failed to write system metadata " |
|
863 |
+ guid + " into db because " + e.getMessage()); |
|
864 |
throw new HandlerException( |
|
865 |
"ReplicationHandler.handleSystemMetadata - generic exception " |
|
866 |
+ "writing Replication: " + e.getMessage()); |
|
867 |
} |
|
868 |
|
|
869 |
} |
|
870 |
|
|
802 | 871 |
/** |
803 | 872 |
* updates xml_catalog with entries from other servers. |
804 | 873 |
*/ |
Also available in: Unified diff
handle timed replication of system metadata. there are still a few outstanding issues:
-track server location of system metadata-only entries
-replication policy flag for system metadata-only entries?
-locking for replicated entries?
-forced replication of entries