use of com.sleepycat.je.EnvironmentConfig in project OpenRefine by OpenRefine.
the class RefineBrokerImpl method init.
@Override
public void init(ServletConfig config) throws Exception {
logger.trace("> init");
super.init(config);
timer = new Timer();
expirer = new Expirer();
timer.schedule(expirer, 0, LOCK_EXPIRATION_CHECK_DELAY);
String dataDir = config.getInitParameter("refine.data");
if (dataDir == null)
dataDir = "data";
File dataPath = new File(dataDir);
if (!dataPath.exists())
dataPath.mkdirs();
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setAllowCreate(true);
envConfig.setTransactional(true);
env = new Environment(dataPath, envConfig);
StoreConfig storeConfig = new StoreConfig();
storeConfig.setAllowCreate(true);
storeConfig.setTransactional(true);
projectStore = new EntityStore(env, "ProjectsStore", storeConfig);
lockStore = new EntityStore(env, "LockStore", storeConfig);
projectById = projectStore.getPrimaryIndex(String.class, Project.class);
lockById = lockStore.getPrimaryIndex(String.class, Lock.class);
locksByProject = lockStore.getSecondaryIndex(lockById, String.class, "pid");
logger.trace("< init");
}
use of com.sleepycat.je.EnvironmentConfig in project qpid-broker-j by apache.
the class BDBHAVirtualHostNodeRestTest method testIntruderProtection.
public void testIntruderProtection() throws Exception {
createHANode(NODE1, _node1HaPort, _node1HaPort);
assertNode(NODE1, _node1HaPort, _node1HaPort, NODE1);
Map<String, Object> nodeData = getRestTestHelper().getJsonAsMap(_baseNodeRestUrl + NODE1);
String node1StorePath = (String) nodeData.get(BDBHAVirtualHostNode.STORE_PATH);
long transactionId = ((Number) nodeData.get(BDBHAVirtualHostNode.LAST_KNOWN_REPLICATION_TRANSACTION_ID)).longValue();
// add permitted node
Map<String, Object> node3Data = createNodeAttributeMap(NODE3, _node3HaPort, _node1HaPort);
getRestTestHelper().submitRequest(_baseNodeRestUrl + NODE3, "PUT", node3Data, HttpServletResponse.SC_CREATED);
assertNode(NODE3, _node3HaPort, _node1HaPort, NODE1);
assertRemoteNodes(NODE1, NODE3);
// Ensure PINGDB is created
// in order to exclude hanging of environment
// when environment.close is called whilst PINGDB is created.
// On node joining, a record is updated in PINGDB
// if lastTransactionId is incremented then node ping task was executed
int counter = 0;
long newTransactionId = transactionId;
while (newTransactionId == transactionId && counter < 50) {
nodeData = getRestTestHelper().getJsonAsMap(_baseNodeRestUrl + NODE1);
newTransactionId = ((Number) nodeData.get(BDBHAVirtualHostNode.LAST_KNOWN_REPLICATION_TRANSACTION_ID)).longValue();
if (newTransactionId != transactionId) {
break;
}
counter++;
Thread.sleep(100L);
}
// connect intruder node
String nodeName = NODE2;
String nodeHostPort = "localhost:" + getNextAvailable(_node3HaPort + 1);
File environmentPathFile = new File(node1StorePath, nodeName);
environmentPathFile.mkdirs();
ReplicationConfig replicationConfig = new ReplicationConfig((String) nodeData.get(BDBHAVirtualHostNode.GROUP_NAME), nodeName, nodeHostPort);
replicationConfig.setHelperHosts((String) nodeData.get(BDBHAVirtualHostNode.ADDRESS));
replicationConfig.setConsistencyPolicy(NoConsistencyRequiredPolicy.NO_CONSISTENCY);
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setAllowCreate(true);
envConfig.setTransactional(true);
envConfig.setDurability(Durability.parse((String) nodeData.get(BDBHAVirtualHostNode.DURABILITY)));
ReplicatedEnvironment intruder = null;
try {
intruder = new ReplicatedEnvironment(environmentPathFile, replicationConfig, envConfig);
} finally {
if (intruder != null) {
intruder.close();
}
}
_restTestHelper.waitForAttributeChanged(_baseNodeRestUrl + NODE1, VirtualHostNode.STATE, State.ERRORED.name());
_restTestHelper.waitForAttributeChanged(_baseNodeRestUrl + NODE3, VirtualHostNode.STATE, State.ERRORED.name());
}
use of com.sleepycat.je.EnvironmentConfig in project vertigo by KleeGroup.
the class BerkeleyKVStorePlugin method buildFsEnvironment.
private static Environment buildFsEnvironment(final File dbFile, final boolean readOnly) {
dbFile.mkdirs();
final EnvironmentConfig fsEnvironmentConfig = new EnvironmentConfig().setConfigParam(EnvironmentConfig.LOG_MEM_ONLY, "false").setConfigParam(EnvironmentConfig.CLEANER_MIN_UTILIZATION, "90").setConfigParam(EnvironmentConfig.CLEANER_MIN_FILE_UTILIZATION, "50").setReadOnly(readOnly).setAllowCreate(!readOnly).setTransactional(!readOnly);
return new Environment(dbFile, fsEnvironmentConfig);
}
use of com.sleepycat.je.EnvironmentConfig in project jvarkit by lindenb.
the class Biostar92368 method doWork.
@Override
public int doWork(List<String> args) {
if (this.dbHome == null) {
LOG.error("Undefined DB-Home");
return -1;
}
environment = null;
EnvironmentConfig envCfg = new EnvironmentConfig();
this.database = null;
Transaction txn = null;
PrintStream out = null;
try {
envCfg.setAllowCreate(true);
this.environment = new Environment(dbHome, envCfg);
DatabaseConfig cfg = new DatabaseConfig();
cfg.setAllowCreate(true);
cfg.setTemporary(true);
this.database = environment.openDatabase(txn, "interactions", cfg);
if (args.isEmpty()) {
LOG.info("reading stdin");
LineIterator r = IOUtils.openStdinForLineIterator();
load(txn, r);
CloserUtil.close(r);
} else {
for (String filename : args) {
LOG.info("reading " + filename);
LineIterator r = IOUtils.openURIForLineIterator(filename);
load(txn, r);
CloserUtil.close(r);
}
}
out = super.openFileOrStdoutAsPrintStream(outputFile);
DatabaseEntry key1 = new DatabaseEntry();
DatabaseEntry data1 = new DatabaseEntry();
DatabaseEntry key2 = new DatabaseEntry();
DatabaseEntry data2 = new DatabaseEntry();
Cursor c1 = this.database.openCursor(txn, null);
Cursor c2 = this.database.openCursor(txn, null);
while (c1.getNext(key1, data1, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
String prot1 = StringBinding.entryToString(key1);
boolean first = true;
while ((first ? c2.getFirst(key2, data2, LockMode.DEFAULT) : c2.getNext(key2, data2, LockMode.DEFAULT)) == OperationStatus.SUCCESS) {
first = false;
String prot2 = StringBinding.entryToString(key2);
if (prot2.compareTo(prot1) <= 0)
continue;
Stack<String> path = new Stack<String>();
path.push(prot1);
int depth = recursive(txn, prot2, path, -1, maxDepth);
if (depth != -1) {
out.println(prot1 + "\t" + prot2 + "\t" + depth);
} else {
// System.out.println(prot1+"\t"+prot2+"\t"+depth);
}
if (out.checkError())
break;
}
}
CloserUtil.close(c2);
CloserUtil.close(c1);
out.flush();
out.close();
return 0;
} catch (Exception err) {
LOG.error(err);
return -1;
} finally {
CloserUtil.close(this.database);
CloserUtil.close(this.environment);
}
}
use of com.sleepycat.je.EnvironmentConfig in project jvarkit by lindenb.
the class VcfAnnotWithBeacon method doWork.
@Override
public int doWork(final List<String> args) {
try {
if (this.bdbDir != null) {
LOG.info("open BDB " + this.bdbDir);
IOUtil.assertDirectoryIsWritable(this.bdbDir);
final EnvironmentConfig envCfg = new EnvironmentConfig();
envCfg.setAllowCreate(true);
envCfg.setReadOnly(false);
this.bdbEnv = new Environment(this.bdbDir, envCfg);
final DatabaseConfig cfg = new DatabaseConfig();
cfg.setAllowCreate(true);
cfg.setReadOnly(false);
this.beaconDatabase = this.bdbEnv.openDatabase(this.txn, "ga4ghBeaconBuffer", cfg);
}
return doVcfToVcf(args, outputFile);
} catch (final Exception err) {
LOG.error(err);
return -1;
} finally {
CloserUtil.close(beaconDatabase);
CloserUtil.close(bdbEnv);
}
}
Aggregations