Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed Neo4jClient to read login parameters from a file #1

Closed
wants to merge 12 commits into from
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# ignore the db.properties file
/neo4j/src/main/java/com/yahoo/ycsb/db/db.properties

# ignore compiled byte code
target

Expand Down
26 changes: 19 additions & 7 deletions neo4j/src/main/java/com/yahoo/ycsb/db/Neo4jClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.util.concurrent.TimeUnit;

import java.io.File;

import java.io.*;
import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
Expand All @@ -36,13 +36,13 @@

public class Neo4jClient extends DB {
private static final String URL_PROPERTY = "neo4j.url";
private static final String URL_PROPERTY_DEFAULT = "bolt://localhost:7687";
private static String URL_PROPERTY_DEFAULT = "";

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let this be as is, because that would be the default value.

private static final String USER_PROPERTY = "neo4j.user";
private static final String USER_PROPERTY_DEFAULT = "neo4j";
private static final String USER_PROPERTY = "neo4j.user";
private static String USER_PROPERTY_DEFAULT = "";

private static final String PASSWORD_PROPERTY = "neo4j.password";
private static final String PASSWORD_PROPERTY_DEFAULT = "1234";
private static final String PASSWORD_PROPERTY = "neo4j.password";
private static String PASSWORD_PROPERTY_DEFAULT = "";
/**
* Initialize any state for this DB. Called once per DB instance; there is one DB instance per client thread.
*/
Expand All @@ -63,11 +63,23 @@ private static enum RelTypes implements RelationshipType {
public void init() throws DBException {
// initialize Neo4j driver
synchronized(Neo4jClient.class) {
try{
FileReader reader=new FileReader("./neo4j/src/main/java/com/yahoo/ycsb/db/db.properties");
Properties externProps = new Properties();
externProps.load(reader);
URL_PROPERTY_DEFAULT = externProps.getProperty("URL_PROPERTY_DEFAULT");
USER_PROPERTY_DEFAULT = externProps.getProperty("USER_PROPERTY_DEFAULT");
PASSWORD_PROPERTY_DEFAULT = externProps.getProperty("PASSWORD_PROPERTY_DEFAULT");

}
catch(Exception e){
e.printStackTrace();
}

final Properties props = getProperties();
String url = props.getProperty(URL_PROPERTY, URL_PROPERTY_DEFAULT);
String user = props.getProperty(USER_PROPERTY, USER_PROPERTY_DEFAULT);
String password = props.getProperty(PASSWORD_PROPERTY, PASSWORD_PROPERTY_DEFAULT);

if (driver == null) {
System.out.println("Making connection");

Expand Down
4 changes: 2 additions & 2 deletions workloads/workloada
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
# Default data size: 1 KB records (10 fields, 100 bytes each, plus key)
# Request distribution: zipfian

recordcount=1000
operationcount=1000
recordcount=5
operationcount=5
workload=com.yahoo.ycsb.workloads.CoreWorkload

readallfields=true
Expand Down