當前位置: 首頁>>代碼示例>>Java>>正文


Java Future.complete方法代碼示例

本文整理匯總了Java中io.vertx.core.Future.complete方法的典型用法代碼示例。如果您正苦於以下問題:Java Future.complete方法的具體用法?Java Future.complete怎麽用?Java Future.complete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.vertx.core.Future的用法示例。


在下文中一共展示了Future.complete方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: undeployWebSocketVerticle

import io.vertx.core.Future; //導入方法依賴的package包/類
private Future<String> undeployWebSocketVerticle() {
	Future<String> future = Future.future();
	if(ws_id == null){
		future.complete();
	} else {
		vertx.undeploy(ws_id, res -> {
			  if (res.succeeded()) {
					  ws_id = null;
					  System.out.println("WebsocketVerticle undeployed");
					  future.complete();
				  } else {
					  System.err.println("WebsocketVerticle Undeployment failed: " + res.cause().getMessage()); 
					  future.fail(res.cause());
				  }
		});
	}
	return future;
}
 
開發者ID:AlxGDev,項目名稱:BittrexGatherer,代碼行數:19,代碼來源:BittrexVerticle.java

示例2: resultOfAuthentication

import io.vertx.core.Future; //導入方法依賴的package包/類
private void resultOfAuthentication(final AsyncResult<HttpResponse<Buffer>> postReturn,
		final Future<AuthInfo> futureAuthinfo) {
	if (postReturn.succeeded()) {
		// Get session info
		final Buffer body = postReturn.result().body();
		final AuthInfo a = this.extractAuthInfoFromBody(body);
		if (a != null) {
			this.setCachedAuthInfo(a);
			futureAuthinfo.complete(a);
		} else {
			futureAuthinfo.fail("Authentication phase failed, please check log");
		}
	} else {
		futureAuthinfo.fail(postReturn.cause());
	}
}
 
開發者ID:Stwissel,項目名稱:vertx-sfdc-platformevents,代碼行數:17,代碼來源:SoapApi.java

示例3: importBlocks

import io.vertx.core.Future; //導入方法依賴的package包/類
private Future<Void> importBlocks(StorableBlock block) {
    Future<Void> future = Future.future();

    if (config.isTxImport()) {
        listener.onQueueChanged(queue.incrementAndGet());

        storage.put(block, done -> {
            if (done.succeeded()) {
                if (!config.isTxImport()) {
                    listener.onImported(block.getHash(), block.getNumber());
                }
                future.complete();
            } else {
                future.fail(done.cause());
            }
            listener.onQueueChanged(queue.decrementAndGet());
        });
    } else {
        future.complete();
    }
    return future;
}
 
開發者ID:codingchili,項目名稱:ethereum-ingest,代碼行數:23,代碼來源:BlockService.java

示例4: readInWorker

