
com.alachisoft.ncache.client.internal.command.CloseStreamCommand Maven / Gradle / Ivy
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.alachisoft.ncache.client.internal.command;
import com.alachisoft.ncache.common.protobuf.CloseStreamCommandProtocol;
import com.alachisoft.ncache.common.protobuf.CommandProtocol;
import com.alachisoft.ncache.runtime.exceptions.CommandException;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
/**
* @author Asad Hasnain
*/
public final class CloseStreamCommand extends Command {
private CloseStreamCommandProtocol.CloseStreamCommand.Builder closeStreamCommand;
protected com.alachisoft.ncache.common.protobuf.CloseStreamCommandProtocol.CloseStreamCommand _commandInstance;
public CloseStreamCommand(String key, String lockHandle , int methodOverload) {
closeStreamCommand = CloseStreamCommandProtocol.CloseStreamCommand.newBuilder();
closeStreamCommand.setKey(key);
closeStreamCommand.setLockHandle(lockHandle);
closeStreamCommand.setMethodOverload(methodOverload);
}
public void createCommand() throws CommandException {
if (closeStreamCommand.getKey() == null) {
throw new NullPointerException("Key");
}
if (closeStreamCommand.getKey().equals("")) {
throw new IllegalArgumentException("key");
}
_commandInstance =closeStreamCommand.setRequestId(this.getRequestId()).build();
}
@Override
public CommandType getCommandType() {
return CommandType.CLOSE_STREAM;
}
@Override
public RequestType getCommandRequestType() {
return RequestType.AtomicWrite;
}
@Override
protected void serializeCommandInternal(ByteArrayOutputStream stream) throws IOException
{
_commandInstance.writeTo(stream);
}
@Override
protected short getCommandHandle()
{
return (short)CommandProtocol.Command.Type.CLOSE_STREAM.getNumber();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy