1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.chukwa.analysis.salsa.fsm;
20
21 import java.util.StringTokenizer;
22
23
24
25
26
27
28 public class ParseUtilities {
29
30 public static FSMIntermedEntry splitChukwaRecordKey
31 (String origkey, FSMIntermedEntry rec, String delim)
32 throws Exception
33 {
34 StringTokenizer st = new StringTokenizer(origkey, delim);
35 if (st.countTokens() != 3) {
36 throw new Exception("Expected 3 tokens from ChukwaRecordKey but only found " + st.countTokens() + ".");
37 }
38 rec.time_orig_epoch = new String(st.nextToken());
39 rec.job_id = new String(st.nextToken());
40 rec.time_orig = new String(st.nextToken());
41 return rec;
42 }
43
44 public static String extractHostnameFromTrackerName (String trackerName)
45 {
46 int firstPos = "tracker_".length();
47 int secondPos;
48 String hostname = new String("");
49
50 if (trackerName.startsWith("tracker_")) {
51 secondPos = trackerName.indexOf(":",firstPos);
52 hostname = trackerName.substring(firstPos, secondPos);
53 }
54
55 return hostname;
56 }
57
58 public static String removeRackFromHostname (String origHostname)
59 {
60 int pos = origHostname.lastIndexOf("/");
61 if (pos > -1) {
62 return new String(origHostname.substring(pos));
63 } else {
64 return new String(origHostname);
65 }
66 }
67
68 }