public String getCatalogDatabase() { return catalogDBAdaptorFactory.getCatalogDatabase(configuration.getDatabasePrefix()); }
public static Configuration load(InputStream configurationInputStream) throws IOException { return load(configurationInputStream, DEFAULT_CONFIGURATION_FORMAT); }
switch (variable) { case "OPENCGA_DB_PREFIX": configuration.setDatabasePrefix(envVariables.get(variable)); break; case "OPENCGA_USER_WORKSPACE": configuration.setDataDir(envVariables.get(variable)); break; case "OPENCGA_JOBS_DIR": configuration.setTempJobsDir(envVariables.get(variable)); break; case "OPENCGA_TOOLS_DIR": configuration.setToolDir(envVariables.get(variable)); break; case "OPENCGA_MONITOR_PORT": configuration.getMonitor().setPort(Integer.parseInt(envVariables.get(variable))); break; case "OPENCGA_EXECUTION_MODE": configuration.getExecution().setMode(envVariables.get(variable)); break; case "OPENCGA_MAIL_HOST": configuration.getEmail().setHost(envVariables.get(variable)); break; case "OPENCGA_MAIL_PORT": configuration.getEmail().setPort(envVariables.get(variable)); break; case "OPENCGA_MAIL_USER": configuration.getEmail().setUser(envVariables.get(variable)); break; case "OPENCGA_MAIL_PASSWORD":
public CatalogIOManager(String catalogConfigurationFile) throws CatalogIOException { this(); this.configuration = new Configuration(); try { this.configuration.load(new FileInputStream(catalogConfigurationFile)); } catch (IOException e) { throw new CatalogIOException("Error loading Catalog Configuration file", e); } setup(); }
JwtManager(Configuration configuration) { this.configuration = configuration; this.secretKey = this.configuration.getAdmin().getSecretKey(); this.expiration = this.configuration.getAuthentication().getExpiration(); logger = LoggerFactory.getLogger(JwtManager.class); }
@Override protected void setConfiguration(Configuration configuration) throws CatalogIOException { try { rootDir = UriUtils.createDirectoryUri(configuration.getDataDir()); } catch (URISyntaxException e) { throw new CatalogIOException("Malformed URI 'OPENCGA.CATALOG.MAIN.ROOTDIR'", e); } if (!rootDir.getScheme().equals("file")) { throw new CatalogIOException("wrong posix file system in catalog.properties: " + rootDir); } if (configuration.getTempJobsDir().isEmpty()) { jobsDir = rootDir.resolve(DEFAULT_OPENCGA_JOBS_FOLDER); } else { try { jobsDir = UriUtils.createDirectoryUri(configuration.getTempJobsDir()); } catch (URISyntaxException e) { throw new CatalogIOException("Malformed URI 'OPENCGA.CATALOG.MAIN.ROOTDIR'", e); } } if (!jobsDir.getScheme().equals("file")) { throw new CatalogIOException("wrong posix file system in catalog.properties: " + jobsDir); } }
@Before public void beforeClass() throws Exception { Configuration configuration = Configuration.load(getClass().getResource("/configuration-test.yml") .openStream()); configuration.getCatalog().getDatabase().getHosts().get(0).split(":")[0], 27017); .add("username", configuration.getCatalog().getDatabase().getUser()) .add("password", configuration.getCatalog().getDatabase().getPassword()) .add("authenticationDatabase", configuration.getCatalog().getDatabase().getOptions().get("authenticationDatabase")) .build(); if(StringUtils.isNotEmpty(configuration.getDatabasePrefix())) { if (!configuration.getDatabasePrefix().endsWith("_")) { database = configuration.getDatabasePrefix() + "_catalog"; } else { database = configuration.getDatabasePrefix() + "catalog";
@Override public void before() throws Exception { int c = 0; do { opencgaHome = Paths.get("target/test-data").resolve("junit_opencga_home_" + TimeUtils.getTimeMillis() + (c > 0 ? "_" + c : "")); c++; } while (opencgaHome.toFile().exists()); Files.createDirectories(opencgaHome); configuration = Configuration.load(getClass().getResource("/configuration-test.yml").openStream()); configuration.getAdmin().setAlgorithm("HS256"); configuration.setDataDir(opencgaHome.resolve("sessions").toUri().toString()); configuration.setTempJobsDir(opencgaHome.resolve("jobs").toUri().toString()); catalogManager = new CatalogManager(configuration); try { catalogManager.deleteCatalogDB(false); } catch (Exception ignore) {} clearCatalog(configuration); if (!opencgaHome.toFile().exists()) { deleteFolderTree(opencgaHome.toFile()); Files.createDirectory(opencgaHome); } catalogManager.installCatalogDB("dummy", "admin"); }
@Before public void setUp() throws Exception { Configuration configuration = Configuration.load(getClass().getResource("/configuration-test.yml").openStream()); configuration.getAdmin().setSecretKey("12345"); configuration.getAdmin().setAlgorithm("HS256"); jwtSessionManager = new JwtManager(configuration); testCreateJWTToken(); }
public MongoDBAdaptorFactory(Configuration catalogConfiguration) throws CatalogDBException { MongoDBConfiguration mongoDBConfiguration = MongoDBConfiguration.builder() .setUserPassword( catalogConfiguration.getCatalog().getDatabase().getUser(), catalogConfiguration.getCatalog().getDatabase().getPassword()) .load(catalogConfiguration.getCatalog().getDatabase().getOptions()) .build(); List<DataStoreServerAddress> dataStoreServerAddresses = new LinkedList<>(); for (String hostPort : catalogConfiguration.getCatalog().getDatabase().getHosts()) { if (hostPort.contains(":")) { String[] split = hostPort.split(":"); int port = Integer.valueOf(split[1]); dataStoreServerAddresses.add(new DataStoreServerAddress(split[0], port)); } else { dataStoreServerAddresses.add(new DataStoreServerAddress(hostPort, 27017)); } } this.mongoManager = new MongoDataStoreManager(dataStoreServerAddresses); this.configuration = mongoDBConfiguration; this.database = getCatalogDatabase(catalogConfiguration.getDatabasePrefix()); logger = LoggerFactory.getLogger(this.getClass()); connect(); }
private void clearCatalog() throws URISyntaxException { List<DataStoreServerAddress> dataStoreServerAddresses = new LinkedList<>(); for (String hostPort : configuration.getCatalog().getDatabase().getHosts()) { if (hostPort.contains(":")) { String[] split = hostPort.split(":"); Integer port = Integer.valueOf(split[1]); dataStoreServerAddresses.add(new DataStoreServerAddress(split[0], port)); } else { dataStoreServerAddresses.add(new DataStoreServerAddress(hostPort, 27017)); } } MongoDataStoreManager mongoManager = new MongoDataStoreManager(dataStoreServerAddresses); // MongoDataStore db = mongoManager.get(catalogConfiguration.getDatabase().getDatabase()); MongoDataStore db = mongoManager.get(getCatalogDatabase()); db.getDb().drop(); // mongoManager.close(catalogConfiguration.getDatabase().getDatabase()); mongoManager.close(getCatalogDatabase()); Path rootdir = Paths.get(UriUtils.createDirectoryUri(configuration.getDataDir())); deleteFolderTree(rootdir.toFile()); if (!configuration.getTempJobsDir().isEmpty()) { Path jobsDir = Paths.get(UriUtils.createDirectoryUri(configuration.getTempJobsDir())); if (jobsDir.toFile().exists()) { deleteFolderTree(jobsDir.toFile()); } } }
@Before public void before() throws CatalogException, IOException, URISyntaxException { Configuration configuration = Configuration.load(getClass().getResource("/configuration-test.yml") .openStream()); configuration.getAdmin().setAlgorithm("HS256"); MongoDBConfiguration mongoDBConfiguration = MongoDBConfiguration.builder() .add("username", configuration.getCatalog().getDatabase().getUser()) .add("password", configuration.getCatalog().getDatabase().getPassword()) .add("authenticationDatabase", configuration.getCatalog().getDatabase().getOptions().get("authenticationDatabase")) .build(); String[] split = configuration.getCatalog().getDatabase().getHosts().get(0).split(":"); DataStoreServerAddress dataStoreServerAddress = new DataStoreServerAddress(split[0], Integer.parseInt(split[1]));
public void initializeMetaCollection(Configuration configuration) throws CatalogException { Admin admin = configuration.getAdmin(); admin.setPassword(CatalogAuthenticationManager.cypherPassword(admin.getPassword())); Metadata metadata = new Metadata().setIdCounter(configuration.getCatalog().getOffset()).setVersion(VERSION); Document metadataObject = getMongoDBDocument(metadata, "Metadata"); metadataObject.put(PRIVATE_ID, MongoDBAdaptorFactory.METADATA_OBJECT_ID); Document adminDocument = getMongoDBDocument(admin, "Admin"); metadataObject.put("admin", adminDocument); metaCollection.insert(metadataObject, null); }
String getSecretKey() { if (StringUtils.isEmpty(secretKey)) { secretKey = configuration.getAdmin().getSecretKey(); } return secretKey; }
public void createSolrCollections() { if (catalogManager.getConfiguration().getCatalog().getSearch().getMode().equals("cloud")) { createCatalogSolrCollections(); } else { createCatalogSolrCores(); } }
public void installCatalogDB(String secretKey, String password) throws CatalogException { if (existsCatalogDB()) { throw new CatalogException("Nothing to install. There already exists a catalog database"); } ParamUtils.checkParameter(secretKey, "secretKey"); ParamUtils.checkParameter(password, "password"); configuration.getAdmin().setPassword(password); configuration.getAdmin().setSecretKey(secretKey); // Check jobs folder is empty URI jobsURI; try { jobsURI = UriUtils.createDirectoryUri(configuration.getTempJobsDir()); } catch (URISyntaxException e) { throw new CatalogException("Failed to create a directory URI from " + configuration.getTempJobsDir()); } CatalogIOManager ioManager = getCatalogIOManagerFactory().get(jobsURI); if (!ioManager.isDirectory(jobsURI) || CollectionUtils.isNotEmpty(ioManager.listFiles(jobsURI))) { throw new CatalogException("Cannot install openCGA. Jobs folder is not empty.\nPlease, empty it first."); } catalogDBAdaptorFactory.installCatalogDB(configuration); }
private static String getDefaultQueue() throws Exception { if (StringUtils.isEmpty(configuration.getExecution().getDefaultQueue())) { throw new Exception("Execution default queue is not defined!"); } return configuration.getExecution().getDefaultQueue(); }
public IndexDaemon(int interval, String sessionId, CatalogManager catalogManager, String appHome) throws URISyntaxException, CatalogIOException, CatalogDBException { super(interval, sessionId, catalogManager); this.binHome = appHome + "/bin/"; URI uri = UriUtils.createUri(catalogManager.getConfiguration().getTempJobsDir()); this.tempJobFolder = Paths.get(uri.getPath()); this.catalogIOManager = catalogManager.getCatalogIOManagerFactory().get("file"); this.jobDBAdaptor = dbAdaptorFactory.getCatalogJobDBAdaptor(); // this.variantIndexOutputRecorder = new VariantIndexOutputRecorder(catalogManager, catalogIOManager, sessionId); }
public CatalogIOManagerFactory(Configuration configuration) throws CatalogIOException { this.properties = null; this.configuration = configuration; try { mainRootdir = UriUtils.createDirectoryUri(configuration.getDataDir()); } catch (URISyntaxException e) { throw new CatalogIOException("Malformed URI 'OPENCGA.CATALOG.MAIN.ROOTDIR'", e); } String scheme = mainRootdir.getScheme(); if (scheme != null) { defaultCatalogScheme = scheme; } }
private void init(String password) throws IOException, URISyntaxException { logger = LoggerFactory.getLogger(this.getClass()); try { this.catalogManager = new CatalogManager(this.configuration); String sessionId = this.catalogManager.getUserManager().getSystemTokenForUser("admin", password); executionDaemon = new ExecutionDaemon(configuration.getMonitor().getExecutionDaemonInterval(), sessionId, catalogManager, appHome); indexDaemon = new IndexDaemon(configuration.getMonitor().getExecutionDaemonInterval(), sessionId, catalogManager, appHome); fileDaemon = new FileDaemon(configuration.getMonitor().getFileDaemonInterval(), configuration.getMonitor().getDaysToRemove(), sessionId, catalogManager); authorizationDaemon = new AuthorizationDaemon(10000, sessionId, catalogManager); executionThread = new Thread(executionDaemon, "execution-thread"); indexThread = new Thread(indexDaemon, "index-thread"); fileThread = new Thread(fileDaemon, "file-thread"); authorizationThread = new Thread(authorizationDaemon, "authorization-thread"); this.port = configuration.getMonitor().getPort(); } catch (CatalogException e) { e.printStackTrace(); } }