Search in sources :

Example 31 with ZNRecord

use of org.apache.helix.ZNRecord in project pinot by linkedin.

the class SegmentCompletionIntegrationTests method startFakeServer.

// Start a fake server that only implements helix part, does not consume any rows.
private void startFakeServer() throws Exception {
    String hostName = NetUtil.getHostAddress();
    _serverInstance = CommonConstants.Helix.PREFIX_OF_SERVER_INSTANCE + hostName + "_" + CommonConstants.Helix.DEFAULT_SERVER_NETTY_PORT;
    _helixManager = HelixManagerFactory.getZKHelixManager(_clusterName, _serverInstance, InstanceType.PARTICIPANT, ZkStarter.DEFAULT_ZK_STR);
    final StateMachineEngine stateMachineEngine = _helixManager.getStateMachineEngine();
    _helixManager.connect();
    ZkHelixPropertyStore<ZNRecord> zkPropertyStore = ZkUtils.getZkPropertyStore(_helixManager, _clusterName);
    final StateModelFactory<?> stateModelFactory = new FakeServerSegmentStateModelFactory(_clusterName, _serverInstance, zkPropertyStore);
    stateMachineEngine.registerStateModelFactory(SegmentOnlineOfflineStateModelFactory.getStateModelName(), stateModelFactory);
    _helixAdmin = _helixManager.getClusterManagmentTool();
    _helixAdmin.addInstanceTag(_clusterName, _serverInstance, TableNameBuilder.REALTIME_TABLE_NAME_BUILDER.forTable(ControllerTenantNameBuilder.DEFAULT_TENANT_NAME));
    ControllerLeaderLocator.create(_helixManager);
}
Also used : StateMachineEngine(org.apache.helix.participant.StateMachineEngine) ZNRecord(org.apache.helix.ZNRecord)

Example 32 with ZNRecord

use of org.apache.helix.ZNRecord in project pinot by linkedin.

the class LLCRealtimeClusterIntegrationTest method testSegmentFlushSize.

@Test
public void testSegmentFlushSize() {
    ZkClient zkClient = new ZkClient(ZkStarter.DEFAULT_ZK_STR, 10000);
    zkClient.setZkSerializer(new ZNRecordSerializer());
    String zkPath = "/LLCRealtimeClusterIntegrationTest/PROPERTYSTORE/SEGMENTS/mytable_REALTIME";
    List<String> segmentNames = zkClient.getChildren(zkPath);
    for (String segmentName : segmentNames) {
        ZNRecord znRecord = zkClient.<ZNRecord>readData(zkPath + "/" + segmentName);
        Assert.assertEquals(znRecord.getSimpleField(CommonConstants.Segment.FLUSH_THRESHOLD_SIZE), Integer.toString(ROW_COUNT_FOR_REALTIME_SEGMENT_FLUSH / KAFKA_PARTITION_COUNT), "Segment " + segmentName + " does not have the expected flush size");
    }
    zkClient.close();
}
Also used : ZkClient(org.apache.helix.manager.zk.ZkClient) ZNRecord(org.apache.helix.ZNRecord) ZNRecordSerializer(org.apache.helix.manager.zk.ZNRecordSerializer) Test(org.testng.annotations.Test)

Example 33 with ZNRecord

use of org.apache.helix.ZNRecord in project pinot by linkedin.

the class SegmentFetcherAndLoader method getSchema.

private Schema getSchema(String schemaName) throws IOException {
    PinotHelixPropertyStoreZnRecordProvider propertyStoreHelper = PinotHelixPropertyStoreZnRecordProvider.forSchema(_propertyStore);
    ZNRecord record = propertyStoreHelper.get(schemaName);
    if (record != null) {
        LOGGER.info("Found schema: {}", schemaName);
        return SchemaUtils.fromZNRecord(record);
    } else {
        return null;
    }
}
Also used : PinotHelixPropertyStoreZnRecordProvider(com.linkedin.pinot.common.utils.helix.PinotHelixPropertyStoreZnRecordProvider) ZNRecord(org.apache.helix.ZNRecord)

Example 34 with ZNRecord

use of org.apache.helix.ZNRecord in project pinot by linkedin.

the class PinotSegmentRebalancer method rebalanceTenantTables.

/**
   * rebalances all tables for the tenant
   * @param tenantName
   */
