Package org.rhq.coregui.client.util.async

Examples of org.rhq.coregui.client.util.async.CountDownLatch


                        enabledScheduleDefinitionIds[i++] = measurementSchedule.getDefinition().getId();
                    }

                    // This latch is the last thing that gets executed after we have executed the
                    // 2 queries in Parallel
                    final CountDownLatch countDownLatch = CountDownLatch.create(2, new Command() {

                        @Override
                        public void execute() {
                            // we needed the ResourceMetrics query and Metric Display Summary
                            // to finish before we can query the live metrics and populate the
View Full Code Here


        String areYouSureQuestion = operationType == StorageNodeOperation.OTHER ? question.getMessage(operationName,
            selectedAddresses.toString()) : question.getMessage(selectedAddresses.toString());
        SC.ask(areYouSureQuestion, new BooleanCallback() {
            public void execute(Boolean confirmed) {
                if (confirmed) {
                    final CountDownLatch latch = CountDownLatch.create(selections.length, new Command() {
                        @Override
                        public void execute() {
                            String msgString = null;
                            if (operationType == StorageNodeOperation.OTHER) {
                                msgString = success.getMessage(operationName, selectedAddresses.toString());
                            } else {
                                msgString = success.getMessage(selectedAddresses.toString());
                            }
                            Message msg = new Message(msgString, Message.Severity.Info);
                            CoreGUI.getMessageCenter().notify(msg);
                            refreshTableInfo();
                        }
                    });
                    boolean isStopStartOrRestart = Arrays.asList("start", "shutdown", "restart")
                        .contains(operationName);
                    for (ListGridRecord storageNodeRecord : selections) {
                        // NFE should never happen, because of the condition for table action enablement
                        int resourceId = storageNodeRecord.getAttributeAsInt(FIELD_RESOURCE_ID.propertyName());
                        if (isStopStartOrRestart) {
                            // start, stop or restart the storage node
                            GWTServiceLookup.getOperationService().scheduleResourceOperation(resourceId, operationName,
                                null, "Run by Storage Node Administrations UI", 0, new AsyncCallback<Void>() {
                                    public void onSuccess(Void result) {
                                        latch.countDown();
                                    }

                                    public void onFailure(Throwable caught) {
                                        String msg = failure.getMessage(operationName,
                                            selectedAddresses + " " + caught.getMessage());
                                        CoreGUI.getErrorHandler().handleError(msg, caught);
                                        latch.countDown();
                                        refreshTableInfo();
                                    }
                                });
                        } else {
                            if (operationType != StorageNodeOperation.OTHER) { // (un)deploy
                                AsyncCallback<Void> callback = new AsyncCallback<Void>() {
                                    public void onSuccess(Void result) {
                                        latch.countDown();
                                    }

                                    public void onFailure(Throwable caught) {
                                        String msg = failure.getMessage(
                                            selectedAddresses.toString(),
                                            Arrays.asList(getSelectedIds(selections)).toString() + " "
                                                + caught.getMessage());
                                        CoreGUI.getErrorHandler().handleError(msg, caught);
                                        latch.countDown();
                                        refreshTableInfo();
                                    }
                                };
                                int storageNodeId = storageNodeRecord.getAttributeAsInt("id");
                                StorageNode node = new StorageNode(storageNodeId);
                                if (operationType == StorageNodeOperation.DEPLOY) {
                                    GWTServiceLookup.getStorageService().deployStorageNode(node, callback);
                                } else {
                                    GWTServiceLookup.getStorageService().undeployStorageNode(node, callback);
                                }
                            } else {
                                // invoke the operation on the storage service resource
                                GWTServiceLookup.getStorageService().invokeOperationOnStorageService(resourceId,
                                    operationName, new AsyncCallback<Void>() {
                                        public void onSuccess(Void result) {
                                            latch.countDown();
                                        }

                                        public void onFailure(Throwable caught) {
                                            String msg = failure.getMessage(operationName, selectedAddresses + " "
                                                + caught.getMessage());
                                            CoreGUI.getErrorHandler().handleError(msg, caught);
                                            latch.countDown();
                                            refreshTableInfo();
                                        }
                                    });
                            }
                        }
View Full Code Here

TOP

Related Classes of org.rhq.coregui.client.util.async.CountDownLatch

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.