test_class.declarator: metaStore = null
test_class.modifier: private
test_class.original_string: private MetaStore metaStore = null;
test_class.type: MetaStore
test_class.var_name: metaStore
test_class.file: smart-hadoop-support/smart-hadoop/src/test/java/org/smartdata/hdfs/metric/fetcher/TestInotifyEventApplier.java
test_class.identifier: TestInotifyEventApplier
test_class.superclass: extends TestDaoUtil
test_case.body: @Test
    public void testApplier() throws Exception {
      DFSClient client = Mockito.mock(DFSClient.class);
  
      FileInfo root = HadoopUtil.convertFileStatus(getDummyDirStatus("/", 1000), "/");
      metaStore.insertFile(root);
      BackUpInfo backUpInfo = new BackUpInfo(1L, "/file", "remote/dest/", 10);
      metaStore.insertBackUpInfo(backUpInfo);
      InotifyEventApplier applier = new InotifyEventApplier(metaStore, client);
  
      Event.CreateEvent createEvent =
          new Event.CreateEvent.Builder()
              .iNodeType(Event.CreateEvent.INodeType.FILE)
              .ctime(1)
              .defaultBlockSize(1024)
              .groupName("cg1")
              .overwrite(true)
              .ownerName("user1")
              .path("/file")
              .perms(new FsPermission("777"))
              .replication(3)
              .build();
      HdfsFileStatus status1 =
          CompatibilityHelperLoader.getHelper().createHdfsFileStatus(
              0,
              false,
              1,
              1024,
              0,
              0,
              new FsPermission("777"),
              "owner",
              "group",
              new byte[0],
              new byte[0],
              1010,
              0,
              null,
              (byte) 0);
      Mockito.when(client.getFileInfo(Matchers.startsWith("/file"))).thenReturn(status1);
      Mockito.when(client.getFileInfo(Matchers.startsWith("/dir"))).thenReturn(getDummyDirStatus("", 1010));
      applier.apply(new Event[] {createEvent});
  
      FileInfo result1 = metaStore.getFile().get(1);
      Assert.assertEquals(result1.getPath(), "/file");
      Assert.assertEquals(result1.getFileId(), 1010L);
      Assert.assertEquals(result1.getPermission(), 511);
  
      Event close = new Event.CloseEvent("/file", 1024, 0);
      applier.apply(new Event[] {close});
      FileInfo result2 = metaStore.getFile().get(1);
      Assert.assertEquals(result2.getLength(), 1024);
      Assert.assertEquals(result2.getModificationTime(), 0L);
  
  //    Event truncate = new Event.TruncateEvent("/file", 512, 16);
  //    applier.apply(new Event[] {truncate});
  //    ResultSet result3 = metaStore.executeQuery("SELECT * FROM files");
  //    Assert.assertEquals(result3.getLong("length"), 512);
  //    Assert.assertEquals(result3.getLong("modification_time"), 16L);
  
      Event meta =
          new Event.MetadataUpdateEvent.Builder()
              .path("/file")
              .metadataType(Event.MetadataUpdateEvent.MetadataType.TIMES)
              .mtime(2)
              .atime(3)
              .replication(4)
              .ownerName("user2")
              .groupName("cg2")
              .build();
      applier.apply(new Event[] {meta});
      FileInfo result4 = metaStore.getFile().get(1);
      Assert.assertEquals(result4.getAccessTime(), 3);
      Assert.assertEquals(result4.getModificationTime(), 2);
  
      Event meta1 =
          new Event.MetadataUpdateEvent.Builder()
              .path("/file")
              .metadataType(Event.MetadataUpdateEvent.MetadataType.OWNER)
              .ownerName("user1")
              .groupName("cg1")
              .build();
      applier.apply(new Event[] {meta1});
      result4 = metaStore.getFile().get(1);
      Assert.assertEquals(result4.getOwner(), "user1");
      Assert.assertEquals(result4.getGroup(), "cg1");
  
      Event.CreateEvent createEvent2 =
          new Event.CreateEvent.Builder()
              .iNodeType(Event.CreateEvent.INodeType.DIRECTORY)
              .ctime(1)
              .groupName("cg1")
              .overwrite(true)
              .ownerName("user1")
              .path("/dir")
              .perms(new FsPermission("777"))
              .replication(3)
              .build();
      Event.CreateEvent createEvent3 =
          new Event.CreateEvent.Builder()
              .iNodeType(Event.CreateEvent.INodeType.FILE)
              .ctime(1)
              .groupName("cg1")
              .overwrite(true)
              .ownerName("user1")
              .path("/dir/file")
              .perms(new FsPermission("777"))
              .replication(3)
              .build();
      Event rename =
        new Event.RenameEvent.Builder().dstPath("/dir2").srcPath("/dir").timestamp(5).build();
  
      applier.apply(new Event[] {createEvent2, createEvent3, rename});
      List<FileInfo> result5 = metaStore.getFile();
      List<String> expectedPaths = Arrays.asList("/dir2", "/dir2/file", "/file");
      List<String> actualPaths = new ArrayList<>();
      for (FileInfo s : result5) {
        actualPaths.add(s.getPath());
      }
      Collections.sort(actualPaths);
      Assert.assertTrue(actualPaths.size() == 4);
      Assert.assertTrue(actualPaths.containsAll(expectedPaths));
  
      Event unlink = new Event.UnlinkEvent.Builder().path("/").timestamp(6).build();
      applier.apply(new Event[]{unlink});
      Thread.sleep(1200);
      Assert.assertEquals(metaStore.getFile().size(), 0);
      System.out.println("Files in table " + metaStore.getFile().size());
      List<FileDiff> fileDiffList = metaStore.getPendingDiff();
      Assert.assertTrue(fileDiffList.size() == 4);
    }
test_case.class_method_signature: TestInotifyEventApplier.testApplier()
test_case.full_signature: @Test public void testApplier()
test_case.identifier: testApplier
test_case.invocations: mock convertFileStatus getDummyDirStatus insertFile insertBackUpInfo build replication perms path ownerName overwrite groupName defaultBlockSize ctime iNodeType createHdfsFileStatus getHelper thenReturn when getFileInfo startsWith thenReturn when getFileInfo startsWith getDummyDirStatus apply get getFile assertEquals getPath assertEquals getFileId assertEquals getPermission apply get getFile assertEquals getLength assertEquals getModificationTime build groupName ownerName replication atime mtime metadataType path apply get getFile assertEquals getAccessTime assertEquals getModificationTime build groupName ownerName metadataType path apply get getFile assertEquals getOwner assertEquals getGroup build replication perms path ownerName overwrite groupName ctime iNodeType build replication perms path ownerName overwrite groupName ctime iNodeType build timestamp srcPath dstPath apply getFile asList add getPath sort assertTrue size assertTrue containsAll build timestamp path apply sleep assertEquals size getFile println size getFile getPendingDiff assertTrue size
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testApplier()
focal_class.declarator: metaStore
focal_class.modifier: private final
focal_class.original_string: private final MetaStore metaStore;
focal_class.type: MetaStore
focal_class.var_name: metaStore
focal_class.declarator: client
focal_class.modifier: private
focal_class.original_string: private DFSClient client;
focal_class.type: DFSClient
focal_class.var_name: client
focal_class.declarator: LOG =
        LoggerFactory.getLogger(InotifyEventFetcher.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOG =
        LoggerFactory.getLogger(InotifyEventFetcher.class);
focal_class.type: Logger
focal_class.var_name: LOG
focal_class.declarator: ignoreEventDirs
focal_class.modifier: private
focal_class.original_string: private List<String> ignoreEventDirs;
focal_class.type: List<String>
focal_class.var_name: ignoreEventDirs
focal_class.declarator: fetchEventDirs
focal_class.modifier: private
focal_class.original_string: private List<String> fetchEventDirs;
focal_class.type: List<String>
focal_class.var_name: fetchEventDirs
focal_class.declarator: namespaceFetcher
focal_class.modifier: private
focal_class.original_string: private NamespaceFetcher namespaceFetcher;
focal_class.type: NamespaceFetcher
focal_class.var_name: namespaceFetcher
focal_class.file: smart-hadoop-support/smart-hadoop/src/main/java/org/smartdata/hdfs/metric/fetcher/InotifyEventApplier.java
focal_class.identifier: InotifyEventApplier
focal_class.class_method_signature: InotifyEventApplier.InotifyEventApplier(MetaStore metaStore, DFSClient client)
focal_class.full_signature: public  InotifyEventApplier(MetaStore metaStore, DFSClient client)
focal_class.identifier: InotifyEventApplier
focal_class.modifiers: public
focal_class.parameters: (MetaStore metaStore, DFSClient client)
focal_class.signature:  InotifyEventApplier(MetaStore metaStore, DFSClient client)
focal_class.class_method_signature: InotifyEventApplier.InotifyEventApplier(MetaStore metaStore, DFSClient client, NamespaceFetcher namespaceFetcher)
focal_class.full_signature: public  InotifyEventApplier(MetaStore metaStore, DFSClient client, NamespaceFetcher namespaceFetcher)
focal_class.identifier: InotifyEventApplier
focal_class.modifiers: public
focal_class.parameters: (MetaStore metaStore, DFSClient client, NamespaceFetcher namespaceFetcher)
focal_class.signature:  InotifyEventApplier(MetaStore metaStore, DFSClient client, NamespaceFetcher namespaceFetcher)
focal_class.class_method_signature: InotifyEventApplier.initialize()
focal_class.full_signature: private void initialize()
focal_class.identifier: initialize
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void initialize()
focal_class.class_method_signature: InotifyEventApplier.apply(List<Event> events)
focal_class.full_signature: public void apply(List<Event> events)
focal_class.identifier: apply
focal_class.modifiers: public
focal_class.parameters: (List<Event> events)
focal_class.return: void
focal_class.signature: void apply(List<Event> events)
focal_class.class_method_signature: InotifyEventApplier.apply(Event[] events)
focal_class.full_signature: public void apply(Event[] events)
focal_class.identifier: apply
focal_class.modifiers: public
focal_class.parameters: (Event[] events)
focal_class.return: void
focal_class.signature: void apply(Event[] events)
focal_class.class_method_signature: InotifyEventApplier.shouldIgnore(String path)
focal_class.full_signature: private boolean shouldIgnore(String path)
focal_class.identifier: shouldIgnore
focal_class.modifiers: private
focal_class.parameters: (String path)
focal_class.return: boolean
focal_class.signature: boolean shouldIgnore(String path)
focal_class.class_method_signature: InotifyEventApplier.getSqlStatement(Event event)
focal_class.full_signature: private List<String> getSqlStatement(Event event)
focal_class.identifier: getSqlStatement
focal_class.modifiers: private
focal_class.parameters: (Event event)
focal_class.return: List<String>
focal_class.signature: List<String> getSqlStatement(Event event)
focal_class.class_method_signature: InotifyEventApplier.getCreateSql(Event.CreateEvent createEvent)
focal_class.full_signature: private String getCreateSql(Event.CreateEvent createEvent)
focal_class.identifier: getCreateSql
focal_class.modifiers: private
focal_class.parameters: (Event.CreateEvent createEvent)
focal_class.return: String
focal_class.signature: String getCreateSql(Event.CreateEvent createEvent)
focal_class.class_method_signature: InotifyEventApplier.inBackup(String src)
focal_class.full_signature: private boolean inBackup(String src)
focal_class.identifier: inBackup
focal_class.modifiers: private
focal_class.parameters: (String src)
focal_class.return: boolean
focal_class.signature: boolean inBackup(String src)
focal_class.class_method_signature: InotifyEventApplier.getCloseSql(Event.CloseEvent closeEvent)
focal_class.full_signature: private String getCloseSql(Event.CloseEvent closeEvent)
focal_class.identifier: getCloseSql
focal_class.modifiers: private
focal_class.parameters: (Event.CloseEvent closeEvent)
focal_class.return: String
focal_class.signature: String getCloseSql(Event.CloseEvent closeEvent)
focal_class.class_method_signature: InotifyEventApplier.getRenameSql(Event.RenameEvent renameEvent)
focal_class.full_signature: private List<String> getRenameSql(Event.RenameEvent renameEvent)
focal_class.identifier: getRenameSql
focal_class.modifiers: private
focal_class.parameters: (Event.RenameEvent renameEvent)
focal_class.return: List<String>
focal_class.signature: List<String> getRenameSql(Event.RenameEvent renameEvent)
focal_class.class_method_signature: InotifyEventApplier.generateFileDiff(Event.RenameEvent renameEvent)
focal_class.full_signature: private void generateFileDiff(Event.RenameEvent renameEvent)
focal_class.identifier: generateFileDiff
focal_class.modifiers: private
focal_class.parameters: (Event.RenameEvent renameEvent)
focal_class.return: void
focal_class.signature: void generateFileDiff(Event.RenameEvent renameEvent)
focal_class.class_method_signature: InotifyEventApplier.getMetaDataUpdateSql(Event.MetadataUpdateEvent metadataUpdateEvent)
focal_class.full_signature: private String getMetaDataUpdateSql(Event.MetadataUpdateEvent metadataUpdateEvent)
focal_class.identifier: getMetaDataUpdateSql
focal_class.modifiers: private
focal_class.parameters: (Event.MetadataUpdateEvent metadataUpdateEvent)
focal_class.return: String
focal_class.signature: String getMetaDataUpdateSql(Event.MetadataUpdateEvent metadataUpdateEvent)
focal_class.class_method_signature: InotifyEventApplier.getAppendSql(Event.AppendEvent appendEvent)
focal_class.full_signature: private List<String> getAppendSql(Event.AppendEvent appendEvent)
focal_class.identifier: getAppendSql
focal_class.modifiers: private
focal_class.parameters: (Event.AppendEvent appendEvent)
focal_class.return: List<String>
focal_class.signature: List<String> getAppendSql(Event.AppendEvent appendEvent)
focal_class.class_method_signature: InotifyEventApplier.getUnlinkSql(Event.UnlinkEvent unlinkEvent)
focal_class.full_signature: private List<String> getUnlinkSql(Event.UnlinkEvent unlinkEvent)
focal_class.identifier: getUnlinkSql
focal_class.modifiers: private
focal_class.parameters: (Event.UnlinkEvent unlinkEvent)
focal_class.return: List<String>
focal_class.signature: List<String> getUnlinkSql(Event.UnlinkEvent unlinkEvent)
focal_class.class_method_signature: InotifyEventApplier.insertDeleteDiff(String path, boolean isDir)
focal_class.full_signature: private void insertDeleteDiff(String path, boolean isDir)
focal_class.identifier: insertDeleteDiff
focal_class.modifiers: private
focal_class.parameters: (String path, boolean isDir)
focal_class.return: void
focal_class.signature: void insertDeleteDiff(String path, boolean isDir)
focal_class.class_method_signature: InotifyEventApplier.insertDeleteDiff(String path)
focal_class.full_signature: private void insertDeleteDiff(String path)
focal_class.identifier: insertDeleteDiff
focal_class.modifiers: private
focal_class.parameters: (String path)
focal_class.return: void
focal_class.signature: void insertDeleteDiff(String path)
focal_class.class_method_signature: InotifyEventApplier.getFilesUnderDir(String dir)
focal_class.full_signature: private List<String> getFilesUnderDir(String dir)
focal_class.identifier: getFilesUnderDir
focal_class.modifiers: private
focal_class.parameters: (String dir)
focal_class.return: List<String>
focal_class.signature: List<String> getFilesUnderDir(String dir)
focal_class.class_method_signature: InotifyEventApplier.isUnderDir(String path, List<String> dirs)
focal_class.full_signature: private boolean isUnderDir(String path, List<String> dirs)
focal_class.identifier: isUnderDir
focal_class.modifiers: private
focal_class.parameters: (String path, List<String> dirs)
focal_class.return: boolean
focal_class.signature: boolean isUnderDir(String path, List<String> dirs)
focal_method.body: public void apply(List<Event> events) throws IOException, MetaStoreException, InterruptedException {
      List<String> statements = new ArrayList<>();
      for (Event event : events) {
        List<String> gen = getSqlStatement(event);
        if (gen != null && !gen.isEmpty()) {
          for (String s : gen) {
            if (s != null && s.length() > 0) {
              statements.add(s);
            }
          }
        }
      }
      this.metaStore.execute(statements);
    }
focal_method.class_method_signature: InotifyEventApplier.apply(List<Event> events)
focal_method.full_signature: public void apply(List<Event> events)
focal_method.identifier: apply
focal_method.invocations: getSqlStatement isEmpty length add execute
focal_method.modifiers: public
focal_method.parameters: (List<Event> events)
focal_method.return: void
focal_method.signature: void apply(List<Event> events)