Search in sources :

Example 6 with UdbContext

use of alluxio.table.common.udb.UdbContext in project alluxio by Alluxio.

the class HiveDatabaseTest method createEmptyName.

@Test
public void createEmptyName() {
    mExpection.expect(IllegalArgumentException.class);
    UdbContext udbContext = new UdbContext(null, null, "hive", "thrift://not_running:9083", "", DB_NAME);
    assertEquals(DB_NAME, HiveDatabase.create(udbContext, new UdbConfiguration(ImmutableMap.of())).getName());
}
Also used : UdbContext(alluxio.table.common.udb.UdbContext) UdbConfiguration(alluxio.table.common.udb.UdbConfiguration) Test(org.junit.Test)

Example 7 with UdbContext

use of alluxio.table.common.udb.UdbContext in project alluxio by Alluxio.

the class HiveDatabaseTest method createEmptyConnectionUri.

@Test
public void createEmptyConnectionUri() {
    mExpection.expect(IllegalArgumentException.class);
    UdbContext udbContext = new UdbContext(null, null, "hive", "", DB_NAME, DB_NAME);
    assertEquals(DB_NAME, HiveDatabase.create(udbContext, new UdbConfiguration(ImmutableMap.of())).getName());
}
Also used : UdbContext(alluxio.table.common.udb.UdbContext) UdbConfiguration(alluxio.table.common.udb.UdbConfiguration) Test(org.junit.Test)

Example 8 with UdbContext

use of alluxio.table.common.udb.UdbContext in project alluxio by Alluxio.

the class HiveDatabaseTest method createNullName.

@Test
public void createNullName() {
    mExpection.expect(IllegalArgumentException.class);
    UdbContext udbContext = new UdbContext(null, null, "hive", "thrift://not_running:9083", null, DB_NAME);
    assertEquals(DB_NAME, HiveDatabase.create(udbContext, new UdbConfiguration(ImmutableMap.of())).getName());
}
Also used : UdbContext(alluxio.table.common.udb.UdbContext) UdbConfiguration(alluxio.table.common.udb.UdbConfiguration) Test(org.junit.Test)

Example 9 with UdbContext

use of alluxio.table.common.udb.UdbContext in project alluxio by Alluxio.

the class HiveDatabaseTest method before.

@Before
public void before() {
    mUdbContext = new UdbContext(null, null, "hive", "thrift://not_running:9083", DB_NAME, DB_NAME);
    mUdbConf = new UdbConfiguration(CONF);
}
Also used : UdbContext(alluxio.table.common.udb.UdbContext) UdbConfiguration(alluxio.table.common.udb.UdbConfiguration) Before(org.junit.Before)

Example 10 with UdbContext

use of alluxio.table.common.udb.UdbContext in project alluxio by Alluxio.

the class AlluxioCatalog method getDbIterator.

private Iterator<Journal.JournalEntry> getDbIterator() {
    final Iterator<Map.Entry<String, Database>> it = mDBs.entrySet().iterator();
    return new Iterator<Journal.JournalEntry>() {

        private Map.Entry<String, Database> mEntry = null;

        @Override
        public boolean hasNext() {
            if (mEntry != null) {
                return true;
            }
            if (it.hasNext()) {
                mEntry = it.next();
                return true;
            }
            return false;
        }

        @Override
        public Journal.JournalEntry next() {
            if (!hasNext()) {
                throw new NoSuchElementException();
            }
            String dbName = mEntry.getKey();
            Database database = mEntry.getValue();
            UdbContext udbContext = database.getUdb().getUdbContext();
            mEntry = null;
            return Journal.JournalEntry.newBuilder().setAttachDb(alluxio.proto.journal.Table.AttachDbEntry.newBuilder().setUdbType(database.getType()).setUdbConnectionUri(udbContext.getConnectionUri()).setUdbDbName(udbContext.getUdbDbName()).setDbName(dbName).putAllConfig(database.getConfig()).build()).build();
        }

        @Override
        public void remove() {
            throw new UnsupportedOperationException("GetDbIteratorr#Iterator#remove is not supported.");
        }
    };
}
Also used : CloseableIterator(alluxio.resource.CloseableIterator) Iterator(java.util.Iterator) Journal(alluxio.proto.journal.Journal) UdbContext(alluxio.table.common.udb.UdbContext) NoSuchElementException(java.util.NoSuchElementException)

Aggregations

UdbContext (alluxio.table.common.udb.UdbContext)11 UdbConfiguration (alluxio.table.common.udb.UdbConfiguration)8 Test (org.junit.Test)6 Before (org.junit.Before)2 Journal (alluxio.proto.journal.Journal)1 CloseableIterator (alluxio.resource.CloseableIterator)1 UnderDatabaseRegistry (alluxio.table.common.udb.UnderDatabaseRegistry)1 Iterator (java.util.Iterator)1 NoSuchElementException (java.util.NoSuchElementException)1