Search in sources :

Example 1 with ZNRecord

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

the class ZKMetadataProvider method setInstanceZKMetadata.

public static void setInstanceZKMetadata(ZkHelixPropertyStore<ZNRecord> propertyStore, InstanceZKMetadata instanceZKMetadata) {
    ZNRecord znRecord = instanceZKMetadata.toZNRecord();
    propertyStore.set(StringUtil.join("/", PROPERTYSTORE_INSTANCE_CONFIGS_PREFIX, instanceZKMetadata.getId()), znRecord, AccessOption.PERSISTENT);
}
Also used : ZNRecord(org.apache.helix.ZNRecord)

Example 2 with ZNRecord

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

the class ZKMetadataProvider method getRealtimeSegmentZKMetadata.

@Nullable
public static RealtimeSegmentZKMetadata getRealtimeSegmentZKMetadata(ZkHelixPropertyStore<ZNRecord> propertyStore, String tableName, String segmentName) {
    String realtimeTableName = TableNameBuilder.REALTIME_TABLE_NAME_BUILDER.forTable(tableName);
    ZNRecord znRecord = propertyStore.get(constructPropertyStorePathForSegment(realtimeTableName, segmentName), null, AccessOption.PERSISTENT);
    // It is possible that the segment metadata has just been deleted due to retention.
    if (znRecord == null) {
        return null;
    }
    if (SegmentName.isHighLevelConsumerSegmentName(segmentName)) {
        return new RealtimeSegmentZKMetadata(znRecord);
    } else {
        return new LLCRealtimeSegmentZKMetadata(znRecord);
    }
}
Also used : RealtimeSegmentZKMetadata(com.linkedin.pinot.common.metadata.segment.RealtimeSegmentZKMetadata) LLCRealtimeSegmentZKMetadata(com.linkedin.pinot.common.metadata.segment.LLCRealtimeSegmentZKMetadata) LLCRealtimeSegmentZKMetadata(com.linkedin.pinot.common.metadata.segment.LLCRealtimeSegmentZKMetadata) ZNRecord(org.apache.helix.ZNRecord) Nullable(javax.annotation.Nullable)

Example 3 with ZNRecord

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

the class ZKMetadataProvider method getOfflineSegmentZKMetadataListForTable.

public static List<OfflineSegmentZKMetadata> getOfflineSegmentZKMetadataListForTable(ZkHelixPropertyStore<ZNRecord> propertyStore, String tableName) {
    List<OfflineSegmentZKMetadata> resultList = new ArrayList<OfflineSegmentZKMetadata>();
    if (propertyStore == null) {
        return resultList;
    }
    String offlineTableName = TableNameBuilder.OFFLINE_TABLE_NAME_BUILDER.forTable(tableName);
    if (propertyStore.exists(constructPropertyStorePathForResource(offlineTableName), AccessOption.PERSISTENT)) {
        List<ZNRecord> znRecordList = propertyStore.getChildren(constructPropertyStorePathForResource(offlineTableName), null, AccessOption.PERSISTENT);
        if (znRecordList != null) {
            for (ZNRecord record : znRecordList) {
                resultList.add(new OfflineSegmentZKMetadata(record));
            }
        }
    }
    return resultList;
}
Also used : OfflineSegmentZKMetadata(com.linkedin.pinot.common.metadata.segment.OfflineSegmentZKMetadata) ArrayList(java.util.ArrayList) ZNRecord(org.apache.helix.ZNRecord)

Example 4 with ZNRecord

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

the class ZKMetadataProvider method getRealtimeSegmentZKMetadataListForTable.

public static List<RealtimeSegmentZKMetadata> getRealtimeSegmentZKMetadataListForTable(ZkHelixPropertyStore<ZNRecord> propertyStore, String resourceName) {
    List<RealtimeSegmentZKMetadata> resultList = new ArrayList<RealtimeSegmentZKMetadata>();
    if (propertyStore == null) {
        return resultList;
    }
    String realtimeTableName = TableNameBuilder.REALTIME_TABLE_NAME_BUILDER.forTable(resourceName);
    if (propertyStore.exists(constructPropertyStorePathForResource(realtimeTableName), AccessOption.PERSISTENT)) {
        List<ZNRecord> znRecordList = propertyStore.getChildren(constructPropertyStorePathForResource(realtimeTableName), null, AccessOption.PERSISTENT);
        if (znRecordList != null) {
            for (ZNRecord record : znRecordList) {
                resultList.add(new RealtimeSegmentZKMetadata(record));
            }
        }
    }
    return resultList;
}
Also used : RealtimeSegmentZKMetadata(com.linkedin.pinot.common.metadata.segment.RealtimeSegmentZKMetadata) LLCRealtimeSegmentZKMetadata(com.linkedin.pinot.common.metadata.segment.LLCRealtimeSegmentZKMetadata) ArrayList(java.util.ArrayList) ZNRecord(org.apache.helix.ZNRecord)

Example 5 with ZNRecord

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

the class InstanceZKMetadata method toZNRecord.

@Override
public ZNRecord toZNRecord() {
    ZNRecord znRecord = new ZNRecord(getId());
    znRecord.setMapField(KAFKA_HIGH_LEVEL_CONSUMER_GROUP_MAP, _groupIdMap);
    znRecord.setMapField(KAFKA_HIGH_LEVEL_CONSUMER_PARTITION_MAP, _partitionMap);
    return znRecord;
}
Also used : ZNRecord(org.apache.helix.ZNRecord)

Aggregations

ZNRecord (org.apache.helix.ZNRecord)448 Test (org.testng.annotations.Test)186 ArrayList (java.util.ArrayList)117 Date (java.util.Date)111 HelixDataAccessor (org.apache.helix.HelixDataAccessor)91 ZKHelixDataAccessor (org.apache.helix.manager.zk.ZKHelixDataAccessor)78 Builder (org.apache.helix.PropertyKey.Builder)75 HashMap (java.util.HashMap)72 IdealState (org.apache.helix.model.IdealState)69 PropertyKey (org.apache.helix.PropertyKey)61 HelixException (org.apache.helix.HelixException)47 Map (java.util.Map)41 MockParticipantManager (org.apache.helix.integration.manager.MockParticipantManager)40 ZkBaseDataAccessor (org.apache.helix.manager.zk.ZkBaseDataAccessor)40 ClusterControllerManager (org.apache.helix.integration.manager.ClusterControllerManager)33 PropertyPathBuilder (org.apache.helix.PropertyPathBuilder)30 List (java.util.List)29 ZkClient (org.apache.helix.manager.zk.ZkClient)29 HelixAdmin (org.apache.helix.HelixAdmin)28 LiveInstance (org.apache.helix.model.LiveInstance)28