private Observable<DeployApplicationRequest> removeRunFile(DeployApplicationRequest deployApplicationRequest) { deployApplicationRequest.setRunning(false); return rxVertx.fileSystem().rxExists(config.getRunDir() + moduleIdToStop) .toObservable() .flatMap(exists -> { if (exists) { LOG.info("[{} - {}]: Removing runfile for application with applicationId '{}'.", LogConstants.DEPLOY_REQUEST, deployApplicationRequest.getId(), moduleIdToStop); return rxVertx.fileSystem().rxDelete(config.getRunDir() + moduleIdToStop) .toObservable() .flatMap(x -> just(deployApplicationRequest)); } else { return just(deployApplicationRequest); } }); }
Observable<DeployApplicationRequest> readServiceDefaults(DeployApplicationRequest request) { Properties serviceProperties = new Properties(); String path = deployConfig.getServiceConfigLocation() + request.getGroupId() + ":" + request.getArtifactId(); return rxVertx.fileSystem().rxExists(path) .toObservable() .filter(Boolean.TRUE::equals) .map(x -> path) .switchIfEmpty(rxVertx.fileSystem().rxExists(path.replace(":", "~")) .toObservable() .filter(Boolean.TRUE::equals)
private Observable<DeployApplicationRequest> registerApplication(DeployApplicationRequest deployApplicationRequest) { io.vertx.rxjava.core.Vertx rxVertx = new io.vertx.rxjava.core.Vertx(vertx); return rxVertx.fileSystem() .rxExists(config.getRunDir() + deployApplicationRequest.getModuleId()) .toObservable() .flatMap(exists -> { if (!exists) { return rxVertx.fileSystem().rxCreateFile(config.getRunDir() + deployApplicationRequest.getModuleId()) .toObservable() .flatMap(x -> just(deployApplicationRequest)); } else { return just(deployApplicationRequest); } }); }
/** * Download and extract Elasticsearch to a given location. If the destination * exists already this method does nothing. * @param downloadUrl the URL to the ZIP file containing Elasticsearch * @param destPath the path to the destination folder where the downloaded ZIP * file should be extracted to * @param strip <code>true</code> if the first path element of all items in the * ZIP file should be stripped away. * @return a single emitting the path to the extracted Elasticsearch */ public Single<String> download(String downloadUrl, String destPath, boolean strip) { FileSystem fs = vertx.fileSystem(); return fs.rxExists(destPath) .flatMap(exists -> { if (exists) { return Single.just(destPath); } return downloadNoCheck(downloadUrl, destPath, strip); }); }