PageRenderTime 48ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/spring-hadoop-test/src/test/java/org/springframework/data/hadoop/test/tests/Version.java

https://github.com/rajeshmeher/spring-hadoop
Java | 55 lines | 18 code | 8 blank | 29 comment | 5 complexity | ea28809e428c5134d576174a58b81893 MD5 | raw file
Possible License(s): Apache-2.0
  1. /*
  2. * Copyright 2013 the original author or authors.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.springframework.data.hadoop.test.tests;
  17. import org.apache.hadoop.util.VersionInfo;
  18. import org.springframework.util.StringUtils;
  19. /**
  20. * A hadoop version used to limit when certain tests are run.
  21. *
  22. * @author Janne Valkealahti
  23. *
  24. */
  25. public enum Version {
  26. /**
  27. * All hadoop 1.x and MR1 based distros.
  28. */
  29. HADOOP1X,
  30. /**
  31. * All hadoop 2.x YARN based distros.
  32. */
  33. HADOOP2X;
  34. public static Version resolveVersion() {
  35. String version = VersionInfo.getVersion();
  36. if (StringUtils.hasText(version)) {
  37. // 1.x or 2.x
  38. if (version.startsWith("1") || version.contains("mr1")) {
  39. return HADOOP1X;
  40. } else if (version.startsWith("2")) {
  41. return HADOOP2X;
  42. }
  43. }
  44. // should not get here
  45. return null;
  46. }
  47. }