use of org.apache.helix.ClusterMessagingService in project pinot by linkedin.
the class PinotHelixResourceManager method sendSegmentRefreshMessage.
/**
* Attempt to send a message to refresh the new segment. We do not wait for any acknowledgements.
* The message is sent as session-specific, so if a new zk session is created (e.g. server restarts)
* it will not get the message.
*
* @param segmentZKMetadata is the metadata of the newly arrived segment.
* @return true if message has been sent to at least one instance of the server hosting the segment.
*/
private void sendSegmentRefreshMessage(OfflineSegmentZKMetadata segmentZKMetadata) {
final String segmentName = segmentZKMetadata.getSegmentName();
final String rawTableName = segmentZKMetadata.getTableName();
final String tableName = TableNameBuilder.OFFLINE_TABLE_NAME_BUILDER.forTable(rawTableName);
// Infinite timeout on the recipient.
final int timeoutMs = -1;
SegmentRefreshMessage refreshMessage = new SegmentRefreshMessage(tableName, segmentName, segmentZKMetadata.getCrc());
Criteria recipientCriteria = new Criteria();
recipientCriteria.setRecipientInstanceType(InstanceType.PARTICIPANT);
recipientCriteria.setInstanceName("%");
recipientCriteria.setResource(tableName);
recipientCriteria.setPartition(segmentName);
recipientCriteria.setSessionSpecific(true);
ClusterMessagingService messagingService = _helixZkManager.getMessagingService();
LOGGER.info("Sending refresh message for segment {} of table {}:{} to recipients {}", segmentName, rawTableName, refreshMessage, recipientCriteria);
// Helix sets the timeoutMs argument specified in 'send' call as the processing timeout of the message.
int nMsgsSent = messagingService.send(recipientCriteria, refreshMessage, null, timeoutMs);
if (nMsgsSent > 0) {
// TODO Would be nice if we can get the name of the instances to which messages were sent.
LOGGER.info("Sent {} msgs to refresh segment {} of table {}", nMsgsSent, segmentName, rawTableName);
} else {
// May be the case when none of the servers are up yet. That is OK, because when they come up they will get the
// new version of the segment.
LOGGER.warn("Unable to send segment refresh message for {} of table {}, nMsgs={}", segmentName, tableName, nMsgsSent);
}
}
Aggregations