com.alachisoft.ncache.client.internal.command.GetMessageCommand 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 license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.alachisoft.ncache.client.internal.command;
import Alachisoft.NCache.Common.BitSet;
import com.alachisoft.ncache.common.protobuf.CommandProtocol;
import com.alachisoft.ncache.common.protobuf.GetMessageCommandProtocol;
import com.alachisoft.ncache.runtime.exceptions.CommandException;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
public class GetMessageCommand extends Command {
private final BitSet flag;
protected com.alachisoft.ncache.common.protobuf.GetMessageCommandProtocol.GetMessageCommand _commandInstance;
public GetMessageCommand(BitSet flagMap) {
name = "GetMessageCommand";
flag = flagMap;
}
@Override
public CommandType getCommandType() {
return CommandType.GETMESSAGE;
}
@Override
public RequestType getCommandRequestType() {
return RequestType.AtomicRead;
}
@Override
protected void createCommand() throws CommandException {
GetMessageCommandProtocol.GetMessageCommand.Builder builder = GetMessageCommandProtocol.GetMessageCommand.newBuilder();
builder.setRequestId(getRequestId()).setFlag(flag.getData());
builder.setVersion(VERSION).setCommandVersion(1).setClientLastViewId(getClientLastViewId());
if(getIntendedRecipient()!=null)
builder.setIntendedRecipient(getIntendedRecipient());
_commandInstance =builder.build();
}
@Override
protected void serializeCommandInternal(ByteArrayOutputStream stream) throws IOException
{
_commandInstance.writeTo(stream);
}
@Override
protected short getCommandHandle()
{
return (short)CommandProtocol.Command.Type.GET_MESSAGE.getNumber();
}
}