Skip to content

Commit

Permalink
Merge pull request #425 from kmgowda/kmg-logger-103
Browse files Browse the repository at this point in the history
Add the option "-out" for logger options

Signed-off-by: Keshava Munegowda <keshava.gowda@gmail.com>
  • Loading branch information
kmgowda authored Sep 28, 2023
2 parents ed39dba + 39d9037 commit 6fc4736
Show file tree
Hide file tree
Showing 47 changed files with 545 additions and 299 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ task SbkYal(type: CreateStartScripts) {
}

task SbkGem(type: CreateStartScripts) {
mainClass = 'io.sbk.main.SbkGemMain'
mainClass = 'io.gem.main.SbkGemMain'
applicationName = 'sbk-gem'
defaultJvmOpts = ['-Dsbk.applicationName=' + rootProject.name, '-Dsbk.appHome=SBK_APP_HOME', '-Dsbk.jmxExport=false']
outputDir = startScripts.outputDir
Expand Down Expand Up @@ -468,7 +468,7 @@ task SbkGem(type: CreateStartScripts) {
}

task SbkGemYal(type: CreateStartScripts) {
mainClass = 'io.sbk.main.SbkGemYalMain'
mainClass = 'io.gem.main.SbkGemYalMain'
applicationName = 'sbk-gem-yal'
defaultJvmOpts = ['-Dsbk.applicationName=' + rootProject.name, '-Dsbk.appHome=SBK_APP_HOME', '-Dsbk.jmxExport=false']
outputDir = startScripts.outputDir
Expand Down
1 change: 1 addition & 0 deletions checkstyle/import-control.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<allow pkg="io.sbp"/>
<allow pkg="io.sbk"/>
<allow pkg="io.sbm"/>
<allow pkg="io.gem"/>
<allow pkg="io.pravega"/>
<allow pkg="lombok"/>
<allow pkg="ch.qos.logback"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ public class BookKeeperTest {
*/
private final static String CONFIGFILE = "BookKeeper.properties";
final String[] drivers = {"BookKeeper"};
final String[] loggers = {};
final String benchmarkName = Config.NAME + " -class bookkeeper";
private InputParameterOptions params;
private BookKeeper bk;

@Test
public void addArgsTest() {
params = new SbkDriversParameters(benchmarkName, drivers);
params = new SbkDriversParameters(benchmarkName, drivers, loggers);
bk = new BookKeeper();
bk.addArgs(params);

Expand All @@ -42,7 +43,7 @@ public void addArgsTest() {
*/
@Test
public void parseArgs() {
params = new SbkDriversParameters(benchmarkName, drivers);
params = new SbkDriversParameters(benchmarkName, drivers, loggers);
bk = new BookKeeper();
bk.addArgs(params);
Exception exception = null;
Expand All @@ -58,7 +59,7 @@ public void parseArgs() {
@Test(expected = IllegalArgumentException.class)
public void testParseArgsNullLogName() {
final String[] args = {"-class", "bookkeeper", "-uri", "distributedlog://localhost:2181/streams", "-writers", "1", "-size", "100"};
params = new SbkDriversParameters(benchmarkName, drivers);
params = new SbkDriversParameters(benchmarkName, drivers, loggers);
bk = new BookKeeper();
bk.addArgs(params);
try {
Expand All @@ -73,7 +74,7 @@ public void testParseArgsNullLogName() {
@Test(expected = IllegalArgumentException.class)
public void testParseArgsNullUri() {
final String[] args = {"-class", "bookkeeper", "-log", "logName", "writers", "1", "size", "100"};
params = new SbkDriversParameters(benchmarkName, drivers);
params = new SbkDriversParameters(benchmarkName, drivers, loggers);
bk = new BookKeeper();
bk.addArgs(params);
try {
Expand Down
25 changes: 13 additions & 12 deletions drivers/file/src/test/java/io/sbk/driver/File/FileTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@
*/
public class FileTest {
final String[] drivers = {"File"};
final String[] loggers = {};
final String benchmarkName = Config.NAME + " -class file";
private File file;
private InputParameterOptions params;

@Test
public void testParseArgs() {
final String[] args = {"-class", "file", "-size", "100", "-writers", "1", "records", "1"};
params = new SbkDriversParameters(benchmarkName, drivers);
params = new SbkDriversParameters(benchmarkName, drivers, loggers);
file = new File();
file.addArgs(params);
try {
Expand All @@ -53,7 +54,7 @@ public void testParseArgs() {
@Test(expected = IllegalArgumentException.class)
public void testParseArgsWritersCount() {
final String[] args = {"-class", "file", "-size", "100", "-writers", "2", "records", "1"};
params = new SbkDriversParameters(benchmarkName, drivers);
params = new SbkDriversParameters(benchmarkName, drivers, loggers);
file = new File();
file.addArgs(params);
try {
Expand All @@ -68,7 +69,7 @@ public void testParseArgsWritersCount() {
@Test(expected = IllegalArgumentException.class)
public void testParseArgsReadersWritersCount() {
final String[] args = {"-class", "file", "-size", "100", "-readers", "1", "-writers", "1", "records", "1"};
params = new SbkDriversParameters(benchmarkName, drivers);
params = new SbkDriversParameters(benchmarkName, drivers, loggers);
file = new File();
file.addArgs(params);
try {
Expand All @@ -83,7 +84,7 @@ public void testParseArgsReadersWritersCount() {
@Test
public void testOpenAndCloseStorage() {
final String[] args = {"-class", "file", "-size", "100", "-writers", "1", "records", "1"};
params = new SbkDriversParameters(benchmarkName, drivers);
params = new SbkDriversParameters(benchmarkName, drivers, loggers);
file = new File();
file.addArgs(params);
try {
Expand Down Expand Up @@ -112,7 +113,7 @@ public void testGetDataType() {
@Test
public void testCreateWriter() {
final String[] args = {"-class", "file", "-file", "test.txt", "-size", "100", "-writers", "1", "records", "1"};
params = new SbkDriversParameters(benchmarkName, drivers);
params = new SbkDriversParameters(benchmarkName, drivers, loggers);
file = new File();
file.addArgs(params);
try {
Expand All @@ -134,7 +135,7 @@ public void testCreateWriter() {
public void testCreateReader() {
final String[] writeArgs = {"-class", "file", "-file", "test.txt", "-size", "100", "-writers", "1", "records", "1"};
final String[] readArgs = {"-class", "file", "-file", "test.txt", "-size", "100", "-readers", "1", "records", "1"};
params = new SbkDriversParameters(benchmarkName, drivers);
params = new SbkDriversParameters(benchmarkName, drivers, loggers);
file = new File();
file.addArgs(params);
try {
Expand All @@ -150,7 +151,7 @@ public void testCreateReader() {
ex.printStackTrace();
Assert.fail("CreateWriter failed!");
}
params = new SbkDriversParameters(benchmarkName, drivers);
params = new SbkDriversParameters(benchmarkName, drivers, loggers);
file = new File();
file.getDataType();
file.addArgs(params);
Expand All @@ -173,7 +174,7 @@ public void testCreateReader() {
public void testCreateReaderFileNotFound() {
final String[] args = {"-class", "file", "-file", "NoFile.sbk", "-size", "100", "-readers", "1", "records", "1"};
Exception retEx = null;
params = new SbkDriversParameters(benchmarkName, drivers);
params = new SbkDriversParameters(benchmarkName, drivers, loggers);
file = new File();
file.getDataType();
file.addArgs(params);
Expand Down Expand Up @@ -205,7 +206,7 @@ public void testWriterReaderData() {
ByteBuffer readBuffer = null;
String readData = null;

params = new SbkDriversParameters(benchmarkName, drivers);
params = new SbkDriversParameters(benchmarkName, drivers, loggers);
file = new File();
file.addArgs(params);
try {
Expand Down Expand Up @@ -241,7 +242,7 @@ public void testWriterReaderData() {
ex.printStackTrace();
Assert.fail("Writer Failed");
}
params = new SbkDriversParameters(benchmarkName, drivers);
params = new SbkDriversParameters(benchmarkName, drivers, loggers);
file = new File();
file.getDataType();
file.addArgs(params);
Expand Down Expand Up @@ -295,7 +296,7 @@ public void testReaderEOF() {
ByteBuffer readBuffer = null;
String readData = null;

params = new SbkDriversParameters(benchmarkName, drivers);
params = new SbkDriversParameters(benchmarkName, drivers, loggers);
file = new File();
file.addArgs(params);
try {
Expand Down Expand Up @@ -331,7 +332,7 @@ public void testReaderEOF() {
ex.printStackTrace();
Assert.fail("Writer Failed");
}
params = new SbkDriversParameters(benchmarkName, drivers);
params = new SbkDriversParameters(benchmarkName, drivers, loggers);
file = new File();
file.getDataType();
file.addArgs(params);
Expand Down
16 changes: 11 additions & 5 deletions sbk-api/src/main/java/io/sbk/api/Package.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
Expand All @@ -32,20 +33,25 @@ public abstract class Package<T> {
final private StringCompareIgnoreCase stringComparator;

public Package(String packageName) {
final Set<Class<? extends T>> subTypes = getClasses(packageName);
final int size = subTypes.size();
final Map<String, Class<? extends T>> classMap = new HashMap<>();
getClasses(packageName).forEach(x -> {
//Exclude the Abstract classes & interfaces
int mod = x.getModifiers();
if (!Modifier.isAbstract(mod) && !Modifier.isInterface(mod)) {
classMap.put(x.getSimpleName(), x);
}
});
final int size = classMap.size();
this.packageName = packageName;
this.stringComparator = new StringCompareIgnoreCase();
this.simpleNames = new String[size];
this.names = new String[size];
if (size > 0) {
final AtomicInteger index = new AtomicInteger(0);
final Map<String, String> classMap = new HashMap<>();
subTypes.forEach(x -> classMap.put(x.getSimpleName(), x.getName()));
classMap.keySet().stream().sorted(String::compareToIgnoreCase).forEach(x -> {
final int i = index.get();
simpleNames[i] = StringUtils.capitalize(x);
names[i] = classMap.get(x);
names[i] = classMap.get(x).getName();
index.incrementAndGet();
});
}
Expand Down
Loading

0 comments on commit 6fc4736

Please sign in to comment.