org.apache.helix.InstanceType Java Examples
The following examples show how to use
org.apache.helix.InstanceType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DistClusterControllerStateModel.java From helix with Apache License 2.0 | 6 votes |
@Override public void onBecomeLeaderFromStandby(Message message, NotificationContext context) throws Exception { String clusterName = message.getPartitionName(); String controllerName = message.getTgtName(); logger.info(controllerName + " becoming leader from standby for " + clusterName); if (_controller == null) { _controller = HelixManagerFactory.getZKHelixManager(clusterName, controllerName, InstanceType.CONTROLLER, _zkAddr); _controller.setEnabledControlPipelineTypes(_enabledPipelineTypes); _controller.connect(); _controller.startTimerTasks(); logStateTransition("STANDBY", "LEADER", clusterName, controllerName); } else { logger.error("controller already exists:" + _controller.getInstanceName() + " for " + clusterName); } }
Example #2
Source File: ControllerTest.java From incubator-pinot with Apache License 2.0 | 6 votes |
protected void addFakeServerInstanceToAutoJoinHelixCluster(String instanceId, boolean isSingleTenant, int adminPort) throws Exception { HelixManager helixManager = HelixManagerFactory .getZKHelixManager(getHelixClusterName(), instanceId, InstanceType.PARTICIPANT, ZkStarter.DEFAULT_ZK_STR); helixManager.getStateMachineEngine() .registerStateModelFactory(FakeSegmentOnlineOfflineStateModelFactory.STATE_MODEL_DEF, FakeSegmentOnlineOfflineStateModelFactory.FACTORY_INSTANCE); helixManager.connect(); HelixAdmin helixAdmin = helixManager.getClusterManagmentTool(); if (isSingleTenant) { helixAdmin.addInstanceTag(getHelixClusterName(), instanceId, TagNameUtils.getOfflineTagForTenant(null)); helixAdmin.addInstanceTag(getHelixClusterName(), instanceId, TagNameUtils.getRealtimeTagForTenant(null)); } else { helixAdmin.addInstanceTag(getHelixClusterName(), instanceId, UNTAGGED_SERVER_INSTANCE); } HelixConfigScope configScope = new HelixConfigScopeBuilder(HelixConfigScope.ConfigScopeProperty.PARTICIPANT, getHelixClusterName()) .forParticipant(instanceId).build(); helixAdmin.setConfig(configScope, Collections.singletonMap(ADMIN_PORT_KEY, Integer.toString(adminPort))); _fakeInstanceHelixManagers.add(helixManager); }
Example #3
Source File: TestResourceGroupEndtoEnd.java From helix with Apache License 2.0 | 6 votes |
public HelixManager start() throws Exception { HelixManager manager = null; // zk cluster manager if (_clusterMangerType.equalsIgnoreCase("zk")) { manager = HelixManagerFactory.getZKHelixManager(_clusterName, _instanceName, InstanceType.PARTICIPANT, _zkConnectString); } else { throw new IllegalArgumentException("Unsupported cluster manager type:" + _clusterMangerType); } MockOnlineOfflineStateModelFactory stateModelFactory2 = new MockOnlineOfflineStateModelFactory(_transDelayInMs, _resourceName, _resourceTag, _instanceName); // genericStateMachineHandler = new StateMachineEngine(); StateMachineEngine stateMach = manager.getStateMachineEngine(); stateMach.registerStateModelFactory("OnlineOffline", stateModelFactory2); manager.connect(); //manager.getMessagingService().registerMessageHandlerFactory(MessageType.STATE_TRANSITION.name(), genericStateMachineHandler); return manager; }
Example #4
Source File: PinotHelixResourceManager.java From incubator-pinot with Apache License 2.0 | 6 votes |
public int reloadAllSegments(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; }
Example #5
Source File: PinotHelixResourceManager.java From incubator-pinot with Apache License 2.0 | 6 votes |
private void sendTableConfigRefreshMessage(String tableNameWithType) { TableConfigRefreshMessage tableConfigRefreshMessage = new TableConfigRefreshMessage(tableNameWithType); // Send table config refresh message to brokers Criteria recipientCriteria = new Criteria(); recipientCriteria.setRecipientInstanceType(InstanceType.PARTICIPANT); recipientCriteria.setInstanceName("%"); recipientCriteria.setResource(Helix.BROKER_RESOURCE_INSTANCE); recipientCriteria.setSessionSpecific(true); recipientCriteria.setPartition(tableNameWithType); // Send message with no callback and infinite timeout on the recipient int numMessagesSent = _helixZkManager.getMessagingService().send(recipientCriteria, tableConfigRefreshMessage, null, -1); if (numMessagesSent > 0) { // TODO: Would be nice if we can get the name of the instances to which messages were sent LOGGER.info("Sent {} table config refresh messages to brokers for table: {}", numMessagesSent, tableNameWithType); } else { LOGGER.warn("No table config refresh message sent to brokers for table: {}", tableNameWithType); } }
Example #6
Source File: ZKHelixAdmin.java From helix with Apache License 2.0 | 6 votes |
@Override public void removeInstanceTag(String clusterName, String instanceName, String tag) { logger.info("Remove instance tag {} for instance {} in cluster {}.", tag, instanceName, clusterName); if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) { throw new HelixException("cluster " + clusterName + " is not setup yet"); } if (!ZKUtil.isInstanceSetup(_zkClient, clusterName, instanceName, InstanceType.PARTICIPANT)) { throw new HelixException( "cluster " + clusterName + " instance " + instanceName + " is not setup yet"); } ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_zkClient)); PropertyKey.Builder keyBuilder = accessor.keyBuilder(); InstanceConfig config = accessor.getProperty(keyBuilder.instanceConfig(instanceName)); config.removeTag(tag); accessor.setProperty(keyBuilder.instanceConfig(instanceName), config); }
Example #7
Source File: HelixAgentMain.java From helix with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { CommandLine cmd = processCommandLineArgs(args); String zkAddress = cmd.getOptionValue(zkAddr); String clusterName = cmd.getOptionValue(cluster); String instance = cmd.getOptionValue(instanceName); String stateModelName = cmd.getOptionValue(stateModel); HelixManager manager = new ZKHelixManager(clusterName, instance, InstanceType.PARTICIPANT, zkAddress); StateMachineEngine stateMach = manager.getStateMachineEngine(); stateMach.registerStateModelFactory(stateModelName, new AgentStateModelFactory()); Runtime.getRuntime().addShutdownHook(new HelixAgentShutdownHook(manager)); try { manager.connect(); Thread.currentThread().join(); } catch (Exception e) { LOG.error(e.toString()); } finally { if (manager != null && manager.isConnected()) { manager.disconnect(); } } }
Example #8
Source File: TestGroupCommitAddBackData.java From helix with Apache License 2.0 | 6 votes |
@BeforeClass public void beforeClass() throws Exception { // Logger.getRootLogger().setLevel(Level.INFO); System.out.println("START " + CLASS_NAME + " at " + new Date(System.currentTimeMillis())); // setup storage cluster _gSetupTool.addCluster(CLUSTER_NAME, true); String storageNodeName = PARTICIPANT_PREFIX + "_" + START_PORT; _gSetupTool.addInstanceToCluster(CLUSTER_NAME, storageNodeName); _participant = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, storageNodeName); _participant.syncStart(); // create cluster manager _manager = HelixManagerFactory.getZKHelixManager(CLUSTER_NAME, "Admin", InstanceType.ADMINISTRATOR, ZK_ADDR); _manager.connect(); }
Example #9
Source File: YarnSecurityManagerTest.java From incubator-gobblin with Apache License 2.0 | 6 votes |
@Test public void testSendTokenFileUpdatedMessage() throws Exception { Logger log = LoggerFactory.getLogger("testSendTokenFileUpdatedMessage"); this._yarnAppYarnAppSecurityManagerWithKeytabs.sendTokenFileUpdatedMessage(InstanceType.CONTROLLER); Assert.assertEquals(this.curatorFramework.checkExists().forPath( String.format("/%s/CONTROLLER/MESSAGES", YarnSecurityManagerTest.class.getSimpleName())).getVersion(), 0); AssertWithBackoff.create().logger(log).timeoutMs(20000) .assertEquals(new GetHelixMessageNumFunc(YarnSecurityManagerTest.class.getSimpleName(), InstanceType.CONTROLLER, "", this.curatorFramework), 1, "1 controller message queued"); this._yarnAppYarnAppSecurityManagerWithKeytabs.sendTokenFileUpdatedMessage(InstanceType.PARTICIPANT, HELIX_TEST_INSTANCE_PARTICIPANT); Assert.assertEquals(this.curatorFramework.checkExists().forPath( String.format("/%s/INSTANCES/%s/MESSAGES", YarnSecurityManagerTest.class.getSimpleName(), HELIX_TEST_INSTANCE_PARTICIPANT)).getVersion(), 0); AssertWithBackoff.create().logger(log).timeoutMs(20000) .assertEquals(new GetHelixMessageNumFunc(YarnSecurityManagerTest.class.getSimpleName(), InstanceType.PARTICIPANT, HELIX_TEST_INSTANCE_PARTICIPANT, this.curatorFramework), 1, "1 controller message queued"); }
Example #10
Source File: HelixParticipant.java From ambry with Apache License 2.0 | 6 votes |
/** * Instantiate a HelixParticipant. * @param clusterMapConfig the {@link ClusterMapConfig} associated with this participant. * @param helixFactory the {@link HelixFactory} to use to get the {@link HelixManager}. * @param metricRegistry the {@link MetricRegistry} to instantiate {@link HelixParticipantMetrics}. * @param zkConnectStr the address identifying the zk service which this participant interacts with. * @param isSoleParticipant whether this is the sole participant on current node. */ public HelixParticipant(ClusterMapConfig clusterMapConfig, HelixFactory helixFactory, MetricRegistry metricRegistry, String zkConnectStr, boolean isSoleParticipant) { this.clusterMapConfig = clusterMapConfig; this.zkConnectStr = zkConnectStr; participantMetrics = new HelixParticipantMetrics(metricRegistry, isSoleParticipant ? null : zkConnectStr, localPartitionAndState); clusterName = clusterMapConfig.clusterMapClusterName; instanceName = getInstanceName(clusterMapConfig.clusterMapHostName, clusterMapConfig.clusterMapPort); if (clusterName.isEmpty()) { throw new IllegalStateException("Cluster name is empty in clusterMapConfig"); } // HelixAdmin is initialized in constructor allowing caller to do any administrative operations in Helix // before participating. helixAdmin = helixFactory.getHelixAdmin(this.zkConnectStr); manager = helixFactory.getZKHelixManager(clusterName, instanceName, InstanceType.PARTICIPANT, this.zkConnectStr); replicaSyncUpManager = new AmbryReplicaSyncUpManager(clusterMapConfig); partitionStateChangeListeners = new HashMap<>(); }
Example #11
Source File: TestControllerHistory.java From helix with Apache License 2.0 | 6 votes |
@Test() public void testControllerLeaderHistory() throws Exception { HelixManager manager = HelixManagerFactory .getZKHelixManager(CLUSTER_NAME, "admin", InstanceType.ADMINISTRATOR, ZK_ADDR); manager.connect(); PropertyKey.Builder keyBuilder = new PropertyKey.Builder(CLUSTER_NAME); PropertyKey propertyKey = keyBuilder.controllerLeaderHistory(); ControllerHistory controllerHistory = manager.getHelixDataAccessor().getProperty(propertyKey); Assert.assertNotNull(controllerHistory); List<String> list = controllerHistory.getRecord().getListField("HISTORY"); Assert.assertEquals(list.size(), 1); for (int i = 0; i <= 12; i++) { _controller.syncStop(); _controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, "Controller-" + i); _controller.syncStart(); } controllerHistory = manager.getHelixDataAccessor().getProperty(propertyKey); Assert.assertNotNull(controllerHistory); list = controllerHistory.getRecord().getListField("HISTORY"); Assert.assertEquals(list.size(), 10); manager.disconnect(); }
Example #12
Source File: SegmentCompletionIntegrationTest.java From incubator-pinot with Apache License 2.0 | 6 votes |
/** * Helper method to start a fake server that only implements Helix part. * * @throws Exception */ private void startFakeServer() throws Exception { _serverInstance = CommonConstants.Helix.PREFIX_OF_SERVER_INSTANCE + NetUtil.getHostAddress() + "_" + CommonConstants.Helix.DEFAULT_SERVER_NETTY_PORT; // Create server instance with the fake server state model _serverHelixManager = HelixManagerFactory .getZKHelixManager(getHelixClusterName(), _serverInstance, InstanceType.PARTICIPANT, ZkStarter.DEFAULT_ZK_STR); _serverHelixManager.getStateMachineEngine() .registerStateModelFactory(SegmentOnlineOfflineStateModelFactory.getStateModelName(), new FakeServerSegmentStateModelFactory()); _serverHelixManager.connect(); // Add Helix tag to the server _serverHelixManager.getClusterManagmentTool().addInstanceTag(getHelixClusterName(), _serverInstance, TableNameBuilder.REALTIME.tableNameWithType(TagNameUtils.DEFAULT_TENANT_NAME)); // Initialize controller leader locator ControllerLeaderLocator.create(_serverHelixManager); }
Example #13
Source File: ControllerTest.java From incubator-pinot with Apache License 2.0 | 6 votes |
protected void addFakeBrokerInstanceToAutoJoinHelixCluster(String instanceId, boolean isSingleTenant) throws Exception { HelixManager helixManager = HelixManagerFactory .getZKHelixManager(getHelixClusterName(), instanceId, InstanceType.PARTICIPANT, ZkStarter.DEFAULT_ZK_STR); helixManager.getStateMachineEngine() .registerStateModelFactory(FakeBrokerResourceOnlineOfflineStateModelFactory.STATE_MODEL_DEF, FakeBrokerResourceOnlineOfflineStateModelFactory.FACTORY_INSTANCE); helixManager.connect(); HelixAdmin helixAdmin = helixManager.getClusterManagmentTool(); if (isSingleTenant) { helixAdmin.addInstanceTag(getHelixClusterName(), instanceId, TagNameUtils.getBrokerTagForTenant(null)); } else { helixAdmin.addInstanceTag(getHelixClusterName(), instanceId, UNTAGGED_BROKER_INSTANCE); } _fakeInstanceHelixManagers.add(helixManager); }
Example #14
Source File: Message.java From helix with Apache License 2.0 | 6 votes |
/** * Create a reply based on an incoming message * @param srcMessage the incoming message * @param instanceName the instance that is the source of the reply * @param taskResultMap the result of executing the incoming message * @return the reply Message */ public static Message createReplyMessage(Message srcMessage, String instanceName, Map<String, String> taskResultMap) { if (srcMessage.getCorrelationId() == null) { throw new HelixException( "Message " + srcMessage.getMsgId() + " does not contain correlation id"); } Message replyMessage = new Message(MessageType.TASK_REPLY, UUID.randomUUID().toString()); replyMessage.setCorrelationId(srcMessage.getCorrelationId()); replyMessage.setResultMap(taskResultMap); replyMessage.setTgtSessionId("*"); replyMessage.setMsgState(MessageState.NEW); replyMessage.setSrcName(instanceName); if (srcMessage.getSrcInstanceType() == InstanceType.CONTROLLER) { replyMessage.setTgtName(InstanceType.CONTROLLER.name()); } else { replyMessage.setTgtName(srcMessage.getMsgSrc()); } return replyMessage; }
Example #15
Source File: BootstrapProcess.java From helix with Apache License 2.0 | 6 votes |
public void start() throws Exception { manager = HelixManagerFactory.getZKHelixManager(clusterName, instanceName, InstanceType.PARTICIPANT, zkConnectString); stateModelFactory = new BootstrapHandler(); // genericStateMachineHandler = new StateMachineEngine(); // genericStateMachineHandler.registerStateModelFactory("MasterSlave", stateModelFactory); StateMachineEngine stateMach = manager.getStateMachineEngine(); stateMach.registerStateModelFactory("MasterSlave", stateModelFactory); manager.getMessagingService().registerMessageHandlerFactory( MessageType.STATE_TRANSITION.name(), stateMach); manager.getMessagingService().registerMessageHandlerFactory( MessageType.USER_DEFINE_MSG.name(), new CustomMessageHandlerFactory()); manager.connect(); }
Example #16
Source File: TestDistControllerElection.java From helix with Apache License 2.0 | 6 votes |
@Test() public void testParticipant() throws Exception { String className = getShortClassName(); LOG.info("RUN " + className + " at " + new Date(System.currentTimeMillis())); final String clusterName = CLUSTER_PREFIX + "_" + className + "_" + "testParticipant"; TestHelper.setupEmptyCluster(_gZkClient, clusterName); final String controllerName = "participant_0"; HelixManager manager = new MockZKHelixManager(clusterName, controllerName, InstanceType.PARTICIPANT, _gZkClient); GenericHelixController participant0 = new GenericHelixController(); List<HelixTimerTask> timerTasks = Collections.emptyList(); try { DistributedLeaderElection election = new DistributedLeaderElection(manager, participant0, timerTasks); Assert.fail( "Should not be able construct DistributedLeaderElection object using participant manager."); } catch (HelixException ex) { // expected } TestHelper.dropCluster(clusterName, _gZkClient); }
Example #17
Source File: HelixCallbackMonitor.java From helix with Apache License 2.0 | 6 votes |
public HelixCallbackMonitor(InstanceType type, String clusterName, String instanceName, HelixConstants.ChangeType changeType) throws JMException { _changeType = changeType; _type = type; _clusterName = clusterName; _instanceName = instanceName; // Don't put instanceName into sensor name. This detail information is in the MBean name already. _sensorName = String .format("%s.%s.%s.%s", MonitorDomainNames.HelixCallback.name(), type.name(), clusterName, changeType.name()); _latencyGauge = new HistogramDynamicMetric("LatencyGauge", new Histogram( new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS))); _totalLatencyCounter = new SimpleDynamicMetric("LatencyCounter", 0l); _unbatchedCounter = new SimpleDynamicMetric("UnbatchedCounter", 0l); _counter = new SimpleDynamicMetric("Counter", 0l); }
Example #18
Source File: TestBasicSpectator.java From helix with Apache License 2.0 | 6 votes |
@Test public void TestSpectator() throws Exception { HelixManager relayHelixManager = HelixManagerFactory.getZKHelixManager(CLUSTER_NAME, null, InstanceType.SPECTATOR, ZK_ADDR); relayHelixManager.connect(); relayHelixManager.addExternalViewChangeListener(this); _gSetupTool.addResourceToCluster(CLUSTER_NAME, "NextDB", 64, STATE_MODEL); _gSetupTool.rebalanceStorageCluster(CLUSTER_NAME, "NextDB", 3); boolean result = ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier( ZK_ADDR, CLUSTER_NAME)); Assert.assertTrue(result); Assert.assertTrue(_externalViewChanges.containsKey("NextDB")); Assert.assertTrue(_externalViewChanges.containsKey(TEST_DB)); }
Example #19
Source File: GobblinTaskRunnerTest.java From incubator-gobblin with Apache License 2.0 | 6 votes |
@Test public void testConnectHelixManagerWithRetry() { HelixManager instanceManager = HelixManagerFactory.getZKHelixManager( clusterName, corruptHelixInstance, InstanceType.PARTICIPANT, testingZKServer.getConnectString()); ClusterIntegrationTestUtils.createPartialInstanceStructure(instanceManager, testingZKServer.getConnectString()); //Ensure that the connecting to Helix without retry will throw a HelixException try { corruptGobblinTaskRunner.connectHelixManager(); Assert.fail("Unexpected success in connecting to HelixManager"); } catch (Exception e) { //Assert that a HelixException is thrown. Assert.assertTrue(e.getClass().equals(HelixException.class)); } //Ensure that connect with retry succeeds corruptGobblinTaskRunner.connectHelixManagerWithRetry(); Assert.assertTrue(true); }
Example #20
Source File: MockHelixManager.java From ambry with Apache License 2.0 | 6 votes |
/** * Instantiate a MockHelixManager. * @param instanceName the name of the instance associated with this manager. * @param instanceType the {@link InstanceType} of the requester. * @param zkAddr the address identifying the zk service to which this request is to be made. * @param helixCluster the {@link MockHelixCluster} associated with this manager. * @param znRecordMap a map that contains ZNode path and its {@link ZNRecord} associated with HelixPropertyStore in this manager. * @param beBadException the {@link Exception} that this manager will throw on listener registrations. */ MockHelixManager(String instanceName, InstanceType instanceType, String zkAddr, MockHelixCluster helixCluster, Map<String, ZNRecord> znRecordMap, Exception beBadException) { this.instanceName = instanceName; this.instanceType = instanceType; mockAdmin = helixCluster.getHelixAdminFactory().getHelixAdmin(zkAddr); mockAdmin.addHelixManager(this); clusterName = helixCluster.getClusterName(); dataAccessor = new MockHelixDataAccessor(clusterName, mockAdmin); this.beBadException = beBadException; this.znRecordMap = znRecordMap; Properties storeProps = new Properties(); storeProps.setProperty("helix.property.store.root.path", "/" + clusterName + "/" + ClusterMapUtils.PROPERTYSTORE_STR); HelixPropertyStoreConfig propertyStoreConfig = new HelixPropertyStoreConfig(new VerifiableProperties(storeProps)); helixPropertyStore = (ZkHelixPropertyStore<ZNRecord>) CommonUtils.createHelixPropertyStore(zkAddr, propertyStoreConfig, Collections.singletonList(propertyStoreConfig.rootPath)); if (znRecordMap != null) { for (Map.Entry<String, ZNRecord> znodePathAndRecord : znRecordMap.entrySet()) { helixPropertyStore.set(znodePathAndRecord.getKey(), znodePathAndRecord.getValue(), AccessOption.PERSISTENT); } } }
Example #21
Source File: TestBatchAddJobs.java From helix with Apache License 2.0 | 5 votes |
public SubmitJobTask(String zkAddress, int index) throws Exception { HelixManager manager = HelixManagerFactory.getZKHelixManager(CLUSTER_NAME, "Administrator", InstanceType.ADMINISTRATOR, zkAddress); manager.connect(); _driver = new TaskDriver(manager); _jobPrefixName = "JOB_" + index + "#"; }
Example #22
Source File: DefaultMessagingService.java From helix with Apache License 2.0 | 5 votes |
private List<Message> generateMessagesForController(Message message) { List<Message> messages = new ArrayList<Message>(); String id = (message.getMsgId() == null) ? UUID.randomUUID().toString() : message.getMsgId(); Message newMessage = new Message(message.getRecord(), id); newMessage.setMsgId(id); newMessage.setSrcName(_manager.getInstanceName()); newMessage.setTgtName(InstanceType.CONTROLLER.name()); messages.add(newMessage); return messages; }
Example #23
Source File: TestClusterAggregateMetrics.java From helix with Apache License 2.0 | 5 votes |
@BeforeClass public void beforeClass() throws Exception { System.out.println("START " + CLASS_NAME + " at " + new Date(System.currentTimeMillis())); _setupTool = new ClusterSetup(ZK_ADDR); // setup storage cluster _setupTool.addCluster(CLUSTER_NAME, true); _setupTool.addResourceToCluster(CLUSTER_NAME, TEST_DB, NUM_PARTITIONS, STATE_MODEL); for (int i = 0; i < NUM_PARTICIPANTS; i++) { String storageNodeName = PARTICIPANT_PREFIX + "_" + (START_PORT + i); _setupTool.addInstanceToCluster(CLUSTER_NAME, storageNodeName); } _setupTool.rebalanceStorageCluster(CLUSTER_NAME, TEST_DB, NUM_REPLICAS); // start dummy participants for (int i = 0; i < NUM_PARTICIPANTS; i++) { String instanceName = PARTICIPANT_PREFIX + "_" + (START_PORT + i); _participants[i] = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, instanceName); _participants[i].syncStart(); } // start controller String controllerName = CONTROLLER_PREFIX + "_0"; _controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName); _controller.syncStart(); boolean result = ClusterStateVerifier.verifyByPolling( new ClusterStateVerifier.MasterNbInExtViewVerifier(ZK_ADDR, CLUSTER_NAME), 10000, 100); Assert.assertTrue(result); result = ClusterStateVerifier.verifyByPolling( new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR, CLUSTER_NAME), 10000, 100); Assert.assertTrue(result); // create cluster manager _manager = HelixManagerFactory.getZKHelixManager(CLUSTER_NAME, "Admin", InstanceType.ADMINISTRATOR, ZK_ADDR); _manager.connect(); }
Example #24
Source File: TestTaskStopQueue.java From helix with Apache License 2.0 | 5 votes |
@BeforeClass public void beforeClass() throws Exception { super.beforeClass(); _manager = HelixManagerFactory.getZKHelixManager(CLUSTER_NAME, "Admin", InstanceType.ADMINISTRATOR, ZK_ADDR); _manager.connect(); _driver = new TaskDriver(_manager); _admin = _gSetupTool.getClusterManagementTool(); }
Example #25
Source File: GobblinTaskRunnerTest.java From incubator-gobblin with Apache License 2.0 | 5 votes |
@Override protected void createHelixCluster() throws Exception { super.createHelixCluster(); String clusterName = super.getManagerConfig().getString(GobblinClusterConfigurationKeys.HELIX_CLUSTER_NAME_KEY); String zkConnectString = super.getManagerConfig().getString(GobblinClusterConfigurationKeys.ZK_CONNECTION_STRING_KEY); HelixManager helixManager = HelixManagerFactory .getZKHelixManager(clusterName, IntegrationBasicSuite.WORKER_INSTANCE_0, InstanceType.PARTICIPANT, zkConnectString); //Create a partial instance setup ClusterIntegrationTestUtils.createPartialInstanceStructure(helixManager, zkConnectString); }
Example #26
Source File: ZkStandAloneCMTestBase.java From helix with Apache License 2.0 | 5 votes |
@BeforeClass public void beforeClass() throws Exception { super.beforeClass(); System.out.println("START " + CLASS_NAME + " at " + new Date(System.currentTimeMillis())); // setup storage cluster _gSetupTool.addCluster(CLUSTER_NAME, true); _gSetupTool.addResourceToCluster(CLUSTER_NAME, TEST_DB, _PARTITIONS, STATE_MODEL); for (int i = 0; i < NODE_NR; i++) { String storageNodeName = PARTICIPANT_PREFIX + "_" + (START_PORT + i); _gSetupTool.addInstanceToCluster(CLUSTER_NAME, storageNodeName); } _gSetupTool.rebalanceStorageCluster(CLUSTER_NAME, TEST_DB, _replica); // start dummy participants for (int i = 0; i < NODE_NR; i++) { String instanceName = PARTICIPANT_PREFIX + "_" + (START_PORT + i); _participants[i] = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, instanceName); _participants[i].syncStart(); } // start controller String controllerName = CONTROLLER_PREFIX + "_0"; _controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName); _controller.syncStart(); _clusterVerifier = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkAddr(ZK_ADDR).build(); Assert.assertTrue(_clusterVerifier.verifyByPolling()); // create cluster manager _manager = HelixManagerFactory .getZKHelixManager(CLUSTER_NAME, "Admin", InstanceType.ADMINISTRATOR, ZK_ADDR); _manager.connect(); }
Example #27
Source File: MockParticipantManager.java From helix with Apache License 2.0 | 5 votes |
public MockParticipantManager(String zkAddr, String clusterName, String instanceName, int transDelay, HelixCloudProperty helixCloudProperty) { super(zkAddr, clusterName, instanceName, InstanceType.PARTICIPANT); _transDelay = transDelay; _msModelFactory = new MockMSModelFactory(null); _lsModelFactory = new DummyLeaderStandbyStateModelFactory(_transDelay); _ofModelFactory = new DummyOnlineOfflineStateModelFactory(_transDelay); _helixCloudProperty = helixCloudProperty; }
Example #28
Source File: DummyParticipant.java From helix with Apache License 2.0 | 5 votes |
public static void main(String[] args) { if (args.length < 3) { System.err.println("USAGE: DummyParticipant zkAddress clusterName instanceName"); System.exit(1); } String zkAddr = args[0]; String clusterName = args[1]; String instanceName = args[2]; HelixManager manager = null; try { manager = HelixManagerFactory.getZKHelixManager(clusterName, instanceName, InstanceType.PARTICIPANT, zkAddr); StateMachineEngine stateMach = manager.getStateMachineEngine(); DummyMSModelFactory msModelFactory = new DummyMSModelFactory(); stateMach.registerStateModelFactory("MasterSlave", msModelFactory); manager.connect(); Thread.currentThread().join(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { if (manager != null) { manager.disconnect(); } } }
Example #29
Source File: HelixAssignedParticipantCheckTest.java From incubator-gobblin with Apache License 2.0 | 5 votes |
@BeforeClass public void setUp() throws Exception { Config jobConfigOverrides = ClusterIntegrationTestUtils.buildSleepingJob(JOB_ID, TASK_STATE_FILE); //Set up a Gobblin Helix cluster integration job suite = new IntegrationBasicSuite(jobConfigOverrides); helixConfig = suite.getManagerConfig(); String clusterName = helixConfig.getString(GobblinClusterConfigurationKeys.HELIX_CLUSTER_NAME_KEY); String zkConnectString = helixConfig.getString(GobblinClusterConfigurationKeys.ZK_CONNECTION_STRING_KEY); helixManager = HelixManagerFactory.getZKHelixManager(clusterName, "TestManager", InstanceType.SPECTATOR, zkConnectString); }
Example #30
Source File: TestCustomizedStateUpdate.java From helix with Apache License 2.0 | 5 votes |
@BeforeClass public void beforeClass() throws Exception { super.beforeClass(); _manager = HelixManagerFactory .getZKHelixManager(CLUSTER_NAME, "admin", InstanceType.ADMINISTRATOR, ZK_ADDR); _manager.connect(); _participants[0].connect(); _mockProvider = CustomizedStateProviderFactory.getInstance() .buildCustomizedStateProvider(_manager, _participants[0].getInstanceName()); _dataAccessor = _manager.getHelixDataAccessor(); _propertyKey = _dataAccessor.keyBuilder() .customizedStates(_participants[0].getInstanceName(), CUSTOMIZE_STATE_NAME); }