@Override public List<NetEndpoint> getReplicationEndpoints(Set<NetEndpoint> oldReplicationEndpoints, Set<NetEndpoint> candidateEndpoints) { return NetEndpointManagerHolder.get().getReplicationEndpoints(this, oldReplicationEndpoints, candidateEndpoints); } }
@Override public ReplicationSession createReplicationSession(Session session, Collection<NetEndpoint> replicationEndpoints, Boolean remote) { return NetEndpointManagerHolder.get().createReplicationSession(session, replicationEndpoints, remote); }
@Override public ReplicationSession createReplicationSession(Session session, Collection<NetEndpoint> replicationEndpoints) { return NetEndpointManagerHolder.get().createReplicationSession(session, replicationEndpoints); }
@Override public String getHostId(NetEndpoint endpoint) { return NetEndpointManagerHolder.get().getHostId(endpoint); }
@Override public NetEndpoint getEndpoint(String hostId) { return NetEndpointManagerHolder.get().getEndpoint(hostId); }
private void rewriteSql(boolean toReplicationMode) { if (session.isRoot()) { oldHostIds = db.getHostIds(); if (parameters != null && parameters.containsKey("hostIds")) { newHostIds = StringUtils.arraySplit(parameters.get("hostIds"), ',', true); } else { if (toReplicationMode) newHostIds = NetEndpointManagerHolder.get().getReplicationEndpoints(db); else newHostIds = NetEndpointManagerHolder.get().getShardingEndpoints(db); } String hostIds = StringUtils.arrayCombine(oldHostIds, ',') + "," + StringUtils.arrayCombine(newHostIds, ','); db.getParameters().put("hostIds", hostIds); rewriteSql(); } else { if (super.isTargetEndpoint(db)) { oldHostIds = db.getHostIds(); HashSet<String> oldSet = new HashSet<>(Arrays.asList(oldHostIds)); if (parameters != null && parameters.containsKey("hostIds")) { String[] hostIds = StringUtils.arraySplit(parameters.get("hostIds"), ',', true); HashSet<String> newSet = new HashSet<>(Arrays.asList(hostIds)); newSet.removeAll(oldSet); newHostIds = newSet.toArray(new String[0]); } else { DbException.throwInternalError(); } } } }
public static int executeDatabaseStatement(IDatabase db, Session currentSession, StatementBase statement) { NetEndpointManager m = NetEndpointManagerHolder.get(); Set<NetEndpoint> liveMembers = m.getLiveEndpoints(); NetEndpoint localEndpoint = NetEndpoint.getLocalP2pEndpoint();
private static int executeDefineStatement(StatementBase defineStatement) { NetEndpointManager m = NetEndpointManagerHolder.get(); Set<NetEndpoint> liveMembers; Session currentSession = defineStatement.getSession();
newDB.setRunMode(runMode); if (!parameters.containsKey("hostIds")) { String[] hostIds = NetEndpointManagerHolder.get().assignEndpoints(newDB); if (hostIds != null && hostIds.length > 0) newDB.getParameters().put("hostIds", StringUtils.arrayCombine(hostIds, ','));