List of usage examples for org.apache.hadoop.registry.client.api RegistryConstants DEFAULT_ZK_REGISTRY_ROOT
String DEFAULT_ZK_REGISTRY_ROOT
To view the source code for org.apache.hadoop.registry.client.api RegistryConstants DEFAULT_ZK_REGISTRY_ROOT.
Click Source Link
From source file:com.alibaba.jstorm.yarn.registry.YarnRegistryViewForProviders.java
License:Apache License
/** * Get the absolute path to where the service has registered itself. * This includes the base registry path//w ww. ja v a 2 s. c om * Null until the service is registered * @return the service registration path. */ public String getAbsoluteSelfRegistrationPath() { if (selfRegistrationPath == null) { return null; } String root = registryOperations.getConfig().getTrimmed(RegistryConstants.KEY_REGISTRY_ZK_ROOT, RegistryConstants.DEFAULT_ZK_REGISTRY_ROOT); return RegistryPathUtils.join(root, selfRegistrationPath); }
From source file:org.apache.slider.providers.agent.TestAgentProviderService.java
License:Apache License
@Test public void testRegistration() throws IOException { ConfTree tree = new ConfTree(); tree.global.put(InternalKeys.INTERNAL_APPLICATION_IMAGE_PATH, "."); AgentProviderService aps = createAgentProviderService(new Configuration()); ContainerLaunchContext ctx = createNiceMock(ContainerLaunchContext.class); AggregateConf instanceDefinition = new AggregateConf(); instanceDefinition.setInternal(tree); instanceDefinition.setAppConf(tree); instanceDefinition.getAppConfOperations().getGlobalOptions().put(AgentKeys.APP_DEF, "."); instanceDefinition.getAppConfOperations().getGlobalOptions().put(AgentKeys.AGENT_CONF, "."); instanceDefinition.getAppConfOperations().getGlobalOptions().put(AgentKeys.AGENT_VERSION, "."); Container container = createNiceMock(Container.class); String role = "HBASE_MASTER"; SliderFileSystem sliderFileSystem = createNiceMock(SliderFileSystem.class); ContainerLauncher launcher = createNiceMock(ContainerLauncher.class); Path generatedConfPath = new Path(".", "test"); MapOperations resourceComponent = new MapOperations(); MapOperations appComponent = new MapOperations(); Path containerTmpDirPath = new Path(".", "test"); FileSystem mockFs = createNiceMock(FileSystem.class); expect(mockFs.exists(anyObject(Path.class))).andReturn(true); expect(sliderFileSystem.getFileSystem()).andReturn(mockFs).anyTimes(); expect(sliderFileSystem.createAmResource(anyObject(Path.class), anyObject(LocalResourceType.class))) .andReturn(createNiceMock(LocalResource.class)).anyTimes(); expect(container.getId()).andReturn(new MockContainerId(1)).anyTimes(); expect(container.getNodeId()).andReturn(new MockNodeId("localhost")).anyTimes(); StateAccessForProviders access = createNiceMock(StateAccessForProviders.class); AgentProviderService mockAps = Mockito.spy(aps); doReturn(access).when(mockAps).getAmState(); CommandScript cs = new CommandScript(); cs.setScript("scripts/hbase_master.py"); doReturn(cs).when(mockAps).getScriptPathFromMetainfo(anyString()); Metainfo metainfo = new Metainfo(); metainfo.setApplication(new Application()); doReturn(metainfo).when(mockAps).getApplicationMetainfo(any(SliderFileSystem.class), anyString()); Configuration conf = new Configuration(); conf.set(RegistryConstants.KEY_REGISTRY_ZK_ROOT, RegistryConstants.DEFAULT_ZK_REGISTRY_ROOT); try {//ww w .ja va2s. co m doReturn(true).when(mockAps).isMaster(anyString()); doNothing().when(mockAps).addInstallCommand(eq("HBASE_MASTER"), eq("mockcontainer_1"), any(HeartBeatResponse.class), eq("scripts/hbase_master.py"), eq(600L)); doReturn(conf).when(mockAps).getConfig(); } catch (SliderException e) { } doNothing().when(mockAps).processAllocatedPorts(anyString(), anyString(), anyString(), anyMap()); doNothing().when(mockAps).publishFolderPaths(anyMap(), anyString(), anyString(), anyString()); 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(); AggregateConf aggConf = new AggregateConf(); ConfTreeOperations treeOps = aggConf.getAppConfOperations(); treeOps.getOrAddComponent("HBASE_MASTER").put(AgentKeys.WAIT_HEARTBEAT, "0"); treeOps.set(OptionKeys.APPLICATION_NAME, "HBASE"); expect(access.getInstanceDefinitionSnapshot()).andReturn(aggConf); expect(access.getInternalsSnapshot()).andReturn(treeOps).anyTimes(); replay(access, ctx, container, sliderFileSystem, mockFs); try { mockAps.buildContainerLaunchContext(launcher, instanceDefinition, container, role, sliderFileSystem, generatedConfPath, resourceComponent, appComponent, containerTmpDirPath); // JDK7 } catch (IOException he) { log.warn("{}", he, he); } catch (SliderException he) { log.warn("{}", he, he); } Register reg = new Register(); reg.setResponseId(0); reg.setLabel("mockcontainer_1___HBASE_MASTER"); Map<String, String> ports = new HashMap<String, String>(); ports.put("a", "100"); reg.setAllocatedPorts(ports); Map<String, String> folders = new HashMap<String, String>(); folders.put("F1", "F2"); reg.setLogFolders(folders); RegistrationResponse resp = mockAps.handleRegistration(reg); Assert.assertEquals(0, resp.getResponseId()); Assert.assertEquals(RegistrationStatus.OK, resp.getResponseStatus()); Mockito.verify(mockAps, Mockito.times(1)).processAllocatedPorts(anyString(), anyString(), anyString(), anyMap()); Mockito.verify(mockAps, Mockito.times(1)).publishFolderPaths(anyMap(), anyString(), anyString(), anyString()); HeartBeat hb = new HeartBeat(); hb.setResponseId(1); hb.setHostname("mockcontainer_1___HBASE_MASTER"); HeartBeatResponse hbr = mockAps.handleHeartBeat(hb); Assert.assertEquals(2, hbr.getResponseId()); }