Search in sources :

Example 1 with NamespaceNotCreatedException

use of com.ms.silverking.cloud.dht.daemon.storage.NamespaceNotCreatedException in project SilverKing by Morgan-Stanley.

the class NamespaceOptionsClient method verifyNamespaceProperties.

private boolean verifyNamespaceProperties(long namespace, NamespaceProperties nsProperties) throws RetrievalException {
    NamespaceOptions existingProperties;
    if (debug) {
        System.out.printf("verifyNamespaceProperties(%x, %s)\n", namespace, nsProperties);
    }
    existingProperties = getNamespaceOptions(namespace);
    if (debug) {
        System.out.println("Done verifyNamespaceProperties");
    }
    if (existingProperties == null) {
        throw new NamespaceNotCreatedException("No existing properties found");
    }
    return existingProperties.equals(nsProperties);
}
Also used : NamespaceOptions(com.ms.silverking.cloud.dht.NamespaceOptions) NamespaceNotCreatedException(com.ms.silverking.cloud.dht.daemon.storage.NamespaceNotCreatedException)

Example 2 with NamespaceNotCreatedException

use of com.ms.silverking.cloud.dht.daemon.storage.NamespaceNotCreatedException in project SilverKing by Morgan-Stanley.

the class SilverKingClient method doGetNamespaceOptions.

private void doGetNamespaceOptions(String[] args) throws OperationException, IOException {
    String name;
    NamespaceOptions nsOptions;
    opMessage("Getting namespace options");
    name = args[0];
    nsOptions = null;
    sw.reset();
    for (int i = 0; i < reps; i++) {
        try {
            nsOptions = session.getNamespace(name).getOptions();
        } catch (NamespaceNotCreatedException nnce) {
            err.printf("No such namespace: %s\n", name);
        }
    }
    sw.stop();
    if (nsOptions != null) {
        out.println(nsOptions);
    }
}
Also used : NamespaceOptions(com.ms.silverking.cloud.dht.NamespaceOptions) NamespaceNotCreatedException(com.ms.silverking.cloud.dht.daemon.storage.NamespaceNotCreatedException) VersionConstraint(com.ms.silverking.cloud.dht.VersionConstraint)

Example 3 with NamespaceNotCreatedException

use of com.ms.silverking.cloud.dht.daemon.storage.NamespaceNotCreatedException in project SilverKing by Morgan-Stanley.

the class SilverKingClient method doSetNamespace.

private void doSetNamespace(String[] args) {
    SynchronousNamespacePerspective<String, byte[]> _syncNSP;
    String namespace;
    namespace = args[0];
    out.printf("Setting namespace to \"%s\"\n", namespace);
    _syncNSP = syncNSP;
    try {
        Namespace ns;
        NamespacePerspectiveOptions<String, byte[]> nspOptions;
        ns = session.getNamespace(namespace);
        if (args.length > 1) {
            nspOptions = ns.getDefaultNSPOptions(String.class, byte[].class);
            nspOptions = nspOptions.parse(args[1]);
        } else {
            nspOptions = ns.getDefaultNSPOptions(String.class, byte[].class);
        }
        syncNSP = null;
        syncNSP = ns.openSyncPerspective(nspOptions);
    } catch (NamespaceNotCreatedException nnce) {
        err.printf("No such namespace: %s\n", namespace);
    }
    if (syncNSP == null && _syncNSP != null) {
        syncNSP = _syncNSP;
        err.printf("Setting namespace back to: %s\n", syncNSP.getName());
    }
}
Also used : NamespaceNotCreatedException(com.ms.silverking.cloud.dht.daemon.storage.NamespaceNotCreatedException) Namespace(com.ms.silverking.cloud.dht.client.Namespace)

Example 4 with NamespaceNotCreatedException

use of com.ms.silverking.cloud.dht.daemon.storage.NamespaceNotCreatedException in project SilverKing by Morgan-Stanley.

the class DHTSessionImpl method getClientNamespace.

