Search in sources :

Example 11 with AccumuloConfiguration

use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.

the class ZooCachePropertyAccessorTest method testGetProperties_ParentFilter.

@Test
public void testGetProperties_ParentFilter() {
    Map<String, String> props = new java.util.HashMap<>();
    AccumuloConfiguration parent = createMock(AccumuloConfiguration.class);
    @SuppressWarnings("unchecked") Predicate<String> filter = createMock(Predicate.class);
    @SuppressWarnings("unchecked") Predicate<String> parentFilter = createMock(Predicate.class);
    parent.getProperties(props, parentFilter);
    replay(parent);
    expect(zc.getChildren(PATH)).andReturn(null);
    replay(zc);
    a.getProperties(props, PATH, filter, parent, parentFilter);
    verify(parent);
}
Also used : AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) Test(org.junit.Test)

Example 12 with AccumuloConfiguration

use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.

the class ZooCachePropertyAccessorTest method testGetProperties_NoChildren.

@Test
public void testGetProperties_NoChildren() {
    Map<String, String> props = new java.util.HashMap<>();
    AccumuloConfiguration parent = createMock(AccumuloConfiguration.class);
    @SuppressWarnings("unchecked") Predicate<String> filter = createMock(Predicate.class);
    parent.getProperties(props, filter);
    replay(parent);
    expect(zc.getChildren(PATH)).andReturn(null);
    replay(zc);
    a.getProperties(props, PATH, filter, parent, null);
    assertEquals(0, props.size());
}
Also used : AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) Test(org.junit.Test)

Example 13 with AccumuloConfiguration

use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.

the class ZooReaderWriterFactory method getInstance.

/**
 * Gets a reader/writer, retrieving ZooKeeper information from the site configuration. The same instance may be returned for multiple calls.
 *
 * @return reader/writer
 */
public IZooReaderWriter getInstance() {
    synchronized (ZooReaderWriterFactory.class) {
        if (instance == null) {
            AccumuloConfiguration conf = SiteConfiguration.getInstance();
            instance = getZooReaderWriter(conf.get(Property.INSTANCE_ZK_HOST), (int) conf.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT), conf.get(Property.INSTANCE_SECRET));
        }
        return instance;
    }
}
Also used : AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration)

Example 14 with AccumuloConfiguration

use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.

the class MultiLevelIndexTest method runTest.

