示例#1
0
  @Override
  protected void createCommand() throws CommandException {

    this._lockId = (this._lockId == null) ? "" : this._lockId;

    try {
      UnlockCommandProtocol.UnlockCommand.Builder builder =
          UnlockCommandProtocol.UnlockCommand.newBuilder();

      builder
          .setRequestId(this.getRequestId())
          .setKey(CacheKeyUtil.toByteString(key, this.getCacheId()))
          .setLockId(this._lockId)
          .setPreemptive(this._preemptive);

      CommandProtocol.Command.Builder commandBuilder = CommandProtocol.Command.newBuilder();

      commandBuilder =
          commandBuilder
              .setUnlockCommand(builder)
              .setRequestID(this.getRequestId())
              .setType(CommandProtocol.Command.Type.UNLOCK);

      super.commandBytes = this.constructCommand(commandBuilder.build().toByteArray());

    } catch (IOException e) {
      throw new CommandException(e.getMessage());
    }
  }
示例#2
0
  @Override
  public void ExecuteCommand(
      ClientManager clientManager,
      com.alachisoft.tayzgrid.common.protobuf.CommandProtocol.Command command) {
    CommandInfo cmdInfo = new CommandInfo();

    try {
      cmdInfo = ParseCommand(command, clientManager).clone();
    } catch (RuntimeException exc) {
      _syncEventResult = getOperationResult().Failure;
      if (!super.immatureId.equals("-2")) {
        _serializedResponsePackets.add(
            ResponseHelper.SerializeExceptionResponse(exc, command.getRequestID()));
      }
      return;
    }

    byte[] data = null;

    try {
      ICommandExecuter tempVar = clientManager.getCmdExecuter();
      TayzGrid nCache = (TayzGrid) ((tempVar instanceof TayzGrid) ? tempVar : null);

      EventStatus eventStatus = nCache.GetEventsStatus();
      java.util.ArrayList<com.alachisoft.tayzgrid.persistence.Event> syncEventResult =
          nCache
              .getCache()
              .GetFilteredEvents(clientManager.getClientID(), cmdInfo.EventsList, eventStatus);
      SyncEventResponseBuilder.BuildResponse(
          syncEventResult,
          cmdInfo.RequestId,
          _serializedResponsePackets,
          clientManager.getClientID(),
          nCache.getCacheId());

    } catch (Exception exc) {
      _syncEventResult = getOperationResult().Failure;
      // PROTOBUF:RESPONSE
      _serializedResponsePackets.add(
          ResponseHelper.SerializeExceptionResponse(exc, command.getRequestID()));
    }
  }
 @Override
 protected void createCommand() throws CommandException {
   try {
     // TODO - InComplete :Farhan
     commandBytes =
         super.constructCommand(
             CommandProtocol.Command.newBuilder()
                 .setMapReduceTaskCommand(
                     MapReduceTaskCommandProtocol.MapReduceTaskCommand.newBuilder()
                         .setRequestId(this.getRequestId())
                         .setTaskId(taskId)
                         .setCallbackId((int) callbackId)
                         .setMapReduceTask(ByteString.copyFrom(mrTask))
                         .setOutputOption(outputOption))
                 .setRequestID(this.getRequestId())
                 .setType(CommandProtocol.Command.Type.MAP_REDUCE_TASK)
                 .build()
                 .toByteArray());
   } catch (IOException ex) {
     throw new CommandException(ex.getMessage());
   }
 }