OdpsHooks { public OdpsHooks() { try { synchronized (lock) { for (Class<? extends OdpsHook> hookClass : registeredHooks) { runningHooks.add(hookClass.newInstance()); } } } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } } OdpsHooks(); void before(Job job, Odps odps); void onInstanceCreated(Instance instance, Odps odps); void after(Instance instance, Odps odps); static void registerHooks(Collection<Class<? extends OdpsHook>> hooks); static void registerHook(Class<? extends OdpsHook> hook); @Deprecated static List<Class<? extends OdpsHook>> getRegisteredHooks(); static void clearRegisteredHooks(); static boolean isEnabled(); static void setEnabled(boolean enabled);  }
@Test public void testOdpsHooks() throws OdpsException { OdpsHooks.registerHook(TestHook.class); Instance i = SQLTask.run(odps, "select count(*) from " + TABLE_NAME + ";"); i.waitForSuccess(); assertTrue(beforeDone); assertTrue(afterDone); assertTrue(onInstanceCreatedDone); }