/** * Sets the file system and context. Contexts with the same subject are shared among file systems * to reduce resource usage such as the metrics heartbeat. */ private void updateFileSystemAndContext() { Subject subject = getHadoopSubject(); if (subject != null) { LOG.debug("Using Hadoop subject: {}", subject); mContext = FileSystemContext.get(subject); mFileSystem = FileSystem.Factory.get(mContext); } else { LOG.debug("No Hadoop subject. Using FileSystem Context without subject."); mContext = FileSystemContext.get(); mFileSystem = FileSystem.Factory.get(mContext); } }
/** * Checks whether the connect details from the uri + hadoop conf + global Alluxio conf are the * same as the connect details currently being used by {@link FileSystemContext}. * * @param uri the uri * @param conf the hadoop conf * @return whether the details match */ private boolean connectDetailsMatch(URI uri, org.apache.hadoop.conf.Configuration conf) { // Create the master inquire client that we would have after merging the hadoop conf into // Alluxio Configuration. AlluxioConfiguration alluxioConf = new InstancedConfiguration(Configuration.global()); HadoopConfigurationUtils.mergeHadoopConfiguration(conf, alluxioConf); ConnectDetails newDetails = Factory.getConnectDetails(alluxioConf); return newDetails.equals(FileSystemContext.get().getMasterInquireClient().getConnectDetails()); }
LOG.warn(ExceptionMessage.DIFFERENT_MASTER_ADDRESS .getMessage(mUri.getHost() + ":" + mUri.getPort(), FileSystemContext.get().getMasterAddress())); sInitialized = false;
/** * Resets the client pools to the original state. */ protected void resetClientPools() throws IOException { Configuration.set(PropertyKey.USER_METRICS_COLLECTION_ENABLED, false); FileSystemContext.clearCache(); FileSystemContext.get().reset(Configuration.global()); }
/** * Starts both master and a worker using the configurations in test conf respectively. */ public void start() throws Exception { // Disable HDFS client caching to avoid file system close() affecting other clients System.setProperty("fs.hdfs.impl.disable.cache", "true"); resetClientPools(); setupTest(); startMasters(); // Reset the file system context to make sure the correct master RPC port is used. FileSystemContext.get().reset(Configuration.global()); startWorkers(); startProxy(); // Reset contexts so that they pick up the updated configuration. reset(); }