public void rebalanceTenantTables(String tenantName) throws Exception {
    String tableConfigPath = "/CONFIGS/TABLE";
    List<Stat> stats = new ArrayList<>();
    List<ZNRecord> tableConfigs = propertyStore.getChildren(tableConfigPath, stats, 0);
    String rawTenantName = tenantName.replaceAll("_OFFLINE", "").replace("_REALTIME", "");
    int nRebalances = 0;
    for (ZNRecord znRecord : tableConfigs) {
        AbstractTableConfig tableConfig;
        try {
            tableConfig = AbstractTableConfig.fromZnRecord(znRecord);
        } catch (Exception e) {
            LOGGER.warn("Failed to parse table configuration for ZnRecord id: {}. Skipping", znRecord.getId());
            continue;
        }
        if (tableConfig.getTenantConfig().getServer().equals(rawTenantName)) {
            LOGGER.info(tableConfig.getTableName() + ":" + tableConfig.getTenantConfig().getServer());
            nRebalances++;
            rebalanceTable(tableConfig.getTableName(), tenantName);
        }
    }
    if (nRebalances == 0) {
        LOGGER.info("No tables found for tenant " + tenantName);
    }
}
Also used : Stat(org.apache.zookeeper.data.Stat) ArrayList(java.util.ArrayList) AbstractTableConfig(com.linkedin.pinot.common.config.AbstractTableConfig) ZNRecord(org.apache.helix.ZNRecord)

Example 35 with ZNRecord

use of org.apache.helix.ZNRecord in project pinot by linkedin.

the class MoveReplicaGroup method getTableConfig.

private AbstractTableConfig getTableConfig(String tableName) throws IOException, JSONException {
    ZNRecordSerializer serializer = new ZNRecordSerializer();
    String path = PropertyPathConfig.getPath(PropertyType.PROPERTYSTORE, zkPath);
    ZkHelixPropertyStore<ZNRecord> propertyStore = new ZkHelixPropertyStore<>(zkHost, serializer, path);
    ZNRecord tcZnRecord = propertyStore.get("/CONFIGS/TABLE/" + tableName, null, 0);
    AbstractTableConfig tableConfig = AbstractTableConfig.fromZnRecord(tcZnRecord);
    LOGGER.debug("Loaded table config");
    return tableConfig;
}
Also used : ZkHelixPropertyStore(org.apache.helix.store.zk.ZkHelixPropertyStore) AbstractTableConfig(com.linkedin.pinot.common.config.AbstractTableConfig) ZNRecord(org.apache.helix.ZNRecord) ZNRecordSerializer(org.apache.helix.manager.zk.ZNRecordSerializer)

Aggregations

ZNRecord (org.apache.helix.ZNRecord)80 ArrayList (java.util.ArrayList)23 IdealState (org.apache.helix.model.IdealState)15 Test (org.testng.annotations.Test)13 LLCRealtimeSegmentZKMetadata (com.linkedin.pinot.common.metadata.segment.LLCRealtimeSegmentZKMetadata)12 HashMap (java.util.HashMap)12 LLCSegmentName (com.linkedin.pinot.common.utils.LLCSegmentName)11 AbstractTableConfig (com.linkedin.pinot.common.config.AbstractTableConfig)10 RealtimeSegmentZKMetadata (com.linkedin.pinot.common.metadata.segment.RealtimeSegmentZKMetadata)8 HelixAdmin (org.apache.helix.HelixAdmin)8 ZNRecordSerializer (org.apache.helix.manager.zk.ZNRecordSerializer)8 HashSet (java.util.HashSet)6 List (java.util.List)6 ExternalView (org.apache.helix.model.ExternalView)6 OfflineSegmentZKMetadata (com.linkedin.pinot.common.metadata.segment.OfflineSegmentZKMetadata)5 KafkaStreamMetadata (com.linkedin.pinot.common.metadata.stream.KafkaStreamMetadata)5 BeforeTest (org.testng.annotations.BeforeTest)5 TableType (com.linkedin.pinot.common.utils.CommonConstants.Helix.TableType)4 PinotHelixPropertyStoreZnRecordProvider (com.linkedin.pinot.common.utils.helix.PinotHelixPropertyStoreZnRecordProvider)4 ZkClient (org.apache.helix.manager.zk.ZkClient)4