use of org.apache.bookkeeper.stats.StatsLogger in project pulsar by yahoo.
the class LocalBookkeeperEnsemble method runBookies.
private void runBookies(ServerConfiguration baseConf) throws Exception {
LOG.info("Starting Bookie(s)");
// Create Bookie Servers (B1, B2, B3)
bs = new BookieServer[numberOfBookies];
bsConfs = new ServerConfiguration[numberOfBookies];
statsProviders = new StatsProvider[numberOfBookies];
for (int i = 0; i < numberOfBookies; i++) {
File bkDataDir = isNotBlank(bkDataDirName) ? Files.createDirectories(Paths.get(bkDataDirName + Integer.toString(i))).toFile() : Files.createTempDirectory("bk" + Integer.toString(i) + "test").toFile();
if (this.clearOldData) {
cleanDirectory(bkDataDir);
}
bsConfs[i] = new ServerConfiguration(baseConf);
// override settings
bsConfs[i].setBookiePort(initialPort + i);
bsConfs[i].setZkServers("127.0.0.1:" + ZooKeeperDefaultPort);
bsConfs[i].setJournalDirName(bkDataDir.getPath());
bsConfs[i].setLedgerDirNames(new String[] { bkDataDir.getPath() });
bsConfs[i].setAllowLoopback(true);
bsConfs[i].setGcWaitTime(60000);
String statsFilePath = FileSystems.getDefault().getPath(bkDataDir.getAbsolutePath(), "bookie-stats.json").toString();
// Initialize Stats Provider
statsProviders[i] = new DataSketchesMetricsProvider();
bsConfs[i].setProperty("dataSketchesMetricsJsonFileReporter", statsFilePath);
statsProviders[i].start(bsConfs[i]);
StatsLogger statsLogger = statsProviders[i].getStatsLogger("");
bs[i] = new BookieServer(bsConfs[i], statsLogger);
bs[i].start();
LOG.debug("Local BK[{}] started (port: {}, data_directory: {})", i, initialPort + i, bkDataDir.getAbsolutePath());
}
}
use of org.apache.bookkeeper.stats.StatsLogger in project distributedlog by twitter.
the class AbstractFeatureProvider method getFeatureProvider.
public static FeatureProvider getFeatureProvider(String rootScope, DistributedLogConfiguration conf, StatsLogger statsLogger) throws IOException {
Class<? extends FeatureProvider> featureProviderClass;
try {
featureProviderClass = conf.getFeatureProviderClass();
} catch (ConfigurationException e) {
throw new IOException("Can't initialize the feature provider : ", e);
}
// create feature provider
Constructor<? extends FeatureProvider> constructor;
try {
constructor = featureProviderClass.getDeclaredConstructor(String.class, DistributedLogConfiguration.class, StatsLogger.class);
} catch (NoSuchMethodException e) {
throw new IOException("No constructor found for feature provider class " + featureProviderClass + " : ", e);
}
try {
return constructor.newInstance(rootScope, conf, statsLogger);
} catch (InstantiationException e) {
throw new IOException("Failed to instantiate feature provider : ", e);
} catch (IllegalAccessException e) {
throw new IOException("Encountered illegal access when instantiating feature provider : ", e);
} catch (InvocationTargetException e) {
Throwable targetException = e.getTargetException();
if (targetException instanceof IOException) {
throw (IOException) targetException;
} else {
throw new IOException("Encountered invocation target exception while instantiating feature provider : ", e);
}
}
}
use of org.apache.bookkeeper.stats.StatsLogger in project distributedlog by twitter.
the class StreamBenchmark method run.
protected void run(String[] args) throws Exception {
logger.info("Parsing arguments for benchmark : {}", args);
// parse command line
parseCommandLine(args);
statsProvider.start(conf);
// run the benchmark
StatsLogger statsLogger = statsProvider.getStatsLogger("dl");
DistributedLogNamespace namespace = DistributedLogNamespaceBuilder.newBuilder().conf(conf).uri(uri).statsLogger(statsLogger).build();
try {
benchmark(namespace, streamName, statsProvider.getStatsLogger("benchmark"));
} finally {
namespace.close();
statsProvider.stop();
}
}
use of org.apache.bookkeeper.stats.StatsLogger in project distributedlog by twitter.
the class TestStatsFilter method testServiceSuccess.
@Test(timeout = 60000)
public void testServiceSuccess() throws Exception {
StatsLogger stats = new NullStatsLogger();
StatsFilter<String, String> filter = new StatsFilter<String, String>(stats);
Future<String> result = filter.apply("", new ConstantService<String, String>(Future.value("result")));
assertEquals("result", Await.result(result));
}
use of org.apache.bookkeeper.stats.StatsLogger in project distributedlog by twitter.
the class TestStatsFilter method testServiceFailure.
@Test(timeout = 60000)
public void testServiceFailure() throws Exception {
StatsLogger stats = new NullStatsLogger();
StatsFilter<String, String> filter = new StatsFilter<String, String>(stats);
try {
filter.apply("", new RuntimeExService<String, String>());
} catch (RuntimeException ex) {
}
}
Aggregations