private void runTest(int maxBlockSize, int num) throws IOException {
    AccumuloConfiguration aconf = DefaultConfiguration.getInstance();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    FSDataOutputStream dos = new FSDataOutputStream(baos, new FileSystem.Statistics("a"));
    CachableBlockFile.Writer _cbw = new CachableBlockFile.Writer(PositionedOutputs.wrap(dos), "gz", CachedConfiguration.getInstance(), aconf);
    BufferedWriter mliw = new BufferedWriter(new Writer(_cbw, maxBlockSize));
    for (int i = 0; i < num; i++) mliw.add(new Key(String.format("%05d000", i)), i, 0, 0, 0);
    mliw.addLast(new Key(String.format("%05d000", num)), num, 0, 0, 0);
    ABlockWriter root = _cbw.prepareMetaBlock("root");
    mliw.close(root);
    root.close();
    _cbw.close();
    dos.close();
    baos.close();
    byte[] data = baos.toByteArray();
    SeekableByteArrayInputStream bais = new SeekableByteArrayInputStream(data);
    FSDataInputStream in = new FSDataInputStream(bais);
    CachableBlockFile.Reader _cbr = new CachableBlockFile.Reader(in, data.length, CachedConfiguration.getInstance(), aconf);
    Reader reader = new Reader(_cbr, RFile.RINDEX_VER_8);
    BlockRead rootIn = _cbr.getMetaBlock("root");
    reader.readFields(rootIn);
    rootIn.close();
    IndexIterator liter = reader.lookup(new Key("000000"));
    int count = 0;
    while (liter.hasNext()) {
        assertEquals(count, liter.nextIndex());
        assertEquals(count, liter.peek().getNumEntries());
        assertEquals(count, liter.next().getNumEntries());
        count++;
    }
    assertEquals(num + 1, count);
    while (liter.hasPrevious()) {
        count--;
        assertEquals(count, liter.previousIndex());
        assertEquals(count, liter.peekPrevious().getNumEntries());
        assertEquals(count, liter.previous().getNumEntries());
    }
    assertEquals(0, count);
    // go past the end
    liter = reader.lookup(new Key(String.format("%05d000", num + 1)));
    assertFalse(liter.hasNext());
    Random rand = new Random();
    for (int i = 0; i < 100; i++) {
        int k = rand.nextInt(num * 1000);
        int expected;
        if (k % 1000 == 0)
            // end key is inclusive
            expected = k / 1000;
        else
            expected = k / 1000 + 1;
        liter = reader.lookup(new Key(String.format("%08d", k)));
        IndexEntry ie = liter.next();
        assertEquals(expected, ie.getNumEntries());
    }
}
Also used : Reader(org.apache.accumulo.core.file.rfile.MultiLevelIndex.Reader) IndexEntry(org.apache.accumulo.core.file.rfile.MultiLevelIndex.IndexEntry) ABlockWriter(org.apache.accumulo.core.file.blockfile.ABlockWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IndexIterator(org.apache.accumulo.core.file.rfile.MultiLevelIndex.Reader.IndexIterator) BufferedWriter(org.apache.accumulo.core.file.rfile.MultiLevelIndex.BufferedWriter) BlockRead(org.apache.accumulo.core.file.blockfile.impl.CachableBlockFile.BlockRead) Random(java.util.Random) FileSystem(org.apache.hadoop.fs.FileSystem) SeekableByteArrayInputStream(org.apache.accumulo.core.file.rfile.RFileTest.SeekableByteArrayInputStream) FSDataInputStream(org.apache.hadoop.fs.FSDataInputStream) CachableBlockFile(org.apache.accumulo.core.file.blockfile.impl.CachableBlockFile) FSDataOutputStream(org.apache.hadoop.fs.FSDataOutputStream) BufferedWriter(org.apache.accumulo.core.file.rfile.MultiLevelIndex.BufferedWriter) ABlockWriter(org.apache.accumulo.core.file.blockfile.ABlockWriter) Writer(org.apache.accumulo.core.file.rfile.MultiLevelIndex.Writer) Key(org.apache.accumulo.core.data.Key) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration)

Example 15 with AccumuloConfiguration

use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.

the class RFileTest method setAndGetAccumuloConfig.

private AccumuloConfiguration setAndGetAccumuloConfig(String cryptoConfSetting) {
    ConfigurationCopy result = new ConfigurationCopy(DefaultConfiguration.getInstance());
    Configuration conf = new Configuration(false);
    conf.addResource(cryptoConfSetting);
    for (Entry<String, String> e : conf) {
        result.set(e.getKey(), e.getValue());
    }
    return result;
}
Also used : ConfigurationCopy(org.apache.accumulo.core.conf.ConfigurationCopy) Configuration(org.apache.hadoop.conf.Configuration) SamplerConfiguration(org.apache.accumulo.core.client.sample.SamplerConfiguration) BlockCacheConfiguration(org.apache.accumulo.core.file.blockfile.cache.impl.BlockCacheConfiguration) DefaultConfiguration(org.apache.accumulo.core.conf.DefaultConfiguration) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) CachedConfiguration(org.apache.accumulo.core.util.CachedConfiguration)

Aggregations

AccumuloConfiguration (org.apache.accumulo.core.conf.AccumuloConfiguration)117 Test (org.junit.Test)44 Path (org.apache.hadoop.fs.Path)26 ConfigurationCopy (org.apache.accumulo.core.conf.ConfigurationCopy)25 IOException (java.io.IOException)23 Configuration (org.apache.hadoop.conf.Configuration)19 HashMap (java.util.HashMap)17 ClientConfiguration (org.apache.accumulo.core.client.ClientConfiguration)13 Key (org.apache.accumulo.core.data.Key)13 DefaultConfiguration (org.apache.accumulo.core.conf.DefaultConfiguration)12 Property (org.apache.accumulo.core.conf.Property)12 Value (org.apache.accumulo.core.data.Value)12 ByteArrayInputStream (java.io.ByteArrayInputStream)11 DataInputStream (java.io.DataInputStream)11 FileSystem (org.apache.hadoop.fs.FileSystem)11 ArrayList (java.util.ArrayList)10 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)9 Text (org.apache.hadoop.io.Text)9 ByteArrayOutputStream (java.io.ByteArrayOutputStream)8 AccumuloException (org.apache.accumulo.core.client.AccumuloException)8