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


Java Buffer.getLong方法代碼示例

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


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

示例1: parseHeader

import io.vertx.core.buffer.Buffer; //導入方法依賴的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.buffer.Buffer; //導入方法依賴的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


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