Search in sources :

Example 1 with GobblinHelixMessagingService

use of org.apache.gobblin.cluster.GobblinHelixMessagingService in project incubator-gobblin by apache.

the class YarnAppSecurityManager method sendTokenFileUpdatedMessage.

@VisibleForTesting
void sendTokenFileUpdatedMessage(InstanceType instanceType) {
    Criteria criteria = new Criteria();
    criteria.setInstanceName("%");
    criteria.setResource("%");
    criteria.setPartition("%");
    criteria.setPartitionState("%");
    criteria.setRecipientInstanceType(instanceType);
    /**
     * #HELIX-0.6.7-WORKAROUND
     * Add back when LIVESTANCES messaging is ported to 0.6 branch
     *    if (instanceType == InstanceType.PARTICIPANT) {
     *      criteria.setDataSource(Criteria.DataSource.LIVEINSTANCES);
     *    }
     */
    criteria.setSessionSpecific(true);
    Message tokenFileUpdatedMessage = new Message(Message.MessageType.USER_DEFINE_MSG, HelixMessageSubTypes.TOKEN_FILE_UPDATED.toString().toLowerCase() + UUID.randomUUID().toString());
    tokenFileUpdatedMessage.setMsgSubType(HelixMessageSubTypes.TOKEN_FILE_UPDATED.toString());
    tokenFileUpdatedMessage.setMsgState(Message.MessageState.NEW);
    if (instanceType == InstanceType.CONTROLLER) {
        tokenFileUpdatedMessage.setTgtSessionId("*");
    }
    // #HELIX-0.6.7-WORKAROUND
    // Temporarily bypass the default messaging service to allow upgrade to 0.6.7 which is missing support
    // for messaging to instances
    // int messagesSent = this.helixManager.getMessagingService().send(criteria, tokenFileUpdatedMessage);
    GobblinHelixMessagingService messagingService = new GobblinHelixMessagingService(this.helixManager);
    int messagesSent = messagingService.send(criteria, tokenFileUpdatedMessage);
    LOGGER.info(String.format("Sent %d token file updated message(s) to the %s", messagesSent, instanceType));
}
Also used : Message(org.apache.helix.model.Message) Criteria(org.apache.helix.Criteria) GobblinHelixMessagingService(org.apache.gobblin.cluster.GobblinHelixMessagingService) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 GobblinHelixMessagingService (org.apache.gobblin.cluster.GobblinHelixMessagingService)1 Criteria (org.apache.helix.Criteria)1 Message (org.apache.helix.model.Message)1