@VisibleForTesting void initialize(URI name, Configuration conf, FileSystem underlyingFS) throws IOException { super.initialize(name, conf); this.allocator = config.getAllocator(); this.localAccessAllowed = config.isLocalAccessAllowed(); this.executor = config.getExecutor(); this.runnerFactory = config.getRunnerFactory(); this.endpointProvider = config.getEndpointProvider(); this.localAddress = config.getLocalIdentity().getAddress(); this.uri = name; this.underlyingFS = underlyingFS; }
@Override public void start() throws Exception { FabricService fabricService = this.fabricService.get(); pool = new CloseableThreadPool("pdfs"); FabricRunnerFactory factory = fabricService.registerProtocol(PDFSProtocol.newInstance(identityProvider.get(), this.config, allocator, allowLocalAccess)); final PDFSConfig config = new PDFSConfig(pool, factory, allocator, nodeProvider, identityProvider.get(), allowLocalAccess); PseudoDistributedFileSystem.configure(config); // A hack until DX-4639 is addressed. createFileSystem(); }
protected ExecutorService getExecutor(){ // total hack. since our executor could have been shutdown in tests, we need // to also try to use the latest statically provided one just in case this // instance of pdfs is cached. synchronized(executor){ if(executor.isShutdown()){ return globalConfig.getExecutor(); }else { return executor; } } }
private Iterable<NodeEndpoint> getEndpoints(){ if(Iterables.isEmpty(endpointProvider.get())){ return globalConfig.getEndpointProvider().get(); } else { return endpointProvider.get(); } }
@Override public void initialize(URI name, Configuration conf) throws IOException { initialize(name, conf, newLocalFileSystem(conf, config.isLocalAccessAllowed())); }
@Before public void setUp() throws IOException { PDFSConfig config = new PDFSConfig( MoreExecutors.newDirectExecutorService(), null, null, ENDPOINTS_PROVIDER, LOCAL_ENDPOINT, true); hadoopConf = new Configuration(); fs = newPseudoDistributedFileSystem(config); }
@Test public void testCanonicalizeLocalFileIfNoLocalAccess() throws IOException { Provider<Iterable<NodeEndpoint>> endpointsProvider = DirectProvider.<Iterable<NodeEndpoint>>wrap((Arrays.asList(REMOTE_ENDPOINT_1, REMOTE_ENDPOINT_2))); PDFSConfig pdfsConfig = new PDFSConfig(MoreExecutors.newDirectExecutorService(), null, null, endpointsProvider, LOCAL_ENDPOINT, false); PseudoDistributedFileSystem pdfs = newPseudoDistributedFileSystem(pdfsConfig); Path path = new Path("/foo/bar/file"); Path resolvedPath = pdfs.canonicalizePath(path); assertEquals(new Path("/foo/bar/10.0.0.2@file"), resolvedPath); } }