This repository has been archived by the owner on Oct 17, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c75cf3b
commit 872e871
Showing
3 changed files
with
178 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Copyright (c) 2018 Uber Technologies, Inc. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
package metadata | ||
|
||
import ( | ||
"github.com/m3db/m3metrics/aggregation" | ||
"github.com/m3db/m3metrics/op/applied" | ||
"github.com/m3db/m3metrics/policy" | ||
) | ||
|
||
// Metadata represents the metadata associated with a metric. | ||
type Metadata struct { | ||
// List of aggregation types. | ||
AggregationID aggregation.ID | ||
|
||
// List of storage policies. | ||
StoragePolicies []policy.StoragePolicy | ||
|
||
// Pipeline of operations that may be applied to the metric. | ||
Pipeline applied.Pipeline | ||
} | ||
|
||
// IsDefault returns whether this is the default metadata. | ||
func (m Metadata) IsDefault() bool { | ||
return m.AggregationID.IsDefault() && | ||
policy.IsDefaultStoragePolicies(m.StoragePolicies) && | ||
m.Pipeline.IsEmpty() | ||
} | ||
|
||
// ForwardMetadata represents the metadata information associated with forwarded metrics. | ||
type ForwardMetadata struct { | ||
// List of aggregation types. | ||
AggregationID aggregation.ID | ||
|
||
// Storage policy. | ||
StoragePolicy policy.StoragePolicy | ||
|
||
// Pipeline of operations that may be applied to the metric. | ||
Pipeline applied.Pipeline | ||
} | ||
|
||
// StagedMetadata represents metadata with a staged cutover time. | ||
type StagedMetadata struct { | ||
Metadata | ||
|
||
// Cutover is when the metadata is applicable. | ||
CutoverNanos int64 | ||
|
||
// Tombstoned determines whether the associated metric has been tombstoned. | ||
Tombstoned bool | ||
} | ||
|
||
// StagedMetadatas contains a list of staged metadatas. | ||
type StagedMetadatas []StagedMetadatas | ||
|
||
// IsDefault determines whether the list of staged metadata is a default list. | ||
func (sms StagedMetadatas) IsDefault() bool { | ||
return len(sms) == 1 && sms[0].IsDefault() | ||
} |
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,95 @@ | ||
// Copyright (c) 2018 Uber Technologies, Inc. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
package applied | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
|
||
"github.com/m3db/m3metrics/aggregation" | ||
"github.com/m3db/m3metrics/op" | ||
) | ||
|
||
// Rollup captures the rollup metadata after the operation is applied against a metric ID. | ||
type Rollup struct { | ||
// Metric ID generated as a result of the rollup. | ||
ID []byte | ||
// Type of aggregation performed within each unique dimension combination. | ||
AggregationType aggregation.Type | ||
} | ||
|
||
func (op Rollup) String() string { | ||
var b bytes.Buffer | ||
b.WriteString("{") | ||
fmt.Fprintf(&b, "id: %s, ", op.ID) | ||
fmt.Fprintf(&b, "aggregation: %v", op.AggregationType) | ||
b.WriteString("}") | ||
return b.String() | ||
} | ||
|
||
// Union is a union of different types of operation. | ||
type Union struct { | ||
Type op.Type | ||
Aggregation op.Aggregation | ||
Transformation op.Transformation | ||
Rollup Rollup | ||
} | ||
|
||
func (u Union) String() string { | ||
var b bytes.Buffer | ||
b.WriteString("{") | ||
switch u.Type { | ||
case op.AggregationType: | ||
fmt.Fprintf(&b, "aggregation: %s", u.Aggregation.String()) | ||
case op.TransformationType: | ||
fmt.Fprintf(&b, "transformation: %s", u.Transformation.String()) | ||
case op.RollupType: | ||
fmt.Fprintf(&b, "rollup: %s", u.Rollup.String()) | ||
default: | ||
fmt.Fprintf(&b, "unknown op type: %v", u.Type) | ||
} | ||
b.WriteString("}") | ||
return b.String() | ||
} | ||
|
||
// Pipeline is a pipeline of operations. | ||
type Pipeline struct { | ||
// a list of pipeline operations. | ||
Operations []Union | ||
} | ||
|
||
// IsEmpty determines whether a pipeline is empty. | ||
func (p Pipeline) IsEmpty() bool { | ||
return len(p.Operations) == 0 | ||
} | ||
|
||
func (p Pipeline) String() string { | ||
var b bytes.Buffer | ||
b.WriteString("{operations: [") | ||
for i, op := range p.Operations { | ||
b.WriteString(op.String()) | ||
if i < len(p.Operations)-1 { | ||
b.WriteString(", ") | ||
} | ||
} | ||
b.WriteString("]}") | ||
return b.String() | ||
} |
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