List of usage examples for java.util NavigableMap put
V put(K key, V value);
From source file:co.cask.cdap.data2.increment.hbase96.IncrementHandler.java
@Override public void prePut(ObserverContext<RegionCoprocessorEnvironment> ctx, Put put, WALEdit edit, Durability durability) throws IOException { if (put.getAttribute(HBaseOrderedTable.DELTA_WRITE) != null) { // incremental write NavigableMap<byte[], List<Cell>> newFamilyMap = new TreeMap<byte[], List<Cell>>(Bytes.BYTES_COMPARATOR); for (Map.Entry<byte[], List<Cell>> entry : put.getFamilyCellMap().entrySet()) { List<Cell> newCells = new ArrayList<Cell>(entry.getValue().size()); for (Cell cell : entry.getValue()) { // rewrite the cell value with a special prefix to identify it as a delta // for 0.98 we can update this to use cell tags byte[] newValue = Bytes.add(DELTA_MAGIC_PREFIX, CellUtil.cloneValue(cell)); newCells.add(CellUtil.createCell(CellUtil.cloneRow(cell), CellUtil.cloneFamily(cell), CellUtil.cloneQualifier(cell), cell.getTimestamp(), cell.getTypeByte(), newValue)); }/*from w ww. j a v a 2 s. co m*/ newFamilyMap.put(entry.getKey(), newCells); } put.setFamilyCellMap(newFamilyMap); } // put completes normally with value prefix marker }
From source file:co.cask.tigon.data.increment.hbase96.IncrementHandler.java
@Override public void prePut(ObserverContext<RegionCoprocessorEnvironment> ctx, Put put, WALEdit edit, Durability durability) throws IOException { if (put.getAttribute(Constants.DELTA_WRITE) != null) { // incremental write NavigableMap<byte[], List<Cell>> newFamilyMap = new TreeMap<byte[], List<Cell>>(Bytes.BYTES_COMPARATOR); for (Map.Entry<byte[], List<Cell>> entry : put.getFamilyCellMap().entrySet()) { List<Cell> newCells = new ArrayList<Cell>(entry.getValue().size()); for (Cell cell : entry.getValue()) { // rewrite the cell value with a special prefix to identify it as a delta // for 0.98 we can update this to use cell tags byte[] newValue = Bytes.add(DELTA_MAGIC_PREFIX, CellUtil.cloneValue(cell)); newCells.add(CellUtil.createCell(CellUtil.cloneRow(cell), CellUtil.cloneFamily(cell), CellUtil.cloneQualifier(cell), cell.getTimestamp(), cell.getTypeByte(), newValue)); }/*from w ww . jav a2 s. co m*/ newFamilyMap.put(entry.getKey(), newCells); } put.setFamilyCellMap(newFamilyMap); } // put completes normally with value prefix marker }
From source file:com.datatorrent.demos.dimensions.generic.RandomWeightedMovableGenerator.java
/** * Updates all the weights in the probability map by performing random * Gaussian movements on them./*from w w w .j av a 2 s . c o m*/ * @param localMoveDeviation movement size multiplier (aka Gaussian standard deviation) */ public synchronized void move(double localMoveDeviation) { NavigableMap<Double, E> newMap = new TreeMap<Double, E>(); double runningTotal = 0; double newTotal = 0; // Iterate over keys in ascending order for (Map.Entry<Double, E> entry : map.entrySet()) { double newWeight = 0.0; double oldWeight = entry.getKey() - runningTotal; runningTotal += oldWeight; // Check if special condition of fixed weights applies if (getMinWeight() == getMaxWeight()) { newWeight = getMinWeight(); } else { // Keep generating and testing random Gaussian increments until valid newWeight is found do { newWeight = oldWeight + random.nextGaussian() * localMoveDeviation; } while (newWeight < getMinWeight() || newWeight > getMaxWeight()); } newTotal += newWeight; newMap.put(newTotal, entry.getValue()); } // Exchange current values with new total and map representing movements total = newTotal; map = newMap; }
From source file:com.mirth.connect.client.ui.LoadedExtensions.java
public void initialize() { // Remove all existing extensions from the maps in case they are being // initialized again clearExtensionMaps();/*from w w w . ja v a 2 s . c o m*/ // Order all the plugins by their weight before loading any of them. Map<String, String> pluginNameMap = new HashMap<String, String>(); NavigableMap<Integer, List<String>> weightedPlugins = new TreeMap<Integer, List<String>>(); for (PluginMetaData metaData : PlatformUI.MIRTH_FRAME.getPluginMetaData().values()) { try { if (PlatformUI.MIRTH_FRAME.mirthClient.isExtensionEnabled(metaData.getName())) { extensionVersions.put(metaData.getName(), metaData.getPluginVersion()); if (metaData.getClientClasses() != null) { for (PluginClass pluginClass : metaData.getClientClasses()) { String clazzName = pluginClass.getName(); int weight = pluginClass.getWeight(); pluginNameMap.put(clazzName, metaData.getName()); List<String> classList = weightedPlugins.get(weight); if (classList == null) { classList = new ArrayList<String>(); weightedPlugins.put(weight, classList); } classList.add(clazzName); } } if (StringUtils.isNotEmpty(metaData.getTemplateClassName())) { Class<?> clazz = Class.forName(metaData.getTemplateClassName()); for (Constructor<?> constructor : clazz.getDeclaredConstructors()) { if (constructor.getParameterTypes().length == 1) { CodeTemplatePlugin codeTemplatePlugin = (CodeTemplatePlugin) constructor .newInstance(new Object[] { metaData.getName() }); addPluginPoints(codeTemplatePlugin); break; } } } } } catch (Exception e) { PlatformUI.MIRTH_FRAME.alertThrowable(PlatformUI.MIRTH_FRAME, e); } } // Load connector code template plugins before anything else for (ConnectorMetaData metaData : PlatformUI.MIRTH_FRAME.getConnectorMetaData().values()) { try { if (PlatformUI.MIRTH_FRAME.mirthClient.isExtensionEnabled(metaData.getName())) { extensionVersions.put(metaData.getName(), metaData.getPluginVersion()); if (StringUtils.isNotEmpty(metaData.getTemplateClassName())) { Class<?> clazz = Class.forName(metaData.getTemplateClassName()); for (Constructor<?> constructor : clazz.getDeclaredConstructors()) { if (constructor.getParameterTypes().length == 1) { CodeTemplatePlugin codeTemplatePlugin = (CodeTemplatePlugin) constructor .newInstance(new Object[] { metaData.getName() }); addPluginPoints(codeTemplatePlugin); break; } } } } } catch (Exception e) { PlatformUI.MIRTH_FRAME.alertThrowable(PlatformUI.MIRTH_FRAME, e, "Could not load code template plugin: " + metaData.getTemplateClassName()); } } // Signal the reference list factory that code template plugins have been loaded ReferenceListFactory.getInstance().loadPluginReferences(); // Load the plugins in order of their weight for (List<String> classList : weightedPlugins.descendingMap().values()) { for (String clazzName : classList) { try { String pluginName = pluginNameMap.get(clazzName); Class<?> clazz = Class.forName(clazzName); Constructor<?>[] constructors = clazz.getDeclaredConstructors(); for (int i = 0; i < constructors.length; i++) { Class<?> parameters[]; parameters = constructors[i].getParameterTypes(); // load plugin if the number of parameters // in the constructor is 1. if (parameters.length == 1) { ClientPlugin clientPlugin = (ClientPlugin) constructors[i] .newInstance(new Object[] { pluginName }); addPluginPoints(clientPlugin); i = constructors.length; } } } catch (Exception e) { PlatformUI.MIRTH_FRAME.alertThrowable(PlatformUI.MIRTH_FRAME, e, "Could not load plugin class: " + clazzName); } } } for (ConnectorMetaData metaData : PlatformUI.MIRTH_FRAME.getConnectorMetaData().values()) { try { if (PlatformUI.MIRTH_FRAME.mirthClient.isExtensionEnabled(metaData.getName())) { String connectorName = metaData.getName(); ConnectorSettingsPanel connectorSettingsPanel = (ConnectorSettingsPanel) Class .forName(metaData.getClientClassName()).newInstance(); if (metaData.getType() == ConnectorMetaData.Type.SOURCE) { connectors.put(connectorName, connectorSettingsPanel); sourceConnectors.put(connectorName, connectorSettingsPanel); } else if (metaData.getType() == ConnectorMetaData.Type.DESTINATION) { connectors.put(connectorName, connectorSettingsPanel); destinationConnectors.put(connectorName, connectorSettingsPanel); } else { // type must be SOURCE or DESTINATION throw new Exception(); } } } catch (Exception e) { PlatformUI.MIRTH_FRAME.alertThrowable(PlatformUI.MIRTH_FRAME, e, "Could not load connector class: " + metaData.getClientClassName()); } } // Signal the reference list factory that all other plugins have been loaded ReferenceListFactory.getInstance().loadReferencesAfterPlugins(); }
From source file:velocitekProStartAnalyzer.MainWindow.java
private void createChartPanel() { XYSeriesCollection dataset = JDBCPointDao.dataSet; JFreeChart chart = createChart(dataset); ChartPanel chartPanel = new ChartPanel(chart, true, false, false, true, false); chartPanel.setMinimumDrawWidth(0);/*from w ww .j a v a2 s . c o m*/ chartPanel.setMinimumDrawHeight(0); chartPanel.setMaximumDrawWidth(1920); chartPanel.setMaximumDrawHeight(1200); chartPanel.getPopupMenu().addSeparator(); chartPanel.getPopupMenu().add(btnAvgSpeedChart); chartPanel.getPopupMenu().add(btnMedianSpeedChart); chartPanel.getPopupMenu().add(btnResetSpeedChart); chartPanel.getPopupMenu().addSeparator(); btnMenuSaveSubmenuForChart = new JMenu("Save"); chartPanel.getPopupMenu().add(btnMenuSaveSubmenuForChart); if (JDBCPointDao.points.isEmpty()) { btnSaveAsVCC.setEnabled(false); } saveChartAsPng(chartPanel); btnMenuSaveSubmenuForChart.add(btnSaveChartAsPngForChart); btnMenuSaveSubmenuForChart.add(btnSaveTableAsPngForChart); btnMenuSaveSubmenuForChart.add(btnSaveMapAsPngForChart); btnMenuSaveSubmenuForChart.addSeparator(); btnMenuSaveSubmenuForChart.add(btnSaveAsVCC); chartPanel.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseClicked(ChartMouseEvent event) { Rectangle2D dataArea = chartPanel.getScreenDataArea(); JFreeChart chart = event.getChart(); XYPlot plot = (XYPlot) chart.getPlot(); ValueAxis xAxis = plot.getDomainAxis(); double x = xAxis.java2DToValue(event.getTrigger().getX(), dataArea, RectangleEdge.BOTTOM); // make the crosshairs disappear if the mouse is out of range if (!xAxis.getRange().contains(x)) { x = Double.NaN; } x = Math.round(x); if (SwingUtilities.isLeftMouseButton(event.getTrigger()) && event.getTrigger().isShiftDown()) { for (PointDto cord : JDBCPointDao.points) { { if (cord.getPointID() == x) { if (pointTable.getSelectionModel() == null) { for (int i = 0; i < pointTable.getModel().getRowCount(); i++) { if (pointTable.getModel().getValueAt(i, 0).equals(cord.getPointID())) { pointTable.setRowSelectionInterval(i, i); } } } else { for (int i = 0; i < pointTable.getModel().getRowCount(); i++) { if (pointTable.getModel().getValueAt(i, 0).equals(cord.getPointID())) { pointTable.addRowSelectionInterval(pointTable.getSelectedRow(), i); } } } pointTable.scrollRectToVisible( pointTable.getCellRect(pointTable.getSelectedRow(), 0, true)); } } } } else { for (PointDto cord : JDBCPointDao.points) { { if (cord.getPointID() == x) { if (pointTable.getSelectionModel() != null) { pointTable.getSelectionModel().clearSelection(); } for (int i = 0; i < pointTable.getModel().getRowCount(); i++) { if (pointTable.getModel().getValueAt(i, 0).equals(cord.getPointID())) { pointTable.setRowSelectionInterval(i, i); } } pointTable.scrollRectToVisible( pointTable.getCellRect(pointTable.getSelectedRow(), 0, true)); //MainWindow.pointTable.revalidate(); } } } } } @Override public void chartMouseMoved(ChartMouseEvent event) { Rectangle2D dataArea = chartPanel.getScreenDataArea(); JFreeChart chart = event.getChart(); XYPlot plot = (XYPlot) chart.getPlot(); ValueAxis xAxis = plot.getDomainAxis(); double x = xAxis.java2DToValue(event.getTrigger().getX(), dataArea, RectangleEdge.BOTTOM); // make the crosshairs disappear if the mouse is out of range if (!xAxis.getRange().contains(x)) { x = Double.NaN; } double y = DatasetUtilities.findYValue(plot.getDataset(), 0, x); xCrosshair.setValue(x); yCrosshair.setValue(y); x = Math.round(x); for (PointDto cord : JDBCPointDao.points) { if (cord.getPointID() == x) { mapPanel.map().removeMapMarker(mapPanel.getMapPoint()); mapPanel.setMapPoint( new MapMarkerDot(null, null, cord.getPointLatidude(), cord.getPointLongtidude())); mapPanel.setMapPoint(mapPanel.getMapPoint()); mapPanel.getMapPoint().setColor(colorMapMarkerCircle); mapPanel.getMapPoint().setBackColor(colorMapMarkerHover); mapPanel.map().addMapMarker(mapPanel.getMapPoint()); } } } }); XYPlot xyPlot = (XYPlot) chart.getPlot(); ValueAxis rangeAxis = xyPlot.getRangeAxis(); NavigableMap<Double, PointDto> pointDtoSortedSpeedMap = new TreeMap<Double, PointDto>(); if (!JDBCPointDao.points.isEmpty()) { for (PointDto pointDto : JDBCPointDao.points) { pointDtoSortedSpeedMap.put(pointDto.getPointSpeed(), pointDto); } rangeAxis.setRange(pointDtoSortedSpeedMap.firstEntry().getKey() - 0.1, pointDtoSortedSpeedMap.lastEntry().getKey() + 0.1); } CrosshairOverlay crosshairOverlay = new CrosshairOverlay(); xCrosshair = new Crosshair(Double.NaN, Color.GRAY, new BasicStroke(0f)); xCrosshair.setLabelVisible(true); yCrosshair = new Crosshair(Double.NaN, Color.GRAY, new BasicStroke(0f)); yCrosshair.setLabelVisible(true); crosshairOverlay.addDomainCrosshair(xCrosshair); crosshairOverlay.addRangeCrosshair(yCrosshair); chartPanel.addOverlay(crosshairOverlay); graphPanel.removeAll(); graphPanel.add(chartPanel, BorderLayout.CENTER); graphPanel.revalidate(); graphPanel.repaint(); graphMapSplitPanel.revalidate(); }
From source file:com.google.cloud.dns.testing.LocalDnsHelper.java
/** * Lists changes. Next page token is the ID of the last change listed. */// ww w . jav a2 s. co m @VisibleForTesting Response listChanges(String projectId, String zoneName, String query) { Map<String, Object> options = OptionParsers.parseListChangesOptions(query); Response response = checkListOptions(options); if (response != null) { return response; } ZoneContainer zoneContainer = findZone(projectId, zoneName); if (zoneContainer == null) { return Error.NOT_FOUND.response( String.format("The 'parameters.managedZone' resource named '%s' does not exist", zoneName)); } // take a sorted snapshot of the current change list NavigableMap<Integer, Change> changes = new TreeMap<>(); for (Change c : zoneContainer.changes()) { if (c.getId() != null) { changes.put(Integer.valueOf(c.getId()), c); } } String[] fields = (String[]) options.get("fields"); String sortOrder = (String) options.get("sortOrder"); String pageToken = (String) options.get("pageToken"); Integer maxResults = options.get("maxResults") == null ? null : Integer.valueOf((String) options.get("maxResults")); // as the only supported field is change sequence, we are not reading sortBy NavigableSet<Integer> keys; if ("descending".equals(sortOrder)) { keys = changes.descendingKeySet(); } else { keys = changes.navigableKeySet(); } Integer from = null; try { from = Integer.valueOf(pageToken); } catch (NumberFormatException ex) { // ignore page token } keys = from != null ? keys.tailSet(from, false) : keys; NavigableMap<Integer, Change> fragment = from != null && changes.containsKey(from) ? changes.tailMap(from, false) : changes; boolean sizeReached = false; boolean hasMorePages = false; LinkedList<String> serializedResults = new LinkedList<>(); String lastChangeId = null; for (Integer key : keys) { Change change = fragment.get(key); if (sizeReached) { // we do not add this, just note that there would be more and there should be a token hasMorePages = true; break; } else { lastChangeId = change.getId(); try { serializedResults.addLast(jsonFactory.toString(OptionParsers.extractFields(change, fields))); } catch (IOException e) { return Error.INTERNAL_ERROR.response( String.format("Error when serializing change %s in managed zone %s in project %s", lastChangeId, zoneName, projectId)); } } sizeReached = maxResults != null && maxResults.equals(serializedResults.size()); } boolean includePageToken = hasMorePages && (fields == null || Arrays.asList(fields).contains("nextPageToken")); return toListResponse(serializedResults, "changes", lastChangeId, includePageToken); }
From source file:com.mirth.connect.server.controllers.DefaultExtensionController.java
@Override public void initPlugins() { // Order all the plugins by their weight before loading any of them. Map<String, String> pluginNameMap = new HashMap<String, String>(); NavigableMap<Integer, List<String>> weightedPlugins = new TreeMap<Integer, List<String>>(); for (PluginMetaData pmd : getPluginMetaData().values()) { if (isExtensionEnabled(pmd.getName())) { if (pmd.getServerClasses() != null) { for (PluginClass pluginClass : pmd.getServerClasses()) { String clazzName = pluginClass.getName(); int weight = pluginClass.getWeight(); pluginNameMap.put(clazzName, pmd.getName()); List<String> classList = weightedPlugins.get(weight); if (classList == null) { classList = new ArrayList<String>(); weightedPlugins.put(weight, classList); }/*ww w . j av a 2s.c o m*/ classList.add(clazzName); } } } else { logger.warn("Plugin \"" + pmd.getName() + "\" is not enabled."); } } // Load the plugins in order of their weight for (List<String> classList : weightedPlugins.descendingMap().values()) { for (String clazzName : classList) { String pluginName = pluginNameMap.get(clazzName); try { ServerPlugin serverPlugin = (ServerPlugin) Class.forName(clazzName).newInstance(); if (serverPlugin instanceof ServicePlugin) { ServicePlugin servicePlugin = (ServicePlugin) serverPlugin; /* * load any properties that may currently be in the database */ Properties currentProperties = getPluginProperties(pluginName); /* get the default properties for the plugin */ Properties defaultProperties = servicePlugin.getDefaultProperties(); /* * if there are any properties that not currently set, set them to the the * default */ for (Object key : defaultProperties.keySet()) { if (!currentProperties.containsKey(key)) { currentProperties.put(key, defaultProperties.get(key)); } } /* save the properties to the database */ setPluginProperties(pluginName, currentProperties); /* * initialize the plugin with those properties and add it to the list of * loaded plugins */ servicePlugin.init(currentProperties); servicePlugins.put(servicePlugin.getPluginPointName(), servicePlugin); serverPlugins.add(servicePlugin); logger.debug("sucessfully loaded server plugin: " + serverPlugin.getPluginPointName()); } if (serverPlugin instanceof ChannelPlugin) { ChannelPlugin channelPlugin = (ChannelPlugin) serverPlugin; channelPlugins.put(channelPlugin.getPluginPointName(), channelPlugin); serverPlugins.add(channelPlugin); logger.debug( "sucessfully loaded server channel plugin: " + serverPlugin.getPluginPointName()); } if (serverPlugin instanceof CodeTemplateServerPlugin) { CodeTemplateServerPlugin codeTemplateServerPlugin = (CodeTemplateServerPlugin) serverPlugin; codeTemplateServerPlugins.put(codeTemplateServerPlugin.getPluginPointName(), codeTemplateServerPlugin); serverPlugins.add(codeTemplateServerPlugin); logger.debug("sucessfully loaded server code template plugin: " + serverPlugin.getPluginPointName()); } if (serverPlugin instanceof DataTypeServerPlugin) { DataTypeServerPlugin dataTypePlugin = (DataTypeServerPlugin) serverPlugin; dataTypePlugins.put(dataTypePlugin.getPluginPointName(), dataTypePlugin); serverPlugins.add(dataTypePlugin); logger.debug( "sucessfully loaded server data type plugin: " + serverPlugin.getPluginPointName()); } if (serverPlugin instanceof ResourcePlugin) { ResourcePlugin resourcePlugin = (ResourcePlugin) serverPlugin; resourcePlugins.put(resourcePlugin.getPluginPointName(), resourcePlugin); serverPlugins.add(resourcePlugin); logger.debug("Successfully loaded resource plugin: " + resourcePlugin.getPluginPointName()); } if (serverPlugin instanceof TransmissionModeProvider) { TransmissionModeProvider transmissionModeProvider = (TransmissionModeProvider) serverPlugin; transmissionModeProviders.put(transmissionModeProvider.getPluginPointName(), transmissionModeProvider); serverPlugins.add(transmissionModeProvider); logger.debug("Successfully loaded transmission mode provider plugin: " + transmissionModeProvider.getPluginPointName()); } if (serverPlugin instanceof AuthorizationPlugin) { AuthorizationPlugin authorizationPlugin = (AuthorizationPlugin) serverPlugin; if (this.authorizationPlugin != null) { throw new Exception("Multiple Authorization Plugins are not permitted."); } this.authorizationPlugin = authorizationPlugin; serverPlugins.add(authorizationPlugin); logger.debug("sucessfully loaded server authorization plugin: " + serverPlugin.getPluginPointName()); } } catch (Exception e) { logger.error("Error instantiating plugin: " + pluginName, e); } } } }
From source file:de.hybris.platform.acceleratorcms.services.impl.RankingCMSRestrictionService.java
@Override public Collection<AbstractPageModel> evaluatePages(final Collection<AbstractPageModel> pages, final RestrictionData data) { final NavigableMap<Integer, List<AbstractPageModel>> allowedPages = new TreeMap<>(); final Collection<AbstractPageModel> defaultPages = getDefaultPages(pages); for (final AbstractPageModel page : pages) { if (defaultPages.contains(page)) { continue; }// w ww. ja va 2 s . c o m final List<AbstractRestrictionModel> restrictions = page.getRestrictions(); if (restrictions == null || restrictions.isEmpty()) { LOG.debug("Page [" + page.getName() + "] is not default page and contains no restrictions. Skipping this page."); } else { LOG.debug("Evaluating restrictions for page [" + page.getName() + "]."); final boolean onlyOneRestrictionMustApply = page.isOnlyOneRestrictionMustApply(); final boolean allowed = evaluate(restrictions, data, onlyOneRestrictionMustApply); if (allowed) { LOG.debug("Adding page [" + page.getName() + "] to allowed pages"); final Integer countOfMatchingRestrictions = Integer .valueOf(onlyOneRestrictionMustApply ? 1 : restrictions.size()); if (allowedPages.containsKey(countOfMatchingRestrictions)) { // Add to existing list allowedPages.get(countOfMatchingRestrictions).add(page); } else { // Add a new entry final List<AbstractPageModel> list = new ArrayList<>(); list.add(page); allowedPages.put(countOfMatchingRestrictions, list); } } } } final List<AbstractPageModel> result = new ArrayList<>(); if (MapUtils.isNotEmpty(allowedPages)) { // Take the highest match count result.addAll(allowedPages.lastEntry().getValue()); } else { if (defaultPages.size() > 1) { LOG.warn(createMoreThanOneDefaultPageWarning(defaultPages)); } if (CollectionUtils.isNotEmpty(defaultPages)) { LOG.debug("Returning default page"); result.add(defaultPages.iterator().next()); } } return result; }
From source file:com.alibaba.wasp.fserver.EntityGroup.java
/** * Use new value replace old value./*from w ww. j a v a 2s . c om*/ * * @param oldValues * @param action * @return */ private NavigableMap<byte[], NavigableMap<byte[], byte[]>> prepareUpdateValues( NavigableMap<byte[], NavigableMap<byte[], byte[]>> oldValues, UpdateAction action) { Iterator<ColumnStruct> iterator = action.getColumns().iterator(); while (iterator.hasNext()) { ColumnStruct column = iterator.next(); if (column.isIndex()) { NavigableMap<byte[], byte[]> family = oldValues.get(Bytes.toBytes(column.getFamilyName())); byte[] columnName = Bytes.toBytes(column.getColumnName()); family.put(columnName, column.getValue()); } } return oldValues; }
From source file:com.alibaba.wasp.meta.FMetaServicesImplWithoutRetry.java
@Override public NavigableMap<EntityGroupInfo, Result> getServerUserEntityGroups(final ServerName serverName) throws MetaException { final NavigableMap<EntityGroupInfo, Result> egis = new TreeMap<EntityGroupInfo, Result>(); // Fill the above egis map with entries from .FMETA. that have the passed // servername. CollectingVisitor<Result> v = new CollectingVisitor<Result>() { @Override/*from ww w.ja va 2 s . c o m*/ void add(Result r) { if (r == null || r.isEmpty()) return; ServerName sn = ServerName.getServerName(r); if (sn != null && sn.equals(serverName)) this.results.add(r); } }; fullScan(v); List<Result> results = v.getResults(); if (results != null && !results.isEmpty()) { // Convert results to Map keyed by HRI for (Result r : results) { Pair<EntityGroupInfo, ServerName> p = EntityGroupInfo.getEntityGroupInfoAndServerName(r); if (p != null && p.getFirst() != null) egis.put(p.getFirst(), r); } } return egis; }