/// <exception cref="System.Exception"/> protected override void ServiceInit(Configuration conf) { if (this.scmAddress == null) { this.scmAddress = GetScmAddress(conf); } this.conf = conf; this.checksum = SharedCacheChecksumFactory.GetChecksum(conf); base.ServiceInit(conf); }
/// <param name="resource">the local resource that contains the original remote path</param> /// <param name="localPath"> /// the path in the local filesystem where the resource is /// localized /// </param> /// <param name="fs">the filesystem of the shared cache</param> /// <param name="localFs">the local filesystem</param> public SharedCacheUploader(LocalResource resource, Path localPath, string user, Configuration conf, SCMUploaderProtocol scmClient, FileSystem fs, FileSystem localFs) { this.resource = resource; this.localPath = localPath; this.user = user; this.conf = conf; this.scmClient = scmClient; this.fs = fs; this.sharedCacheRootDir = conf.Get(YarnConfiguration.SharedCacheRoot, YarnConfiguration .DefaultSharedCacheRoot); this.nestedLevel = SharedCacheUtil.GetCacheDepth(conf); this.checksum = SharedCacheChecksumFactory.GetChecksum(conf); this.localFs = localFs; this.recordFactory = RecordFactoryProvider.GetRecordFactory(null); }
/// <summary> /// Get a new <code>SharedCacheChecksum</code> object based on the configurable /// algorithm implementation /// (see <code>yarn.sharedcache.checksum.algo.impl</code>) /// </summary> /// <returns><code>SharedCacheChecksum</code> object</returns> public static SharedCacheChecksum GetChecksum(Configuration conf) { Type clazz = conf.GetClass <SharedCacheChecksum>(YarnConfiguration.SharedCacheChecksumAlgoImpl , defaultAlgorithm); SharedCacheChecksum checksum = instances[clazz]; if (checksum == null) { try { checksum = ReflectionUtils.NewInstance(clazz, conf); SharedCacheChecksum old = instances.PutIfAbsent(clazz, checksum); if (old != null) { checksum = old; } } catch (Exception e) { throw new YarnRuntimeException(e); } } return(checksum); }