Search in sources :

Example 91 with KeeperException

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.KeeperException 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 92 with KeeperException

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.KeeperException 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 93 with KeeperException

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.KeeperException 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 94 with KeeperException

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.KeeperException in project SilverKing by Morgan-Stanley.

the class DHTMetaWatcher method readRing.

// FIXME - think about zkidLimit
public void readRing(String ringName, long zkidLimit) throws KeeperException, IOException {
    com.ms.silverking.cloud.toporing.meta.MetaClient ringMC;
    // com.ms.silverking.cloud.meta.MetaClient             cloudMC;
    NamedRingConfiguration namedRingConfig;
    RingConfiguration ringConfig;
    InstantiatedRingTree ringTree;
    long ringConfigVersion;
    long configInstanceVersion;
    DHTMetaUpdate dhtMetaUpdate;
    int readAttemptIndex;
    int ringReadAttempts = 20;
    int ringReadRetryInvervalSeconds = 2;
    ZooKeeperExtended zk;
    // cloudMC = new com.ms.silverking.cloud.meta.MetaClient(ringConfig.getCloudConfiguration(),
    // zkConfig);
    zk = mc.getZooKeeper();
    // unresolved
    namedRingConfig = new NamedRingConfiguration(ringName, RingConfiguration.emptyTemplate);
    ringMC = new com.ms.silverking.cloud.toporing.meta.MetaClient(namedRingConfig, zkConfig);
    ringConfigVersion = zk.getVersionPriorTo(ringMC.getMetaPaths().getConfigPath(), zkidLimit);
    ringConfig = new RingConfigurationZK(ringMC).readFromZK(ringConfigVersion, null);
    // resolved
    namedRingConfig = new NamedRingConfiguration(ringName, ringConfig);
    ringMC = new com.ms.silverking.cloud.toporing.meta.MetaClient(namedRingConfig, zkConfig);
    if (enableLogging) {
        Log.warning("ringConfig\t", ringConfig);
    }
    configInstanceVersion = zk.getVersionPriorTo(ringMC.getMetaPaths().getConfigInstancePath(ringConfigVersion), zkidLimit);
    if (enableLogging) {
        Log.warning("configInstanceVersion: " + configInstanceVersion);
    }
    if (configInstanceVersion == -1) {
        configInstanceVersion = 0;
    }
    if (DHTConstants.isDaemon || Log.levelMet(Level.INFO)) {
        Log.warning("Waiting until valid " + ringMC.getMetaPaths().getConfigInstancePath(ringConfigVersion) + " " + configInstanceVersion);
    }
    SingleRingZK.waitUntilValid(ringMC, ringMC.getMetaPaths().getConfigInstancePath(ringConfigVersion), configInstanceVersion);
    if (DHTConstants.isDaemon || Log.levelMet(Level.INFO)) {
        Log.warning("Valid");
    }
    ringTree = null;
    readAttemptIndex = 0;
    while (ringTree == null) {
        try {
            // , weightsVersion);
            ringTree = SingleRingZK.readTree(ringMC, ringConfigVersion, configInstanceVersion);
        } catch (Exception e) {
            if (++readAttemptIndex >= ringReadAttempts) {
                throw new RuntimeException("Ring read failed", e);
            } else {
                ThreadUtil.sleepSeconds(ringReadRetryInvervalSeconds);
            }
        }
    }
    if (enableLogging) {
        Log.warning("\t\t###\t" + ringConfigVersion + "\t" + configInstanceVersion);
    }
    dhtMetaUpdate = new DHTMetaUpdate(dhtConfig, namedRingConfig, ringTree, mc);
    notifyListeners(dhtMetaUpdate);
// ringUpdateListener.newRingTree(new NamedRingConfiguration(ringName, ringConfig), ringTree);
// ringUpdateListener.newRingTree(ringTree.getMap(ringConfig.getRingParentName()));
}
Also used : RingConfigurationZK(com.ms.silverking.cloud.toporing.meta.RingConfigurationZK) NamedRingConfiguration(com.ms.silverking.cloud.toporing.meta.NamedRingConfiguration) ZooKeeperExtended(com.ms.silverking.cloud.zookeeper.ZooKeeperExtended) InstantiatedRingTree(com.ms.silverking.cloud.toporing.InstantiatedRingTree) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException) RingConfiguration(com.ms.silverking.cloud.toporing.meta.RingConfiguration) NamedRingConfiguration(com.ms.silverking.cloud.toporing.meta.NamedRingConfiguration)

Example 95 with KeeperException

use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.KeeperException in project SilverKing by Morgan-Stanley.

the class DaemonStateZK method waitForQuorumState.

