com.alachisoft.ncache.client.internal.command.IsLockedCommand Maven / Gradle / Ivy
Show all versions of ncache-professional-client Show documentation
/*
* 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.CommandProtocol;
import com.alachisoft.ncache.common.protobuf.IsLockedCommandProtocol;
import com.alachisoft.ncache.runtime.exceptions.CommandException;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
/**
* @author asad
* Created on May 12, 2011 3:19:48 PM
*
* Copyright 2011 Alachisoft, Inc. All rights reserved.
* ALACHISOFT PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
public class IsLockedCommand extends Command {
private String _lockId;
private String _key;
protected com.alachisoft.ncache.common.protobuf.IsLockedCommandProtocol.IsLockedCommand _commandInstance;
public IsLockedCommand(String key, String lockId) {
super.name = "IsLockedCommand";
this._key = key;
this._lockId = lockId;
}
@Override
protected void createCommand() throws CommandException {
IsLockedCommandProtocol.IsLockedCommand.Builder builder =
IsLockedCommandProtocol.IsLockedCommand.newBuilder();
builder = builder.setRequestId(this.getRequestId())
.setKey(_key);
if (_lockId != null) {
builder = builder.setLockId(_lockId);
}
_commandInstance =builder.build();
}
public CommandType getCommandType() {
return CommandType.ISLOCKED;
}
@Override
public RequestType getCommandRequestType() {
return RequestType.AtomicRead;
}
@Override
protected void serializeCommandInternal(ByteArrayOutputStream stream) throws IOException
{
_commandInstance.writeTo(stream);
}
@Override
protected short getCommandHandle()
{
return (short)CommandProtocol.Command.Type.ISLOCKED.getNumber();
}
}