
com.alachisoft.ncache.client.internal.command.AddCacheSyncDependency Maven / Gradle / Ivy
/*
* AddCacheSyncDependency.java _DATE_
*
* Created on December 14, 2006, 12:43 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 com.alachisoft.ncache.common.protobuf.AddSyncDependencyCommandProtocol.AddSyncDependencyCommand;
import com.alachisoft.ncache.client.CacheSyncDependency;
import com.alachisoft.ncache.common.protobuf.CommandProtocol;
import com.alachisoft.ncache.common.protobuf.SyncDependencyProtocol.SyncDependency;
import com.alachisoft.ncache.runtime.exceptions.CommandException;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
public final class AddCacheSyncDependency extends Command {
private CacheSyncDependency _syncDependency;
protected com.alachisoft.ncache.common.protobuf.AddSyncDependencyCommandProtocol.AddSyncDependencyCommand _commandInstance;
public AddCacheSyncDependency(String key, CacheSyncDependency syncDependency) {
name = "ADDSYNCDEPENDENCY";
super.key = key;
_syncDependency = syncDependency;
}
protected void createCommand() throws CommandException {
String cacheId = null;
String depKey = null;
String server = null;
int port = 0;
if (_syncDependency != null) {
cacheId = _syncDependency.getCacheId();
depKey = _syncDependency.getKey();
server = _syncDependency.getServer() == null ? "" : _syncDependency.getServer();
port = _syncDependency.getPort();
}
AddSyncDependencyCommand.Builder builder = AddSyncDependencyCommand.newBuilder().
setKey(key).
setRequestId(this.getRequestId()).
setSyncDependency(SyncDependency.newBuilder().
setCacheId(cacheId).
setKey(depKey).
setPort(port).
setServer(server));
_commandInstance=builder.setRequestId(getRequestId()).build();
}
@Override
public RequestType getCommandRequestType() {
return RequestType.AtomicWrite;
}
protected boolean parseCommand() {
return true;
}
public CommandType getCommandType() {
return CommandType.ADD_SYNC_DEPENDENCY;
}
@Override
protected void serializeCommandInternal(ByteArrayOutputStream stream) throws IOException
{
_commandInstance.writeTo(stream);
}
@Override
protected short getCommandHandle()
{
return (short)CommandProtocol.Command.Type.ADD_SYNC_DEPENDENCY.getNumber();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy