use of alluxio.proto.journal.Journal.JournalEntry in project alluxio by Alluxio.
the class UfsJournalReader method readInternal.
/**
* Reads the next journal entry.
*
* @return the journal entry, null if no journal entry is found
*/
private Journal.JournalEntry readInternal() throws IOException {
if (mInputStream == null) {
return null;
}
JournalEntry entry = mInputStream.mReader.readEntry();
if (entry != null) {
return entry;
}
if (mInputStream.mFile.isIncompleteLog()) {
// Incomplete logs may end early.
return null;
} else {
Preconditions.checkState(mInputStream.mFile.isCompletedLog(), "Expected log to be either checkpoint, incomplete, or complete");
ProcessUtils.fatalError(LOG, "Journal entry %s was truncated", mNextSequenceNumber);
return null;
}
}
use of alluxio.proto.journal.Journal.JournalEntry in project alluxio by Alluxio.
the class JournalTool method main.
/**
* Reads a journal via
* {@code java -cp \
* assembly/server/target/alluxio-assembly-server-<ALLUXIO-VERSION>-jar-with-dependencies.jar \
* alluxio.master.journal.JournalTool < journal/FileSystemMaster/log.out}.
*
* @param args arguments passed to the tool
*/
public static void main(String[] args) throws IOException {
if (!parseInputArgs(args)) {
usage();
System.exit(EXIT_FAILED);
}
if (sHelp) {
usage();
System.exit(EXIT_SUCCEEDED);
}
if (!sNoTimeout && !stdinHasData()) {
System.exit(EXIT_FAILED);
}
JournalFormatter formatter = new ProtoBufJournalFormatter();
try (JournalInputStream journalStream = formatter.deserialize(System.in)) {
JournalEntry entry;
while ((entry = journalStream.read()) != null) {
System.out.print(entry);
System.out.println(ENTRY_SEPARATOR);
}
}
}
use of alluxio.proto.journal.Journal.JournalEntry in project SSM by Intel-bigdata.
the class AlluxioEntryFetchAndApplyTask method run.
@Override
public void run() {
LOG.trace("AlluxioEntryFetchAndApplyTask run at " + new Date());
try {
JournalEntry journalEntry = journalReader.read();
while (journalEntry != null) {
entryApplier.apply(journalEntry);
lastSn.getAndSet(journalEntry.getSequenceNumber());
metaStore.updateAndInsertIfNotExist(new SystemInfo(SmartConstants.SMART_ALLUXIO_LAST_ENTRY_SN, String.valueOf(lastSn.get())));
journalEntry = journalReader.read();
}
} catch (Throwable t) {
LOG.error("Alluxio Entry Apply Events error", t);
}
}
use of alluxio.proto.journal.Journal.JournalEntry in project SSM by Intel-bigdata.
the class TestAlluxioEntryApplier method testRenameApplier.
@Test
public void testRenameApplier() throws Exception {
FileSystem fs = Mockito.mock(FileSystem.class);
AlluxioEntryApplier entryApplier = new AlluxioEntryApplier(metaStore, fs);
FileInfo fooFile = FileInfo.newBuilder().setFileId(50331647).setIsdir(false).setPath("/bar/foobar1").build();
metaStore.insertFile(fooFile);
BackUpInfo backUpInfo = new BackUpInfo(1L, "/bar/foobar1", "remote/dest/", 10);
metaStore.insertBackUpInfo(backUpInfo);
alluxio.wire.FileInfo info1 = new alluxio.wire.FileInfo().setFileId(50331647).setPath("/bar/foobar1").setLength(300L).setFolder(false).setBlockSizeBytes(310000).setLastModificationTimeMs(1515665270681L).setCreationTimeMs(1515665270681L).setMode(493).setOwner("user1").setGroup("group1");
URIStatus status1 = new URIStatus(info1);
Mockito.when(fs.getStatus(new AlluxioURI("/bar/foobar1"))).thenReturn(status1);
RenameEntry renameEntry = RenameEntry.newBuilder().setId(50331647).setOpTimeMs(1515666148444L).setDstPath("/bar/foobar1_new").build();
JournalEntry renameJEntry = JournalEntry.newBuilder().setRename(renameEntry).build();
entryApplier.apply(renameJEntry);
List<FileDiff> fileDiffs = metaStore.getFileDiffsByFileName("/bar/foobar1");
Assert.assertTrue(fileDiffs.size() > 0);
for (FileDiff fileDiff : fileDiffs) {
if (fileDiff.getDiffType().equals(FileDiffType.RENAME)) {
Assert.assertEquals("/bar/foobar1", fileDiff.getSrc());
Assert.assertEquals("/bar/foobar1_new", fileDiff.getParameters().get("-dest"));
}
}
}
use of alluxio.proto.journal.Journal.JournalEntry in project SSM by Intel-bigdata.
the class TestAlluxioEntryApplier method testInodeDirectoryApplier.
@Test
public void testInodeDirectoryApplier() throws Exception {
FileSystem fs = Mockito.mock(FileSystem.class);
AlluxioEntryApplier entryApplier = new AlluxioEntryApplier(metaStore, fs);
FileInfo rootDir = FileInfo.newBuilder().setFileId(0).setIsdir(true).setPath("/").build();
metaStore.insertFile(rootDir);
alluxio.wire.FileInfo info1 = new alluxio.wire.FileInfo().setFileId(1).setPath("/dir1").setLength(0L).setFolder(true).setBlockSizeBytes(1000000).setLastModificationTimeMs(1528876616216L).setCreationTimeMs(1528876616216L).setMode(493).setOwner("user1").setGroup("group1");
URIStatus status1 = new URIStatus(info1);
Mockito.when(fs.getStatus(new AlluxioURI("/dir1"))).thenReturn(status1);
InodeDirectoryEntry inodeDirectoryEntry = InodeDirectoryEntry.newBuilder().setId(1).setParentId(0).setName("dir1").setPersistenceState("NOT_PERSISTED").setPinned(false).setCreationTimeMs(1528876616216L).setLastModificationTimeMs(1528876616216L).setOwner("user1").setGroup("group1").setMode(493).setMountPoint(false).setDirectChildrenLoaded(false).setTtl(-1L).setTtlAction(PTtlAction.DELETE).build();
JournalEntry inodeDirectoryJEntry = JournalEntry.newBuilder().setInodeDirectory(inodeDirectoryEntry).build();
entryApplier.apply(inodeDirectoryJEntry);
Assert.assertTrue(metaStore.getFile().get(0).getPath().equals("/"));
Assert.assertTrue(metaStore.getFile().get(1).getPath().equals("/dir1"));
Assert.assertEquals("user1", metaStore.getFile("/dir1").getOwner());
Assert.assertEquals(1528876616216L, metaStore.getFile("/dir1").getModificationTime());
}
Aggregations