1 package org.apache.helix.filestore;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 public class ChangeRecord
23 {
24 /**
25 * Transaction Id corresponding to the change that increases monotonically. 31
26 * LSB correspond to sequence number that increments every change. 31 MSB
27 * increments when the master changes
28 */
29 long txid;
30 /**
31 * File(s) that were changed
32 */
33 String file;
34
35 /**
36 * Timestamp
37 */
38 long timestamp;
39 /**
40 * Type of event like create, modified, deleted
41 */
42 short type;
43
44 transient String changeLogFileName;
45
46 transient long startOffset;
47
48 transient long endOffset;
49
50 public short fileFieldLength;
51
52 public String toString()
53 {
54 StringBuilder sb = new StringBuilder();
55 sb.append(txid);
56 sb.append("|");
57 sb.append(timestamp);
58 sb.append("|");
59 sb.append(file);
60 sb.append("|");
61 sb.append(changeLogFileName);
62 sb.append("|");
63 sb.append(startOffset);
64 sb.append("|");
65 sb.append(endOffset);
66 return sb.toString();
67 }
68
69 public static ChangeRecord fromString(String line)
70 {
71 ChangeRecord record=null;
72 if (line != null)
73 {
74 String[] split = line.split("\\|");
75 if (split.length == 6)
76 {
77 record = new ChangeRecord();
78 record.txid = Long.parseLong(split[0]);
79 record.timestamp = Long.parseLong(split[1]);
80 record.file = split[2];
81 record.changeLogFileName = split[3];
82 record.startOffset = Long.parseLong(split[4]);
83 record.endOffset = Long.parseLong(split[5]);
84 }
85 }
86 return record;
87 }
88
89 }