Search in sources :

Example 11 with IPAndPort

use of com.ms.silverking.net.IPAndPort in project SilverKing by Morgan-Stanley.

the class SystemNamespaceStore method getAllReplicasFreeSystemDiskBytesEstimate.

private byte[] getAllReplicasFreeSystemDiskBytesEstimate() {
    List<Pair<IPAndPort, Long>> results;
    Map<IPAndPort, NodeInfo> nodeInfo;
    results = new ArrayList<>();
    try {
        nodeInfo = getAllNodeInfo();
        for (IPAndPort node : ringMaster.getAllCurrentReplicaServers()) {
            NodeInfo info;
            info = nodeInfo.get(node);
            if (info != null) {
                long freeSystemBytesEstimate;
                freeSystemBytesEstimate = (long) ((double) info.getFSFreeBytes() / ringMaster.getCurrentOwnedFraction(node, OwnerQueryMode.Primary));
                results.add(new Pair<>(node, freeSystemBytesEstimate));
            }
        }
    } catch (KeeperException ke) {
        Log.logErrorWarning(ke);
    }
    return pairedResultsToBytes(results);
}
Also used : IPAndPort(com.ms.silverking.net.IPAndPort) NodeInfo(com.ms.silverking.cloud.dht.daemon.NodeInfo) KeeperException(org.apache.zookeeper.KeeperException) Pair(com.ms.silverking.collection.Pair)

Example 12 with IPAndPort

use of com.ms.silverking.net.IPAndPort in project SilverKing by Morgan-Stanley.

the class SystemNamespaceStore method getAllReplicasFreeDiskBytes.

private byte[] getAllReplicasFreeDiskBytes() {
    List<Pair<IPAndPort, Long>> results;
    Map<IPAndPort, NodeInfo> nodeInfo;
    results = new ArrayList<>();
    try {
        nodeInfo = getAllNodeInfo();
        for (IPAndPort node : ringMaster.getAllCurrentReplicaServers()) {
            NodeInfo info;
            info = nodeInfo.get(node);
            if (info != null) {
                results.add(new Pair<>(node, info.getFSFreeBytes()));
            }
        }
    } catch (KeeperException ke) {
        Log.logErrorWarning(ke);
    }
    return pairedResultsToBytes(results);
}
Also used : IPAndPort(com.ms.silverking.net.IPAndPort) NodeInfo(com.ms.silverking.cloud.dht.daemon.NodeInfo) KeeperException(org.apache.zookeeper.KeeperException) Pair(com.ms.silverking.collection.Pair)

Example 13 with IPAndPort

use of com.ms.silverking.net.IPAndPort in project SilverKing by Morgan-Stanley.

the class SKAdmin method _getActiveDaemons.

private Pair<Boolean, Set<IPAndPort>> _getActiveDaemons() {
    try {
        Set<IPAndPort> activeDaemons;
        activeDaemons = suspectsZK.readActiveNodesFromZK();
        for (IPAndPort daemon : activeDaemons) {
            System.out.printf("%s\n", daemon.getIPAsString());
        }
        return new Pair<>(true, activeDaemons);
    } catch (KeeperException ke) {
        Log.logErrorWarning(ke);
        return new Pair(false, ImmutableSet.of());
    }
}
Also used : IPAndPort(com.ms.silverking.net.IPAndPort) KeeperException(org.apache.zookeeper.KeeperException) Pair(com.ms.silverking.collection.Pair)

Example 14 with IPAndPort

use of com.ms.silverking.net.IPAndPort in project SilverKing by Morgan-Stanley.

the class ComputeRingStats method generateLostServers.

private Set<IPAndPort> generateLostServers(int s) {
    Set<IPAndPort> lostServers;
    // Currently a simple algorithm appropriate only when s <<< |replicas|
    lostServers = new HashSet<>();
    while (lostServers.size() < s) {
        int index;
        IPAndPort replica;
        index = ThreadLocalRandom.current().nextInt(replicas.size());
        replica = replicas.get(index);
        if (!lostServers.contains(replica)) {
            lostServers.add(replica);
        }
    }
    return lostServers;
}
Also used : IPAndPort(com.ms.silverking.net.IPAndPort)

Example 15 with IPAndPort

use of com.ms.silverking.net.IPAndPort in project SilverKing by Morgan-Stanley.

the class ComputeRingStats method lostData.

public boolean lostData(Set<IPAndPort> lostServers) {
    // out.println(lostServers);
    for (Set<IPAndPort> replicaSet : this.sMap.getReplicaSets()) {
        boolean lost;
        lost = true;
        // out.println(replicaSet);
        for (IPAndPort replica : replicaSet) {
            // out.println(replica);
            if (!lostServers.contains(replica)) {
                lost = false;
                break;
            }
        }
        if (lost) {
            return true;
        }
    }
    return false;
}
Also used : IPAndPort(com.ms.silverking.net.IPAndPort)

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