Created
August 26, 2019 15:13
-
-
Save davidfauth/d3b17b2044a3a7654852c439bf07c20b to your computer and use it in GitHub Desktop.
Neo4jDriverWrite_40Cluster
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
import java.net.URI; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.Random; | |
import java.util.logging.Level; | |
import static java.util.concurrent.TimeUnit.SECONDS; | |
import java.time.Duration; | |
import java.time.Instant; | |
import org.neo4j.driver.internal.logging.ConsoleLogging; | |
import org.neo4j.driver.AuthToken; | |
import org.neo4j.driver.AuthTokens; | |
import org.neo4j.driver.Config; | |
import org.neo4j.driver.Driver; | |
import org.neo4j.driver.GraphDatabase; | |
import org.neo4j.driver.Record; | |
import org.neo4j.driver.Session; | |
import org.neo4j.driver.StatementResult; | |
import org.neo4j.driver.Transaction; | |
import org.neo4j.driver.exceptions.ServiceUnavailableException; | |
import org.neo4j.driver.*; | |
import org.reactivestreams.*; | |
import static org.neo4j.driver.SessionConfig.builder; | |
import static org.neo4j.driver.Values.parameters; | |
public class Neo4jDriverTest2 { | |
static Config config = Config.builder() | |
.withMaxTransactionRetryTime( 15, SECONDS ) | |
.build(); | |
public static void main(String[] argv) throws Exception { | |
System.out.println("-------- Neo4j Bolt Connection Testing ------"); | |
Transaction transaction; | |
List<String> uris = new ArrayList<String>(); | |
uris.add("bolt+routing://localhost:7687"); | |
uris.add("bolt+routing://localhost:7697"); | |
uris.add("bolt+routing://localhost:7607"); | |
Driver driver = null; | |
int i=0; | |
for (i =0; i<1; i++){ | |
int j = 100; | |
// driver = acquireDriver(uris,AuthTokens.basic( "neo4j", "password" ),config ); | |
driver = GraphDatabase.driver( "neo4j://18.222.122.180:7687", AuthTokens.basic( "neo4j", "password" ),config ); | |
Instant start = Instant.now(); | |
try (Session session = driver.session( builder().withDatabase( "redhorse" ).withDefaultAccessMode( AccessMode.WRITE ).build() ) ) | |
{ | |
for (i =0; i<10; i++){ | |
transaction = session.beginTransaction(); | |
transaction.run("unwind range(1,25000) as id merge (p:Person{id:id}) ON CREATE SET p.name = 'Joe', p.age=53"); | |
transaction.success(); | |
transaction.close(); | |
//transaction.run("CREATE (a:Person {name: $name})", parameters( "name", "smith" ) ); | |
} | |
} | |
Instant end = Instant.now(); | |
Duration timeElapsed = Duration.between(start, end); | |
System.out.println("Time taken: "+ timeElapsed.toMillis() +" milliseconds"); | |
} | |
driver.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment