예제 #1
0
파일: skyring.go 프로젝트: skyrings/skyring
func scheduleSummaryMonitoring(config conf.SystemSummaryConfig) error {
	go ComputeSystemSummary(make(map[string]interface{}))
	schedule.InitShechuleManager()
	scheduler, err := schedule.NewScheduler()
	if err != nil {
		logger.Get().Error("Error scheduling the system summary calculation. Error %v", err)
		return err
	}
	f := ComputeSystemSummary
	go scheduler.Schedule(time.Duration(config.NetSummaryInterval)*time.Second, f, make(map[string]interface{}))
	return nil
}
예제 #2
0
파일: skyring.go 프로젝트: skyrings/skyring
func schedulePhysicalResourceStatsFetch(config conf.SystemSummaryConfig, params map[string]interface{}) error {
	go SyncNodeUtilizations(params)
	schedule.InitShechuleManager()
	scheduler, err := schedule.NewScheduler()
	if err != nil {
		logger.Get().Error("Error scheduling the node resource fetch. Error %v", err)
		return err
	}
	f := SyncNodeUtilizations
	go scheduler.Schedule(time.Duration(config.NetSummaryInterval)*time.Second, f, params)
	return nil
}
예제 #3
0
파일: skyring.go 프로젝트: skyrings/skyring
func (a *App) PostInitApplication(sysConfig conf.SkyringCollection) error {
	// Initialize the scheduler
	schedule.InitShechuleManager()

	// Create syncing schedule
	scheduler, err := schedule.NewScheduler()
	if err != nil {
		logger.Get().Error("Error scheduling clusters syncing")
	} else {
		if sysConfig.ScheduleConfig.ClustersSyncInterval == 0 {
			sysConfig.ScheduleConfig.ClustersSyncInterval = 86400 // 24hrs
		}
		go scheduler.Schedule(
			time.Duration(sysConfig.ScheduleConfig.ClustersSyncInterval)*time.Second,
			a.SyncClusterDetails,
			nil)
	}

	// Create monitoring schedule
	go InitMonitoringSchedules()

	// First time sync of the cluster details while startup
	go a.SyncClusterDetails(nil)

	reqId, err := uuid.New()
	if err != nil {
		logger.Get().Error("Error Creating the RequestId. error: %v", err)
		return fmt.Errorf("Error Creating the RequestId. error: %v", err)
	}

	ctxt := fmt.Sprintf("%v:%v", models.ENGINE_NAME, reqId.String())
	if err := schedulePhysicalResourceStatsFetch(sysConfig.SummaryConfig, map[string]interface{}{"ctxt": ctxt}); err != nil {
		logger.Get().Error("%s - Failed to schedule fetching node resource utilizations.Error %v", ctxt, err)
		return err
	}

	if err := scheduleSummaryMonitoring(sysConfig.SummaryConfig); err != nil {
		logger.Get().Error("%s - Failed to schedule fetching summary.Error %v", ctxt, err)
		return err
	}
	schedule_task_check(ctxt)
	node_Reinitialize()
	cleanupTasks()
	initializeAbout(ctxt)
	schedule_archive_activities(ctxt)
	FailStillCreatingClusters(ctxt)
	schedule_session_refresh(ctxt)
	return nil
}
예제 #4
0
파일: main.go 프로젝트: skyrings/bigfin
func main() {
	confStr := make([]byte, base64.StdEncoding.DecodedLen(len(os.Args[1])))
	l, _ := base64.StdEncoding.Decode(confStr, []byte(os.Args[1]))

	key, err := ioutil.ReadFile(models.SKYRING_ENC_KEY_FILE)
	if err != nil {
		panic(fmt.Sprintf("Reading enc key failed. error: %v", err))
	}
	cfgs, err := crypto.Decrypt(key, []byte(confStr[:l]))

	var config conf.SkyringCollection
	if err := json.Unmarshal(cfgs, &config); err != nil {
		panic(fmt.Sprintf("Reading configurations failed. error: %v", err))
	}
	conf.SystemConfig = config

	var eventTypes = make(map[string]string)
	if err := json.Unmarshal([]byte(os.Args[2]), &eventTypes); err != nil {
		panic(fmt.Sprintf("Reading event types failed. error: %v", err))
	}
	provider.EventTypes = eventTypes

	var providerConfig conf.ProviderInfo
	if err := json.Unmarshal([]byte(os.Args[3]), &providerConfig); err != nil {
		panic(fmt.Sprintf("Reading provider configurations failed. error: %v", err))
	}
	bigfin_conf.ProviderConfig = providerConfig

	// Initialize the logger
	level, err := logging.LogLevel(config.Logging.Level.String())
	if err != nil {
		level = logging.DEBUG
	}
	if err := logger.Init(
		"bigfin",
		fmt.Sprintf("%s/bigfin.log", filepath.Dir(config.Logging.Filename)),
		true,
		level); err != nil {
		panic(fmt.Sprintf("log init failed. %s", err))
	}

	if err := db.InitDBSession(config.DBConfig); err != nil {
		logger.Get().Fatalf("Unable to initialize DB. error: %v", err)
	}

	//Initialize the DB provider
	if err := provider.InitializeDb(); err != nil {
		logger.Get().Error("Unable to initialize the DB provider: %s", err)
	}

	// Initialize the task manager
	if err := task.InitializeTaskManager(); err != nil {
		logger.Get().Fatalf("Failed to initialize task manager. error: %v", err)
	}

	if err := provider.InitMonitoringManager(); err != nil {
		logger.Get().Fatalf("Error initializing the monitoring manager: %v", err)
	}

	if err := provider.InitInstaller(); err != nil {
		logger.Get().Fatalf("Error initializing the Installer: %v", err)
	}

	schedule.InitShechuleManager()
	if err := provider.ScheduleRbdEventEmitter(); err != nil {
		logger.Get().Error("Error while initializing RbdEventer scheduler: %v", err)
	}

	// Initialize ceph http client
	client.InitCephApiSession()

	provd := &provider.CephProvider{}
	p := pie.NewProvider()
	if err := p.RegisterName(bigfin_conf.ProviderName, provd); err != nil {
		logger.Get().Fatalf("Failed to register plugin. error: %v", err)
	}
	p.ServeCodec(jsonrpc.NewServerCodec)
}