use of org.apache.ignite.internal.igfs.common.IgfsLogger in project ignite by apache.
the class IgniteHadoopFileSystemLoggerSelfTest method testCreateDelete.
/**
* Ensure correct static loggers creation/removal as well as file creation.
*
* @throws Exception If failed.
*/
public void testCreateDelete() throws Exception {
IgfsLogger log = IgfsLogger.logger(ENDPOINT, IGFS_NAME, LOG_DIR, 10);
IgfsLogger sameLog0 = IgfsLogger.logger(ENDPOINT, IGFS_NAME, LOG_DIR, 10);
// Loggers for the same endpoint must be the same object.
assert log == sameLog0;
IgfsLogger otherLog = IgfsLogger.logger("other" + ENDPOINT, IGFS_NAME, LOG_DIR, 10);
// Logger for another endpoint must be different.
assert log != otherLog;
otherLog.close();
log.logDelete(PATH, false);
log.close();
File logFile = new File(LOG_FILE);
// When there are multiple loggers, closing one must not force flushing.
assert !logFile.exists();
IgfsLogger sameLog1 = IgfsLogger.logger(ENDPOINT, IGFS_NAME, LOG_DIR, 10);
assert sameLog0 == sameLog1;
sameLog0.close();
assert !logFile.exists();
sameLog1.close();
// When we cloe the last logger, it must flush data to disk.
assert logFile.exists();
logFile.delete();
IgfsLogger sameLog2 = IgfsLogger.logger(ENDPOINT, IGFS_NAME, LOG_DIR, 10);
// This time we expect new logger instance to be created.
assert sameLog0 != sameLog2;
sameLog2.close();
// As we do not add any records to the logger, we do not expect flushing.
assert !logFile.exists();
}
use of org.apache.ignite.internal.igfs.common.IgfsLogger in project ignite by apache.
the class IgniteHadoopFileSystemLoggerSelfTest method testLogMisc.
/**
* Test miscellaneous operations logging.
*
* @throws Exception If failed.
*/
@SuppressWarnings("TooBroadScope")
public void testLogMisc() throws Exception {
IgfsLogger log = IgfsLogger.logger(ENDPOINT, IGFS_NAME, LOG_DIR, 10);
String newFile = "/dir3/file.test";
String file1 = "/dir3/file1.test";
String file2 = "/dir3/file1.test";
log.logMakeDirectory(PATH);
log.logRename(PATH, new IgfsPath(newFile));
log.logListDirectory(PATH, new String[] { file1, file2 });
log.logDelete(PATH, false);
log.close();
checkLog(new SB().a(U.jvmPid() + d() + TYPE_DIR_MAKE + d() + PATH_STR_ESCAPED + d() + d(17)).toString(), new SB().a(U.jvmPid() + d() + TYPE_RENAME + d() + PATH_STR_ESCAPED + d() + d(15) + newFile + d(2)).toString(), new SB().a(U.jvmPid() + d() + TYPE_DIR_LIST + d() + PATH_STR_ESCAPED + d() + d(17) + file1 + DELIM_FIELD_VAL + file2).toString(), new SB().a(U.jvmPid() + d() + TYPE_DELETE + d(1) + PATH_STR_ESCAPED + d() + d(16) + 0 + d()).toString());
}
use of org.apache.ignite.internal.igfs.common.IgfsLogger in project ignite by apache.
the class IgniteHadoopFileSystemLoggerSelfTest method testLogRead.
/**
* Test read operations logging.
*
* @throws Exception If failed.
*/
public void testLogRead() throws Exception {
IgfsLogger log = IgfsLogger.logger(ENDPOINT, IGFS_NAME, LOG_DIR, 10);
log.logOpen(1, PATH, 2, 3L);
log.logRandomRead(1, 4L, 5);
log.logSeek(1, 6L);
log.logSkip(1, 7L);
log.logMark(1, 8L);
log.logReset(1);
log.logCloseIn(1, 9L, 10L, 11);
log.close();
checkLog(new SB().a(U.jvmPid() + d() + TYPE_OPEN_IN + d() + PATH_STR_ESCAPED + d() + d() + 1 + d() + 2 + d() + 3 + d(14)).toString(), new SB().a(U.jvmPid() + d() + TYPE_RANDOM_READ + d(3) + 1 + d(7) + 4 + d() + 5 + d(8)).toString(), new SB().a(U.jvmPid() + d() + TYPE_SEEK + d(3) + 1 + d(7) + 6 + d(9)).toString(), new SB().a(U.jvmPid() + d() + TYPE_SKIP + d(3) + 1 + d(9) + 7 + d(7)).toString(), new SB().a(U.jvmPid() + d() + TYPE_MARK + d(3) + 1 + d(10) + 8 + d(6)).toString(), new SB().a(U.jvmPid() + d() + TYPE_RESET + d(3) + 1 + d(16)).toString(), new SB().a(U.jvmPid() + d() + TYPE_CLOSE_IN + d(3) + 1 + d(11) + 9 + d() + 10 + d() + 11 + d(3)).toString());
}
use of org.apache.ignite.internal.igfs.common.IgfsLogger in project ignite by apache.
the class IgniteHadoopFileSystemLoggerSelfTest method testLogWrite.
/**
* Test write operations logging.
*
* @throws Exception If failed.
*/
public void testLogWrite() throws Exception {
IgfsLogger log = IgfsLogger.logger(ENDPOINT, IGFS_NAME, LOG_DIR, 10);
log.logCreate(1, PATH, true, 2, new Integer(3).shortValue(), 4L);
log.logAppend(2, PATH, 8);
log.logCloseOut(2, 9L, 10L, 11);
log.close();
checkLog(new SB().a(U.jvmPid() + d() + TYPE_OPEN_OUT + d() + PATH_STR_ESCAPED + d() + d() + 1 + d() + 2 + d(2) + 0 + d() + 1 + d() + 3 + d() + 4 + d(10)).toString(), new SB().a(U.jvmPid() + d() + TYPE_OPEN_OUT + d() + PATH_STR_ESCAPED + d() + d() + 2 + d() + 8 + d(2) + 1 + d(13)).toString(), new SB().a(U.jvmPid() + d() + TYPE_CLOSE_OUT + d(3) + 2 + d(11) + 9 + d() + 10 + d() + 11 + d(3)).toString());
}
use of org.apache.ignite.internal.igfs.common.IgfsLogger in project ignite by apache.
the class IgniteHadoopFileSystemLoggerStateSelfTest method logEnabled.
/**
* Ensure that real logger is used by the file system.
*
* @return {@code True} in case path is secondary.
* @throws Exception If failed.
*/
private boolean logEnabled() throws Exception {
assert fs != null;
Field field = fs.getClass().getDeclaredField("clientLog");
field.setAccessible(true);
return ((IgfsLogger) field.get(fs)).isLogEnabled();
}
Aggregations