/** * Convert to a JSON string * @return a JSON string description */ public String toJson() throws IOException, JsonGenerationException, JsonMappingException { return confTree.toJson(); }
@Override public String toString() { return confTree.toString(); }
/** * Convert to a JSON string * @return a JSON string description */ public String toJson() throws IOException, JsonGenerationException, JsonMappingException { return confTree.toJson(); }
@Override public String toString() { return confTree.toString(); }
@Override public String toString() { try { return toJson(); } catch (Exception e) { log.warn("Failed to convert to JSON ", e); return super.toString(); } }
@Override public String toString() { try { return toJson(); } catch (Exception e) { log.warn("Failed to convert to JSON ", e); return super.toString(); } }
protected ConfTree buildConfTree(Map<String, String> optionsMap) throws BadCommandArgumentsException { ConfTree confTree = new ConfTree(); ConfTreeOperations ops = new ConfTreeOperations(confTree); confTree.global.putAll(optionsMap); return confTree; } }
@Override public Messages.GetInstanceDefinitionResponseProto getInstanceDefinition( Messages.GetInstanceDefinitionRequestProto request) throws IOException, YarnException { onRpcCall("getinstancedefinition"); String internal; String resources; String app; AggregateConf instanceDefinition = state.getInstanceDefinitionSnapshot(); internal = instanceDefinition.getInternal().toJson(); resources = instanceDefinition.getResources().toJson(); app = instanceDefinition.getAppConf().toJson(); assert internal != null; assert resources != null; assert app != null; log.debug("Generating getInstanceDefinition Response"); Messages.GetInstanceDefinitionResponseProto.Builder builder = Messages.GetInstanceDefinitionResponseProto.newBuilder(); builder.setInternal(internal); builder.setResources(resources); builder.setApplication(app); return builder.build(); }
protected ConfTree buildConfTree(Map<String, String> optionsMap) throws BadCommandArgumentsException { ConfTree confTree = new ConfTree(); ConfTreeOperations ops = new ConfTreeOperations(confTree); confTree.global.putAll(optionsMap); return confTree; } }
private void actionDiagnosticApplication(ActionDiagnosticArgs diagnosticArgs) throws YarnException, IOException { // not using member variable clustername because we want to place // application name after --application option and member variable // cluster name has to be put behind action String clusterName = diagnosticArgs.name; requireArgumentSet(Arguments.ARG_NAME, clusterName); AggregateConf instanceDefinition = fetchInstanceDefinition(clusterName); String clusterDir = instanceDefinition.getAppConfOperations() .getGlobalOptions().get(AgentKeys.APP_ROOT); String pkgTarball = getApplicationDefinitionPath(instanceDefinition.getAppConfOperations()); String runAsUser = instanceDefinition.getAppConfOperations() .getGlobalOptions().get(AgentKeys.RUNAS_USER); log.info("The location of the cluster instance directory in HDFS is: {}", clusterDir); log.info("The name of the application package tarball on HDFS is: {}",pkgTarball); log.info("The runas user of the application in the cluster is: {}",runAsUser); if (diagnosticArgs.verbose) { log.info("App config of the application:\n{}", instanceDefinition.getAppConf().toJson()); log.info("Resource config of the application:\n{}", instanceDefinition.getResources().toJson()); } }
@Test public void testComponentCommandOrderBadComponent() throws Exception { ConfTreeOperations resourcesGood = new ConfTreeOperations(new ConfTree()); resourcesGood.getOrAddComponent("A"); resourcesGood.getOrAddComponent("Z"); ConfTreeOperations resourcesBad = new ConfTreeOperations(new ConfTree()); CommandOrder co1 = new CommandOrder(); co1.setCommand("A-START"); co1.setRequires("Z-STARTED"); CommandOrder co2 = new CommandOrder(); co2.setCommand("Z-START"); co2.setRequires("A-STARTED"); ComponentCommandOrder cco = new ComponentCommandOrder( Arrays.asList(co1), resourcesGood); try { cco = new ComponentCommandOrder(Arrays.asList(co1), resourcesBad); Assert.fail("Instantiation should have failed."); } catch (IllegalArgumentException ie) { log.info(ie.getMessage()); } cco = new ComponentCommandOrder(Arrays.asList(co2), resourcesGood); try { cco = new ComponentCommandOrder(Arrays.asList(co2), resourcesBad); Assert.fail("Instantiation should have failed."); } catch (IllegalArgumentException ie) { log.info(ie.getMessage()); } }
@Override public Messages.GetInstanceDefinitionResponseProto getInstanceDefinition( Messages.GetInstanceDefinitionRequestProto request) throws IOException, YarnException { onRpcCall("getinstancedefinition"); String internal; String resources; String app; AggregateConf instanceDefinition = state.getInstanceDefinitionSnapshot(); internal = instanceDefinition.getInternal().toJson(); resources = instanceDefinition.getResources().toJson(); app = instanceDefinition.getAppConf().toJson(); assert internal != null; assert resources != null; assert app != null; log.debug("Generating getInstanceDefinition Response"); Messages.GetInstanceDefinitionResponseProto.Builder builder = Messages.GetInstanceDefinitionResponseProto.newBuilder(); builder.setInternal(internal); builder.setResources(resources); builder.setApplication(app); return builder.build(); }
@Test public void testComponentCommandOrderBadComponent() throws Exception { ConfTreeOperations resourcesGood = new ConfTreeOperations(new ConfTree()); resourcesGood.getOrAddComponent("A"); resourcesGood.getOrAddComponent("Z"); ConfTreeOperations resourcesBad = new ConfTreeOperations(new ConfTree()); CommandOrder co1 = new CommandOrder(); co1.setCommand("A-START"); co1.setRequires("Z-STARTED"); CommandOrder co2 = new CommandOrder(); co2.setCommand("Z-START"); co2.setRequires("A-STARTED"); ComponentCommandOrder cco = new ComponentCommandOrder( Arrays.asList(co1), resourcesGood); try { cco = new ComponentCommandOrder(Arrays.asList(co1), resourcesBad); Assert.fail("Instantiation should have failed."); } catch (IllegalArgumentException ie) { log.info(ie.getMessage()); } cco = new ComponentCommandOrder(Arrays.asList(co2), resourcesGood); try { cco = new ComponentCommandOrder(Arrays.asList(co2), resourcesBad); Assert.fail("Instantiation should have failed."); } catch (IllegalArgumentException ie) { log.info(ie.getMessage()); } }
private void actionDiagnosticApplication(ActionDiagnosticArgs diagnosticArgs) throws YarnException, IOException { // not using member variable clustername because we want to place // application name after --application option and member variable // cluster name has to be put behind action String clusterName = diagnosticArgs.name; requireArgumentSet(Arguments.ARG_NAME, clusterName); AggregateConf instanceDefinition = fetchInstanceDefinition(clusterName); String clusterDir = instanceDefinition.getAppConfOperations() .getGlobalOptions().get(AgentKeys.APP_ROOT); String pkgTarball = getApplicationDefinitionPath(instanceDefinition.getAppConfOperations()); String runAsUser = instanceDefinition.getAppConfOperations() .getGlobalOptions().get(AgentKeys.RUNAS_USER); log.info("The location of the cluster instance directory in HDFS is: {}", clusterDir); log.info("The name of the application package tarball on HDFS is: {}",pkgTarball); log.info("The runas user of the application in the cluster is: {}",runAsUser); if (diagnosticArgs.verbose) { log.info("App config of the application:\n{}", instanceDefinition.getAppConf().toJson()); log.info("Resource config of the application:\n{}", instanceDefinition.getResources().toJson()); } }
expect(access.getPublishedExportsSet()).andReturn(pubExpSet).anyTimes(); expect(access.getAppConfSnapshot()).andReturn(new ConfTreeOperations( new ConfTree())).anyTimes(); replay(access);
/** * Flex operation * @param resources new resources * @return the response * @throws IOException */ public boolean flex(ConfTree resources) throws IOException { Messages.FlexClusterRequestProto request = Messages.FlexClusterRequestProto.newBuilder() .setClusterSpec(resources.toJson()) .build(); Messages.FlexClusterResponseProto response = appMaster.flexCluster(request); return response.getResponse(); }