Search in sources :

Example 6 with NamespaceNotCreatedException

use of com.ms.silverking.cloud.dht.daemon.storage.NamespaceNotCreatedException 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

NamespaceNotCreatedException (com.ms.silverking.cloud.dht.daemon.storage.NamespaceNotCreatedException)6 NamespaceOptions (com.ms.silverking.cloud.dht.NamespaceOptions)3 RetrievalException (com.ms.silverking.cloud.dht.client.RetrievalException)2 VersionConstraint (com.ms.silverking.cloud.dht.VersionConstraint)1 Namespace (com.ms.silverking.cloud.dht.client.Namespace)1 NamespaceCreationException (com.ms.silverking.cloud.dht.client.NamespaceCreationException)1 PutException (com.ms.silverking.cloud.dht.client.PutException)1 Context (com.ms.silverking.cloud.dht.common.Context)1 NamespaceProperties (com.ms.silverking.cloud.dht.common.NamespaceProperties)1