Revision 6457
Added by ben leinfelder about 13 years ago
src/edu/ucsb/nceas/metacat/dataone/hazelcast/CNReplicationTask.java | ||
---|---|---|
26 | 26 |
|
27 | 27 |
import org.dataone.client.D1Client; |
28 | 28 |
import org.dataone.configuration.Settings; |
29 |
import org.dataone.service.exceptions.NotFound; |
|
30 | 29 |
import org.dataone.service.types.v1.Identifier; |
31 | 30 |
import org.dataone.service.types.v1.Node; |
32 | 31 |
import org.dataone.service.types.v1.Permission; |
... | ... | |
35 | 34 |
import com.hazelcast.core.Hazelcast; |
36 | 35 |
import com.hazelcast.core.IMap; |
37 | 36 |
|
38 |
import edu.ucsb.nceas.metacat.IdentifierManager; |
|
39 |
import edu.ucsb.nceas.metacat.McdbDocNotFoundException; |
|
40 |
import edu.ucsb.nceas.metacat.dataone.CNodeService; |
|
41 |
|
|
42 | 37 |
/** |
43 | 38 |
* A single CN replication task to be executed by the CN Replication Service. This |
44 | 39 |
* applies to replication of system metadata, science metadata, and resource maps |
... | ... | |
267 | 262 |
|
268 | 263 |
// get the systemMetadata |
269 | 264 |
SystemMetadata sm = sysMetaMap.get(pid); |
265 |
// TODO: need any info from the system metadata? |
|
270 | 266 |
|
271 |
|
|
272 |
|
|
273 |
// only system metadata - no data replicated |
|
274 |
boolean isData = formatType.equals("??"); |
|
275 |
if (!isData) { |
|
276 |
// TODO: get the science metadata/ORE from somewhere |
|
277 |
InputStream sciMetaORE = null; |
|
278 |
try { |
|
279 |
sciMetaORE = CNodeService.getInstance().get(null, pid); |
|
280 |
} catch (NotFound nf) { |
|
281 |
try { |
|
282 |
sciMetaORE = D1Client.getCN().get(null, pid); |
|
283 |
// save it locally |
|
284 |
CNodeService.getInstance().create(null, pid, sciMetaORE, sm); |
|
285 |
} catch (Exception e) { |
|
286 |
// TODO Auto-generated catch block |
|
287 |
e.printStackTrace(); |
|
288 |
} |
|
289 |
} catch (Exception e) { |
|
290 |
e.printStackTrace(); |
|
291 |
} |
|
292 |
} else { |
|
293 |
// just system metadata |
|
294 |
try { |
|
295 |
if (!IdentifierManager.getInstance().identifierExists(pid.getValue())) { |
|
296 |
IdentifierManager.getInstance().createSystemMetadata(sm); |
|
297 |
} else { |
|
298 |
IdentifierManager.getInstance().updateSystemMetadata(sm); |
|
299 |
} |
|
300 |
} catch (McdbDocNotFoundException e) { |
|
301 |
// TODO Auto-generated catch block |
|
302 |
e.printStackTrace(); |
|
303 |
return null; |
|
304 |
} |
|
305 |
} |
|
306 |
|
|
267 |
// get the object from source |
|
268 |
InputStream sciMetaORE = null; |
|
269 |
try { |
|
270 |
// get from the MN |
|
271 |
sciMetaORE = D1Client.getMN(originatingNode.getIdentifier()).get(null, pid); |
|
272 |
|
|
273 |
// save it to target |
|
274 |
D1Client.getMN(targetNode.getIdentifier()).create(null, pid, sciMetaORE, sm); |
|
275 |
} catch (Exception e) { |
|
276 |
// report up the stack, even though we can't declare it |
|
277 |
throw new RuntimeException(e.getMessage(), e); |
|
278 |
} |
|
279 |
|
|
307 | 280 |
return pid; |
308 | 281 |
} |
309 | 282 |
|
Also available in: Unified diff
rework this to be MN->MN replication. Should be fleshed out more.