All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alachisoft.ncache.client.internal.command.ListCommandBase Maven / Gradle / Ivy

package com.alachisoft.ncache.client.internal.command;

import com.alachisoft.ncache.common.protobuf.CommandProtocol;
import com.alachisoft.ncache.common.protobuf.ListCommandProtocol;
import com.alachisoft.ncache.common.protobuf.LockInfoProtocol;
import com.alachisoft.ncache.runtime.caching.WriteThruOptions;
import com.alachisoft.ncache.runtime.util.TimeSpan;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

public abstract class ListCommandBase extends Command {
    protected String _lockId;
    protected TimeSpan _lockTimeout = new TimeSpan();

    protected WriteThruOptions _writeThruOption;
    protected ListCommandProtocol.ListCommand.Builder _listCommandBuilder;

    @Override
    protected short getCommandHandle()
    {
        return (short) CommandProtocol.Command.Type.LIST_COMMAND.getNumber();
    }

    @Override
    protected void serializeCommandInternal(ByteArrayOutputStream stream) throws IOException {
        _listCommandBuilder.build().writeTo(stream);
    }

    @Override
    protected void createCommand()
    {
        _listCommandBuilder = ListCommandProtocol.ListCommand.newBuilder();
        _listCommandBuilder.setRequestId(super.getRequestId());
        _listCommandBuilder.setName(key);

        LockInfoProtocol.LockInfo.Builder lockInfoBuilder = LockInfoProtocol.LockInfo.newBuilder();
        if(_lockId != null){
            lockInfoBuilder.setLockId(_lockId);
        }
        lockInfoBuilder.setLockTimeout(_lockTimeout.getTotalTicks());

        if (_writeThruOption != null)
        {
            _listCommandBuilder.setDsWriteOption((int)_writeThruOption.getMode().getValue());
            if(_writeThruOption.getProviderName() != null) _listCommandBuilder.setProviderName(_writeThruOption.getProviderName());
        }

        _listCommandBuilder.setLockInfo(lockInfoBuilder);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy