Revision 6351
Added by Chris Jones over 13 years ago
src/edu/ucsb/nceas/metacat/dataone/MNodeService.java | ||
---|---|---|
27 | 27 |
import java.io.InputStream; |
28 | 28 |
import java.security.NoSuchAlgorithmException; |
29 | 29 |
import java.sql.SQLException; |
30 |
import java.text.SimpleDateFormat; |
|
30 | 31 |
import java.util.Date; |
31 | 32 |
import java.util.List; |
32 | 33 |
|
... | ... | |
64 | 65 |
import org.dataone.service.types.Node; |
65 | 66 |
import org.dataone.service.types.NodeHealth; |
66 | 67 |
import org.dataone.service.types.NodeReference; |
68 |
import org.dataone.service.types.NodeState; |
|
67 | 69 |
import org.dataone.service.types.NodeType; |
68 | 70 |
import org.dataone.service.types.ObjectFormat; |
69 | 71 |
import org.dataone.service.types.ObjectFormatIdentifier; |
70 | 72 |
import org.dataone.service.types.ObjectList; |
71 | 73 |
import org.dataone.service.types.Permission; |
74 |
import org.dataone.service.types.Ping; |
|
75 |
import org.dataone.service.types.Schedule; |
|
72 | 76 |
import org.dataone.service.types.Service; |
73 | 77 |
import org.dataone.service.types.Services; |
74 | 78 |
import org.dataone.service.types.Session; |
79 |
import org.dataone.service.types.Status; |
|
75 | 80 |
import org.dataone.service.types.Subject; |
76 | 81 |
import org.dataone.service.types.Synchronization; |
77 | 82 |
import org.dataone.service.types.SystemMetadata; |
... | ... | |
694 | 699 |
"dataone.nodeReplicate")).booleanValue(); |
695 | 700 |
|
696 | 701 |
mnCoreServiceVersion = |
697 |
PropertyService.getProperty("dataone.mncore.serviceVersion");
|
|
702 |
PropertyService.getProperty("dataone.mnCore.serviceVersion");
|
|
698 | 703 |
mnReadServiceVersion = |
699 |
PropertyService.getProperty("dataone.mnread.serviceVersion");
|
|
704 |
PropertyService.getProperty("dataone.mnRead.serviceVersion");
|
|
700 | 705 |
mnAuthorizationServiceVersion = |
701 |
PropertyService.getProperty("dataone.mnauthorization.serviceVersion");
|
|
706 |
PropertyService.getProperty("dataone.mnAuthorization.serviceVersion");
|
|
702 | 707 |
mnStorageServiceVersion = |
703 |
PropertyService.getProperty("dataone.mnstorage.serviceVersion");
|
|
708 |
PropertyService.getProperty("dataone.mnStorage.serviceVersion");
|
|
704 | 709 |
mnReplicationServiceVersion = |
705 |
PropertyService.getProperty("dataone.mnreplication.serviceVersion");
|
|
710 |
PropertyService.getProperty("dataone.mnReplication.serviceVersion");
|
|
706 | 711 |
|
707 | 712 |
mnCoreServiceAvailable = new Boolean( |
708 |
PropertyService.getProperty("dataone.mncore.serviceAvailable")).booleanValue();
|
|
713 |
PropertyService.getProperty("dataone.mnCore.serviceAvailable")).booleanValue();
|
|
709 | 714 |
mnReadServiceAvailable = new Boolean( |
710 | 715 |
PropertyService.getProperty( |
711 |
"dataone.mnread.serviceAvailable")).booleanValue();
|
|
716 |
"dataone.mnRead.serviceAvailable")).booleanValue();
|
|
712 | 717 |
mnAuthorizationServiceAvailable = new Boolean( |
713 | 718 |
PropertyService.getProperty( |
714 |
"dataone.mnauthorization.serviceAvailable")).booleanValue();
|
|
719 |
"dataone.mnAuthorization.serviceAvailable")).booleanValue();
|
|
715 | 720 |
mnStorageServiceAvailable = new Boolean( |
716 | 721 |
PropertyService.getProperty( |
717 |
"dataone.mnstorage.serviceAvailable")).booleanValue();
|
|
722 |
"dataone.mnStorage.serviceAvailable")).booleanValue();
|
|
718 | 723 |
mnReplicationServiceAvailable = new Boolean( |
719 | 724 |
PropertyService.getProperty( |
720 |
"dataone.mnreplication.serviceAvailable")).booleanValue();
|
|
725 |
"dataone.mnReplication.serviceAvailable")).booleanValue();
|
|
721 | 726 |
|
722 | 727 |
} catch(PropertyNotFoundException pnfe) { |
723 | 728 |
logMetacat.error("MNodeService.getCapabilities(): " + |
... | ... | |
725 | 730 |
|
726 | 731 |
} |
727 | 732 |
|
728 |
// set the properties of the node based on configuration information |
|
733 |
// Set the properties of the node based on configuration information and |
|
734 |
// calls to current status methods |
|
729 | 735 |
Node node = new Node(); |
730 | 736 |
node.setBaseURL(metacatUrl + "/" + nodeType); |
731 | 737 |
node.setDescription(nodeDesc); |
732 |
// TODO: health |
|
738 |
|
|
739 |
// set the node's health information |
|
733 | 740 |
NodeHealth health = new NodeHealth(); |
741 |
NodeState state = NodeState.UP; |
|
742 |
health.setState(state); |
|
743 |
// set the ping response to the current value |
|
744 |
Ping canPing = new Ping(); |
|
745 |
canPing.setSuccess(false); |
|
746 |
try { |
|
747 |
canPing.setSuccess(ping()); |
|
748 |
} catch (InsufficientResources e) { |
|
749 |
e.printStackTrace(); |
|
750 |
|
|
751 |
} catch (UnsupportedType e) { |
|
752 |
e.printStackTrace(); |
|
753 |
|
|
754 |
} |
|
755 |
health.setPing(canPing); |
|
756 |
// TODO: getStatus() should be consulted here when it's implemented |
|
757 |
Status nodeStatus = new Status(); |
|
758 |
nodeStatus.setSuccess(true); |
|
759 |
nodeStatus.setDateChecked(new Date()); |
|
760 |
health.setStatus(nodeStatus); |
|
734 | 761 |
node.setHealth(health); |
762 |
|
|
735 | 763 |
NodeReference identifier = new NodeReference(); |
736 | 764 |
identifier.setValue(nodeId); |
737 | 765 |
node.setIdentifier(identifier); |
... | ... | |
741 | 769 |
|
742 | 770 |
// services: MNAuthorization, MNCore, MNRead, MNReplication, MNStorage |
743 | 771 |
Services services = new Services(); |
772 |
|
|
773 |
Service sMNCore = new Service(); |
|
774 |
sMNCore.setName("MNCore"); |
|
775 |
sMNCore.setVersion(mnCoreServiceVersion); |
|
776 |
sMNCore.setAvailable(mnCoreServiceAvailable); |
|
777 |
|
|
744 | 778 |
Service sMNRead = new Service(); |
745 | 779 |
sMNRead.setName("MNRead"); |
746 | 780 |
sMNRead.setVersion(mnReadServiceVersion); |
747 | 781 |
sMNRead.setAvailable(mnReadServiceAvailable); |
748 | 782 |
|
749 |
Service sMNCore = new Service(); |
|
750 |
sMNCore.setName("MNCore"); |
|
751 |
sMNCore.setVersion(mnCoreServiceVersion); |
|
752 |
sMNCore.setAvailable(mnCoreServiceAvailable); |
|
753 |
|
|
754 | 783 |
Service sMNAuthorization = new Service(); |
755 | 784 |
sMNAuthorization.setName("MNAuthorization"); |
756 | 785 |
sMNAuthorization.setVersion(mnAuthorizationServiceVersion); |
... | ... | |
773 | 802 |
services.addService(sMNReplication); |
774 | 803 |
node.setServices(services); |
775 | 804 |
|
776 |
// TODO: sync info
|
|
805 |
// TODO: Determine the synchronization info without mock values
|
|
777 | 806 |
Synchronization synchronization = new Synchronization(); |
807 |
Schedule schedule = new Schedule(); |
|
808 |
Date now = new Date(); |
|
809 |
schedule.setYear(new SimpleDateFormat("yyyy").format(now)); |
|
810 |
schedule.setMon(new SimpleDateFormat("MM").format(now)); |
|
811 |
schedule.setMday(new SimpleDateFormat("dd").format(now)); |
|
812 |
schedule.setWday(new SimpleDateFormat("dd").format(now)); |
|
813 |
schedule.setHour(new SimpleDateFormat("HH").format(now)); |
|
814 |
schedule.setMin(new SimpleDateFormat("mm").format(now)); |
|
815 |
schedule.setSec(new SimpleDateFormat("ss").format(now)); |
|
816 |
synchronization.setSchedule(schedule); |
|
817 |
synchronization.setLastHarvested(now); |
|
818 |
synchronization.setLastCompleteHarvest(now); |
|
778 | 819 |
node.setSynchronization(synchronization); |
779 | 820 |
node.setSynchronize(false); |
780 | 821 |
node.setType(NodeType.MN); |
Also available in: Unified diff
In MNodeService.getCapabilities(), update the properties to match those in metacat.properties. Flesh out the NodeHealth object, adding NodeState, Ping, and Status information. Flesh out the Synchronization object information, but for now, use mock values. TODO: This should be determined from configuration and on-the-fly information.