@Test public void testApplierCreateEvent() throws Exception { DFSClient client = Mockito.mock(DFSClient.class); InotifyEventApplier applier = new InotifyEventApplier(metaStore, client); BackUpInfo backUpInfo = new BackUpInfo(1L, "/file1", "remote/dest/", 10); metaStore.insertBackUpInfo(backUpInfo); HdfsFileStatus status1 = CompatibilityHelperLoader.getHelper().createHdfsFileStatus( 0, false, 2, 123, 0, 0, new FsPermission("777"), "test", "group", new byte[0], new byte[0], 1010, 0, null, (byte) 0); Mockito.when(client.getFileInfo("/file1")).thenReturn(status1); List<Event> events = new ArrayList<>(); Event.CreateEvent createEvent = new Event.CreateEvent.Builder().path("/file1").defaultBlockSize(123).ownerName("test") .replication(2).perms(new FsPermission(FsAction.NONE, FsAction.NONE, FsAction.NONE)).build(); events.add(createEvent); Mockito.when(client.getFileInfo("/file1")).thenReturn(status1); applier.apply(events); Assert.assertTrue(metaStore.getFile("/file1").getOwner().equals("test")); List<FileDiff> fileDiffs = metaStore.getFileDiffsByFileName("/file1"); Assert.assertTrue(fileDiffs.size() > 0); for (FileDiff fileDiff : fileDiffs) { if (fileDiff.getDiffType().equals(FileDiffType.APPEND)) { Assert.assertTrue(fileDiff.getParameters().get("-owner").equals("test")); } } }
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); }
InotifyEventApplier { 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); } }
InotifyEventApplier { 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); } InotifyEventApplier(MetaStore metaStore, DFSClient client);  InotifyEventApplier(MetaStore metaStore, DFSClient client, NamespaceFetcher namespaceFetcher); }
InotifyEventApplier { 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); } InotifyEventApplier(MetaStore metaStore, DFSClient client);  InotifyEventApplier(MetaStore metaStore, DFSClient client, NamespaceFetcher namespaceFetcher); void apply(List<Event> events); void apply(Event[] events); }
InotifyEventApplier { 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); } InotifyEventApplier(MetaStore metaStore, DFSClient client);  InotifyEventApplier(MetaStore metaStore, DFSClient client, NamespaceFetcher namespaceFetcher); void apply(List<Event> events); void apply(Event[] events);  }