mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2024-11-28 19:44:02 -06:00
add userfile support to cql and cqld3 drivers
This commit is contained in:
parent
639a1173bf
commit
46c19ff41c
@ -104,11 +104,17 @@ public class CQLSessionCache implements Shutdownable {
|
||||
builder.withCompression(ProtocolOptions.Compression.NONE);
|
||||
|
||||
Optional<String> usernameOpt = activityDef.getParams().getOptionalString("username");
|
||||
Optional<String> userfileOpt = activityDef.getParams().getOptionalString("userfile");
|
||||
Optional<String> passwordOpt = activityDef.getParams().getOptionalString("password");
|
||||
Optional<String> passfileOpt = activityDef.getParams().getOptionalString("passfile");
|
||||
|
||||
if (usernameOpt.isPresent()) {
|
||||
String username = usernameOpt.get();
|
||||
|
||||
if (usernameOpt.isPresent() || userfileOpt.isPresent()) {
|
||||
String username = usernameOpt.orElse(null);
|
||||
if (userfileOpt.isPresent()) {
|
||||
username = readfile(userfileOpt.get());
|
||||
}
|
||||
|
||||
String password;
|
||||
if (passwordOpt.isPresent()) {
|
||||
password = passwordOpt.get();
|
||||
@ -332,6 +338,14 @@ public class CQLSessionCache implements Shutdownable {
|
||||
return session;
|
||||
}
|
||||
|
||||
private String readfile(String path) {
|
||||
try {
|
||||
return Files.readAllLines(Path.of(path)).get(0);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
for (Session session : sessionCache.values()) {
|
||||
|
@ -106,11 +106,16 @@ public class CQLSessionCache implements Shutdownable {
|
||||
builder.withCompression(ProtocolOptions.Compression.NONE);
|
||||
|
||||
Optional<String> usernameOpt = activityDef.getParams().getOptionalString("username");
|
||||
Optional<String> userfileOpt = activityDef.getParams().getOptionalString("userfile");
|
||||
Optional<String> passwordOpt = activityDef.getParams().getOptionalString("password");
|
||||
Optional<String> passfileOpt = activityDef.getParams().getOptionalString("passfile");
|
||||
|
||||
if (usernameOpt.isPresent()) {
|
||||
String username = usernameOpt.get();
|
||||
if (usernameOpt.isPresent() || userfileOpt.isPresent()) {
|
||||
String username = usernameOpt.orElse(null);
|
||||
if (userfileOpt.isPresent()) {
|
||||
username = readfile(userfileOpt.get());
|
||||
}
|
||||
|
||||
String password;
|
||||
if (passwordOpt.isPresent()) {
|
||||
password = passwordOpt.get();
|
||||
@ -326,6 +331,14 @@ public class CQLSessionCache implements Shutdownable {
|
||||
return session;
|
||||
}
|
||||
|
||||
private String readfile(String path) {
|
||||
try {
|
||||
return Files.readAllLines(Path.of(path)).get(0);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
for (Session session : sessionCache.values()) {
|
||||
|
Loading…
Reference in New Issue
Block a user