use of com.ms.silverking.net.IPAndPort in project SilverKing by Morgan-Stanley.
the class RingMapState method createSecondarySet.
private Set<IPAndPort> createSecondarySet(Set<SecondaryTarget> secondaryTargets) {
ImmutableSet.Builder<IPAndPort> members;
members = ImmutableSet.builder();
for (SecondaryTarget target : secondaryTargets) {
Set<IPAndPort> targetReplicas;
switch(target.getType()) {
case NodeID:
targetReplicas = getTargetsByNodeID(target.getTarget());
break;
case AncestorClass:
targetReplicas = getTargetsByAncestorClass(target.getTarget());
break;
default:
throw new RuntimeException("Type not handled " + target.getType());
}
members.addAll(targetReplicas);
}
return members.build();
}
use of com.ms.silverking.net.IPAndPort in project SilverKing by Morgan-Stanley.
the class ReplicaHealthPrioritizer method main.
public static void main(String[] args) {
try {
PeerHealthMonitor p;
IPAndPort[] suspects;
IPAndPort[] replicas;
replicas = IPAndPort.list(ImmutableList.copyOf(StringUtil.splitAndTrim(args[0], ","))).toArray(new IPAndPort[0]);
suspects = IPAndPort.list(ImmutableList.copyOf(StringUtil.splitAndTrim(args[1], ","))).toArray(new IPAndPort[0]);
p = new PeerHealthMonitor(null, null);
for (IPAndPort suspect : suspects) {
p.addSuspect(suspect, PeerHealthIssue.OpTimeout);
}
Arrays.sort(replicas, new ReplicaHealthPrioritizer(p));
System.out.println(IPAndPort.arrayToString(replicas));
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.ms.silverking.net.IPAndPort in project SilverKing by Morgan-Stanley.
the class PeerHealthMonitor method addSuspect.
@Override
public void addSuspect(InetSocketAddress peer, Object rawCause) {
PeerHealthIssue issue;
if (rawCause instanceof PeerHealthIssue) {
issue = (PeerHealthIssue) rawCause;
} else if (rawCause instanceof SuspectProblem) {
switch((SuspectProblem) rawCause) {
case ConnectionEstablishmentFailed:
issue = PeerHealthIssue.CommunicationError;
break;
case CommunicationError:
issue = PeerHealthIssue.CommunicationError;
break;
default:
throw new RuntimeException("Panic");
}
} else {
throw new RuntimeException("Panic");
}
addSuspect(new IPAndPort(peer), issue);
}
use of com.ms.silverking.net.IPAndPort in project SilverKing by Morgan-Stanley.
the class ActiveProxyOperation method getFilteredSecondaryReplicas.
protected List<IPAndPort> getFilteredSecondaryReplicas(K entry, List<IPAndPort> primaryReplicas, List<IPAndPort> secondaryReplicas, OpCommunicator<K, R> comm, Set<SecondaryTarget> secondaryTargets) {
List<IPAndPort> filteredSecondaryReplicas;
if (forwardingMode.forwards()) {
if (secondaryTargets != null) {
Set<IPAndPort> secondarySet;
secondarySet = messageModule.getSecondarySet(secondaryTargets);
if (secondarySet.isEmpty()) {
filteredSecondaryReplicas = ImmutableList.of();
} else {
filteredSecondaryReplicas = new ArrayList<>(secondaryReplicas.size());
for (IPAndPort replica : secondaryReplicas) {
if (secondarySet.contains(replica)) {
filteredSecondaryReplicas.add(replica);
}
}
}
} else {
filteredSecondaryReplicas = secondaryReplicas;
}
} else {
filteredSecondaryReplicas = secondaryReplicas;
}
return filteredSecondaryReplicas;
}
use of com.ms.silverking.net.IPAndPort in project SilverKing by Morgan-Stanley.
the class ActiveProxyOperation method processInitialMessageEntries.
protected void processInitialMessageEntries(MessageGroup update, OpCommunicator<K, R> comm, Iterable<? extends K> iterable) {
if (debug) {
System.out.println("processInitialMessageEntries()");
}
for (K entry : iterable) {
PrimarySecondaryIPListPair listPair;
List<IPAndPort> primaryReplicas;
List<IPAndPort> secondaryReplicas;
// Find the replicas for this message entry
listPair = messageModule.getReplicaListPair(update.getContext(), entry, messageTypeToOwnerQueryOpType(update.getMessageType()));
primaryReplicas = listPair.getPrimaryOwners();
if (primaryReplicas.size() == 0) {
Log.warning(String.format("No primary replicas found for %s", KeyUtil.keyToString(entry)));
throw new RuntimeException("No primary replica found for " + KeyUtil.keyToString(entry));
}
secondaryReplicas = listPair.getSecondaryOwners();
if (debug) {
System.out.printf("primaryReplicas.size() %d\n", primaryReplicas.size());
}
// operation.processInitialMessageGroupEntry(entry, primaryReplicas, secondaryReplicas, comm);
processInitialMessageGroupEntry(entry, primaryReplicas, secondaryReplicas, comm);
}
}
Aggregations