com.alachisoft.ncache.client.internal.command.ClearCommand Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ncache-professional-client Show documentation
Show all versions of ncache-professional-client Show documentation
NCache Professional client for java.
/*
* ClearCommand.java
*
* Created on September 12, 2006, 12:04 PM
*
* Copyright 2005 Alachisoft, Inc. All rights reserved.
* ALACHISOFT PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.alachisoft.ncache.client.internal.command;
import Alachisoft.NCache.Common.BitSet;
import Alachisoft.NCache.Common.BitSetConstants;
import com.alachisoft.ncache.common.protobuf.ClearCommandProtocol;
import com.alachisoft.ncache.common.protobuf.CommandProtocol;
import com.alachisoft.ncache.runtime.exceptions.CommandException;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
/**
* @author Administrator
* @version 1.0
*/
public final class ClearCommand extends Command {
/**
* Creates a new instance of ClearCommand
*
* @param isAsync
*/
private int flagMap;
private int onDsClearedId;
private String providerName;
private short _cacheCleared;
private int _methodOverload;
protected com.alachisoft.ncache.common.protobuf.ClearCommandProtocol.ClearCommand _commandInstance;
public ClearCommand(short cacheCleared , boolean isAsync, BitSet flagMap, int onDsClearedId, String providerName , int methodOverload) {
super.name = "ClearCommand";
this._cacheCleared = cacheCleared;
super.asyncCallbackId = this._cacheCleared;
super.isAsync = isAsync;
this.flagMap = BitSetConstants.getBitSetData(flagMap);
this.onDsClearedId = onDsClearedId;
this.providerName = providerName;
this._methodOverload = methodOverload;
this.asyncCallbackSpecified = this.isAsync && super.asyncCallbackId != -1 ? true : false;
}
protected void createCommand() throws CommandException {
ClearCommandProtocol.ClearCommand.Builder builder =
ClearCommandProtocol.ClearCommand.newBuilder();
builder.setDatasourceClearedCallbackId(this.onDsClearedId)
.setRequestId(this.getRequestId())
.setFlag(flagMap)
.setIsAsync(isAsync);
if (providerName != null && !providerName.equals("")) {
builder.setProviderName(providerName);
}
_commandInstance =builder.setMethodOverload(_methodOverload).build();
}
/**
* @return
*/
@Override
public CommandType getCommandType() {
return CommandType.CLEAR;
}
public int getAsyncCacheClearedOpComplete() {
return this._cacheCleared;
}
@Override
public RequestType getCommandRequestType() {
return RequestType.AtomicWrite;
}
@Override
public boolean getIsKeyBased()
{
return false;
}
@Override
protected void serializeCommandInternal(ByteArrayOutputStream stream) throws IOException
{
_commandInstance.writeTo(stream);
}
@Override
protected short getCommandHandle()
{
return (short)CommandProtocol.Command.Type.CLEAR.getNumber();
}
}