use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.
the class RFileTest method runVersionTest.
private void runVersionTest(int version) throws IOException {
InputStream in = this.getClass().getClassLoader().getResourceAsStream("org/apache/accumulo/core/file/rfile/ver_" + version + ".rf");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
int read;
while ((read = in.read(buf)) > 0) baos.write(buf, 0, read);
byte[] data = baos.toByteArray();
SeekableByteArrayInputStream bais = new SeekableByteArrayInputStream(data);
FSDataInputStream in2 = new FSDataInputStream(bais);
AccumuloConfiguration aconf = DefaultConfiguration.getInstance();
CachableBlockFile.Reader _cbr = new CachableBlockFile.Reader(in2, data.length, CachedConfiguration.getInstance(), aconf);
Reader reader = new RFile.Reader(_cbr);
checkIndex(reader);
ColumnFamilySkippingIterator iter = new ColumnFamilySkippingIterator(reader);
for (int start : new int[] { 0, 10, 100, 998 }) {
for (int cf = 1; cf <= 4; cf++) {
if (start == 0)
iter.seek(new Range(), newColFamByteSequence(formatString("cf_", cf)), true);
else
iter.seek(new Range(formatString("r_", start), null), newColFamByteSequence(formatString("cf_", cf)), true);
for (int i = start; i < 1000; i++) {
assertTrue(iter.hasTop());
assertEquals(newKey(formatString("r_", i), formatString("cf_", cf), formatString("cq_", 0), "", 1000 - i), iter.getTopKey());
assertEquals(newValue(i + ""), iter.getTopValue());
iter.next();
}
assertFalse(iter.hasTop());
}
if (start == 0)
iter.seek(new Range(), newColFamByteSequence(), false);
else
iter.seek(new Range(formatString("r_", start), null), newColFamByteSequence(), false);
for (int i = start; i < 1000; i++) {
for (int cf = 1; cf <= 4; cf++) {
assertTrue(iter.hasTop());
assertEquals(newKey(formatString("r_", i), formatString("cf_", cf), formatString("cq_", 0), "", 1000 - i), iter.getTopKey());
assertEquals(newValue(i + ""), iter.getTopValue());
iter.next();
}
}
assertFalse(iter.hasTop());
}
reader.close();
}
use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.
the class IteratorUtilTest method test4.
@Test
public void test4() throws IOException {
// try loading for a different scope
AccumuloConfiguration conf = new ConfigurationCopy();
TreeMap<Key, Value> tm = new TreeMap<>();
MultiIteratorTest.newKeyValue(tm, 1, 0, false, "1");
MultiIteratorTest.newKeyValue(tm, 2, 0, false, "2");
SortedMapIterator source = new SortedMapIterator(tm);
SortedKeyValueIterator<Key, Value> iter = IteratorUtil.loadIterators(IteratorScope.majc, source, new KeyExtent(Table.ID.of("tab"), null, null), conf, new DefaultIteratorEnvironment(conf));
iter.seek(new Range(), EMPTY_COL_FAMS, false);
assertTrue(iter.hasTop());
assertTrue(iter.getTopKey().equals(MultiIteratorTest.newKey(1, 0)));
assertTrue(iter.getTopValue().toString().equals("1"));
iter.next();
assertTrue(iter.hasTop());
assertTrue(iter.getTopKey().equals(MultiIteratorTest.newKey(2, 0)));
assertTrue(iter.getTopValue().toString().equals("2"));
iter.next();
assertFalse(iter.hasTop());
}
use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.
the class CloseWriteAheadLogReferencesIT method setupEasyMockStuff.
@Before
public void setupEasyMockStuff() {
Instance mockInst = createMock(Instance.class);
SiteConfiguration siteConfig = EasyMock.createMock(SiteConfiguration.class);
expect(mockInst.getInstanceID()).andReturn(testName.getMethodName()).anyTimes();
expect(mockInst.getZooKeepers()).andReturn("localhost").anyTimes();
expect(mockInst.getZooKeepersSessionTimeOut()).andReturn(30000).anyTimes();
final AccumuloConfiguration systemConf = new ConfigurationCopy(new HashMap<>());
ServerConfigurationFactory factory = createMock(ServerConfigurationFactory.class);
expect(factory.getSystemConfiguration()).andReturn(systemConf).anyTimes();
expect(factory.getSiteConfiguration()).andReturn(siteConfig).anyTimes();
// Just make the SiteConfiguration delegate to our AccumuloConfiguration
// Presently, we only need get(Property) and iterator().
EasyMock.expect(siteConfig.get(EasyMock.anyObject(Property.class))).andAnswer(new IAnswer<String>() {
@Override
public String answer() {
Object[] args = EasyMock.getCurrentArguments();
return systemConf.get((Property) args[0]);
}
}).anyTimes();
EasyMock.expect(siteConfig.getBoolean(EasyMock.anyObject(Property.class))).andAnswer(new IAnswer<Boolean>() {
@Override
public Boolean answer() {
Object[] args = EasyMock.getCurrentArguments();
return systemConf.getBoolean((Property) args[0]);
}
}).anyTimes();
EasyMock.expect(siteConfig.iterator()).andAnswer(new IAnswer<Iterator<Entry<String, String>>>() {
@Override
public Iterator<Entry<String, String>> answer() {
return systemConf.iterator();
}
}).anyTimes();
replay(mockInst, factory, siteConfig);
refs = new WrappedCloseWriteAheadLogReferences(new AccumuloServerContext(mockInst, factory));
}
use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.
the class CryptoTest method AESGCM_Encryption_Test_Tag_Integrity_Compromised.
@Test
public void AESGCM_Encryption_Test_Tag_Integrity_Compromised() throws IOException, AEADBadTagException {
AccumuloConfiguration conf = setAndGetAccumuloConfig(CRYPTO_ON_CONF);
byte[] encryptedBytes = testEncryption(conf, new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20 });
// modify the tag
encryptedBytes[encryptedBytes.length - 1]++;
exception.expect(AEADBadTagException.class);
testDecryption(conf, encryptedBytes);
encryptedBytes[encryptedBytes.length - 1]--;
// modify the data
encryptedBytes[1486]++;
exception.expect(AEADBadTagException.class);
testDecryption(conf, encryptedBytes);
}
use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.
the class CryptoTest method testCryptoModuleParamsValidation2.
@Test
public void testCryptoModuleParamsValidation2() throws IOException {
AccumuloConfiguration conf = setAndGetAccumuloConfig(CRYPTO_ON_CONF);
CryptoModuleParameters params = CryptoModuleFactory.createParamsObjectFromAccumuloConfiguration(conf);
CryptoModule cryptoModule = CryptoModuleFactory.getCryptoModule(conf);
assertTrue(cryptoModule instanceof DefaultCryptoModule);
exception.expect(RuntimeException.class);
cryptoModule.getDecryptingInputStream(params);
}
Aggregations