private ClientNamespace getClientNamespace(String namespace) {
    ClientNamespace clientNamespace;
    Context context;
    context = namespaceCreator.createNamespace(namespace);
    clientNamespace = clientNamespaces.get(context.contextAsLong());
    if (clientNamespace == null) {
        ClientNamespace previous;
        NamespaceProperties nsProperties;
        NamespaceOptions nsOptions;
        ClientNamespace parent;
        NamespaceLinkMeta nsLinkMeta;
        nsProperties = getNamespaceProperties(namespace);
        if (nsProperties == null) {
            throw new NamespaceNotCreatedException(namespace);
        }
        nsOptions = nsProperties.getOptions();
        if (nsProperties.getParent() != null) {
            parent = getClientNamespace(nsProperties.getParent());
        } else {
            parent = null;
        }
        if (nsOptions.getAllowLinks() && nsOptions.getVersionMode() == NamespaceVersionMode.SINGLE_VERSION) {
            nsLinkMeta = getNSLinkMeta();
        } else {
            nsLinkMeta = null;
        }
        clientNamespace = new ClientNamespace(this, namespace, nsOptions, serializationRegistry, absMillisTimeSource, server, parent, nsLinkMeta);
        previous = clientNamespaces.putIfAbsent(context.contextAsLong(), clientNamespace);
        if (previous != null) {
            clientNamespace = previous;
        } else {
            if (Log.levelMet(Level.INFO)) {
                Log.info("Created client namespace: " + namespace + " " + context);
            }
            clientNamespaceList.add(clientNamespace);
        }
    }
    return clientNamespace;
}
Also used : Context(com.ms.silverking.cloud.dht.common.Context) NamespaceOptions(com.ms.silverking.cloud.dht.NamespaceOptions) NamespaceProperties(com.ms.silverking.cloud.dht.common.NamespaceProperties) NamespaceNotCreatedException(com.ms.silverking.cloud.dht.daemon.storage.NamespaceNotCreatedException)

Example 5 with NamespaceNotCreatedException

use of com.ms.silverking.cloud.dht.daemon.storage.NamespaceNotCreatedException in project SilverKing by Morgan-Stanley.

the class NamespaceOptionsClient method storeNamespaceProperties.

public void storeNamespaceProperties(long namespace, NamespaceProperties nsProperties) throws NamespaceCreationException {
    boolean retry;
    retry = false;
    do {
        NamespaceProperties existingProperties;
        try {
            existingProperties = getNamespaceProperties(namespace, seTimeoutController.getMaxRelativeTimeoutMillis(null));
        } catch (TimeoutException te) {
            Log.warning("Failed to store namespace due to timeout " + String.format("%x", namespace));
            throw new NamespaceCreationException(Long.toHexString(namespace), te);
        } catch (RetrievalException re) {
            Log.warning(re.getDetailedFailureMessage());
            throw new NamespaceCreationException("RetrievalException during first property check", re);
        }
        if (existingProperties != null) {
            if (!existingProperties.equals(nsProperties)) {
                Log.warning("existingProperties", existingProperties);
                Log.warning("nsProperties", nsProperties);
                throw new NamespaceCreationException("Namespace already created with incompatible properties");
            } else {
            // Already created with the same options. No further action required.
            }
        } else {
            try {
                if (debug) {
                    System.out.printf("storeNamespaceProperties(%x, %s)\n", namespace, nsProperties);
                }
                syncNSP.put(getOptionsKey(namespace), nsProperties.toString());
                if (debug) {
                    System.out.println("Done storeNamespaceOptions");
                }
            } catch (PutException pe) {
                // For other errors, we try this also on the
                try {
                    boolean optionsMatch;
                    try {
                        optionsMatch = verifyNamespaceProperties(namespace, nsProperties);
                        if (!optionsMatch) {
                            throw new NamespaceCreationException("Namespace already created with incompatible properties");
                        }
                    } catch (NamespaceNotCreatedException nnce) {
                        // Should not be possible any more, but leave old retry in for now.
                        retry = true;
                    } catch (RuntimeException re) {
                        Log.logErrorWarning(re);
                        Log.warning(pe.getDetailedFailureMessage());
                        Log.logErrorWarning(pe, "Couldn't store options due to exception");
                    }
                } catch (RetrievalException re) {
                    Log.warning("storeNamespaceProperties failing");
                    Log.warning("PutException");
                    pe.printStackTrace();
                    Log.warning("RetrievalException");
                    re.printStackTrace();
                    throw new NamespaceCreationException(re);
                }
            }
        }
    } while (retry);
}
Also used : PutException(com.ms.silverking.cloud.dht.client.PutException) RetrievalException(com.ms.silverking.cloud.dht.client.RetrievalException) NamespaceNotCreatedException(com.ms.silverking.cloud.dht.daemon.storage.NamespaceNotCreatedException) NamespaceCreationException(com.ms.silverking.cloud.dht.client.NamespaceCreationException)

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