http://git-wip-us.apache.org/repos/asf/oodt/blob/a973c531/config/src/main/resources/examples/resmgr/cmd-line-actions.xml ---------------------------------------------------------------------- diff --git a/config/src/main/resources/examples/resmgr/cmd-line-actions.xml b/config/src/main/resources/examples/resmgr/cmd-line-actions.xml new file mode 100755 index 0000000..04919e9 --- /dev/null +++ b/config/src/main/resources/examples/resmgr/cmd-line-actions.xml @@ -0,0 +1,92 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Author: bfoster (Brian Foster) +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> + + <bean id="addNode" + class="org.apache.oodt.cas.resource.cli.action.AddNodeCliAction"> + <property name="description" value="Adds a ResourceNode" /> + </bean> + <bean id="addNodeToQueue" + class="org.apache.oodt.cas.resource.cli.action.AddNodeToQueueCliAction"> + <property name="description" value="Adds a ResourceNode to a Queue" /> + </bean> + <bean id="addQueue" + class="org.apache.oodt.cas.resource.cli.action.AddQueueCliAction"> + <property name="description" value="Adds a queue" /> + </bean> + <bean id="getExecNode" + class="org.apache.oodt.cas.resource.cli.action.GetExecNodeCliAction"> + <property name="description" value="Get execution node for a job" /> + </bean> + <bean id="getJobInfo" + class="org.apache.oodt.cas.resource.cli.action.GetJobInfoCliAction"> + <property name="description" value="Gets information about a job" /> + </bean> + <bean id="getNodeById" + class="org.apache.oodt.cas.resource.cli.action.GetNodeByIdCliAction"> + <property name="description" value="Gets information about a node" /> + </bean> + <bean id="getNodeLoad" + class="org.apache.oodt.cas.resource.cli.action.GetNodeLoadCliAction"> + <property name="description" value="Gets the current job load of a node" /> + </bean> + <bean id="getNodes" + class="org.apache.oodt.cas.resource.cli.action.GetNodesCliAction"> + <property name="description" value="Gets a list of managed nodes" /> + </bean> + <bean id="getNodesInQueue" + class="org.apache.oodt.cas.resource.cli.action.GetNodesInQueueCliAction"> + <property name="description" + value="Gets list of nodes which belong to given queue" /> + </bean> + <bean id="getQueues" + class="org.apache.oodt.cas.resource.cli.action.GetQueuesCliAction"> + <property name="description" value="Gets list of queues" /> + </bean> + <bean id="getQueuesWithNode" + class="org.apache.oodt.cas.resource.cli.action.GetQueuesWithNodeCliAction"> + <property name="description" value="Gets list of queues which contain given node" /> + </bean> + <bean id="kill" class="org.apache.oodt.cas.resource.cli.action.KillCliAction"> + <property name="description" value="Kills a job" /> + </bean> + <bean id="removeNode" + class="org.apache.oodt.cas.resource.cli.action.RemoveNodeCliAction"> + <property name="description" value="Removes given node from managed nodes" /> + </bean> + <bean id="removeNodeFromQueue" + class="org.apache.oodt.cas.resource.cli.action.RemoveNodeFromQueueCliAction"> + <property name="description" value="Removes given node from given queue" /> + </bean> + <bean id="removeQueue" + class="org.apache.oodt.cas.resource.cli.action.RemoveQueueCliAction"> + <property name="description" value="Removes a queue" /> + </bean> + <bean id="setNodeCapacity" + class="org.apache.oodt.cas.resource.cli.action.SetNodeCapacityCliAction"> + <property name="description" value="Changes a nodes capacity" /> + </bean> + <bean id="submitJob" + class="org.apache.oodt.cas.resource.cli.action.SubmitJobCliAction"> + <property name="description" value="Submits a job for execution" /> + </bean> +</beans>
http://git-wip-us.apache.org/repos/asf/oodt/blob/a973c531/config/src/main/resources/examples/resmgr/cmd-line-options.xml ---------------------------------------------------------------------- diff --git a/config/src/main/resources/examples/resmgr/cmd-line-options.xml b/config/src/main/resources/examples/resmgr/cmd-line-options.xml new file mode 100755 index 0000000..a7a1fde --- /dev/null +++ b/config/src/main/resources/examples/resmgr/cmd-line-options.xml @@ -0,0 +1,601 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Author: bfoster (Brian Foster) +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> + + <bean id="url" class="org.apache.oodt.cas.cli.option.AdvancedCmdLineOption"> + <property name="shortOption" value="u" /> + <property name="longOption" value="url" /> + <property name="description" value="Resource Manager URL" /> + <property name="hasArgs" value="true" /> + <property name="argsDescription" value="url" /> + <property name="required" value="true" /> + <property name="handler"> + <bean + class="org.apache.oodt.cas.cli.option.handler.SetJavaPropertiesHandler"> + <property name="propertyNames"> + <list> + <value>org.apache.oodt.cas.resource.url</value> + </list> + </property> + </bean> + </property> + </bean> + + <bean id="operation" class="org.apache.oodt.cas.cli.option.GroupCmdLineOption"> + <property name="shortOption" value="op" /> + <property name="longOption" value="operation" /> + <property name="description" + value="Declare that you wish to present an operation" /> + <property name="hasArgs" value="false" /> + <property name="required" value="true" /> + <property name="subOptions"> + <list> + <bean class="org.apache.oodt.cas.cli.option.GroupSubOption" + p:option-ref="getNodeById" p:required="false" /> + <bean class="org.apache.oodt.cas.cli.option.GroupSubOption" + p:option-ref="getNodes" p:required="false" /> + <bean class="org.apache.oodt.cas.cli.option.GroupSubOption" + p:option-ref="getQueues" p:required="false" /> + <bean class="org.apache.oodt.cas.cli.option.GroupSubOption" + p:option-ref="addNode" p:required="false" /> + <bean class="org.apache.oodt.cas.cli.option.GroupSubOption" + p:option-ref="removeNode" p:required="false" /> + <bean class="org.apache.oodt.cas.cli.option.GroupSubOption" + p:option-ref="setNodeCapacity" p:required="false" /> + <bean class="org.apache.oodt.cas.cli.option.GroupSubOption" + p:option-ref="getExecNode" p:required="false" /> + <bean class="org.apache.oodt.cas.cli.option.GroupSubOption" + p:option-ref="addQueue" p:required="false" /> + <bean class="org.apache.oodt.cas.cli.option.GroupSubOption" + p:option-ref="removeQueue" p:required="false" /> + <bean class="org.apache.oodt.cas.cli.option.GroupSubOption" + p:option-ref="addNodeToQueue" p:required="false" /> + <bean class="org.apache.oodt.cas.cli.option.GroupSubOption" + p:option-ref="getNodesInQueue" p:required="false" /> + <bean class="org.apache.oodt.cas.cli.option.GroupSubOption" + p:option-ref="getQueuesWithNode" p:required="false" /> + <bean class="org.apache.oodt.cas.cli.option.GroupSubOption" + p:option-ref="removeNodeFromQueue" p:required="false" /> + <bean class="org.apache.oodt.cas.cli.option.GroupSubOption" + p:option-ref="getNodeLoad" p:required="false" /> + <bean class="org.apache.oodt.cas.cli.option.GroupSubOption" + p:option-ref="submitJob" p:required="false" /> + <bean class="org.apache.oodt.cas.cli.option.GroupSubOption" + p:option-ref="getJobInfo" p:required="false" /> + <bean class="org.apache.oodt.cas.cli.option.GroupSubOption" + p:option-ref="kill" p:required="false" /> + </list> + </property> + </bean> + + <!-- GetNodeById Options --> + <bean id="getNodeById" class="org.apache.oodt.cas.cli.option.ActionCmdLineOption" + p:isSubOption="true"> + <property name="shortOption" value="nbyid" /> + <property name="longOption" value="getNodeById" /> + <property name="description" value="Triggers getNodeById Action" /> + <property name="hasArgs" value="false" /> + <property name="staticArgs"> + <list> + <value>getNodeById</value> + </list> + </property> + <property name="requirementRules"> + <list> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="getNodeById" p:relation="REQUIRED" /> + </list> + </property> + </bean> + + <!-- GetNodes Options --> + <bean id="getNodes" class="org.apache.oodt.cas.cli.option.ActionCmdLineOption" + p:isSubOption="true"> + <property name="shortOption" value="nodes" /> + <property name="longOption" value="getNodes" /> + <property name="description" value="Triggers getNodes Action" /> + <property name="hasArgs" value="false" /> + <property name="staticArgs"> + <list> + <value>getNodes</value> + </list> + </property> + <property name="requirementRules"> + <list> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="getNodes" p:relation="REQUIRED" /> + </list> + </property> + </bean> + + <!-- GetQueues Options --> + <bean id="getQueues" class="org.apache.oodt.cas.cli.option.ActionCmdLineOption" + p:isSubOption="true"> + <property name="shortOption" value="queues" /> + <property name="longOption" value="getQueues" /> + <property name="description" value="Triggers getQueues Action" /> + <property name="hasArgs" value="false" /> + <property name="staticArgs"> + <list> + <value>getQueues</value> + </list> + </property> + <property name="requirementRules"> + <list> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="getQueues" p:relation="REQUIRED" /> + </list> + </property> + </bean> + + <!-- AddNode Options --> + <bean id="addNode" class="org.apache.oodt.cas.cli.option.ActionCmdLineOption" + p:isSubOption="true"> + <property name="shortOption" value="an" /> + <property name="longOption" value="addNode" /> + <property name="description" value="Triggers addNode Action" /> + <property name="hasArgs" value="false" /> + <property name="staticArgs"> + <list> + <value>addNode</value> + </list> + </property> + <property name="requirementRules"> + <list> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="addNode" p:relation="REQUIRED" /> + </list> + </property> + </bean> + + <bean id="ipAddr" class="org.apache.oodt.cas.cli.option.AdvancedCmdLineOption"> + <property name="shortOption" value="addr" /> + <property name="longOption" value="ipAddr" /> + <property name="description" value="Node IP Address" /> + <property name="type" value="java.net.URL" /> + <property name="hasArgs" value="true" /> + <property name="argsDescription" value="ip-addr" /> + <property name="requirementRules"> + <list> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="addNode" p:relation="REQUIRED" /> + </list> + </property> + <property name="handler"> + <bean class="org.apache.oodt.cas.cli.option.handler.ApplyToActionHandler"> + <property name="applyToActions"> + <list> + <bean class="org.apache.oodt.cas.cli.option.handler.ApplyToAction" + p:actionName="addNode" p:methodName="setNodeUrl" /> + </list> + </property> + </bean> + </property> + </bean> + + <!-- RemoveNode Options --> + <bean id="removeNode" class="org.apache.oodt.cas.cli.option.ActionCmdLineOption" + p:isSubOption="true"> + <property name="shortOption" value="rn" /> + <property name="longOption" value="removeNode" /> + <property name="description" value="Triggers removeNode Action" /> + <property name="hasArgs" value="false" /> + <property name="staticArgs"> + <list> + <value>removeNode</value> + </list> + </property> + <property name="requirementRules"> + <list> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="removeNode" p:relation="REQUIRED" /> + </list> + </property> + </bean> + + <!-- SetNodeCapacity Options --> + <bean id="setNodeCapacity" class="org.apache.oodt.cas.cli.option.ActionCmdLineOption" + p:isSubOption="true"> + <property name="shortOption" value="sncap" /> + <property name="longOption" value="setNodeCapacity" /> + <property name="description" value="Triggers setNodeCapacity Action" /> + <property name="hasArgs" value="false" /> + <property name="staticArgs"> + <list> + <value>setNodeCapacity</value> + </list> + </property> + <property name="requirementRules"> + <list> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="setNodeCapacity" p:relation="REQUIRED" /> + </list> + </property> + </bean> + + <!-- SetNodeCapacity Options --> + <bean id="getExecNode" class="org.apache.oodt.cas.cli.option.ActionCmdLineOption" + p:isSubOption="true"> + <property name="shortOption" value="exeNode" /> + <property name="longOption" value="getExecNode" /> + <property name="description" value="Triggers getExecNode Action" /> + <property name="hasArgs" value="false" /> + <property name="staticArgs"> + <list> + <value>getExecNode</value> + </list> + </property> + <property name="requirementRules"> + <list> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="getExecNode" p:relation="REQUIRED" /> + </list> + </property> + </bean> + + <!-- AddQueue Options --> + <bean id="addQueue" class="org.apache.oodt.cas.cli.option.ActionCmdLineOption" + p:isSubOption="true"> + <property name="shortOption" value="aq" /> + <property name="longOption" value="addQueue" /> + <property name="description" value="Triggers addQueue Action" /> + <property name="hasArgs" value="false" /> + <property name="staticArgs"> + <list> + <value>addQueue</value> + </list> + </property> + <property name="requirementRules"> + <list> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="addQueue" p:relation="REQUIRED" /> + </list> + </property> + </bean> + + <!-- RemoveQueue Options --> + <bean id="removeQueue" class="org.apache.oodt.cas.cli.option.ActionCmdLineOption" + p:isSubOption="true"> + <property name="shortOption" value="rq" /> + <property name="longOption" value="removeQueue" /> + <property name="description" value="Triggers removeQueue Action" /> + <property name="hasArgs" value="false" /> + <property name="staticArgs"> + <list> + <value>removeQueue</value> + </list> + </property> + <property name="requirementRules"> + <list> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="removeQueue" p:relation="REQUIRED" /> + </list> + </property> + </bean> + + <!-- AddNodeToQueue Options --> + <bean id="addNodeToQueue" class="org.apache.oodt.cas.cli.option.ActionCmdLineOption" + p:isSubOption="true"> + <property name="shortOption" value="antq" /> + <property name="longOption" value="addNodeToQueue" /> + <property name="description" value="Triggers addNodeToQueue Action" /> + <property name="hasArgs" value="false" /> + <property name="staticArgs"> + <list> + <value>addNodeToQueue</value> + </list> + </property> + <property name="requirementRules"> + <list> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="addNodeToQueue" p:relation="REQUIRED" /> + </list> + </property> + </bean> + + <!-- GetNodesInQueue Options --> + <bean id="getNodesInQueue" class="org.apache.oodt.cas.cli.option.ActionCmdLineOption" + p:isSubOption="true"> + <property name="shortOption" value="ninq" /> + <property name="longOption" value="getNodesInQueue" /> + <property name="description" value="Triggers getNodesInQueue Action" /> + <property name="hasArgs" value="false" /> + <property name="staticArgs"> + <list> + <value>getNodesInQueue</value> + </list> + </property> + <property name="requirementRules"> + <list> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="getNodesInQueue" p:relation="REQUIRED" /> + </list> + </property> + </bean> + + <!-- GetQueuesWithNode Options --> + <bean id="getQueuesWithNode" class="org.apache.oodt.cas.cli.option.ActionCmdLineOption" + p:isSubOption="true"> + <property name="shortOption" value="qwn" /> + <property name="longOption" value="getQueuesWithNode" /> + <property name="description" value="Triggers getQueuesWithNode Action" /> + <property name="hasArgs" value="false" /> + <property name="staticArgs"> + <list> + <value>getQueuesWithNode</value> + </list> + </property> + <property name="requirementRules"> + <list> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="getQueuesWithNode" p:relation="REQUIRED" /> + </list> + </property> + </bean> + + <!-- RemoveNodeFromQueue Options --> + <bean id="removeNodeFromQueue" class="org.apache.oodt.cas.cli.option.ActionCmdLineOption" + p:isSubOption="true"> + <property name="shortOption" value="rnfq" /> + <property name="longOption" value="removeNodeFromQueue" /> + <property name="description" value="Triggers removeNodeFromQueue Action" /> + <property name="hasArgs" value="false" /> + <property name="staticArgs"> + <list> + <value>removeNodeFromQueue</value> + </list> + </property> + <property name="requirementRules"> + <list> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="removeNodeFromQueue" p:relation="REQUIRED" /> + </list> + </property> + </bean> + + <!-- GetNodeLoad Options --> + <bean id="getNodeLoad" class="org.apache.oodt.cas.cli.option.ActionCmdLineOption" + p:isSubOption="true"> + <property name="shortOption" value="load" /> + <property name="longOption" value="getNodeLoad" /> + <property name="description" value="Triggers getNodeLoad Action" /> + <property name="hasArgs" value="false" /> + <property name="staticArgs"> + <list> + <value>getNodeLoad</value> + </list> + </property> + <property name="requirementRules"> + <list> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="getNodeLoad" p:relation="REQUIRED" /> + </list> + </property> + </bean> + + <!-- SubmitJob Options --> + <bean id="submitJob" class="org.apache.oodt.cas.cli.option.ActionCmdLineOption" + p:isSubOption="true"> + <property name="shortOption" value="submit" /> + <property name="longOption" value="submitJob" /> + <property name="description" value="Triggers submitJob Action" /> + <property name="hasArgs" value="false" /> + <property name="staticArgs"> + <list> + <value>submitJob</value> + </list> + </property> + <property name="requirementRules"> + <list> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="submitJob" p:relation="REQUIRED" /> + </list> + </property> + </bean> + + <bean id="def" class="org.apache.oodt.cas.cli.option.AdvancedCmdLineOption"> + <property name="shortOption" value="d" /> + <property name="longOption" value="def" /> + <property name="description" value="Job Definition File" /> + <property name="hasArgs" value="true" /> + <property name="argsDescription" value="xml-file" /> + <property name="requirementRules"> + <list> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="submitJob" p:relation="REQUIRED" /> + </list> + </property> + <property name="handler"> + <bean class="org.apache.oodt.cas.cli.option.handler.ApplyToActionHandler"> + <property name="applyToActions"> + <list> + <bean class="org.apache.oodt.cas.cli.option.handler.ApplyToAction" + p:actionName="submitJob" p:methodName="setJobDefinitionFile" /> + </list> + </property> + </bean> + </property> + </bean> + + <bean id="nodeUrl" class="org.apache.oodt.cas.cli.option.AdvancedCmdLineOption"> + <property name="shortOption" value="nu" /> + <property name="longOption" value="nodeUrl" /> + <property name="description" value="Node URL" /> + <property name="type" value="java.net.URL" /> + <property name="hasArgs" value="true" /> + <property name="argsDescription" value="url" /> + <property name="requirementRules"> + <list> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="submitJob" p:relation="OPTIONAL" /> + </list> + </property> + <property name="handler"> + <bean class="org.apache.oodt.cas.cli.option.handler.ApplyToActionHandler"> + <property name="applyToActions"> + <list> + <bean class="org.apache.oodt.cas.cli.option.handler.ApplyToAction" + p:actionName="submitJob" p:methodName="setUrl" /> + </list> + </property> + </bean> + </property> + </bean> + + <!-- GetJobInfo Options --> + <bean id="getJobInfo" class="org.apache.oodt.cas.cli.option.ActionCmdLineOption" + p:isSubOption="true"> + <property name="shortOption" value="info" /> + <property name="longOption" value="getJobInfo" /> + <property name="description" value="Triggers getJobInfo Action" /> + <property name="hasArgs" value="false" /> + <property name="staticArgs"> + <list> + <value>getJobInfo</value> + </list> + </property> + <property name="requirementRules"> + <list> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="getJobInfo" p:relation="REQUIRED" /> + </list> + </property> + </bean> + + <!-- Kill Options --> + <bean id="kill" class="org.apache.oodt.cas.cli.option.ActionCmdLineOption" + p:isSubOption="true"> + <property name="shortOption" value="k" /> + <property name="longOption" value="kill" /> + <property name="description" value="Triggers kill Action" /> + <property name="hasArgs" value="false" /> + <property name="staticArgs"> + <list> + <value>kill</value> + </list> + </property> + <property name="requirementRules"> + <list> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="kill" p:relation="REQUIRED" /> + </list> + </property> + </bean> + + <!-- Options used for multiple Actions --> + <bean id="nodeId" class="org.apache.oodt.cas.cli.option.AdvancedCmdLineOption"> + <property name="shortOption" value="nid" /> + <property name="longOption" value="nodeId" /> + <property name="description" value="Node ID" /> + <property name="hasArgs" value="true" /> + <property name="argsDescription" value="node-id" /> + <property name="requirementRules"> + <list> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="getNodeById" p:relation="REQUIRED" /> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="addNode" p:relation="REQUIRED" /> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="removeNode" p:relation="REQUIRED" /> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="setNodeCapacity" p:relation="REQUIRED" /> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="addNodeToQueue" p:relation="REQUIRED" /> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="getQueuesWithNode" p:relation="REQUIRED" /> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="removeNodeFromQueue" p:relation="REQUIRED" /> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="getNodeLoad" p:relation="REQUIRED" /> + </list> + </property> + <property name="handler"> + <bean class="org.apache.oodt.cas.cli.option.handler.ApplyToActionHandler" /> + </property> + </bean> + + <bean id="capacity" class="org.apache.oodt.cas.cli.option.AdvancedCmdLineOption"> + <property name="shortOption" value="cap" /> + <property name="longOption" value="capacity" /> + <property name="description" value="Node Capacity" /> + <property name="type" value="int" /> + <property name="hasArgs" value="true" /> + <property name="argsDescription" value="capacity" /> + <property name="requirementRules"> + <list> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="addNode" p:relation="REQUIRED" /> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="setNodeCapacity" p:relation="REQUIRED" /> + </list> + </property> + <property name="handler"> + <bean class="org.apache.oodt.cas.cli.option.handler.ApplyToActionHandler" /> + </property> + </bean> + + <bean id="queueName" class="org.apache.oodt.cas.cli.option.AdvancedCmdLineOption"> + <property name="shortOption" value="qn" /> + <property name="longOption" value="queueName" /> + <property name="description" value="Queue name" /> + <property name="hasArgs" value="true" /> + <property name="argsDescription" value="queue-name" /> + <property name="requirementRules"> + <list> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="addQueue" p:relation="REQUIRED" /> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="removeQueue" p:relation="REQUIRED" /> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="addNodeToQueue" p:relation="REQUIRED" /> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="getNodesInQueue" p:relation="REQUIRED" /> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="removeNodeFromQueue" p:relation="REQUIRED" /> + </list> + </property> + <property name="handler"> + <bean class="org.apache.oodt.cas.cli.option.handler.ApplyToActionHandler" /> + </property> + </bean> + + <bean id="jobId" class="org.apache.oodt.cas.cli.option.AdvancedCmdLineOption"> + <property name="shortOption" value="jid" /> + <property name="longOption" value="jobId" /> + <property name="description" value="Job ID" /> + <property name="hasArgs" value="true" /> + <property name="argsDescription" value="job-id" /> + <property name="requirementRules"> + <list> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="getJobInfo" p:relation="REQUIRED" /> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="getExecNode" p:relation="REQUIRED" /> + <bean class="org.apache.oodt.cas.cli.option.require.ActionDependencyRule" + p:actionName="kill" p:relation="REQUIRED" /> + </list> + </property> + <property name="handler"> + <bean class="org.apache.oodt.cas.cli.option.handler.ApplyToActionHandler" /> + </property> + </bean> +</beans> http://git-wip-us.apache.org/repos/asf/oodt/blob/a973c531/config/src/main/resources/examples/resmgr/jobs/exJob.xml ---------------------------------------------------------------------- diff --git a/config/src/main/resources/examples/resmgr/jobs/exJob.xml b/config/src/main/resources/examples/resmgr/jobs/exJob.xml new file mode 100755 index 0000000..bbe0def --- /dev/null +++ b/config/src/main/resources/examples/resmgr/jobs/exJob.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<cas:job xmlns:cas="http://oodt.jpl.nasa.gov/1.0/cas" id="abcd" + name="TestJob"> + <instanceClass + name="org.apache.oodt.cas.resource.examples.HelloWorldJob" /> + <inputClass + name="org.apache.oodt.cas.resource.structs.NameValueJobInput"> + <properties> + <property name="user.name" value="Homer!" /> + </properties> + </inputClass> + <queue>quick</queue> + <load>1</load> +</cas:job> http://git-wip-us.apache.org/repos/asf/oodt/blob/a973c531/config/src/main/resources/examples/resmgr/jobs/exLongJob.xml ---------------------------------------------------------------------- diff --git a/config/src/main/resources/examples/resmgr/jobs/exLongJob.xml b/config/src/main/resources/examples/resmgr/jobs/exLongJob.xml new file mode 100755 index 0000000..3cbeb29 --- /dev/null +++ b/config/src/main/resources/examples/resmgr/jobs/exLongJob.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<cas:job xmlns:cas="http://oodt.jpl.nasa.gov/1.0/cas" id="abcd" + name="TestJob"> + <instanceClass + name="org.apache.oodt.cas.resource.examples.LongJob" /> + <inputClass + name="org.apache.oodt.cas.resource.structs.NameValueJobInput"> + <properties> + <property name="wait" value="60" /> + </properties> + </inputClass> + <queue>quick</queue> + <load>1</load> +</cas:job> http://git-wip-us.apache.org/repos/asf/oodt/blob/a973c531/config/src/main/resources/examples/resmgr/logging.properties ---------------------------------------------------------------------- diff --git a/config/src/main/resources/examples/resmgr/logging.properties b/config/src/main/resources/examples/resmgr/logging.properties new file mode 100755 index 0000000..8785c8b --- /dev/null +++ b/config/src/main/resources/examples/resmgr/logging.properties @@ -0,0 +1,67 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE.txt file distributed with +# this work for additional information regarding copyright ownership. The ASF +# licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# + +# Specify the handlers to create in the root logger +# (all loggers are children of the root logger) +# The following creates two handlers +handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler + +# Set the default logging level for the root logger +.level = ALL + +# Set the default logging level for new ConsoleHandler instances +java.util.logging.ConsoleHandler.level = ALL +java.util.logging.FileHandler.level = ALL + +# Set the default formatter for new ConsoleHandler instances +java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter + +# default file output is in user's home directory. +java.util.logging.FileHandler.pattern = ../logs/cas_resource%g.log +java.util.logging.FileHandler.limit = 50000 +java.util.logging.FileHandler.count = 5 +java.util.logging.FileHandler.append = true +java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter + +# Set the default logging level for the subsystems + +# batchmgr subsystem +org.apache.oodt.cas.resource.batchmgr.level = INFO + +# monitor subsystem +org.apache.oodt.cas.resource.monitor.level = INFO + +# jobqueue subsystem +org.apache.oodt.cas.resource.jobqueue.level = INFO + +# scheduler subsystem +org.apache.oodt.cas.resource.scheduler.level = INFO + +# system subsystem +org.apache.oodt.cas.resource.system.level = FINE + +# control the underlying commons-httpclient transport layer for xmlrpc +org.apache.commons.httpclient.level = INFO +httpclient.wire.header.level = INFO +httpclient.wire.level = INFO + +# spring framework logging +org.springframework.beans.level = SEVERE +org.springframework.core.level = SEVERE +org.springframework.level = SEVERE +org.springframework.beans.factory.level = SEVERE +org.springframework.beans.factory.config.level = SEVERE +org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.level = SEVERE http://git-wip-us.apache.org/repos/asf/oodt/blob/a973c531/config/src/main/resources/examples/resmgr/node-to-queue-mapping.xml ---------------------------------------------------------------------- diff --git a/config/src/main/resources/examples/resmgr/node-to-queue-mapping.xml b/config/src/main/resources/examples/resmgr/node-to-queue-mapping.xml new file mode 100755 index 0000000..73b0eba --- /dev/null +++ b/config/src/main/resources/examples/resmgr/node-to-queue-mapping.xml @@ -0,0 +1,26 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- +Licensed to the Apache Software Foundation (ASF) under one or more contributor +license agreements. See the NOTICE.txt file distributed with this work for +additional information regarding copyright ownership. The ASF licenses this +file to you under the Apache License, Version 2.0 (the "License"); you may not +use this file except in compliance with the License. You may obtain a copy of +the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations under +the License. +--> +<cas:node-to-queue-mapping xmlns:cas="http://oodt.jpl.nasa.gov/1.0/cas"> + <node id="localhost"> + <queues> + <queue name="high"/> + <queue name="quick"/> + <queue name="long"/> + </queues> + </node> +</cas:node-to-queue-mapping> http://git-wip-us.apache.org/repos/asf/oodt/blob/a973c531/config/src/main/resources/examples/resmgr/nodes.xml ---------------------------------------------------------------------- diff --git a/config/src/main/resources/examples/resmgr/nodes.xml b/config/src/main/resources/examples/resmgr/nodes.xml new file mode 100755 index 0000000..d3d415d --- /dev/null +++ b/config/src/main/resources/examples/resmgr/nodes.xml @@ -0,0 +1,23 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- +Licensed to the Apache Software Foundation (ASF) under one or more contributor +license agreements. See the NOTICE.txt file distributed with this work for +additional information regarding copyright ownership. The ASF licenses this +file to you under the Apache License, Version 2.0 (the "License"); you may not +use this file except in compliance with the License. You may obtain a copy of +the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations under +the License. +--> +<cas:resourcenodes xmlns:cas="http://oodt.jpl.nasa.gov/1.0/cas"> + <node nodeId="localhost" ip="http://localhost:2001" capacity="8"/> + <!-- EnvReplace Example + <node nodeId="somehost" ip="http://somehost:[BATCH_STUB_PORT]" capacity="8" envReplace="true"/> + --> +</cas:resourcenodes> http://git-wip-us.apache.org/repos/asf/oodt/blob/a973c531/config/src/main/resources/examples/resmgr/resource.properties ---------------------------------------------------------------------- diff --git a/config/src/main/resources/examples/resmgr/resource.properties b/config/src/main/resources/examples/resmgr/resource.properties new file mode 100755 index 0000000..5520c7b --- /dev/null +++ b/config/src/main/resources/examples/resmgr/resource.properties @@ -0,0 +1,61 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE.txt file distributed with +# this work for additional information regarding copyright ownership. The ASF +# licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# +# Properties required to configure the Resource Manager + +# resource batchmgr factory +resource.batchmgr.factory = org.apache.oodt.cas.resource.batchmgr.XmlRpcBatchMgrFactory + +# resource monitor factory +resource.monitor.factory = org.apache.oodt.cas.resource.monitor.AssignmentMonitorFactory + +# resource scheduler factory +resource.scheduler.factory = org.apache.oodt.cas.resource.scheduler.LRUSchedulerFactory + +# resource jobqueue factory +resource.jobqueue.factory = org.apache.oodt.cas.resource.jobqueue.JobStackJobQueueFactory + +# resource job repository factory +resource.jobrepo.factory = org.apache.oodt.cas.resource.jobrepo.MemoryJobRepositoryFactory + +# node repository factory +org.apache.oodt.cas.resource.nodes.repo.factory = org.apache.oodt.cas.resource.noderepo.XmlNodeRepositoryFactory + +# queue repository factory +org.apache.oodt.cas.resource.queues.repo.factory = org.apache.oodt.cas.resource.queuerepo.XmlQueueRepositoryFactory + +# JobStack JobQueue config properties +org.apache.oodt.cas.resource.jobqueue.jobstack.maxstacksize=1000 + +# XML LRUScheduler config properties +org.apache.oodt.cas.resource.scheduler.wait.seconds=20 + +# XML-RPC configuration props +org.apache.oodt.cas.resource.system.xmlrpc.requestTimeout.minutes=20 +org.apache.oodt.cas.resource.system.xmlrpc.connectionTimeout.minutes=60 + +# XStream JobRepo configuration props +org.apache.oodt.cas.resource.jobrepo.xstream.working.dir=[HOME]/job-repo +org.apache.oodt.cas.resource.jobrepo.xstream.max.history=4000 + +# XML Node Repository config properties +org.apache.oodt.cas.resource.nodes.dirs=file://[RESMGR_HOME]/policy + +# XML Queue Repository config properties +org.apache.oodt.cas.resource.nodetoqueues.dirs=file://[RESMGR_HOME]/policy + + + http://git-wip-us.apache.org/repos/asf/oodt/blob/a973c531/config/src/test/java/org/apache/oodt/config/distributed/AbstractTestCase.java ---------------------------------------------------------------------- diff --git a/config/src/test/java/org/apache/oodt/config/distributed/AbstractTestCase.java b/config/src/test/java/org/apache/oodt/config/distributed/AbstractTestCase.java new file mode 100644 index 0000000..5bd0651 --- /dev/null +++ b/config/src/test/java/org/apache/oodt/config/distributed/AbstractTestCase.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.oodt.config.distributed; + +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.test.TestingServer; +import org.apache.oodt.config.distributed.utils.CuratorUtils; +import org.junit.AfterClass; +import org.junit.BeforeClass; + +import static org.apache.oodt.config.Constants.Properties.ZK_CONNECT_STRING; + +public abstract class AbstractTestCase { + + protected static TestingServer zookeeper; + protected static CuratorFramework client; + + @BeforeClass + public static void setUp() throws Exception { + zookeeper = new TestingServer(); + zookeeper.start(); + + System.setProperty(ZK_CONNECT_STRING, zookeeper.getConnectString()); + + client = CuratorUtils.newCuratorFrameworkClient(zookeeper.getConnectString()); + client.start(); + } + + @AfterClass + public static void tearDown() throws Exception { + client.close(); + zookeeper.stop(); + } +} http://git-wip-us.apache.org/repos/asf/oodt/blob/a973c531/config/src/test/java/org/apache/oodt/config/distributed/DistributedConfigurationManagerTest.java ---------------------------------------------------------------------- diff --git a/config/src/test/java/org/apache/oodt/config/distributed/DistributedConfigurationManagerTest.java b/config/src/test/java/org/apache/oodt/config/distributed/DistributedConfigurationManagerTest.java new file mode 100644 index 0000000..5a75ff6 --- /dev/null +++ b/config/src/test/java/org/apache/oodt/config/distributed/DistributedConfigurationManagerTest.java @@ -0,0 +1,122 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.oodt.config.distributed; + +import org.apache.commons.io.FileUtils; +import org.apache.oodt.config.ConfigurationManager; +import org.apache.oodt.config.distributed.cli.DistributedConfigurationPublisher; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import static org.apache.oodt.config.Constants.CONFIG_PUBLISHER_XML; +import static org.apache.oodt.config.Constants.SEPARATOR; + +/** + * Testing the {@link DistributedConfigurationManager} whether it is downloading and storing the configuration correctly + * in local files + * + * @author Imesha Sudasingha + */ +public class DistributedConfigurationManagerTest extends AbstractTestCase { + + private static List<DistributedConfigurationPublisher> publishers; + + @BeforeClass + public static void setUp() throws Exception { + AbstractTestCase.setUp(); + + DistributedConfigurationPublisher.main(new String[]{ + "-connectString", zookeeper.getConnectString(), + "-publish" + }); + + ApplicationContext applicationContext = new ClassPathXmlApplicationContext(CONFIG_PUBLISHER_XML); + Map distributedConfigurationPublishers = applicationContext.getBeansOfType(DistributedConfigurationPublisher.class); + + publishers = new ArrayList<>(distributedConfigurationPublishers.values().size()); + for (Object bean : distributedConfigurationPublishers.values()) { + DistributedConfigurationPublisher publisher = (DistributedConfigurationPublisher) bean; + publishers.add(publisher); + ConfigurationManager configurationManager = new DistributedConfigurationManager(publisher.getComponentName()); + configurationManager.loadConfiguration(); + } + } + + @Test + public void loadConfigurationTest() throws Exception { + for (DistributedConfigurationPublisher publisher : publishers) { + ConfigurationManager configurationManager = new DistributedConfigurationManager(publisher.getComponentName()); + configurationManager.loadConfiguration(); + + // Checking for configuration files + for (Map.Entry<String, String> entry : publisher.getPropertiesFiles().entrySet()) { + File file = new File(entry.getKey()); + Properties properties = new Properties(); + try (InputStream in = new FileInputStream(file)) { + properties.load(in); + } + + for (String key : properties.stringPropertyNames()) { + Assert.assertEquals(properties.getProperty(key), System.getProperty(key)); + } + } + + // Checking for configuration files + for (Map.Entry<String, String> entry : publisher.getConfigFiles().entrySet()) { + String fileName = entry.getValue(); + fileName = fileName.startsWith(SEPARATOR) ? fileName.substring(1) : fileName; + File file = new File(fileName); + Assert.assertTrue(file.exists()); + } + } + } + + @AfterClass + public static void tearDown() throws Exception { + for (DistributedConfigurationPublisher publisher : publishers) { + publisher.destroy(); + + for (Map.Entry<String, String> entry : publisher.getConfigFiles().entrySet()) { + String fileName = entry.getValue(); + fileName = fileName.startsWith(SEPARATOR) ? fileName.substring(1) : fileName; + String confDir = fileName.split(SEPARATOR)[0]; + File dir = new File(confDir); + FileUtils.deleteDirectory(dir); + } + } + + DistributedConfigurationPublisher.main(new String[]{ + "-connectString", zookeeper.getConnectString(), + "-clear" + }); + + AbstractTestCase.tearDown(); + } +} http://git-wip-us.apache.org/repos/asf/oodt/blob/a973c531/config/src/test/java/org/apache/oodt/config/distributed/DistributedConfigurationPublisherTest.java ---------------------------------------------------------------------- diff --git a/config/src/test/java/org/apache/oodt/config/distributed/DistributedConfigurationPublisherTest.java b/config/src/test/java/org/apache/oodt/config/distributed/DistributedConfigurationPublisherTest.java index 21aef23..fbccbc7 100644 --- a/config/src/test/java/org/apache/oodt/config/distributed/DistributedConfigurationPublisherTest.java +++ b/config/src/test/java/org/apache/oodt/config/distributed/DistributedConfigurationPublisherTest.java @@ -17,59 +17,96 @@ package org.apache.oodt.config.distributed; -import org.apache.curator.framework.CuratorFramework; -import org.apache.curator.framework.CuratorFrameworkFactory; -import org.apache.curator.retry.RetryNTimes; -import org.apache.curator.test.TestingServer; +import org.apache.commons.io.FileUtils; import org.apache.oodt.config.distributed.cli.DistributedConfigurationPublisher; -import org.junit.AfterClass; import org.junit.Assert; -import org.junit.BeforeClass; import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; -import java.io.IOException; +import java.io.File; +import java.util.ArrayList; +import java.util.List; import java.util.Map; -public class DistributedConfigurationPublisherTest { +import static org.apache.oodt.config.Constants.CONFIG_PUBLISHER_XML; - private static final String DISTRIBUTED_CONFIG_PUBLISHER_SPRING_CONFIG = "etc/config-publisher.xml"; - - private static TestingServer zookeeper; - private static CuratorFramework client; - - @BeforeClass - public static void setUp() throws Exception { - zookeeper = new TestingServer(); - zookeeper.start(); - - client = CuratorFrameworkFactory.builder() - .connectString(zookeeper.getConnectString()) - .retryPolicy(new RetryNTimes(3, 1000)) - .build(); - client.start(); - } +/** + * Testing the functionality of {@link DistributedConfigurationPublisher} and its CLI + * + * @author Imesha Sudasingha + */ +public class DistributedConfigurationPublisherTest extends AbstractTestCase{ @Test public void publishConfigurationTest() throws Exception { + // Publishing configuration through CLI and verifying whether they were stored correctly DistributedConfigurationPublisher.main(new String[]{ "-connectString", zookeeper.getConnectString(), - "-publish" + "-publish", + "-verify" }); - ApplicationContext applicationContext = new ClassPathXmlApplicationContext(DISTRIBUTED_CONFIG_PUBLISHER_SPRING_CONFIG); + ApplicationContext applicationContext = new ClassPathXmlApplicationContext(CONFIG_PUBLISHER_XML); Map distributedConfigurationPublishers = applicationContext.getBeansOfType(DistributedConfigurationPublisher.class); + List<DistributedConfigurationPublisher> publishers = new ArrayList<>(distributedConfigurationPublishers.values().size()); for (Object bean : distributedConfigurationPublishers.values()) { - DistributedConfigurationPublisher publisher = (DistributedConfigurationPublisher) bean; + publishers.add((DistributedConfigurationPublisher) bean); + } + + for (DistributedConfigurationPublisher publisher : publishers) { Assert.assertTrue(publisher.verifyPublishedConfiguration()); + + ZNodePaths zNodePaths = publisher.getZNodePaths(); + + // Checking for configuration files + for (Map.Entry<String, String> entry : publisher.getPropertiesFiles().entrySet()) { + String zNodePath = zNodePaths.getPropertiesZNodePath(entry.getValue()); + Assert.assertNotNull(client.checkExists().forPath(zNodePath)); + + String storedContent = new String(client.getData().forPath(zNodePath)); + String fileContent = FileUtils.readFileToString(new File(entry.getKey())); + Assert.assertEquals(fileContent, storedContent); + } + + // Checking for configuration files + for (Map.Entry<String, String> entry : publisher.getConfigFiles().entrySet()) { + String zNodePath = zNodePaths.getConfigurationZNodePath(entry.getValue()); + Assert.assertNotNull(client.checkExists().forPath(zNodePath)); + + String storedContent = new String(client.getData().forPath(zNodePath)); + String fileContent = FileUtils.readFileToString(new File(entry.getKey())); + Assert.assertEquals(fileContent, storedContent); + } } - } - @AfterClass - public static void tearDown() throws IOException { - client.close(); - zookeeper.stop(); + // Clearing configuration through CLI and checking whether the configuration has actually been gone + DistributedConfigurationPublisher.main(new String[]{ + "-connectString", zookeeper.getConnectString(), + "-clear" + }); + + for (DistributedConfigurationPublisher publisher : publishers) { + Assert.assertFalse(publisher.verifyPublishedConfiguration()); + + ZNodePaths zNodePaths = publisher.getZNodePaths(); + + // Checking for configuration files + for (Map.Entry<String, String> entry : publisher.getPropertiesFiles().entrySet()) { + String zNodePath = zNodePaths.getPropertiesZNodePath(entry.getValue()); + Assert.assertNull(client.checkExists().forPath(zNodePath)); + } + + // Checking for configuration files + for (Map.Entry<String, String> entry : publisher.getConfigFiles().entrySet()) { + String zNodePath = zNodePaths.getConfigurationZNodePath(entry.getValue()); + Assert.assertNull(client.checkExists().forPath(zNodePath)); + } + } + + for (DistributedConfigurationPublisher publisher : publishers) { + publisher.destroy(); + } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/oodt/blob/a973c531/config/src/test/resources/etc/config-publisher.xml ---------------------------------------------------------------------- diff --git a/config/src/test/resources/etc/config-publisher.xml b/config/src/test/resources/etc/config-publisher.xml index 109f48f..f779f14 100644 --- a/config/src/test/resources/etc/config-publisher.xml +++ b/config/src/test/resources/etc/config-publisher.xml @@ -23,12 +23,17 @@ <constructor-arg value="filemgr"/> <property name="propertiesFiles"> <map key-type="java.lang.String" value-type="java.lang.String"> - <entry key="src/main/resources/examples/filemgr.properties" value="/etc/filemgr.properties"/> + <entry key="src/main/resources/examples/filemgr/filemgr.properties" value="/etc/filemgr.properties"/> </map> </property> <property name="configFiles"> <map key-type="java.lang.String" value-type="java.lang.String"> - <entry key="src/main/resources/examples/mime-types.xml" value="/etc/mime-types.xml"/> + <entry key="src/main/resources/examples/filemgr/mime-types.xml" value="/etc/mime-types.xml"/> + <entry key="src/main/resources/examples/filemgr/cmd-line-actions.xml" value="/policy/cmd-line-actions.xml"/> + <entry key="src/main/resources/examples/filemgr/cmd-line-options.xml" value="/policy/cmd-line-options.xml"/> + <entry key="src/main/resources/examples/filemgr/oodt/elements.xml" value="/policy/oodt/elements.xml"/> + <entry key="src/main/resources/examples/filemgr/oodt/product-types.xml" value="/policy/oodt/product-types.xml"/> + <entry key="src/main/resources/examples/filemgr/oodt/product-type-element-map.xml" value="/policy/oodt/product-type-element-map.xml"/> </map> </property> </bean> @@ -37,12 +42,18 @@ <constructor-arg value="resmgr"/> <property name="propertiesFiles"> <map key-type="java.lang.String" value-type="java.lang.String"> - <entry key="src/main/resources/examples/filemgr.properties" value="/etc/resmgr.properties"/> + <entry key="src/main/resources/examples/resmgr/resource.properties" value="/etc/resource.properties"/> + <entry key="src/main/resources/examples/resmgr/logging.properties" value="/etc/logging.properties"/> </map> </property> <property name="configFiles"> <map key-type="java.lang.String" value-type="java.lang.String"> - <entry key="src/main/resources/examples/mime-types.xml" value="/etc/mime-types.xml"/> + <entry key="src/main/resources/examples/resmgr/cmd-line-actions.xml" value="/policy/cmd-line-actions.xml"/> + <entry key="src/main/resources/examples/resmgr/cmd-line-options.xml" value="/policy/cmd-line-options.xml"/> + <entry key="src/main/resources/examples/resmgr/nodes.xml" value="/policy/nodes.xml"/> + <entry key="src/main/resources/examples/resmgr/node-to-queue-mapping.xml" value="/policy/node-to-queue-mapping.xml"/> + <entry key="src/main/resources/examples/resmgr/jobs/exJob.xml" value="/policy/jobs/exJob.xml"/> + <entry key="src/main/resources/examples/resmgr/jobs/exLongJob.xml" value="/policy/jobs/exLongJob.xml"/> </map> </property> </bean>