AuxServices extends AbstractService implements ServiceStateChangeListener, EventHandler<AuxServicesEvent> { Collection<AuxiliaryService> getServices() { return Collections.unmodifiableCollection(serviceMap.values()); } 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 testAuxUnexpectedStop() throws IOException { Configuration conf = getABConf(); final AuxServices aux = new AuxServices(MOCK_AUX_PATH_HANDLER, MOCK_CONTEXT, MOCK_DEL_SERVICE); aux.init(conf); aux.start(); Service s = aux.getServices().iterator().next(); s.stop(); assertEquals("Auxiliary service stop caused AuxServices stop", STARTED, aux.getServiceState()); assertEquals(2, aux.getServices().size()); }
@Test public void testAuxServiceRecoverySetup() throws IOException { Configuration conf = getABConf("Asrv", "Bsrv", RecoverableServiceA.class, RecoverableServiceB.class); conf.setBoolean(YarnConfiguration.NM_RECOVERY_ENABLED, true); conf.set(YarnConfiguration.NM_RECOVERY_DIR, TEST_DIR.toString()); try { final AuxServices aux = new AuxServices(MOCK_AUX_PATH_HANDLER, MOCK_CONTEXT, MOCK_DEL_SERVICE); aux.init(conf); Assert.assertEquals(2, aux.getServices().size()); File auxStorageDir = new File(TEST_DIR, AuxServices.STATE_STORE_ROOT_NAME); Assert.assertEquals(2, auxStorageDir.listFiles().length); aux.close(); } finally { FileUtil.fullyDelete(TEST_DIR); } }
@Test public void testAuxServicesManifestPermissions() throws IOException { Assume.assumeTrue(useManifest); Configuration conf = getABConf(); FileSystem fs = FileSystem.get(conf); fs.setPermission(new Path(manifest.getAbsolutePath()), FsPermission .createImmutable((short) 0777)); AuxServices aux = new AuxServices(MOCK_AUX_PATH_HANDLER, MOCK_CONTEXT, MOCK_DEL_SERVICE); aux.init(conf); assertEquals(0, aux.getServices().size()); fs.setPermission(new Path(manifest.getAbsolutePath()), FsPermission .createImmutable((short) 0775)); aux = new AuxServices(MOCK_AUX_PATH_HANDLER, MOCK_CONTEXT, MOCK_DEL_SERVICE); aux.init(conf); assertEquals(0, aux.getServices().size()); fs.setPermission(new Path(manifest.getAbsolutePath()), FsPermission .createImmutable((short) 0755)); fs.setPermission(new Path(rootDir.getAbsolutePath()), FsPermission .createImmutable((short) 0775)); aux = new AuxServices(MOCK_AUX_PATH_HANDLER, MOCK_CONTEXT, MOCK_DEL_SERVICE); aux.init(conf); assertEquals(0, aux.getServices().size()); fs.setPermission(new Path(rootDir.getAbsolutePath()), FsPermission .createImmutable((short) 0755)); aux = new AuxServices(MOCK_AUX_PATH_HANDLER, MOCK_CONTEXT, MOCK_DEL_SERVICE); aux.init(conf); assertEquals(2, aux.getServices().size()); conf.set(YarnConfiguration.YARN_ADMIN_ACL, ""); aux = new AuxServices(MOCK_AUX_PATH_HANDLER, MOCK_CONTEXT, MOCK_DEL_SERVICE); aux.init(conf); assertEquals(0, aux.getServices().size()); conf.set(YarnConfiguration.YARN_ADMIN_ACL, UserGroupInformation .getCurrentUser().getShortUserName()); aux = new AuxServices(MOCK_AUX_PATH_HANDLER, MOCK_CONTEXT, MOCK_DEL_SERVICE); aux.init(conf); assertEquals(2, aux.getServices().size()); }