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


Java Future.fail方法代碼示例

本文整理匯總了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;
}
 
開發者ID:pflima92,項目名稱:jspare-vertx-ms-blueprint,代碼行數:17,代碼來源:LoadBalanceServiceImpl.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: 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();
	}

}
 
開發者ID:Stwissel,項目名稱:vertx-sfdc-platformevents,代碼行數:24,代碼來源:MemoryDedup.java

示例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;
}
 
開發者ID:vert-x3,項目名稱:vertx-starter,代碼行數:17,代碼來源:TemplateService.java

示例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);
	}
}
 
開發者ID:mustertech,項目名稱:rms-deployer,代碼行數:23,代碼來源:DeployRecords.java

示例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);
}
 
開發者ID:mustertech,項目名稱:rms-deployer,代碼行數:29,代碼來源:VtxDeployer.java

示例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);
  }
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:10,代碼來源:InputStreamToReadStream.java

示例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);
}
 
開發者ID:mustertech,項目名稱:rms-deployer,代碼行數:47,代碼來源:VtxDeployer.java

示例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);
	}
}
 
開發者ID:gengteng,項目名稱:vertx-fastdfs-client,代碼行數:8,代碼來源:FdfsConnection.java

示例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);
        }
    };
}
 
開發者ID:daniel-zarzeczny,項目名稱:vertx-spring-boot-example,代碼行數:11,代碼來源:HttpServerVerticle.java

示例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;
}
 
開發者ID:danielpetisme,項目名稱:vertx-forge,代碼行數:13,代碼來源:TemplateService.java

示例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());
    }
}
 
開發者ID:Atypon-OpenSource,項目名稱:wayf-cloud,代碼行數:12,代碼來源:WayfVerticle.java

示例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");
	}
 
開發者ID:troopson,項目名稱:etagate,代碼行數:16,代碼來源:TestRequest.java

示例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;
}
 
開發者ID:vert-x3,項目名稱:vertx-starter,代碼行數:13,代碼來源:TemplateService.java

示例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;
}
 
開發者ID:vert-x3,項目名稱:vertx-starter,代碼行數:13,代碼來源:TemplateService.java


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