Sends a {@link HelloReply} using {@code blockingTaskExecutor}.

@see <a href="https://line.github.io/armeria/server-grpc.html#blocking-service-implementation">Blocking
service implementation</a>
965579
@Override
    public void blockingHello(HelloRequest request, StreamObserver<HelloReply> responseObserver) {
        // Unlike upstream gRPC-Java, Armeria does not run service logic in a separate thread pool by default.
        // Therefore, this method will run in the event loop, which means that you can suffer the performance
        // degradation if you call a blocking API in this method. In this case, you have the following options:
        //
        // 1. Call a blocking API in the blockingTaskExecutor provided by Armeria.
        // 2. Set GrpcServiceBuilder.useBlockingTaskExecutor(true) when building your GrpcService.
        // 3. Call a blocking API in the separate thread pool you manage.
        //
        // In this example, we chose the option 1:
        final ServiceRequestContext ctx = RequestContext.current();
        ctx.blockingTaskExecutor().submit(() -> {
            try {
                // Simulate a blocking API call.
                Thread.sleep(3000);
            } catch (Exception ignored) {
                // Do nothing.
            }
            responseObserver.onNext(buildReply(toMessage(request.getName())));
            responseObserver.onCompleted();
        });
    }
643183
function () {
        //client will set the counter property on the message
        //logger.log("server: send hello");
        this.client.secureOut = this.secureOut;
        this.client.sendCounter = CryptoLib.getRandomUINT16();
        this.client.sendMessage("Hello", {}, null, null);

        this.stage++;
        this.nextStep();
    }
65009
public void start(ExecutorService executorService, Callable<Future<R>> innerTask, ThreadContextDescriptor threadContext) {
        synchronized (this) {
            this.innerTask = innerTask;
            this.threadContext = threadContext;
            //set up the future to hold the result
            this.resultFuture = new CompletableFuture<Future<R>>();
            //submit the innerTask (wrapped by this) for execution
            this.taskFuture = executorService.submit(this);
        }
    }
90315
def SendReply(self,
                rdf_value=None,
                session_id=None,
                message_type=rdf_flows.GrrMessage.Type.MESSAGE):
    """"""
    # TODO(hanuszczak): This is pretty bad. Here we assume that if the session
    # id is not none we are "replying" to a well-known flow. If we are replying
    # to a well-known flow we cannot increment the response id (since these are
    # not really responses) because otherwise the parent flow will think it is
    # missing some responses.
    #
    # Moreover, the message queue (at least in the flow test helper workflow)
    # expects flow messages to have request id equal to 0. This is rather
    # convoluted and should be untangled in the future.
    #
    # Once we have a separate method for communicating with well-known flows
    # this if-statement should no longer be relevant (since setting custom
    # session ids would become illegal).
    if session_id is None:
      response_id = self.response_id
      request_id = self.message.request_id
      session_id = self.message.session_id
      self.response_id += 1
    else:
      response_id = 0
      request_id = 0

    self.grr_worker.SendReply(
        rdf_value,
        # This is not strictly necessary but adds context
        # to this response.
        name=self.__class__.__name__,
        session_id=session_id,
        response_id=response_id,
        request_id=request_id,
        message_type=message_type,
        task_id=self.message.Get("task_id") or None,
        require_fastpoll=self.require_fastpoll)
877876
@Override
    protected void sendMessage(INDArray message, int iterationNumber, int epochNumber) {
        // here we'll send our stuff to other executores over the wire
        // and let's pray for udp broadcast availability

        // Send this message away
        // FIXME: do something with unsafe duplication, which is bad and used ONLY for local spark
        try (MemoryWorkspace wsO = Nd4j.getMemoryManager().scopeOutOfWorkspaces()) {
            long updateId = updatesCounter.getAndIncrement();

            VoidParameterServer.getInstance().execDistributedImmediately(
                            new SilentUpdatesMessage(message.unsafeDuplication(), updateId));
        }


        // heere we update local queue
        super.sendMessage(message, iterationNumber, epochNumber);
    }
976657
public static ServiceAdapter<ExecutorService> forExecutorService() {
		return new SimpleServiceAdapter<ExecutorService>(false, true) {
			@Override
			protected void start(ExecutorService instance) {
			}

			@Override
			protected void stop(ExecutorService instance) throws Exception {
				List<Runnable> runnables = instance.shutdownNow();
				if (!runnables.isEmpty()) {
					logger.warn("Cancelled tasks: " + runnables);
				}
				if (!instance.isTerminated()) {
					logger.warn("Awaiting termination of " + instance + " ...");
					instance.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
				}
			}
		};
	}
