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

com.alachisoft.ncache.client.internal.command.PingCommand 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 com.alachisoft.ncache.common.protobuf.CommandProtocol;
import com.alachisoft.ncache.common.protobuf.PingCommandProtocol;
import com.alachisoft.ncache.runtime.exceptions.CommandException;

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

public class PingCommand extends Command {
    private boolean _hasResponse = false;
    private int _methodOverload = 0;
    protected com.alachisoft.ncache.common.protobuf.PingCommandProtocol.PingCommand _commandInstance;

    public PingCommand(boolean hasResponse, boolean async) {
        name = "PublishMessageCommand";
        isAsync = async;
        _hasResponse = hasResponse;
    }

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

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

    @Override
    protected void createCommand() throws CommandException {


        PingCommandProtocol.PingCommand.Builder builder = PingCommandProtocol.PingCommand.newBuilder();
        builder.setRequestId(getRequestId())
                .setHasResponse(_hasResponse).setMethodOverload(1);

        CommandProtocol.Command.Builder commandBuilder = CommandProtocol.Command.newBuilder();
        _commandInstance =builder
                .setMethodOverload(_methodOverload)
                .build();

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

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy