AuxServices extends AbstractService implements ServiceStateChangeListener, EventHandler<AuxServicesEvent> { AuxServices(AuxiliaryLocalPathHandler auxiliaryLocalPathHandler, Context nmContext, DeletionService deletionService) { super(AuxServices.class.getName()); serviceMap = Collections.synchronizedMap(new HashMap<String, AuxiliaryService>()); serviceRecordMap = Collections.synchronizedMap(new HashMap<String, AuxServiceRecord>()); serviceMetaData = Collections.synchronizedMap(new HashMap<String,ByteBuffer>()); this.auxiliaryLocalPathHandler = auxiliaryLocalPathHandler; this.dirsHandler = nmContext.getLocalDirsHandler(); this.delService = deletionService; this.userUGI = getRemoteUgi(); this.mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); } 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 testAuxServices() throws IOException { Configuration conf = getABConf(); final AuxServices aux = new AuxServices(MOCK_AUX_PATH_HANDLER, MOCK_CONTEXT, MOCK_DEL_SERVICE); aux.init(conf); int latch = 1; for (Service s : aux.getServices()) { assertEquals(INITED, s.getServiceState()); if (s instanceof ServiceA) { latch *= 2; } else if (s instanceof ServiceB) { latch *= 3; } else fail("Unexpected service type " + s.getClass()); } assertEquals("Invalid mix of services", 6, latch); aux.start(); for (AuxiliaryService s : aux.getServices()) { assertEquals(STARTED, s.getServiceState()); assertEquals(s.getAuxiliaryLocalPathHandler(), MOCK_AUX_PATH_HANDLER); } aux.stop(); for (Service s : aux.getServices()) { assertEquals(STOPPED, s.getServiceState()); } }