本文整理匯總了Java中org.elasticsearch.common.io.stream.StreamInput.getVersion方法的典型用法代碼示例。如果您正苦於以下問題:Java StreamInput.getVersion方法的具體用法?Java StreamInput.getVersion怎麽用?Java StreamInput.getVersion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.elasticsearch.common.io.stream.StreamInput
的用法示例。
在下文中一共展示了StreamInput.getVersion方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: TransportAddress
import org.elasticsearch.common.io.stream.StreamInput; //導入方法依賴的package包/類
/**
* Read from a stream and use the {@code hostString} when creating the InetAddress if the input comes from a version prior
* {@link Version#V_5_0_3_UNRELEASED} as the hostString was not serialized
*/
public TransportAddress(StreamInput in, @Nullable String hostString) throws IOException {
if (in.getVersion().before(Version.V_6_0_0_alpha1_UNRELEASED)) { // bwc layer for 5.x where we had more than one transport address
final short i = in.readShort();
if(i != 1) { // we fail hard to ensure nobody tries to use some custom transport address impl even if that is difficult to add
throw new AssertionError("illegal transport ID from node of version: " + in.getVersion() + " got: " + i + " expected: 1");
}
}
final int len = in.readByte();
final byte[] a = new byte[len]; // 4 bytes (IPv4) or 16 bytes (IPv6)
in.readFully(a);
final InetAddress inetAddress;
if (in.getVersion().onOrAfter(Version.V_5_0_3_UNRELEASED)) {
String host = in.readString(); // the host string was serialized so we can ignore the passed in version
inetAddress = InetAddress.getByAddress(host, a);
} else {
// prior to this version, we did not serialize the host string so we used the passed in version
inetAddress = InetAddress.getByAddress(hostString, a);
}
int port = in.readInt();
this.address = new InetSocketAddress(inetAddress, port);
}
示例2: readFrom
import org.elasticsearch.common.io.stream.StreamInput; //導入方法依賴的package包/類
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
bytes = in.readBytesReference();
version = in.getVersion();
}
示例3: CompressedStreamInput
import org.elasticsearch.common.io.stream.StreamInput; //導入方法依賴的package包/類
public CompressedStreamInput(StreamInput in) throws IOException {
this.in = in;
super.setVersion(in.getVersion());
readHeader(in);
}