Search in sources :

Example 6 with ZNRecordSerializer

use of org.apache.helix.manager.zk.ZNRecordSerializer in project pinot by linkedin.

the class UpdateSegmentState method init.

private void init() {
    LOGGER.info("Trying to connect to " + _zkAddress + " cluster " + _clusterName);
    _helixAdmin = new ZKHelixAdmin(_zkAddress);
    ZNRecordSerializer serializer = new ZNRecordSerializer();
    String path = PropertyPathConfig.getPath(PropertyType.PROPERTYSTORE, _clusterName);
    _propertyStore = new ZkHelixPropertyStore<>(_zkAddress, serializer, path);
}
Also used : ZKHelixAdmin(org.apache.helix.manager.zk.ZKHelixAdmin) ZNRecordSerializer(org.apache.helix.manager.zk.ZNRecordSerializer)

Example 7 with ZNRecordSerializer

use of org.apache.helix.manager.zk.ZNRecordSerializer 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)

Example 8 with ZNRecordSerializer

use of org.apache.helix.manager.zk.ZNRecordSerializer in project pinot by linkedin.

the class ValidateConfigCommand method execute.

@Override
public boolean execute() throws Exception {
    if (!_validateTableConfig && !_validateSchema) {
        throw new RuntimeException("Need to specify at least one of -schema and -tableConfig");
    }
    LOGGER.info("Connecting to Zookeeper: {}, cluster: ", _zkAddress, _clusterName);
    ZNRecordSerializer serializer = new ZNRecordSerializer();
    String path = PropertyPathConfig.getPath(PropertyType.PROPERTYSTORE, _clusterName);
    _helixPropertyStore = new ZkHelixPropertyStore<>(_zkAddress, serializer, path);
    LOGGER.info("\n\n-------------------- Starting Validation --------------------");
    if (_validateTableConfig) {
        validateTableConfig();
    }
    if (_validateSchema) {
        validateSchema();
    }
    return true;
}
Also used : ZNRecordSerializer(org.apache.helix.manager.zk.ZNRecordSerializer)

Example 9 with ZNRecordSerializer

use of org.apache.helix.manager.zk.ZNRecordSerializer in project pinot by linkedin.

the class TimeBoundaryServiceTest method beforeTest.

@BeforeTest
public void beforeTest() {
    _zookeeperInstance = ZkStarter.startLocalZkServer();
    _zkClient = new ZkClient(StringUtil.join("/", StringUtils.chomp(ZkStarter.DEFAULT_ZK_STR, "/")), ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer());
    String helixClusterName = "TestTimeBoundaryService";
    _zkClient.deleteRecursive("/" + helixClusterName + "/PROPERTYSTORE");
    _zkClient.createPersistent("/" + helixClusterName + "/PROPERTYSTORE", true);
    _propertyStore = new ZkHelixPropertyStore<ZNRecord>(new ZkBaseDataAccessor<ZNRecord>(_zkClient), "/" + helixClusterName + "/PROPERTYSTORE", null);
}
Also used : ZkClient(org.apache.helix.manager.zk.ZkClient) ZkBaseDataAccessor(org.apache.helix.manager.zk.ZkBaseDataAccessor) ZNRecord(org.apache.helix.ZNRecord) ZNRecordSerializer(org.apache.helix.manager.zk.ZNRecordSerializer) BeforeTest(org.testng.annotations.BeforeTest)

Example 10 with ZNRecordSerializer

use of org.apache.helix.manager.zk.ZNRecordSerializer in project pinot by linkedin.

the class DeleteOverlappingSegmentsInPinot method deleteOverlappingSegments.

