示例#1
0
        /// <exception cref="System.IO.IOException"/>
        public ShortCircuitRegistry(Configuration conf)
        {
            bool enabled = false;
            SharedFileDescriptorFactory shmFactory = null;
            DomainSocketWatcher         watcher    = null;

            try
            {
                int interruptCheck = conf.GetInt(DFSConfigKeys.DfsShortCircuitSharedMemoryWatcherInterruptCheckMs
                                                 , DFSConfigKeys.DfsShortCircuitSharedMemoryWatcherInterruptCheckMsDefault);
                if (interruptCheck <= 0)
                {
                    throw new IOException(DFSConfigKeys.DfsShortCircuitSharedMemoryWatcherInterruptCheckMs
                                          + " was set to " + interruptCheck);
                }
                string[] shmPaths = conf.GetTrimmedStrings(DFSConfigKeys.DfsDatanodeSharedFileDescriptorPaths
                                                           );
                if (shmPaths.Length == 0)
                {
                    shmPaths = DFSConfigKeys.DfsDatanodeSharedFileDescriptorPathsDefault.Split(",");
                }
                shmFactory = SharedFileDescriptorFactory.Create("HadoopShortCircuitShm_", shmPaths
                                                                );
                string dswLoadingFailure = DomainSocketWatcher.GetLoadingFailureReason();
                if (dswLoadingFailure != null)
                {
                    throw new IOException(dswLoadingFailure);
                }
                watcher = new DomainSocketWatcher(interruptCheck, "datanode");
                enabled = true;
                if (Log.IsDebugEnabled())
                {
                    Log.Debug("created new ShortCircuitRegistry with interruptCheck=" + interruptCheck
                              + ", shmPath=" + shmFactory.GetPath());
                }
            }
            catch (IOException e)
            {
                if (Log.IsDebugEnabled())
                {
                    Log.Debug("Disabling ShortCircuitRegistry", e);
                }
            }
            finally
            {
                this.enabled    = enabled;
                this.shmFactory = shmFactory;
                this.watcher    = watcher;
            }
        }
 /// <exception cref="System.IO.IOException"/>
 internal DfsClientShmManager(int interruptCheckPeriodMs)
 {
     this.domainSocketWatcher = new DomainSocketWatcher(interruptCheckPeriodMs, "client"
                                                        );
 }