private void publishModifiedExportGroups(Set<String> modifiedGroups) { for (String groupName : modifiedGroups) { Map<String, List<ExportEntry>> entries = this.exportGroups.get(groupName); // Publish in old format for the time being Map<String, String> simpleEntries = new HashMap<String, String>(); for (Map.Entry<String, List<ExportEntry>> entry : entries.entrySet()) { List<ExportEntry> exports = entry.getValue(); if (SliderUtils.isNotEmpty(exports)) { // there is no support for multiple exports per name - so extract only the first one simpleEntries.put(entry.getKey(), entry.getValue().get(0).getValue()); } } if (!getAmState().getAppConfSnapshot().getComponentOptBool( groupName, AgentKeys.AM_CONFIG_GENERATION, false)) { publishApplicationInstanceData(groupName, groupName, simpleEntries.entrySet()); } PublishedExports exports = new PublishedExports(groupName); exports.setUpdated(new Date().getTime()); exports.putValues(entries.entrySet()); getAmState().getPublishedExportsSet().put(groupName, exports); } }
protected String getClusterInfoPropertyValue(String name) { StateAccessForProviders accessor = getAmState(); assert accessor.isApplicationLive(); ClusterDescription description = accessor.getClusterStatus(); return description.getInfo(name); }
@Override public AggregateConf refresh() throws Exception { return resolved ? state.getInstanceDefinitionSnapshot() : state.getUnresolvedInstanceDefinition(); } }
anyString(), anyString(), anyMap()); expect(access.isApplicationLive()).andReturn(true).anyTimes(); ClusterDescription desc = new ClusterDescription(); desc.setOption(OptionKeys.ZOOKEEPER_QUORUM, "host1:2181"); desc.setInfo(OptionKeys.APPLICATION_NAME, "HBASE"); expect(access.getClusterStatus()).andReturn(desc).anyTimes(); treeOps.set("site.fs.defaultFS", "hdfs://c6409.ambari.apache.org:8020"); treeOps.set(InternalKeys.INTERNAL_DATA_DIR_PATH, "hdfs://c6409.ambari.apache.org:8020/user/yarn/.slider/cluster/cl1/data"); expect(access.getInstanceDefinitionSnapshot()).andReturn(aggConf); expect(access.getInternalsSnapshot()).andReturn(treeOps).anyTimes(); expect(access.getAppConfSnapshot()).andReturn(treeOps).anyTimes(); replay(access, ctx, container, sliderFileSystem);
@VisibleForTesting protected void addUpgradeCommand(String roleName, String roleGroup, String containerId, HeartBeatResponse response, String scriptPath, long timeout) throws SliderException { assert getAmState().isApplicationLive(); ConfTreeOperations appConf = getAmState().getAppConfSnapshot(); ConfTreeOperations internalsConf = getAmState().getInternalsSnapshot(); ExecutionCommand cmd = new ExecutionCommand( AgentCommandType.EXECUTION_COMMAND); prepareExecutionCommand(cmd); String clusterName = internalsConf.get(OptionKeys.APPLICATION_NAME); String hostName = getClusterInfoPropertyValue(StatusKeys.INFO_AM_HOSTNAME); cmd.setHostname(hostName); cmd.setClusterName(clusterName); cmd.setRoleCommand(Command.UPGRADE.toString()); cmd.setServiceName(clusterName); cmd.setComponentName(roleName); cmd.setRole(roleName); Map<String, String> hostLevelParams = new TreeMap<String, String>(); hostLevelParams.put(JAVA_HOME, appConf.getGlobalOptions() .getMandatoryOption(JAVA_HOME)); hostLevelParams.put(CONTAINER_ID, containerId); cmd.setHostLevelParams(hostLevelParams); cmd.setCommandParams(commandParametersSet(scriptPath, timeout, true)); Map<String, Map<String, String>> configurations = buildCommandConfigurations( appConf, containerId, roleName, roleGroup); cmd.setConfigurations(configurations); response.addExecutionCommand(cmd); }
@VisibleForTesting protected void addGetConfigDockerCommand(String roleName, String roleGroup, String containerId, HeartBeatResponse response) throws SliderException { assert getAmState().isApplicationLive(); ConfTreeOperations appConf = getAmState().getAppConfSnapshot(); Map<String, Map<String, String>> configurations = buildCommandConfigurations( appConf, containerId, roleName, roleGroup);
@VisibleForTesting protected void doIndex(Hamlet html, String providerName) { ClusterDescription clusterStatus = appState.getClusterStatus(); String name = clusterStatus.name; if (name != null && (name.startsWith(" ") || name.endsWith(" "))) { appState.getApplicationLivenessInformation(); String livestatus = liveness.allRequestsSatisfied ? ALL_CONTAINERS_ALLOCATED table1.tr() .td("Total number of containers") .td(Integer.toString(appState.getNumOwnedContainers())) ._(); table1.tr() List<RoleStatus> roleStatuses = appState.cloneRoleStatusList(); Collections.sort(roleStatuses, new RoleStatus.CompareByName()); for (RoleStatus status : roleStatuses) { exports.h3("Exports"); ul = html.ul(); enumeratePublishedExports(appState.getPublishedExportsSet(), ul); ul._(); exports._(); .getApplicationDiagnostics(); List<ContainerInformation> appContainers = new ArrayList<>( appDiagnostics.getContainers());
@Override protected void render(Block html) { final Map<String,RoleInstance> containerInstances = getContainerInstances( appState.cloneOwnedContainerList()); appState.getRoleClusterNodeMapping(); Map<String, ComponentInformation> componentInfoMap = appState.getComponentInfoSnapshot(); ClusterDescription desc = appState.getClusterStatus(); Map<String, String> options = desc.getRole(name); Iterable<Entry<TableContent, String>> tableContent;
protected Map<String, DefaultConfig> getDefaultConfigs(String roleGroup) { ConfTreeOperations appConf = getAmState().getAppConfSnapshot(); String mapKey = appConf.getComponentOpt(roleGroup, ROLE_PREFIX, DEFAULT_METAINFO_MAP_KEY); return metaInfoMap.get(mapKey).defaultConfigs; }
@GET @Path(EXPORTS_RESOURCES_PATH) @Produces({MediaType.APPLICATION_JSON}) public PublishedExportsSet gePublishedExports() { return appState.getPublishedExportsSet(); }
ConfTreeOperations appConf = getAmState().getAppConfSnapshot(); MapOperations clientOperations = appConf.getOrAddComponent(client.getName()); appConf.resolve(); new PublishedConfiguration(configFile.getDictionaryName(), config.entrySet()); getAmState().getPublishedSliderConfigurations().put( configFile.getDictionaryName(), publishedConfiguration); log.info("Publishing AM configuration {}", configFile.getDictionaryName());
RoleInstance role = null; if(status.getIp() != null && !status.getIp().isEmpty()){ role = amState.getOwnedContainer(containerId); role.ip = status.getIp(); role = amState.getOwnedContainer(containerId); role.hostname = status.getHostname(); int waitForCount = accessor.getInstanceDefinitionSnapshot(). getAppConfOperations().getComponentOptInt(roleGroup, AgentKeys.WAIT_HEARTBEAT, 0);
/** * Get the JSON, catching any exceptions and returning error text instead * @return */ private String getJson() { return appState.getClusterStatus().toString(); }
private String getClusterName() { if (SliderUtils.isUnset(clusterName)) { clusterName = getAmState().getInternalsSnapshot().get(OptionKeys.APPLICATION_NAME); } return clusterName; }
protected AggregateConf getAggregateConf() { return slider.getAppState().getInstanceDefinitionSnapshot(); } }
/** * Get a list of all hosts for all role/container per role * * @return the map of role->node */ protected Map<String, Map<String, ClusterNode>> getRoleClusterNodeMapping() { return amState.getRoleClusterNodeMapping(); }
@VisibleForTesting protected void addGetConfigCommand(String roleName, String roleGroup, String containerId, HeartBeatResponse response) throws SliderException { assert getAmState().isApplicationLive(); StatusCommand cmd = new StatusCommand(); String clusterName = getClusterName(); cmd.setCommandType(AgentCommandType.STATUS_COMMAND); cmd.setComponentName(roleName); cmd.setServiceName(clusterName); cmd.setClusterName(clusterName); cmd.setRoleCommand(StatusCommand.GET_CONFIG_COMMAND); Map<String, String> hostLevelParams = new TreeMap<String, String>(); hostLevelParams.put(CONTAINER_ID, containerId); cmd.setHostLevelParams(hostLevelParams); hostLevelParams.put(CONTAINER_ID, containerId); response.addStatusCommand(cmd); }
@Override public Map<String, ContainerInformation> refresh() throws Exception { List<RoleInstance> containerList = state.cloneOwnedContainerList(); Map<String, ContainerInformation> map = new HashMap<>(); for (RoleInstance instance : containerList) { ContainerInformation serialized = instance.serialize(); map.put(serialized.containerId, serialized); } return map; } }
@Override public Map<String,RoleStatus> getRoleStatusByName() { List<RoleStatus> roleStatuses = appState.cloneRoleStatusList(); Map<String, RoleStatus> map = new TreeMap<>(); for (RoleStatus status : roleStatuses) { map.put(status.getName(), status); } return map; }
@Override //SliderClusterProtocol public Messages.ListNodeUUIDsByRoleResponseProto listNodeUUIDsByRole(Messages.ListNodeUUIDsByRoleRequestProto request) throws IOException, YarnException { onRpcCall("listnodes)"); String role = request.getRole(); Messages.ListNodeUUIDsByRoleResponseProto.Builder builder = Messages.ListNodeUUIDsByRoleResponseProto.newBuilder(); List<RoleInstance> nodes = state.enumLiveInstancesInRole(role); for (RoleInstance node : nodes) { builder.addUuid(node.id); } return builder.build(); }