com.alachisoft.ncache.client.internal.command.PingCommand 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 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();
}
}