
com.alachisoft.ncache.client.internal.command.GetNextChunkCommand Maven / Gradle / Ivy
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.alachisoft.ncache.client.internal.command;
import com.alachisoft.ncache.common.protobuf.CommandProtocol;
import com.alachisoft.ncache.common.protobuf.EnumerationPointerProtocol;
import com.alachisoft.ncache.common.protobuf.GetNextChunkCommandProtocol;
import com.alachisoft.ncache.runtime.exceptions.CommandException;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
/**
* @author Administrator
*/
public class GetNextChunkCommand extends Command {
private String id;
private int chunckId;
private boolean isDisposed;
protected com.alachisoft.ncache.common.protobuf.GetNextChunkCommandProtocol.GetNextChunkCommand _commandInstance;
public GetNextChunkCommand(String id, int chunckId, boolean isDisposed) {
this.id = id;
this.chunckId = chunckId;
this.isDisposed = isDisposed;
}
@Override
protected void createCommand() throws CommandException {
EnumerationPointerProtocol.EnumerationPointer.Builder pointerBuilder =
EnumerationPointerProtocol.EnumerationPointer.newBuilder();
pointerBuilder.setChunkId(chunckId)
.setId(id)
.setIsDisposed(isDisposed);
GetNextChunkCommandProtocol.GetNextChunkCommand.Builder builder =
GetNextChunkCommandProtocol.GetNextChunkCommand.newBuilder();
builder = builder.setRequestId(this.getRequestId())
.setEnumerationPointer(pointerBuilder);
_commandInstance =builder.build();
}
@Override
public CommandType getCommandType() {
return CommandType.GET_NEXT_CHUNK;
}
@Override
public RequestType getCommandRequestType() {
return RequestType.ChunkRead;
}
@Override
protected void serializeCommandInternal(ByteArrayOutputStream stream) throws IOException
{
_commandInstance.writeTo(stream);
}
@Override
protected short getCommandHandle()
{
return (short)CommandProtocol.Command.Type.GET_NEXT_CHUNK.getNumber();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy