com.alachisoft.ncache.client.internal.command.RemoveTopicCommand 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.RemoveTopicCommandProtocol;
import com.alachisoft.ncache.runtime.exceptions.CommandException;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
public class RemoveTopicCommand extends Command {
private final String topicName;
private final boolean forcefully;
protected com.alachisoft.ncache.common.protobuf.RemoveTopicCommandProtocol.RemoveTopicCommand _commandInstance;
public RemoveTopicCommand(String topicName, boolean forcefully) {
name = "RemoveTopicCommand";
this.topicName = topicName;
this.forcefully = forcefully;
}
@Override
public CommandType getCommandType() {
return CommandType.REMOVE_TOPIC;
}
@Override
public RequestType getCommandRequestType() {
return RequestType.AtomicRead;
}
@Override
protected void createCommand() throws CommandException {
RemoveTopicCommandProtocol.RemoveTopicCommand.Builder builder = RemoveTopicCommandProtocol.RemoveTopicCommand.newBuilder();
builder.setRequestId(getRequestId())
.setTopicName(topicName)
.setForcefully(forcefully);
if(this.getIntendedRecipient()!=null)
builder.setIntendedRecipient(getIntendedRecipient());
_commandInstance =builder
.setClientLastViewId(getClientLastViewId())
.setCommandVersion(1)
.setVersion(VERSION)
.build();
}
@Override
protected void serializeCommandInternal(ByteArrayOutputStream stream) throws IOException
{
_commandInstance.writeTo(stream);
}
@Override
protected short getCommandHandle()
{
return (short)CommandProtocol.Command.Type.REMOVE_TOPIC.getNumber();
}
}