Search in sources :

Example 6 with PinotHelixResourceManager

use of com.linkedin.pinot.controller.helix.core.PinotHelixResourceManager in project pinot by linkedin.

the class ValidationManagerTest method setUp.

@BeforeClass
public void setUp() throws Exception {
    _zookeeperInstance = ZkStarter.startLocalZkServer();
    _zkClient = new ZkClient(ZK_STR);
    Thread.sleep(1000);
    _pinotHelixResourceManager = new PinotHelixResourceManager(ZK_STR, HELIX_CLUSTER_NAME, CONTROLLER_INSTANCE_NAME, null, 1000L, true, /*isUpdateStateModel=*/
    false);
    _pinotHelixResourceManager.start();
    ControllerRequestBuilderUtil.addFakeDataInstancesToAutoJoinHelixCluster(HELIX_CLUSTER_NAME, ZK_STR, 2, true);
    ControllerRequestBuilderUtil.addFakeBrokerInstancesToAutoJoinHelixCluster(HELIX_CLUSTER_NAME, ZK_STR, 2, true);
    String OfflineTableConfigJson = ControllerRequestBuilderUtil.buildCreateOfflineTableJSON(TEST_TABLE_NAME, null, null, "timestamp", "millsSinceEpoch", "DAYS", "5", 2, "BalanceNumSegmentAssignmentStrategy").toString();
    _offlineTableConfig = AbstractTableConfig.init(OfflineTableConfigJson);
    final String instanceId = "localhost_helixController";
    _helixManager = HelixSetupUtils.setup(HELIX_CLUSTER_NAME, ZK_STR, instanceId, /*isUpdateStateModel=*/
    false);
    _pinotHelixResourceManager.addTable(_offlineTableConfig);
}
Also used : ZkClient(org.apache.helix.manager.zk.ZkClient) PinotHelixResourceManager(com.linkedin.pinot.controller.helix.core.PinotHelixResourceManager) Matchers.anyString(org.mockito.Matchers.anyString) BeforeClass(org.testng.annotations.BeforeClass)

Example 7 with PinotHelixResourceManager

use of com.linkedin.pinot.controller.helix.core.PinotHelixResourceManager in project pinot by linkedin.

the class HelixHelperTest method testWriteLargeIdealState.

/**
   * Regression test for large ideal state updates failing silently
   */
@Test
public void testWriteLargeIdealState() {
    final int segmentCount = 20000;
    PinotHelixResourceManager resourceManager = _controller.getHelixResourceManager();
    final IdealState idealState = new IdealState(RESOURCE_NAME);
    idealState.setStateModelDefRef("OnlineOffline");
    idealState.setRebalanceMode(IdealState.RebalanceMode.CUSTOMIZED);
    idealState.setReplicas("0");
    resourceManager.getHelixAdmin().addResource(CLUSTER_NAME, RESOURCE_NAME, idealState);
    HelixHelper.updateIdealState(resourceManager.getHelixZkManager(), RESOURCE_NAME, new Function<IdealState, IdealState>() {

        @Override
        public IdealState apply(@Nullable IdealState idealState) {
            for (int i = 0; i < segmentCount; ++i) {
                idealState.setPartitionState("segment_" + i, INSTANCE_NAME, "ONLINE");
            }
            return idealState;
        }
    }, RetryPolicies.noDelayRetryPolicy(1));
    Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);
    final IdealState resourceIdealState = resourceManager.getHelixAdmin().getResourceIdealState(CLUSTER_NAME, RESOURCE_NAME);
    for (int i = 0; i < segmentCount; ++i) {
        assertEquals(resourceIdealState.getInstanceStateMap("segment_" + i).get(INSTANCE_NAME), "ONLINE");
    }
}
Also used : PinotHelixResourceManager(com.linkedin.pinot.controller.helix.core.PinotHelixResourceManager) IdealState(org.apache.helix.model.IdealState) Test(org.testng.annotations.Test)

Example 8 with PinotHelixResourceManager

use of com.linkedin.pinot.controller.helix.core.PinotHelixResourceManager in project pinot by linkedin.

the class PinotResourceManagerTest method setup.

@BeforeTest
public void setup() throws Exception {
    _zookeeperInstance = ZkStarter.startLocalZkServer();
    _zkClient = new ZkClient(ZK_SERVER);
    final String instanceId = "localhost_helixController";
    _pinotHelixResourceManager = new PinotHelixResourceManager(ZK_SERVER, HELIX_CLUSTER_NAME, instanceId, null, 10000L, true, /*isUpdateStateModel=*/
    false);
    _pinotHelixResourceManager.start();
    final String helixZkURL = HelixConfig.getAbsoluteZkPathForHelix(ZK_SERVER);
    _helixZkManager = HelixSetupUtils.setup(HELIX_CLUSTER_NAME, helixZkURL, instanceId, /*isUpdateStateModel=*/
    false);
    _helixAdmin = _helixZkManager.getClusterManagmentTool();
    /////////////////////////
    _numInstance = 1;
    ControllerRequestBuilderUtil.addFakeDataInstancesToAutoJoinHelixCluster(HELIX_CLUSTER_NAME, ZK_SERVER, _numInstance, true);
    ControllerRequestBuilderUtil.addFakeBrokerInstancesToAutoJoinHelixCluster(HELIX_CLUSTER_NAME, ZK_SERVER, 1, true);
    Thread.sleep(3000);
    Assert.assertEquals(_helixAdmin.getInstancesInClusterWithTag(HELIX_CLUSTER_NAME, "DefaultTenant_BROKER").size(), 1);
    Assert.assertEquals(_helixAdmin.getInstancesInClusterWithTag(HELIX_CLUSTER_NAME, "DefaultTenant_OFFLINE").size(), 1);
    Assert.assertEquals(_helixAdmin.getInstancesInClusterWithTag(HELIX_CLUSTER_NAME, "DefaultTenant_REALTIME").size(), 1);
    // Adding table
    String OfflineTableConfigJson = ControllerRequestBuilderUtil.buildCreateOfflineTableJSON(TABLE_NAME, null, null, 1).toString();
    AbstractTableConfig offlineTableConfig = AbstractTableConfig.init(OfflineTableConfigJson);
    _pinotHelixResourceManager.addTable(offlineTableConfig);
}
Also used : ZkClient(org.apache.helix.manager.zk.ZkClient) PinotHelixResourceManager(com.linkedin.pinot.controller.helix.core.PinotHelixResourceManager) AbstractTableConfig(com.linkedin.pinot.common.config.AbstractTableConfig) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

PinotHelixResourceManager (com.linkedin.pinot.controller.helix.core.PinotHelixResourceManager)8 BeforeTest (org.testng.annotations.BeforeTest)4 AbstractTableConfig (com.linkedin.pinot.common.config.AbstractTableConfig)3 ZkClient (org.apache.helix.manager.zk.ZkClient)3 ZkClient (org.I0Itec.zkclient.ZkClient)2 JSONObject (org.json.JSONObject)2 BeforeClass (org.testng.annotations.BeforeClass)2 HelixBrokerStarter (com.linkedin.pinot.broker.broker.helix.HelixBrokerStarter)1 Tenant (com.linkedin.pinot.common.config.Tenant)1 TenantBuilder (com.linkedin.pinot.common.config.Tenant.TenantBuilder)1 Configuration (org.apache.commons.configuration.Configuration)1 ExternalView (org.apache.helix.model.ExternalView)1 IdealState (org.apache.helix.model.IdealState)1 Matchers.anyString (org.mockito.Matchers.anyString)1 Test (org.testng.annotations.Test)1