示例#1
0
func NewLogger(uri string) (logging.Logger, errors.Error) {
	var logger logging.Logger
	if strings.HasPrefix(uri, "golog") {
		logger = logger_golog.NewLogger(os.Stderr, logging.Info, false)
		logging.SetLogger(logger)
		return logger, nil
	}
	return nil, errors.NewAdminInvalidURL("Logger", uri)
}
示例#2
0
func NewAcctstore(uri string) (accounting.AccountingStore, errors.Error) {
	if strings.HasPrefix(uri, "stub:") {
		return accounting_stub.NewAccountingStore(uri)
	}

	if strings.HasPrefix(uri, "gometrics:") {
		return accounting_gm.NewAccountingStore(), nil
	}

	return nil, errors.NewAdminInvalidURL("AccountingStore", uri)
}
示例#3
0
func NewClusterConfig(uri string,
	clusterName string,
	version string,
	datastore datastore.Datastore,
	acctstore accounting.AccountingStore,
	cfgstore clustering.ConfigurationStore) (clustering.Cluster, errors.Error) {

	if strings.HasPrefix(uri, "zookeeper:") {
		v := clustering.NewVersion(version)
		return clustering_zk.NewCluster(clusterName, v, cfgstore, datastore, acctstore)
	}
	return nil, errors.NewAdminInvalidURL("ConfigurationStore", uri)
}
示例#4
0
func NewQueryNodeConfig(uri string,
	version string,
	httpAddr string,
	opts clustering.ClOptions,
	datastore datastore.Datastore,
	acctstore accounting.AccountingStore,
	cfgstore clustering.ConfigurationStore) (clustering.QueryNode, errors.Error) {

	if strings.HasPrefix(uri, "zookeeper:") {
		v := clustering.NewVersion(version)
		s := clustering.NewStandalone(v, cfgstore, datastore, acctstore)
		return clustering_zk.NewQueryNode(httpAddr, s, &opts)
	}
	return nil, errors.NewAdminInvalidURL("ConfigurationStore", uri)
}
示例#5
0
func NewConfigstore(uri string) (clustering.ConfigurationStore, errors.Error) {
	if strings.HasPrefix(uri, "http:") {
		clustering_cb.Enable_ns_server_shutdown()
		return clustering_cb.NewConfigstore(uri)
	}

	if strings.HasPrefix(uri, "zookeeper:") {
		return clustering_zk.NewConfigstore(uri)
	}

	if strings.HasPrefix(uri, "stub:") {
		return clustering_stub.NewConfigurationStore()
	}
	return nil, errors.NewAdminInvalidURL("ConfigurationStore", uri)
}