@Transition(from = "OFFLINE", to = "SLAVE")
public void offlineToSlave(Message message, NotificationContext context) {
System.out.println("BootstrapProcess.BootstrapStateModel.offlineToSlave()");
HelixManager manager = context.getManager();
ClusterMessagingService messagingService = manager.getMessagingService();
Message requestBackupUriRequest =
new Message(MessageType.USER_DEFINE_MSG, MessageId.from(UUID.randomUUID().toString()));
requestBackupUriRequest.setMsgSubType(BootstrapProcess.REQUEST_BOOTSTRAP_URL);
requestBackupUriRequest.setMsgState(MessageState.NEW);
Criteria recipientCriteria = new Criteria();
recipientCriteria.setInstanceName("*");
recipientCriteria.setRecipientInstanceType(InstanceType.PARTICIPANT);
recipientCriteria.setResource(message.getResourceId().stringify());
recipientCriteria.setPartition(message.getPartitionId().stringify());
recipientCriteria.setSessionSpecific(true);
// wait for 30 seconds
int timeout = 30000;
BootstrapReplyHandler responseHandler = new BootstrapReplyHandler();
int sentMessageCount =
messagingService.sendAndWait(recipientCriteria, requestBackupUriRequest, responseHandler,
timeout);
if (sentMessageCount == 0) {
// could not find any other node hosting the partition
} else if (responseHandler.getBootstrapUrl() != null) {
System.out.println("Got bootstrap url:" + responseHandler.getBootstrapUrl());