@Override public BlobStore setUp() { String className = System.getProperty("dataStore"); checkNotNull(className, "No system property named 'dataStore' defined"); try { dataStore = Class.forName(className).asSubclass(DataStore.class).newInstance(); config = getConfig(); configure(dataStore, config); dataStore = configureIfCloudDataStore(className, dataStore, config, unique.toLowerCase(), statisticsProvider); storeDir = new File(basedir, unique); dataStore.init(storeDir.getAbsolutePath()); blobStore = new DataStoreBlobStore(dataStore, true, fdsCacheInMB); configure(blobStore); return blobStore; } catch (Exception e) { throw new IllegalStateException("Cannot instantiate DataStore " + className, e); } }
@Override public BlobStore setUp() { String className = System.getProperty("dataStore"); checkNotNull(className, "No system property named 'dataStore' defined"); try { dataStore = Class.forName(className).asSubclass(DataStore.class).newInstance(); config = getConfig(); configure(dataStore, config); dataStore = configureIfCloudDataStore(className, dataStore, config, unique.toLowerCase(), statisticsProvider); storeDir = new File(basedir, unique); dataStore.init(storeDir.getAbsolutePath()); blobStore = new DataStoreBlobStore(dataStore, true, fdsCacheInMB); configure(blobStore); return blobStore; } catch (Exception e) { throw new IllegalStateException("Cannot instantiate DataStore " + className, e); } }
private void initializeDelegate(String homeDir) throws RepositoryException { checkNotNull(delegateClass, "No delegate DataStore class defined via 'delegateClass' property"); try { delegate = (DataStore) getClass().getClassLoader().loadClass(delegateClass).newInstance(); } catch (InstantiationException e) { throw new RepositoryException("Cannot load delegate class " + delegateClass, e); } catch (IllegalAccessException e) { throw new RepositoryException("Cannot load delegate class " + delegateClass, e); } catch (ClassNotFoundException e) { throw new RepositoryException("Cannot load delegate class " + delegateClass, e); } log.info("Using {} as the delegating DataStore", delegateClass); if (delegateConfigFilePath != null) { File configFile = new File(delegateConfigFilePath); checkArgument(configFile.exists(), "Delegate DataStore config file %s does not exist", configFile.getAbsolutePath()); InputStream is = null; try { Properties props = new Properties(); is = Files.asByteSource(configFile).openStream(); props.load(is); PropertiesUtil.populate(delegate, propsToMap(props), false); log.info("Configured the delegating DataStore via {}", configFile.getAbsolutePath()); } catch (IOException e) { throw new RepositoryException("Error reading from config file " + configFile.getAbsolutePath(), e); } finally { IOUtils.closeQuietly(is); } } delegate.init(homeDir); }
private void initializeDelegate(String homeDir) throws RepositoryException { checkNotNull(delegateClass, "No delegate DataStore class defined via 'delegateClass' property"); try { delegate = (DataStore) getClass().getClassLoader().loadClass(delegateClass).newInstance(); } catch (InstantiationException e) { throw new RepositoryException("Cannot load delegate class " + delegateClass, e); } catch (IllegalAccessException e) { throw new RepositoryException("Cannot load delegate class " + delegateClass, e); } catch (ClassNotFoundException e) { throw new RepositoryException("Cannot load delegate class " + delegateClass, e); } log.info("Using {} as the delegating DataStore", delegateClass); if (delegateConfigFilePath != null) { File configFile = new File(delegateConfigFilePath); checkArgument(configFile.exists(), "Delegate DataStore config file %s does not exist", configFile.getAbsolutePath()); InputStream is = null; try { Properties props = new Properties(); is = Files.asByteSource(configFile).openStream(); props.load(is); PropertiesUtil.populate(delegate, propsToMap(props), false); log.info("Configured the delegating DataStore via {}", configFile.getAbsolutePath()); } catch (IOException e) { throw new RepositoryException("Error reading from config file " + configFile.getAbsolutePath(), e); } finally { IOUtils.closeQuietly(is); } } delegate.init(homeDir); }
ds.init(homeDir);
((MultiDataStore) store).setArchiveDataStore(archive); store.init(directory); return store;
ds.init(homeDir);
((MultiDataStore) store).setArchiveDataStore(archive); store.init(directory); return store;
public static DataStore getS3DataStore(String className, Properties props, String homeDir) throws Exception { DataStore ds = Class.forName(className).asSubclass(DataStore.class).newInstance(); PropertiesUtil.populate(ds, Utils.asMap(props), false); // Set the props object if (S3.getName().equals(className)) { ((S3DataStore) ds).setProperties(props); } ds.init(homeDir); return ds; }
public static DataStoreBlobStore getBlobStore(String homeDir) throws Exception { String className = System.getProperty(DS_CLASS_NAME, OakFileDataStore.class.getName()); DataStore ds = Class.forName(className).asSubclass(DataStore.class).newInstance(); PropertiesUtil.populate(ds, getConfig(), false); ds.init(homeDir); return new DataStoreBlobStore(ds); }
private DataStore getAssertCachingFileDataStore(String nasPath, String cachePath) throws RepositoryException { long cacheSize = 100L; Map<String, Object> config = new HashMap<String, Object>(); config.put("repository.home", folder.getRoot().getAbsolutePath()); config.put(FileDataStoreService.CACHE_SIZE, cacheSize); config.put(FileDataStoreService.PATH, nasPath); config.put(FileDataStoreService.CACHE_PATH, cachePath); FileDataStoreService fdsSvc = new FileDataStoreService(); DataStore ds = fdsSvc.createDataStore(context.componentContext(), config); PropertiesUtil.populate(ds, config, false); ds.init(folder.getRoot().getAbsolutePath()); assertTrue("not instance of CachingFDS", ds instanceof CachingFileDataStore); return ds; }
@Override public NodeStore createNodeStore() { try { log.info("Creating NodeStore using " + toString()); DocumentNodeStoreBuilder<?> documentNodeStoreBuilder = DocumentNodeStoreBuilder.newDocumentNodeStoreBuilder(); File dataStoreFolder = null; BlobStore blobStore = null; DataStore dataStore = null; if (dataStoreFixture != null) { dataStore = dataStoreFixture.createDataStore(); // init with a new folder inside a temporary one dataStoreFolder = FixtureUtils.createTempFolder(); dataStore.init(dataStoreFolder.getAbsolutePath()); blobStore = new DataStoreBlobStore(dataStore); documentNodeStoreBuilder.setBlobStore(blobStore); } NodeStore nodeStore = documentNodeStoreBuilder.build(); // track all main components if (dataStore != null) { components.put(nodeStore, DataStore.class.getName(), dataStore); components.put(nodeStore, DataStore.class.getName() + ":folder", dataStoreFolder); } if (blobStore != null) { components.put(nodeStore, BlobStore.class.getName(), blobStore); } return nodeStore; } catch (IOException | RepositoryException e) { throw new AssertionError("Cannot create test repo fixture " + toString(), e); } }
/** * * Test to verify @FileDataStore is returned if cacheSize is not configured. */ @Test public void configFileDataStore() throws Exception { String nasPath = folder.getRoot().getAbsolutePath() + "/NASPath"; String cachePath = folder.getRoot().getAbsolutePath() + "/cachePath"; Map<String, Object> config = new HashMap<String, Object>(); config.put("repository.home", folder.getRoot().getAbsolutePath()); config.put(FileDataStoreService.PATH, nasPath); config.put(FileDataStoreService.CACHE_PATH, cachePath); FileDataStoreService fdsSvc = new FileDataStoreService(); DataStore ds = fdsSvc.createDataStore(context.componentContext(), config); PropertiesUtil.populate(ds, config, false); ds.init(folder.getRoot().getAbsolutePath()); assertTrue("not instance of FileDataStore", ds instanceof FileDataStore); FileDataStore fds = (FileDataStore) ds; assertEquals("path not equal", nasPath, fds.getPath()); }
dataStore.init(dataStoreFolder.getAbsolutePath());
populate(delegate, asMap(props), true); delegate.init(null);
populate(delegate, asMap(props), true); delegate.init(null);