forked from pinpoint-apm/pinpoint
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pinpoint-apm#10944] Improve RangeValidator
- Loading branch information
Showing
30 changed files
with
284 additions
and
170 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
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
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
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
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
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
52 changes: 52 additions & 0 deletions
52
...main/java/com/navercorp/pinpoint/common/server/util/time/RangeValidatorConfiguration.java
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,52 @@ | ||
package com.navercorp.pinpoint.common.server.util.time; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Primary; | ||
|
||
import java.time.Duration; | ||
|
||
@Configuration | ||
public class RangeValidatorConfiguration { | ||
|
||
@Bean | ||
@Primary | ||
public RangeValidator rangeValidator2d() { | ||
return new ForwardRangeValidator(Duration.ofDays(2)); | ||
} | ||
|
||
@Bean | ||
public RangeValidator rangeValidator7d() { | ||
return new ForwardRangeValidator(Duration.ofDays(7)); | ||
} | ||
|
||
@Bean | ||
public RangeValidator rangeValidator14d() { | ||
return new ForwardRangeValidator(Duration.ofDays(14)); | ||
} | ||
|
||
@Bean | ||
public RangeValidator rangeValidator30d() { | ||
return new ForwardRangeValidator(Duration.ofDays(30)); | ||
} | ||
|
||
@Bean | ||
public RangeValidator reverseRangeValidator2d() { | ||
return new ReverseRangeValidator(Duration.ofDays(2)); | ||
} | ||
|
||
@Bean | ||
public RangeValidator reverseRangeValidator7d() { | ||
return new ReverseRangeValidator(Duration.ofDays(7)); | ||
} | ||
|
||
@Bean | ||
public RangeValidator reverseRangeValidator14d() { | ||
return new ReverseRangeValidator(Duration.ofDays(14)); | ||
} | ||
|
||
@Bean | ||
public RangeValidator reverseRangeValidator30d() { | ||
return new ReverseRangeValidator(Duration.ofDays(30)); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...r/src/main/java/com/navercorp/pinpoint/common/server/util/time/ReverseRangeValidator.java
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,43 @@ | ||
/* | ||
* Copyright 2014 NAVER Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.navercorp.pinpoint.common.server.util.time; | ||
|
||
import java.time.Duration; | ||
import java.time.Instant; | ||
|
||
/** | ||
* @author emeroad | ||
*/ | ||
public class ReverseRangeValidator implements RangeValidator { | ||
|
||
private final RangeValidator validator; | ||
|
||
public ReverseRangeValidator(Duration limitDay) { | ||
this.validator = new ForwardRangeValidator(limitDay); | ||
} | ||
|
||
@Override | ||
public void validate(Instant from, Instant to) { | ||
validator.validate(to, from); | ||
} | ||
|
||
@Override | ||
public void validate(Range range) { | ||
// Range already inverted | ||
validator.validate(range.getToInstant(), range.getFromInstant()); | ||
} | ||
} |
Oops, something went wrong.