@VisibleForTesting void connectHelixManager() { try { if (this.helixManager.isPresent()) { this.helixManager.get().connect(); this.helixManager.get() .getMessagingService() .registerMessageHandlerFactory(Message.MessageType.USER_DEFINE_MSG.toString(), new ControllerUserDefinedMessageHandlerFactory(flowCatalogLocalCommit, scheduler, resourceHandler, serviceName)); } } catch (Exception e) { LOGGER.error("HelixManager failed to connect", e); throw Throwables.propagate(e); } }
@VisibleForTesting void connectHelixManager() { try { this.jobHelixManager.connect(); this.jobHelixManager.getMessagingService() .registerMessageHandlerFactory(GobblinHelixConstants.SHUTDOWN_MESSAGE_TYPE, new ParticipantShutdownMessageHandlerFactory()); this.jobHelixManager.getMessagingService() .registerMessageHandlerFactory(Message.MessageType.USER_DEFINE_MSG.toString(), getUserDefinedMessageHandlerFactory()); if (this.taskDriverHelixManager.isPresent()) { this.taskDriverHelixManager.get().connect(); } } catch (Exception e) { logger.error("HelixManager failed to connect", e); throw Throwables.propagate(e); } }
public int reloadAllSegments(@Nonnull String tableNameWithType) { LOGGER.info("Sending reload message for table: {}", tableNameWithType); Criteria recipientCriteria = new Criteria(); recipientCriteria.setRecipientInstanceType(InstanceType.PARTICIPANT); recipientCriteria.setInstanceName("%"); recipientCriteria.setResource(tableNameWithType); recipientCriteria.setSessionSpecific(true); SegmentReloadMessage segmentReloadMessage = new SegmentReloadMessage(tableNameWithType, null); ClusterMessagingService messagingService = _helixZkManager.getMessagingService(); // Infinite timeout on the recipient int timeoutMs = -1; int numMessagesSent = messagingService.send(recipientCriteria, segmentReloadMessage, null, timeoutMs); if (numMessagesSent > 0) { LOGGER.info("Sent {} reload messages for table: {}", numMessagesSent, tableNameWithType); } else { LOGGER.warn("No reload message sent for table: {}", tableNameWithType); } return numMessagesSent; }
public int reloadSegment(@Nonnull String tableNameWithType, @Nonnull String segmentName) { LOGGER.info("Sending reload message for segment: {} in table: {}", segmentName, tableNameWithType); Criteria recipientCriteria = new Criteria(); recipientCriteria.setRecipientInstanceType(InstanceType.PARTICIPANT); recipientCriteria.setInstanceName("%"); recipientCriteria.setResource(tableNameWithType); recipientCriteria.setPartition(segmentName); recipientCriteria.setSessionSpecific(true); SegmentReloadMessage segmentReloadMessage = new SegmentReloadMessage(tableNameWithType, segmentName); ClusterMessagingService messagingService = _helixZkManager.getMessagingService(); // Infinite timeout on the recipient int timeoutMs = -1; int numMessagesSent = messagingService.send(recipientCriteria, segmentReloadMessage, null, timeoutMs); if (numMessagesSent > 0) { LOGGER.info("Sent {} reload messages for segment: {} in table: {}", numMessagesSent, segmentName, tableNameWithType); } else { LOGGER.warn("No reload message sent for segment: {} in table: {}", segmentName, tableNameWithType); } return numMessagesSent; }
this.jobClusterHelixManager.getMessagingService() .registerMessageHandlerFactory(Message.MessageType.USER_DEFINE_MSG.toString(), userDefinedMessageHandlerFactory); this.jobClusterHelixManager.getMessagingService() .registerMessageHandlerFactory(GobblinHelixConstants.SHUTDOWN_MESSAGE_TYPE, new ControllerShutdownMessageHandlerFactory());
@VisibleForTesting void sendShutdownRequest() { Criteria criteria = new Criteria(); criteria.setInstanceName("%"); criteria.setResource("%"); criteria.setPartition("%"); criteria.setPartitionState("%"); criteria.setRecipientInstanceType(InstanceType.CONTROLLER); criteria.setSessionSpecific(true); Message shutdownRequest = new Message(GobblinHelixConstants.SHUTDOWN_MESSAGE_TYPE, HelixMessageSubTypes.APPLICATION_MASTER_SHUTDOWN.toString().toLowerCase() + UUID.randomUUID().toString()); shutdownRequest.setMsgSubType(HelixMessageSubTypes.APPLICATION_MASTER_SHUTDOWN.toString()); shutdownRequest.setMsgState(Message.MessageState.NEW); shutdownRequest.setTgtSessionId("*"); int messagesSent = this.helixManager.getMessagingService().send(criteria, shutdownRequest); if (messagesSent == 0) { LOGGER.error(String.format("Failed to send the %s message to the controller", shutdownRequest.getMsgSubType())); } }
@VisibleForTesting void sendShutdownRequest() { final Criteria criteria = new Criteria(); criteria.setInstanceName("%"); criteria.setResource("%"); criteria.setPartition("%"); criteria.setPartitionState("%"); criteria.setRecipientInstanceType(InstanceType.CONTROLLER); criteria.setSessionSpecific(true); final Message shutdownRequest = new Message(GobblinHelixConstants.SHUTDOWN_MESSAGE_TYPE, HelixMessageSubTypes.APPLICATION_MASTER_SHUTDOWN.toString().toLowerCase() + UUID.randomUUID().toString()); shutdownRequest.setMsgSubType(HelixMessageSubTypes.APPLICATION_MASTER_SHUTDOWN.toString()); shutdownRequest.setMsgState(Message.MessageState.NEW); shutdownRequest.setTgtSessionId("*"); // Wait for 5 minutes final int timeout = 300000; // Send shutdown request to Cluster master, which will send shutdown request to workers // Upon receiving shutdown response from workers, master will shut itself down and call back shutdownASG() final int messagesSent = this.helixManager.getMessagingService().send(criteria, shutdownRequest, shutdownASG(),timeout); if (messagesSent == 0) { LOGGER.error(String.format("Failed to send the %s message to the controller", shutdownRequest.getMsgSubType())); } }
ClusterMessagingService messagingService = _helixZkManager.getMessagingService(); LOGGER.info("Sending timeboundary refresh message for segment {} of table {}:{} to recipients {}", segmentName, rawTableName, refreshMessage, recipientCriteria);
@VisibleForTesting public static void sendUserDefinedMessage(String messageSubType, String messageVal, String messageId, InstanceType instanceType, HelixManager helixManager, Logger logger) { Criteria criteria = new Criteria(); criteria.setInstanceName("%"); criteria.setResource("%"); criteria.setPartition("%"); criteria.setPartitionState("%"); criteria.setRecipientInstanceType(instanceType); criteria.setSessionSpecific(true); Message message = new Message(Message.MessageType.USER_DEFINE_MSG.toString(), messageId); message.setMsgSubType(messageSubType); message.setAttribute(Message.Attributes.INNER_MESSAGE, messageVal); message.setMsgState(Message.MessageState.NEW); message.setTgtSessionId("*"); int messagesSent = helixManager.getMessagingService().send(criteria, message); if (messagesSent == 0) { logger.error(String.format("Failed to send the %s message to the participants", message)); } } }
recipientCriteria.setSessionSpecific(true); ClusterMessagingService messagingService = _helixZkManager.getMessagingService(); LOGGER.info("Sending refresh message for segment {} of table {}:{} to recipients {}", segmentName, rawTableName, refreshMessage, recipientCriteria);
@Test(dependsOnMethods = "testCreateHelixCluster") public void testSendShutdownRequest() throws Exception { this.helixManager.connect(); this.helixManager.getMessagingService().registerMessageHandlerFactory(GobblinHelixConstants.SHUTDOWN_MESSAGE_TYPE, new TestShutdownMessageHandlerFactory(this)); this.gobblinYarnAppLauncher.connectHelixManager(); this.gobblinYarnAppLauncher.sendShutdownRequest(); Assert.assertEquals(this.curatorFramework.checkExists() .forPath(String.format("/%s/CONTROLLER/MESSAGES", GobblinYarnAppLauncherTest.class.getSimpleName())) .getVersion(), 0); YarnSecurityManagerTest.GetControllerMessageNumFunc getCtrlMessageNum = new YarnSecurityManagerTest.GetControllerMessageNumFunc(GobblinYarnAppLauncherTest.class.getSimpleName(), this.curatorFramework); AssertWithBackoff assertWithBackoff = AssertWithBackoff.create().logger(LoggerFactory.getLogger("testSendShutdownRequest")).timeoutMs(20000); assertWithBackoff.assertEquals(getCtrlMessageNum, 1, "1 controller message queued"); // Give Helix sometime to handle the message assertWithBackoff.assertEquals(getCtrlMessageNum, 0, "all controller messages processed"); }
@BeforeClass public void setUp() throws Exception { // Use a random ZK port this.testingZKServer = new TestingServer(-1); LOG.info("Testing ZK Server listening on: " + testingZKServer.getConnectString()); URL url = GobblinClusterManagerTest.class.getClassLoader().getResource( GobblinClusterManager.class.getSimpleName() + ".conf"); Assert.assertNotNull(url, "Could not find resource " + url); Config config = ConfigFactory.parseURL(url) .withValue("gobblin.cluster.zk.connection.string", ConfigValueFactory.fromAnyRef(testingZKServer.getConnectString())) .resolve(); String zkConnectionString = config.getString(GobblinClusterConfigurationKeys.ZK_CONNECTION_STRING_KEY); HelixUtils.createGobblinHelixCluster(zkConnectionString, config.getString(GobblinClusterConfigurationKeys.HELIX_CLUSTER_NAME_KEY)); this.helixManager = HelixManagerFactory .getZKHelixManager(config.getString(GobblinClusterConfigurationKeys.HELIX_CLUSTER_NAME_KEY), TestHelper.TEST_HELIX_INSTANCE_NAME, InstanceType.PARTICIPANT, zkConnectionString); this.helixManager.connect(); this.helixManager.getMessagingService().registerMessageHandlerFactory(GobblinHelixConstants.SHUTDOWN_MESSAGE_TYPE, new TestShutdownMessageHandlerFactory(this)); this.gobblinClusterManager = new GobblinClusterManager(TestHelper.TEST_APPLICATION_NAME, TestHelper.TEST_APPLICATION_ID, config, Optional.<Path>absent()); this.gobblinClusterManager.getEventBus().register(this.gobblinClusterManager); this.gobblinClusterManager.connectHelixManager(); }
@Test(dependsOnMethods = "testGetReconnectableApplicationId") public void testSendShutdownRequest() throws Exception { // Connect to Helix as Controller and register a shutdown request handler this.helixManager.connect(); this.helixManager.getMessagingService().registerMessageHandlerFactory(GobblinHelixConstants.SHUTDOWN_MESSAGE_TYPE, new TestShutdownMessageHandlerFactory(this)); // Make Gobblin AWS Cluster launcher start a shutdown this.gobblinAwsClusterLauncher.connectHelixManager(); this.gobblinAwsClusterLauncher.sendShutdownRequest(); Assert.assertEquals(this.curatorFramework.checkExists() .forPath(String.format("/%s/CONTROLLER/MESSAGES", this.helixClusterName)).getVersion(), 0); GetControllerMessageNumFunc getCtrlMessageNum = new GetControllerMessageNumFunc(this.helixClusterName, this.curatorFramework); // Assert to check if shutdown message was issued AssertWithBackoff assertWithBackoff = AssertWithBackoff.create().logger(LoggerFactory.getLogger("testSendShutdownRequest")).timeoutMs(20000); assertWithBackoff.assertEquals(getCtrlMessageNum, 1, "1 controller message queued"); // Assert to check if shutdown message was processed // Give Helix sometime to handle the message assertWithBackoff.assertEquals(getCtrlMessageNum, 0, "all controller messages processed"); }
_helixManager.getMessagingService() .registerMessageHandlerFactory(Message.MessageType.USER_DEFINE_MSG.toString(), messageHandlerFactory);
_pinotHelixProperties.getLong(CommonConstants.Broker.CONFIG_OF_BROKER_REFRESH_TIMEBOUNDARY_INFO_SLEEP_INTERVAL, CommonConstants.Broker.DEFAULT_BROKER_REFRESH_TIMEBOUNDARY_INFO_SLEEP_INTERVAL_MS)); _helixManager.getMessagingService() .registerMessageHandlerFactory(Message.MessageType.USER_DEFINE_MSG.toString(), _tbiMessageHandler);
public ControllerManagerHelper(HelixManager manager, List<HelixTimerTask> controllerTimerTasks) { _manager = manager; _messagingService = (DefaultMessagingService) manager.getMessagingService(); _controllerTimerTasks = controllerTimerTasks; }
public ControllerManagerHelper(HelixManager manager, List<HelixTimerTask> controllerTimerTasks) { _manager = manager; _messagingService = (DefaultMessagingService) manager.getMessagingService(); _controllerTimerTasks = controllerTimerTasks; }
@VisibleForTesting void connectHelixManager() { try { if (this.helixManager.isPresent()) { this.helixManager.get().connect(); this.helixManager.get() .getMessagingService() .registerMessageHandlerFactory(Message.MessageType.USER_DEFINE_MSG.toString(), new ControllerUserDefinedMessageHandlerFactory(flowCatalogLocalCommit, scheduler, resourceHandler, serviceName)); } } catch (Exception e) { LOGGER.error("HelixManager failed to connect", e); throw Throwables.propagate(e); } }
@Override public void broadcast( final MessageType type, final Map<String, String> content ) { if (!isStarted()) { return; } participantManager.getMessagingService().send( buildCriteria(), buildMessage( type, content ) ); }
@Override public void sendTo( String resourceId, MessageType type, Map<String, String> content ) { if (!isStarted()) { return; } participantManager.getMessagingService().send( buildCriteria( resourceId ), buildMessage( type, content ) ); }