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

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

There is a newer version: 5.3.0
Show newest version
package com.alachisoft.ncache.client.internal.command;

import com.alachisoft.ncache.common.protobuf.CommandProtocol;
import com.alachisoft.ncache.common.protobuf.MessageCountCommandProtocol;
import com.alachisoft.ncache.runtime.exceptions.CommandException;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

public final class MessageCountCommand extends Command
{

    private com.alachisoft.ncache.common.protobuf.MessageCountCommandProtocol.MessageCountCommand _commandInstance;
    com.alachisoft.ncache.common.protobuf.MessageCountCommandProtocol.MessageCountCommand.Builder _messageCountCommand;

    public MessageCountCommand(String topicName)
    {
        name = "MessageCountCommand";
        _messageCountCommand = MessageCountCommandProtocol.MessageCountCommand.newBuilder();
        _messageCountCommand.setTopicName(topicName);
        _messageCountCommand.setRequestId(super.getRequestId());
    }

    @Override
    public RequestType getCommandRequestType()
    {
        return RequestType.AtomicRead;
    }

    @Override
    public CommandType getCommandType()
    {
        return CommandType.MESSAGE_COUNT;
    }

    @Override
    public boolean getIsKeyBased()
    {
        return false;
    }

    @Override
    protected void createCommand() throws CommandException {
        _messageCountCommand.setRequestId(super.getRequestId());
        _commandInstance = _messageCountCommand.build();
    }

    @Override
    protected short getCommandHandle()
    {
        return (short) CommandProtocol.Command.Type.MESSAGE_COUNT.getNumber();
    }

    @Override
    protected  void serializeCommandInternal(ByteArrayOutputStream stream) throws IOException
    {
        _commandInstance.writeTo(stream);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy