@Override public Boolean onSuccess(Map<IgfsPath, IgfsEntryInfo> infos) throws Exception { fs.mkdirs(path, props); assert !infos.isEmpty(); // Now perform synchronization again starting with the last created parent. IgfsPath parentPath = null; for (IgfsPath curPath : infos.keySet()) { if (parentPath == null || curPath.isSubDirectoryOf(parentPath)) parentPath = curPath; } assert parentPath != null; IgfsEntryInfo parentPathInfo = infos.get(parentPath); synchronize(fs, parentPath, parentPathInfo, path, true, null); if (evts.isRecordable(EventType.EVT_IGFS_DIR_CREATED)) { IgfsPath evtPath = path; while (!parentPath.equals(evtPath)) { pendingEvts.addFirst(new IgfsEvent(evtPath, locNode, EventType.EVT_IGFS_DIR_CREATED)); evtPath = evtPath.parent(); assert evtPath != null; // If this fails, then ROOT does not exist. } } return true; }
assertEquals(EVT_IGFS_DIR_CREATED, evt.type()); assertEquals(new IgfsPath("/dir1"), evt.path()); assertEquals(EVT_IGFS_DIR_CREATED, evt.type()); assertEquals(new IgfsPath("/dir1/dir2"), evt.path()); assertEquals(EVT_IGFS_FILE_CREATED, evt.type()); assertEquals(new IgfsPath("/dir1/dir2/file1"), evt.path()); assertEquals(EVT_IGFS_FILE_OPENED_WRITE, evt.type()); assertEquals(new IgfsPath("/dir1/dir2/file1"), evt.path()); assertEquals(EVT_IGFS_FILE_CLOSED_WRITE, evt.type()); assertEquals(new IgfsPath("/dir1/dir2/file1"), evt.path()); assertEquals(0, evt.dataSize()); assertEquals(EVT_IGFS_FILE_RENAMED, evt4.type()); assertEquals(new IgfsPath("/dir1/dir2/file1"), evt4.path()); assertEquals(new IgfsPath("/dir1/file1"), evt4.newPath());
assertEquals(EVT_IGFS_FILE_CREATED, evt.type()); assertEquals(new IgfsPath("/file1"), evt.path()); assertEquals(EVT_IGFS_FILE_OPENED_WRITE, evt.type()); assertEquals(new IgfsPath("/file1"), evt.path()); assertEquals(EVT_IGFS_FILE_CLOSED_WRITE, evt.type()); assertEquals(new IgfsPath("/file1"), evt.path()); assertEquals((long)dataSize, evt.dataSize()); assertEquals(EVT_IGFS_FILE_OPENED_READ, evt.type()); assertEquals(new IgfsPath("/file1"), evt.path()); assertEquals(EVT_IGFS_FILE_CLOSED_READ, evt.type()); assertEquals(new IgfsPath("/file1"), evt.path()); assertEquals((long) dataSize, evt.dataSize());
assertEquals(EVT_IGFS_DIR_CREATED, evt.type()); assertEquals(new IgfsPath("/dir1"), evt.path()); assertTrue(evt.isDirectory()); assertEquals(EVT_IGFS_FILE_CREATED, evt.type()); assertEquals(new IgfsPath("/dir1/file1"), evt.path()); assertFalse(evt.isDirectory()); assertEquals(EVT_IGFS_FILE_OPENED_WRITE, evt.type()); assertEquals(new IgfsPath("/dir1/file1"), evt.path()); assertEquals(EVT_IGFS_FILE_CLOSED_WRITE, evt.type()); assertEquals(new IgfsPath("/dir1/file1"), evt.path()); assertEquals(EVT_IGFS_FILE_CREATED, evt.type()); assertEquals(new IgfsPath("/dir1/file2"), evt.path()); assertFalse(evt.isDirectory()); assertEquals(EVT_IGFS_FILE_OPENED_WRITE, evt.type()); assertEquals(new IgfsPath("/dir1/file2"), evt.path()); assertEquals(EVT_IGFS_FILE_CLOSED_WRITE, evt.type()); assertEquals(new IgfsPath("/dir1/file2"), evt.path()); assertEquals(EVT_IGFS_DIR_DELETED, evt.type()); assertEquals(new IgfsPath("/dir1"), evt.path());
/** * Checks if this is a directory-related event. * * @return {@code True} if this event is directory-related. */ public boolean isDirectory() { int t = type(); return t == EVT_IGFS_DIR_CREATED || t == EVT_IGFS_DIR_RENAMED || t == EVT_IGFS_DIR_DELETED; }
assertEquals(EVT_IGFS_DIR_CREATED, evt.type()); assertEquals(new IgfsPath("/dir1"), evt.path()); assertTrue(evt.isDirectory()); assertEquals(EVT_IGFS_DIR_RENAMED, evt.type()); assertEquals(new IgfsPath("/dir1"), evt.path()); assertEquals(new IgfsPath("/mvDir1"), evt.newPath()); assertTrue(evt.isDirectory()); assertEquals(EVT_IGFS_DIR_DELETED, evt.type()); assertEquals(new IgfsPath("/mvDir1"), evt.path()); assertTrue(evt.isDirectory());
/** * Checks if this is a directory-related event. * * @return {@code True} if this event is directory-related. */ public boolean isDirectory() { int t = type(); return t == EVT_IGFS_DIR_CREATED || t == EVT_IGFS_DIR_RENAMED || t == EVT_IGFS_DIR_DELETED; }
assertEquals(EVT_IGFS_DIR_CREATED, evt.type()); assertEquals(new IgfsPath("/dir1"), evt.path()); assertTrue(evt.isDirectory()); assertEquals(EVT_IGFS_DIR_CREATED, evt.type()); assertEquals(new IgfsPath("/dir1/dir2"), evt.path()); assertEquals(EVT_IGFS_DIR_CREATED, evt.type()); assertEquals(new IgfsPath("/dir1/dir2/dir3"), evt.path()); assertEquals(EVT_IGFS_FILE_CREATED, evt.type()); assertEquals(new IgfsPath("/dir1/dir2/dir3/file1"), evt.path()); assertFalse(evt.isDirectory()); assertEquals(EVT_IGFS_FILE_OPENED_WRITE, evt.type()); assertEquals(new IgfsPath("/dir1/dir2/dir3/file1"), evt.path()); assertEquals(EVT_IGFS_FILE_CLOSED_WRITE, evt.type()); assertEquals(new IgfsPath("/dir1/dir2/dir3/file1"), evt.path()); assertEquals(0, evt.dataSize()); assertEquals(EVT_IGFS_FILE_RENAMED, evt.type()); assertEquals(new IgfsPath("/dir1/dir2/dir3/file1"), evt.path()); assertEquals(new IgfsPath("/dir1/dir2/dir3/mvFile1"), evt.newPath()); assertEquals(EVT_IGFS_DIR_DELETED, evt.type()); assertEquals(new IgfsPath("/dir1/dir2"), evt.path());
/** * Sends a series of event. * * @param kernalCtx Kernal context. * @param path The path of the created file. * @param newPath New path. * @param type The type of event to send. */ public static void sendEvents(GridKernalContext kernalCtx, IgfsPath path, IgfsPath newPath, int type) { assert kernalCtx != null; assert path != null; GridEventStorageManager evts = kernalCtx.event(); ClusterNode locNode = kernalCtx.discovery().localNode(); if (evts.isRecordable(type)) { if (newPath == null) evts.record(new IgfsEvent(path, locNode, type)); else evts.record(new IgfsEvent(path, newPath, locNode, type)); } }
assertEquals(EVT_IGFS_DIR_CREATED, evt.type()); assertEquals(new IgfsPath("/dir1"), evt.path()); assertTrue(evt.isDirectory()); assertEquals(EVT_IGFS_FILE_CREATED, evt.type()); assertEquals(new IgfsPath("/dir1/file1"), evt.path()); assertEquals(EVT_IGFS_FILE_OPENED_WRITE, evt.type()); assertEquals(new IgfsPath("/dir1/file1"), evt.path()); assertEquals(EVT_IGFS_FILE_CLOSED_WRITE, evt.type()); assertEquals(new IgfsPath("/dir1/file1"), evt.path()); assertEquals(0, evt.dataSize()); assertEquals(EVT_IGFS_FILE_CREATED, evt.type()); assertEquals(new IgfsPath("/dir1/file2"), evt.path()); assertEquals(EVT_IGFS_FILE_OPENED_WRITE, evt.type()); assertEquals(new IgfsPath("/dir1/file2"), evt.path()); assertEquals(EVT_IGFS_FILE_CLOSED_WRITE, evt.type()); assertEquals(new IgfsPath("/dir1/file2"), evt.path()); assertEquals(0, evt.dataSize());
evts.record(new IgfsEvent(path, igfsCtx.localNode(), EVT_IGFS_FILE_CLOSED_READ, bytes()));
/** * Updates IGFS metrics when the stream is closed. */ protected void updateMetricsOnClose() { IgfsLocalMetrics metrics = igfsCtx.metrics(); metrics.addWrittenBytesTime(bytes, time); metrics.decrementFilesOpenedForWrite(); GridEventStorageManager evts = igfsCtx.kernalContext().event(); if (evts.isRecordable(EVT_IGFS_FILE_CLOSED_WRITE)) evts.record(new IgfsEvent(path, igfsCtx.localNode(), EVT_IGFS_FILE_CLOSED_WRITE, bytes)); }
assertEquals(EVT_IGFS_DIR_CREATED, evt.type()); assertEquals(new IgfsPath("/dir1"), evt.path()); assertEquals(EVT_IGFS_DIR_CREATED, evt.type()); assertEquals(new IgfsPath("/dir1/dir2"), evt.path()); assertEquals(EVT_IGFS_DIR_DELETED, evt3.type()); assertEquals(new IgfsPath("/dir1/dir2"), evt3.path());