AuxServices extends AbstractService implements ServiceStateChangeListener, EventHandler<AuxServicesEvent> { protected static AuxServiceRecord newAuxService(String name, String className) { AuxServiceConfiguration serviceConf = new AuxServiceConfiguration(); serviceConf.setProperty(CLASS_NAME, className); return new AuxServiceRecord().name(name).configuration(serviceConf); } AuxServices(AuxiliaryLocalPathHandler auxiliaryLocalPathHandler,
      Context nmContext, DeletionService deletionService); boolean isManifestEnabled(); Collection<AuxServiceRecord> getServiceRecords(); Map<String, ByteBuffer> getMetaData(); synchronized void reload(AuxServiceRecords services); @Override synchronized void serviceInit(Configuration conf); @Override synchronized void serviceStart(); @Override synchronized void serviceStop(); @Override void stateChanged(Service service); @Override void handle(AuxServicesEvent event); static final String NM_AUX_SERVICE_DIR; static final FsPermission NM_AUX_SERVICE_DIR_PERM; static final String CLASS_NAME; static final String SYSTEM_CLASSES; }
@Test public void testValidAuxServiceName() throws IOException { Configuration conf = getABConf("Asrv1", "Bsrv_2", ServiceA.class, ServiceB.class); final AuxServices aux = new AuxServices(MOCK_AUX_PATH_HANDLER, MOCK_CONTEXT, MOCK_DEL_SERVICE); try { aux.init(conf); } catch (Exception ex) { Assert.fail("Should not receive the exception."); } final AuxServices aux1 = new AuxServices(MOCK_AUX_PATH_HANDLER, MOCK_CONTEXT, MOCK_DEL_SERVICE); if (useManifest) { AuxServiceRecord serviceA = AuxServices.newAuxService("1Asrv1", ServiceA.class.getName()); writeManifestFile(new AuxServiceRecords().serviceList(serviceA), conf); } else { conf.setStrings(YarnConfiguration.NM_AUX_SERVICES, new String[] {"1Asrv1"}); conf.setClass(String.format(YarnConfiguration.NM_AUX_SERVICE_FMT, "1Asrv1"), ServiceA.class, Service.class); } try { aux1.init(conf); Assert.fail("Should receive the exception."); } catch (Exception ex) { assertTrue("Wrong message: " + ex.getMessage(), ex.getMessage().contains("The auxiliary service name: 1Asrv1 is " + "invalid. The valid service name should only contain a-zA-Z0-9_" + " and cannot start with numbers.")); } }