/** * Tag Pinot Minion instance if needed. */ private void addInstanceTagIfNeeded() { InstanceConfig instanceConfig = _helixAdmin.getInstanceConfig(_helixClusterName, _instanceId); if (instanceConfig.getTags().isEmpty()) { LOGGER.info("Adding default Helix tag: {} to Pinot minion", CommonConstants.Minion.UNTAGGED_INSTANCE); _helixAdmin.addInstanceTag(_helixClusterName, _instanceId, CommonConstants.Minion.UNTAGGED_INSTANCE); } } }
private List<String> getTagsForInstance(String instanceName) { InstanceConfig config = _helixDataAccessor.getProperty(_keyBuilder.instanceConfig(instanceName)); return config.getTags(); }
public static Instance fromInstanceConfig(InstanceConfig instanceConfig) { InstanceConfig ic = instanceConfig; String instanceName = ic.getInstanceName(); String type; if (instanceName.startsWith(CommonConstants.Helix.PREFIX_OF_SERVER_INSTANCE)) { type = CommonConstants.Helix.SERVER_INSTANCE_TYPE; } else if (instanceName.startsWith(CommonConstants.Helix.PREFIX_OF_BROKER_INSTANCE)) { type = CommonConstants.Helix.BROKER_INSTANCE_TYPE; } else { throw new RuntimeException("Unknown instance type for: " + instanceName); } Instance instance = new Instance(ic.getHostName(), ic.getPort(), type, org.apache.commons.lang.StringUtils.join(ic.getTags(), ',')); return instance; }
@GET @Path("/instances/{instanceName}") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "Get instance information", produces = MediaType.APPLICATION_JSON) @ApiResponses(value = {@ApiResponse(code = 200, message = "Success"), @ApiResponse(code = 404, message = "Instance not found"), @ApiResponse(code = 500, message = "Internal error")}) public String getInstance( @ApiParam(value = "Instance name", required = true, example = "Server_a.b.com_20000 | Broker_my.broker.com_30000") @PathParam("instanceName") String instanceName) { InstanceConfig instanceConfig = pinotHelixResourceManager.getHelixInstanceConfig(instanceName); if (instanceConfig == null) { throw new ControllerApplicationException(LOGGER, "Instance " + instanceName + " not found", Response.Status.NOT_FOUND); } ObjectNode response = JsonUtils.newObjectNode(); response.put("instanceName", instanceConfig.getInstanceName()); response.put("hostName", instanceConfig.getHostName()); response.put("enabled", instanceConfig.getInstanceEnabled()); response.put("port", instanceConfig.getPort()); response.set("tags", JsonUtils.objectToJsonNode(instanceConfig.getTags())); return response.toString(); }
public Set<String> getAllServerTenantNames() { Set<String> tenantSet = new HashSet<>(); List<String> instancesInCluster = _helixAdmin.getInstancesInCluster(_helixClusterName); for (String instanceName : instancesInCluster) { InstanceConfig config = _helixDataAccessor.getProperty(_keyBuilder.instanceConfig(instanceName)); for (String tag : config.getTags()) { if (tag.equals(CommonConstants.Helix.UNTAGGED_BROKER_INSTANCE) || tag .equals(CommonConstants.Helix.UNTAGGED_SERVER_INSTANCE) || tag .equals(CommonConstants.Minion.UNTAGGED_INSTANCE)) { continue; } if (TagNameUtils.getTenantRoleFromTag(tag) == TenantRole.SERVER) { tenantSet.add(TagNameUtils.getTenantNameFromTag(tag)); } } } return tenantSet; }
public Set<String> getAllBrokerTenantNames() { Set<String> tenantSet = new HashSet<>(); List<String> instancesInCluster = _helixAdmin.getInstancesInCluster(_helixClusterName); for (String instanceName : instancesInCluster) { InstanceConfig config = _helixDataAccessor.getProperty(_keyBuilder.instanceConfig(instanceName)); for (String tag : config.getTags()) { if (tag.equals(CommonConstants.Helix.UNTAGGED_BROKER_INSTANCE) || tag .equals(CommonConstants.Helix.UNTAGGED_SERVER_INSTANCE) || tag .equals(CommonConstants.Minion.UNTAGGED_INSTANCE)) { continue; } if (TagNameUtils.getTenantRoleFromTag(tag) == TenantRole.BROKER) { tenantSet.add(TagNameUtils.getTenantNameFromTag(tag)); } } } return tenantSet; }
private void addInstanceTagIfNeeded(String clusterName, String instanceName) { InstanceConfig instanceConfig = _helixAdmin.getInstanceConfig(clusterName, instanceName); List<String> instanceTags = instanceConfig.getTags(); if (instanceTags == null || instanceTags.isEmpty()) { if (ZKMetadataProvider.getClusterTenantIsolationEnabled(_propertyStore)) { _helixAdmin.addInstanceTag(clusterName, instanceName, TagNameUtils.getBrokerTagForTenant(TagNameUtils.DEFAULT_TENANT_NAME)); } else { _helixAdmin.addInstanceTag(clusterName, instanceName, CommonConstants.Helix.UNTAGGED_BROKER_INSTANCE); } } }
/** * Helix participant cannot pre-configure tags before it connects to ZK. So this method can only be invoked after * {@link HelixManager#connect()}. However this will still work because tagged jobs won't be sent to a non-tagged instance. Hence * the job with EXAMPLE_INSTANCE_TAG will remain in the ZK until an instance with EXAMPLE_INSTANCE_TAG was found. */ private void addInstanceTags() { List<String> tags = ConfigUtils.getStringList(this.config, GobblinClusterConfigurationKeys.HELIX_INSTANCE_TAGS_KEY); HelixManager receiverManager = getReceiverManager(); if (receiverManager.isConnected()) { if (!tags.isEmpty()) { logger.info("Adding tags binding " + tags); tags.forEach(tag -> receiverManager.getClusterManagmentTool() .addInstanceTag(this.clusterName, this.helixInstanceName, tag)); logger.info("Actual tags binding " + receiverManager.getClusterManagmentTool() .getInstanceConfig(this.clusterName, this.helixInstanceName).getTags()); } } }
private void addInstanceTagIfNeeded(String clusterName, String instanceName) { InstanceConfig instanceConfig = _helixAdmin.getInstanceConfig(clusterName, instanceName); List<String> instanceTags = instanceConfig.getTags(); if (instanceTags == null || instanceTags.size() == 0) { if (ZKMetadataProvider.getClusterTenantIsolationEnabled(_helixManager.getHelixPropertyStore())) { _helixAdmin.addInstanceTag(clusterName, instanceName, TableNameBuilder.OFFLINE.tableNameWithType(TagNameUtils.DEFAULT_TENANT_NAME)); _helixAdmin.addInstanceTag(clusterName, instanceName, TableNameBuilder.REALTIME.tableNameWithType(TagNameUtils.DEFAULT_TENANT_NAME)); } else { _helixAdmin.addInstanceTag(clusterName, instanceName, CommonConstants.Helix.UNTAGGED_SERVER_INSTANCE); } } }
/** * Helix participant cannot pre-configure tags before it connects to ZK. So this method can only be invoked after * {@link HelixManager#connect()}. However this will still work because tagged jobs won't be sent to a non-tagged instance. Hence * the job with EXAMPLE_INSTANCE_TAG will remain in the ZK until an instance with EXAMPLE_INSTANCE_TAG was found. */ private void addInstanceTags() { if (this.helixManager.isConnected()) { List<String> tags = ConfigUtils.getStringList(this.config, GobblinClusterConfigurationKeys.HELIX_INSTANCE_TAGS_KEY); logger.info("Adding tags binding " + tags); tags.forEach(tag -> helixManager.getClusterManagmentTool().addInstanceTag(this.clusterName, this.helixInstanceName, tag)); logger.info("Actual tags binding " + helixManager.getClusterManagmentTool() .getInstanceConfig(this.clusterName, this.helixInstanceName).getTags()); } }
disabledPartitions.put(instanceName, config.getDisabledPartitionsMap()); Set<String> instanceTags = Sets.newHashSet(config.getTags()); tags.put(instanceName, instanceTags);
disabledPartitions.put(instanceName, config.getDisabledPartitionsMap()); Set<String> instanceTags = Sets.newHashSet(config.getTags()); tags.put(instanceName, instanceTags);
String stateModelDefName = resourceMap.get(beanName.resourceName()).getStateModelDefRef(); InstanceConfig config = instanceConfigMap.get(beanName.instanceName()); bean.update(beanMap.get(beanName), Sets.newHashSet(config.getTags()), stateModelDefMap.get(stateModelDefName)); monitorsToRegister.add(bean); String stateModelDefName = resourceMap.get(beanName.resourceName()).getStateModelDefRef(); InstanceConfig config = instanceConfigMap.get(beanName.instanceName()); bean.update(beanMap.get(beanName), Sets.newHashSet(config.getTags()), stateModelDefMap.get(stateModelDefName));
String stateModelDefName = resourceMap.get(beanName.resourceName()).getStateModelDefRef(); InstanceConfig config = instanceConfigMap.get(beanName.instanceName()); bean.update(beanMap.get(beanName), Sets.newHashSet(config.getTags()), stateModelDefMap.get(stateModelDefName)); monitorsToRegister.add(bean); String stateModelDefName = resourceMap.get(beanName.resourceName()).getStateModelDefRef(); InstanceConfig config = instanceConfigMap.get(beanName.instanceName()); bean.update(beanMap.get(beanName), Sets.newHashSet(config.getTags()), stateModelDefMap.get(stateModelDefName));
instanceConfigsMap.get(instanceName).getRecord().setSimpleField("Alive", isAlive + ""); InstanceConfig config = instanceConfigsMap.get(instanceName); for (String tag : config.getTags()) { if (!tagInstanceLists.containsKey(tag)) { tagInstanceLists.put(tag, new LinkedList<String>());