import io.vertx.core.Future; //導入方法依賴的package包/類
private synchronized void readInWorker(Future<ReadResult> future) {
  try {
    ReadResult readResult = new ReadResult();
    readResult.doRead();
    future.complete(readResult);
  } catch (Throwable e) {
    future.fail(e);
  }
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:10,代碼來源:InputStreamToReadStream.java

示例5: completeStartup

import io.vertx.core.Future; //導入方法依賴的package包/類
private void completeStartup(AsyncResult<HttpServer> http, Future<Void> fut) {
    if (http.succeeded()) {
        initConfigs();

        LOG.info("SUCCESS: wayf-cloud successfully initialized");
        fut.complete();
    } else {
        LOG.debug("FAILURE: Could not start wayf-cloud due to exception", http.cause());
        fut.fail(http.cause());
    }
}
 
開發者ID:Atypon-OpenSource,項目名稱:wayf-cloud,代碼行數:12,代碼來源:WayfVerticle.java

示例6: init

import io.vertx.core.Future; //導入方法依賴的package包/類
/**
 * Method to initialize the object so that it can handle deployment and undeployment of components
 *
 * @param isClustered Whether cluster mode is opted
 * @param future      Future to provide the status of initialization
 * @see <a href="http://vertx.io/docs/apidocs/io/vertx/core/Future.html" target="_blank">Future</a>
 */
void init(Boolean isClustered, Future<Boolean> future) {
	if (isInitialized()) {
		future.complete(false);
		return;
	}

	if (isClustered) {
		sharedData.getLock(RECORDS_LOCK_NAME, lockRes -> {
			if (lockRes.succeeded()) {
				Lock asyncLock = lockRes.result();

				sharedData.<String, String>getClusterWideMap(RECORDS_MAP_NAME, mapRes -> {
					if (mapRes.succeeded()) {
						clusterRecords = mapRes.result();
						future.complete(true);
					} else {
						future.fail(mapRes.cause());
					}

					asyncLock.release();
				});
			} else {
				future.fail(lockRes.cause());
			}
		});

		return;
	}

	localRecords = sharedData.getLocalMap(RECORDS_MAP_NAME);
	future.complete(true);
}
 
開發者ID:mustertech,項目名稱:rms-deployer,代碼行數:40,代碼來源:DeployRecords.java

示例7: render

import io.vertx.core.Future; //導入方法依賴的package包/類
public Future<String> render(String template, JsonObject object) {
    Context context = Context.newBuilder(object.getMap()).resolver(MapValueResolver.INSTANCE).build();
    log.debug("Rendering template {} with object {}", object);
    Future future = Future.future();
    try {
        future.complete(handlebars.compile(template).apply(context));
    } catch (IOException e) {
        log.error("Impossible to render template {}: ", template, e.getMessage());
        future.fail(e.getCause());
    }
    return future;
}
 
開發者ID:danielpetisme,項目名稱:vertx-forge,代碼行數:13,代碼來源:TemplateService.java

示例8: render

import io.vertx.core.Future; //導入方法依賴的package包/類
public Future<String> render(String template, String destination, JsonObject object) {
  Context context = Context.newBuilder(object.getMap()).resolver(MapValueResolver.INSTANCE).build();
  log.debug("Rendering template {} with object {}", object);
  Future future = Future.future();
  try {
    future.complete(writeFile(destination, handlebars.compile(template).apply(context)));
  } catch (IOException e) {
    log.error("Impossible to render template {}: ", template, e);
    future.fail(e.getCause());
  }
  return future;
}
 
開發者ID:vert-x3,項目名稱:vertx-starter,代碼行數:13,代碼來源:TemplateService.java

示例9: stopListening

import io.vertx.core.Future; //導入方法依賴的package包/類
@Override
public SFDCVerticle stopListening(final Future<Void> stopListenFuture) {
	this.logger.info("Stop listening:" + this.getClass().getName());
	this.listening = false;
	if (this.dedupConsumer == null) {
		stopListenFuture.complete();
	} else {
		this.dedupConsumer.unregister(res -> {
			stopListenFuture.complete();
		});
	}
	return this;
}
 
開發者ID:Stwissel,項目名稱:vertx-sfdc-platformevents,代碼行數:14,代碼來源:AbstractSFDCDedupVerticle.java

示例10: close

import io.vertx.core.Future; //導入方法依賴的package包/類
void close(Handler<AsyncResult<Void>> completionHandler) {
  synchronized (vertx) {
    if (--refCount == 0) {
      Future<Void> f1 = Future.future();
      Future<Void> f2 = Future.future();
      if (completionHandler != null) {
        CompositeFuture.all(f1, f2).<Void>map(f -> null).setHandler(completionHandler);
      }
      if (emf != null) {
        vertx.executeBlocking(future -> {
          emf.close();
          future.complete();
        }, f2.completer());
      } else {
        f2.complete();
      }
      try {
        if (exec != null) {
          exec.shutdown();
        }
        if (map != null) {
          map.remove(name);
          if (map.isEmpty()) {
            map.close();
          }
        }
        f1.complete();
      } catch (Throwable t) {
        f1.fail(t);
      }
    } else {
      if (completionHandler != null) {
        completionHandler.handle(Future.succeededFuture());
      }
    }
  }
}
 
開發者ID:pflima92,項目名稱:vertx-jpa,代碼行數:38,代碼來源:EntityManagerProviderImpl.java

示例11: count

import io.vertx.core.Future; //導入方法依賴的package包/類
/**
 * Get the count of currently deployed components
 *
 * @param future Future to provide the count of deployed components
 * @see <a href="http://vertx.io/docs/apidocs/io/vertx/core/Future.html" target="_blank">Future</a>
 */
void count(Future<Integer> future) {
	if (!isInitialized()) {
		future.fail("DeployRecords should be initialized before using it!");
		return;
	}

	if (null == localRecords) {
		sharedData.getLock(RECORDS_LOCK_NAME, lockRes -> {
			if (lockRes.succeeded()) {
				Lock asyncLock = lockRes.result();

				clusterRecords.size(sizeRes -> {
					if (sizeRes.succeeded()) {
						future.complete(sizeRes.result());
					} else {
						future.fail(sizeRes.cause());
					}

					asyncLock.release();
				});
			} else {
				future.fail(lockRes.cause());
			}
		});

		return;
	}

	future.complete(Integer.valueOf(localRecords.size()));
}
 
開發者ID:mustertech,項目名稱:rms-deployer,代碼行數:37,代碼來源:DeployRecords.java

示例12: get

import io.vertx.core.Future; //導入方法依賴的package包/類
public Future<FdfsConnection> get() {
	Future<FdfsConnection> future = Future.future();

	switch (state.get()) {
	case RESERVED:
		pending.add(future);
		break;
	case CONNECTING:
		pending.add(future);
		break;
	case CONNECTED:
		if (this.state.compareAndSet(State.CONNECTED, State.RESERVED)) {
			future.complete(this);
		} else {
			pending.add(future);
		}
		break;
	case DISCONNECTED:
		connect(ar -> {
			if (ar.succeeded()) {
				if (this.state.get() == State.CONNECTED) {
					completeFuture(future);
				} else {
					pending.add(future);
				}
			} else {
				future.fail(ar.cause());
			}
		});
		break;
	default:
		break;
	}

	return future;
}
 
開發者ID:gengteng,項目名稱:vertx-fastdfs-client,代碼行數:37,代碼來源:FdfsConnection.java

示例13: teardown

import io.vertx.core.Future; //導入方法依賴的package包/類
/**
 * Unset / cleanup the deployer completely, by undeploying the components and closing the vert.x instance.
 * You should run 'setup' again, in order to reuse the instance.
 *
 * @param future Vert.x Future object to update the termination status
 * @see <a href="http://vertx.io/docs/apidocs/io/vertx/core/Future.html" target="_blank">Future</a>
 */
public void teardown(Future<Void> future) {
	if (null == this.vertx) {
		logger.warn("Not setup yet! Call 'setup' method first.");
		future.complete();

		return;
	}

	Future<Integer> countFuture = Future.future();

	countFuture.setHandler(sizeRes -> {
		if (sizeRes.succeeded()) {
			if (0 < sizeRes.result()) {
				Future<Void> undeployFuture = Future.future();

				undeployFuture.setHandler(asyncRes -> {
					if (asyncRes.succeeded()) {
						this.closeVertx(future);
					} else {
						future.fail(asyncRes.cause());
					}
				});

				this.undeployAll(undeployFuture);
			} else {
				this.closeVertx(future);
			}
		} else {
			future.fail(sizeRes.cause());
		}
	});

	this.deployRecords.count(countFuture);
}
 
開發者ID:mustertech,項目名稱:rms-deployer,代碼行數:42,代碼來源:VtxDeployer.java

示例14: stopListening

import io.vertx.core.Future; //導入方法依賴的package包/類
@Override
public SFDCVerticle stopListening(final Future<Void> stopListenFuture) {
	this.logger.info("Stop listening:" + this.getClass().getName());
	this.listening = false;
	if (this.consumer == null) {
		stopListenFuture.complete();
	} else {
		this.consumer.unregister(res -> {
			stopListenFuture.complete();
		});
	}
	return this;
}
 
開發者ID:Stwissel,項目名稱:vertx-sfdc-platformevents,代碼行數:14,代碼來源:AbstractSFDCConsumer.java

示例15: startWebServer

import io.vertx.core.Future; //導入方法依賴的package包/類
/**
 * Loading of the API & WEB UI to provide a minimal Admin GUI to watch the
 * system. WIP
 */
private void startWebServer(final Future<Void> startFuture) {

	// Sanitize the parameters and capture cookies / headers
	// TODO:
	// this.router.route().handler(RequestSanitizer.create(this.vertx));

	final String apiRoute = this.config().getString(Constants.API_ROOT, Constants.API_ROOT);

	// API route
	this.router.route(apiRoute).handler(this::rootHandler);

	// API Routes
	this.setupRouteSecurity(this.router);

	// To be able to access the request body
	this.router.route(apiRoute + "/*").handler(BodyHandler.create());

	// TODO: Deal with failures
	// this.router.route(apiRoute +
	// "/*").failureHandler(this::failureHandler);

	// Allow shutdown with a proper authorized request
	this.router.post(apiRoute + "/shutdown").handler(this::shutdownHandler);

	// Static pages
	this.router.route().handler(StaticHandler.create());

	// Launch the server
	this.logger.info("Listening on port " + Integer.toString(this.appConfig.port));
	this.vertx.createHttpServer().requestHandler(this.router::accept).listen(this.appConfig.port);

	// Finally done
	startFuture.complete();
}
 
開發者ID:Stwissel,項目名稱:vertx-sfdc-platformevents,代碼行數:39,代碼來源:ApplicationStarter.java


注:本文中的io.vertx.core.Future.complete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。