WorkerRegister extends Configured { public static WorkerRegister getWorkerRegister(Configuration conf) throws IOException { String workerRegisterCls = conf.get(TransactionConstant.WORKER_REGISTER_CLASS_KEY, TransactionConstant.DEFAULT_WORKER_REISTER_CLASS); if (register == null) { synchronized (registerLock) { if (register == null) { try { register = (WorkerRegister) (Class.forName(workerRegisterCls).getConstructor(Configuration.class) .newInstance(conf)); } catch (Exception e) { LOG.fatal("create workerRegister fail", e); throw new IOException(e); } } } } return register; } WorkerRegister(Configuration conf); static WorkerRegister getWorkerRegister(Configuration conf); boolean registerWorker(); abstract void doRegisterWorker(); abstract boolean isWorkerAlive(String clientAddress); abstract String getClientAddress();  }
@Test public void testCreateSingletonRegister() throws IOException { WorkerRegister register = WorkerRegister.getWorkerRegister(conf); Assert.assertSame(register, WorkerRegister.getWorkerRegister(conf)); }