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


Java Future.succeededFuture方法代碼示例

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


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

示例1: parseHeader

import io.vertx.core.Future; //導入方法依賴的package包/類
/**
 * 解析報文頭。
 * 
 * @param headerBuffer header Buffer
 * @param expectedCommand expectedCommand
 * @param expectedBodyLength expectedBodyLength
 * @return async result of the length of the packet body
 */
public static Future<Long> parseHeader(Buffer headerBuffer, byte expectedCommand, long expectedBodyLength) {
	if (headerBuffer.length() != HEADER_BYTE_LENGTH) {
		return Future.failedFuture(new FdfsException("receive packet size" + headerBuffer.length()
				+ " is not equal to the expected header size: " + HEADER_BYTE_LENGTH));
	}

	byte command = headerBuffer.getByte(PROTO_HEADER_CMD_INDEX);
	if (command != expectedCommand) {
		return Future.failedFuture(new FdfsException(
				"receive command: " + command + " is not equal to the expected command: " + expectedCommand));
	}

	byte status = headerBuffer.getByte(PROTO_HEADER_STATUS_INDEX);
	if (status != HEADER_STATUS_SUCCESS) {
		return Future.failedFuture(new FdfsException("receive packet errno is: " + status));
	}

	long bodyLength = headerBuffer.getLong(0);
	if (expectedBodyLength > 0 && bodyLength != expectedBodyLength) {
		return Future.failedFuture(new FdfsException("receive packet body length: " + bodyLength
				+ " is not equal to the expected: " + expectedBodyLength));
	}

	return Future.succeededFuture(bodyLength);
}
 
開發者ID:gengteng,項目名稱:vertx-fastdfs-client,代碼行數:34,代碼來源:FdfsProtocol.java

示例2: parseStorage

import io.vertx.core.Future; //導入方法依賴的package包/類
private Future<FdfsStorageOptions> parseStorage(Buffer bodyBuffer, String charset, boolean hasPathIndex) {
	try {
		FdfsStorageOptions storageOptions = new FdfsStorageOptions(options);

		String group = FdfsUtils
				.fdfsTrim(bodyBuffer.getString(0, FdfsProtocol.FDFS_GROUP_NAME_MAX_LEN, options.getCharset()));
		String ip = FdfsUtils.fdfsTrim(bodyBuffer.getString(FdfsProtocol.FDFS_GROUP_NAME_MAX_LEN,
				FdfsProtocol.FDFS_GROUP_NAME_MAX_LEN + FdfsProtocol.FDFS_IPADDR_SIZE - 1, options.getCharset()));
		long port = bodyBuffer.getLong(FdfsProtocol.FDFS_GROUP_NAME_MAX_LEN + FdfsProtocol.FDFS_IPADDR_SIZE - 1);

		storageOptions.setGroup(group).setAddress(SocketAddress.inetSocketAddress((int) port, ip));

		if (hasPathIndex && bodyBuffer.length() > FdfsProtocol.TRACKER_QUERY_STORAGE_FETCH_BODY_LEN) {
			byte storePathIndex = bodyBuffer.getByte(FdfsProtocol.TRACKER_QUERY_STORAGE_FETCH_BODY_LEN);
			storageOptions.setStorePathIndex(storePathIndex);
		}

		return Future.succeededFuture(storageOptions);
	} catch (Exception e) {
		return Future.failedFuture(e);
	}
}
 
開發者ID:gengteng,項目名稱:vertx-fastdfs-client,代碼行數:23,代碼來源:FdfsTrackerImpl.java

示例3: getAuthInfo

import io.vertx.core.Future; //導入方法依賴的package包/類
/**
 * Check for the Authentication info if required
 *
 * @return a future that resolves when successful got AuthInfo
 */
private Future<AuthInfo> getAuthInfo() {
	Future<AuthInfo> result;
	final String authName = this.getConsumerConfig().getAuthName();
	if ((this.authInfo == null) && (authName != null)) {
		result = Future.future();
		final EventBus eb = this.getVertx().eventBus();
		final String address = Constants.BUS_AUTHREQUEST + authName;
		eb.send(address, null, replyHandler -> {
			if (replyHandler.succeeded()) {
				this.authInfo = (AuthInfo) replyHandler.result().body();
				result.complete(this.authInfo);
			} else {
				result.fail(replyHandler.cause());
			}
		});

	} else {
		result = Future.succeededFuture(this.authInfo);
	}
	return result;
}
 
