List of usage examples for java.util.concurrent CopyOnWriteArrayList iterator
public Iterator<E> iterator()
From source file:eu.tango.energymodeller.datasourceclient.WattsUpMeterDataSourceAdaptor.java
@Override public synchronized double getCpuUtilisation(Host host, int lastNSeconds) { double count = 0.0; double sumOfUtil = 0.0; GregorianCalendar cal = new GregorianCalendar(); long now = TimeUnit.MILLISECONDS.toSeconds(cal.getTimeInMillis()); long nowMinustime = now - lastNSeconds; CopyOnWriteArrayList<CPUUtilisation> list = new CopyOnWriteArrayList<>(); list.addAll(cpuMeasure);//from ww w .j a v a 2s. c om for (Iterator<CPUUtilisation> it = list.iterator(); it.hasNext();) { CPUUtilisation util = it.next(); if (util.isOlderThan(nowMinustime)) { list.remove(util); cpuMeasure.remove(util); } else { sumOfUtil = sumOfUtil + util.getCpuBusy(); count = count + 1; } } if (count == 0) { return 0.0; } return sumOfUtil / count; }
From source file:org.wso2.carbon.event.input.adaptor.websocket.local.WebsocketLocalEventAdaptorType.java
@Override public void unsubscribe(InputEventAdaptorMessageConfiguration inputEventAdaptorMessageConfiguration, InputEventAdaptorConfiguration inputEventAdaptorConfiguration, AxisConfiguration axisConfiguration, String subscriptionId) {/* w ww. j a va 2 s . c om*/ int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); String topic = inputEventAdaptorMessageConfiguration.getInputMessageProperties() .get(WebsocketLocalEventAdaptorConstants.ADAPTOR_MESSAGE_TOPIC); Map<String, ConcurrentHashMap<String, CopyOnWriteArrayList<WebsocketAdaptorListener>>> tenantSpecificListenerMap = inputEventAdaptorListenerMap .get(tenantId); if (tenantSpecificListenerMap != null) { Map<String, CopyOnWriteArrayList<WebsocketAdaptorListener>> adaptorSpecificListeners = tenantSpecificListenerMap .get(inputEventAdaptorConfiguration.getName()); if (adaptorSpecificListeners != null) { CopyOnWriteArrayList<WebsocketAdaptorListener> topicSpecificListeners = adaptorSpecificListeners .get(topic); if (topicSpecificListeners != null) { for (Iterator<WebsocketAdaptorListener> iterator = topicSpecificListeners.iterator(); iterator .hasNext();) { WebsocketAdaptorListener websocketAdaptorListener = iterator.next(); if (subscriptionId.equals(websocketAdaptorListener.getSubscriptionId())) { iterator.remove(); break; } } } } } }
From source file:org.wso2.carbon.event.input.adaptor.websocket.WebsocketEventAdaptorType.java
@Override public void unsubscribe(InputEventAdaptorMessageConfiguration inputEventAdaptorMessageConfiguration, InputEventAdaptorConfiguration inputEventAdaptorConfiguration, AxisConfiguration axisConfiguration, String subscriptionId) {/*from www . jav a 2 s . c om*/ int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); String topic = inputEventAdaptorMessageConfiguration.getInputMessageProperties() .get(WebsocketEventAdaptorConstants.ADAPTOR_MESSAGE_TOPIC); String socketServerUrl = inputEventAdaptorConfiguration.getInputProperties() .get(WebsocketEventAdaptorConstants.ADAPTER_SERVER_URL); Map<String, ConcurrentHashMap<String, CopyOnWriteArrayList<ClientManagerWrapper>>> tenantSpecificAdaptorMap = inputEventAdaptorClientManagerMap .get(tenantId); if (tenantSpecificAdaptorMap != null) { ConcurrentHashMap<String, CopyOnWriteArrayList<ClientManagerWrapper>> adaptorSpecificTopicMap = tenantSpecificAdaptorMap .get(inputEventAdaptorConfiguration.getName()); if (adaptorSpecificTopicMap != null) { CopyOnWriteArrayList<ClientManagerWrapper> topicSpecificClientManagers = adaptorSpecificTopicMap .get(topic); if (topicSpecificClientManagers != null) { for (Iterator<ClientManagerWrapper> iterator = topicSpecificClientManagers.iterator(); iterator .hasNext();) { ClientManagerWrapper clientManagerWrapper = iterator.next(); if (subscriptionId.equals(clientManagerWrapper.getSubscriptionId())) { iterator.remove(); break; } } } } } }
From source file:ypcnv.converter.mainFrame.MainFrame.java
/** * Check configurations for nulls, arrange them, etc. * @param confsList - configurations to be processed. *///from w w w .jav a 2 s .c om private void refactorConfigurations(ArrayList<DataSourceConf> confsList) { CopyOnWriteArrayList<DataSourceConf> confs = new CopyOnWriteArrayList<DataSourceConf>(); confs.addAll(confsList); srcObjectConfig = null; dstObjectConfig = null; for (DataSourceConf config : confs) { Side side = config.getSide(); if (side == null) { side = Side.heath; } switch (side) { case source: srcObjectConfig = new DataSourceConf(config); confsList.remove(config); break; case destination: dstObjectConfig = new DataSourceConf(config); confsList.remove(config); break; } } int quantityOfWantedDataSources = 2; for (int idx = 0; idx < confs.size() && idx < quantityOfWantedDataSources && confs.size() > 0; idx++) { Iterator<DataSourceConf> iter = confs.iterator(); while (iter.hasNext()) { DataSourceConf conf = iter.next(); if (srcObjectConfig == null) { srcObjectConfig = conf; confsList.remove(conf); } else if (dstObjectConfig == null) { dstObjectConfig = conf; confsList.remove(conf); } } } if (srcObjectConfig == null) { srcObjectConfig = new DataSourceConf(null, null, null); } if (dstObjectConfig == null) { dstObjectConfig = new DataSourceConf(null, null, null); } confsList = new ArrayList<DataSourceConf>(); confsList.add(srcObjectConfig); confsList.add(dstObjectConfig); }