Creates a QUERY_REPLY message.

@param leader the current leader in broadcasting phase.
@return a protobuf message.
775799
public static Message buildQueryReply(String leader) {
    QueryReply reply = QueryReply.newBuilder()
                                 .setLeader(leader)
                                 .build();
    return Message.newBuilder().setType(MessageType.QUERY_LEADER_REPLY)
                               .setReply(reply)
                               .build();
  }
63508
public void answerWhoisMasterQuestion(JoinMessage joinMessage, Connection connection) {
        if (!ensureValidConfiguration(joinMessage)) {
            return;
        }

        if (clusterService.isJoined()) {
            if (!checkIfJoinRequestFromAnExistingMember(joinMessage, connection)) {
                sendMasterAnswer(joinMessage.getAddress());
            }
        } else {
            if (logger.isFineEnabled()) {
                logger.fine(format("Received a master question from %s,"
                        + " but this node is not master itself or doesn't have a master yet!", joinMessage.getAddress()));
            }
        }
    }
248868
public QuerySmResult queryShortMessage(String messageId,
            TypeOfNumber sourceAddrTon, NumberingPlanIndicator sourceAddrNpi,
            String sourceAddr) throws PDUException, ResponseTimeoutException,
            InvalidResponseException, NegativeResponseException, IOException {
        
        ensureTransmittable("queryShortMessage");
        
        QuerySmCommandTask task = new QuerySmCommandTask(pduSender(),
                messageId, sourceAddrTon, sourceAddrNpi, sourceAddr);
        
        QuerySmResp resp = (QuerySmResp)executeSendCommand(task,
                getTransactionTimer());

        if (resp.getMessageId().equals(messageId)) {
            return new QuerySmResult(resp.getFinalDate(), resp
                    .getMessageState(), resp.getErrorCode());
        } else {
            // message id requested not same as the returned
            throw new InvalidResponseException(
                    "Requested message_id doesn't match with the result");
        }
    }
465611
public CompletableFuture<Void> anoint() {
    if (role.role() == RaftServer.Role.LEADER) {
      return CompletableFuture.completedFuture(null);
    }

    CompletableFuture<Void> future = new CompletableFuture<>();

    threadContext.execute(() -> {
      // Register a leader election listener to wait for the election of this node.
      Consumer<RaftMember> electionListener = new Consumer<RaftMember>() {
        @Override
        public void accept(RaftMember member) {
          if (member.memberId().equals(cluster.getMember().memberId())) {
            future.complete(null);
          } else {
            future.completeExceptionally(new RaftException.ProtocolException("Failed to transfer leadership"));
          }
          removeLeaderElectionListener(this);
        }
      };
      addLeaderElectionListener(electionListener);

      // If a leader already exists, request a leadership transfer from it. Otherwise, transition to the candidate
      // state and attempt to get elected.
      RaftMember member = getCluster().getMember();
      RaftMember leader = getLeader();
      if (leader != null) {
        protocol.transfer(leader.memberId(), TransferRequest.builder()
            .withMember(member.memberId())
            .build()).whenCompleteAsync((response, error) -> {
              if (error != null) {
                future.completeExceptionally(error);
              } else if (response.status() == RaftResponse.Status.ERROR) {
                future.completeExceptionally(response.error().createException());
              } else {
                transition(RaftServer.Role.CANDIDATE);
              }
            }, threadContext);
      } else {
        transition(RaftServer.Role.CANDIDATE);
      }
    });
    return future;
  }
297717
public final SubscriptionMessage createNewSubscriptionMessage() throws MessageCreateFailedException {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "createNewSubscriptionMessage");
    SubscriptionMessage msg = null;
    try {
      msg = new SubscriptionMessageImpl(MfpConstants.CONSTRUCTOR_NO_OP);
    }
    catch (MessageDecodeFailedException e) {
      /* No need to FFDC this as JsMsgObject will already have done so */
      // No FFDC code needed
      throw new MessageCreateFailedException(e);
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "createNewSubscriptionMessage");
    return msg;
  }
372438
function whenDeathListener(msg) {
      if (msg.context === 'leader' && msg.action === 'death') {
        leaderElector.applyOnce().then(function () {
          if (leaderElector.isLeader) finish();
        });
      }
    }
81985
@Override
	public void start(LeaderRetrievalListener listener) {
		checkNotNull(listener, "Listener must not be null.");

		synchronized (startStopLock) {
			checkState(!started, "StandaloneLeaderRetrievalService can only be started once.");
			started = true;

			// directly notify the listener, because we already know the leading JobManager's address
			listener.notifyLeaderAddress(leaderAddress, leaderId);
		}
	}
