com.alachisoft.ncache.client.internal.command.GetGroupNextChunkCommand Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ncache-professional-client Show documentation
Show all versions of ncache-professional-client Show documentation
NCache Professional client for java.
/*
* 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.GetGroupNextChunkCommandProtocol;
import com.alachisoft.ncache.common.protobuf.GroupEnumerationPointerProtocol;
import com.alachisoft.ncache.runtime.exceptions.CommandException;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
/**
* @author Administrator
*/
public class GetGroupNextChunkCommand extends Command {
private String group;
private String subGroup;
private String id;
private int chunckId;
protected com.alachisoft.ncache.common.protobuf.GetGroupNextChunkCommandProtocol.GetGroupNextChunkCommand _commandInstance;
public GetGroupNextChunkCommand(String id, int chunckId, String group, String subGroup) {
this.group = group;
this.subGroup = subGroup;
this.id = id;
this.chunckId = chunckId;
}
@Override
protected void createCommand() throws CommandException {
if (group == null) {
if (subGroup != null) {
throw new NullPointerException(
"group must be specified for sub group");
} else {
subGroup = "";
}
group = "";
}
GroupEnumerationPointerProtocol.GroupEnumerationPointer.Builder pointerBuilder =
GroupEnumerationPointerProtocol.GroupEnumerationPointer.newBuilder();
pointerBuilder.setChunkId(chunckId)
.setId(id);
if (group != null) {
pointerBuilder = pointerBuilder.setGroup(group);
if (subGroup != null) {
pointerBuilder = pointerBuilder.setSubGroup(subGroup);
}
}
GetGroupNextChunkCommandProtocol.GetGroupNextChunkCommand.Builder builder =
GetGroupNextChunkCommandProtocol.GetGroupNextChunkCommand.newBuilder();
builder = builder.setRequestId(this.getRequestId())
.setGroupEnumerationPointer(pointerBuilder);
_commandInstance =builder.build();
}
@Override
public CommandType getCommandType() {
return CommandType.GETGROUP_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_GROUP_NEXT_CHUNK.getNumber();
}
}