com.alachisoft.ncache.client.internal.command.SurrogateCommand 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 Alachisoft.NCache.Common.Net.Address;
import com.alachisoft.ncache.common.protobuf.CommandProtocol;
import com.alachisoft.ncache.common.protobuf.SurrogateCommandProtocol;
import com.alachisoft.ncache.runtime.exceptions.CommandException;
import com.google.protobuf.ByteString;
import java.io.IOException;
public class SurrogateCommand extends Command {
private Address actualTargetNode;
private Command wrappedCommand;
private boolean requestInquireEnable;
public SurrogateCommand(Command command, Address actualNode, boolean requestInquireEnable) {
setWrappedCommand(command);
setActualTargetNode(actualNode);
this.requestInquireEnable = requestInquireEnable;
}
public Command getWrappedCommand() {
return wrappedCommand;
}
public void setWrappedCommand(Command wrappedCommand) {
this.wrappedCommand = wrappedCommand;
}
public Address getActualTargetNode() {
return actualTargetNode;
}
public void setActualTargetNode(Address actualTargetNode) {
this.actualTargetNode = actualTargetNode;
}
@Override
public CommandType getCommandType() {
return getWrappedCommand().getCommandType();
}
@Override
public RequestType getCommandRequestType() {
return getWrappedCommand().getCommandRequestType();
}
@Override
protected void createCommand() throws CommandException {
SurrogateCommandProtocol.SurrogateCommand.Builder builder = SurrogateCommandProtocol.SurrogateCommand.newBuilder();
builder.setRequestId(getRequestId()).setTargetServer(getActualTargetNode().toString())
.setRequestId(getWrappedCommand().getRequestId());
CommandProtocol.Command.Builder commandBuilder = CommandProtocol.Command.newBuilder();
commandBuilder = commandBuilder.setSurrogateCommand(builder.build())
.setRequestID(getWrappedCommand().getRequestId())
.setType(CommandProtocol.Command.Type.SURROGATE);
super._command = commandBuilder.build();
}
}