use of com.icodici.universa.node2.Config in project neo4j by neo4j.
the class BoltCausalClusteringIT method shouldPickANewServerToWriteToOnLeaderSwitch.
@Test
public void shouldPickANewServerToWriteToOnLeaderSwitch() throws Throwable {
// given
cluster = clusterRule.withNumberOfReadReplicas(0).startCluster();
CoreClusterMember leader = cluster.awaitLeader();
LeaderSwitcher leaderSwitcher = new LeaderSwitcher(cluster);
Config config = Config.build().withLogging(new JULogging(Level.OFF)).toConfig();
Set<BoltServerAddress> seenAddresses = new HashSet<>();
try (Driver driver = GraphDatabase.driver(leader.routingURI(), AuthTokens.basic("neo4j", "neo4j"), config)) {
boolean success = false;
long deadline = System.currentTimeMillis() + (30 * 1000);
while (!success) {
if (System.currentTimeMillis() > deadline) {
fail("Failed to write to the new leader in time. Addresses seen: " + seenAddresses);
}
try (Session session = driver.session(AccessMode.WRITE)) {
BoltServerAddress boltServerAddress = ((RoutingNetworkSession) session).address();
session.run("CREATE (p:Person)");
seenAddresses.add(boltServerAddress);
success = seenAddresses.size() >= 2;
} catch (Exception e) {
Thread.sleep(100);
}
/*
* Having the latch release here ensures that we've done at least one pass through the loop, which means
* we've completed a connection before the forced master switch.
*/
if (seenAddresses.size() >= 1) {
leaderSwitcher.start();
}
}
} finally {
leaderSwitcher.stop();
assertTrue(leaderSwitcher.hadLeaderSwitch());
assertThat(seenAddresses.size(), greaterThanOrEqualTo(2));
}
}
use of com.icodici.universa.node2.Config in project jdk8u_jdk by JetBrains.
the class EType method initStatic.
public static void initStatic() {
boolean allowed = false;
try {
Config cfg = Config.getInstance();
String temp = cfg.get("libdefaults", "allow_weak_crypto");
if (temp != null && temp.equals("true"))
allowed = true;
} catch (Exception exc) {
if (DEBUG) {
System.out.println("Exception in getting allow_weak_crypto, " + "using default value " + exc.getMessage());
}
}
allowWeakCrypto = allowed;
}
use of com.icodici.universa.node2.Config in project jdk8u_jdk by JetBrains.
the class ParseConfig method main.
public static void main(String[] args) throws Exception {
System.setProperty("java.security.krb5.conf", System.getProperty("test.src", ".") + "/krb5.conf");
Config config = Config.getInstance();
config.listTable();
String sample = "kdc.example.com kdc2.example.com";
for (int i = 0; i < 4; i++) {
String expected = config.getAll("realms", "EXAMPLE_" + i + ".COM", "kdc");
if (!sample.equals(expected)) {
throw new Exception("krb5.conf: unexpected kdc value \"" + expected + "\"");
}
}
// JDK-8055045: IOOBE when reading an empty value
config.get("empty1", "NOVAL.COM");
config.get("empty2", "NOVAL.COM");
config.get("quote1", "NOVAL.COM");
config.get("quote2", "NOVAL.COM");
}
use of com.icodici.universa.node2.Config in project jdk8u_jdk by JetBrains.
the class DNS method main.
public static void main(String[] args) throws Exception {
System.setProperty("java.security.krb5.conf", System.getProperty("test.src", ".") + "/no-such-file.conf");
Config config = Config.getInstance();
try {
String r = config.getDefaultRealm();
throw new Exception("What? There is a default realm " + r + "?");
} catch (KrbException ke) {
ke.printStackTrace();
if (ke.getCause() != null) {
throw new Exception("There should be no cause. Won't try DNS");
}
}
String kdcs = config.getKDCList("X");
if (!kdcs.equals("a.com.:88 b.com.:99") && !kdcs.equals("a.com. b.com.:99")) {
throw new Exception("Strange KDC: [" + kdcs + "]");
}
;
}
use of com.icodici.universa.node2.Config in project jdk8u_jdk by JetBrains.
the class SCDynamicConfigTest method main.
public static void main(String[] args) throws Exception {
// Reconstruct a typical SCDynamicConfig.getKerberosConfig() output
Hashtable<String, Object> conf = new Hashtable<>();
Hashtable<String, Object> libdefaults = new Hashtable<>();
libdefaults.put("default_realm", "REALM.COM");
conf.put("libdefaults", libdefaults);
Hashtable<String, Object> realms = new Hashtable<>();
Hashtable<String, Object> thisRealm = new Hashtable<>();
realms.put("REALM.COM", thisRealm);
thisRealm.put("kpasswd", hosts());
thisRealm.put("kadmin", hosts());
thisRealm.put("kdc", hosts());
conf.put("realms", realms);
Hashtable<String, Object> domain_realm = new Hashtable<>();
domain_realm.put(".realm.com", "REALM.COM");
domain_realm.put("realm.com", "REALM.COM");
conf.put("domain_realm", domain_realm);
System.out.println("SCDynamicConfig:\n");
System.out.println(conf);
// Simulate SCDynamicConfig.getConfig() output
Method m = SCDynamicStoreConfig.class.getDeclaredMethod("convertNativeConfig", Hashtable.class);
m.setAccessible(true);
conf = (Hashtable) m.invoke(null, conf);
System.out.println("\nkrb5.conf:\n");
System.out.println(conf);
// Feed it into a Config object
System.setProperty("java.security.krb5.conf", "not-a-file");
Config cf = Config.getInstance();
Field f = Config.class.getDeclaredField("stanzaTable");
f.setAccessible(true);
f.set(cf, conf);
System.out.println("\nConfig:\n");
System.out.println(cf);
if (!cf.getDefaultRealm().equals("REALM.COM")) {
throw new Exception();
}
if (!cf.getKDCList("REALM.COM").equals("127.0.0.1 127.0.0.2")) {
throw new Exception();
}
if (!cf.get("domain_realm", ".realm.com").equals("REALM.COM")) {
throw new Exception();
}
}
Aggregations