1211398
private void sendNextPayload() {
		singleThreadExecutor.execute(new Runnable() {
			@Override
			public void run() {
				try {
					sendNextPayloadSync();
				} catch (Exception e) {
					ApptentiveLog.e(e, "Exception while trying to send next payload");
					logException(e);
				}
			}
		});
	}
636562
public static ExecutorService newBlockingFixedThreadPoolExecutor(int nThreads, int queueSize) {
        BlockingQueue<Runnable> blockingQueue = new ArrayBlockingQueue<>(queueSize);
        RejectedExecutionHandler blockingRejectedExecutionHandler = new RejectedExecutionHandler() {
            @Override
            public void rejectedExecution(Runnable task, ThreadPoolExecutor executor) {
                try {
                    executor.getQueue().put(task);
                } catch (InterruptedException e) {
                }
            }

        };

        return new ThreadPoolExecutor(nThreads, nThreads,
                0L, TimeUnit.MILLISECONDS, blockingQueue,
                blockingRejectedExecutionHandler);
    }
905999
public static <ReqT, RespT> RespT blockingUnaryCall(
      Channel channel, MethodDescriptor<ReqT, RespT> method, CallOptions callOptions, ReqT req) {
    ThreadlessExecutor executor = new ThreadlessExecutor();
    ClientCall<ReqT, RespT> call = channel.newCall(method, callOptions.withExecutor(executor));
    try {
      ListenableFuture<RespT> responseFuture = futureUnaryCall(call, req);
      while (!responseFuture.isDone()) {
        try {
          executor.waitAndDrain();
        } catch (InterruptedException e) {
          Thread.currentThread().interrupt();
          throw Status.CANCELLED
              .withDescription("Call was interrupted")
              .withCause(e)
              .asRuntimeException();
        }
      }
      return getUnchecked(responseFuture);
    } catch (RuntimeException e) {
      throw cancelThrow(call, e);
    } catch (Error e) {
      throw cancelThrow(call, e);
    }
  }
630370
public void send(CEMI frame, BlockingMode mode) throws KNXTimeoutException,
		KNXConnectionClosedException
	{
		if (!(frame instanceof CEMIDevMgmt))
			throw new KNXIllegalArgumentException("unsupported cEMI type");
		super.send(frame, mode);
	}
321883
private void sendIncrementalBlockReport(long startTime) throws Exception {

    // check if there are newly received blocks
    Block[] receivedAndDeletedBlockArray = null;
    int numBlocksReceivedAndDeleted = 0;
    int currentPendingRequests = 0;

    synchronized (receivedAndDeletedBlockList) {
      
      // construct the ACKs array
      lastDeletedReport = startTime;
      numBlocksReceivedAndDeleted = receivedAndDeletedBlockList.size();
      if (numBlocksReceivedAndDeleted > 0) {
        receivedAndDeletedBlockArray = receivedAndDeletedBlockList
            .toArray(new Block[numBlocksReceivedAndDeleted]);
        receivedAndDeletedBlockList.clear();
        currentPendingRequests = pendingReceivedRequests;
        pendingReceivedRequests = 0;
      }
    }
    // process received + deleted
    // if exception is thrown, add all blocks to the retry list
    if (receivedAndDeletedBlockArray != null) {            
      long[] failed = null;
      try {
        IncrementalBlockReport ibr = new IncrementalBlockReport(receivedAndDeletedBlockArray);

        long rpcStartTime = 0;
        if (LOG.isDebugEnabled()) {
          rpcStartTime = System.nanoTime();
          LOG.debug("sending blockReceivedAndDeletedNew "
                    + receivedAndDeletedBlockArray.length +
                    " blocks to " + namenodeAddress);
        }
        failed = avatarnode.blockReceivedAndDeletedNew(nsRegistration, ibr);
        if (LOG.isDebugEnabled()) {
          LOG.debug("finished blockReceivedAndDeletedNew " +
                    "to " + namenodeAddress +
                    " time: " + (System.nanoTime() - rpcStartTime) + " ns");
        }

        boolean isPrimaryCached = isPrimaryServiceCached();
        // if we talk to primary failed must be null
        // if we talk to standby failed shouldn't be null
        if(isPrimaryCached && failed!=null){
          //this should never happen
          //the primary can't switch to standby
          throw new IOException("Primary started acting as standby");
        } else if (!isPrimaryCached && failed == null) {
          String msg = "Received null response from standby for incremental"
              + " block report. ";
          if (clearPrimaryCommandProcessed) {
            LOG.info(msg + "Failover is in progress"
                + " - will not clear primary again");
          } else {
            LOG.info(msg + "Standby is acting as primary. Clearing primary");
            // failover - we need to refresh our knowledge
            this.clearPrimary();
          }
        }
      } catch (Exception e) {
        processFailedBlocks(
            receivedAndDeletedBlockArray, currentPendingRequests);
        throw e;
      }
      if(failed != null && failed.length != 0){
        processFailedReceivedDeleted(failed, receivedAndDeletedBlockArray);
      }
    }
  }
