// ReloadFormatHandler - Reload Format.
435402
func (s *peerRESTServer) ReloadFormatHandler(w http.ResponseWriter, r *http.Request) {
	if !s.IsValid(w, r) {
		s.writeErrorResponse(w, errors.New("Invalid request"))
		return
	}

	vars := mux.Vars(r)
	dryRunString := vars[peerRESTDryRun]
	if dryRunString == "" {
		s.writeErrorResponse(w, errors.New("dry run parameter is missing"))
		return
	}

	var dryRun bool
	switch strings.ToLower(dryRunString) {
	case "true":
		dryRun = true
	case "false":
		dryRun = false
	default:
		s.writeErrorResponse(w, errInvalidArgument)
		return
	}

	objAPI := newObjectLayerFn()
	if objAPI == nil {
		s.writeErrorResponse(w, errServerNotInitialized)
		return
	}
	err := objAPI.ReloadFormat(context.Background(), dryRun)
	if err != nil {
		s.writeErrorResponse(w, err)
		return
	}
	w.(http.Flusher).Flush()
}
501374
func (mod *RSSBee) ReloadOptions(options bees.BeeOptions) {
	mod.SetOptions(options)

	options.Bind("skip_first", &mod.skipNextFetch)
	options.Bind("url", &mod.url)
}
675558
func (c *Command) handleReload() {
	c.Ui.Output("Reloading configuration...")
	newConf := c.readConfig()
	if newConf == nil {
		c.Ui.Error(fmt.Sprintf("Failed to reload configs"))
		return
	}

	// Change the log level
	minLevel := logutils.LogLevel(strings.ToUpper(newConf.LogLevel))
	if ValidateLevelFilter(minLevel, c.logFilter) {
		c.logFilter.SetMinLevel(minLevel)
	} else {
		c.Ui.Error(fmt.Sprintf(
			"Invalid log level: %s. Valid log levels are: %v",
			minLevel, c.logFilter.Levels))

		// Keep the current log level
		newConf.LogLevel = c.agent.GetConfig().LogLevel
	}

	shouldReloadAgent, shouldReloadHTTP := c.agent.ShouldReload(newConf)
	if shouldReloadAgent {
		c.agent.logger.Debug("starting reload of agent config")
		err := c.agent.Reload(newConf)
		if err != nil {
			c.agent.logger.Error("failed to reload the config", "error", err)
			return
		}
	}

	if s := c.agent.Server(); s != nil {
		c.agent.logger.Debug("starting reload of server config")
		sconf, err := convertServerConfig(newConf)
		if err != nil {
			c.agent.logger.Error("failed to convert server config", "error", err)
			return
		}

		// Finalize the config to get the agent objects injected in
		c.agent.finalizeServerConfig(sconf)

		// Reload the config
		if err := s.Reload(sconf); err != nil {
			c.agent.logger.Error("reloading server config failed", "error", err)
			return
		}
	}

	if s := c.agent.Client(); s != nil {
		c.agent.logger.Debug("starting reload of client config")
		clientConfig, err := convertClientConfig(newConf)
		if err != nil {
			c.agent.logger.Error("failed to convert client config", "error", err)
			return
		}

		// Finalize the config to get the agent objects injected in
		if err := c.agent.finalizeClientConfig(clientConfig); err != nil {
			c.agent.logger.Error("failed to finalize client config", "error", err)
			return
		}

		if err := c.agent.Client().Reload(clientConfig); err != nil {
			c.agent.logger.Error("reloading client config failed", "error", err)
			return
		}
	}

	// reload HTTP server after we have reloaded both client and server, in case
	// we error in either of the above cases. For example, reloading the http
	// server to a TLS connection could succeed, while reloading the server's rpc
	// connections could fail.
	if shouldReloadHTTP {
		err := c.reloadHTTPServer()
		if err != nil {
			c.agent.httpLogger.Error("reloading config failed", "error", err)
			return
		}
	}
}
839715
func (p *chainMonitor) ReorgHandler() {
	defer p.wg.Done()
out:
	for {
	keepon:
		select {
		case reorgData, ok := <-p.reorgChan:
			if !ok {
				log.Warnf("Reorg channel closed.")
				break out
			}
			if reorgData == nil {
				log.Warnf("nil reorg data received!")
				break keepon
			}

			newHeight := reorgData.NewChainHeight
			newHash := reorgData.NewChainHead

			// Do not handle reorg and block connects simultaneously.
			p.reorgLock.Lock()

			log.Infof("Reorganize signaled to blockdata. "+
				"Collecting data for NEW head block %v at height %d.",
				newHash, newHeight)

			// Collect data for the new best block.
			msgBlock, blockData, err := p.collect(&newHash)
			if err != nil {
				log.Errorf("ReorgHandler: Failed to collect data for block %v: %v", newHash, err)
				p.reorgLock.Unlock()
				reorgData.WG.Done()
				break keepon
			}

			// Store block data with each REORG saver.
			for _, s := range p.reorgDataSavers {
				if s != nil {
					// Save data to wherever the saver wants to put it.
					if err := s.Store(blockData, msgBlock); err != nil {
						log.Errorf("(%v).Store failed: %v", reflect.TypeOf(s), err)
					}
				}
			}

			p.reorgLock.Unlock()

			reorgData.WG.Done()

		case <-p.ctx.Done():
			log.Debugf("Got quit signal. Exiting reorg notification handler.")
			break out
		}
	}
}
1298582
func (p *Phosphor) reloadConfig() error {
	c := p.configProvider.Config()

	// Skip reloading if the config is the same
	h := fmt.Sprintf("%x", deephash.Hash(c))
	if p.compareConfigHash(h) {
		return nil
	}

	// keep reference to the old channel so we can drain this in parallel with
	// new traces the transport receives
	oldChan := p.traceChan

	// init new channel for traces, ensure this *isn't* zero
	bufLen := c.BufferSize
	if bufLen == 0 {
		bufLen = defaultTraceBufferSize
	}
	newChan := make(chan []byte, bufLen)

	// Get a new transport and keep a reference to the old one
	p.trMtx.Lock()
	defer p.trMtx.Unlock()
	oldTr := p.tr
	endpoint := fmt.Sprintf("%s:%v", c.Host, c.Port)
	newTr := newUDPTransport(endpoint)

	// start new transport by passing both channels to this
	// therefore it starts consuming from the new one (with nothing)
	// and also the old one (still current) in parallel to the previous transport
	// If this somehow fails, abort until next attempt
	if err := newTr.Consume(oldChan, newChan); err != nil {
		newTr.Stop()
		return err
	}

	// swap the client reference of the trace channel from old to new, so
	// new clients start using the new resized channel
	// TODO atomically swap this
	p.traceChan = newChan

	// gracefully shut down old transport, so just the new one is running
	if oldTr != nil {
		if err := oldTr.Stop(); err != nil {
			return err
		}
	}

	// set the config hash & swap the transport as we're finished
	p.updateConfigHash(h)
	p.tr = newTr

	return nil
}
144894
func NewLoginFormRenderer(customLoginTemplateFile string) (*loginTemplateRenderer, error) {
	r := &loginTemplateRenderer{}
	if len(customLoginTemplateFile) > 0 {
		customTemplate, err := template.ParseFiles(customLoginTemplateFile)
		if err != nil {
			return nil, err
		}
		r.loginTemplate = customTemplate
	} else {
		r.loginTemplate = defaultLoginTemplate
	}

	return r, nil
}
412970
func (m *nfsMounter) Reload(source string) error {
	newNFSm, err := NewNFSMounter([]string{NFSAllServers},
		m.mountImpl,
		m.Mounter.allowedDirs,
	)
	if err != nil {
		return err
	}
	newNFSmounter, ok := newNFSm.(*nfsMounter)
	if !ok {
		return fmt.Errorf("Internal error failed to convert %T",
			newNFSmounter)
	}

	return m.reload(source, newNFSmounter.mounts[source])
}
496572
func Loader(l CacheableLoader) Option {
	return func(c Cache) error {
		switch oc := c.(type) {
		case *cache:
			oc.load = l
			return nil
		default:
			return errors.New(ErrIllegalCache, errorMessages)
		}
	}
}
1166287
func (exp *explorerUI) reloadTemplatesSig(sig os.Signal) {
	sigChan := make(chan os.Signal, 1)
	signal.Notify(sigChan, sig)

	go func() {
		for {
			sigr := <-sigChan
			log.Infof("Received %s", sig)
			if sigr == sig {
				if err := exp.reloadTemplates(); err != nil {
					log.Error(err)
					continue
				}
				log.Infof("Explorer UI html templates reparsed.")
			}
		}
	}()
}
1138138
func (r *Node) Reload() (*Node, error) {
	return r.collection.Get(r.Metadata.Name)
}
338721
func (b *Backend) loader(c context.Context, k Key, v *Value) (*Value, error) {
	return CacheLoad(c, b.B, k, v)
}
1158240
func (client *peerRESTClient) ReloadFormat(dryRun bool) error {
	values := make(url.Values)
	if dryRun {
		values.Set(peerRESTDryRun, "true")
	} else {
		values.Set(peerRESTDryRun, "false")
	}

	respBody, err := client.call(peerRESTMethodReloadFormat, values, nil, -1)
	if err != nil {
		return err
	}
	defer http.DrainBody(respBody)
	return nil
}
1027198
func (a *ArgType) TemplateLoader(name string) ([]byte, error) {
	// no template path specified
	if a.TemplatePath == "" {
		return templates.Asset(name)
	}

	return ioutil.ReadFile(path.Join(a.TemplatePath, name))
}
438127
func (fs *FSObjects) ReloadFormat(ctx context.Context, dryRun bool) error {
	logger.LogIf(ctx, NotImplemented{})
	return NotImplemented{}
}
486622
func loadFormatXLAll(storageDisks []StorageAPI) ([]*formatXLV3, []error) {
	// Initialize sync waitgroup.
	var wg = &sync.WaitGroup{}

	// Initialize list of errors.
	var sErrs = make([]error, len(storageDisks))

	// Initialize format configs.
	var formats = make([]*formatXLV3, len(storageDisks))

	// Load format from each disk in parallel
	for index, disk := range storageDisks {
		if disk == nil {
			sErrs[index] = errDiskNotFound
			continue
		}
		wg.Add(1)
		// Launch go-routine per disk.
		go func(index int, disk StorageAPI) {
			defer wg.Done()

			format, lErr := loadFormatXL(disk)
			if lErr != nil {
				sErrs[index] = lErr
				return
			}
			formats[index] = format
		}(index, disk)
	}

	// Wait for all go-routines to finish.
	wg.Wait()

	// Return all formats and nil
	return formats, sErrs
}
839238
func (loader *TemplateLoader) Refresh() (err *Error) {
	loader.templateMutex.Lock()
	defer loader.templateMutex.Unlock()

	loader.loadVersionSeed++
	runtimeLoader := &templateRuntime{loader: loader,
		version:     loader.loadVersionSeed,
		templateMap: map[string]Template{}}

	templateLog.Debug("Refresh: Refreshing templates from ", "path", loader.paths)
	if err = loader.initializeEngines(runtimeLoader, Config.StringDefault("template.engines", GO_TEMPLATE)); err != nil {
		return
	}
	for _, engine := range runtimeLoader.templatesAndEngineList {
		engine.Event(TEMPLATE_REFRESH_REQUESTED, nil)
	}
	RaiseEvent(TEMPLATE_REFRESH_REQUESTED, nil)
	defer func() {
		for _, engine := range runtimeLoader.templatesAndEngineList {
			engine.Event(TEMPLATE_REFRESH_COMPLETED, nil)
		}
		RaiseEvent(TEMPLATE_REFRESH_COMPLETED, nil)

		// Reset the runtimeLoader
		loader.runtimeLoader.Store(runtimeLoader)
	}()

	// Resort the paths, make sure the revel path is the last path,
	// so anything can override it
	revelTemplatePath := filepath.Join(RevelPath, "templates")
	// Go through the paths
	for i, o := range loader.paths {
		if o == revelTemplatePath && i != len(loader.paths)-1 {
			loader.paths[i] = loader.paths[len(loader.paths)-1]
			loader.paths[len(loader.paths)-1] = revelTemplatePath
		}
	}
	templateLog.Debug("Refresh: Refreshing templates from", "path", loader.paths)

	runtimeLoader.compileError = nil
	runtimeLoader.TemplatePaths = map[string]string{}

	for _, basePath := range loader.paths {
		// Walk only returns an error if the template loader is completely unusable
		// (namely, if one of the TemplateFuncs does not have an acceptable signature).

		// Handling symlinked directories
		var fullSrcDir string
		f, err := os.Lstat(basePath)
		if err == nil && f.Mode()&os.ModeSymlink == os.ModeSymlink {
			fullSrcDir, err = filepath.EvalSymlinks(basePath)
			if err != nil {
				templateLog.Panic("Refresh: Eval symlinks error ", "error", err)
			}
		} else {
			fullSrcDir = basePath
		}

		var templateWalker filepath.WalkFunc

		templateWalker = func(path string, info os.FileInfo, err error) error {
			if err != nil {
				templateLog.Error("Refresh: error walking templates:", "error", err)
				return nil
			}

			// Walk into watchable directories
			if info.IsDir() {
				if !loader.WatchDir(info) {
					return filepath.SkipDir
				}
				return nil
			}

			// Only add watchable
			if !loader.WatchFile(info.Name()) {
				return nil
			}

			fileBytes, err := runtimeLoader.findAndAddTemplate(path, fullSrcDir, basePath)
			if err != nil {
				// Add in this template name to the list of templates unable to be compiled
				runtimeLoader.compileErrorNameList = append(runtimeLoader.compileErrorNameList, filepath.ToSlash(path[len(fullSrcDir)+1:]))
			}
			// Store / report the first error encountered.
			if err != nil && runtimeLoader.compileError == nil {
				runtimeLoader.compileError, _ = err.(*Error)

				if nil == runtimeLoader.compileError {
					_, line, description := ParseTemplateError(err)

					runtimeLoader.compileError = &Error{
						Title:       "Template Compilation Error",
						Path:        path,
						Description: description,
						Line:        line,
						SourceLines: strings.Split(string(fileBytes), "\n"),
					}
				}
				templateLog.Errorf("Refresh: Template compilation error (In %s around line %d):\n\t%s",
					path, runtimeLoader.compileError.Line, err.Error())
			} else if nil != err { //&& strings.HasPrefix(templateName, "errors/") {

				if compileError, ok := err.(*Error); ok {
					templateLog.Errorf("Template compilation error (In %s around line %d):\n\t%s",
						path, compileError.Line, err.Error())
				} else {
					templateLog.Errorf("Template compilation error (In %s ):\n\t%s",
						path, err.Error())
				}
			}
			return nil
		}

		if _, err = os.Lstat(fullSrcDir); os.IsNotExist(err) {
			// #1058 Given views/template path is not exists
			// so no need to walk, move on to next path
			continue
		}

		funcErr := Walk(fullSrcDir, templateWalker)

		// If there was an error with the Funcs, set it and return immediately.
		if funcErr != nil {
			runtimeLoader.compileError = NewErrorFromPanic(funcErr)
			return runtimeLoader.compileError
		}
	}

	// Note: compileError may or may not be set.
	return runtimeLoader.compileError
}
1197995
func (c *Command) reloadHTTPServer() error {
	c.agent.logger.Info("reloading HTTP server with new TLS configuration")

	c.httpServer.Shutdown()

	http, err := NewHTTPServer(c.agent, c.agent.config)
	if err != nil {
		return err
	}
	c.httpServer = http

	return nil
}