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

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

There is a newer version: 5.3.0
Show newest version
package com.alachisoft.ncache.client.internal.command;

import com.alachisoft.ncache.client.internal.util.ConversionUtil;
import com.alachisoft.ncache.common.protobuf.AddAttributeProtocol;
import com.alachisoft.ncache.common.protobuf.CommandProtocol;
import com.alachisoft.ncache.common.protobuf.TouchCommandProtocol;
import com.alachisoft.ncache.runtime.exceptions.CommandException;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.List;

public class TouchCommand extends Command {
    List _keys;
    protected com.alachisoft.ncache.common.protobuf.TouchCommandProtocol.TouchCommand _commandInstance;

    @Override
    public CommandType getCommandType() {
        return CommandType.TOUCH;
    }

    @Override
    public RequestType getCommandRequestType() {
        return RequestType.AtomicWrite;
    }



    public TouchCommand(List keys)
    {
        _keys=keys;
    }
    @Override
    protected  void serializeCommandInternal(ByteArrayOutputStream stream) throws IOException
    {
        _commandInstance.writeTo(stream);
    }
    @Override
    protected short getCommandHandle()
    {
        return (short)CommandProtocol.Command.Type.ADD_ATTRIBUTE.getNumber();
    }


    @Override
    protected void createCommand() throws CommandException {
        TouchCommandProtocol.TouchCommand.Builder touchCommand= TouchCommandProtocol.TouchCommand.newBuilder();
        touchCommand.addAllKeys(_keys);
        touchCommand.setRequestId(getRequestId());
        _commandInstance=touchCommand.build();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy