Search in sources :

Example 26 with IPAndPort

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();
}
Also used : SecondaryTarget(com.ms.silverking.cloud.dht.SecondaryTarget) IPAndPort(com.ms.silverking.net.IPAndPort) ImmutableSet(com.google.common.collect.ImmutableSet)

Example 27 with IPAndPort

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();
    }
}
Also used : IPAndPort(com.ms.silverking.net.IPAndPort)

Example 28 with IPAndPort

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);
}
Also used : IPAndPort(com.ms.silverking.net.IPAndPort) SuspectProblem(com.ms.silverking.net.async.SuspectProblem)

Example 29 with IPAndPort

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;
}
Also used : IPAndPort(com.ms.silverking.net.IPAndPort)

Example 30 with IPAndPort

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);
    }
}
Also used : IPAndPort(com.ms.silverking.net.IPAndPort) PrimarySecondaryIPListPair(com.ms.silverking.cloud.toporing.PrimarySecondaryIPListPair)

Aggregations

IPAndPort (com.ms.silverking.net.IPAndPort)71 ImmutableSet (com.google.common.collect.ImmutableSet)9 KeeperException (org.apache.zookeeper.KeeperException)7 DaemonState (com.ms.silverking.cloud.dht.daemon.DaemonState)5 ExclusionSet (com.ms.silverking.cloud.meta.ExclusionSet)5 Node (com.ms.silverking.cloud.topology.Node)5 Pair (com.ms.silverking.collection.Pair)5 RingRegion (com.ms.silverking.cloud.ring.RingRegion)4 IOException (java.io.IOException)4 DHTNode (com.ms.silverking.cloud.dht.daemon.DHTNode)3 NodeInfo (com.ms.silverking.cloud.dht.daemon.NodeInfo)3 ConvergencePoint (com.ms.silverking.cloud.dht.daemon.storage.convergence.ConvergencePoint)3 RingEntry (com.ms.silverking.cloud.toporing.RingEntry)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Map (java.util.Map)3 Set (java.util.Set)3 ImmutableList (com.google.common.collect.ImmutableList)2