開發者ID:Stwissel,項目名稱:vertx-sfdc-platformevents,代碼行數:27,代碼來源:RestConsumer.java

示例4: getAuthInfo

import io.vertx.core.Future; //導入方法依賴的package包/類
private Future<AuthInfo> getAuthInfo() {
	Future<AuthInfo> result;
	if (this.authInfo == null) {
		result = Future.future();
		final EventBus eb = this.getVertx().eventBus();
		final String address = Constants.BUS_AUTHREQUEST + this.getListenerConfig().getAuthName();
		eb.send(address, null, replyHandler -> {
			if (replyHandler.succeeded()) {
				this.authInfo = (AuthInfo) replyHandler.result().body();
				result.complete(this.authInfo);
			} else {
				result.fail(replyHandler.cause());
			}
		});

	} else {
		result = Future.succeededFuture(this.authInfo);
	}
	return result;
}
 
開發者ID:Stwissel,項目名稱:vertx-sfdc-platformevents,代碼行數:21,代碼來源:CometD.java

示例5: build

import io.vertx.core.Future; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
static Future<Envelop> build(final Object returnValue) {
    if (null == returnValue) {
        // Empty Future
        return Future.succeededFuture(Envelop.ok());
    }
    final Class<?> clazz = returnValue.getClass();
    final Future<Envelop> result;
    if (Future.class.isAssignableFrom(clazz)) {
        // Fix Async Server Issue
        LOGGER.info(Info.MSG_FLOW, "Future", clazz);
        result = (Future<Envelop>) returnValue;
    } else {
        if (Envelop.class == clazz) {
            // Envelop got
            LOGGER.info(Info.MSG_FLOW, "Envelop", clazz);
            result = Future.succeededFuture((Envelop) returnValue);
        } else {
            LOGGER.info(Info.MSG_FLOW, "Other Type", clazz);
            final Envelop envelop = Envelop.success(returnValue);
            result = Future.succeededFuture(envelop);
        }
    }
    return result;
}
 
開發者ID:silentbalanceyh,項目名稱:vertx-zero,代碼行數:26,代碼來源:ReturnTransit.java

示例6: entityManagerFactory

import io.vertx.core.Future; //導入方法依賴的package包/類
Future<EntityManagerFactory> entityManagerFactory() {

      if (emf == null) {

        Future<EntityManagerFactory> f1 = Future.future();
        emfProvider.getEntityManagerFactory(datasourceName).setHandler(res -> {
          if (res.succeeded()) {
            emf = res.result();
            f1.complete(emf);
          } else {
            f1.fail(res.cause());
          }
        });
        return f1;
      }
      return Future.succeededFuture(emf);
    }
 
開發者ID:pflima92,項目名稱:vertx-jpa,代碼行數:18,代碼來源:EntityManagerProviderImpl.java

示例7: createStorage

import io.vertx.core.Future; //導入方法依賴的package包/類
private Future<FdfsStorage> createStorage(FdfsStorageOptions storageOptions) {
	return Future.succeededFuture(new FdfsStorageImpl(vertx, pool, storageOptions));
}
 
開發者ID:gengteng,項目名稱:vertx-fastdfs-client,代碼行數:4,代碼來源:FdfsTrackerImpl.java

示例8: createTracker

import io.vertx.core.Future; //導入方法依賴的package包/類
private Future<FdfsTracker> createTracker(FdfsTrackerOptions trackerOptions) {
	return Future.succeededFuture(new FdfsTrackerImpl(vertx, pool, trackerOptions));
}
 
開發者ID:gengteng,項目名稱:vertx-fastdfs-client,代碼行數:4,代碼來源:FdfsClientImpl.java

示例9: send

import io.vertx.core.Future; //導入方法依賴的package包/類
@Ipc(value = "IPC://EVENT/ADDR")
public Future<Envelop> send(final Envelop envelop) {
    final JsonObject data = envelop.data(JsonObject.class);
    data.put("role", "Terminator");
    return Future.succeededFuture(Envelop.success(data));
}
 
開發者ID:silentbalanceyh,項目名稱:vertx-zero,代碼行數:7,代碼來源:SpeakWorker.java

示例10: succeededFuture

import io.vertx.core.Future; //導入方法依賴的package包/類
public static <T> Future<T> succeededFuture()
{
    return Future.succeededFuture();
}
 
開發者ID:DavidQuan,項目名稱:vertx-ssdb,代碼行數:5,代碼來源:F.java


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