PageRenderTime 39ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/release-0.0.0-rc0/hive/external/ql/src/java/org/apache/hadoop/hive/ql/exec/TaskRunner.java

#
Java | 64 lines | 30 code | 11 blank | 23 comment | 0 complexity | 39303efe09e2dd00cdd508eb3b8d43a2 MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause, JSON, CPL-1.0
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. package org.apache.hadoop.hive.ql.exec;
  19. import java.io.Serializable;
  20. import org.apache.hadoop.hive.ql.session.SessionState;
  21. /**
  22. * TaskRunner implementation.
  23. **/
  24. public class TaskRunner extends Thread {
  25. protected Task<? extends Serializable> tsk;
  26. protected TaskResult result;
  27. protected SessionState ss;
  28. public TaskRunner(Task<? extends Serializable> tsk, TaskResult result) {
  29. this.tsk = tsk;
  30. this.result = result;
  31. ss = SessionState.get();
  32. }
  33. public Task<? extends Serializable> getTask() {
  34. return tsk;
  35. }
  36. @Override
  37. public void run() {
  38. SessionState.start(ss);
  39. runSequential();
  40. }
  41. /**
  42. * Launches a task, and sets its exit value in the result variable.
  43. */
  44. public void runSequential() {
  45. int exitVal = -101;
  46. try {
  47. exitVal = tsk.executeTask();
  48. } catch (Throwable t) {
  49. t.printStackTrace();
  50. }
  51. result.setExitVal(exitVal);
  52. }
  53. }