/** * Check if an Instance exists in the Helix cluster. * * @param instanceName: Name of instance to check. * @return True if instance exists in the Helix cluster, False otherwise. */ public boolean instanceExists(String instanceName) { ZNRecord znRecord = _cacheInstanceConfigsDataAccessor.get("/" + instanceName, null, AccessOption.PERSISTENT); return (znRecord != null); }
/** * Get all instance Ids. * * @return List of instance Ids */ @Nonnull public List<String> getAllInstances() { return _cacheInstanceConfigsDataAccessor.getChildNames("/", AccessOption.PERSISTENT); }
private boolean isExistingTable(String tableName) { return helix.getResourcesInCluster(zkPath).contains(tableName); }
FakeHelixManager(String clusterName, String instanceName, InstanceType instanceType, String zkAddress) { super(clusterName, instanceName, instanceType, zkAddress); super._zkclient = new ZkClient(StringUtil.join("/", StringUtils.chomp(ZkStarter.DEFAULT_ZK_STR, "/")), ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer()); _zkclient.deleteRecursive("/" + clusterName + "/PROPERTYSTORE"); _zkclient.createPersistent("/" + clusterName + "/PROPERTYSTORE", true); setPropertyStore(clusterName); }
public TableRetentionValidator(@Nonnull String zkAddress, @Nonnull String clusterName) { _clusterName = clusterName; _helixAdmin = new ZKHelixAdmin(zkAddress); _propertyStore = new ZkHelixPropertyStore<>(zkAddress, new ZNRecordSerializer(), PropertyPathConfig.getPath(PropertyType.PROPERTYSTORE, clusterName)); }
public void start(ControllerMetrics controllerMetrics) { _controllerMetrics = controllerMetrics; LOGGER.info("Starting realtime segments manager, adding a listener on the property store table configs path."); String zkUrl = _pinotHelixResourceManager.getHelixZkURL(); _zkClient = new ZkClient(zkUrl, ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT); _zkClient.setZkSerializer(new ZNRecordSerializer()); _zkClient.waitUntilConnected(CommonConstants.Helix.ZkClient.DEFAULT_CONNECT_TIMEOUT_SEC, TimeUnit.SECONDS); // Subscribe to any data/child changes to property _zkClient.subscribeChildChanges(_tableConfigPath, this); _zkClient.subscribeDataChanges(_tableConfigPath, this); // Subscribe to leadership changes ControllerLeadershipManager.getInstance().subscribe(PinotLLCRealtimeSegmentManager.class.getName(), this); // Setup change listeners for already existing tables, if any. processPropertyStoreChange(_tableConfigPath); }
@Override public boolean execute() throws Exception { LOGGER.info("Connecting to Zookeeper at address: {}", _zkAddress); ZkClient zkClient = new ZkClient(_zkAddress, 5000); String helixClusterName = "/" + _clusterName; LOGGER.info("Executing command: " + toString()); if (!zkClient.exists(helixClusterName)) { LOGGER.error("Cluster {} does not exist.", _clusterName); return false; } zkClient.deleteRecursive(helixClusterName); return true; } }
void closeZkClient() { _zkclient.close(); } }
public static IdealState cloneIdealState(IdealState idealState) { return new IdealState( (ZNRecord) ZN_RECORD_SERIALIZER.deserialize(ZN_RECORD_SERIALIZER.serialize(idealState.getRecord()))); }
void setPropertyStore(String clusterName) { _propertyStore = new ZkHelixPropertyStore<>(new ZkBaseDataAccessor<ZNRecord>(_zkclient), "/" + clusterName + "/PROPERTYSTORE", null); }
/** * State store that stores instances of {@link State}s in a ZooKeeper-backed {@link HelixPropertyStore} * storeRootDir will be created when the first entry is written if it does not exist * @param connectString ZooKeeper connect string * @param storeRootDir The root directory for the state store * @param compressedValues should values be compressed for storage? * @param stateClass The type of state being stored * @throws IOException */ public ZkStateStore(String connectString, String storeRootDir, boolean compressedValues, Class<T> stateClass) throws IOException { this.compressedValues = compressedValues; this.stateClass = stateClass; ZkSerializer serializer = new ByteArraySerializer(); propStore = new ZkHelixPropertyStore<byte[]>(connectString, serializer, storeRootDir); }
private boolean hasDisabledInstances(String logTag, List<String> instances) { boolean hasDisabled = false; for (String instance : instances) { if (!helix.getInstanceConfig(zkPath, instance).getInstanceEnabled()) { LOGGER.error("{} instance: {} is disabled", logTag, instance); hasDisabled = true; } } return hasDisabled; }
@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<>(new ZkBaseDataAccessor<ZNRecord>(_zkClient), "/" + helixClusterName + "/PROPERTYSTORE", null); }
public AutoAddInvertedIndex(@Nonnull String zkAddress, @Nonnull String clusterName, @Nonnull String controllerAddress, @Nonnull String brokerAddress, @Nonnull Strategy strategy, @Nonnull Mode mode) { _clusterName = clusterName; _controllerAddress = controllerAddress; _brokerAddress = brokerAddress; _helixAdmin = new ZKHelixAdmin(zkAddress); _propertyStore = new ZkHelixPropertyStore<>(zkAddress, new ZNRecordSerializer(), PropertyPathConfig.getPath(PropertyType.PROPERTYSTORE, clusterName)); _strategy = strategy; _mode = mode; }
protected void stopController() { stopControllerStarter(); FileUtils.deleteQuietly(new File(_controllerDataDir)); _zkClient.close(); }
private List<String> getAllTables() { List<String> tableNames = new ArrayList<>(); List<String> resources = helixAdmin.getResourcesInCluster(clusterName); for (String resourceName : resources) { if (TableNameBuilder.isTableResource(resourceName)) { tableNames.add(resourceName); } } return tableNames; } }
/** * Get the Helix instance config for the given instance Id. * * @param instanceId Instance Id * @return Helix instance config */ public InstanceConfig getHelixInstanceConfig(@Nonnull String instanceId) { ZNRecord znRecord = _cacheInstanceConfigsDataAccessor.get("/" + instanceId, null, AccessOption.PERSISTENT); return znRecord != null ? new InstanceConfig(znRecord) : null; }
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); }
@AfterTest public void afterTest() { _zkClient.close(); ZkStarter.stopLocalZkServer(_zookeeperInstance); }
public PinotZKChanger(String zkAddress, String clusterName) { this.clusterName = clusterName; helixAdmin = new ZKHelixAdmin(zkAddress); helixManager = HelixManagerFactory .getZKHelixManager(clusterName, "PinotNumReplicaChanger", InstanceType.ADMINISTRATOR, zkAddress); try { helixManager.connect(); } catch (Exception e) { throw new RuntimeException(e); } ZNRecordSerializer serializer = new ZNRecordSerializer(); String path = PropertyPathConfig.getPath(PropertyType.PROPERTYSTORE, clusterName); propertyStore = new ZkHelixPropertyStore<>(zkAddress, serializer, path); }