com.sleepycat.je.Durability Java Examples

The following examples show how to use com.sleepycat.je.Durability. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReplicatedEnvironmentFacadeTest.java    From qpid-broker-j with Apache License 2.0 6 votes vote down vote up
@Test
public void testSetMessageStoreDurability() throws Exception
{
    ReplicatedEnvironmentFacade master = createMaster();
    assertEquals("Unexpected message store durability",
                        new Durability(Durability.SyncPolicy.NO_SYNC, Durability.SyncPolicy.NO_SYNC, Durability.ReplicaAckPolicy.SIMPLE_MAJORITY),
                        master.getRealMessageStoreDurability());
    assertEquals("Unexpected durability", TEST_DURABILITY, master.getMessageStoreDurability());
    assertTrue("Unexpected coalescing sync", master.isCoalescingSync());

    master.setMessageStoreDurability(Durability.SyncPolicy.WRITE_NO_SYNC, Durability.SyncPolicy.SYNC, Durability.ReplicaAckPolicy.ALL);
    assertEquals("Unexpected message store durability",
                        new Durability(Durability.SyncPolicy.WRITE_NO_SYNC, Durability.SyncPolicy.SYNC, Durability.ReplicaAckPolicy.ALL),
                        master.getRealMessageStoreDurability());
    assertFalse("Coalescing sync committer is still running", master.isCoalescingSync());
}
 
Example #2
Source File: JE_Repository.java    From tddl with Apache License 2.0 6 votes vote down vote up
@Override
public void init() {

    EnvironmentConfig envConfig = new EnvironmentConfig();
    commonConfig(envConfig);
    envConfig.setCachePercent(config.getCachePercent());
    envConfig.setAllowCreate(true);
    if (config.isTransactional()) {
        envConfig.setCachePercent(config.getCachePercent());
        envConfig.setTransactional(config.isTransactional());
        envConfig.setTxnTimeout(config.getTxnTimeout(), TimeUnit.SECONDS);
        this.durability = config.isCommitSync() ? Durability.COMMIT_SYNC : Durability.COMMIT_NO_SYNC;
        envConfig.setDurability(this.durability);
    }
    File repo_dir = new File(config.getRepoDir());
    if (!repo_dir.exists()) {
        repo_dir.mkdirs();
    }
    this.env = new Environment(repo_dir, envConfig);
    cef = new CommandHandlerFactoryBDBImpl();
    cursorFactoryBDBImp = new CursorFactoryBDBImp();

}
 
Example #3
Source File: DatabasePinger.java    From qpid-broker-j with Apache License 2.0 5 votes vote down vote up
public DatabasePinger()
{
    // The ping merely needs to establish that the sufficient remote nodes are available,
    // we don't need to await the data being written/synch'd
    _pingTransactionConfig.setDurability(new Durability(Durability.SyncPolicy.NO_SYNC,
                                                        Durability.SyncPolicy.NO_SYNC,
                                                        Durability.ReplicaAckPolicy.SIMPLE_MAJORITY));
}
 
Example #4
Source File: BDBHAVirtualHostNodeTest.java    From qpid-broker-j with Apache License 2.0 5 votes vote down vote up
@Test
public void testIntruderConnected() throws Exception
{
    int node1PortNumber = _portHelper.getNextAvailable();
    int node2PortNumber = _portHelper.getNextAvailable();

    String helperAddress = "localhost:" + node1PortNumber;
    String groupName = "group";
    String nodeName = "node1";

    Map<String, Object> node1Attributes = _helper.createNodeAttributes(nodeName, groupName, helperAddress, helperAddress, nodeName, node1PortNumber);
    BDBHAVirtualHostNode<?> node1 = _helper.createAndStartHaVHN(node1Attributes);

    final CountDownLatch stopLatch = new CountDownLatch(1);
    ConfigurationChangeListener listener = new AbstractConfigurationChangeListener()
    {
        @Override
        public void stateChanged(ConfiguredObject<?> object, State oldState, State newState)
        {
            if (newState == State.ERRORED)
            {
                stopLatch.countDown();
            }
        }
    };
    node1.addChangeListener(listener);

    String node2Name = "node2";
    File environmentPathFile = new File(_helper.getMessageStorePath() + File.separator + node2Name);
    Durability durability = Durability.parse((String) node1Attributes.get(BDBHAVirtualHostNode.DURABILITY));
    joinIntruder(node2PortNumber, node2Name, groupName, helperAddress, durability, environmentPathFile);

    assertTrue("Intruder protection was not triggered during expected timeout",
                      stopLatch.await(20, TimeUnit.SECONDS));
}
 
