本文整理匯總了Java中io.vertx.core.Future.fail方法的典型用法代碼示例。如果您正苦於以下問題:Java Future.fail方法的具體用法?Java Future.fail怎麽用?Java Future.fail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.vertx.core.Future
的用法示例。
在下文中一共展示了Future.fail方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handleRecordList
import io.vertx.core.Future; //導入方法依賴的package包/類
protected Future<Record> handleRecordList(String alias, AsyncResult<List<Record>> resultHandler){
Future<Record> future = Future.future();
if(resultHandler.succeeded()){
// Simple LoadBalance with findAny on stream
Optional<Record> client = resultHandler.result().stream()
.filter(record -> RecordMetadata.of(record.getMetadata()).getName().equals(alias)).findAny();
if(client.isPresent()) future.complete(client.get());
else future.fail(new BusinessException(RECORD_NOT_FOUND_REASON));
}else{
future.fail(resultHandler.cause());
}
return future;
}
示例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());
}
}
示例3: checkForDuplicate
import io.vertx.core.Future; //導入方法依賴的package包/類
/**
* Actual routine that check for "duplication". Could be anything, depending on use case.
* The future fails when a duplicate is found and succeeds when it is not.
* This allows for async execution
*
* @see net.wissel.salesforce.vertx.dedup.AbstractSFDCDedupVerticle#checkForDuplicate(io.vertx.core.Future, io.vertx.core.json.JsonObject)
*/
@Override
protected void checkForDuplicate(final Future<Void> failIfDuplicate, final JsonObject messageBody) {
final String candidate = messageBody.encode();
if (this.memoryQueue.contains(candidate)) {
// We have a duplicate and fail the future
failIfDuplicate.fail("Duplicate");
} else {
this.memoryQueue.offer(candidate);
// Limit the size of the queue
while (this.memoryQueue.size() > MAX_MEMBERS) {
this.memoryQueue.poll();
}
failIfDuplicate.complete();
}
}
示例4: getPath
import io.vertx.core.Future; //導入方法依賴的package包/類
private Future<Path> getPath(String filename) {
Future future = Future.future();
URL url = getClass().getResource(filename);
if (url.getProtocol().startsWith("jar")) {
try {
Path path = getPathInJar(filename);
future.complete(path);
} catch (IOException e) {
e.printStackTrace();
future.fail(e);
}
} else {
future.complete(Paths.get(filename));
}
return future;
}
示例5: getRecord
import io.vertx.core.Future; //導入方法依賴的package包/類
/**
* Method to get deployment details corresponding to a component identifier
*
* @param id Component identifier
* @param future Future to provide the record
* @see <a href="http://vertx.io/docs/apidocs/io/vertx/core/Future.html" target="_blank">Future</a>
*/
void getRecord(final String id, Future<JsonObject> future) {
if (null == localRecords) {
getClusterRecord(id, future);
return;
}
String recStr = localRecords.get(id);
if (null == recStr) {
future.fail("Record not found!");
} else {
JsonObject record = new JsonObject(recStr);
future.complete(record);
}
}
示例6: deployAll
import io.vertx.core.Future; //導入方法依賴的package包/類
/**
* Deploys the list of local and/or remote components
*
* @param future Vert.x Future object to update the status of deployment
* @see <a href="http://vertx.io/docs/apidocs/io/vertx/core/Future.html" target="_blank">Future</a>
*/
public void deployAll(Future<Void> future) {
if (null == this.vertx) {
String errMesg = "Not setup yet! Call 'setup' method first.";
logger.error(errMesg);
future.fail(new Exception(errMesg));
return;
}
JsonArray compList = this.deployConfig.getJsonArray("components");
List<DeployComponent> components = new ArrayList<>();
int listLen = compList.size();
JsonObject deployConf;
for (int idx = 0; idx < listLen; idx++) {
deployConf = compList.getJsonObject(idx);
components.add(this.setupComponent(deployConf));
}
this.deployRecords.deployAll(components, future);
}
示例7: 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);
}
}
示例8: deploy
import io.vertx.core.Future; //導入方法依賴的package包/類
/**
* Deploy a component with given JSON configuration
*
* @param deployConfig Json configuration corresponding to a component to be deployed
* @param future Future to provide the status of deployment
* @see <a href="http://vertx.io/docs/apidocs/io/vertx/core/Future.html" target="_blank">Future</a>
*/
public void deploy(JsonObject deployConfig, Future<Boolean> future) {
if (null == this.vertx) {
String errMesg = "Not setup yet! Call 'setup' method first.";
logger.error(errMesg);
future.fail(new Exception(errMesg));
return;
}
try {
Schema jsonSchema = BaseUtil.schemaFromResource("/deploy-opts-schema.json");
String jsonData = deployConfig.toString();
BaseUtil.validateData(jsonSchema, jsonData);
} catch (ValidationException vldEx) {
logger.error("Issue with deployment configuration validation!", vldEx);
vldEx
.getCausingExceptions()
.stream()
.map(ValidationException::getMessage)
.forEach((errMsg) -> {
logger.error(errMsg);
});
future.fail(vldEx);
return;
} catch (IOException ioEx) {
logger.error("Issue while loading schema configuration!", ioEx);
future.fail(ioEx);
return;
}
DeployComponent component = this.setupComponent(deployConfig);
this.deployRecords.deploy(component.getIdentifier(), component.getDeployOpts(), future);
}
示例9: cleanPending
import io.vertx.core.Future; //導入方法依賴的package包/類
private void cleanPending(Throwable e) {
Future<FdfsConnection> future = null;
while ((future = pending.poll()) != null) {
future.fail(e);
}
}
示例10: serverStartHandler
import io.vertx.core.Future; //導入方法依賴的package包/類
private Handler<AsyncResult<HttpServer>> serverStartHandler(final Future<Void> startFuture) {
return onComplete -> {
if (onComplete.succeeded()) {
startFuture.complete();
} else {
startFuture.fail(onComplete.cause());
System.exit(0);
}
};
}
示例11: 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;
}
示例12: 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());
}
}
示例13: test
import io.vertx.core.Future; //導入方法依賴的package包/類
@Test
public void test(TestContext context) throws InterruptedException {
Future<String> f =Future.future();
f.fail("aaa");
f.setHandler(res->{
if(res.failed())
System.out.println("failed...");
else
System.out.println("ok....");
});
// async.awaitSuccess();
System.out.println("end");
}
示例14: 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;
}
示例15: copyFileFromJar
import io.vertx.core.Future; //導入方法依賴的package包/類
private Future<String> copyFileFromJar(String jarPath, String filename, String destination) {
log.debug("Copying {} from jar {} to {}", filename, jarPath, destination);
Future future = Future.future();
try (FileSystem jarfs = FileSystems.newFileSystem(URI.create(jarPath), new HashMap<>())) {
Files.copy(jarfs.getPath(filename), Paths.get(destination));
future.complete(filename);
} catch (IOException e) {
log.error("Impossible to copy file {} from jar {} to {}: {}", filename, jarPath, destination, e.getMessage());
future.fail(e);
}
return future;
}