Java Code Examples for org.apache.flume.Channel#setName()
The following examples show how to use
org.apache.flume.Channel#setName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RegexEventSerializerIT.java From phoenix with Apache License 2.0 | 5 votes |
private Channel initChannel() { //Channel configuration Context channelContext = new Context(); channelContext.put("capacity", "10000"); channelContext.put("transactionCapacity", "200"); Channel channel = new MemoryChannel(); channel.setName("memorychannel"); Configurables.configure(channel, channelContext); return channel; }
Example 2
Source File: PhoenixSinkIT.java From phoenix with Apache License 2.0 | 5 votes |
private Channel initChannel() { //Channel configuration Context channelContext = new Context(); channelContext.put("capacity", "10000"); channelContext.put("transactionCapacity", "200"); Channel channel = new MemoryChannel(); channel.setName("memorychannel"); Configurables.configure(channel, channelContext); return channel; }
Example 3
Source File: RoundRobinChannelSelectorTest.java From fiware-cygnus with GNU Affero General Public License v3.0 | 5 votes |
/** * Sets up tests by creating a unique instance of the tested class, and by defining the behaviour of the mocked * classes. * * @throws Exception */ @Before public void setUp() throws Exception { // set up the instance of the tested class channelSelector = new RoundRobinChannelSelector(); Channel channel1 = new MemoryChannel(); channel1.setName("ch1"); Channel channel2 = new MemoryChannel(); channel2.setName("ch2"); Channel channel3 = new MemoryChannel(); channel3.setName("ch3"); Channel channel4 = new MemoryChannel(); channel4.setName("ch4"); Channel channel5 = new MemoryChannel(); channel5.setName("ch5"); Channel channel6 = new MemoryChannel(); channel6.setName("ch6"); ArrayList<Channel> allChannels = new ArrayList<Channel>(); allChannels.add(channel1); allChannels.add(channel2); allChannels.add(channel3); allChannels.add(channel4); allChannels.add(channel5); allChannels.add(channel6); channelSelector.setChannels(allChannels); // set up other instances context = new Context(); context.put("storages", "3"); context.put("storages.storage1", "ch1"); context.put("storages.storage2", "ch2,ch3"); context.put("storages.storage3", "ch4,ch5,ch6"); }
Example 4
Source File: TestRegexEventSerializer.java From phoenix with BSD 3-Clause "New" or "Revised" License | 5 votes |
private Channel initChannel() { //Channel configuration Context channelContext = new Context(); channelContext.put("capacity", "10000"); channelContext.put("transactionCapacity", "200"); Channel channel = new MemoryChannel(); channel.setName("memorychannel"); Configurables.configure(channel, channelContext); return channel; }
Example 5
Source File: TestPhoenixSink.java From phoenix with BSD 3-Clause "New" or "Revised" License | 5 votes |
private Channel initChannel() { //Channel configuration Context channelContext = new Context(); channelContext.put("capacity", "10000"); channelContext.put("transactionCapacity", "200"); Channel channel = new MemoryChannel(); channel.setName("memorychannel"); Configurables.configure(channel, channelContext); return channel; }
Example 6
Source File: MockChannel.java From mt-flume with Apache License 2.0 | 4 votes |
public static Channel createMockChannel(String name) { Channel ch = new MockChannel(); ch.setName(name); return ch; }
Example 7
Source File: JDBCSinkTest.java From ingestion with Apache License 2.0 | 4 votes |
@Test public void mappedWithH2() throws Exception { Class.forName("org.h2.Driver").newInstance(); Connection conn = DriverManager.getConnection("jdbc:h2:/tmp/jdbcsink_test"); conn.prepareStatement("DROP TABLE public.test IF EXISTS;").execute(); conn.prepareStatement("CREATE TABLE public.test (myInteger INTEGER, myString VARCHAR, myId BIGINT AUTO_INCREMENT PRIMARY KEY);").execute(); conn.commit(); conn.close(); Context ctx = new Context(); ctx.put("driver", "org.h2.Driver"); ctx.put("connectionString", "jdbc:h2:/tmp/jdbcsink_test"); ctx.put("table", "test"); ctx.put("sqlDialect", "H2"); ctx.put("batchSize", "1"); JDBCSink jdbcSink = new JDBCSink(); Configurables.configure(jdbcSink, ctx); Context channelContext = new Context(); channelContext.put("capacity", "10000"); channelContext.put("transactionCapacity", "200"); Channel channel = new MemoryChannel(); channel.setName("junitChannel"); Configurables.configure(channel, channelContext); jdbcSink.setChannel(channel); channel.start(); jdbcSink.start(); Transaction tx = channel.getTransaction(); tx.begin(); Map<String, String> headers = new HashMap<String, String>(); headers.put("myString", "bar"); // Overwrites the value defined in JSON body headers.put("myInteger", "64"); headers.put("myBoolean", "true"); headers.put("myDouble", "1.0"); headers.put("myNull", "foobar"); Date myDate = new Date(); headers.put("myDate", Long.toString(myDate.getTime())); headers.put("myString2", "baz"); Event event = EventBuilder.withBody(new byte[0], headers); channel.put(event); tx.commit(); tx.close(); jdbcSink.process(); jdbcSink.stop(); channel.stop(); conn = DriverManager.getConnection("jdbc:h2:/tmp/jdbcsink_test"); ResultSet resultSet = conn.prepareStatement("SELECT * FROM public.test").executeQuery(); resultSet.next(); assertThat(resultSet.getInt("myInteger")).isEqualTo(64); assertThat(resultSet.getString("myString")).isEqualTo("bar"); conn.close(); }
Example 8
Source File: JDBCSinkTest.java From ingestion with Apache License 2.0 | 4 votes |
@Test public void mappedWithDerby() throws Exception { FileUtils.deleteDirectory(new File("test_derby_db")); Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); Connection conn = DriverManager.getConnection("jdbc:derby:test_derby_db;create=true"); conn.prepareStatement("CREATE TABLE TEST (myInteger INT, myString VARCHAR(255), myId INT NOT NULL GENERATED ALWAYS AS IDENTITY \n" + "\t(START WITH 1, INCREMENT BY 1), PRIMARY KEY(myId))").execute(); conn.commit(); conn.close(); Context ctx = new Context(); ctx.put("driver", "org.apache.derby.jdbc.EmbeddedDriver"); ctx.put("connectionString", "jdbc:derby:test_derby_db"); ctx.put("table", "test"); ctx.put("sqlDialect", "DERBY"); ctx.put("batchSize", "1"); JDBCSink jdbcSink = new JDBCSink(); Configurables.configure(jdbcSink, ctx); Context channelContext = new Context(); channelContext.put("capacity", "10000"); channelContext.put("transactionCapacity", "200"); Channel channel = new MemoryChannel(); channel.setName("junitChannel"); Configurables.configure(channel, channelContext); jdbcSink.setChannel(channel); channel.start(); jdbcSink.start(); Transaction tx = channel.getTransaction(); tx.begin(); Map<String, String> headers = new HashMap<String, String>(); headers.put("myString", "bar"); // Overwrites the value defined in JSON body headers.put("myInteger", "64"); headers.put("myBoolean", "true"); headers.put("myDouble", "1.0"); headers.put("myNull", "foobar"); Date myDate = new Date(); headers.put("myDate", Long.toString(myDate.getTime())); headers.put("myString2", "baz"); Event event = EventBuilder.withBody(new byte[0], headers); channel.put(event); tx.commit(); tx.close(); jdbcSink.process(); jdbcSink.stop(); channel.stop(); conn = DriverManager.getConnection("jdbc:derby:test_derby_db"); ResultSet resultSet = conn.prepareStatement("SELECT * FROM TEST").executeQuery(); resultSet.next(); assertThat(resultSet.getInt("myInteger")).isEqualTo(64); assertThat(resultSet.getString("myString")).isEqualTo("bar"); conn.close(); try { DriverManager.getConnection("jdbc:derby:;shutdown=true"); } catch (SQLException ex) { } }
Example 9
Source File: JDBCSinkTest.java From ingestion with Apache License 2.0 | 4 votes |
@Test public void templateWithH2() throws Exception { Class.forName("org.h2.Driver").newInstance(); Connection conn = DriverManager.getConnection("jdbc:h2:/tmp/jdbcsink_test"); conn.prepareStatement("DROP TABLE public.test IF EXISTS;").execute(); conn.prepareStatement("CREATE TABLE public.test (myInteger INTEGER, myString VARCHAR, myId BIGINT AUTO_INCREMENT PRIMARY KEY);").execute(); conn.commit(); conn.close(); Context ctx = new Context(); ctx.put("driver", "org.h2.Driver"); ctx.put("connectionString", "jdbc:h2:/tmp/jdbcsink_test"); ctx.put("sqlDialect", "H2"); ctx.put("batchSize", "1"); ctx.put("sql", "INSERT INTO \"PUBLIC\".\"TEST\" (\"MYINTEGER\", \"MYSTRING\") VALUES (cast(${header.myInteger:int} as integer), cast(${header.myString:varchar} as varchar))"); JDBCSink jdbcSink = new JDBCSink(); Configurables.configure(jdbcSink, ctx); Context channelContext = new Context(); channelContext.put("capacity", "10000"); channelContext.put("transactionCapacity", "200"); Channel channel = new MemoryChannel(); channel.setName("junitChannel"); Configurables.configure(channel, channelContext); jdbcSink.setChannel(channel); channel.start(); jdbcSink.start(); Transaction tx = channel.getTransaction(); tx.begin(); Map<String, String> headers = new HashMap<String, String>(); headers.put("myString", "bar"); // Overwrites the value defined in JSON body headers.put("myInteger", "64"); headers.put("myBoolean", "true"); headers.put("myDouble", "1.0"); headers.put("myNull", "foobar"); Date myDate = new Date(); headers.put("myDate", Long.toString(myDate.getTime())); headers.put("myString2", "baz"); Event event = EventBuilder.withBody(new byte[0], headers); channel.put(event); tx.commit(); tx.close(); jdbcSink.process(); jdbcSink.stop(); channel.stop(); conn = DriverManager.getConnection("jdbc:h2:/tmp/jdbcsink_test"); ResultSet rs = conn.prepareStatement("SELECT count(*) AS count FROM public.test").executeQuery(); rs.next(); assertThat(rs.getInt("count")).isEqualTo(1); rs = conn.prepareStatement("SELECT * FROM public.test").executeQuery(); rs.next(); // for (int i = 1; i <= 3; i++) { // System.out.println(rs.getString(i)); // } assertThat(rs.getInt("myInteger")).isEqualTo(64); assertThat(rs.getString("myString")).isEqualTo("bar"); conn.close(); }
Example 10
Source File: JDBCSinkTest.java From ingestion with Apache License 2.0 | 4 votes |
/** * Sample code to validate postgresql integration with JDBC sink * Ignored until we get a Docker Postgresql and move to integration test * @throws Exception */ @Test @Ignore public void templateWithPostgres() throws Exception { Class.forName("org.postgresql.Driver").newInstance(); Connection connTruncate = DriverManager.getConnection("jdbc:postgresql://10.200.0.126:5432/test_erige?user=postgres&password="); connTruncate.prepareStatement("TRUNCATE tc40;").execute(); //conn.prepareStatement("CREATE TABLE tc40 (myInteger INTEGER, myString VARCHAR, myId BIGINT AUTO_INCREMENT " // + "PRIMARY KEY);").execute(); //connTruncate.commit(); connTruncate.close(); Context ctx = new Context(); ctx.put("driver", "org.postgresql.Driver"); ctx.put("connectionString", "jdbc:postgresql://10.200.0.126:5432/test_erige?user=postgres&password="); ctx.put("sqlDialect", "POSTGRES"); ctx.put("table", "tc40"); ctx.put("username", "postgres"); ctx.put("batchSize", "1"); ctx.put("sql", "INSERT INTO \"tc40\" (\"arn\", \"account_number\") VALUES " + "(${header.arn:varchar}, ${header.account_number:varchar})"); JDBCSink jdbcSink = new JDBCSink(); Configurables.configure(jdbcSink, ctx); Context channelContext = new Context(); channelContext.put("capacity", "10000"); channelContext.put("transactionCapacity", "200"); Channel channel = new MemoryChannel(); channel.setName("junitChannel"); Configurables.configure(channel, channelContext); jdbcSink.setChannel(channel); channel.start(); jdbcSink.start(); Transaction tx = channel.getTransaction(); tx.begin(); Map<String, String> headers = new HashMap<String, String>(); headers.put("arn", "bar"); // Overwrites the value defined in JSON body headers.put("account_number", "account number"); headers.put("dsadas", "dsadasdas"); Event event = EventBuilder.withBody(new byte[0], headers); channel.put(event); tx.commit(); tx.close(); jdbcSink.process(); jdbcSink.stop(); channel.stop(); //Connection conn = DriverManager.getConnection("jdbc:h2:/tmp/jdbcsink_test"); Connection conn = DriverManager.getConnection("jdbc:postgresql://10.200.0" + ".126:5432/test_erige?user=postgres&password="); ResultSet rs = conn.prepareStatement("SELECT count(*) AS count FROM tc40").executeQuery(); rs.next(); assertThat(rs.getInt("count")).isEqualTo(1); rs = conn.prepareStatement("SELECT * FROM tc40").executeQuery(); rs.next(); // for (int i = 1; i <= 3; i++) { // System.out.println(rs.getString(i)); // } assertThat(rs.getString("arn")).isEqualTo("bar"); conn.close(); }