Examples of ResourceContainer


Examples of org.rhq.core.pc.inventory.ResourceContainer

     * @param tokens tokenized command line tokens[0] is the command itself
     */
    private void children(String[] tokens) {

        int id = getResourceIdFromTokens(tokens,resourceId);
        ResourceContainer resourceContainer = inventoryManager.getResourceContainer(id);
        if (resourceContainer != null) {
            Resource r = resourceContainer.getResource();
            Set<Resource> resources = r.getChildResources();
            for (Resource res : resources) {
                System.out.println(res);
            }
        } else {
View Full Code Here

Examples of org.rhq.core.pc.inventory.ResourceContainer

                } else
                    resourceId = Integer.valueOf(arg);
            } catch (NumberFormatException nfe) {
                System.err.println("Sorry, but [" + arg + "] is no valid number");
            }
            ResourceContainer rc = inventoryManager.getResourceContainer(resourceId);
            if (rc == null) {
                System.err.println("No resource with that id exists");
                resourceId = 0;
            }
        } else
View Full Code Here

Examples of org.rhq.core.pc.inventory.ResourceContainer

            initialize();
        }

        @Override
        public ResourceContainer getResourceContainer(int resourceId) {
            ResourceContainer container = resourceContainers.get(resourceId);
            if (container == null) {
                Resource resource = new Resource();
                resource.setId(resourceId);
                container = new ResourceContainer(resource, getClass().getClassLoader());
                resourceContainers.put(resourceId, container);
            }
            return container;
        }
View Full Code Here

