@Test @Category(UnitTest.class) public void testPreferredProviderFromMrGeoProp() throws Exception { String good = "good"; setupPreferred(conf, null, good, null); DataProviderFactory.initialize(conf); Assert.assertEquals("Bad adhoc preferred provider!", good, DataProviderFactory.preferredAdHocProviderName); Assert.assertEquals("Bad image preferred provider!", good, DataProviderFactory.preferredImageProviderName); Assert.assertEquals("Bad vector preferred provider!", good, DataProviderFactory.preferredVectorProviderName); teardownPreferred(conf); }
protected synchronized static void initialize(Configuration conf) throws DataProviderException { if (adHocProviderFactories == null) { log.info("Initializing ad hoc provider factories"); adHocProviderFactories = new HashMap<>(); ServiceLoader<AdHocDataProviderFactory> dataProviderLoader = ServiceLoader .load(AdHocDataProviderFactory.class); for (AdHocDataProviderFactory dp : dataProviderLoader) { if (configSettings != null) { dp.setConfiguration(configSettings); } if (dp.isValid(conf)) { log.info("Found ad hoc data provider factory " + dp.getClass().getName()); adHocProviderFactories.put(dp.getPrefix(), dp); dp.initialize(conf); } else { log.info("Skipping ad hoc data provider " + dp.getClass().getName() + " because isValid returned false"); } } } if (mrsImageProviderFactories == null) { log.info("Initializing image provider factories"); mrsImageProviderFactories = new HashMap<>(); ServiceLoader<MrsImageDataProviderFactory> dataProviderLoader = ServiceLoader .load(MrsImageDataProviderFactory.class); for (MrsImageDataProviderFactory dp : dataProviderLoader) { try { if (configSettings != null) { dp.setConfiguration(configSettings); } if (dp.isValid()) { log.info("Found mrs image data provider factory {} {}", dp.getPrefix(), dp.getClass().getName()); mrsImageProviderFactories.put(dp.getPrefix(), dp); dp.initialize(conf); } else { log.info("Skipping mrs image data provider " + dp.getClass().getName() + " because isValid returned false"); } } catch (Exception e) { log.warn("Ignoring " + dp.getClass().getName(), e); } } } if (vectorProviderFactories == null) { log.info("Initializing vector provider factories"); boolean debugEnabled = log.isDebugEnabled(); vectorProviderFactories = new HashMap<>(); if (debugEnabled) { log.debug("Finding vector provider factories"); } ServiceLoader<VectorDataProviderFactory> dataProviderLoader = ServiceLoader .load(VectorDataProviderFactory.class); int count = 0; for (VectorDataProviderFactory dp : dataProviderLoader) { try { if (debugEnabled) { log.debug("Checking if vector factory is valid: " + dp.getClass().getName() + " with config " + ((conf == null) ? "null" : "not null")); } if (configSettings != null) { dp.setConfiguration(configSettings); } if (dp.isValid(conf)) { if (debugEnabled) { log.debug("Factory " + dp.getClass().getName() + " is valid, uses prefix: " + dp.getPrefix()); } vectorProviderFactories.put(dp.getPrefix(), dp); dp.initialize(conf); count++; } else { if (debugEnabled) { log.debug("Factory " + dp.getClass().getName() + " is NOT valid, uses prefix: " + dp.getPrefix()); } log.info("Skipping vector data provider " + dp.getClass().getName() + " because isValid returned false"); } } catch (Exception e) { log.warn("Skipping vector factory provider " + dp.getClass().getName() + " due to exception", e); } } if (count == 0) { log.warn("No vector factory providers were found"); } } findPreferredProvider(conf); }
DataProviderFactory { protected synchronized static void initialize(Configuration conf) throws DataProviderException { if (adHocProviderFactories == null) { log.info("Initializing ad hoc provider factories"); adHocProviderFactories = new HashMap<>(); ServiceLoader<AdHocDataProviderFactory> dataProviderLoader = ServiceLoader .load(AdHocDataProviderFactory.class); for (AdHocDataProviderFactory dp : dataProviderLoader) { if (configSettings != null) { dp.setConfiguration(configSettings); } if (dp.isValid(conf)) { log.info("Found ad hoc data provider factory " + dp.getClass().getName()); adHocProviderFactories.put(dp.getPrefix(), dp); dp.initialize(conf); } else { log.info("Skipping ad hoc data provider " + dp.getClass().getName() + " because isValid returned false"); } } } if (mrsImageProviderFactories == null) { log.info("Initializing image provider factories"); mrsImageProviderFactories = new HashMap<>(); ServiceLoader<MrsImageDataProviderFactory> dataProviderLoader = ServiceLoader .load(MrsImageDataProviderFactory.class); for (MrsImageDataProviderFactory dp : dataProviderLoader) { try { if (configSettings != null) { dp.setConfiguration(configSettings); } if (dp.isValid()) { log.info("Found mrs image data provider factory {} {}", dp.getPrefix(), dp.getClass().getName()); mrsImageProviderFactories.put(dp.getPrefix(), dp); dp.initialize(conf); } else { log.info("Skipping mrs image data provider " + dp.getClass().getName() + " because isValid returned false"); } } catch (Exception e) { log.warn("Ignoring " + dp.getClass().getName(), e); } } } if (vectorProviderFactories == null) { log.info("Initializing vector provider factories"); boolean debugEnabled = log.isDebugEnabled(); vectorProviderFactories = new HashMap<>(); if (debugEnabled) { log.debug("Finding vector provider factories"); } ServiceLoader<VectorDataProviderFactory> dataProviderLoader = ServiceLoader .load(VectorDataProviderFactory.class); int count = 0; for (VectorDataProviderFactory dp : dataProviderLoader) { try { if (debugEnabled) { log.debug("Checking if vector factory is valid: " + dp.getClass().getName() + " with config " + ((conf == null) ? "null" : "not null")); } if (configSettings != null) { dp.setConfiguration(configSettings); } if (dp.isValid(conf)) { if (debugEnabled) { log.debug("Factory " + dp.getClass().getName() + " is valid, uses prefix: " + dp.getPrefix()); } vectorProviderFactories.put(dp.getPrefix(), dp); dp.initialize(conf); count++; } else { if (debugEnabled) { log.debug("Factory " + dp.getClass().getName() + " is NOT valid, uses prefix: " + dp.getPrefix()); } log.info("Skipping vector data provider " + dp.getClass().getName() + " because isValid returned false"); } } catch (Exception e) { log.warn("Skipping vector factory provider " + dp.getClass().getName() + " due to exception", e); } } if (count == 0) { log.warn("No vector factory providers were found"); } } findPreferredProvider(conf); } }
DataProviderFactory { protected synchronized static void initialize(Configuration conf) throws DataProviderException { if (adHocProviderFactories == null) { log.info("Initializing ad hoc provider factories"); adHocProviderFactories = new HashMap<>(); ServiceLoader<AdHocDataProviderFactory> dataProviderLoader = ServiceLoader .load(AdHocDataProviderFactory.class); for (AdHocDataProviderFactory dp : dataProviderLoader) { if (configSettings != null) { dp.setConfiguration(configSettings); } if (dp.isValid(conf)) { log.info("Found ad hoc data provider factory " + dp.getClass().getName()); adHocProviderFactories.put(dp.getPrefix(), dp); dp.initialize(conf); } else { log.info("Skipping ad hoc data provider " + dp.getClass().getName() + " because isValid returned false"); } } } if (mrsImageProviderFactories == null) { log.info("Initializing image provider factories"); mrsImageProviderFactories = new HashMap<>(); ServiceLoader<MrsImageDataProviderFactory> dataProviderLoader = ServiceLoader .load(MrsImageDataProviderFactory.class); for (MrsImageDataProviderFactory dp : dataProviderLoader) { try { if (configSettings != null) { dp.setConfiguration(configSettings); } if (dp.isValid()) { log.info("Found mrs image data provider factory {} {}", dp.getPrefix(), dp.getClass().getName()); mrsImageProviderFactories.put(dp.getPrefix(), dp); dp.initialize(conf); } else { log.info("Skipping mrs image data provider " + dp.getClass().getName() + " because isValid returned false"); } } catch (Exception e) { log.warn("Ignoring " + dp.getClass().getName(), e); } } } if (vectorProviderFactories == null) { log.info("Initializing vector provider factories"); boolean debugEnabled = log.isDebugEnabled(); vectorProviderFactories = new HashMap<>(); if (debugEnabled) { log.debug("Finding vector provider factories"); } ServiceLoader<VectorDataProviderFactory> dataProviderLoader = ServiceLoader .load(VectorDataProviderFactory.class); int count = 0; for (VectorDataProviderFactory dp : dataProviderLoader) { try { if (debugEnabled) { log.debug("Checking if vector factory is valid: " + dp.getClass().getName() + " with config " + ((conf == null) ? "null" : "not null")); } if (configSettings != null) { dp.setConfiguration(configSettings); } if (dp.isValid(conf)) { if (debugEnabled) { log.debug("Factory " + dp.getClass().getName() + " is valid, uses prefix: " + dp.getPrefix()); } vectorProviderFactories.put(dp.getPrefix(), dp); dp.initialize(conf); count++; } else { if (debugEnabled) { log.debug("Factory " + dp.getClass().getName() + " is NOT valid, uses prefix: " + dp.getPrefix()); } log.info("Skipping vector data provider " + dp.getClass().getName() + " because isValid returned false"); } } catch (Exception e) { log.warn("Skipping vector factory provider " + dp.getClass().getName() + " due to exception", e); } } if (count == 0) { log.warn("No vector factory providers were found"); } } findPreferredProvider(conf); }  }
DataProviderFactory { protected synchronized static void initialize(Configuration conf) throws DataProviderException { if (adHocProviderFactories == null) { log.info("Initializing ad hoc provider factories"); adHocProviderFactories = new HashMap<>(); ServiceLoader<AdHocDataProviderFactory> dataProviderLoader = ServiceLoader .load(AdHocDataProviderFactory.class); for (AdHocDataProviderFactory dp : dataProviderLoader) { if (configSettings != null) { dp.setConfiguration(configSettings); } if (dp.isValid(conf)) { log.info("Found ad hoc data provider factory " + dp.getClass().getName()); adHocProviderFactories.put(dp.getPrefix(), dp); dp.initialize(conf); } else { log.info("Skipping ad hoc data provider " + dp.getClass().getName() + " because isValid returned false"); } } } if (mrsImageProviderFactories == null) { log.info("Initializing image provider factories"); mrsImageProviderFactories = new HashMap<>(); ServiceLoader<MrsImageDataProviderFactory> dataProviderLoader = ServiceLoader .load(MrsImageDataProviderFactory.class); for (MrsImageDataProviderFactory dp : dataProviderLoader) { try { if (configSettings != null) { dp.setConfiguration(configSettings); } if (dp.isValid()) { log.info("Found mrs image data provider factory {} {}", dp.getPrefix(), dp.getClass().getName()); mrsImageProviderFactories.put(dp.getPrefix(), dp); dp.initialize(conf); } else { log.info("Skipping mrs image data provider " + dp.getClass().getName() + " because isValid returned false"); } } catch (Exception e) { log.warn("Ignoring " + dp.getClass().getName(), e); } } } if (vectorProviderFactories == null) { log.info("Initializing vector provider factories"); boolean debugEnabled = log.isDebugEnabled(); vectorProviderFactories = new HashMap<>(); if (debugEnabled) { log.debug("Finding vector provider factories"); } ServiceLoader<VectorDataProviderFactory> dataProviderLoader = ServiceLoader .load(VectorDataProviderFactory.class); int count = 0; for (VectorDataProviderFactory dp : dataProviderLoader) { try { if (debugEnabled) { log.debug("Checking if vector factory is valid: " + dp.getClass().getName() + " with config " + ((conf == null) ? "null" : "not null")); } if (configSettings != null) { dp.setConfiguration(configSettings); } if (dp.isValid(conf)) { if (debugEnabled) { log.debug("Factory " + dp.getClass().getName() + " is valid, uses prefix: " + dp.getPrefix()); } vectorProviderFactories.put(dp.getPrefix(), dp); dp.initialize(conf); count++; } else { if (debugEnabled) { log.debug("Factory " + dp.getClass().getName() + " is NOT valid, uses prefix: " + dp.getPrefix()); } log.info("Skipping vector data provider " + dp.getClass().getName() + " because isValid returned false"); } } catch (Exception e) { log.warn("Skipping vector factory provider " + dp.getClass().getName() + " due to exception", e); } } if (count == 0) { log.warn("No vector factory providers were found"); } } findPreferredProvider(conf); }  static void saveProviderPropertiesToConfig(ProviderProperties providerProperties,
    Configuration conf); static ProviderProperties loadProviderPropertiesFromConfig(Configuration conf); static Map<String, String> getConfigurationFromProviders(); static void setConfigurationForProviders(Map<String, String> properties); static AdHocDataProvider createAdHocDataProvider(ProviderProperties providerProperties); static AdHocDataProvider createAdHocDataProvider(Configuration conf); static AdHocDataProvider getAdHocDataProvider(String name,
    AccessMode mode,
    ProviderProperties providerProperties); static AdHocDataProvider getAdHocDataProvider(String name,
    AccessMode mode,
    Configuration conf); static String[] listImages(ProviderProperties providerProperties); static String[] listVectors(ProviderProperties providerProperties); static MrsImageDataProvider createTempMrsImageDataProvider(ProviderProperties props); static MrsImageDataProvider createTempMrsImageDataProvider(Configuration conf); static MrsImageDataProvider getMrsImageDataProvider(String name,
    AccessMode accessMode,
    ProviderProperties props); static MrsImageDataProvider getMrsImageDataProviderNoCache(String name,
    AccessMode accessMode,
    ProviderProperties props); static MrsImageDataProvider getMrsImageDataProvider(String name,
    AccessMode accessMode,
    Configuration conf); static VectorDataProvider getVectorDataProvider(String name,
    AccessMode accessMode,
    ProviderProperties providerProperties); static VectorDataProvider getVectorDataProvider(String name,
    AccessMode accessMode, Configuration conf); static void invalidateCache(); static void invalidateCache(String resource); static void delete(String resource,
    ProviderProperties providerProperties); static void addDependencies(Configuration conf); static Set<String> getDependencies(); }
