Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static OffPeakHours getInstance(Configuration conf) {

/**
* @param startHour inclusive
* @param endHour exclusive
* @param endHour inclusive
*/
public static OffPeakHours getInstance(int startHour, int endHour) {
if (startHour == -1 && endHour == -1) {
Expand Down Expand Up @@ -84,7 +84,7 @@ private static class OffPeakHoursImpl extends OffPeakHours {

/**
* @param startHour inclusive
* @param endHour exclusive
* @param endHour inclusive
*/
OffPeakHoursImpl(int startHour, int endHour) {
this.startHour = startHour;
Expand All @@ -99,7 +99,7 @@ public boolean isOffPeakHour() {
@Override
public boolean isOffPeakHour(int targetHour) {
if (startHour <= endHour) {
return startHour <= targetHour && targetHour < endHour;
return startHour <= targetHour && targetHour <= endHour;
}
return targetHour < endHour || startHour <= targetHour;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public static void setUpClass() {
private int hourPlusOne;
private int hourMinusOne;
private int hourMinusTwo;
private int hourAllDayStart;
private int hourAllDayEnd;
private Configuration conf;

@Before
Expand All @@ -57,6 +59,8 @@ public void setUp() {
hourPlusOne = ((hourOfDay + 1) % 24);
hourMinusOne = ((hourOfDay - 1 + 24) % 24);
hourMinusTwo = ((hourOfDay - 2 + 24) % 24);
hourAllDayStart = 0;
hourAllDayEnd = 23;
conf = testUtil.getConfiguration();
}

Expand All @@ -82,4 +86,14 @@ public void testSetPeakHourOutsideCurrentSelection() {
OffPeakHours target = OffPeakHours.getInstance(conf);
assertFalse(target.isOffPeakHour(hourOfDay));
}

@Test
public void testSetPeakHourAllDay() {
conf.setLong(CompactionConfiguration.HBASE_HSTORE_OFFPEAK_START_HOUR, hourAllDayStart);
conf.setLong(CompactionConfiguration.HBASE_HSTORE_OFFPEAK_END_HOUR, hourAllDayEnd);
OffPeakHours target = OffPeakHours.getInstance(conf);
assertTrue(target.isOffPeakHour(hourAllDayStart));
assertTrue(target.isOffPeakHour(hourOfDay));
assertTrue(target.isOffPeakHour(hourAllDayEnd));
}
}