Examples of org.rhq.core.pc.inventory.ResourceContainer

            Set<Resource> resources = inventoryManager.getResourcesWithType(resourceType);
            if (resources.isEmpty()) {
                throw new Exception("No bundle plugin supports bundle type [" + bundleType + "]");
            }
            final int bundleHandlerResourceId = resources.iterator().next().getId();
            final ResourceContainer resourceContainer = inventoryManager.getResourceContainer(bundleHandlerResourceId);
            if (null == resourceContainer.getResourceContext()) {
                throw new Exception("No bundle plugin resource available to handle deployment for bundle type ["
                    + bundleType
                    + "]. Ensure the bundle plugin is deployed and its resource is imported into inventory.");
            }

            auditDeployment(resourceDeployment, AUDIT_DEPLOYMENT_SCHEDULED, bundleDeployment.getName(),
                "Scheduled deployment time: " + request.getRequestedDeployTimeAsString());

            Runnable deployerRunnable = new Runnable() {
                @Override
                public void run() {
                    try {
                        // pull down the bundle files that the plugin will need in order to process the bundle
                        File pluginTmpDir = resourceContainer.getResourceContext().getTemporaryDirectory();
                        File bundleFilesDir = new File(pluginTmpDir, "bundle-versions/"
                            + bundleDeployment.getBundleVersion().getId());
                        bundleFilesDir.mkdirs();

                        // clean up any old downloads we may have retrieved before. This helps clean out
View Full Code Here

Examples of org.rhq.core.pc.inventory.ResourceContainer

        return response;
    }

    private Configuration createReferencedConfigurationFromResource(BundleResourceDeployment resourceDeployment) {
        ResourceContainer rc = inventoryManager.getResourceContainer(resourceDeployment.getResource());

        Set<ResourceTypeBundleConfiguration.BundleDestinationSpecification> specs = rc.getResource().getResourceType()
            .getResourceTypeBundleConfiguration().getBundleDestinationSpecifications();

        String specName = resourceDeployment.getBundleDeployment().getDestination()
            .getDestinationSpecificationName();

        for (ResourceTypeBundleConfiguration.BundleDestinationSpecification spec : specs) {
            if (specName.equals(spec.getName())) {
                ResourceTypeBundleConfiguration.BundleDestinationDefinition def =
                    (ResourceTypeBundleConfiguration.BundleDestinationDefinition) spec;

                Resource resource = rc.getResource();

                Configuration transferred = new Configuration();

                Configuration pluginConfiguration = resource.getPluginConfiguration();
                Configuration resourceConfiguration = InventoryManager.getResourceConfiguration(resource);

                for (ResourceTypeBundleConfiguration.BundleDestinationDefinition.ConfigRef refProp :
                    def.getReferencedConfiguration()) {

                    switch (refProp.getContext()) {
                    case PLUGIN_CONFIGURATION:
                        switch (refProp.getType()) {
                        case LIST:
                            PropertyList list = pluginConfiguration.getList(refProp.getName()).deepCopy(false);
                            list.setName(refProp.getTargetName());

                            transferred.put(list);
                            break;
                        case MAP:
                            PropertyMap map = pluginConfiguration.getMap(refProp.getName()).deepCopy(false);
                            map.setName(refProp.getTargetName());

                            transferred.put(map);
                            break;
                        case SIMPLE:
                            PropertySimple simple = pluginConfiguration.getSimple(refProp.getName()).deepCopy(false);
                            simple.setName(refProp.getTargetName());

                            transferred.put(simple);
                            break;
                        case FULL:
                            for (Property p : pluginConfiguration.getProperties()) {
                                Property copy = p.deepCopy(false);
                                if (refProp.getTargetName() != null) {
                                    copy.setName(refProp.getTargetName() + copy.getName());
                                }
                                transferred.put(copy);
                            }
                            break;
                        }
                        break;
                    case RESOURCE_CONFIGURATION:
                        switch (refProp.getType()) {
                        case LIST:
                            PropertyList list = resourceConfiguration.getList(refProp.getName()).deepCopy(false);
                            list.setName(refProp.getTargetName());

                            transferred.put(list);
                            break;
                        case MAP:
                            PropertyMap map = resourceConfiguration.getMap(refProp.getName()).deepCopy(false);
                            map.setName(refProp.getTargetName());

                            transferred.put(map);
                            break;
                        case SIMPLE:
                            PropertySimple simple = resourceConfiguration.getSimple(refProp.getName()).deepCopy(false);
                            simple.setName(refProp.getTargetName());

                            transferred.put(simple);
                            break;
                        case FULL:
                            for (Property p : resourceConfiguration.getProperties()) {
                                Property copy = p.deepCopy(false);
                                if (refProp.getTargetName() != null) {
                                    copy.setName(refProp.getTargetName() + copy.getName());
                                }
                                transferred.put(copy);
                            }
                            break;
                        }
                        break;
                    case MEASUREMENT_TRAIT:
                        if (refProp.getType() ==
                            ResourceTypeBundleConfiguration.BundleDestinationDefinition.ConfigRef.Type.FULL) {
                            Set<MeasurementScheduleRequest> schedules = rc.getMeasurementSchedule();
                            for (MeasurementScheduleRequest schedule : schedules) {
                                if (schedule.getDataType() != DataType.TRAIT) {
                                    String value = measurementManager.getTraitValue(rc, schedule.getName());
                                    String name = schedule.getName();
                                    if (refProp.getTargetName() != null) {
View Full Code Here

Examples of org.rhq.core.pc.inventory.ResourceContainer

        return null;
    }

    private String getConnectionString(BundleResourceDeployment resourceDeployment) {
        ResourceContainer rc = inventoryManager.getResourceContainer(resourceDeployment.getResource());
        BundleDestination dest = resourceDeployment.getBundleDeployment().getDestination();
        ResourceType type = rc.getResource().getResourceType();
        String specName = dest.getDestinationSpecificationName();
        String relativeDeployDir = dest.getDeployDir();

        Configuration config = new Configuration();
        config.put(new PropertySimple("deployDir", relativeDeployDir));
View Full Code Here

Examples of org.rhq.core.pc.inventory.ResourceContainer

            Set<Resource> resources = inventoryManager.getResourcesWithType(resourceType);
            if (resources.isEmpty()) {
                throw new Exception("No bundle plugin supports bundle type [" + bundleType + "]");
            }
            final int bundleHandlerResourceId = resources.iterator().next().getId();
            final ResourceContainer resourceContainer = inventoryManager.getResourceContainer(bundleHandlerResourceId);
            if (null == resourceContainer.getResourceContext()) {
                throw new Exception("No bundle plugin resource available to handle purge for bundle type ["
                    + bundleType
                    + "]. Ensure the bundle plugin is deployed and its resource is imported into inventory.");
            }
View Full Code Here

Examples of org.rhq.core.pc.inventory.ResourceContainer

            relativeDeployDir = File.separator;
        }

        // get the resource entity stored in our local inventory
        Resource resource = bundleResourceDeployment.getResource();
        ResourceContainer container = inventoryManager.getResourceContainer(resource);
        resource = container.getResource();

        // find out the type of base location that is specified by the bundle destination
        BundleDestinationBaseDirectory bundleDestBaseDir = null;
        ResourceTypeBundleConfiguration rtbc = resource.getResourceType().getResourceTypeBundleConfiguration();
        if (rtbc == null) {
View Full Code Here

Examples of org.rhq.core.pc.inventory.ResourceContainer

    @Override
    public List<DriftDefinition> getDeletedDefinitions(int resourceId, Set<DriftDefinition> definitionsFromServer) {
        log.debug("Checking for drift definitions that need to be deleted for resource id " + resourceId);
        List<DriftDefinition> deleted = new LinkedList<DriftDefinition>();
        ResourceContainer container = inventoryMgr.getResourceContainer(resourceId);

        for (DriftDefinition c : container.getDriftDefinitions()) {
            if (!definitionsFromServer.contains(c)) {
                if (log.isDebugEnabled()) {
                    log.debug("Detected stale drift definition that needs to be purged - " + toString(resourceId, c));
                }
                deleted.add(c);
View Full Code Here

Examples of org.rhq.core.pc.inventory.ResourceContainer

    @Override
    public void purgeFromLocalInventory(int resourceId, List<DriftDefinition> definitions) {
        log.debug("Preparing to purge from local inventory drift definitions that have been deleted on the server "
            + "for resource id " + resourceId);
        ResourceContainer container = inventoryMgr.getResourceContainer(resourceId);
        File resourceSnapshotsDir = new File(snapshotsDir, Integer.toString(resourceId));

        for (DriftDefinition c : definitions) {
            if (log.isDebugEnabled()) {
                log.debug("Purging " + toString(resourceId, c) + " from local inventory");
            }
            container.removeDriftDefinition(c);
            File snapshotDir = new File(resourceSnapshotsDir, c.getName());
            if (snapshotDir.exists()) {
                if (log.isDebugEnabled()) {
                    log.debug("Puring snapshot directory " + snapshotDir.getPath());
                }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.