Search in sources :

Example 96 with Collection

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());
}
Also used : User(org.apache.hadoop.hbase.security.User) KeyValue(org.apache.hadoop.hbase.KeyValue) Configuration(org.apache.hadoop.conf.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) CompactionConfiguration(org.apache.hadoop.hbase.regionserver.compactions.CompactionConfiguration) FileSystem(org.apache.hadoop.fs.FileSystem) FilterFileSystem(org.apache.hadoop.fs.FilterFileSystem) LocalFileSystem(org.apache.hadoop.fs.LocalFileSystem) Collection(java.util.Collection) IOException(java.io.IOException) IOException(java.io.IOException) Test(org.junit.Test)

Example 97 with Collection

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);
}
Also used : HashMap(java.util.HashMap) Collection(java.util.Collection) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 98 with Collection

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);
}
Also used : HashMap(java.util.HashMap) Collection(java.util.Collection) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 99 with Collection

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);
    }
}
Also used : INimbusCredentialPlugin(org.apache.storm.security.INimbusCredentialPlugin) Collection(java.util.Collection) IOException(java.io.IOException) HashSet(java.util.HashSet)

Example 100 with Collection

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);
}
Also used : LongSum(org.apache.storm.streams.operations.aggregators.LongSum) FilterProcessor(org.apache.storm.streams.processors.FilterProcessor) DefaultDirectedGraph(org.jgrapht.graph.DefaultDirectedGraph) Collection(java.util.Collection) TopologyContext(org.apache.storm.task.TopologyContext) Set(java.util.Set) Test(org.junit.Test) HashMap(java.util.HashMap) Fields(org.apache.storm.tuple.Fields) Multimap(com.google.common.collect.Multimap) GlobalStreamId(org.apache.storm.generated.GlobalStreamId) AggregateProcessor(org.apache.storm.streams.processors.AggregateProcessor) Processor(org.apache.storm.streams.processors.Processor) Mockito(org.mockito.Mockito) Values(org.apache.storm.tuple.Values) Tuple(org.apache.storm.tuple.Tuple) ArgumentCaptor(org.mockito.ArgumentCaptor) OutputCollector(org.apache.storm.task.OutputCollector) Map(java.util.Map) Assert.assertArrayEquals(org.junit.Assert.assertArrayEquals) DirectedGraph(org.jgrapht.DirectedGraph) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) Values(org.apache.storm.tuple.Values) Collection(java.util.Collection) Test(org.junit.Test)

Aggregations

Collection (java.util.Collection)2848 ArrayList (java.util.ArrayList)801 Map (java.util.Map)581 Test (org.junit.Test)537 HashMap (java.util.HashMap)479 List (java.util.List)387 Iterator (java.util.Iterator)325 HashSet (java.util.HashSet)279 IOException (java.io.IOException)258 Set (java.util.Set)250 File (java.io.File)114 Collectors (java.util.stream.Collectors)95 LinkedHashMap (java.util.LinkedHashMap)90 LinkedList (java.util.LinkedList)82 Test (org.testng.annotations.Test)78 NotNull (org.jetbrains.annotations.NotNull)75 Region (org.apache.geode.cache.Region)71 Collections (java.util.Collections)67 Field (java.lang.reflect.Field)65 Logger (org.slf4j.Logger)63