Search in sources :

Example 6 with RetrievalException

use of com.ms.silverking.cloud.dht.client.RetrievalException in project SilverKing by Morgan-Stanley.

the class NamespaceMetaStore method getNamespaceProperties.

// FUTURE - THINK ABOUT COMPLETELY REMOVING ANY READS/WRITES TO META NS FROM THE SERVER SIDE
// clients can probably do it all
public NamespaceProperties getNamespaceProperties(long namespace, NamespaceOptionsRetrievalMode retrievalMode) {
    try {
        NamespaceProperties nsProperties;
        nsProperties = nsPropertiesMap.get(namespace);
        if (nsProperties != null) {
            return nsProperties;
        } else {
            switch(retrievalMode) {
                case LocalCheckOnly:
                    return null;
                case FetchRemotely:
                    nsProperties = nsOptionsClient.getNamespaceProperties(namespace, nsOptionsFetchTimeoutMillis);
                    if (nsProperties != null) {
                        nsPropertiesMap.put(namespace, nsProperties);
                        return nsProperties;
                    } else {
                        Log.warning(String.format("Namespace not found %x", namespace));
                        Log.warning(getNamespaceMetaDataReplicas(namespace));
                        throw new NamespaceNotCreatedException(Long.toHexString(namespace));
                    }
                default:
                    throw new RuntimeException("Panic");
            }
        }
    } catch (TimeoutException te) {
        Log.warning("Failed to retrieve namespace due to timeout " + String.format("%x", namespace));
        Log.warning(getNamespaceMetaDataReplicas(namespace));
        throw new NamespaceNotCreatedException(Long.toHexString(namespace), te);
    } catch (RetrievalException re) {
        Log.warning("Failed to retrieve namespace " + String.format("%x", namespace));
        Log.warning(getNamespaceMetaDataReplicas(namespace));
        Log.warning(re.getDetailedFailureMessage());
        throw new NamespaceNotCreatedException(Long.toHexString(namespace), re);
    }
}
Also used : RetrievalException(com.ms.silverking.cloud.dht.client.RetrievalException) NamespaceNotCreatedException(com.ms.silverking.cloud.dht.daemon.storage.NamespaceNotCreatedException)

Aggregations

RetrievalException (com.ms.silverking.cloud.dht.client.RetrievalException)6 RetrievalOptions (com.ms.silverking.cloud.dht.RetrievalOptions)2 VersionConstraint (com.ms.silverking.cloud.dht.VersionConstraint)2 NamespaceNotCreatedException (com.ms.silverking.cloud.dht.daemon.storage.NamespaceNotCreatedException)2 AsyncValueRetrieval (com.ms.silverking.cloud.dht.client.AsyncValueRetrieval)1 NamespaceCreationException (com.ms.silverking.cloud.dht.client.NamespaceCreationException)1 OperationState (com.ms.silverking.cloud.dht.client.OperationState)1 PutException (com.ms.silverking.cloud.dht.client.PutException)1 StoredValue (com.ms.silverking.cloud.dht.client.StoredValue)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1