8 from optparse
import OptionParser
9 from kmrfsplit
import *
10 from kmrgenscript
import *
15 if __name__ ==
"__main__":
17 usage =
"usage: %prog [options] -m mapper -r reducer inputfile" 18 parser = OptionParser(usage)
20 parser.add_option(
"-n",
21 "--number-of-separation",
24 help=
"number of file separate",
28 parser.add_option(
"-e",
29 "--number-of-exec-nodes",
32 help=
"number of execute nodes",
36 parser.add_option(
"-s",
40 help=
"separator string",
44 parser.add_option(
"-p",
45 "--separate-file-prefix",
48 help=
"separate filename prefix",
52 parser.add_option(
"-o",
56 help=
"output filename prefix",
60 parser.add_option(
"-d",
64 help=
"work directory",
68 parser.add_option(
"-O",
72 help=
"output directory",
76 parser.add_option(
"-t",
84 parser.add_option(
"-m",
91 parser.add_option(
"-r",
98 parser.add_option(
"-S",
102 help=
"scheduler (default is 'K')",
106 parser.add_option(
"-w",
107 "--write-scriptfile",
110 help=
"script filename",
113 parser.add_option(
"-f",
120 (options, args) = parser.parse_args()
125 parser.error(
"missing parameter")
130 if options.nodes > options.nums :
131 print 'Error: number of execute nodes must be less than or equal to number of file separation.' 136 if options.nodes < options.nums :
141 if not os.path.exists(inputfile) :
142 print 'Error: inputfile %s is not exist.' % inputfile
145 if os.path.exists(options.workdir) :
146 if not os.path.isdir(options.workdir) :
147 print 'Error: "%s" is not directory.' % options.workdir
152 os.mkdir(options.workdir)
154 print 'Error: could not create "%s".' % options.workdir
157 print 'Error: directory "%s" is not exist. create it or use -f option.' % options.workdir
160 splitfile(options.nums, options.sep, options.workdir, options.prefix, inputfile)
162 selectscheduler(options.nodes, options.prefix, options.outfile,
163 options.workdir, options.outdir, options.rsctime,
164 options.mapper, options.reducer, multi,
165 options.sched, options.scrfile)