Package org.rioproject.impl.system

Examples of org.rioproject.impl.system.ComputeResource


                                                  new ClassBundle[]{exportBundle});
        if(sbLifeCycleManager == null)
            sbLifeCycleManager = new LifeCycleManager();

        checkUtilityConfiguration(config);
        ComputeResource computeResource = new ComputeResource(config);

        Uuid serviceID = UuidFactory.generate();
        DefaultServiceBeanManager serviceBeanManager = new DefaultServiceBeanManager(sElem,
                                               computeResource.getHostName(),
                                               computeResource.getAddress().getHostAddress(),
                                               serviceID);
        serviceBeanManager.setDiscardManager(sbLifeCycleManager);
        serviceBeanManager.setServiceID(serviceID);
        DefaultServiceBeanContext serviceBeanContext = new DefaultServiceBeanContext(sElem, serviceBeanManager, computeResource, null); /* Shared Configuration */
        serviceBeanContext.setConfiguration(config);
View Full Code Here


        ServiceBeanContext context = new ServiceContextFactory().create(serviceElement,
                                                                    new DefaultServiceBeanManager(serviceElement,
                                                                                   InetAddress.getLocalHost().getHostName(),
                                                                                   InetAddress.getLocalHost().getHostAddress(),
                                                                                   UuidFactory.generate()),
                                                                    new ComputeResource(),
                                                                    EmptyConfiguration.INSTANCE);
        Configuration config = context.getConfiguration();
        String something = (String) config.getEntry("simple", "something", String.class);
        Assert.assertNotNull("Expected something not to be null", something);
        Assert.assertEquals("Expected something", "something", something);
View Full Code Here

            URL.setURLStreamHandlerFactory(new ArtifactURLStreamHandlerFactory());
        }
        try {
            Configuration config = EmptyConfiguration.INSTANCE;
            instantiator = new ServiceBeanContainerImpl(config);
            ComputeResource cr = new ComputeResource();
            String provisionRoot = Environment.setupProvisionRoot(true, config);
            cr.setPersistentProvisioningRoot(provisionRoot);
            cr.boot();
            instantiator.setComputeResource(cr);
        } catch (Exception e) {
            e.printStackTrace();
        }
        instantiator.setUuid(UuidFactory.generate());
View Full Code Here

public class ReportIntervalTest {
    private ComputeResource computeResource;

    @Before
    public void create() throws UnknownHostException, ConfigurationException {
        computeResource = new ComputeResource();
    }
View Full Code Here

        Long instanceID = sElem.getServiceBeanConfig().getInstanceID();
        threadName.append(instanceID==null?"<?>":instanceID).append("-delegate");
        Thread jsbThread = new Thread(threadName.toString()) {
            public void run() {
                starting.set(true);
                ComputeResource computeResource = container.getComputeResource();
                try {

                    if(!runningForked()) {
                       /* If there are provisionable capabilities, or
                         * data staging, perform the stagedData/installation */
                        stagedDataManager.download();

                        installedPlatformCapabilities.addAll(stagedDataManager.getInstalledPlatformCapabilities());
                        for(PlatformCapability pCap : installedPlatformCapabilities) {
                            int count = pCap.incrementUsage();
                            logger.info("PlatformCapability ["+getName()+"], count="+count);
                        }
                    }

                    /* Check if we are forking a service bean */
                    if(sElem.forkService() && !runningForked()) {
                        logger.debug("Fork required for {}", ServiceLogUtil.logName(sElem));
                        logger.trace("Created a ServiceBeanExecHandler for {}", ServiceLogUtil.logName(sElem));
                        execManager = new ServiceBeanExecHandler(sElem, container.getSharedConfiguration(), container.getUuid());
                        try {
                            /* Get matched PlatformCapability instances to apply */
                            PlatformCapability[] pCaps = computeResource.getPlatformCapabilities();
                            PlatformCapability[] matched = ServiceElementUtil.getMatchedPlatformCapabilities(sElem, pCaps);
                            logger.trace("Invoke ServiceBeanExecHandler.exec for {}", ServiceLogUtil.logName(sElem));
                            instance = execManager.exec(opStringMgr, new JSBDiscardManager(), matched);
                            logger.trace("ServiceBeanInstance obtained from ServiceBeanExecHandler for {}", ServiceLogUtil
                                                                                                                .logName(sElem));
                            serviceRecord = execManager.getServiceRecord();
                            logger.trace("ServiceRecord obtained from ServiceBeanExecHandler for {}", ServiceLogUtil.logName(sElem));
                        } catch (Exception e) {
                            abortThrowable = e;
                        }

                    } else {
                        /* Create the DiscardManager */
                        JSBDiscardManager discardManager = new JSBDiscardManager();

                        /* Create the ServiceBeanManager */
                        DefaultServiceBeanManager serviceBeanManager = new DefaultServiceBeanManager(sElem,
                                                               opStringMgr,
                                                               computeResource.getHostName(),
                                                               computeResource.getAddress().getHostAddress(),
                                                               container.getUuid());
                        serviceBeanManager.setDiscardManager(discardManager);
                        serviceBeanManager.setServiceID(serviceID);
                        /*
                        * Load and start the ServiceBean
View Full Code Here

    private void bootstrap(final String[] configArgs) throws Exception {
        ClassLoader cCL = Thread.currentThread().getContextClassLoader();
        Configuration config = ConfigurationProvider.getInstance(configArgs, cCL);
        container = new ServiceBeanContainerImpl(config);
        computeResource = new ComputeResource(config);

        /* Setup persistent provisioning attributes */
        boolean provisionEnabled = (Boolean) config.getEntry("org.rioproject.cybernode",
                                                             "provisionEnabled",
                                                             Boolean.class,
View Full Code Here

                                               final ServiceBeanContainer container) throws ServiceBeanInstantiationException {
        ServiceBeanFactory.Created created = null;
        MarshalledInstance marshalledProxy = null;
        ServiceBeanContext context;
        CommonClassLoader commonCL = CommonClassLoader.getInstance();
        ComputeResource computeResource = container.getComputeResource();

        /*
         * Provision service jars
         */
        URL[] exports = new URL[0];
        URL[] implJARs = new URL[0];
        if(System.getProperty("StaticCybernode")==null) {
            try {
                Resolver resolver = ResolverHelper.getResolver();
                boolean install = computeResource.getPersistentProvisioning();
                Map<String, ProvisionedResources> serviceResources = provisionService(sElem, resolver, install);
                ProvisionedResources dlPR = serviceResources.get("dl");
                ProvisionedResources implPR = serviceResources.get("impl");
                if(dlPR.getJars().length==0 && dlPR.getArtifact()!=null) {
                    String convertedArtifact = dlPR.getArtifact().replaceAll(":", "/");
                    String[] artifactParts = convertedArtifact.split(" ");
                    List<URL> exportURLList = new ArrayList<URL>();
                    for(String artifactPart : artifactParts) {
                        // TODO: if the repositories is default maven central, still need to add?
                        exportURLList.add(new URL("artifact:"+artifactPart+dlPR.getRepositories()));
                    }
                    exports = exportURLList.toArray(new URL[exportURLList.size()]);
                } else {
                    exports = dlPR.getJars();
                }
                implJARs = implPR.getJars();
            } catch(Exception e) {
                throw new ServiceBeanInstantiationException("Unable to provision JARs for " +
                                                            "service "+ ServiceLogUtil.logName(sElem), e);
            }
        }

        final Thread currentThread = Thread.currentThread();
        ClassLoader currentClassLoader = currentThread.getContextClassLoader();
        Uuid serviceIDToUse = serviceID;
        try {
            ClassBundle jsbBundle = sElem.getComponentBundle();
            List<URL> urlList = new ArrayList<URL>();
            /*
            URL[] implJARs;
            if(jsbBundle!=null && jsbBundle.getCodebase()!=null)
                implJARs = jsbBundle.getJARs();
            else
                implJARs = new URL[0];
            */
            urlList.addAll(Arrays.asList(implJARs));

            /* Get matched PlatformCapability jars to load */
            PlatformCapability[] pCaps = computeResource.getPlatformCapabilities();
            PlatformCapability[] matched = ServiceElementUtil.getMatchedPlatformCapabilities(sElem, pCaps);
            for (PlatformCapability pCap : matched) {
                URL[] urls = PlatformCapabilityLoader.getLoadableClassPath(pCap);
                for(URL url : urls) {
                    if(!urlList.contains(url))
View Full Code Here

TOP

Related Classes of org.rioproject.impl.system.ComputeResource

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.