DataProviderFactory { protected synchronized static void initialize(Configuration conf) throws DataProviderException { if (adHocProviderFactories == null) { log.info("Initializing ad hoc provider factories"); adHocProviderFactories = new HashMap<>(); ServiceLoader<AdHocDataProviderFactory> dataProviderLoader = ServiceLoader .load(AdHocDataProviderFactory.class); for (AdHocDataProviderFactory dp : dataProviderLoader) { if (configSettings != null) { dp.setConfiguration(configSettings); } if (dp.isValid(conf)) { log.info("Found ad hoc data provider factory " + dp.getClass().getName()); adHocProviderFactories.put(dp.getPrefix(), dp); dp.initialize(conf); } else { log.info("Skipping ad hoc data provider " + dp.getClass().getName() + " because isValid returned false"); } } } if (mrsImageProviderFactories == null) { log.info("Initializing image provider factories"); mrsImageProviderFactories = new HashMap<>(); ServiceLoader<MrsImageDataProviderFactory> dataProviderLoader = ServiceLoader .load(MrsImageDataProviderFactory.class); for (MrsImageDataProviderFactory dp : dataProviderLoader) { try { if (configSettings != null) { dp.setConfiguration(configSettings); } if (dp.isValid()) { log.info("Found mrs image data provider factory {} {}", dp.getPrefix(), dp.getClass().getName()); mrsImageProviderFactories.put(dp.getPrefix(), dp); dp.initialize(conf); } else { log.info("Skipping mrs image data provider " + dp.getClass().getName() + " because isValid returned false"); } } catch (Exception e) { log.warn("Ignoring " + dp.getClass().getName(), e); } } } if (vectorProviderFactories == null) { log.info("Initializing vector provider factories"); boolean debugEnabled = log.isDebugEnabled(); vectorProviderFactories = new HashMap<>(); if (debugEnabled) { log.debug("Finding vector provider factories"); } ServiceLoader<VectorDataProviderFactory> dataProviderLoader = ServiceLoader .load(VectorDataProviderFactory.class); int count = 0; for (VectorDataProviderFactory dp : dataProviderLoader) { try { if (debugEnabled) { log.debug("Checking if vector factory is valid: " + dp.getClass().getName() + " with config " + ((conf == null) ? "null" : "not null")); } if (configSettings != null) { dp.setConfiguration(configSettings); } if (dp.isValid(conf)) { if (debugEnabled) { log.debug("Factory " + dp.getClass().getName() + " is valid, uses prefix: " + dp.getPrefix()); } vectorProviderFactories.put(dp.getPrefix(), dp); dp.initialize(conf); count++; } else { if (debugEnabled) { log.debug("Factory " + dp.getClass().getName() + " is NOT valid, uses prefix: " + dp.getPrefix()); } log.info("Skipping vector data provider " + dp.getClass().getName() + " because isValid returned false"); } } catch (Exception e) { log.warn("Skipping vector factory provider " + dp.getClass().getName() + " due to exception", e); } } if (count == 0) { log.warn("No vector factory providers were found"); } } findPreferredProvider(conf); }  static void saveProviderPropertiesToConfig(ProviderProperties providerProperties,
    Configuration conf); static ProviderProperties loadProviderPropertiesFromConfig(Configuration conf); static Map<String, String> getConfigurationFromProviders(); static void setConfigurationForProviders(Map<String, String> properties); static AdHocDataProvider createAdHocDataProvider(ProviderProperties providerProperties); static AdHocDataProvider createAdHocDataProvider(Configuration conf); static AdHocDataProvider getAdHocDataProvider(String name,
    AccessMode mode,
    ProviderProperties providerProperties); static AdHocDataProvider getAdHocDataProvider(String name,
    AccessMode mode,
    Configuration conf); static String[] listImages(ProviderProperties providerProperties); static String[] listVectors(ProviderProperties providerProperties); static MrsImageDataProvider createTempMrsImageDataProvider(ProviderProperties props); static MrsImageDataProvider createTempMrsImageDataProvider(Configuration conf); static MrsImageDataProvider getMrsImageDataProvider(String name,
    AccessMode accessMode,
    ProviderProperties props); static MrsImageDataProvider getMrsImageDataProviderNoCache(String name,
    AccessMode accessMode,
    ProviderProperties props); static MrsImageDataProvider getMrsImageDataProvider(String name,
    AccessMode accessMode,
    Configuration conf); static VectorDataProvider getVectorDataProvider(String name,
    AccessMode accessMode,
    ProviderProperties providerProperties); static VectorDataProvider getVectorDataProvider(String name,
    AccessMode accessMode, Configuration conf); static void invalidateCache(); static void invalidateCache(String resource); static void delete(String resource,
    ProviderProperties providerProperties); static void addDependencies(Configuration conf); static Set<String> getDependencies(); static final String PROVIDER_PROPERTY_USER_NAME; static final String PROVIDER_PROPERTY_USER_ROLES; }