586081
public BaseMessage createReplyMessage(BaseMessage messageIn)
    {
        //ProductRequest productRequest = (ProductRequest)messageIn.getMessageDataDesc(null);
        BaseMessage replyMessage = (BaseMessage)this.getMessageProcessInfo().createReplyMessage(messageIn);
        
        //BaseProductResponse responseMessage = (BaseProductResponse)replyMessage.getMessageDataDesc(null);
        //responseMessage.moveRequestInfoToReply(productRequest);
        if (replyMessage == null)
            replyMessage = new TreeMessage(null, null);
        if (replyMessage.getExternalMessage() == null)
            new ExternalMapTrxMessageIn(replyMessage, null);
        return replyMessage;    // Override this!
    }
1012721
List<QueryResponse> broadcast(ClusteredQueryCommand clusteredQueryCommand) {
      // invoke on own node
      Future<QueryResponse> localResponse = localInvoke(clusteredQueryCommand);
      Map<Address, Response> responses = rpcManager.invokeRemotely(null, clusteredQueryCommand, rpcOptions);
      List<QueryResponse> queryResponses = cast(responses);
      try {
         queryResponses.add(localResponse.get());
      } catch (InterruptedException e) {
         throw new SearchException("Interrupted while searching locally", e);
      } catch (ExecutionException e) {
         throw new SearchException("Exception while searching locally", e);
      }
      return queryResponses;
   }
239895
public ChatMessage createFinalMessage(MessageSentResponse response) {
        return ChatMessage.builder()
                .setMessageId(response.getId())
                .setSentEventId(response.getEventId())
                .setConversationId(conversationId)
                .setSentBy(sender)
                .setFromWhom(new Sender(sender, sender))
                .setSentOn(System.currentTimeMillis())
                .setParts(getAllParts())
                .setMetadata(originalMessage.getMetadata()).build();
    }
1109743
@Broadcast(writeEntity = false)
    @POST
    @Produces("application/json")
    public Response broadcast(Message message) {
        return new Response(message.author, message.message);
    }
610821
private void reply(final String response, final boolean error,
            final String errorMessage, final String stackTrace,
            final String statusCode, final int statusCodeInt,
            Map<String, List<String>> responseHeaders) {

        if (!sentReply) {
            // must update sentReply first to avoid duplicated msg.
            sentReply = true;

            final ResponseOnSingeRequest res = new ResponseOnSingeRequest(
                    response, error, errorMessage, stackTrace, statusCode,
                    statusCodeInt, PcDateUtils.getNowDateTimeStrStandard(),
                    responseHeaders);
            if (!getContext().system().deadLetters().equals(sender)) {
                sender.tell(res, getSelf());
            }
            if (getContext() != null) {
                getContext().stop(getSelf());
            }
        }

    }
644792
public Collection<ProposalResponse> queryByChaincode(QueryByChaincodeRequest queryByChaincodeRequest, Collection<Peer> peers) throws InvalidArgumentException, ProposalException {
        return sendProposal(queryByChaincodeRequest, peers);
    }
1071016
public Message createReplyMessage(Message message)
    {
        Object objResponseID = ((BaseMessage)message).getMessageHeader().get(TrxMessageHeader.MESSAGE_RESPONSE_ID);
        if (objResponseID == null)
            return null;    // TODO (don) FIX this - return an error.
        MessageProcessInfo recMessageProcessInfo = (MessageProcessInfo)this.getMessageProcessInfo(objResponseID.toString());
        MessageInfo recMessageInfo = (MessageInfo)((ReferenceField)recMessageProcessInfo.getField(MessageProcessInfo.MESSAGE_INFO_ID)).getReference();
        BaseMessage replyMessage = new TreeMessage(null, null);
        MessageRecordDesc messageRecordDesc = recMessageInfo.createNewMessage(replyMessage, null);
        return replyMessage;
    }
182073
public SipServletResponse createResponse(final int statusCode, final String reasonPhrase) {
		return createResponse(statusCode, reasonPhrase, true, false);
	}
940519
@Override
	public FbBotMillResponse createResponse(MessageEnvelope envelope) {
		return ReplyFactory.addTypingAction(this.typingAction).build(envelope);
	}
1285071
public void askSubscribers( Actor sender, String topic, Object message, Callback cb ) {
        List<ReceiverActor> subscriber = topic2Subscriber.get(topic);
        if ( subscriber != null ) {
            List<IPromise> results = subscriber.stream()
                    .filter(subs -> !subs.equals(sender))
                    .map(subs -> subs.receiveAsk(topic, message))
                    .collect(Collectors.toList());
            try {
                all((List) results).await(5000); // is non-blocking
            } catch (Exception ex) {
                // timeout goes here
                Log.Info(this, "timeout in broadcast");
            }
            results.forEach( promise -> cb.pipe(promise.get()));
            cb.finish(); // important to release callback mapping in remoting !
        }
    }