
com.alachisoft.ncache.client.internal.command.HashSetCommandBase Maven / Gradle / Ivy
package com.alachisoft.ncache.client.internal.command;
import com.alachisoft.ncache.common.protobuf.CommandProtocol;
import com.alachisoft.ncache.common.protobuf.HashSetCommandProtocol;
import com.alachisoft.ncache.common.protobuf.LockInfoProtocol;
import com.alachisoft.ncache.runtime.caching.WriteThruOptions;
import com.alachisoft.ncache.runtime.exceptions.CommandException;
import com.alachisoft.ncache.runtime.util.TimeSpan;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
public abstract class HashSetCommandBase extends Command {
protected String _lockId;
protected TimeSpan _lockTimeout = new TimeSpan();
protected WriteThruOptions _writeThruOption;
protected HashSetCommandProtocol.HashSetCommand.Builder _hashSetCommandBuilder;
@Override
protected short getCommandHandle()
{
return (short) CommandProtocol.Command.Type.HASHSET_COMMAND.getNumber();
}
@Override
protected void serializeCommandInternal(ByteArrayOutputStream stream) throws IOException {
_hashSetCommandBuilder.build().writeTo(stream);
}
@Override
protected void createCommand() throws CommandException
{
_hashSetCommandBuilder = HashSetCommandProtocol.HashSetCommand.newBuilder();
_hashSetCommandBuilder.setRequestId(super.getRequestId());
_hashSetCommandBuilder.setName(key);
LockInfoProtocol.LockInfo.Builder lockInfoBuilder = LockInfoProtocol.LockInfo.newBuilder();
if(_lockId != null) lockInfoBuilder.setLockId(_lockId);
lockInfoBuilder.setLockTimeout(_lockTimeout.getTotalTicks());
if (_writeThruOption != null)
{
_hashSetCommandBuilder.setDsWriteOption((int)_writeThruOption.getMode().getValue());
if(_writeThruOption.getProviderName() != null) _hashSetCommandBuilder.setProviderName(_writeThruOption.getProviderName());
}
_hashSetCommandBuilder.setLockInfo(lockInfoBuilder);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy