org.elasticsearch.transport.InboundDecoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of elasticsearch Show documentation
Show all versions of elasticsearch Show documentation
Elasticsearch subproject :server
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
package org.elasticsearch.transport;
import org.elasticsearch.Version;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.bytes.ReleasableBytesReference;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.lease.Releasable;
import org.elasticsearch.common.util.PageCacheRecycler;
import org.elasticsearch.core.internal.io.IOUtils;
import java.io.IOException;
import java.util.function.Consumer;
public class InboundDecoder implements Releasable {
static final Object PING = new Object();
static final Object END_CONTENT = new Object();
private final Version version;
private final PageCacheRecycler recycler;
private TransportDecompressor decompressor;
private int totalNetworkSize = -1;
private int bytesConsumed = 0;
private boolean isClosed = false;
public InboundDecoder(Version version, PageCacheRecycler recycler) {
this.version = version;
this.recycler = recycler;
}
public int decode(ReleasableBytesReference reference, Consumer