本文整理汇总了Java中org.elasticsearch.common.io.stream.BytesStreamOutput.writeLong方法的典型用法代码示例。如果您正苦于以下问题:Java BytesStreamOutput.writeLong方法的具体用法?Java BytesStreamOutput.writeLong怎么用?Java BytesStreamOutput.writeLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.common.io.stream.BytesStreamOutput
的用法示例。
在下文中一共展示了BytesStreamOutput.writeLong方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: publishClusterStateVersionToNode
import org.elasticsearch.common.io.stream.BytesStreamOutput; //导入方法依赖的package包/类
public void publishClusterStateVersionToNode(final long newVersion,
final DiscoveryNode node,
final TimeValue publishTimeout,
final BlockingClusterStatePublishResponseHandler publishResponseHandler) {
try {
BytesStreamOutput bStream = new BytesStreamOutput();
bStream.writeLong(newVersion);
clusterService.localNode().writeTo(bStream);
bStream.writeString(node.getId());
BytesReference nodeBytes = bStream.bytes();
TransportRequestOptions options = TransportRequestOptions.builder().withType(TransportRequestOptions.Type.STATE).withCompress(false).withTimeout(publishTimeout).build();
transportService.sendRequest(node, PUBLISH_VERSION_ACTION_NAME, new BytesTransportRequest(nodeBytes, node.version()),
options,
new EmptyTransportResponseHandler(ThreadPool.Names.SAME) {
@Override
public void handleResponse(TransportResponse.Empty response) {
publishResponseHandler.onResponse(node);
}
@Override
public void handleException(TransportException exp) {
logger.debug("failed to send cluster state to {}, version {}", exp, node, newVersion);
publishResponseHandler.onFailure(node, exp);
}
});
} catch (Throwable t) {
logger.warn("error sending cluster state to {}", t, node);
publishResponseHandler.onFailure(node, t);
}
}
示例2: writeResponseExceptionHeader
import org.elasticsearch.common.io.stream.BytesStreamOutput; //导入方法依赖的package包/类
private void writeResponseExceptionHeader(BytesStreamOutput stream) throws IOException {
stream.writeLong(requestId);
byte status = 0;
status = TransportStatus.setResponse(status);
status = TransportStatus.setError(status);
stream.writeByte(status);
}