Revision 6528
Added by Chris Jones about 13 years ago
src/edu/ucsb/nceas/metacat/dataone/MNodeService.java | ||
---|---|---|
34 | 34 |
|
35 | 35 |
import org.apache.commons.io.IOUtils; |
36 | 36 |
import org.apache.log4j.Logger; |
37 |
import org.dataone.client.CNode; |
|
37 | 38 |
import org.dataone.client.D1Client; |
38 | 39 |
import org.dataone.client.MNode; |
39 | 40 |
import org.dataone.service.exceptions.IdentifierNotUnique; |
... | ... | |
69 | 70 |
import org.dataone.service.types.v1.ObjectList; |
70 | 71 |
import org.dataone.service.types.v1.Permission; |
71 | 72 |
import org.dataone.service.types.v1.Ping; |
73 |
import org.dataone.service.types.v1.ReplicationStatus; |
|
72 | 74 |
import org.dataone.service.types.v1.Schedule; |
73 | 75 |
import org.dataone.service.types.v1.Service; |
74 | 76 |
import org.dataone.service.types.v1.Services; |
... | ... | |
382 | 384 |
* @throws InvalidRequest |
383 | 385 |
*/ |
384 | 386 |
@Override |
385 |
public boolean replicate(Session session, SystemMetadata sysmeta, NodeReference sourceNode) throws NotImplemented, ServiceFailure, NotAuthorized, |
|
386 |
InvalidRequest, InsufficientResources, UnsupportedType { |
|
387 |
public boolean replicate(Session session, SystemMetadata sysmeta, NodeReference sourceNode) |
|
388 |
throws NotImplemented, ServiceFailure, NotAuthorized, InvalidRequest, |
|
389 |
InsufficientResources, UnsupportedType { |
|
387 | 390 |
|
388 | 391 |
boolean result = false; |
389 | 392 |
|
... | ... | |
395 | 398 |
// get from the membernode |
396 | 399 |
// TODO: switch credentials for the server retrieval? |
397 | 400 |
MNode mn = D1Client.getMN(sourceNode); |
401 |
CNode cn = D1Client.getCN(); |
|
402 |
|
|
398 | 403 |
InputStream object = null; |
399 | 404 |
|
400 | 405 |
try { |
401 |
object = mn.get(session, pid); |
|
406 |
object = mn.getReplica(session, pid);
|
|
402 | 407 |
} catch (InvalidToken e) { |
403 | 408 |
e.printStackTrace(); |
404 | 409 |
throw new ServiceFailure("2151", "Could not retrieve object to replicate (InvalidToken): " + e.getMessage()); |
... | ... | |
423 | 428 |
throw new ServiceFailure("2151", "Could not save object to local store (InvalidSystemMetadata): " + e.getMessage()); |
424 | 429 |
} |
425 | 430 |
|
431 |
try { |
|
432 |
session = null; |
|
433 |
cn.setReplicationStatus(session, pid, sourceNode, ReplicationStatus.COMPLETED); |
|
434 |
|
|
435 |
} catch (InvalidToken e) { |
|
436 |
// TODO Auto-generated catch block |
|
437 |
e.printStackTrace(); |
|
438 |
} catch (NotFound e) { |
|
439 |
// TODO Auto-generated catch block |
|
440 |
e.printStackTrace(); |
|
441 |
} |
|
426 | 442 |
return result; |
427 | 443 |
|
428 | 444 |
} |
Also available in: Unified diff
Once a CN calls replicate() on an MN, the MN needs to call getReplica() on the source MN (not get()). Once the bytes are retrieved, the MN must then call back to the CN with setReplicationStatus() to indicate that the replication status is complete. Modify MNodeService to do so.