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);
}
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();
}
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;
}
}
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);
}
}
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;
}
Aggregations