All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alachisoft.ncache.client.internal.command.GetMessageCommand Maven / Gradle / Ivy

There is a newer version: 5.3.0
Show newest version
/*
 * 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();
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy