List of usage examples for org.apache.hadoop.fs FilterFileSystem FilterFileSystem
public FilterFileSystem(FileSystem fs)
From source file:org.apache.slider.providers.agent.TestAgentProviderService.java
License:Apache License
private AgentProviderService prepareProviderServiceForAgentStateTests() throws IOException { ContainerLaunchContext ctx = createNiceMock(ContainerLaunchContext.class); Container container = createNiceMock(Container.class); String role = "HBASE_MASTER"; SliderFileSystem sliderFileSystem = createNiceMock(SliderFileSystem.class); FileSystem mockFs = new MockFileSystem(); expect(sliderFileSystem.getFileSystem()).andReturn(new FilterFileSystem(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(); expect(container.getPriority()).andReturn(Priority.newInstance(1)); StateAccessForProviders access = createNiceMock(StateAccessForProviders.class); Configuration conf = new Configuration(); AgentProviderService aps = createAgentProviderService(conf); 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(); Application application = new Application(); metainfo.setApplication(application); doReturn(metainfo).when(mockAps).getApplicationMetainfo(any(SliderFileSystem.class), anyString()); doReturn(metainfo).when(mockAps).getMetainfo(); try {/* ww w . j av a 2 s . c om*/ 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()); 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"); treeOps.set("java_home", "/usr/jdk7/"); treeOps.set("site.fs.defaultFS", "hdfs://c6409.ambari.apache.org:8020"); treeOps.set(InternalKeys.INTERNAL_DATA_DIR_PATH, "hdfs://c6409.ambari.apache.org:8020/user/yarn/.slider/cluster/cl1/data"); expect(access.getInstanceDefinitionSnapshot()).andReturn(aggConf); expect(access.getInternalsSnapshot()).andReturn(treeOps).anyTimes(); expect(access.getAppConfSnapshot()).andReturn(treeOps).anyTimes(); replay(access, ctx, container, sliderFileSystem); List<Container> containers = new ArrayList<Container>(); containers.add(container); Map<Integer, ProviderRole> providerRoleMap = new HashMap<Integer, ProviderRole>(); ProviderRole providerRole = new ProviderRole(role, 1); providerRoleMap.put(1, providerRole); mockAps.rebuildContainerDetails(containers, "mockcontainer_1", providerRoleMap); return mockAps; }