Skip to content

Commit

Permalink
Merge pull request #107 from bgokden/develop
Browse files Browse the repository at this point in the history
Deletion of unused datasets
  • Loading branch information
bgokden committed May 5, 2023
2 parents a32fdc3 + eb09b38 commit 22ca908
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
18 changes: 18 additions & 0 deletions data/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func (dt *Data) Close() error {
}
}
// return dt.DB.Close()
dt.DeletePath()
return nil
}

Expand All @@ -123,6 +124,23 @@ func (dt *Data) DeletePath() error {
return nil
}

// Check if dataset is active
func (dt *Data) CheckIfActive() bool {
if dt.N > 0 {
return true
}
if dt.Sources != nil && len(dt.Sources.Items()) > 0 {
sourceList := dt.Sources.Items()
for _, sourceItem := range sourceList { // Assumption is that random map runs are random enough
source := sourceItem.Object.(DataSource)
if source.GetDataInfo().N > 0 {
return true
}
}
}
return false
}

// Run runs statistical calculation regularly
func (dt *Data) Run() error {
if atomic.LoadInt32(&dt.Runs) >= 1 {
Expand Down
13 changes: 11 additions & 2 deletions data/dataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,20 @@ func (dts *Dataset) LoadIndex() error {

func (dts *Dataset) ReloadRuns() error {
itemList := dts.DataList.Items()
for _, itemInterface := range itemList {
removeList := make([]string, 0, len(itemList))
for key, itemInterface := range itemList {
if item, ok := itemInterface.Object.(*Data); ok {
go item.Run()
if item.CheckIfActive() {
go item.Run()
} else {
item.Close()
removeList = append(removeList, key)
}
}
}
for _, key := range removeList {
dts.DataList.Delete(key)
}
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions kubernetes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ spec:
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 10%
maxUnavailable: 5%
maxSurge: 1
selector:
matchLabels:
Expand All @@ -56,7 +56,7 @@ spec:
spec:
containers:
- name: veri
image: berkgokden/veri:v0.0.103
image: berkgokden/veri:v0.0.104
args: ["serve", "--services=veriservice:10000"]
imagePullPolicy: IfNotPresent
ports:
Expand Down

0 comments on commit 22ca908

Please sign in to comment.