forked from qubole/rubix
-
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.
new:dev:Choose Dropwizard Metrics as Metrics Collection Framework (qu…
…bole#120) We have wanted to standardize on Dropwizard Metrics for monitoring and the basis of alerting. Rubix depends on Hadoop jars and these bring in their own ecosystem of dependencies and their versions. Therefore we couldn't add Dropwizard Metrics because it may conflict with another version in the classpath. We considered multiple options: * An interface (qubole#99) * Shade the jar * Reuse a version in the class path by using provided scope. This commit has chosen the last option and has been tested with Presto & Hive.
- Loading branch information
1 parent
f478880
commit 5bc1d88
Showing
11 changed files
with
138 additions
and
7 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
74 changes: 74 additions & 0 deletions
74
rubix-bookkeeper/src/test/java/com/qubole/rubix/bookkeeper/TestBookKeeperMetrics.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,74 @@ | ||
/** | ||
* Copyright (c) 2016. Qubole Inc | ||
* 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. See accompanying LICENSE file. | ||
*/ | ||
package com.qubole.rubix.bookkeeper; | ||
|
||
import com.codahale.metrics.MetricRegistry; | ||
import com.qubole.rubix.spi.CacheConfig; | ||
import com.qubole.rubix.spi.ClusterType; | ||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.thrift.shaded.TException; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Test; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
|
||
import static org.testng.Assert.assertEquals; | ||
|
||
public class TestBookKeeperMetrics | ||
{ | ||
private static final int BLOCK_SIZE = 100; | ||
|
||
private final MetricRegistry metrics = new MetricRegistry(); | ||
private final Configuration conf = new Configuration(); | ||
|
||
private BookKeeper bookKeeper; | ||
|
||
@BeforeClass | ||
public void setUp() throws IOException | ||
{ | ||
// Set configuration values for testing | ||
CacheConfig.setCacheDataDirPrefix(conf, "/tmp/media/ephemeral"); | ||
CacheConfig.setMaxDisks(conf, 5); | ||
CacheConfig.setBlockSize(conf, BLOCK_SIZE); | ||
|
||
// Create cache directories | ||
Files.createDirectories(Paths.get(CacheConfig.getCacheDirPrefixList(conf))); | ||
for (int i = 0; i < CacheConfig.getCacheMaxDisks(conf); i++) { | ||
Files.createDirectories(Paths.get(CacheConfig.getCacheDirPrefixList(conf) + i)); | ||
} | ||
|
||
bookKeeper = new BookKeeper(conf, metrics); | ||
} | ||
|
||
/** | ||
* Verify that the metric representing total block hits is correctly registered & incremented. | ||
* | ||
* @throws TException when file metadata cannot be fetched or refreshed. | ||
*/ | ||
@Test | ||
public void verifyBlockHitsMetricIsReported() throws TException | ||
{ | ||
final String remotePath = "/tmp/testPath"; | ||
final long lastModified = 1514764800; // 2018-01-01T00:00:00 | ||
final long fileLength = 5000; | ||
final long startBlock = 20; | ||
final long endBlock = 23; | ||
final long totalRequests = endBlock - startBlock; | ||
|
||
assertEquals(metrics.getCounters().get(BookKeeper.METRIC_BOOKKEEPER_LOCAL_CACHE_COUNT).getCount(), 0); | ||
bookKeeper.getCacheStatus(remotePath, fileLength, lastModified, startBlock, endBlock, ClusterType.TEST_CLUSTER_MANAGER.ordinal()); | ||
assertEquals(metrics.getCounters().get(BookKeeper.METRIC_BOOKKEEPER_LOCAL_CACHE_COUNT).getCount(), totalRequests); | ||
} | ||
} |
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
Empty file.
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