public static LogEntry deserialize(String line) { String[] fields = line.split(",", NUM_FIELDS); return new LogEntry(Long.parseLong(fields[0]), fields[1], fields[2]); }
/** * returns the last log entry * @param fs * @param lockFile * @return * @throws IOException */ public static LogEntry getLastEntry(FileSystem fs, Path lockFile) throws IOException { FSDataInputStream in = fs.open(lockFile); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String lastLine = null; for (String line = reader.readLine(); line != null; line = reader.readLine()) { lastLine = line; } return LogEntry.deserialize(lastLine); }
private void logProgress(String fileOffset, boolean prefixNewLine) throws IOException { long now = System.currentTimeMillis(); LogEntry entry = new LogEntry(now, componentID, fileOffset); String line = entry.toString(); if (prefixNewLine) { lockFileStream.writeBytes(System.lineSeparator() + line); } else { lockFileStream.writeBytes(line); } lockFileStream.hflush(); lastEntry = entry; // update this only after writing to hdfs }
if (lastEntry.equals(lastExpiredLock.getValue())) { FileLock result = FileLock.takeOwnership(hdfs, lastExpiredLock.getKey(), lastEntry, spoutId); lastExpiredLock = null;
/** * returns the last log entry * @param fs * @param lockFile * @return * @throws IOException */ public static LogEntry getLastEntry(FileSystem fs, Path lockFile) throws IOException { FSDataInputStream in = fs.open(lockFile); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String lastLine = null; for(String line = reader.readLine(); line!=null; line = reader.readLine() ) { lastLine=line; } return LogEntry.deserialize(lastLine); }
public static LogEntry deserialize(String line) { String[] fields = line.split(",", NUM_FIELDS); return new LogEntry(Long.parseLong(fields[0]), fields[1], fields[2]); }
private void logProgress(String fileOffset, boolean prefixNewLine) throws IOException { long now = System.currentTimeMillis(); LogEntry entry = new LogEntry(now, componentID, fileOffset); String line = entry.toString(); if(prefixNewLine) { lockFileStream.writeBytes(System.lineSeparator() + line); } else { lockFileStream.writeBytes(line); } lockFileStream.hflush(); lastEntry = entry; // update this only after writing to hdfs }
if (lastEntry.equals(lastExpiredLock.getValue())) { FileLock result = FileLock.takeOwnership(hdfs, lastExpiredLock.getKey(), lastEntry, spoutId); lastExpiredLock = null;