public static void updateResourceConfigsFor(Map<String, String> newConfigs, String resourceName, String clusterName, HelixAdmin admin) { final HelixConfigScope scope = getResourceScopeFor(clusterName, resourceName); admin.setConfig(scope, newConfigs); }
private void updateInstanceConfigInHelix(Map<String, String> props) { HelixConfigScope scope = new HelixConfigScopeBuilder(ConfigScopeProperty.PARTICIPANT, _helixClusterName).forParticipant(_instanceId) .build(); _helixAdmin.setConfig(scope, props); }
admin.setConfig(scope, props);
public static void addFakeDataInstanceToAutoJoinHelixCluster(String helixClusterName, String zkServer, String instanceId, boolean isSingleTenant, int adminPort) throws Exception { final HelixManager helixZkManager = HelixManagerFactory.getZKHelixManager(helixClusterName, instanceId, InstanceType.PARTICIPANT, zkServer); final StateMachineEngine stateMachineEngine = helixZkManager.getStateMachineEngine(); final StateModelFactory<?> stateModelFactory = new EmptySegmentOnlineOfflineStateModelFactory(); stateMachineEngine .registerStateModelFactory(EmptySegmentOnlineOfflineStateModelFactory.getStateModelDef(), stateModelFactory); helixZkManager.connect(); if (isSingleTenant) { helixZkManager.getClusterManagmentTool().addInstanceTag(helixClusterName, instanceId, TableNameBuilder.OFFLINE.tableNameWithType(TagNameUtils.DEFAULT_TENANT_NAME)); helixZkManager.getClusterManagmentTool().addInstanceTag(helixClusterName, instanceId, TableNameBuilder.REALTIME.tableNameWithType(TagNameUtils.DEFAULT_TENANT_NAME)); } else { helixZkManager.getClusterManagmentTool().addInstanceTag(helixClusterName, instanceId, UNTAGGED_SERVER_INSTANCE); } HelixConfigScope scope = new HelixConfigScopeBuilder(HelixConfigScope.ConfigScopeProperty.PARTICIPANT, helixClusterName) .forParticipant(instanceId).build(); Map<String, String> props = new HashMap<>(); props.put(CommonConstants.Helix.Instance.ADMIN_PORT_KEY, String.valueOf(adminPort)); helixZkManager.getClusterManagmentTool().setConfig(scope, props); }
public void enableAutoBalancing() { HelixConfigScope scope = new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER).forCluster(_helixClusterName) .build(); Map<String, String> properties = new HashMap<String, String>(); properties.put(AUTO_BALANCING, ENABLE); _helixAdmin.setConfig(scope, properties); }
public void disableAutoBalancing() { HelixConfigScope scope = new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER).forCluster(_helixClusterName) .build(); Map<String, String> properties = new HashMap<String, String>(); properties.put(AUTO_BALANCING, DISABLE); _helixAdmin.setConfig(scope, properties); }
private synchronized void setEmptyResourceConfig(String topicName) { _helixAdmin.setConfig( new HelixConfigScopeBuilder(ConfigScopeProperty.RESOURCE).forCluster(_helixClusterName) .forResource(topicName).build(), new HashMap<String, String>()); }
public static void createHelixClusterIfNeeded(String helixClusterName, String zkPath) { final HelixAdmin admin = new ZKHelixAdmin(zkPath); if (admin.getClusters().contains(helixClusterName)) { LOGGER.info( "cluster already exist, skipping it.. ********************************************* "); return; } LOGGER.info("Creating a new cluster, as the helix cluster : " + helixClusterName + " was not found ********************************************* "); admin.addCluster(helixClusterName, false); LOGGER.info("Enable mirror maker machines auto join."); final HelixConfigScope scope = new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER) .forCluster(helixClusterName).build(); final Map<String, String> props = new HashMap<String, String>(); props.put(ZKHelixManager.ALLOW_PARTICIPANT_AUTO_JOIN, String.valueOf(true)); props.put(MessageType.STATE_TRANSITION + "." + HelixTaskExecutor.MAX_THREADS, String.valueOf(100)); admin.setConfig(scope, props); LOGGER.info("Adding state model definition named : OnlineOffline generated using : " + OnlineOfflineStateModel.class.toString() + " ********************************************** "); // add state model definition admin.addStateModelDef(helixClusterName, "OnlineOffline", OnlineOfflineStateModel.build()); LOGGER.info("New Cluster setup completed... ********************************************** "); }
private static void addConfiguration(ClusterSetup setup, String baseDir, String clusterName, String instanceName) throws IOException { Map<String, String> properties = new HashMap<String, String>(); HelixConfigScopeBuilder builder = new HelixConfigScopeBuilder(ConfigScopeProperty.PARTICIPANT); HelixConfigScope instanceScope = builder.forCluster(clusterName).forParticipant(instanceName).build(); properties.put("change_log_dir", baseDir + instanceName + "/translog"); properties.put("file_store_dir", baseDir + instanceName + "/filestore"); properties.put("check_point_dir", baseDir + instanceName + "/checkpoint"); setup.getClusterManagementTool().setConfig(instanceScope, properties); FileUtils.deleteDirectory(new File(properties.get("change_log_dir"))); FileUtils.deleteDirectory(new File(properties.get("file_store_dir"))); FileUtils.deleteDirectory(new File(properties.get("check_point_dir"))); new File(properties.get("change_log_dir")).mkdirs(); new File(properties.get("file_store_dir")).mkdirs(); new File(properties.get("check_point_dir")).mkdirs(); } }
public void disableAutoBalancing() { HelixConfigScope scope = new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER) .forCluster(_helixClusterName).build(); Map<String, String> properties = new HashMap<>(); properties.put(AUTO_BALANCING, DISABLE); _helixAdmin.setConfig(scope, properties); }
public void enableAutoBalancing() { HelixConfigScope scope = new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER).forCluster(_helixClusterName) .build(); Map<String, String> properties = new HashMap<>(); properties.put(AUTO_BALANCING, ENABLE); _helixAdmin.setConfig(scope, properties); }
/** * set configs * @param type config-scope type, e.g. CLUSTER, RESOURCE, etc. * @param scopeArgsCsv scopeArgsCsv csv-formatted scope-args, e.g myCluster,testDB * @param keyValuePairs csv-formatted key-value pairs. e.g. k1=v1,k2=v2 */ public void setConfig(ConfigScopeProperty type, String scopeArgsCsv, String keyValuePairs) { // ConfigScope scope = new ConfigScopeBuilder().build(scopesKeyValuePairs); String[] scopeArgs = scopeArgsCsv.split("[\\s,]"); HelixConfigScope scope = new HelixConfigScopeBuilder(type, scopeArgs).build(); Map<String, String> keyValueMap = HelixUtil.parseCsvFormatedKeyValuePairs(keyValuePairs); _admin.setConfig(scope, keyValueMap); }
/** * set configs * @param type config-scope type, e.g. CLUSTER, RESOURCE, etc. * @param scopeArgsCsv scopeArgsCsv csv-formatted scope-args, e.g myCluster,testDB * @param keyValuePairs csv-formatted key-value pairs. e.g. k1=v1,k2=v2 */ public void setConfig(ConfigScopeProperty type, String scopeArgsCsv, String keyValuePairs) { // ConfigScope scope = new ConfigScopeBuilder().build(scopesKeyValuePairs); String[] scopeArgs = scopeArgsCsv.split("[\\s,]"); HelixConfigScope scope = new HelixConfigScopeBuilder(type, scopeArgs).build(); Map<String, String> keyValueMap = HelixUtil.parseCsvFormatedKeyValuePairs(keyValuePairs); _admin.setConfig(scope, keyValueMap); }
private synchronized void setEmptyResourceConfig(String topicName) { _helixAdmin.setConfig( new HelixConfigScopeBuilder(ConfigScopeProperty.RESOURCE).forCluster(_helixClusterName) .forResource(topicName).build(), new HashMap<>()); }
private synchronized void setEmptyResourceConfig(String topicName) { _helixAdmin.setConfig(new HelixConfigScopeBuilder(ConfigScopeProperty.RESOURCE) .forCluster(_helixClusterName) .forResource(topicName).build(), new HashMap<>()); }
public static void createHelixClusterIfNeeded(String helixClusterName, String zkPath) { final HelixAdmin admin = new ZKHelixAdmin(zkPath); if (admin.getClusters().contains(helixClusterName)) { LOGGER.info("cluster already exist, skipping it.. ********************************************* "); return; } LOGGER.info("Creating a new cluster, as the helix cluster : " + helixClusterName + " was not found ********************************************* "); admin.addCluster(helixClusterName, false); LOGGER.info("Enable mirror maker machines auto join."); final HelixConfigScope scope = new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER) .forCluster(helixClusterName).build(); final Map<String, String> props = new HashMap<String, String>(); props.put(ZKHelixManager.ALLOW_PARTICIPANT_AUTO_JOIN, String.valueOf(true)); props.put(MessageType.STATE_TRANSITION + "." + HelixTaskExecutor.MAX_THREADS, String.valueOf(100)); admin.setConfig(scope, props); LOGGER.info("Adding state model definition named : OnlineOffline generated using : " + OnlineOfflineStateModel.class.toString() + " ********************************************** "); // add state model definition admin.addStateModelDef(helixClusterName, "OnlineOffline", OnlineOfflineStateModel.build()); LOGGER.info("New Cluster setup completed... ********************************************** "); }
private synchronized void setEmptyResourceConfig(String topicName) { _helixAdmin.setConfig(new HelixConfigScopeBuilder(ConfigScopeProperty.RESOURCE).forCluster(_helixClusterName) .forResource(topicName).build(), new HashMap<>()); }
/** * @return returns true if */ public boolean start() throws Exception { // auto create cluster and allow nodes to automatically join the cluster admin = HelixManagerFactory.getZKHelixManager(cluster, "service-discovery", InstanceType.ADMINISTRATOR, zkAddress); admin.connect(); admin.getClusterManagmentTool().addCluster(cluster, false); HelixConfigScope scope = new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER).forCluster(cluster).build(); Map<String, String> properties = new HashMap<String, String>(); properties.put(ZKHelixManager.ALLOW_PARTICIPANT_AUTO_JOIN, String.valueOf(true)); admin.getClusterManagmentTool().setConfig(scope, properties); switch (mode) { case POLL: startBackgroundTask(); break; case WATCH: setupWatcher(); break; case NONE:// dont monitor changes, supports only registration } refreshCache(); return true; }
properties.put("pKey1", "pValue1"); properties.put("pKey2", "pValue2"); adminTool.setConfig(scope, properties);
@Test public void testDropResource() { String className = TestHelper.getTestClassName(); String methodName = TestHelper.getTestMethodName(); String clusterName = className + "_" + methodName; System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis())); HelixAdmin tool = new ZKHelixAdmin(_gZkClient); tool.addCluster(clusterName, true); Assert.assertTrue(ZKUtil.isClusterSetup(clusterName, _gZkClient), "Cluster should be setup"); tool.addStateModelDef(clusterName, "MasterSlave", new StateModelDefinition( StateModelConfigGenerator.generateConfigForMasterSlave())); tool.addResource(clusterName, "test-db", 4, "MasterSlave"); Map<String, String> resourceConfig = new HashMap<String, String>(); resourceConfig.put("key1", "value1"); tool.setConfig(new HelixConfigScopeBuilder(ConfigScopeProperty.RESOURCE) .forCluster(clusterName).forResource("test-db").build(), resourceConfig); PropertyKey.Builder keyBuilder = new PropertyKey.Builder(clusterName); Assert.assertTrue(_gZkClient.exists(keyBuilder.idealStates("test-db").getPath()), "test-db ideal-state should exist"); Assert.assertTrue(_gZkClient.exists(keyBuilder.resourceConfig("test-db").getPath()), "test-db resource config should exist"); tool.dropResource(clusterName, "test-db"); Assert.assertFalse(_gZkClient.exists(keyBuilder.idealStates("test-db").getPath()), "test-db ideal-state should be dropped"); Assert.assertFalse(_gZkClient.exists(keyBuilder.resourceConfig("test-db").getPath()), "test-db resource config should be dropped"); tool.dropCluster(clusterName); System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis())); }