public Map<IPAndPort, DaemonState> waitForQuorumState(Set<IPAndPort> members, DaemonState targetState, int inactiveNodeTimeoutSeconds, boolean exitOnTimeout) {
    boolean targetReached;
    int lastNotReadyCount;
    int notReadyCount;
    int inactiveCount;
    Stopwatch sw;
    Set<IPAndPort> incompleteMembers;
    incompleteMembers = new HashSet<>(members);
    if (verbose) {
        System.out.printf("Waiting for quorum state: %s\n", targetState);
    }
    sw = new SimpleStopwatch();
    lastNotReadyCount = Integer.MAX_VALUE;
    targetReached = false;
    randomAwait(0, minQuorumStatePollIntervalMillis);
    while (!targetReached) {
        StringBuilder sb;
        sb = new StringBuilder();
        try {
            if (mc.getZooKeeper().getState() == States.CONNECTED) {
                Map<IPAndPort, DaemonState> quorumState;
                Stopwatch qsSW;
                Set<IPAndPort> newlyCompleteMembers;
                Pair<Boolean, Map<IPAndPort, DaemonState>> rVal;
                boolean allRead;
                qsSW = new SimpleStopwatch();
                rVal = getQuorumState(incompleteMembers, targetState);
                qsSW.stop();
                Log.info("getQuorumState elapsed ", qsSW.getElapsedSeconds());
                allRead = rVal.getV1();
                quorumState = rVal.getV2();
                targetReached = true;
                notReadyCount = 0;
                inactiveCount = 0;
                newlyCompleteMembers = new HashSet<>();
                for (IPAndPort incompleteMember : incompleteMembers) {
                    DaemonState memberState;
                    memberState = quorumState.get(incompleteMember);
                    if (verbose && allRead) {
                        sb.append(String.format("%s\t%s\n", incompleteMember, memberState));
                    }
                    if (memberState == null) {
                        if (allRead) {
                            ++inactiveCount;
                            if ((int) sw.getSplitSeconds() < inactiveNodeTimeoutSeconds) {
                                ++notReadyCount;
                                targetReached = false;
                            } else {
                                sb.append(String.format("%s\t%s\tinactive node timed out\n", incompleteMember, memberState));
                                if (exitOnTimeout) {
                                    Map<IPAndPort, DaemonState> stateMap;
                                    System.out.print(sb);
                                    Log.warningf("Timeout: %s", incompleteMember);
                                    stateMap = fetchAndDisplayIncompleteState(incompleteMembers, targetState);
                                    return stateMap;
                                }
                            }
                        } else {
                            targetReached = false;
                        }
                    } else if (memberState.ordinal() < targetState.ordinal()) {
                        targetReached = false;
                        ++notReadyCount;
                    } else {
                        newlyCompleteMembers.add(incompleteMember);
                    }
                }
                incompleteMembers.removeAll(newlyCompleteMembers);
                if (verbose) {
                    if (allRead) {
                        if (notReadyCount != lastNotReadyCount) {
                            System.out.print(sb);
                        } else {
                            System.out.printf("Waiting for %d nodes\n", notReadyCount);
                        }
                    } else {
                        System.out.printf("waitForQuorumState > %d incomplete\n", maxIncompletePerFetch);
                    }
                }
                lastNotReadyCount = notReadyCount;
            }
        } catch (KeeperException ke) {
            Log.logErrorWarning(ke);
        }
        if (!targetReached) {
            int maxSleepMillis;
            if ((int) sw.getSplitSeconds() > inactiveNodeTimeoutSeconds) {
                if (exitOnTimeout) {
                    Map<IPAndPort, DaemonState> stateMap;
                    Log.warningf("Timeout in targetState: %s", targetState);
                    try {
                        stateMap = fetchAndDisplayIncompleteState(incompleteMembers, targetState);
                    } catch (KeeperException e) {
                        e.printStackTrace();
                        stateMap = ImmutableMap.of();
                    }
                    return stateMap;
                }
            }
            maxSleepMillis = (int) Math.max((double) maxQuorumStatePollIntervalMillis * ((double) incompleteMembers.size() / (double) maxQuorumStatePollThreshold), minQuorumStatePollIntervalMillis);
            maxSleepMillis = Math.min(maxSleepMillis, maxQuorumStatePollIntervalMillis);
            Log.info("waitForQuorumState maxSleepMillis: ", maxSleepMillis);
            expectedSignals = incompleteMembers.size();
            randomAwait(minQuorumStatePollIntervalMillis, maxSleepMillis);
            Log.info("waitForQuorumState awake");
        }
    }
    if (verbose) {
        System.out.printf("Quorum state reached: %s\n", targetState);
    }
    return ImmutableMap.of();
}
Also used : IPAndPort(com.ms.silverking.net.IPAndPort) Stopwatch(com.ms.silverking.time.Stopwatch) SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch) SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch) DaemonState(com.ms.silverking.cloud.dht.daemon.DaemonState) HashMap(java.util.HashMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) KeeperException(org.apache.zookeeper.KeeperException)

Aggregations

KeeperException (org.apache.zookeeper.KeeperException)566 IOException (java.io.IOException)188 Stat (org.apache.zookeeper.data.Stat)127 ZooKeeper (org.apache.zookeeper.ZooKeeper)87 ArrayList (java.util.ArrayList)51 NoNodeException (org.apache.zookeeper.KeeperException.NoNodeException)45 Watcher (org.apache.zookeeper.Watcher)39 WatchedEvent (org.apache.zookeeper.WatchedEvent)38 Test (org.junit.jupiter.api.Test)38 CountDownLatch (java.util.concurrent.CountDownLatch)30 SolrException (org.apache.solr.common.SolrException)30 HashMap (java.util.HashMap)29 List (java.util.List)28 ACL (org.apache.zookeeper.data.ACL)27 Test (org.junit.Test)27 HeliosRuntimeException (com.spotify.helios.common.HeliosRuntimeException)25 ServerName (org.apache.hadoop.hbase.ServerName)24 Map (java.util.Map)23 IZooReaderWriter (org.apache.accumulo.fate.zookeeper.IZooReaderWriter)23 InterruptedIOException (java.io.InterruptedIOException)20