Package org.rhq.core.domain.cloud

Examples of org.rhq.core.domain.cloud.StorageNode


            public void execute() throws Exception {
                // verify that all storage nodes objects are actually parsed.
                final Set<String> nodeAddresses = new HashSet<String>(storageNodeCount);

                final String prefix = "storage_node";
                StorageNode lastOne = null, firstOne = null;
                for (int i = 0; i < storageNodeCount; i++) {
                    String address = prefix + String.format(" %03d", i + 1) + ".domain.com";
                    StorageNode node = StorageNodeFactory.newInstance();
                    node.setAddress(address);
                    node.setOperationMode(StorageNode.OperationMode.NORMAL);
                    node.setCqlPort(9142 + i);
                    if (i == 0) {
                        firstOne = node;
                    } else if (i == storageNodeCount - 1) {
                        lastOne = node;
                    }
View Full Code Here


                + "       OR r.resourceType.name = 'RHQ Storage Node'" //
                + " ORDER BY r.id DESC");
            doomed = q.getResultList();
            for (Object removeMe : doomed) {
                Resource res = em.getReference(Resource.class, ((Resource) removeMe).getId());
                StorageNode storageNode = findStorageNode(res);
                if (storageNode != null) {
                    storageNode.setResource(null);
                }
                for (Iterator<CreateResourceHistory> historyIterator = res.getCreateChildResourceRequests().iterator(); historyIterator
                    .hasNext();) {
                    CreateResourceHistory history = historyIterator.next();
                    historyIterator.remove();
View Full Code Here

    public void testStorageNodeAckFailedOperation() throws Exception {
        executeInTransaction(new TransactionCallback() {

            @Override
            public void execute() throws Exception {
                StorageNode node = StorageNodeFactory.newInstance();
                final String address = TEST_PREFIX + "foo.com";
                node.setAddress(address);
                node.setOperationMode(StorageNode.OperationMode.ANNOUNCE);
                node.setCqlPort(9142);
                node.setErrorMessage("It is broken");
                em.persist(node);
                em.flush();               
                assertEquals("The cluster status should be DOWN", StorageNode.Status.DOWN, node.getStatus());
               
                // we need to do this to obtain the new id
                StorageNodeCriteria criteria = new StorageNodeCriteria();
                criteria.addFilterAddress(address);
                StorageNode node2 = nodeManager.findStorageNodeByAddress(address);
               
                nodeManager.ackFailedOperation(subjectManager.getOverlord(), node2.getId());
               
                criteria = new StorageNodeCriteria();
                criteria.addFilterAddress(address);
                StorageNode node3 = nodeManager.findStorageNodeByAddress(address);
               
                assertEquals("The error message should not affect the equals method", node, node2);
                assertEquals("The error message should not affect the equals method", node2, node3);
                assertEquals("The cluster status should be JOINING", StorageNode.Status.JOINING, node3.getStatus());
                assertNull("The error message should be clean now", node3.getErrorMessage());
            }
           
        });
    }
View Full Code Here

    private void createStorageNodes() {
        String[] nodes = System.getProperty("rhq.storage.nodes").split(",");
        String cqlPort = System.getProperty("rhq.storage.cql-port");
        for (String node : nodes) {
            StorageNode storageNode = new StorageNode();
            storageNode.setAddress(node);
            storageNode.setCqlPort(Integer.parseInt(cqlPort));
            storageNode.setOperationMode(StorageNode.OperationMode.NORMAL);
            storageNode.setVersion(StrippedDownStartupBean.RHQ_VERSION);
            entityManager.persist(storageNode);
        }
    }
View Full Code Here

    @Override
    public List<Integer> findNotAcknowledgedStorageNodeAlertsCounts(List<Integer> storageNodeIds) throws RuntimeException {
        try {
            List<Integer> unackAlertCounts = new ArrayList<Integer>(storageNodeIds.size());
            for (int storageNodeId : storageNodeIds) {
                StorageNode node = new StorageNode();
                node.setId(storageNodeId);
                int num = storageNodeManager.findNotAcknowledgedStorageNodeAlerts(getSessionSubject(), node).size();
                unackAlertCounts.add(num);
            }
            assert storageNodeIds.size() == unackAlertCounts.size();
            return unackAlertCounts;
View Full Code Here

            public int compare(StorageNode left, StorageNode right) {
                return left.getAddress().compareTo(right.getAddress());
            }
        });
        for (String address : storageNodeAddresses) {
            StorageNode node = new StorageNode();
            node.setAddress(address);
            node.setCqlPort(cqlPort);
            parsedNodes.add(node);
        }

        return parsedNodes;
    }
View Full Code Here

    @Override
    @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
    public void logError(String address, String error, Exception e) {
        try {
            StorageNode newStorageNode = findStorageNodeByAddress(address);
            newStorageNode.setErrorMessage(error + " Check the server log for details. Root cause: "
                + ThrowableUtil.getRootCause(e).getMessage());
        } catch (Exception e1) {
            log.error("Failed to log error against storage node", e);
        }
    }
View Full Code Here

        }
    }

    private void logError(ResourceOperationHistory operationHistory, String msg, Exception e) {
        log.error(msg, e);
        StorageNode storageNode = findStorageNode(operationHistory.getResource());
        storageNodeOperationsHandler.logError(storageNode.getAddress(), msg, e);
    }
