1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.chukwa.datacollection.sender;
19
20 import junit.framework.TestCase;
21 import org.apache.hadoop.chukwa.ChunkImpl;
22 import org.apache.hadoop.conf.*;
23 import java.util.ArrayList;
24 import java.util.List;
25 import org.apache.hadoop.chukwa.*;
26 import org.apache.hadoop.chukwa.datacollection.adaptor.filetailer.*;
27 import org.apache.hadoop.chukwa.datacollection.adaptor.Adaptor;
28 import org.apache.hadoop.chukwa.datacollection.sender.ChukwaHttpSender.CommitListEntry;
29
30 public class TestAcksOnFailure extends TestCase {
31 public void testNoCollector() {
32
33 Configuration conf = new Configuration();
34 conf.setInt("chukwaAgent.sender.retries", 3);
35 conf.setInt("chukwaAgent.sender.retryInterval", 1000);
36
37 ChukwaHttpSender send = new ChukwaHttpSender(conf);
38 ArrayList<String> collectors = new ArrayList<String>();
39 collectors.add("http://somehost.invalid/chukwa");
40 send.setCollectors(new RetryListOfCollectors(collectors, conf));
41
42 byte[] data = "sometestdata".getBytes();
43 Adaptor a = new FileTailingAdaptor();
44 ChunkImpl ci = new ChunkImpl("testtype", "sname", data.length, data, a);
45 ArrayList<Chunk> toSend = new ArrayList<Chunk>();
46 toSend.add(ci);
47 try {
48 List<CommitListEntry> resp = send.send(toSend);
49 assertTrue(resp.size() == 0);
50 } catch(Exception e) {
51
52 }
53 }
54
55 }