-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from scribe/implementation
Implementation
- Loading branch information
Showing
14 changed files
with
328 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
assertj=3.11.1 | ||
clikt=1.7.0 | ||
kotlinGuiced=0.0.5 | ||
kotlinLogging=1.6.24 | ||
kotlinxCoroutines=1.1.1 | ||
ds3=5.0.4 | ||
mockk=1.9.3.kotlin12 | ||
kotlintest=3.3.2 |
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
23 changes: 23 additions & 0 deletions
23
src/main/kotlin/com/spectralogic/bp/bench/cli/AzInputStream.kt
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,23 @@ | ||
/* | ||
* **************************************************************************** | ||
* Copyright 2014-2019 Spectra Logic Corporation. All Rights Reserved. | ||
* *************************************************************************** | ||
*/ | ||
|
||
package com.spectralogic.bp.bench.cli | ||
|
||
import java.io.InputStream | ||
|
||
class AZInputStream : InputStream() { | ||
private var currentCharacter = 'a' | ||
|
||
override fun read(): Int { | ||
val charToReturn = currentCharacter | ||
|
||
currentCharacter = currentCharacter.inc() | ||
if (currentCharacter == '{') { | ||
currentCharacter = 'a' | ||
} | ||
return charToReturn.toInt() | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/main/kotlin/com/spectralogic/bp/bench/cli/BpCommand.kt
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 @@ | ||
/* | ||
* **************************************************************************** | ||
* Copyright 2014-2019 Spectra Logic Corporation. All Rights Reserved. | ||
* *************************************************************************** | ||
*/ | ||
|
||
package com.spectralogic.bp.bench.cli | ||
|
||
import com.github.ajalt.clikt.core.CliktCommand | ||
import com.github.ajalt.clikt.parameters.options.option | ||
import com.github.ajalt.clikt.parameters.options.prompt | ||
import com.github.ajalt.clikt.parameters.options.validate | ||
|
||
abstract class BpCommand( | ||
help: String = "", | ||
epilog: String = "", | ||
name: String? = null, | ||
invokeWithoutSubcommand: Boolean = false, | ||
printHelpOnEmptyArgs: Boolean = false | ||
) : CliktCommand(help, epilog, name, invokeWithoutSubcommand, printHelpOnEmptyArgs) { | ||
internal val endpoint by option( | ||
"-bp", | ||
"--blackpearl", | ||
envvar = "BP_DATA_ENDPOINT", | ||
help = "The data path on the Black Pearl.\nSet with BP_DATA_ENDPOINT" | ||
).prompt("Black Pearl data path").validate { require(it.isNotEmpty()) { "Black Pearl data path cannot be empty" } } | ||
internal val clientId: String by option( | ||
"-a", | ||
"--accessid", | ||
envvar = "BP_ACCESS_ID", | ||
help = "The access ID of the user you want to transfer as\nSet with BP_ACCESS_ID" | ||
).prompt("Black Pearl access id?").validate { require(it.isNotEmpty()) { "User name cannot be empty" } } | ||
internal val secretKey: String by option( | ||
"-s", | ||
"--secretkey", | ||
envvar = "BP_SECRET_KEY", | ||
help = "The secret key of the user you want to transfer as\nSet with BP_SECRET_KEY" | ||
).prompt("Black Pearl secret key?").validate { require(it.isNotEmpty()) { "Password cannot be empty" } } | ||
internal val bucket: String by option( | ||
"-b", | ||
"--bucket", | ||
envvar = "BP_BUCKET", | ||
help = "The bucket to use for benchmarking.\nSet with BP_BUCKET" | ||
).prompt("Target Black Pearl bucket").validate { require(it.isNotEmpty()) { "Bucket name cannot be empty" } } | ||
} |
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
62 changes: 62 additions & 0 deletions
62
src/main/kotlin/com/spectralogic/bp/bench/cli/PositionableReadOnlySeekableByteChannel.kt
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,62 @@ | ||
/* | ||
* **************************************************************************** | ||
* Copyright 2014-2019 Spectra Logic Corporation. All Rights Reserved. | ||
* *************************************************************************** | ||
*/ | ||
|
||
package com.spectralogic.bp.bench.cli | ||
|
||
import java.nio.ByteBuffer | ||
import java.nio.channels.ReadableByteChannel | ||
import java.nio.channels.SeekableByteChannel | ||
|
||
/** | ||
* Wraps a non-seekable ReadableByteChannel in order to satisfy the SeekableByteChannel interface. | ||
* Despite position being tracked, setting the position does not actually perform a seek. | ||
* This is used in FileSourceImpl to implement the AToZInputStream test tool. | ||
*/ | ||
class PositionableReadOnlySeekableByteChannel(private val channel: ReadableByteChannel) : SeekableByteChannel { | ||
|
||
private var size = 0L | ||
private var position = 0L | ||
|
||
override fun read(dst: ByteBuffer): Int { | ||
val bytesRead = channel.read(dst) | ||
size += bytesRead.toLong() | ||
position += bytesRead.toLong() | ||
return bytesRead | ||
} | ||
|
||
override fun write(src: ByteBuffer): Int { | ||
val l = src.remaining() | ||
size += l | ||
position += l | ||
src.position(src.position() + l) | ||
return l | ||
} | ||
|
||
override fun position(): Long { | ||
return position | ||
} | ||
|
||
override fun position(newPosition: Long): SeekableByteChannel { | ||
this.position = newPosition | ||
return this | ||
} | ||
|
||
override fun size(): Long { | ||
return size | ||
} | ||
|
||
override fun truncate(size: Long): SeekableByteChannel { | ||
return this | ||
} | ||
|
||
override fun isOpen(): Boolean { | ||
return channel.isOpen | ||
} | ||
|
||
override fun close() { | ||
channel.close() | ||
} | ||
} |
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
Oops, something went wrong.