-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve rucio-dataset-mon-go html (#150)
- Loading branch information
Showing
11 changed files
with
331 additions
and
200 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
package models | ||
|
||
import "go.mongodb.org/mongo-driver/bson/primitive" | ||
|
||
// Dataset struct which includes Rucio and DBS calculated values | ||
type Dataset struct { | ||
Id primitive.ObjectID `bson:"_id"` | ||
RseType string `bson:"RSE_TYPE,omitempty" validate:"required"` | ||
Dataset string `bson:"dataset,omitempty" validate:"required"` | ||
LastAccess string `bson:"last_access"` | ||
LastAccessMs int64 `bson:"last_access_ms"` | ||
MaxDatasetSizeInRsesGB float64 `bson:"max_dataset_size_in_rses(GB)"` | ||
MinDatasetSizeInRsesGB float64 `bson:"min_dataset_size_in_rses(GB)"` | ||
SumDatasetSizeInRsesGB float64 `bson:"sum_dataset_size_in_rses(GB)"` | ||
RSEs string `bson:"RSE(s)"` | ||
RseType string `bson:"RseType,omitempty" validate:"required"` | ||
Dataset string `bson:"Dataset,omitempty" validate:"required"` | ||
LastAccess string `bson:"LastAccess"` | ||
LastAccessMs int64 `bson:"LastAccessMs"` | ||
MaxDatasetSizeInRsesGB float64 `bson:"MaxDatasetSizeInRsesGB"` | ||
MinDatasetSizeInRsesGB float64 `bson:"MinDatasetSizeInRsesGB"` | ||
AvgDatasetSizeInRsesGB float64 `bson:"AvgDatasetSizeInRsesGB"` | ||
SumDatasetSizeInRsesGB float64 `bson:"SumDatasetSizeInRsesGB"` | ||
RSEs string `bson:"RSEs"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package mongo | ||
|
||
import ( | ||
"context" | ||
"go.mongodb.org/mongo-driver/bson" | ||
"go.mongodb.org/mongo-driver/mongo" | ||
) | ||
|
||
// GetResults returns cursor of aggregate query results | ||
func GetResults(ctx context.Context, collection *mongo.Collection, match bson.M, sort bson.D, skip int64, limit int64) (*mongo.Cursor, error) { | ||
pipeline := []bson.M{ | ||
{"$match": match}, | ||
{"$sort": sort}, | ||
{"$skip": skip}, | ||
{"$limit": limit}, | ||
} | ||
cursor, err := collection.Aggregate(ctx, pipeline) | ||
return cursor, err | ||
} | ||
|
||
// GetCount returns count of query result | ||
func GetCount(ctx context.Context, collection *mongo.Collection, match bson.M) (int64, error) { | ||
count, err := collection.CountDocuments(ctx, match) | ||
return count, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package mongo | ||
|
||
import ( | ||
"context" | ||
"github.com/dmwm/CMSMonitoring/src/go/rucio-dataset-mon-go/configs" | ||
"go.mongodb.org/mongo-driver/mongo" | ||
"go.mongodb.org/mongo-driver/mongo/options" | ||
"log" | ||
"time" | ||
) | ||
|
||
// DBClient MongoDb Client instance(mongo.Client) | ||
var DBClient = GetMongoClient() | ||
|
||
// GetMongoClient returns mongo client | ||
func GetMongoClient() *mongo.Client { | ||
var err error | ||
var client *mongo.Client | ||
opts := options.Client() | ||
opts.ApplyURI(configs.EnvMongoURI()) | ||
opts.SetMaxPoolSize(100) | ||
opts.SetConnectTimeout(time.Duration(configs.EnvConnTimeout()) * time.Second) | ||
if client, err = mongo.Connect(context.Background(), opts); err != nil { | ||
log.Fatal(err) | ||
} | ||
if err := client.Ping(context.Background(), nil); err != nil { | ||
log.Fatal(err) | ||
} | ||
return client | ||
} | ||
|
||
// GetCollection returns Mongo db collection with the given collection name | ||
func GetCollection(client *mongo.Client, collectionName string) *mongo.Collection { | ||
collection := client.Database(configs.EnvMongoDB()).Collection(collectionName) | ||
return collection | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.