mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2024-12-01 04:49:18 -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);
|
builder.withCompression(ProtocolOptions.Compression.NONE);
|
||||||
|
|
||||||
Optional<String> usernameOpt = activityDef.getParams().getOptionalString("username");
|
Optional<String> usernameOpt = activityDef.getParams().getOptionalString("username");
|
||||||
|
Optional<String> userfileOpt = activityDef.getParams().getOptionalString("userfile");
|
||||||
Optional<String> passwordOpt = activityDef.getParams().getOptionalString("password");
|
Optional<String> passwordOpt = activityDef.getParams().getOptionalString("password");
|
||||||
Optional<String> passfileOpt = activityDef.getParams().getOptionalString("passfile");
|
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;
|
String password;
|
||||||
if (passwordOpt.isPresent()) {
|
if (passwordOpt.isPresent()) {
|
||||||
password = passwordOpt.get();
|
password = passwordOpt.get();
|
||||||
@ -332,6 +338,14 @@ public class CQLSessionCache implements Shutdownable {
|
|||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String readfile(String path) {
|
||||||
|
try {
|
||||||
|
return Files.readAllLines(Path.of(path)).get(0);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
for (Session session : sessionCache.values()) {
|
for (Session session : sessionCache.values()) {
|
||||||
|
@ -106,11 +106,16 @@ public class CQLSessionCache implements Shutdownable {
|
|||||||
builder.withCompression(ProtocolOptions.Compression.NONE);
|
builder.withCompression(ProtocolOptions.Compression.NONE);
|
||||||
|
|
||||||
Optional<String> usernameOpt = activityDef.getParams().getOptionalString("username");
|
Optional<String> usernameOpt = activityDef.getParams().getOptionalString("username");
|
||||||
|
Optional<String> userfileOpt = activityDef.getParams().getOptionalString("userfile");
|
||||||
Optional<String> passwordOpt = activityDef.getParams().getOptionalString("password");
|
Optional<String> passwordOpt = activityDef.getParams().getOptionalString("password");
|
||||||
Optional<String> passfileOpt = activityDef.getParams().getOptionalString("passfile");
|
Optional<String> passfileOpt = activityDef.getParams().getOptionalString("passfile");
|
||||||
|
|
||||||
if (usernameOpt.isPresent()) {
|
if (usernameOpt.isPresent() || userfileOpt.isPresent()) {
|
||||||
String username = usernameOpt.get();
|
String username = usernameOpt.orElse(null);
|
||||||
|
if (userfileOpt.isPresent()) {
|
||||||
|
username = readfile(userfileOpt.get());
|
||||||
|
}
|
||||||
|
|
||||||
String password;
|
String password;
|
||||||
if (passwordOpt.isPresent()) {
|
if (passwordOpt.isPresent()) {
|
||||||
password = passwordOpt.get();
|
password = passwordOpt.get();
|
||||||
@ -326,6 +331,14 @@ public class CQLSessionCache implements Shutdownable {
|
|||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String readfile(String path) {
|
||||||
|
try {
|
||||||
|
return Files.readAllLines(Path.of(path)).get(0);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
for (Session session : sessionCache.values()) {
|
for (Session session : sessionCache.values()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user