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

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

/*
 * GetCommand.java
 *
 * Created on September 11, 2006, 5:06 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.CommandProtocol;
import com.alachisoft.ncache.common.protobuf.GetGroupCommandProtocol;
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 GetGroupCommand extends Command {

    private String group;
    private boolean getData;
    protected com.alachisoft.ncache.common.protobuf.GetGroupCommandProtocol.GetGroupCommand _commandInstance;

    /**
     * Creates a new instance of GetCommand
     *
     * @param group
     */
    public GetGroupCommand(String group, boolean keys) {
        this.group = group;
        //this.name = keys ? "GETGROUPKEYS" : "GETGROUPDATA";
        this.getData = !keys;
    }

    /**
     * @return
     */
    protected boolean parseCommand() {
        return true;
    }

    protected void createCommand() throws CommandException {

        GetGroupCommandProtocol.GetGroupCommand.Builder builder =
                GetGroupCommandProtocol.GetGroupCommand.newBuilder();

        builder = builder.setRequestId(this.getRequestId())
                .setGetGroupKeys(!this.getData);

        if (group != null) {
            builder = builder.setGroup(group);
        }

        // String isAsync = this.isAsync? "Y" : "N";
        _commandInstance =builder
                .setClientLastViewId(this.getClientLastViewId())
                .setCommandVersion(1).
                        build();

    }

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

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

    @Override
    protected  void serializeCommandInternal(ByteArrayOutputStream stream) throws IOException
    {
        _commandInstance.writeTo(stream);
    }
    @Override
    protected short getCommandHandle()
    {
        return (short)CommandProtocol.Command.Type.GET_GROUP.getNumber();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy