OozieScheduling { @VisibleForTesting static final String qualifyUri(Configuration conf, String uriTemplate) { URI baseURI = URI.create(uriTemplate.substring(uriTemplate.indexOf(':') + 1, uriTemplate.indexOf('?'))); if (!"hive".equals(baseURI.getScheme()) || baseURI.getHost() != null || conf.get(HIVE_METASTORE_URIS) == null) { return uriTemplate; } String[] uris = conf.get(HIVE_METASTORE_URIS).split(","); if (uris.length == 0) { return uriTemplate; } URI hiveUri = URI.create(uris[0]); String host = hiveUri.getHost(); int port = hiveUri.getPort(); String prefix = uriTemplate.startsWith("dataset") ? "dataset:hive:" : "view:hive:"; String rest = uriTemplate.substring(prefix.length()); return prefix + " }  static String workflowPath(Schedule schedule); static String coordPath(Schedule schedule); static Instant getNominalTime(Configuration conf); static void element(XMLWriter writer, String name, String attributeName,
                              String attributeValue); static void element(XMLWriter writer, String name, String text); static void writeWorkFlow(Schedule schedule,
                                   AppContext context,
                                   OutputStream output); static void writeCoordinator(Schedule schedule,
                                      SchedulableJobManager manager,
                                      OutputStream output); static void property(XMLWriter writer, String name, String value); static void writeBundle(Class appClass,
                                 AppContext context,
                                 Path appPath,
                                 List<Schedule> schedules,
                                 OutputStream output); static Map<String,View> loadViews(SchedulableJobManager manager, Configuration conf); static Map<String,String> getJobSettings(Schedule schedule, Configuration conf); static void writeJobConfiguration(XMLWriter writer, Schedule schedule, Configuration conf);  }
@Test public void testQualifyHiveUri() { String template = "view:hive:example/events" + "?year=${YEAR}&month=${MONTH}&day=${DAY}&hour=${HOUR}&minute=${MINUTE}"; Configuration conf = new Configuration(); conf.set("hive.metastore.uris", "thrift: String qualified = OozieScheduling.qualifyUri(conf, template); assertEquals("view:hive: "&month=${MONTH}&day=${DAY}&hour=${HOUR}&minute=${MINUTE}", qualified); }
@Test public void testAlreadyQualifiedUri() { String template = "view:hive: "&month=${MONTH}&day=${DAY}&hour=${HOUR}&minute=${MINUTE}"; Configuration conf = new Configuration(); conf.set("hive.metastore.uris", "thrift: String qualified = OozieScheduling.qualifyUri(conf, template); assertEquals(template, qualified); }