Example #5
Source File: BJEConfig.java    From hypergraphdb with Apache License 2.0 5 votes vote down vote up
public void configureTransactional()
{
	envConfig.setTransactional(true);
	dbConfig.setTransactional(true);

	// envConfig.setLockDetectMode(LockDetectMode.RANDOM);

	Durability defaultDurability = new Durability(
			Durability.SyncPolicy.WRITE_NO_SYNC,
			Durability.SyncPolicy.NO_SYNC, // unused by non-HA applications.
			Durability.ReplicaAckPolicy.NONE); // unused by non-HA
												// applications.
	envConfig.setDurability(defaultDurability);
}
 
Example #6
Source File: BdbPersistentEnvironmentCreator.java    From timbuctoo with GNU General Public License v3.0 5 votes vote down vote up
@JsonCreator
public BdbPersistentEnvironmentCreator(@JsonProperty("databaseLocation") String databaseLocation) {
  this.databaseLocation = databaseLocation;
  configuration = new EnvironmentConfig(new Properties());
  configuration.setTransactional(true);
  configuration.setDurability(Durability.COMMIT_NO_SYNC);
  configuration.setAllowCreate(true);
  configuration.setSharedCache(true);
  bdbBackupper = new BdbBackupper();
}
 
Example #7
Source File: MultiNodeTest.java    From qpid-broker-j with Apache License 2.0 4 votes vote down vote up
@Test
public void testClusterCannotStartWithIntruder() throws Exception
{
    int intruderPort =
            new PortHelper().getNextAvailable(Arrays.stream(getBrokerAdmin().getBdbPorts()).max().getAsInt() + 1);
    String nodeName = "intruder";
    String nodeHostPort = getBrokerAdmin().getHost() + ":" + intruderPort;
    File environmentPathFile = Files.createTempDirectory("qpid-work-intruder").toFile();
    try
    {
        environmentPathFile.mkdirs();
        ReplicationConfig replicationConfig =
                new ReplicationConfig("test", nodeName, nodeHostPort);
        replicationConfig.setHelperHosts(getBrokerAdmin().getHelperHostPort());
        EnvironmentConfig envConfig = new EnvironmentConfig();
        envConfig.setAllowCreate(true);
        envConfig.setTransactional(true);
        envConfig.setDurability(new Durability(Durability.SyncPolicy.SYNC,
                                               Durability.SyncPolicy.WRITE_NO_SYNC,
                                               Durability.ReplicaAckPolicy.SIMPLE_MAJORITY));

        final String currentThreadName = Thread.currentThread().getName();
        try (ReplicatedEnvironment intruder = new ReplicatedEnvironment(environmentPathFile,
                                                                        replicationConfig,
                                                                        envConfig))
        {
            LOGGER.debug("Intruder started");
        }
        finally
        {
            Thread.currentThread().setName(currentThreadName);
        }

        Set<Integer> ports =
                Arrays.stream(getBrokerAdmin().getGroupAmqpPorts()).boxed().collect(Collectors.toSet());
        for (int port : ports)
        {
            getBrokerAdmin().awaitNodeToAttainAttributeValue(port,
                                                             BDBHAVirtualHostNode.STATE,
                                                             State.ERRORED.name());
        }

        getBrokerAdmin().stop();
        try
        {
            getBrokerAdmin().start();
            fail("Cluster cannot start with an intruder node");
        }
        catch (Exception e)
        {
            // pass
        }
    }
    finally
    {
        FileUtils.delete(environmentPathFile, true);
    }
}