本文整理匯總了Java中org.vertx.java.core.AsyncResult類的典型用法代碼示例。如果您正苦於以下問題:Java AsyncResult類的具體用法?Java AsyncResult怎麽用?Java AsyncResult使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
AsyncResult類屬於org.vertx.java.core包,在下文中一共展示了AsyncResult類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getResidualRepositorySize
import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
private void getResidualRepositorySize(final Handler<Long> handler) {
storage.stats(new AsyncResultHandler<BucketStats>() {
@Override
public void handle(AsyncResult<BucketStats> event) {
Long residualRepositorySize = 0L;
if (event.succeeded()) {
final Long sizeUsed = event.result().getStorageSize();
final Long residualRepository = ShareBigFilesController.this.maxRepositoryQuota - sizeUsed;
residualRepositorySize = (residualRepository < 0) ? 0L : residualRepository;
} else {
log.error("Can't get the repository stats : ", event.cause());
}
handler.handle(residualRepositorySize);
}
});
}
示例2: testDeployment
import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
@Test
public void testDeployment() throws InterruptedException {
JsonObject config = createBaseConfig();
config.putString(CONF_KEY_LOCAL_ADDRESS, LOCAL_ADDRESS);
container.deployWorkerVerticle(Activator.class.getName(), config, 3, false,
new AsyncResultHandler<String>() {
@Override
public void handle(final AsyncResult<String> ar) {
if (ar.succeeded()) {
initActivator(ar.result());
} else {
m_logger.error("Failed to deploy verticle: {}", ar.cause());
Assert.fail();
}
}
}
);
vertx.setPeriodic(1500L, this); // Generate events once every 500 ms
}
示例3: handle
import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
@Override
public void handle(final Long timerId) {
final FileSystem fs = m_fileSystem;
final List<Path> paths = m_paths; // file paths
for (final Path path : paths) {
m_logger.trace("Inspecting file: {}", path);
// Check that file exists before proceeding further...
if (Files.exists(path)) {
fs.props(path.toString(), new AsyncResultHandler<FileProps>() {
@Override
public void handle(final AsyncResult<FileProps> ar) {
handleFileProps(ar, path);
}
});
}
}
}
示例4: testSqlView
import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
@Test
public void testSqlView() throws ResourceException {
vertx.eventBus().registerLocalHandler(FILTER_DEST_ADDRESS, this);
JsonObject config = createBaseConfig();
config.mergeIn(loadSqlConfig(config));
// Update interval (how often to read the database)
config.putNumber(CONF_KEY_UPDATE_INTERVAL, 500L);
m_logger.info("Update interval: {}", config.getLong(CONF_KEY_UPDATE_INTERVAL));
container.deployWorkerVerticle(Sql.class.getName(), config, 1, false,
new AsyncResultHandler<String>() {
@Override
public void handle(final AsyncResult<String> ar) {
if (ar.failed()) {
m_logger.error("Failed to deploy verticle", ar.cause());
Assert.fail();
}
}
});
}
示例5: execOutputCommand
import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
private void execOutputCommand(final JsonObject config) {
container.deployVerticle(Command.class.getName(), config, 1,
new AsyncResultHandler<String>() {
@Override
public void handle(final AsyncResult<String> ar) {
if (ar.succeeded()) {
// Emit event
JsonObject event = EventCreator.create("Command");
vertx.eventBus().publish(EVENT_SRC_ADDRESS, event);
//
// Stop test
//
VertxAssert.testComplete();
} else {
m_logger.error("Failed to deploy verticle", ar.cause());
Assert.fail();
}
}
});
}
示例6: execute
import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
@Override
public void execute(final Message message) {
// Call verticle undeploy method
JsonArray args = getArgs();
final String verticle = (String) args.get(0);
m_executor.undeployVerticle(
verticle,
new Handler<AsyncResult<Void>>() {
@Override
public void handle(AsyncResult<Void> ar) {
if (ar.failed()) {
m_logger.error("Failed to undeploy verticle: {}",
verticle, ar.cause());
message.reply(Commands.result(
ERR_UNDEPLOY_FAILED,
REASON_UNDEPLOY_FAILED + ar.cause()));
} else {
message.reply(RESULT_OK);
}
}
}
);
}
示例7: handle
import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
@Override
public void handle(AsyncResult<String> ar) {
if (ar.succeeded()) {
String deploymentId = ar.result();
m_logger.debug("Deployment identifier: {}", deploymentId);
m_modules.put(m_groupArtifactId,
new Module(
m_groupArtifactId,
m_artifactVersion,
m_localAddress,
deploymentId)
);
m_latch.countDown();
} else {
throw new RuntimeException("Failed to deploy module: "
+ m_moduleId, ar.cause());
}
}
示例8: testCommand
import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
@Test
public void testCommand() throws InterruptedException {
JsonObject config = new JsonObject();
config.putValue(CONF_KEY_HOME_PATH, ".");
config.putValue(CONF_KEY_CONF_PATH, ".");
config.putValue(CONF_KEY_DATA_PATH, ".");
config.putValue(CONF_KEY_TMP_PATH, ".");
config.putValue(CONF_KEY_LOCAL_ADDRESS, LOCAL_ADDRESS);
container.deployWorkerVerticle(Activator.class.getName(), config, 1, false,
new AsyncResultHandler<String>() {
@Override
public void handle(final AsyncResult<String> ar) {
if (ar.failed()) {
Assert.fail("Failed to deploy verticle: " + ar.cause());
} else {
initActivator(ar.result());
}
}
});
}
示例9: testActivator
import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
@Test
public void testActivator() {
JsonObject config = createBaseConfig();
container.deployWorkerVerticle(Activator.class.getName(), config, 1, false,
new AsyncResultHandler<String>() {
@Override
public void handle(final AsyncResult<String> ar) {
if (ar.succeeded()) {
// Stop test
VertxAssert.testComplete();
} else {
m_logger.error("Failed to deploy verticle", ar.cause());
Assert.fail();
}
}
});
}
示例10: startServer
import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
/**
* Start an embedded HTTP server
*
* @param activeProfilers The active profilers
* @param port The port on which to bind the server
*/
public static void startServer(final Map<String, ScheduledFuture<?>> runningProfilers, final Map<String, Profiler> activeProfilers, final int port, final AtomicReference<Boolean> isRunning, final List<String> errors) {
final HttpServer server = VERTX.createHttpServer();
server.requestHandler(RequestHandler.getMatcher(runningProfilers, activeProfilers, isRunning, errors));
server.listen(port, new Handler<AsyncResult<HttpServer>>() {
@Override
public void handle(AsyncResult<HttpServer> event) {
if (event.failed()) {
server.close();
startServer(runningProfilers, activeProfilers, port + 1, isRunning, errors);
} else if (event.succeeded()) {
LOGGER.info("Profiler server started on port " + port);
}
}
});
}
示例11: start
import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
@Override
public void start(final Future<Void> startedResult) {
container.deployVerticle("net.zyclonite.vertx.NetSocketVerticle", new AsyncResultHandler<String>() {
public void handle(AsyncResult<String> deployResult) {
if (deployResult.succeeded()) {
startedResult.setResult(null);
} else {
startedResult.setFailure(deployResult.cause());
}
}
});
container.deployVerticle("net.zyclonite.vertx.HttpVerticle");
container.deployVerticle("net.zyclonite.vertx.WebSocketVerticle");
container.deployVerticle("JavaScriptVerticle.js");
container.deployVerticle("ClosureVerticle.clj");
}
示例12: read
import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
@Override
public void read(String src, final Handler<ImageFile> handler) {
String [] path = parsePath(src);
if (path == null || path.length != 2) {
handler.handle(null);
return;
}
client.readFile(path[1], path[0], new AsyncResultHandler<StorageObject>() {
@Override
public void handle(AsyncResult<StorageObject> event) {
if (event.succeeded()) {
StorageObject f = event.result();
handler.handle(new ImageFile(
f.getBuffer().getBytes(),
f.getFilename(),
f.getContentType()
));
} else {
handler.handle(null);
}
}
});
}
示例13: write
import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
@Override
public void write(String dest, ImageFile img, final Handler<String> handler) {
String [] path = parsePath(dest);
if (path == null || path.length < 1) {
handler.handle(null);
return;
}
StorageObject o;
if (path.length == 2 && path[1] != null && !path[1].trim().isEmpty()) {
o = new StorageObject(path[1], new Buffer(img.getData()),
img.getFilename(), img.getContentType());
} else {
o = new StorageObject(new Buffer(img.getData()),
img.getFilename(), img.getContentType());
}
client.writeFile(o, path[0], new AsyncResultHandler<String>() {
@Override
public void handle(AsyncResult<String> event) {
if (event.succeeded()) {
handler.handle(event.result());
} else {
handler.handle(null);
}
}
});
}
示例14: handle
import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
/**
* Handle the event bus reply.
*
* @param event The event
*/
@Override
public void handle(final AsyncResult<Message<Object>> event) {
EventBusBridgeResponse response = new EventBusBridgeResponse();
response.setSuccessful(event.succeeded());
response.setAddress(address);
if (event.succeeded()) {
Message<Object> result = event.result();
Object responseMessage = result.body();
response.setResponseMessage(EventBusMessageTypeConverter.convertOutgoingMessage(result.body()));
response.setEventBusMessageType(EventBusMessageType.lookupByClass(responseMessage.getClass()));
} else {
Throwable cause = event.cause();
if (cause != null) {
if (cause instanceof ReplyException) {
ReplyException replyException = (ReplyException) cause;
response.setCause(replyException.failureType().name());
} else {
response.setCause(cause.getMessage());
}
}
}
postResponse(response);
}
示例15: start
import org.vertx.java.core.AsyncResult; //導入依賴的package包/類
@Override
public void start(final Future<Void> startedResult) {
try {
InputStream input = MessageSendWithReplyTest.class.getResourceAsStream("/config/integration-test-config.json");
String configString;
configString = IOUtils.toString(input, Charset.defaultCharset());
config = new JsonObject(configString);
url = HttpRequestHelper.constructUrlStringFromConfig(config, EventBusInstruction.send);
System.out.println("URL: " + url);
container.deployVerticle(JerseyModule.class.getName(), config, new Handler<AsyncResult<String>>() {
public void handle(AsyncResult<String> event) {
if (event.succeeded()) {
startedResult.setResult(null);
MessageSendWithReplyTest.super.start();
} else {
startedResult.setFailure(event.cause());
}
}
});
} catch (IOException e) {
startedResult.setFailure(e);
}
}