(Map<String, Object> args)
| 217 | } |
| 218 | |
| 219 | public Map<String, Object> run(Map<String, Object> args) throws Exception { |
| 220 | getConf().setLong("injector.current.time", System.currentTimeMillis()); |
| 221 | Path input; |
| 222 | Object path = args.get(Nutch.ARG_SEEDDIR); |
| 223 | if (path instanceof Path) { |
| 224 | input = (Path) path; |
| 225 | } else { |
| 226 | input = new Path(path.toString()); |
| 227 | } |
| 228 | numJobs = 1; |
| 229 | currentJobNum = 0; |
| 230 | currentJob = NutchJob.getInstance(getConf(), "inject " + input); |
| 231 | FileStatus[] seedFiles = input.getFileSystem(getConf()).listStatus(input); |
| 232 | int numSeedFiles = 0; |
| 233 | for (FileStatus seedFile : seedFiles) { |
| 234 | if (seedFile.isFile()) { |
| 235 | FileInputFormat.addInputPath(currentJob, seedFile.getPath()); |
| 236 | numSeedFiles++; |
| 237 | LOG.info("Injecting seed URL file {}", seedFile.getPath()); |
| 238 | } else { |
| 239 | LOG.warn("Skipped non-file input in {}: {}", input, |
| 240 | seedFile.getPath()); |
| 241 | } |
| 242 | } |
| 243 | if (numSeedFiles == 0) { |
| 244 | LOG.error("No seed files to inject found in {}", input); |
| 245 | return results; |
| 246 | } |
| 247 | currentJob.setMapperClass(UrlMapper.class); |
| 248 | currentJob.setMapOutputKeyClass(String.class); |
| 249 | currentJob.setMapOutputValueClass(WebPage.class); |
| 250 | currentJob.setOutputFormatClass(GoraOutputFormat.class); |
| 251 | |
| 252 | DataStore<String, WebPage> store = StorageUtils.createWebStore( |
| 253 | currentJob.getConfiguration(), String.class, WebPage.class); |
| 254 | GoraOutputFormat.setOutput(currentJob, store, true); |
| 255 | |
| 256 | // NUTCH-1471 Make explicit which datastore class we use |
| 257 | Class<? extends DataStore<Object, Persistent>> dataStoreClass = StorageUtils |
| 258 | .getDataStoreClass(currentJob.getConfiguration()); |
| 259 | LOG.info("InjectorJob: Using " + dataStoreClass |
| 260 | + " as the Gora storage class."); |
| 261 | |
| 262 | currentJob.setReducerClass(Reducer.class); |
| 263 | currentJob.setNumReduceTasks(0); |
| 264 | |
| 265 | currentJob.waitForCompletion(true); |
| 266 | ToolUtil.recordJobStatus(null, currentJob, results); |
| 267 | |
| 268 | // NUTCH-1370 Make explicit #URLs injected @runtime |
| 269 | long urlsInjected = currentJob.getCounters() |
| 270 | .findCounter("injector", "urls_injected").getValue(); |
| 271 | long urlsFiltered = currentJob.getCounters() |
| 272 | .findCounter("injector", "urls_filtered").getValue(); |
| 273 | LOG.info("InjectorJob: total number of urls rejected by filters: " |
| 274 | + urlsFiltered); |
| 275 | LOG.info("InjectorJob: total number of urls injected after normalization and filtering: " |
| 276 | + urlsInjected); |
no test coverage detected