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

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

package com.alachisoft.ncache.client.internal.command;

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

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class InquiryRequestCommand extends Command {

    private long requestId;
    private int commandId;
    private String destinationIp;
    protected com.alachisoft.ncache.common.protobuf.InquiryRequestCommandProtocol.InquiryRequestCommand _commandInstance;

    public InquiryRequestCommand(long requestId, int commandID, String destinationIP) {
        super.name = "InquiryRequestCommand";
        setRequestId(requestId);
        setCommandId(commandID);
        setDestinationIp(destinationIP);
    }

    public int getCommandId() {
        return commandId;
    }

    public void setCommandId(int commandId) {
        this.commandId = commandId;
    }

    public String getDestinationIp() {
        return destinationIp;
    }

    public void setDestinationIp(String destinationIp) {
        this.destinationIp = destinationIp;
    }

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

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

    @Override
    protected void createCommand() throws CommandException {
        InquiryRequestCommandProtocol.InquiryRequestCommand.Builder builder = InquiryRequestCommandProtocol.InquiryRequestCommand.newBuilder();
        builder.setInquiryRequestId(getRequestId())
                .setInquiryCommandId(getCommandId())
                .setServerIP(getDestinationIp());
        CommandProtocol.Command.Builder commandBuilder = CommandProtocol.Command.newBuilder();

        _commandInstance =builder.setRequestId(this.getRequestId()).build();
    }

    public long getRequestId() {
        return requestId;
    }

    public void setRequestId(long value) {
        this.requestId = value;
    }

    @Override
    protected  void serializeCommandInternal(ByteArrayOutputStream stream) throws IOException
    {
        _commandInstance.writeTo(stream);
    }
    @Override
    protected short getCommandHandle()
    {
        return (short)CommandProtocol.Command.Type.INQUIRY_REQUEST.getNumber();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy