Search in sources :

Example 61 with ImmutableMetaSnapshot

use of com.torodb.core.transaction.metainf.ImmutableMetaSnapshot in project torodb by torodb.

the class SnapshotMergerTest method testDatabaseNameConflict.

/**
   * Test that an exception is thrown on database name conflicts
   *
   * @throws Exception
   */
@Test
public void testDatabaseNameConflict() throws Exception {
    MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(new ImmutableMetaSnapshot(Collections.emptyMap()));
    changedSnapshot.addMetaDatabase("dbName2", "dbId1");
    try {
        new SnapshotMerger(currentSnapshot, changedSnapshot).merge();
        Assert.fail("A " + UnmergeableException.class.getSimpleName() + " was expected to be thrown");
    } catch (UnmergeableException ex) {
    }
}
Also used : WrapperMutableMetaSnapshot(com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot) MutableMetaSnapshot(com.torodb.core.transaction.metainf.MutableMetaSnapshot) UnmergeableException(com.torodb.core.transaction.metainf.UnmergeableException) ImmutableMetaSnapshot(com.torodb.core.transaction.metainf.ImmutableMetaSnapshot) WrapperMutableMetaSnapshot(com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot) Test(org.junit.Test)

Example 62 with ImmutableMetaSnapshot

use of com.torodb.core.transaction.metainf.ImmutableMetaSnapshot in project torodb by torodb.

the class SnapshotMergerTest method testDocPartRefConflict.

/**
   * Test that an exception is thrown on doc part table ref conflicts
   *
   * @throws Exception
   */
@Test
public void testDocPartRefConflict() throws Exception {
    MutableMetaSnapshot changedSnapshot = new WrapperMutableMetaSnapshot(new ImmutableMetaSnapshot(Collections.emptyMap()));
    changedSnapshot.addMetaDatabase("dbName1", "dbId1").addMetaCollection("colName1", "colId1").addMetaDocPart(tableRefFactory.createChild(tableRefFactory.createRoot(), "anotherTRef"), "docPartId1");
    try {
        new SnapshotMerger(currentSnapshot, changedSnapshot).merge();
        Assert.fail("A " + UnmergeableException.class.getSimpleName() + " was expected to be thrown");
    } catch (UnmergeableException ex) {
    }
}
Also used : WrapperMutableMetaSnapshot(com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot) MutableMetaSnapshot(com.torodb.core.transaction.metainf.MutableMetaSnapshot) UnmergeableException(com.torodb.core.transaction.metainf.UnmergeableException) ImmutableMetaSnapshot(com.torodb.core.transaction.metainf.ImmutableMetaSnapshot) WrapperMutableMetaSnapshot(com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot) Test(org.junit.Test)

Example 63 with ImmutableMetaSnapshot

use of com.torodb.core.transaction.metainf.ImmutableMetaSnapshot in project torodb by torodb.

the class ReservedIdInfoFactoryImpl method startUp.

@Override
protected void startUp() throws Exception {
    ImmutableMetaSnapshot snapshot;
    try (SnapshotStage snapshotStage = metainfoRepository.startSnapshotStage()) {
        snapshot = snapshotStage.createImmutableSnapshot();
    }
    try (Connection connection = sqlInterface.getDbBackend().createSystemConnection()) {
        DSLContext dsl = sqlInterface.getDslContextFactory().createDslContext(connection);
        megaMap = loadRowIds(dsl, snapshot);
    }
}
Also used : SnapshotStage(com.torodb.core.transaction.metainf.MetainfoRepository.SnapshotStage) Connection(java.sql.Connection) DSLContext(org.jooq.DSLContext) ImmutableMetaSnapshot(com.torodb.core.transaction.metainf.ImmutableMetaSnapshot)

Example 64 with ImmutableMetaSnapshot

use of com.torodb.core.transaction.metainf.ImmutableMetaSnapshot in project torodb by torodb.

the class IdentifierFactoryImplTest method unallowedDatabaseToIdentifierTest.

@Test
public void unallowedDatabaseToIdentifierTest() {
    ImmutableMetaSnapshot metaSnapshot = new ImmutableMetaSnapshot.Builder().build();
    String identifier = identifierFactory.toDatabaseIdentifier(metaSnapshot, "unallowed_schema");
    Assert.assertEquals("_unallowed_schema", identifier);
}
Also used : ImmutableMetaSnapshot(com.torodb.core.transaction.metainf.ImmutableMetaSnapshot) Test(org.junit.Test)

Example 65 with ImmutableMetaSnapshot

use of com.torodb.core.transaction.metainf.ImmutableMetaSnapshot in project torodb by torodb.

the class SqlTorodServer method enableDataImportMode.

@Override
public void enableDataImportMode() {
    ImmutableMetaSnapshot snapshot = internalTransactionManager.takeMetaSnapshot();
    backend.enableDataImportMode(snapshot);
}
Also used : ImmutableMetaSnapshot(com.torodb.core.transaction.metainf.ImmutableMetaSnapshot)

Aggregations

ImmutableMetaSnapshot (com.torodb.core.transaction.metainf.ImmutableMetaSnapshot)65 Test (org.junit.Test)62 MutableMetaSnapshot (com.torodb.core.transaction.metainf.MutableMetaSnapshot)56 WrapperMutableMetaSnapshot (com.torodb.core.transaction.metainf.WrapperMutableMetaSnapshot)55 UnmergeableException (com.torodb.core.transaction.metainf.UnmergeableException)22 SnapshotStage (com.torodb.core.transaction.metainf.MetainfoRepository.SnapshotStage)2 MergerStage (com.torodb.core.transaction.metainf.MetainfoRepository.MergerStage)1 MutableMetaDocPart (com.torodb.core.transaction.metainf.MutableMetaDocPart)1 Connection (java.sql.Connection)1 DSLContext (org.jooq.DSLContext)1