@Test public void FileHeuristic_should_update_delete_counter_for_every_FileEvent_delete_whatever_the_container() { DataAccessEventProtos.FsEvent event = newFsEvent(FsAction.DELETE); heuristic.compute("app_1", "att_1", "cid_1", event); assertThat(heuristic.deleted.forApp("app_1", "att_1").getCount(), is(1)); heuristic.compute("app_1", "att_1", "cid_2", event); assertThat(heuristic.deleted.forApp("app_1", "att_1").getCount(), is(2)); }
public void compute(String applicationId, String attemptId, String containerId, DataAccessEventProtos.FsEvent fsEvent) { try { FsAction action = FsAction.valueOf(fsEvent.getAction()); switch (action) { case DELETE: deleted.forApp(applicationId, attemptId).increment(); break; case READ: read.forApp(applicationId, attemptId).increment(); break; case WRITE: written.forApp(applicationId, attemptId).increment(); break; case RENAME: renamed.forApp(applicationId, attemptId).increment(); break; case APPEND: append.forApp(applicationId, attemptId).increment(); break; case ADD_BLOCK: addBlock.forApp(applicationId, attemptId).increment(); break; case LIST_STATUS: listStatus.forApp(applicationId, attemptId).increment(); break; case GET_CONTENT_SUMMARY: getContentSummary.forApp(applicationId, attemptId).increment(); break; default: throw new IllegalArgumentException("Received a non managed FsEvent.Action " + action.name()); } } catch (IllegalArgumentException ex) { if (LOGGER.isWarnEnabled()) { LOGGER.warn("received an unexpected FsEvent.Action {}", ex.getMessage()); } } }
FileHeuristic implements Heuristic { public void compute(String applicationId, String attemptId, String containerId, DataAccessEventProtos.FsEvent fsEvent) { try { FsAction action = FsAction.valueOf(fsEvent.getAction()); switch (action) { case DELETE: deleted.forApp(applicationId, attemptId).increment(); break; case READ: read.forApp(applicationId, attemptId).increment(); break; case WRITE: written.forApp(applicationId, attemptId).increment(); break; case RENAME: renamed.forApp(applicationId, attemptId).increment(); break; case APPEND: append.forApp(applicationId, attemptId).increment(); break; case ADD_BLOCK: addBlock.forApp(applicationId, attemptId).increment(); break; case LIST_STATUS: listStatus.forApp(applicationId, attemptId).increment(); break; case GET_CONTENT_SUMMARY: getContentSummary.forApp(applicationId, attemptId).increment(); break; default: throw new IllegalArgumentException("Received a non managed FsEvent.Action " + action.name()); } } catch (IllegalArgumentException ex) { if (LOGGER.isWarnEnabled()) { LOGGER.warn("received an unexpected FsEvent.Action {}", ex.getMessage()); } } } }
FileHeuristic implements Heuristic { public void compute(String applicationId, String attemptId, String containerId, DataAccessEventProtos.FsEvent fsEvent) { try { FsAction action = FsAction.valueOf(fsEvent.getAction()); switch (action) { case DELETE: deleted.forApp(applicationId, attemptId).increment(); break; case READ: read.forApp(applicationId, attemptId).increment(); break; case WRITE: written.forApp(applicationId, attemptId).increment(); break; case RENAME: renamed.forApp(applicationId, attemptId).increment(); break; case APPEND: append.forApp(applicationId, attemptId).increment(); break; case ADD_BLOCK: addBlock.forApp(applicationId, attemptId).increment(); break; case LIST_STATUS: listStatus.forApp(applicationId, attemptId).increment(); break; case GET_CONTENT_SUMMARY: getContentSummary.forApp(applicationId, attemptId).increment(); break; default: throw new IllegalArgumentException("Received a non managed FsEvent.Action " + action.name()); } } catch (IllegalArgumentException ex) { if (LOGGER.isWarnEnabled()) { LOGGER.warn("received an unexpected FsEvent.Action {}", ex.getMessage()); } } } FileHeuristic(HeuristicsResultDB db, int maxCreatedFiles); }
FileHeuristic implements Heuristic { public void compute(String applicationId, String attemptId, String containerId, DataAccessEventProtos.FsEvent fsEvent) { try { FsAction action = FsAction.valueOf(fsEvent.getAction()); switch (action) { case DELETE: deleted.forApp(applicationId, attemptId).increment(); break; case READ: read.forApp(applicationId, attemptId).increment(); break; case WRITE: written.forApp(applicationId, attemptId).increment(); break; case RENAME: renamed.forApp(applicationId, attemptId).increment(); break; case APPEND: append.forApp(applicationId, attemptId).increment(); break; case ADD_BLOCK: addBlock.forApp(applicationId, attemptId).increment(); break; case LIST_STATUS: listStatus.forApp(applicationId, attemptId).increment(); break; case GET_CONTENT_SUMMARY: getContentSummary.forApp(applicationId, attemptId).increment(); break; default: throw new IllegalArgumentException("Received a non managed FsEvent.Action " + action.name()); } } catch (IllegalArgumentException ex) { if (LOGGER.isWarnEnabled()) { LOGGER.warn("received an unexpected FsEvent.Action {}", ex.getMessage()); } } } FileHeuristic(HeuristicsResultDB db, int maxCreatedFiles); void compute(String applicationId, String attemptId, String containerId, DataAccessEventProtos.FsEvent fsEvent); @Override void onContainerCompleted(String applicationId, String attemptId, String containerId); @Override void onAppCompleted(String applicationId, String attemptId); @Override String getHelp(); }
FileHeuristic implements Heuristic { public void compute(String applicationId, String attemptId, String containerId, DataAccessEventProtos.FsEvent fsEvent) { try { FsAction action = FsAction.valueOf(fsEvent.getAction()); switch (action) { case DELETE: deleted.forApp(applicationId, attemptId).increment(); break; case READ: read.forApp(applicationId, attemptId).increment(); break; case WRITE: written.forApp(applicationId, attemptId).increment(); break; case RENAME: renamed.forApp(applicationId, attemptId).increment(); break; case APPEND: append.forApp(applicationId, attemptId).increment(); break; case ADD_BLOCK: addBlock.forApp(applicationId, attemptId).increment(); break; case LIST_STATUS: listStatus.forApp(applicationId, attemptId).increment(); break; case GET_CONTENT_SUMMARY: getContentSummary.forApp(applicationId, attemptId).increment(); break; default: throw new IllegalArgumentException("Received a non managed FsEvent.Action " + action.name()); } } catch (IllegalArgumentException ex) { if (LOGGER.isWarnEnabled()) { LOGGER.warn("received an unexpected FsEvent.Action {}", ex.getMessage()); } } } FileHeuristic(HeuristicsResultDB db, int maxCreatedFiles); void compute(String applicationId, String attemptId, String containerId, DataAccessEventProtos.FsEvent fsEvent); @Override void onContainerCompleted(String applicationId, String attemptId, String containerId); @Override void onAppCompleted(String applicationId, String attemptId); @Override String getHelp();  }