1 起動タスクを実行するための自動実行の使用
この章の内容は次のとおりです。
自動実行の理解
起動時に自動的に次のことを実行するようにEDQを構成できます。
-
アプリケーション・サーバーの起動時に、ある範囲のタスクを実行できます。処理を構成する各タスクは、アプリケーション・サーバーが起動するたびに、またはアプリケーション・サーバーが次に実行するときに1度のみ実行するように構成することができます。
-
EDQサーバーに保存されたパージ設定を上書きするパージ・ルールをロードおよび適用します。
自動実行処理を使用するには、XMLで記述された、タスクを指定する自動実行スクリプトを、EDQインストールの2つの特定のディレクトリのいずれかに配置します。
-
startup
ディレクトリ:startup
ディレクトリのスクリプトは、EDQアプリケーション・サーバーが起動するたびに処理されます。 -
onceonly
ディレクトリ:onceonly
ディレクトリのスクリプトは、EDQアプリケーション・サーバーが次に起動するときに処理され、その後、onceonly
内のcomplete
サブディレクトリに移動されます。complete
ディレクトリ内のスクリプトは、以降の起動時には処理されません。
アプリケーション・サーバーが起動するときに、EDQはonceonly
およびstartup
ディレクトリで自動実行スクリプトをチェックし、存在するものを処理します。
startup
およびonceonly
ディレクトリは、アプリケーション・サーバーのローカル構成ディレクトリoedq.local.home
のEDQ autorun
ディレクトリにあります。
自動実行処理の使用
様々な種類の自動実行処理がEDQでは可能で、それぞれにはその機能に特有のXML属性のセットが含まれます。処理タイプとその属性は自動実行ファイルXMLスキーマで定義されます(「処理とルール・スキーマについて」を参照)。利用可能な処理を次の表にリストします。
処理タイプ | 処理の実行内容 |
---|---|
|
Webサーバーからファイルをダウンロードします。 |
|
プロジェクトを |
|
パージ・ルール構成ファイルなどのファイルをロードします。この処理は、 |
|
ディレクタから既存のジョブを実行します。この処理で指定された実行プロファイルの実行ラベルは無視されます。( |
|
EDQサーバー・コンソールから既存のジョブを実行し、実行ラベルを実行プロファイルに設定するか、または |
|
ディレクタ・データベースに対してデータベース・スクリプトを実行します。このような処理は、最大の注意を払って使用する必要があります。スクリプトが不適切に適用されると基礎となるデータベースが破損する可能性があるからです。 |
|
続行する前に指定した間隔待機します。 |
自動実行スクリプトの使用
自動実行スクリプトはXMLコードを含むファイルです。自動実行スクリプトの主な部分は、それぞれの処理が<chores>
タグで囲まれた、処理のリストから構成されます。個別の処理は「自動実行処理の使用」にリストされている自動実行処理タイプの1つに当たり、実行する処理を指定する属性のセットを含んでいます。使用可能な属性は選択した処理タイプによって異なります。
自動実行スクリプトを構築するのに使用されるXMLスキーマは、「処理とルール・スキーマについて」に完全な形で示されています。
例
この項では、自動実行スクリプトの例をいくつか示します。
- 例1
-
次のXMLコードは、EDQに次のことを指示する自動実行スクリプトの例を示します。
-
23People.dxi
ファイルをダウンロードし、同じ名前で既存のファイルを上書きします。 -
23People
プロジェクトを23People.dxi
ファイルからインポートし、同じ名前で既存のプロジェクトを上書きします。 -
rp1
実行プロファイルで、23People Excel.23People
ジョブを実行します。これはrunopsjob
処理ではないので、プロファイルに指定した実行ラベルは無視されます。
<?xml version="1.0" encoding="UTF-8"?> <chores version="1"> <!-- Get the dxi file --> <httpget overwrite="true" todir="dxiland" tofile="23People.dxi"> <url>http://svn/repos/dev/trunk/benchmark/ benchmark/dxis/23People.dxi</url> </httpget> <!-- Import the project from the dxi --> <package direction="in" dir="dxiland" file="23People.dxi" overwrite="true"> <node type="project" name="23People"/> </package> <!-- Run the jobs --> <runjob project="23People" job="23People Excel.23People" runprofile="rp1" waitforcompletion="true"/> </chores>
-
- 例2
-
次のXMLコードは、
runjob
またはrunopsjob
処理を使用してジョブを実行する4つの方法を示す自動実行スクリプトの例を示します。<?xml version="1.0" encoding="UTF-8"?> <chores version="1"> <!-- runs a director job with no runlabel --> <runjob project="merge" job="tester" waitforlocks="false" waitforcompletion="false" runprofile="x"/> <!-- runs an ops job with the runlabel from the runprofile --> <runopsjob project="merge" job="tester" waitforlocks="false" waitforcompletion="false" runprofile="x" /> <!-- runs an ops job with the runlabel from the runlabel attribute--> <runopsjob project="merge" job="tester" waitforlocks="false" waitforcompletion="false" runprofile="x" runlabel="chooseme" /> <!-- runs an ops job with the runlabel from the runlabel attribute--> <runopsjob project="merge" job="tester" waitforlocks="false" waitforcompletion="false" runlabel="onlychoice" /> </chores>
- 例3
-
次のXMLコードは、load処理を使用してパージ・ルールをロードする方法を示します。
<?xml version="1.0" encoding="UTF-8" ?> <chores version="1"> <load file="purgerules.xml" dir="autorun" type="purgeRules" /> </chores>
次に、処理仕様にロードされた
purgerules.xml
ファイル内のパージ・ルールを示します。<?xml version="1.0" encoding="UTF-8" ?> - <rules> - <rule displayName="testa" enabled="true"> <purgePeriod period="1" unit="HOURS" /> <project>aa</project> <job>12345</job> <runlabelMatcher regex="false" runlabel="ABCD" /> </rule> - <rule displayName="testb" enabled="true"> <purgePeriod period="1" unit="HOURS" /> <project>aa</project> <job>ABCD</job> <runlabelMatcher regex="true" runlabel="^\d{5}$" /> </rule> - <rule displayName="testc" enabled="true"> <purgePeriod period="2" unit="HOURS" /> <project /> <job /> <runlabelMatcher regex="true" runlabel="TEST" /> </rule> - <rule displayName="testd" enabled="true"> <purgePeriod period="3" unit="WEEKS" /> <project /> <job /> <runlabelMatcher regex="true" runlabel="TEST" /> </rule> - <rule displayName="teste" enabled="false"> <purgePeriod period="999" unit="MONTHS" /> <project /> <job /> <runlabelMatcher regex="true" runlabel="^\d{5}$" /> </rule> - <rule displayName="testf" enabled="true"> <purgePeriod period="1" unit="HOURS" /> <project /> <job /> <runlabelMatcher regex="true" runlabel="^\d{5}$" /> </rule> - <rule displayName="testg" enabled="true"> <purgePeriod period="1" unit="DAYS" /> <project /> <job /> <runlabelMatcher regex="false" runlabel="ABCD" /> </rule> </rules>
処理とルール・スキーマについて
この項では、処理とルールXMLスキーマを示します。
処理スキーマについて
このスキーマは、「自動実行処理の使用」にリストされている処理を説明するものです。
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <!-- Chores --> <xs:element name="chores"> <xs:complexType> <!-- List of chores that need to be performed. The chores will be performed in the order specified in the xml file --> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element name="httpget" type="httpgetType"/> <xs:element name="package" type="packageType"/> <xs:element name="runjob" type="runjobType"/> <xs:element name="runopsjob" type="runopsjobType"/> <xs:element name="dumpdb" type="dumpdbType"/> <xs:element name="dbscript" type="dbScriptType"/> <xs:element name="sleep" type="sleepType"/> <xs:element name="load" type="loadType"/> </xs:choice> <!-- Schema version number --> <xs:attribute name="version" type="xs:positiveInteger" use="required"/> </xs:complexType> </xs:element> <!-- Base type for chores --> <xs:complexType name="choreType"> <!-- Flag indicating whether we should wait for completion before moving on to the next chore. --> <xs:attribute name="waitforcompletion" type="xs:boolean" use="optional" default="true"/> </xs:complexType> <!-- HTTP Get chore. Download the specified urls. --> <xs:complexType name="httpgetType"> <xs:complexContent> <xs:extension base="choreType"> <xs:sequence minOccurs="1" maxOccurs="1"> <!-- URL to download. --> <xs:element name="url" type="xs:string"/> </xs:sequence> <!-- Filename to download to. --> <xs:attribute name="tofile" type="xs:string" use="required"/> <!-- Directory to download the files to. - relative path is relative to the config dir - absolute path is used as is - no path indicates the config dir --> <xs:attribute name="todir" type="xs:string" use="optional"/> <!-- If true existing files are overwritten, otherwise download is not performed. --> <xs:attribute name="overwrite" type="xs:boolean" use="optional" default="true"/> </xs:extension> </xs:complexContent> </xs:complexType> <!-- dxi file control chore. Import or export to/from a dxi file. --> <xs:complexType name="packageType"> <xs:complexContent> <xs:extension base="choreType"> <!-- List of root level nodes to import/export. An empty list indicates 'all'. --> <xs:sequence minOccurs="0" maxOccurs="unbounded"> <xs:element name="node" type="packageNodeType"/> </xs:sequence> <!-- dxi filename. --> <xs:attribute name="file" type="xs:string" use="required"/> <!-- Directory that the dxi is in. - relative path is relative to the config dir - absolute path is used as is - no path indicates the config dir --> <xs:attribute name="dir" type="xs:string" use="optional"/> <!-- If true existing files/nodes are overwritten, otherwise no operation. --> <xs:attribute name="overwrite" type="xs:boolean" use="optional" default="true"/> <!-- Direction: in=import out=export --> <xs:attribute name="direction" type="packageDirectionEnum" use="required"/> </xs:extension> </xs:complexContent> </xs:complexType> <!-- Package node for import or export from/to a dxi. --> <xs:complexType name="packageNodeType"> <!-- the type of the node to process --> <xs:attribute name="type" type="nodeTypeEnum" use="required"/> <!-- the name of the node to process --> <xs:attribute name="name" type="xs:string" use="required"/> </xs:complexType> <!-- db script control chore. Runs db script against the configuration database. --> <xs:complexType name="dbScriptType"> <xs:complexContent> <xs:extension base="choreType"> <!-- db script filename. --> <xs:attribute name="file" type="xs:string" use="required"/> <!-- Directory that the db script is in. - relative path is relative to the config dir - absolute path is used as is - no path indicates the config dir --> <xs:attribute name="dir" type="xs:string" use="optional"/> <!-- The database to run the script against --> <xs:attribute name="database" type="databaseEnum" use="required"/> </xs:extension> </xs:complexContent> </xs:complexType> <!-- Invoke named job chore. Run a named job --> <xs:complexType name="runjobType"> <xs:complexContent> <xs:extension base="choreType"> <!-- Project name --> <xs:attribute name="project" type="xs:string" use="required"/> <!-- Job name --> <xs:attribute name="job" type="xs:string" use="required"/> <!-- Wait for locks flag - default to true --> <xs:attribute name="waitforlocks" type="xs:boolean" use="optional" default="true"/> <!-- Optional run profile --> <xs:attribute name="runprofile" type="xs:string" use="optional"/> </xs:extension> </xs:complexContent> </xs:complexType> <xs:complexType name="runopsjobType"> <xs:complexContent> <xs:extension base="runjobType"> <!-- Optional run label (will override run profile run label if set) --> <xs:attribute name="runlabel" type="xs:string" use="optional"/> </xs:extension> </xs:complexContent> </xs:complexType> <!-- Dump the database. --> <xs:complexType name="dumpdbType"> <xs:complexContent> <xs:extension base="choreType"> <!-- Output JMP file for config database --> <xs:attribute name="configout" type="xs:string" use="required"/> <!-- Output JMP file for results database --> <xs:attribute name="resultsout" type="xs:string" use="required"/> <!-- Directory that the JMP files are written to - relative path is relative to the config dir - absolute path is used as is - no path indicates the config dir --> <xs:attribute name="dir" type="xs:string" use="optional"/> <!-- TODO: Add some filtering to allow dumping of categories of data e.g. staged data, results data, case management data, etc. --> </xs:extension> </xs:complexContent> </xs:complexType> <!-- Load a certain file to do a certain thing. Eg change purge rules. --> <xs:complexType name="loadType"> <xs:complexContent> <xs:extension base="choreType"> <!-- type of action to run with file --> <xs:attribute name="type" type="loadTypeEnum" use="required"/> <!-- filename --> <xs:attribute name="file" type="xs:string" use="required"/> <!-- Directory that the file is in. - relative path is relative to the config dir - absolute path is used as is - no path indicates the config dir --> <xs:attribute name="dir" type="xs:string" use="optional"/> </xs:extension> </xs:complexContent> </xs:complexType> <!-- Enumeration of databases --> <xs:simpleType name="databaseEnum"> <xs:restriction base="xs:string"> <xs:enumeration value="director"/> <xs:enumeration value="results"/> </xs:restriction> </xs:simpleType> <!-- Enumeration of valid node types --> <xs:simpleType name="nodeTypeEnum"> <xs:restriction base="xs:string"> <xs:enumeration value="project"/> <!-- Probably need to do these sometime <xs:enumeration value="resource"/> <xs:enumeration value="datastore"/> --> </xs:restriction> </xs:simpleType> <!-- Enumeration of packaging direction. --> <xs:simpleType name="packageDirectionEnum"> <xs:restriction base="xs:string"> <xs:enumeration value="in"/> <xs:enumeration value="out"/> </xs:restriction> </xs:simpleType> <!-- Enumeration of types of things that can be loaded. --> <xs:simpleType name="loadTypeEnum"> <xs:restriction base="xs:string"> <xs:enumeration value="purgeRules"/> <!-- <xs:enumeration value="schedule"/> --> </xs:restriction> </xs:simpleType> <!-- Sleep chore. Wait for a while before doing other autorun stuff --> <xs:complexType name="sleepType"> <xs:complexContent> <xs:extension base="choreType"> <!-- seconds to wait. --> <xs:attribute name="time" type="xs:integer" use="required"/> </xs:extension> </xs:complexContent> </xs:complexType> </xs:schema>
ルール・スキーマについて
この項では、EDQサーバーのパージ・ルールを指定するXMLスクリプトを構成する基礎を提供する、ルール・スキーマについて説明します。load
処理を使用してEDQ起動時にスクリプトをロードします。
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <!-- Common types --> <!-- ============ --> <xs:include schemaLocation="urn:commontypes.xsd"/> <xs:element name="rules" type="rulesType"> <!-- Rule name must be unique --> <xs:key name="rule.name"> <xs:selector xpath="rules/rule"/> <xs:field xpath="@name"/> </xs:key> </xs:element> <!-- Rules --> <xs:complexType name="rulesType"> <xs:sequence> <xs:element name="rule" type="ruleType" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> <xs:attribute name="schemaversion" type="xs:positiveInteger" use="optional" default="1"/> </xs:complexType> <xs:complexType name="ruleType"> <xs:sequence> <xs:element name="purgePeriod" type="periodType" minOccurs="1" maxOccurs="1"/> <xs:element name="project" type="xs:string" minOccurs="0" maxOccurs="1"/> <xs:element name="job" type="xs:string" minOccurs="0" maxOccurs="1"/> <xs:element name="runlabelMatcher" type="runlabelType" minOccurs="0" maxOccurs="1"/> </xs:sequence> <!-- name --> <xs:attribute name="displayName" type="xs:string" use="required"/> <!-- whether this rule should be applied --> <xs:attribute name="enabled" type="xs:boolean" use="required"/> </xs:complexType> <!-- Runlabel --> <xs:complexType name="runlabelType"> <xs:attribute name="regex" type="xs:boolean" use="required"/> <xs:attribute name="runlabel" type="xs:string" use="required"/> </xs:complexType> <!-- Purge Period --> <xs:complexType name="periodType"> <xs:attribute name="period" type="xs:int" use="optional"/> <xs:attribute name="unit" type="periodUnitType" use="required"/> </xs:complexType> <!-- Purge Unit types --> <xs:simpleType name="periodUnitType"> <xs:restriction base="xs:string"> <xs:enumeration value="IMMEDIATE"/> <xs:enumeration value="HOURS"/> <xs:enumeration value="DAYS"/> <xs:enumeration value="WEEKS"/> <xs:enumeration value="MONTHS"/> <xs:enumeration value="NEVER"/> </xs:restriction> </xs:simpleType> </xs:schema>