
com.alachisoft.ncache.client.internal.command.CounterOperationsCommand Maven / Gradle / Ivy
package com.alachisoft.ncache.client.internal.command;
import Alachisoft.NCache.Common.DataTypes.Counter.CounterOperation;
import com.alachisoft.ncache.common.protobuf.CounterCommandProtocol;
import com.alachisoft.ncache.common.protobuf.CounterOpertionsProtocol;
public class CounterOperationsCommand extends CounterCommandBase {
private CounterOperation.OpType _operationType;
private long _value;
private CounterOpertionsProtocol.CounterOperations.Builder _counterOperationsBuilder;
public CounterOperationsCommand(CounterOperation operation) {
super.name = "CounterOperations";
super.key = operation.getName();
_writeThruOption = operation.getWriteThruOptions();
_lockId = (String)operation.getLockId();
_lockTimeout = operation.getLockTimeout();
_value = operation.getValue();
_operationType = operation.getOperationType();
}
@Override
public CommandType getCommandType() {
return CommandType.DATA_TYPE;
}
@Override
public RequestType getCommandRequestType() {
return RequestType.AtomicWrite;
}
@Override
protected void createCommand() {
_counterOperationsBuilder = CounterOpertionsProtocol.CounterOperations.newBuilder();
_counterOperationsBuilder.setValue(_value);
switch (_operationType)
{
case IncrementBy:
_counterOperationsBuilder.setMethod(CounterOpertionsProtocol.CounterOperations.Method.INCREMENTBY);
break;
case DecrementBy:
_counterOperationsBuilder.setMethod(CounterOpertionsProtocol.CounterOperations.Method.DECREMENTBY);
break;
case SetValue:
_counterOperationsBuilder.setMethod(CounterOpertionsProtocol.CounterOperations.Method.SETVALUE);
break;
}
super.createCommand();
_counterCommand.setType(CounterCommandProtocol.CounterCommand.Type.COUNTER_OPERATIONS);
_counterCommand.setCounterOperations(_counterOperationsBuilder);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy