Package org.nimbustools.ctxbroker

Examples of org.nimbustools.ctxbroker.ContextBrokerException


        if (ctxDocAndID == null) {
            final String err = "A previously unknown workspace's context " +
                    "agent is invoking " +
                    "an operation before retrieve, we cannot register it.\n" +
                    "Identity dump: " + this.identitiesDump(identities);
            throw new ContextBrokerException(err);
        }

        if (workspaceID == null) {
            throw new IllegalArgumentException("workspaceID may not be null");
        }

        if (identities.length > 2 || identities.length == 0) {
            throw new ContextBrokerException(
                 "these arbitrary identities are not supported at the moment," +
                         "you may only use 1 or 2 NICs");
        }

        Cloudcluster_Type cluster = ctxDocAndID.getCluster();
View Full Code Here


                                                   boolean allowInjections)

            throws ContextBrokerException {

        if (!this.initialized) {
            throw new ContextBrokerException(
                    ContextBrokerHomeImpl.class.getName() +
                            " not initialized.");
        }

        final ContextBrokerResource resource;
        try {
            resource = (ContextBrokerResource)createNewInstance();
        } catch (Exception e) {
            throw new ContextBrokerException("", e);
        }

        final String uuid = this.uuidGen.nextUUID();
        resource.setID(uuid);

        resource.setAllowInjections(allowInjections);


        // TODO: make this limit configurable and/or possibly make a dynamic
        //       decision.  For example, if the scheduler is NOT best effort
        //       then it is probably OK to just make this expire in a day or
        //       even an hour.  Also, if re-contextualization is implemented,
        //       presumbaly the VMs (for now) would contact with same cred
        //       so expiration will affect things in that situation
        final Calendar expires = Calendar.getInstance();
    expires.add(Calendar.MONTH, 1);
       
        final BootstrapInformation bootstrap =
                this.bootstrapFactory.newBootstrap(uuid,
                                                   this.serviceAddress,
                                                   expires);

        resource.setBootstrap(bootstrap);

        // in the future, policy should come from elsewhere
        try {
            resource.initSecureResource(callerDN, bootstrap.getBootstrapDN());
        } catch (ConfigException e) {
            throw new ContextBrokerException("", e);
        }

        logger.info("WS-CTX created new contextualization " +
                    "resource: '" + uuid + "' for DN = '" + callerDN + "'");
View Full Code Here

        try {
            return (ContextBrokerResource) this.find(ctxKey);
        } catch (ResourceException e) {
            String msg = "Cannot find contextualization resource: '" +
                          getID(ctxKey) + "'";
            throw new ContextBrokerException(msg, e);
        }
    }
View Full Code Here

        try {
            resource = (ContextBrokerResource) this.find(ctxKey);
        } catch (ResourceException e) {
            String msg = "Cannot find contextualization resource: '" +
                          getID(ctxKey) + "'";
            throw new ContextBrokerException(msg, e);
        }

        return resource;
    }
View Full Code Here

    private int clusterSanityAndCount(Cloudcluster_Type cluster)
            throws ContextBrokerException {
       
        if (cluster == null) {
            throw new ContextBrokerException("Invalid cluster description " +
                    "section, <cluster> is missing.");
        }

        Cloudworkspace_Type[] vms = cluster.getWorkspace();
        if (vms == null || vms.length == 0) {
            throw new ContextBrokerException("Invalid cluster description " +
                    "section, missing workspace elements.");
        }

        int totalNodeCount = 0;

        int numActive = 0;
        for (Cloudworkspace_Type vm : vms) {

            if (vm == null) {
                throw new ContextBrokerException(
                        "Invalid cluster description section, missing a " +
                                "workspace element in array.");
            }
           
            if (vm.getCtx() == null) {
                throw new ContextBrokerException(
                        "Invalid cluster description section, missing a " +
                                "ctx element in the workspace list.");
            }

            if (vm.getQuantity() <= 0) {
                throw new ContextBrokerException(
                        "Invalid cluster description section, missing " +
                                "quantity.");
            }

            totalNodeCount += vm.getQuantity();

            // active can be null which equals False
            final Boolean active = vm.getActive();
            if (Boolean.TRUE.equals(active)) {
                numActive += 1;
            }
        }

        if (numActive < 1) {
            throw new ContextBrokerException(
                        "Invalid cluster description, there is no " +
                                "section marked with <active>");
        }

        if (numActive > 1) {
            throw new ContextBrokerException(
                        "Invalid cluster description, more than one " +
                                "section is marked with <active> (there are " +
                                numActive + " marked active)");
        }
View Full Code Here

       
        Provides_Type provides = ctx.getProvides();
        Requires_Type requires = ctx.getRequires();

        if (provides == null && requires == null) {
            throw new ContextBrokerException("Both provides and " +
                    "requires are missing. Will not contextualize this. " +
                    "If there is nothing to do, do not include " +
                    "contextualization document.");
        }

        if (provides != null) {
            IdentityProvides_Type[] givenIDs = provides.getIdentity();
            if (givenIDs == null || givenIDs.length == 0) {
                throw new ContextBrokerException("Provides section is " +
                        "present but has no identity elements.  Will not " +
                        "contextualize.");
            }
        }

        if (requires == null) {
            return;
        }

        Requires_TypeIdentity[] givenID = requires.getIdentity();

        if (givenID == null || givenID.length == 0) {
            return;
        }
       
        // next two exceptions are for forwards compatibility where it
        // may be possible to specify specific identities required
        // (without going through role finding which will always place
        // identities in the filled requires document for a role,
        // regardless if all identities are required or not).

        if (givenID.length > 1) {
            throw new ContextBrokerException("Given requires " +
                    "section has multiple identity elements? Currently " +
                    "only supporting zero or one empty identity element " +
                    "in requires section (which signals all identities " +
                    "are desired).  Will not contextualize.");
        }

        if (givenID[0].getHostname() != null ||
            givenID[0].getIp() != null ||
            givenID[0].getPubkey() != null) {

            throw new ContextBrokerException("Given requires " +
                    "section has an identity element with information " +
                    "in it? Currently only supporting zero or one " +
                    "*empty* identity element in requires section " +
                    "(which signals all identities are desired).  Will " +
                    "not contextualize.");
View Full Code Here

        final EndpointReferenceType epr;
        try {
            epr = AddressingUtils.createEndpointReference(
                                        this.serviceAddress, key);
        } catch (Exception exp) {
            throw new ContextBrokerException("Error creating " +
                    "contextualization endpoint reference", exp);
        }
        return epr;
    }
View Full Code Here

    public String getID(EndpointReferenceType epr)
            throws ContextBrokerException {

        if (epr == null) {
            throw new ContextBrokerException("epr is null");
        }

        if (epr.getProperties() == null) {
            throw new ContextBrokerException("epr properties are null");
        }

        MessageElement key = epr.getProperties().get(this.getKeyTypeName());
        if (key == null) {
            throw new ContextBrokerException("contextualization " +
                    "resource key not present in EPR");
        }

        return key.getValue();
    }
View Full Code Here

    }

    public static String getID(ResourceKey key)
                                    throws ContextBrokerException {
        if (key == null) {
            throw new ContextBrokerException("key is null");
        }
        return (String)key.getValue();
    }
View Full Code Here

        Identity perhaps = this.identities.get(iface);
        if (perhaps != null) {
            // Binding does not allow different NIC names in the real id's,
            // it must be the provides section's fault
            throw new ContextBrokerException("Duplicate interface found." +
                    "  Identity names in provides section can not be" +
                    " duplicated. [[interface already added: interface = " +
                    iface + ", given Identity = " + id + ", Identity " +
                    "already given for this interface: " + perhaps + "]]");
        }
View Full Code Here

TOP

Related Classes of org.nimbustools.ctxbroker.ContextBrokerException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.