public static boolean deleteOverlappingSegments(String zkUrl, String zkCluster, String tableName) {
    boolean updateSuccessful = false;
    if (!tableName.endsWith("_OFFLINE")) {
        tableName = tableName + "_OFFLINE";
    }
    ZkClient zkClient = new ZkClient(zkUrl);
    ZNRecordSerializer zkSerializer = new ZNRecordSerializer();
    zkClient.setZkSerializer(zkSerializer);
    BaseDataAccessor<ZNRecord> baseDataAccessor = new ZkBaseDataAccessor<>(zkClient);
    HelixDataAccessor helixDataAccessor = new ZKHelixDataAccessor(zkCluster, baseDataAccessor);
    Builder keyBuilder = helixDataAccessor.keyBuilder();
    PropertyKey idealStateKey = keyBuilder.idealStates(tableName);
    PropertyKey externalViewKey = keyBuilder.externalView(tableName);
    IdealState currentIdealState = helixDataAccessor.getProperty(idealStateKey);
    byte[] serializeIS = zkSerializer.serialize(currentIdealState.getRecord());
    String name = tableName + ".idealstate." + System.currentTimeMillis();
    File outputFile = new File("/tmp", name);
    try (FileOutputStream fileOutputStream = new FileOutputStream(outputFile)) {
        IOUtils.write(serializeIS, fileOutputStream);
    } catch (IOException e) {
        LOG.error("Exception in delete overlapping segments", e);
        return updateSuccessful;
    }
    LOG.info("Saved current idealstate to {}", outputFile);
    IdealState newIdealState;
    do {
        newIdealState = computeNewIdealStateAfterDeletingOverlappingSegments(helixDataAccessor, idealStateKey);
        LOG.info("Updating IdealState");
        updateSuccessful = helixDataAccessor.getBaseDataAccessor().set(idealStateKey.getPath(), newIdealState.getRecord(), newIdealState.getRecord().getVersion(), AccessOption.PERSISTENT);
        if (updateSuccessful) {
            int numSegmentsDeleted = currentIdealState.getPartitionSet().size() - newIdealState.getPartitionSet().size();
            LOG.info("Successfully updated IdealState: Removed segments: {}", (numSegmentsDeleted));
        }
    } while (!updateSuccessful);
    try {
        while (true) {
            Thread.sleep(10000);
            ExternalView externalView = helixDataAccessor.getProperty(externalViewKey);
            IdealState idealState = helixDataAccessor.getProperty(idealStateKey);
            Set<String> evPartitionSet = externalView.getPartitionSet();
            Set<String> isPartitionSet = idealState.getPartitionSet();
            if (evPartitionSet.equals(isPartitionSet)) {
                LOG.info("Table {} has reached stable state. i.e segments in external view match idealstates", tableName);
                break;
            }
        }
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    return updateSuccessful;
}
Also used : ZkClient(org.apache.helix.manager.zk.ZkClient) ExternalView(org.apache.helix.model.ExternalView) ZkBaseDataAccessor(org.apache.helix.manager.zk.ZkBaseDataAccessor) Builder(org.apache.helix.PropertyKey.Builder) IOException(java.io.IOException) IdealState(org.apache.helix.model.IdealState) ZKHelixDataAccessor(org.apache.helix.manager.zk.ZKHelixDataAccessor) HelixDataAccessor(org.apache.helix.HelixDataAccessor) FileOutputStream(java.io.FileOutputStream) File(java.io.File) ZNRecord(org.apache.helix.ZNRecord) PropertyKey(org.apache.helix.PropertyKey) ZNRecordSerializer(org.apache.helix.manager.zk.ZNRecordSerializer) ZKHelixDataAccessor(org.apache.helix.manager.zk.ZKHelixDataAccessor)

Aggregations

ZNRecordSerializer (org.apache.helix.manager.zk.ZNRecordSerializer)15 ZNRecord (org.apache.helix.ZNRecord)9 ZkClient (org.apache.helix.manager.zk.ZkClient)8 ZKHelixAdmin (org.apache.helix.manager.zk.ZKHelixAdmin)4 File (java.io.File)3 HelixDataAccessor (org.apache.helix.HelixDataAccessor)3 PropertyKey (org.apache.helix.PropertyKey)3 IdealState (org.apache.helix.model.IdealState)3 InputStream (java.io.InputStream)2 URL (java.net.URL)2 HelixAdmin (org.apache.helix.HelixAdmin)2 ZKHelixDataAccessor (org.apache.helix.manager.zk.ZKHelixDataAccessor)2 ZkBaseDataAccessor (org.apache.helix.manager.zk.ZkBaseDataAccessor)2 ExternalView (org.apache.helix.model.ExternalView)2 ZkHelixPropertyStore (org.apache.helix.store.zk.ZkHelixPropertyStore)2 Test (org.testng.annotations.Test)2 AbstractTableConfig (com.linkedin.pinot.common.config.AbstractTableConfig)1 ServerInstance (com.linkedin.pinot.common.response.ServerInstance)1 ServiceStatus (com.linkedin.pinot.common.utils.ServiceStatus)1 PinotHelixBrokerResourceOnlineOfflineStateModelGenerator (com.linkedin.pinot.controller.helix.core.PinotHelixBrokerResourceOnlineOfflineStateModelGenerator)1