private void sendActionToShard(String shardId, Action action, Object... args) { config.getMembersInShard(shardId).forEach(m -> sendAction(m.getMemberId(), action, args)); }
for (Config.ConfigMember member : config.getMembersInHost(hostId)) { try { trace("[{}-{}] Initializing zookeeper node...", gondola.getHostId(), member.getMemberId()); String actionPath = actionPath(serviceName, member.getMemberId()); String statPath = statPath(serviceName, member.getMemberId()); ZookeeperStat stat; ZookeeperAction action; } catch (Exception e) { stat = new ZookeeperStat(); stat.memberId = member.getMemberId(); stat.shardId = member.getShardId(); client.create().creatingParentContainersIfNeeded() } catch (Exception e) { action = new ZookeeperAction(); action.memberId = member.getMemberId(); client.create().creatingParentContainersIfNeeded() .forPath(actionPath, objectMapper.writeValueAsBytes(action)); currentStats.put(member.getMemberId(), stat); processAction(action); NodeCache node = new NodeCache(client, actionPath); } catch (Exception e) { logger.warn("[{}-{}] Unable to create member node, msg={}", gondola.getHostId(), member.getMemberId(), e.getMessage(), e);
if (m.getMemberId() == channel.getRemoteMemberId()) { logger.info("[{}-{}] Slave request from {} rejected: in the same shard", gondola.getHostId(), memberId, channel.getRemoteMemberId());
/** * Starts observer mode to remote shard. */ @Override public void startObserving(String shardId, String observedShardId, long timeoutMs) throws ShardManagerException, InterruptedException { boolean success = false; trace("[{}-{}] Try to follow shardId={} as slave...", gondola.getHostId(), gondola.getShard(shardId).getLocalMember().getMemberId(), observedShardId); List<Config.ConfigMember> membersInShard = config.getMembersInShard(observedShardId); for (Config.ConfigMember m : membersInShard) { if (success = setSlave(shardId, m.getMemberId(), timeoutMs / membersInShard.size())) { filter.getChangeLogProcessor().reset(shardId); trace("[{}-{}] Successfully to follow masterId={}", gondola.getHostId(), gondola.getShard(shardId).getLocalMember().getMemberId(), m.getMemberId()); break; } } if (!success) { logger.error("[{}-{}] Failed follow master={}", gondola.getHostId(), gondola.getShard(shardId).getLocalMember().getMemberId(), observedShardId); throw new ShardManagerException(FAILED_START_SLAVE); } observedShards.add(observedShardId); }
private void sendActionToAll(Action action, Object... args) { for (Config.ConfigMember m : config.getMembers()) { sendAction(m.getMemberId(), action, args); } }