diff --git a/driver-artemis/src/main/java/io/sbk/Artemis/ArtemisCallbackReader.java b/driver-artemis/src/main/java/io/sbk/Artemis/ArtemisCallbackReader.java index 51a1e1317..886aab469 100644 --- a/driver-artemis/src/main/java/io/sbk/Artemis/ArtemisCallbackReader.java +++ b/driver-artemis/src/main/java/io/sbk/Artemis/ArtemisCallbackReader.java @@ -12,6 +12,7 @@ import io.sbk.api.CallbackReader; import io.sbk.api.Parameters; import io.sbk.api.Callback; +import io.sbk.api.impl.SbkLogger; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException; import org.apache.activemq.artemis.api.core.RoutingType; @@ -56,7 +57,7 @@ public void start(Callback callback) throws IOException { try { message.acknowledge(); } catch (ActiveMQException e) { - System.out.println("ArtemisCallbackReader : Message acknowledge failed"); + SbkLogger.log.error("ArtemisCallbackReader : Message acknowledge failed"); } }); } catch (ActiveMQException ex) { diff --git a/driver-natsStream/src/main/java/io/sbk/NatsStream/NatsStreamWriter.java b/driver-natsStream/src/main/java/io/sbk/NatsStream/NatsStreamWriter.java index 41b52633e..19c76cde4 100644 --- a/driver-natsStream/src/main/java/io/sbk/NatsStream/NatsStreamWriter.java +++ b/driver-natsStream/src/main/java/io/sbk/NatsStream/NatsStreamWriter.java @@ -19,6 +19,7 @@ import io.nats.streaming.AckHandler; import io.nats.streaming.NatsStreaming; import io.nats.streaming.StreamingConnection; +import io.sbk.api.impl.SbkLogger; /** * Class for NATS Stream Writer. @@ -44,7 +45,7 @@ public long recordWrite(byte[] data, int size, RecordTime record, int id) { final String[] guid = new String[1]; final AckHandler acb = (s, e) -> { if ((e != null) || !guid[0].equals(s)) { - System.out.println("NAT Streaming Writer failed !"); + SbkLogger.log.error("NAT Streaming Writer failed !"); } else { final long endTime = System.currentTimeMillis(); record.accept(id, time, endTime, size, 1); diff --git a/driver-pravega/src/main/java/io/sbk/Pravega/PravegaStreamHandler.java b/driver-pravega/src/main/java/io/sbk/Pravega/PravegaStreamHandler.java index 0e9c23d38..a365dc81c 100644 --- a/driver-pravega/src/main/java/io/sbk/Pravega/PravegaStreamHandler.java +++ b/driver-pravega/src/main/java/io/sbk/Pravega/PravegaStreamHandler.java @@ -34,6 +34,7 @@ import io.pravega.client.stream.impl.StreamImpl; import io.pravega.client.ClientConfig; import io.pravega.client.stream.Stream; +import io.sbk.api.impl.SbkLogger; /** * Class for Pravega stream and segments. @@ -77,13 +78,13 @@ public boolean create() { public void scale() throws InterruptedException, ExecutionException, TimeoutException { StreamSegments segments = controller.getCurrentSegments(scope, stream).join(); final int nseg = segments.getSegments().size(); - System.out.println("Current segments of the stream: " + stream + " = " + nseg); + SbkLogger.log.info("Current segments of the stream: " + stream + " = " + nseg); if (nseg == segCount) { return; } - System.out.println("The stream: " + stream + " will be manually scaling to " + segCount + " segments"); + SbkLogger.log.info("The stream: " + stream + " will be manually scaling to " + segCount + " segments"); /* * Note that the Upgrade stream API does not change the number of segments; @@ -115,13 +116,13 @@ public void scale() throws InterruptedException, ExecutionException, TimeoutExce throw new TimeoutException("ERROR : Scale operation on stream " + stream + " did not complete"); } - System.out.println("Number of Segments after manual scale: " + + SbkLogger.log.info("Number of Segments after manual scale: " + controller.getCurrentSegments(scope, stream) .get().getSegments().size()); } public void recreate() throws InterruptedException, ExecutionException, TimeoutException { - System.out.println("Sealing and Deleteing the stream : " + stream + " and then recreating the same"); + SbkLogger.log.info("Sealing and Deleteing the stream : " + stream + " and then recreating the same"); CompletableFuture sealStatus = controller.sealStream(scope, stream); if (!sealStatus.get(timeout, TimeUnit.SECONDS)) { throw new TimeoutException("ERROR : Segment sealing operation on stream " + stream + " did not complete"); @@ -156,7 +157,7 @@ public void deleteReaderGroup() { try { readerGroupManager.deleteReaderGroup(rdGrpName); } catch (RuntimeException e) { - System.out.println("Cannot delete reader group " + rdGrpName + " because it is already deleted"); + SbkLogger.log.error("Cannot delete reader group " + rdGrpName + " because it is already deleted"); } } } diff --git a/sbk-api/src/main/java/io/sbk/api/Config.java b/sbk-api/src/main/java/io/sbk/api/Config.java index 83473a505..9716c096b 100644 --- a/sbk-api/src/main/java/io/sbk/api/Config.java +++ b/sbk-api/src/main/java/io/sbk/api/Config.java @@ -11,6 +11,9 @@ package io.sbk.api; public class Config { + final public static String NAME = "sbk"; + final public static String DESC = "Storage Benchmark Kit"; + final public static int NS_PER_MICRO = 1000; final public static int MICROS_PER_MS = 1000; final public static int MS_PER_SEC = 1000; @@ -23,8 +26,6 @@ public class Config { final public static int DEFAULT_WINDOW_LATENCY = MS_PER_MIN; final public static int DEFAULT_MAX_LATENCY = MS_PER_MIN * 15; - public String name; - public String description; public String packageName; public boolean fork; public int reportingMS; diff --git a/sbk-api/src/main/java/io/sbk/api/Parameters.java b/sbk-api/src/main/java/io/sbk/api/Parameters.java index a52b07085..4391afd25 100644 --- a/sbk-api/src/main/java/io/sbk/api/Parameters.java +++ b/sbk-api/src/main/java/io/sbk/api/Parameters.java @@ -141,11 +141,6 @@ public interface Parameters { */ void printHelp(); - /** - * Print the -version output. - */ - void printVersion(); - /** * Parse the command line arguments. * @param args list of command line arguments. diff --git a/sbk-api/src/main/java/io/sbk/api/impl/SbkLogger.java b/sbk-api/src/main/java/io/sbk/api/impl/SbkLogger.java new file mode 100644 index 000000000..193803b07 --- /dev/null +++ b/sbk-api/src/main/java/io/sbk/api/impl/SbkLogger.java @@ -0,0 +1,18 @@ +/** + * Copyright (c) KMG. All Rights Reserved. + * + * 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 + */ +package io.sbk.api.impl; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +final public class SbkLogger { + final private static String LOGGER_NAME = "SBK"; + final public static Logger log = LoggerFactory.getLogger(LOGGER_NAME); +} diff --git a/sbk-api/src/main/java/io/sbk/api/impl/SbkParameters.java b/sbk-api/src/main/java/io/sbk/api/impl/SbkParameters.java index 9fada51b9..2c62db79e 100644 --- a/sbk-api/src/main/java/io/sbk/api/impl/SbkParameters.java +++ b/sbk-api/src/main/java/io/sbk/api/impl/SbkParameters.java @@ -29,7 +29,6 @@ final public class SbkParameters implements Parameters { final private String benchmarkName; final private String className; final private String desc; - final private String version; final private Options options; final private HelpFormatter formatter; final private CommandLineParser parser; @@ -65,14 +64,13 @@ final public class SbkParameters implements Parameters { private double throughput; private CommandLine commandline; - public SbkParameters(String name, String desc, String version, String className, List driversList, long startTime) { + public SbkParameters(String name, String desc, String className, List driversList, long startTime) { this.options = new Options(); this.formatter = new HelpFormatter(); this.parser = new DefaultParser(); this.benchmarkName = name; this.desc = desc; this.className = className; - this.version = version; this.timeout = TIMEOUT; this.driversList = driversList; this.startTime = startTime; @@ -94,7 +92,6 @@ public SbkParameters(String name, String desc, String version, String className, "if 0 , writes 'records'\n" + "if -1, get the maximum throughput"); options.addOption("help", false, "Help message"); - options.addOption("version", false, "Version"); } @Override @@ -116,12 +113,6 @@ public void printHelp() { } } - @Override - public void printVersion() { - System.out.println(desc + ", " + benchmarkName +" version: " + version); - } - - @Override public boolean hasOption(String name) { if (commandline != null) { @@ -156,11 +147,6 @@ public void parseArgs(String[] args) throws ParseException, IllegalArgumentExcep printHelp(); return; } - if (commandline.hasOption("version")) { - printVersion(); - return; - } - writersCount = Integer.parseInt(commandline.getOptionValue("writers", "0")); readersCount = Integer.parseInt(commandline.getOptionValue("readers", "0")); diff --git a/sbk-api/src/main/java/io/sbk/main/SbkMain.java b/sbk-api/src/main/java/io/sbk/main/SbkMain.java index ae4320f84..264bb955b 100644 --- a/sbk-api/src/main/java/io/sbk/main/SbkMain.java +++ b/sbk-api/src/main/java/io/sbk/main/SbkMain.java @@ -17,6 +17,7 @@ import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.Metrics; import io.micrometer.core.instrument.composite.CompositeMeterRegistry; +import io.micrometer.core.instrument.util.IOUtils; import io.micrometer.jmx.JmxConfig; import io.micrometer.jmx.JmxMeterRegistry; import io.sbk.api.Benchmark; @@ -28,6 +29,7 @@ import io.sbk.api.impl.MetricImpl; import io.sbk.api.impl.MetricsLogger; import io.sbk.api.impl.SbkBenchmark; +import io.sbk.api.impl.SbkLogger; import io.sbk.api.impl.SbkParameters; import io.sbk.api.impl.SystemResultLogger; import org.apache.commons.cli.CommandLine; @@ -48,6 +50,7 @@ */ public class SbkMain { final static String CONFIGFILE = "sbk.properties"; + final static String BANNERFILE = "banner.txt"; public static void main(final String[] args) { long startTime = System.currentTimeMillis(); @@ -63,6 +66,9 @@ public static void main(final String[] args) { Config config = null; CompletableFuture ret = null; + SbkLogger.log.info(IOUtils.toString(SbkMain.class.getClassLoader().getResourceAsStream(BANNERFILE))); + SbkLogger.log.info(Config.NAME.toUpperCase() +" version: "+version); + final ObjectMapper mapper = new ObjectMapper(new JavaPropsFactory()) .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); @@ -74,19 +80,6 @@ public static void main(final String[] args) { System.exit(0); } - try { - commandline = new DefaultParser().parse(new Options() - .addOption("version", false, "Version"), - args, true); - } catch (ParseException ex) { - ex.printStackTrace(); - System.exit(0); - } - if (commandline.hasOption("version")) { - System.out.println(config.description + ", " + config.name + " version: " + version); - System.exit(0); - } - try { commandline = new DefaultParser().parse(new Options() .addOption("class", true, "Benchmark Class"), @@ -99,14 +92,14 @@ public static void main(final String[] args) { driversList = getClassNames(config.packageName); className = commandline.getOptionValue("class", null); if (className == null) { - Parameters paramsHelp = new SbkParameters(config.name, config.description, version, "", driversList, startTime); + Parameters paramsHelp = new SbkParameters(config.NAME, config.DESC, "", driversList, startTime); metric.addArgs(paramsHelp); paramsHelp.printHelp(); System.exit(0); } final String name = searchDriver(driversList, className); if (name == null) { - System.out.printf("storage driver : %s not found in the SBK, run with -help to see the supported drivers\n", className); + SbkLogger.log.error("storage driver: " + className+ " not found in the SBK, run with -help to see the supported drivers"); System.exit(0); } try { @@ -118,10 +111,10 @@ public static void main(final String[] args) { final Storage storage = obj; if (storage == null) { - System.out.println("Failure to create Benchmark object"); + SbkLogger.log.error("Failure to create Benchmark object"); System.exit(0); } - params = new SbkParameters(config.name, config.description, version, name, driversList, startTime); + params = new SbkParameters(config.NAME, config.DESC, name, driversList, startTime); storage.addArgs(params); metric.addArgs(params); try { @@ -131,9 +124,6 @@ public static void main(final String[] args) { params.printHelp(); System.exit(0); } - if (params.hasOption("version")) { - System.exit(0); - } if (params.hasOption("help")) { System.exit(0); } @@ -160,7 +150,7 @@ public static void main(final String[] args) { metricsLogger = logger; } else { final CompositeMeterRegistry compositeLogger = Metrics.globalRegistry; - final String prefix = config.name.toUpperCase() + "_" + name + "_" + action + "_"; + final String prefix = config.NAME.toUpperCase() + "_" + name + "_" + action + "_"; compositeLogger.add(new JmxMeterRegistry(JmxConfig.DEFAULT, Clock.SYSTEM)); compositeLogger.add(metricRegistry); metricsLogger = new MetricsLogger( diff --git a/sbk-api/src/main/resources/banner.txt b/sbk-api/src/main/resources/banner.txt new file mode 100644 index 000000000..ca8a6acce --- /dev/null +++ b/sbk-api/src/main/resources/banner.txt @@ -0,0 +1,7 @@ + + _____ ____ _ __ + / ____| | _ \ | | / / + | (___ | |_) | | |/ / + \___ \ | _ < | < + ____) | | |_) | | |\ \ + |_____/ |____/ |_| \_\ diff --git a/sbk-api/src/main/resources/sbk.properties b/sbk-api/src/main/resources/sbk.properties index 95e637a72..3d6c40832 100644 --- a/sbk-api/src/main/resources/sbk.properties +++ b/sbk-api/src/main/resources/sbk.properties @@ -6,12 +6,6 @@ # # http://www.apache.org/licenses/LICENSE-2.0 -# Name of the Framework -name=sbk - -# Description -description=Storage Benchmark Kit - # Package Name to fetch the storage drivers packageName=io.sbk