private void innerRegister(RoutingModel model) { boolean exists = false; do { try { _zk.createTempSeq(model.getKey(), model2Bytes(model)); _tracer.info("RouteModel has been registered.\r\n" + model.toString()); exists = false; } catch (KeeperException.NodeExistsException ex) { if (ex.code() == Code.NODEEXISTS) { exists = true; _tracer.error("Node is exist.", ex); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } } else { exists = false; } } catch (Throwable t) { _tracer.error("DynamicRouting.onConnected error.", t); exists = false; } } while (exists); }
public static void initialize(String conn, String userName, String password) { try { _instance = new DynamicRouting(conn, userName, password); } catch (Throwable t) { _tracer.error("DynamicRouting.static error.", t); } }
@Override public synchronized void onConnected(boolean newSession) { _isConnected = true; if (!newSession) { _tracer.info(getRoutingList()); return; } for (RoutingModel model : _myModels) innerRegister(model); if (_myModels.size() == 0) { try { _zk.fireDataChanged(); } catch (Throwable t) { _tracer.error("DynamicRouting.onConnected error.", t); } } }