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

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

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.alachisoft.ncache.client.internal.command;

import com.alachisoft.ncache.common.protobuf.BridgeMakeTargetCacheActivePassiveCommandProtocol;
import com.alachisoft.ncache.common.protobuf.CommandProtocol;
import com.alachisoft.ncache.runtime.exceptions.CommandException;

import java.io.IOException;

/**
 * @author Basit Anwer
 */
public final class BridgeMakeTargetCacheActivePassiveCommand extends Command {
    private boolean makeCacheActive;

    public BridgeMakeTargetCacheActivePassiveCommand(boolean makeCacheActive) {
        this.name = "BridgeMakeTargetCacheActivePassiveCommand";
        this.makeCacheActive = makeCacheActive;
    }

    public CommandType getCommandType() {
        return CommandType.BRIDGE_MAKE_TARGET_CACHE_ACTIVE_PASSIVE;
    }


    @Override
    protected void createCommand() throws CommandException {
        BridgeMakeTargetCacheActivePassiveCommandProtocol.BridgeMakeTargetCacheActivePassiveCommand.Builder builder =
                BridgeMakeTargetCacheActivePassiveCommandProtocol.BridgeMakeTargetCacheActivePassiveCommand.newBuilder();
        builder.setMakeCacheActive(this.makeCacheActive);
        builder.setRequestId(super.getRequestId());
        CommandProtocol.Command.Builder commandBuilder =
                CommandProtocol.Command.newBuilder();
        try {
            commandBuilder = commandBuilder.setBridgeMakeTargetCacheActivePassiveCommand(builder)
                    .setRequestID(this.getRequestId())
                    .setType(CommandProtocol.Command.Type.BRIDGE_MAKE_TARGET_CACHE_ACTIVE_PASSIVE);
            super.commandBytes = this.constructCommand(commandBuilder.build().toByteArray());

        } catch (IOException ex) {
            throw new CommandException(ex.getMessage());
        }
    }

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

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy