/** * Get a mutable table info for the specified table and server */ private TableInfo getTableInfo(SortedMap<TServerInstance,TabletServerStatus> currentCopy, Multimap<TServerInstance,String> serverTableIdCopied, String tableId, TServerInstance server) { TableInfo newInfo = null; if (currentCopy.containsKey(server)) { Map<String,TableInfo> newTableMap = currentCopy.get(server).getTableMap(); if (newTableMap != null) { newInfo = newTableMap.get(tableId); if (newInfo != null) { Collection<String> tableIdCopied = serverTableIdCopied.get(server); if (tableIdCopied.isEmpty()) { newTableMap = new HashMap<>(newTableMap); currentCopy.get(server).setTableMap(newTableMap); } if (!tableIdCopied.contains(tableId)) { newInfo = new TableInfo(newInfo); newTableMap.put(tableId, newInfo); tableIdCopied.add(tableId); } } } } return newInfo; }
for (Entry<TServerInstance,TabletServerStatus> e : current.entrySet()) { long numTablets = 0; for (TableInfo ti : e.getValue().getTableMap().values()) { numTablets += ti.tablets;
for (Entry<TServerInstance,TabletServerStatus> e : current.entrySet()) { long tabletCount = 0; for (TableInfo ti : e.getValue().getTableMap().values()) { tabletCount += ti.tablets; for (String tableId : e.getValue().getTableMap().keySet()) { Table.ID id = Table.ID.of(tableId); if (!moveMetadata && MetadataTable.ID.equals(id))
public java.lang.Object getFieldValue(_Fields field) { switch (field) { case TABLE_MAP: return getTableMap();
for (Entry<TServerInstance,TabletServerStatus> e : current.entrySet()) { long numTablets = 0; for (TableInfo ti : e.getValue().getTableMap().values()) { numTablets += ti.tablets;
@Override public void getAssignments(SortedMap<TServerInstance,TabletServerStatus> current, Map<KeyExtent,TServerInstance> unassigned, Map<KeyExtent,TServerInstance> assignments) { long total = assignments.size() + unassigned.size(); long avg = (long) Math.ceil(((double) total) / current.size()); Map<TServerInstance,Long> toAssign = new HashMap<TServerInstance,Long>(); List<TServerInstance> tServerArray = new ArrayList<TServerInstance>(); for (Entry<TServerInstance,TabletServerStatus> e : current.entrySet()) { long numTablets = 0; for (TableInfo ti : e.getValue().getTableMap().values()) { numTablets += ti.tablets; } if (numTablets < avg) { tServerArray.add(e.getKey()); toAssign.put(e.getKey(), avg - numTablets); } } for (KeyExtent ke : unassigned.keySet()) { int index = r.nextInt(tServerArray.size()); TServerInstance dest = tServerArray.get(index); assignments.put(ke, dest); long remaining = toAssign.get(dest).longValue() - 1; if (remaining == 0) { tServerArray.remove(index); toAssign.remove(dest); } else { toAssign.put(dest, remaining); } } }
/** * Get a mutable table info for the specified table and server */ private TableInfo getTableInfo(SortedMap<TServerInstance,TabletServerStatus> currentCopy, Multimap<TServerInstance,String> serverTableIdCopied, String tableId, TServerInstance server) { TableInfo newInfo = null; if (currentCopy.containsKey(server)) { Map<String,TableInfo> newTableMap = currentCopy.get(server).getTableMap(); if (newTableMap != null) { newInfo = newTableMap.get(tableId); if (newInfo != null) { Collection<String> tableIdCopied = serverTableIdCopied.get(server); if (tableIdCopied.isEmpty()) { newTableMap = new HashMap<>(newTableMap); currentCopy.get(server).setTableMap(newTableMap); } if (!tableIdCopied.contains(tableId)) { newInfo = new TableInfo(newInfo); newTableMap.put(tableId, newInfo); tableIdCopied.add(tableId); } } } } return newInfo; }
for (Entry<TServerInstance,TabletServerStatus> e : current.entrySet()) { long tabletCount = 0; for (TableInfo ti : e.getValue().getTableMap().values()) { tabletCount += ti.tablets; for (String tableId : e.getValue().getTableMap().keySet()) { if (!moveMetadata && MetadataTable.ID.equals(tableId)) continue;
for (Entry<TServerInstance,TabletServerStatus> e : current.entrySet()) { long tabletCount = 0; for (TableInfo ti : e.getValue().getTableMap().values()) { tabletCount += ti.tablets; for (String table : e.getValue().getTableMap().keySet()) { if (!moveMetadata && "!METADATA".equals(table)) continue;
Arrays.fill(tabletsPerServer, 0l); for (int i = 0; i < stats.getTServerInfoSize(); i++) { for (Map.Entry<String,TableInfo> entry : stats.getTServerInfo().get(i).getTableMap() .entrySet()) { tabletsPerServer[i] += entry.getValue().getTablets();
public Object getFieldValue(_Fields field) { switch (field) { case TABLE_MAP: return getTableMap();