212615
public SoapServerResponseActionBuilder send() {
        SoapServerResponseActionBuilder soapServerResponseActionBuilder = new SoapServerResponseActionBuilder(action, soapServer)
                .withApplicationContext(applicationContext);
        return soapServerResponseActionBuilder;
    }
756537
@Override
  public void execute(Runnable r) {
    Preconditions.checkNotNull(r, "'r' must not be null.");
    boolean scheduleTaskRunner = false;
    synchronized (internalLock) {
      waitQueue.add(r);

      if (!isThreadScheduled) {
        isThreadScheduled = true;
        scheduleTaskRunner = true;
      }
    }
    if (scheduleTaskRunner) {
      boolean threw = true;
      try {
        executor.execute(taskRunner);
        threw = false;
      } finally {
        if (threw) {
          synchronized (internalLock) {
            // It is possible that at this point that there are still tasks in
            // the queue, it would be nice to keep trying but the error may not
            // be recoverable.  So we update our state and propogate so that if
            // our caller deems it recoverable we won't be stuck.
            isThreadScheduled = false;
          }
        }
      }
    }
  }
164476
public ListenableFuture startAsync() {
        // This is run in a background thread by the Service implementation.
        if (chain == null) {
            // Just try to help catch what might be a programming error.
            log.warn("Starting up with no attached block chain. Did you forget to pass one to the constructor?");
        }
        checkState(!vUsedUp, "Cannot start a peer group twice");
        vRunning = true;
        vUsedUp = true;
        executorStartupLatch.countDown();
        // We do blocking waits during startup, so run on the executor thread.
        return executor.submit(new Runnable() {
            @Override
            public void run() {
                try {
                    log.info("Starting ...");
                    channels.startAsync();
                    channels.awaitRunning();
                    triggerConnections();
                    setupPinging();
                } catch (Throwable e) {
                    log.error("Exception when starting up", e);  // The executor swallows exceptions :(
                }
            }
        });
    }
709112
private static <T> ListenableFuture<T> submitAndAddQueueListener(
      ListeningExecutorService executorService, Callable<T> task,
      final BlockingQueue<Future<T>> queue) {
    final ListenableFuture<T> future = executorService.submit(task);
    future.addListener(new Runnable() {
      @Override public void run() {
        queue.add(future);
      }
    }, directExecutor());
    return future;
  }
1022117
void advancedAsyncCall() {
    ClientCall<HelloRequest, HelloReply> call =
        channel.newCall(GreeterGrpc.getSayHelloMethod(), CallOptions.DEFAULT);

    final CountDownLatch latch = new CountDownLatch(1);

    call.start(new ClientCall.Listener<HelloReply>() {

      @Override
      public void onClose(Status status, Metadata trailers) {
        Verify.verify(status.getCode() == Status.Code.INTERNAL);
        Verify.verify(status.getDescription().contains("Narwhal"));
        // Cause is not transmitted over the wire.
        latch.countDown();
      }
    }, new Metadata());

    call.sendMessage(HelloRequest.newBuilder().setName("Marge").build());
    call.halfClose();

    if (!Uninterruptibles.awaitUninterruptibly(latch, 1, TimeUnit.SECONDS)) {
      throw new RuntimeException("timeout!");
    }
  }
540114
void onNextCLR(final AllocatedEvaluator allocatedEvaluator) {
    try {
      allocatedEvaluator.setProcess(clrProcessFactory.newEvaluatorProcess());
      final Configuration contextConfiguration = ContextConfiguration.CONF
          .set(ContextConfiguration.IDENTIFIER, "HelloREEFContext")
          .build();

      final Configuration taskConfiguration = getCLRTaskConfiguration("Hello_From_CLR");

      allocatedEvaluator.submitContextAndTask(contextConfiguration, taskConfiguration);
    } catch (final BindException ex) {
      final String message = "Unable to setup Task or Context configuration.";
      LOG.log(Level.SEVERE, message, ex);
      throw new RuntimeException(message, ex);
    }
  }