forked from grafadruid/go-druid
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement suspend and resume endpoints of supervisor API #7
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
bc7e9a3
Implement suspend and resume endpoints of supervisor API
tomasz-h2o b2369aa
Added TODO tag
tomasz-h2o d481f9b
Merge branch 'master' into tomasz/implement-suspend-resume
vzayts 6bc0bca
WIP: fix build
vzayts c226455
WIP: fix build
vzayts 9f0b917
WIP: fix test
vzayts 3ea7ac6
WIP: fix merge/rebase test issues
vzayts 54b09ed
WIP: fix merge/rebase test issues and remove debug print
vzayts b87f9a6
WIP fix query granularity
vzayts fa66989
Address CR comments
vzayts b543780
Fix comment and rename types.
vzayts 2510094
Make QueryGranularity field a pointer field.
vzayts 24498ae
Update supervisor.go
vzayts File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,5 +1,10 @@ | ||||||||||||||||
package druid | ||||||||||||||||
|
||||||||||||||||
import ( | ||||||||||||||||
"encoding/json" | ||||||||||||||||
"fmt" | ||||||||||||||||
) | ||||||||||||||||
|
||||||||||||||||
// InputIngestionSpec is the root-level type defining an ingestion spec used | ||||||||||||||||
// by Apache Druid. | ||||||||||||||||
type InputIngestionSpec struct { | ||||||||||||||||
|
@@ -125,7 +130,12 @@ type SpatialDimension struct { | |||||||||||||||
type TransformSet []Transform | ||||||||||||||||
|
||||||||||||||||
// DimensionSet is a unique set of druid datasource dimensions(labels). | ||||||||||||||||
type DimensionSet []any | ||||||||||||||||
type DimensionSet []DimensionSpec | ||||||||||||||||
|
||||||||||||||||
// DimensionSpec is a single dataset dimension that can be represented by a typed Dimension or a string value. | ||||||||||||||||
type DimensionSpec struct { | ||||||||||||||||
Value any | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
// Dimension is a typed definition of a datasource dimension. | ||||||||||||||||
type Dimension struct { | ||||||||||||||||
|
@@ -136,27 +146,41 @@ type Dimension struct { | |||||||||||||||
// SpatialDimensionSet is a unique set of druid datasource spatial dimensions. | ||||||||||||||||
type SpatialDimensionSet []SpatialDimension | ||||||||||||||||
|
||||||||||||||||
// DimensionExclusionsSet represents set of excluded dimensions. | ||||||||||||||||
type DimensionExclusionsSet []string | ||||||||||||||||
|
||||||||||||||||
// DimensionsSpec is responsible for configuring Druid's dimensions. They're a | ||||||||||||||||
// set of columns in Druid's data model that can be used for grouping, filtering | ||||||||||||||||
// or applying aggregations. | ||||||||||||||||
// https://druid.apache.org/docs/latest/ingestion/ingestion-spec#dimensionsspec | ||||||||||||||||
type DimensionsSpec struct { | ||||||||||||||||
Dimensions DimensionSet `json:"dimensions,omitempty"` | ||||||||||||||||
DimansionExclusions DimensionSet `json:"dimansionExclusions,omitempty"` | ||||||||||||||||
SpatialDimensions SpatialDimensionSet `json:"spatialDimensions,omitempty"` | ||||||||||||||||
IncludeAllDimensions bool `json:"includeAllDimensions,omitempty"` | ||||||||||||||||
UseSchemaDiscovery bool `json:"useSchemaDiscovery,omitempty"` | ||||||||||||||||
Dimensions DimensionSet `json:"dimensions,omitempty"` | ||||||||||||||||
DimensionExclusions DimensionExclusionsSet `json:"dimensionExclusions,omitempty"` | ||||||||||||||||
SpatialDimensions SpatialDimensionSet `json:"spatialDimensions,omitempty"` | ||||||||||||||||
IncludeAllDimensions bool `json:"includeAllDimensions,omitempty"` | ||||||||||||||||
UseSchemaDiscovery bool `json:"useSchemaDiscovery,omitempty"` | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
// QueryGranularitySpec is an umbrella type for different representations of query granularity, can be string or | ||||||||||||||||
// QueryGranularity value. | ||||||||||||||||
type QueryGranularitySpec struct { | ||||||||||||||||
Value any | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
// QueryGranularity is a typed representation of query granularity. | ||||||||||||||||
type QueryGranularity struct { | ||||||||||||||||
Type string `json:"type,omitempty"` | ||||||||||||||||
} | ||||||||||||||||
Comment on lines
+171
to
173
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
And add a comment please. |
||||||||||||||||
|
||||||||||||||||
// GranularitySpec allows for configuring operations such as data segment | ||||||||||||||||
// partitioning, truncating timestamps, time chunk segmentation or roll-up. | ||||||||||||||||
// https://druid.apache.org/docs/latest/ingestion/ingestion-spec#granularityspec | ||||||||||||||||
type GranularitySpec struct { | ||||||||||||||||
Type string `json:"type"` | ||||||||||||||||
SegmentGranularity string `json:"segmentGranularity,omitempty"` | ||||||||||||||||
QueryGranularity string `json:"queryGranularity,omitempty"` | ||||||||||||||||
Rollup bool `json:"rollup,omitempty"` | ||||||||||||||||
Intervals []string `json:"intervals,omitempty"` | ||||||||||||||||
Type string `json:"type"` | ||||||||||||||||
SegmentGranularity string `json:"segmentGranularity,omitempty"` | ||||||||||||||||
QueryGranularity *QueryGranularitySpec `json:"queryGranularity,omitempty"` | ||||||||||||||||
Rollup bool `json:"rollup,omitempty"` | ||||||||||||||||
Intervals []string `json:"intervals,omitempty"` | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
// AutoScalerConfig is part of IOConfig that controls ingestion auto-scaling. | ||||||||||||||||
|
@@ -177,7 +201,7 @@ type AutoScalerConfig struct { | |||||||||||||||
MinTriggerScaleActionFrequencyMillis int `json:"minTriggerScaleActionFrequencyMillis"` | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
// Defines if and when stream Supervisor can become idle. | ||||||||||||||||
// IdleConfig defines if and when stream Supervisor can become idle. | ||||||||||||||||
vzayts marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||
type IdleConfig struct { | ||||||||||||||||
Enabled bool `json:"enabled"` | ||||||||||||||||
InactiveAfterMillis int64 `json:"inactiveAfterMillis"` | ||||||||||||||||
|
@@ -356,6 +380,7 @@ type SupervisorStatusPayload struct { | |||||||||||||||
Partitions int `json:"partitions"` | ||||||||||||||||
Replicas int `json:"replicas"` | ||||||||||||||||
DurationSeconds int `json:"durationSeconds"` | ||||||||||||||||
Suspended bool `json:"suspended"` | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
// SupervisorStatus is a response object containing status of a supervisor alongside | ||||||||||||||||
|
@@ -400,7 +425,7 @@ func defaultKafkaIngestionSpec() *InputIngestionSpec { | |||||||||||||||
GranularitySpec: &GranularitySpec{ | ||||||||||||||||
Type: "uniform", | ||||||||||||||||
SegmentGranularity: "DAY", | ||||||||||||||||
QueryGranularity: "none", | ||||||||||||||||
QueryGranularity: &QueryGranularitySpec{"none"}, | ||||||||||||||||
Rollup: false, | ||||||||||||||||
}, | ||||||||||||||||
}, | ||||||||||||||||
|
@@ -535,7 +560,7 @@ func SetTimestampColumn(column string) IngestionSpecOptions { | |||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
// SetGranularitySpec sets granularity spec settings that are applied at druid ingestion partitioning stage. | ||||||||||||||||
func SetGranularitySpec(segmentGranularity, queryGranularity string, rollup bool) IngestionSpecOptions { | ||||||||||||||||
func SetGranularitySpec(segmentGranularity string, queryGranularity *QueryGranularitySpec, rollup bool) IngestionSpecOptions { | ||||||||||||||||
return func(spec *InputIngestionSpec) { | ||||||||||||||||
spec.DataSchema.GranularitySpec = &GranularitySpec{ | ||||||||||||||||
Type: "uniform", | ||||||||||||||||
|
@@ -563,3 +588,41 @@ func SetSQLInputSource(dbType, connectURI, user, password string, sqls []string) | |||||||||||||||
} | ||||||||||||||||
} | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
func (g *QueryGranularitySpec) UnmarshalJSON(b []byte) error { | ||||||||||||||||
var str string | ||||||||||||||||
if err := json.Unmarshal(b, &str); err == nil { | ||||||||||||||||
g.Value = str | ||||||||||||||||
return nil | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
var qg QueryGranularity | ||||||||||||||||
if err := json.Unmarshal(b, &qg); err == nil { | ||||||||||||||||
g.Value = qg | ||||||||||||||||
return nil | ||||||||||||||||
} | ||||||||||||||||
return fmt.Errorf("unsupported query granularity: %s", b) | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
func (g *QueryGranularitySpec) MarshalJSON() ([]byte, error) { | ||||||||||||||||
return json.Marshal(&g.Value) | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
func (g *DimensionSpec) UnmarshalJSON(b []byte) error { | ||||||||||||||||
var str string | ||||||||||||||||
if err := json.Unmarshal(b, &str); err == nil { | ||||||||||||||||
g.Value = str | ||||||||||||||||
return nil | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
var qg Dimension | ||||||||||||||||
if err := json.Unmarshal(b, &qg); err == nil { | ||||||||||||||||
g.Value = qg | ||||||||||||||||
return nil | ||||||||||||||||
} | ||||||||||||||||
return fmt.Errorf("unsupported dimension value: %s", b) | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
func (g *DimensionSpec) MarshalJSON() ([]byte, error) { | ||||||||||||||||
return json.Marshal(&g.Value) | ||||||||||||||||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: please consider using
http.MethodGet