com.alachisoft.ncache.client.internal.command.SyncEventsCommand 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.
/*
* 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.CommandProtocol;
import com.alachisoft.ncache.common.protobuf.EventIdCommandProtocol;
import com.alachisoft.ncache.common.protobuf.SyncEventsCommandProtocol;
import com.alachisoft.ncache.runtime.exceptions.CommandException;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
public final class SyncEventsCommand extends Command {
private com.alachisoft.ncache.common.protobuf.SyncEventsCommandProtocol.SyncEventsCommand.Builder _syncEventCommand;
private com.alachisoft.ncache.common.protobuf.EventIdCommandProtocol _eventIdCommand;
protected com.alachisoft.ncache.common.protobuf.SyncEventsCommandProtocol.SyncEventsCommand _commandInstance;
public SyncEventsCommand(java.util.ArrayList eventIds) {
super.name = "SyncEventsCommand";
_syncEventCommand = SyncEventsCommandProtocol.SyncEventsCommand.newBuilder();
_syncEventCommand.setRequestId(super.getRequestId());
for (Alachisoft.NCache.Caching.EventId eventId : eventIds) {
com.alachisoft.ncache.common.protobuf.EventIdCommandProtocol.EventIdCommand.Builder _eventIdCommand = EventIdCommandProtocol.EventIdCommand.newBuilder();
_eventIdCommand.setEventType(eventId.getEventType().getValue());
_eventIdCommand.setEventUniqueId(eventId.getEventUniqueID());
_eventIdCommand.setEventCounter(eventId.getEventCounter());
_eventIdCommand.setOperationCounter(eventId.getOperationCounter());
_eventIdCommand.setQueryChangeType(eventId.getQueryChangeType().getValue());
_eventIdCommand.setQueryId(eventId.getQueryId());
_syncEventCommand.addEventIds(_eventIdCommand);
}
}
@Override
public CommandType getCommandType() {
return getCommandType().SYNC_EVENTS;
}
@Override
protected void createCommand() throws CommandException {
CommandProtocol.Command.Builder commandBuilder = CommandProtocol.Command.newBuilder();
commandBuilder.setRequestID(this.getRequestId());
commandBuilder.setSyncEventsCommand(_syncEventCommand);
commandBuilder.setType(com.alachisoft.ncache.common.protobuf.CommandProtocol.Command.Type.SYNC_EVENTS);
_commandInstance =_syncEventCommand.build();
}
@Override
public RequestType getCommandRequestType() {
return RequestType.InternalCommand;
}
@Override
protected void serializeCommandInternal(ByteArrayOutputStream stream) throws IOException
{
_commandInstance.writeTo(stream);
}
@Override
protected short getCommandHandle()
{
return (short)CommandProtocol.Command.Type.SYNC_EVENTS.getNumber();
}
}