-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add predownload functionality to Pinot
- Loading branch information
1 parent
90b437f
commit f23ae1a
Showing
18 changed files
with
1,957 additions
and
4 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
11 changes: 11 additions & 0 deletions
11
pinot-tools/src/main/java/org/apache/pinot/tools/predownload/PredownloadException.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,11 @@ | ||
package org.apache.pinot.tools.predownload; | ||
|
||
public class PredownloadException extends RuntimeException { | ||
public PredownloadException(String message) { | ||
super(message); | ||
} | ||
|
||
public PredownloadException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
pinot-tools/src/main/java/org/apache/pinot/tools/predownload/PredownloadMetrics.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,45 @@ | ||
package org.apache.pinot.tools.predownload; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
import org.apache.pinot.common.metrics.ServerGauge; | ||
import org.apache.pinot.common.metrics.ServerMeter; | ||
import org.apache.pinot.common.metrics.ServerMetrics; | ||
import org.apache.pinot.common.metrics.ServerTimer; | ||
|
||
|
||
public class PredownloadMetrics { | ||
private static final String INSTANCE_ID_TAG = "instance_id"; | ||
private static final String SEGMENT_ID_TAG = "segment_id"; | ||
private static final long BYTES_TO_MB = 1024 * 1024; | ||
|
||
private final ServerMetrics _serverMetrics; | ||
|
||
public PredownloadMetrics() { | ||
_serverMetrics = ServerMetrics.get(); | ||
} | ||
|
||
public void segmentDownloaded(boolean succeed, String segmentName, long segmentSizeBytes, long downloadTimeMs) { | ||
if (succeed) { | ||
_serverMetrics.addMeteredGlobalValue(ServerMeter.SEGMENT_DOWNLOAD_COUNT, 1); | ||
// Report download speed in MB/s, avoid divide by 0 | ||
_serverMetrics.setValueOfGlobalGauge(ServerGauge.SEGMENT_DOWNLOAD_SPEED, | ||
(segmentSizeBytes / BYTES_TO_MB) / (downloadTimeMs / 1000 + 1)); | ||
} else { | ||
_serverMetrics.addMeteredGlobalValue(ServerMeter.SEGMENT_DOWNLOAD_FAILURE_COUNT, 1); | ||
} | ||
} | ||
|
||
public void preDownloadSucceed(long totalSegmentSizeBytes, long totalDownloadTimeMs) { | ||
_serverMetrics.setValueOfGlobalGauge(ServerGauge.PREDOWNLOAD_SPEED, | ||
(totalSegmentSizeBytes / BYTES_TO_MB) / (totalDownloadTimeMs / 1000 + 1)); | ||
_serverMetrics.addTimedValue(ServerTimer.PREDOWNLOAD_TIME, totalDownloadTimeMs, TimeUnit.MILLISECONDS); | ||
} | ||
|
||
public void preDownloadComplete(PredownloadCompleteReason reason) { | ||
if (reason.isSucceed()) { | ||
_serverMetrics.addMeteredGlobalValue(ServerMeter.PREDOWNLOAD_SUCCEED, 1); | ||
} else { | ||
_serverMetrics.addMeteredGlobalValue(ServerMeter.PREDOWNLOAD_FAILED, 1); | ||
} | ||
} | ||
} |
Oops, something went wrong.