List of usage examples for javax.management.openmbean TabularDataSupport entrySet
@SuppressWarnings("unchecked") public Set<Map.Entry<Object, Object>> entrySet()
From source file:org.trpr.platform.batch.impl.spring.jmx.JMXJobUtils.java
/** * Polls the JobAdministrator for last execution status of the specified job. Makes the current thread sleep for the specified duration between consecutive * checks//from w w w .j av a 2 s . c om * @param jobName the job to wait for execution completion * @param checkFrequency the sleep time in ms between status checks * @throws Exception all Runtime and Checked exceptions thrown, if any, when monitoring the specified job * @return the exist status as String */ public String waitForJobExecution(String jobName, long checkFrequency) throws Exception { while (true) { Thread.sleep(checkFrequency); TabularDataSupport batchStats = (TabularDataSupport) this.mbeanServer .invoke(this.jobAdministratorInstance.getObjectName(), JOB_METRICS, null, null); Set<Map.Entry<Object, Object>> stats = batchStats.entrySet(); for (Map.Entry entry : stats) { CompositeData data = (CompositeData) entry.getValue(); if (data.get(JOB_PARAM_NAME).equals(jobName) && data.get(JOB_PARAM_STATUS) != null) { String status = data.get("jobStatus").toString(); for (String completedStatus : BATCH_COMPLETION_STATUSES) { if (status.equalsIgnoreCase(completedStatus)) { // job has completed execution, so exit. return status; } } } } } }
From source file:org.wso2.andes.management.ui.views.ViewUtility.java
@SuppressWarnings("unchecked") private static void createTabularDataHolder(FormToolkit toolkit, Composite parent, TabularDataSupport tabularData) { Composite composite = toolkit.createComposite(parent, SWT.BORDER); GridLayout layout = new GridLayout(4, true); layout.horizontalSpacing = 0;//w ww . j a v a 2s.c o m layout.marginWidth = 0; layout.marginHeight = 10; layout.verticalSpacing = 10; composite.setLayout(layout); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); Set entrySet = tabularData.entrySet(); ArrayList<Map.Entry> list = new ArrayList<Map.Entry>(entrySet); if (list.size() == 0) { Text text = toolkit.createText(composite, " No records ", SWT.CENTER | SWT.SINGLE | SWT.READ_ONLY); GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1); text.setLayoutData(layoutData); return; } Collections.sort(list, tabularDataComparator); // Attach the tabular record to be retrieved and shown later when record is traversed // using first/next/previous/last buttons composite.setData(list); // Create button and the composite for CompositeData Composite compositeDataHolder = createCompositeDataHolder(toolkit, composite, tabularData.getTabularType().getRowType()); // display the first record CompositeData data = (CompositeData) (list.get(0)).getValue(); composite.setData(INDEX, 0); populateCompositeWithCompositeData(toolkit, compositeDataHolder, data); enableOrDisableTraversalButtons(composite); }