public void stop() { int port = configuration.getServer().getRest(); if (restServerCommandOptions.port > 0) { port = restServerCommandOptions.port; } Client client = ClientBuilder.newClient(); WebTarget target = client.target("http://localhost:" + port) .path("opencga") .path("webservices") .path("rest") .path("admin") .path("stop"); Response response = target.request().get(); logger.info(response.toString()); }
public RestStorageServer(StorageConfiguration storageConfiguration) { super(storageConfiguration.getServer().getRest(), storageConfiguration.getDefaultStorageEngineId()); RestStorageServer.storageConfiguration = storageConfiguration; logger = LoggerFactory.getLogger(this.getClass()); }
public GrpcStorageServer(StorageConfiguration storageConfiguration) { super(storageConfiguration.getServer().getGrpc(), storageConfiguration.getDefaultStorageEngineId()); GrpcStorageServer.storageConfiguration = storageConfiguration; logger = LoggerFactory.getLogger(this.getClass()); }
public GenericGrpcService(StorageConfiguration storageConfiguration, String defaultStorageEngine) { privLogger = LoggerFactory.getLogger("org.opencb.opencga.storage.server.grpc.GenericGrpcService"); logger = LoggerFactory.getLogger(this.getClass()); this.storageConfiguration = storageConfiguration; this.defaultStorageEngine = defaultStorageEngine; // Only one StorageManagerFactory is needed, this acts as a simple Singleton pattern which improves the performance significantly if (storageEngineFactory == null) { privLogger.debug("Creating the StorageManagerFactory object"); // TODO: We will need to pass catalog manager once storage starts doing things over catalog storageEngineFactory = StorageEngineFactory.get(storageConfiguration); } if (authorizedHosts == null) { privLogger.debug("Creating the authorizedHost HashSet"); authorizedHosts = new HashSet<>(storageConfiguration.getServer().getAuthorizedHosts()); } try { if (StringUtils.isNotEmpty(storageConfiguration.getServer().getAuthManager())) { privLogger.debug("Loading AuthManager in {} from {}", this.getClass(), storageConfiguration.getServer().getAuthManager()); authManager = (AuthManager) Class.forName(storageConfiguration.getServer().getAuthManager()).newInstance(); } else { privLogger.debug("Loading DefaultAuthManager in {} from {}", this.getClass(), DefaultAuthManager.class); authManager = new DefaultAuthManager(); } } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { e.printStackTrace(); } }
public GrpcStorageServer() { this(storageConfiguration.getServer().getGrpc(), storageConfiguration.getDefaultStorageEngineId()); }
public RestStorageServer() { this(storageConfiguration.getServer().getGrpc(), storageConfiguration.getDefaultStorageEngineId()); }
public AbstractStorageServer() { this(storageConfiguration.getServer().getGrpc(), storageConfiguration.getDefaultStorageEngineId()); }
authorizedHosts = new HashSet<>(storageConfiguration.getServer().getAuthorizedHosts());
public void start() throws Exception { StorageConfiguration storageConfiguration = configuration; if (StringUtils.isNotEmpty(restServerCommandOptions.commonOptions.configFile)) { Path path = Paths.get(restServerCommandOptions.commonOptions.configFile); if (Files.exists(path)) { storageConfiguration = StorageConfiguration.load(Files.newInputStream(path)); } } // Setting CLI params in the StorageConfiguration if (restServerCommandOptions.port > 0) { storageConfiguration.getServer().setRest(restServerCommandOptions.port); } if (StringUtils.isNotEmpty(restServerCommandOptions.commonOptions.storageEngine)) { storageConfiguration.setDefaultStorageEngineId(restServerCommandOptions.commonOptions.storageEngine); } if (StringUtils.isNotEmpty(restServerCommandOptions.authManager)) { storageConfiguration.getServer().setAuthManager(restServerCommandOptions.authManager); } // Server crated and started RestStorageServer server = new RestStorageServer(storageConfiguration); server.start(); server.blockUntilShutdown(); logger.info("Shutting down OpenCGA Storage REST server"); }
public void stop() throws InterruptedException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { String storageEngine = "mongodb"; GenericServiceModel.Request request = GenericServiceModel.Request.newBuilder() .setStorageEngine(storageEngine) .build(); // Connecting to the server host and port String grpcServerHost = "localhost"; int grpcServerPort = configuration.getServer().getGrpc(); if (grpcServerCommandOptions.port > 0) { grpcServerPort = grpcServerCommandOptions.port; } logger.debug("Stopping gRPC server at '{}:{}'", grpcServerHost, grpcServerPort); // We create the gRPC channel to the specified server host and port ManagedChannel channel = ManagedChannelBuilder.forAddress(grpcServerHost, grpcServerPort) .usePlaintext(true) .build(); // We use a blocking stub to execute the query to gRPC AdminServiceGrpc.AdminServiceBlockingStub adminServiceBlockingStub = AdminServiceGrpc.newBlockingStub(channel); GenericServiceModel.MapResponse stop = adminServiceBlockingStub.stop(request); Map<String, String> values = stop.getValues(); System.out.println(values); channel.shutdown().awaitTermination(2, TimeUnit.SECONDS); }