View Full Code Here

    }

    @Override
    @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
    public void handleAnnounce(ResourceOperationHistory resourceOperationHistory) {
        StorageNode storageNode = findStorageNode(resourceOperationHistory.getResource());
        Configuration parameters = resourceOperationHistory.getParameters();
        PropertyList addresses = parameters.getList("addresses");
        StorageNode newStorageNode;

        switch (resourceOperationHistory.getStatus()) {
        case INPROGRESS:
            // nothing to do here
            return;
        case CANCELED:
            newStorageNode = findStorageNodeByAddress(getAddress(addresses));
            deploymentOperationCanceled(storageNode, resourceOperationHistory, newStorageNode);
        case FAILURE:
            newStorageNode = findStorageNodeByAddress(getAddress(addresses));
            deploymentOperationFailed(storageNode, resourceOperationHistory, newStorageNode);
            return;
        default: // SUCCESS
            storageNode.setMaintenancePending(false);
            StorageNode nextNode = takeFromMaintenanceQueue();
            Subject subject = getSubject(resourceOperationHistory);
            newStorageNode = findStorageNodeByAddress(getAddress(addresses));

            if (nextNode == null) {
                log.info("Successfully announced new storage node to storage cluster");
View Full Code Here

    }

    @Override
    @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
    public void handleUnannounce(ResourceOperationHistory operationHistory) {
        StorageNode storageNode = findStorageNode(operationHistory.getResource());
        Configuration params = operationHistory.getParameters();
        PropertyList addresses = params.getList("addresses");
        StorageNode removedStorageNode;

        switch (operationHistory.getStatus()) {
        case INPROGRESS:
            // nothing to do here
            break;
        case CANCELED:
            removedStorageNode = findStorageNodeByAddress(getAddress(addresses));
            undeploymentOperationCanceled(storageNode, operationHistory, removedStorageNode);
            break;
        case FAILURE:
            removedStorageNode = findStorageNodeByAddress(getAddress(addresses));
            deploymentOperationFailed(storageNode, operationHistory, removedStorageNode);
            break;
        default: // SUCCESS
            storageNode.setMaintenancePending(false);
            StorageNode nextNode = takeFromMaintenanceQueue();
            Subject subject = getSubject(operationHistory);
            removedStorageNode = findStorageNodeByAddress(getAddress(addresses));

            if (nextNode == null) {
                log.info("Successfully unannounced " + removedStorageNode + " to storage cluster");
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.cloud.StorageNode

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.