Author: challngr Date: Thu Feb 7 19:54:31 2013 New Revision: 1443686 URL: http://svn.apache.org/r1443686 Log: UIMA-2595 Add DD-style job descriptor. Add simple generator for service descriptors.
Added: uima/sandbox/uima-ducc/trunk/uima-ducc-examples/src/main/scripts/ uima/sandbox/uima-ducc/trunk/uima-ducc-examples/src/main/scripts/ducc_boot.py (with props) uima/sandbox/uima-ducc/trunk/uima-ducc-examples/src/main/scripts/gen_service (with props) Added: uima/sandbox/uima-ducc/trunk/uima-ducc-examples/src/main/scripts/ducc_boot.py URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-examples/src/main/scripts/ducc_boot.py?rev=1443686&view=auto ============================================================================== --- uima/sandbox/uima-ducc/trunk/uima-ducc-examples/src/main/scripts/ducc_boot.py (added) +++ uima/sandbox/uima-ducc/trunk/uima-ducc-examples/src/main/scripts/ducc_boot.py Thu Feb 7 19:54:31 2013 @@ -0,0 +1,39 @@ +#! /usr/bin/env python + +# ----------------------------------------------------------------------- +# 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. +# ----------------------------------------------------------------------- + +import os +import sys + +# simple bootstratp to establish DUCC_HOME and to set the python path so it can +# find the common code in DUCC_HOME/admin +def set_ducc_home(): + if ( os.environ.has_key('DUCC_HOME') ): + DUCC_HOME = os.environ['DUCC_HOME'] + else: + me = os.path.abspath(sys.argv[0]) + ndx = me.rindex('/') + ndx = me.rindex('/', 0, ndx) + ndx = me.rindex('/', 0, ndx) + DUCC_HOME = me[:ndx] # split from 0 to ndx + os.environ['DUCC_HOME'] = DUCC_HOME + + sys.path.append(DUCC_HOME + '/admin') + Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-examples/src/main/scripts/ducc_boot.py ------------------------------------------------------------------------------ svn:executable = * Added: uima/sandbox/uima-ducc/trunk/uima-ducc-examples/src/main/scripts/gen_service URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-examples/src/main/scripts/gen_service?rev=1443686&view=auto ============================================================================== --- uima/sandbox/uima-ducc/trunk/uima-ducc-examples/src/main/scripts/gen_service (added) +++ uima/sandbox/uima-ducc/trunk/uima-ducc-examples/src/main/scripts/gen_service Thu Feb 7 19:54:31 2013 @@ -0,0 +1,91 @@ +#! /usr/bin/env python +# ----------------------------------------------------------------------- +# 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. +# ----------------------------------------------------------------------- + +import sys +import os +import getopt + +from ducc_boot import * +set_ducc_home() + +from ducc_util import DuccUtil +from ducc_util import DuccProperties + +class GenService(DuccUtil): + + def usage(self, msg): + if ( msg != None ): + print msg + print '' + + print 'This script generates a service descriptor for a simple SleepService' + print 'using the current DUCC broker and sample code. Once generated the service' + print 'may be submitted and started.' + print '' + print 'Usage:' + print '' + print ' gen_service -i <id>' + print '' + print 'Where:' + print ' <id> is a number 1 to 10 to select one of the 10 sample services.' + print ' The services are identical aside from their endpoint, to allow' + print ' convenient testing of multiple services.' + print '' + print '' + sys.exit(1) + + def main(self, argv): + + svcid = None + + opts, args = getopt.getopt(argv, 'i:?h', ['id=', 'help']) + for ( o, a ) in opts: + if o in ('-i', '--id'): + svcid = a + elif o in ('-h', '--help'): + self.usage() + + if ( svcid == None ): + self.usage("Missing service id") + + plain_broker_url = self.broker_protocol + '://' + self.broker_host + ':' + self.broker_port + props = DuccProperties() + props.put('description', 'Test Service ' + svcid) + props.put('process_DD', self.DUCC_HOME + '/examples/simple/resources/Service_FixedSleep_' + svcid + '.xml') + props.put('process_memory_size', '15') + props.put('process_classpath', + self.DUCC_HOME + '/examples/lib/uima-ducc-examples.jar:' + + self.DUCC_HOME + '/examples/simple/resources') + props.put('process_jvm_args', '-Xmx100M -DdefaultBrokerURL=' + plain_broker_url) + props.put('process_environment', 'AE_INIT_TIME=5000 AE_INIT_RANGE=1000 INIT_ERROR=0 LD_LIBRARY_PATH=/yet/a/nother/dumb/path') + # props.put('process_deployments_max', 1) + props.put('scheduling_class', 'fixed') + #props.put('working_directory', '/home/challngr/projects/ducc/ducc_test/services') + props.put('working_directory', os.getcwd()) + #props.put('working_directory', DUCC_HOME + '/test/jobs') + + svcfile = svcid + '.generated.svc' + props.write(svcfile) + print svcfile, 'created.' + +if __name__ == "__main__": + rs = GenService() + rs.main(sys.argv[1:]) + Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-examples/src/main/scripts/gen_service ------------------------------------------------------------------------------ svn:executable = *