use of java.util.Collection in project hbase by apache.
the class TestStore method testHandleErrorsInFlush.
@Test
public void testHandleErrorsInFlush() throws Exception {
LOG.info("Setting up a faulty file system that cannot write");
final Configuration conf = HBaseConfiguration.create();
User user = User.createUserForTesting(conf, "testhandleerrorsinflush", new String[] { "foo" });
// Inject our faulty LocalFileSystem
conf.setClass("fs.file.impl", FaultyFileSystem.class, FileSystem.class);
user.runAs(new PrivilegedExceptionAction<Object>() {
@Override
public Object run() throws Exception {
// Make sure it worked (above is sensitive to caching details in hadoop core)
FileSystem fs = FileSystem.get(conf);
Assert.assertEquals(FaultyFileSystem.class, fs.getClass());
// Initialize region
init(name.getMethodName(), conf);
LOG.info("Adding some data");
store.add(new KeyValue(row, family, qf1, 1, (byte[]) null), null);
store.add(new KeyValue(row, family, qf2, 1, (byte[]) null), null);
store.add(new KeyValue(row, family, qf3, 1, (byte[]) null), null);
LOG.info("Before flush, we should have no files");
Collection<StoreFileInfo> files = store.getRegionFileSystem().getStoreFiles(store.getColumnFamilyName());
Assert.assertEquals(0, files != null ? files.size() : 0);
//flush
try {
LOG.info("Flushing");
flush(1);
Assert.fail("Didn't bubble up IOE!");
} catch (IOException ioe) {
Assert.assertTrue(ioe.getMessage().contains("Fault injected"));
}
LOG.info("After failed flush, we should still have no files!");
files = store.getRegionFileSystem().getStoreFiles(store.getColumnFamilyName());
Assert.assertEquals(0, files != null ? files.size() : 0);
store.getHRegion().getWAL().close();
return null;
}
});
FileSystem.closeAllForUGI(user.getUGI());
}
use of java.util.Collection in project storm by apache.
the class AuthUtilsTest method getNimbusAutoCredPluginTest.
@Test
public void getNimbusAutoCredPluginTest() {
Map emptyMap = new HashMap<String, String>();
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
map.put(Config.NIMBUS_AUTO_CRED_PLUGINS, Arrays.asList(new String[] { "org.apache.storm.security.auth.AuthUtilsTestMock" }));
Assert.assertTrue(AuthUtils.getNimbusAutoCredPlugins(emptyMap).isEmpty());
Assert.assertEquals(AuthUtils.getNimbusAutoCredPlugins(map).size(), 1);
}
use of java.util.Collection in project storm by apache.
the class AuthUtilsTest method GetCredentialRenewersTest.
@Test
public void GetCredentialRenewersTest() {
Map emptyMap = new HashMap<String, String>();
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
map.put(Config.NIMBUS_CREDENTIAL_RENEWERS, Arrays.asList(new String[] { "org.apache.storm.security.auth.AuthUtilsTestMock" }));
Assert.assertTrue(AuthUtils.GetCredentialRenewers(emptyMap).isEmpty());
Assert.assertEquals(AuthUtils.GetCredentialRenewers(map).size(), 1);
}
use of java.util.Collection in project storm by apache.
the class AuthUtils method getNimbusAutoCredPlugins.
/**
* Get all the Nimbus Auto cred plugins.
* @param conf nimbus configuration to use.
* @return nimbus auto credential plugins.
*/
public static Collection<INimbusCredentialPlugin> getNimbusAutoCredPlugins(Map conf) {
try {
Set<INimbusCredentialPlugin> ret = new HashSet<>();
Collection<String> clazzes = (Collection<String>) conf.get(Config.NIMBUS_AUTO_CRED_PLUGINS);
if (clazzes != null) {
for (String clazz : clazzes) {
INimbusCredentialPlugin inst = Utils.newInstance(clazz);
inst.prepare(conf);
ret.add(inst);
}
}
return ret;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of java.util.Collection in project storm by apache.
the class ProcessorBoltTest method testEmitAndAck.
@Test
public void testEmitAndAck() throws Exception {
setUpProcessorBolt(new FilterProcessor<Integer>(x -> true));
bolt.execute(mockTuple1);
ArgumentCaptor<Collection> anchor = ArgumentCaptor.forClass(Collection.class);
ArgumentCaptor<Values> values = ArgumentCaptor.forClass(Values.class);
ArgumentCaptor<String> os = ArgumentCaptor.forClass(String.class);
Mockito.verify(mockOutputCollector).emit(os.capture(), anchor.capture(), values.capture());
assertEquals("outputstream", os.getValue());
assertArrayEquals(new Object[] { mockTuple1 }, anchor.getValue().toArray());
assertEquals(new Values(100), values.getValue());
Mockito.verify(mockOutputCollector, Mockito.times(1)).ack(mockTuple1);
}
Aggregations