public void refresh(List<String> keyspaces) throws IOException, ExecutionException, InterruptedException { Iterator<Entry<String, ColumnFamilyStoreMBean>> it = super.getColumnFamilyStoreMBeanProxies(); while (it.hasNext()) { Entry<String, ColumnFamilyStoreMBean> entry = it.next(); if (keyspaces.contains(entry.getKey())) { logger.info( "Refreshing {} {}", entry.getKey(), entry.getValue().getColumnFamilyName()); loadNewSSTables(entry.getKey(), entry.getValue().getColumnFamilyName()); } } }
public Map<String, List<String>> retriableCall() throws Exception { try (JMXNodeTool nodeTool = JMXNodeTool.instance(configuration)) { final Map<String, List<String>> columnfamilies = new HashMap<>(); Iterator<Map.Entry<String, ColumnFamilyStoreMBean>> columnfamilyStoreMBean = nodeTool.getColumnFamilyStoreMBeanProxies(); columnfamilyStoreMBean.forEachRemaining( entry -> { columnfamilies.putIfAbsent(entry.getKey(), new ArrayList<>()); columnfamilies .get(entry.getKey()) .add(entry.getValue().getColumnFamilyName()); }); return columnfamilies; } } }.call();
/** * You must do the compaction before running this to remove the duplicate tokens out of the * server. TODO code it. */ @SuppressWarnings("unchecked") public JSONObject estimateKeys() throws JSONException { Iterator<Entry<String, ColumnFamilyStoreMBean>> it = super.getColumnFamilyStoreMBeanProxies(); JSONObject object = new JSONObject(); while (it.hasNext()) { Entry<String, ColumnFamilyStoreMBean> entry = it.next(); object.put("keyspace", entry.getKey()); object.put("column_family", entry.getValue().getColumnFamilyName()); object.put("estimated_size", entry.getValue().estimateKeys()); } return object; }
public int compare(Entry<String, ColumnFamilyStoreMBean> e1, Entry<String, ColumnFamilyStoreMBean> e2) { //compare keyspace, then CF name, then normal vs. index int keyspaceNameCmp = e1.getKey().compareTo(e2.getKey()); if(keyspaceNameCmp != 0) return keyspaceNameCmp; // get CF name and split it for index name String e1CF[] = e1.getValue().getColumnFamilyName().split("\\."); String e2CF[] = e2.getValue().getColumnFamilyName().split("\\."); assert e1CF.length <= 2 && e2CF.length <= 2 : "unexpected split count for column family name"; //if neither are indexes, just compare CF names if(e1CF.length == 1 && e2CF.length == 1) return e1CF[0].compareTo(e2CF[0]); //check if it's the same CF int cfNameCmp = e1CF[0].compareTo(e2CF[0]); if(cfNameCmp != 0) return cfNameCmp; // if both are indexes (for the same CF), compare them if(e1CF.length == 2 && e2CF.length == 2) return e1CF[1].compareTo(e2CF[1]); //if length of e1CF is 1, it's not an index, so sort it higher return e1CF.length == 1 ? 1 : -1; } });
public int compare(Entry<String, ColumnFamilyStoreMBean> e1, Entry<String, ColumnFamilyStoreMBean> e2) { //compare keyspace, then CF name, then normal vs. index int keyspaceNameCmp = e1.getKey().compareTo(e2.getKey()); if(keyspaceNameCmp != 0) return keyspaceNameCmp; // get CF name and split it for index name String e1CF[] = e1.getValue().getColumnFamilyName().split("\\."); String e2CF[] = e2.getValue().getColumnFamilyName().split("\\."); assert e1CF.length <= 2 && e2CF.length <= 2 : "unexpected split count for table name"; //if neither are indexes, just compare CF names if(e1CF.length == 1 && e2CF.length == 1) return e1CF[0].compareTo(e2CF[0]); //check if it's the same CF int cfNameCmp = e1CF[0].compareTo(e2CF[0]); if(cfNameCmp != 0) return cfNameCmp; // if both are indexes (for the same CF), compare them if(e1CF.length == 2 && e2CF.length == 2) return e1CF[1].compareTo(e2CF[1]); //if length of e1CF is 1, it's not an index, so sort it higher return e1CF.length == 1 ? 1 : -1; } });
public int compare(Entry<String, ColumnFamilyStoreMBean> e1, Entry<String, ColumnFamilyStoreMBean> e2) { //compare keyspace, then CF name, then normal vs. index int keyspaceNameCmp = e1.getKey().compareTo(e2.getKey()); if(keyspaceNameCmp != 0) return keyspaceNameCmp; // get CF name and split it for index name String e1CF[] = e1.getValue().getColumnFamilyName().split("\\."); String e2CF[] = e2.getValue().getColumnFamilyName().split("\\."); assert e1CF.length <= 2 && e2CF.length <= 2 : "unexpected split count for table name"; //if neither are indexes, just compare CF names if(e1CF.length == 1 && e2CF.length == 1) return e1CF[0].compareTo(e2CF[0]); //check if it's the same CF int cfNameCmp = e1CF[0].compareTo(e2CF[0]); if(cfNameCmp != 0) return cfNameCmp; // if both are indexes (for the same CF), compare them if(e1CF.length == 2 && e2CF.length == 2) return e1CF[1].compareTo(e2CF[1]); //if length of e1CF is 1, it's not an index, so sort it higher return e1CF.length == 1 ? 1 : -1; } });
public int compare(Entry<String, ColumnFamilyStoreMBean> e1, Entry<String, ColumnFamilyStoreMBean> e2) { //compare keyspace, then CF name, then normal vs. index int keyspaceNameCmp = e1.getKey().compareTo(e2.getKey()); if(keyspaceNameCmp != 0) return keyspaceNameCmp; // get CF name and split it for index name String e1CF[] = e1.getValue().getColumnFamilyName().split("\\."); String e2CF[] = e2.getValue().getColumnFamilyName().split("\\."); assert e1CF.length <= 2 && e2CF.length <= 2 : "unexpected split count for table name"; //if neither are indexes, just compare CF names if(e1CF.length == 1 && e2CF.length == 1) return e1CF[0].compareTo(e2CF[0]); //check if it's the same CF int cfNameCmp = e1CF[0].compareTo(e2CF[0]); if(cfNameCmp != 0) return cfNameCmp; // if both are indexes (for the same CF), compare them if(e1CF.length == 2 && e2CF.length == 2) return e1CF[1].compareTo(e2CF[1]); //if length of e1CF is 1, it's not an index, so sort it higher return e1CF.length == 1 ? 1 : -1; } });
/** * Returns the total off heap memory used in MB. * @return the total off heap memory used in MB. */ private static double getOffHeapMemoryUsed(NodeProbe probe) { long offHeapMemUsedInBytes = 0; // get a list of column family stores Iterator<Map.Entry<String, ColumnFamilyStoreMBean>> cfamilies = probe.getColumnFamilyStoreMBeanProxies(); while (cfamilies.hasNext()) { Entry<String, ColumnFamilyStoreMBean> entry = cfamilies.next(); String keyspaceName = entry.getKey(); String cfName = entry.getValue().getColumnFamilyName(); offHeapMemUsedInBytes += (Long) probe.getColumnFamilyMetric(keyspaceName, cfName, "MemtableOffHeapSize"); offHeapMemUsedInBytes += (Long) probe.getColumnFamilyMetric(keyspaceName, cfName, "BloomFilterOffHeapMemoryUsed"); offHeapMemUsedInBytes += (Long) probe.getColumnFamilyMetric(keyspaceName, cfName, "IndexSummaryOffHeapMemoryUsed"); offHeapMemUsedInBytes += (Long) probe.getColumnFamilyMetric(keyspaceName, cfName, "CompressionMetadataOffHeapMemoryUsed"); } return offHeapMemUsedInBytes / (1024d * 1024); } }
/** * Returns the total off heap memory used in MB. * @return the total off heap memory used in MB. */ private static double getOffHeapMemoryUsed(NodeProbe probe) { long offHeapMemUsedInBytes = 0; // get a list of column family stores Iterator<Map.Entry<String, ColumnFamilyStoreMBean>> cfamilies = probe.getColumnFamilyStoreMBeanProxies(); while (cfamilies.hasNext()) { Entry<String, ColumnFamilyStoreMBean> entry = cfamilies.next(); String keyspaceName = entry.getKey(); String cfName = entry.getValue().getColumnFamilyName(); offHeapMemUsedInBytes += (Long) probe.getColumnFamilyMetric(keyspaceName, cfName, "MemtableOffHeapSize"); offHeapMemUsedInBytes += (Long) probe.getColumnFamilyMetric(keyspaceName, cfName, "BloomFilterOffHeapMemoryUsed"); offHeapMemUsedInBytes += (Long) probe.getColumnFamilyMetric(keyspaceName, cfName, "IndexSummaryOffHeapMemoryUsed"); offHeapMemUsedInBytes += (Long) probe.getColumnFamilyMetric(keyspaceName, cfName, "CompressionMetadataOffHeapMemoryUsed"); } return offHeapMemUsedInBytes / (1024d * 1024); } }
/** * Returns the total off heap memory used in MB. * @return the total off heap memory used in MB. */ private static double getOffHeapMemoryUsed(NodeProbe probe) { long offHeapMemUsedInBytes = 0; // get a list of column family stores Iterator<Map.Entry<String, ColumnFamilyStoreMBean>> cfamilies = probe.getColumnFamilyStoreMBeanProxies(); while (cfamilies.hasNext()) { Entry<String, ColumnFamilyStoreMBean> entry = cfamilies.next(); String keyspaceName = entry.getKey(); String cfName = entry.getValue().getColumnFamilyName(); offHeapMemUsedInBytes += (Long) probe.getColumnFamilyMetric(keyspaceName, cfName, "MemtableOffHeapSize"); offHeapMemUsedInBytes += (Long) probe.getColumnFamilyMetric(keyspaceName, cfName, "BloomFilterOffHeapMemoryUsed"); offHeapMemUsedInBytes += (Long) probe.getColumnFamilyMetric(keyspaceName, cfName, "IndexSummaryOffHeapMemoryUsed"); offHeapMemUsedInBytes += (Long) probe.getColumnFamilyMetric(keyspaceName, cfName, "CompressionMetadataOffHeapMemoryUsed"); } return offHeapMemUsedInBytes / (1024d * 1024); } }
/** * Returns the total off heap memory used in MB. * @return the total off heap memory used in MB. */ private static double getOffHeapMemoryUsed(NodeProbe probe) { long offHeapMemUsedInBytes = 0; // get a list of column family stores Iterator<Map.Entry<String, ColumnFamilyStoreMBean>> cfamilies = probe.getColumnFamilyStoreMBeanProxies(); while (cfamilies.hasNext()) { Entry<String, ColumnFamilyStoreMBean> entry = cfamilies.next(); String keyspaceName = entry.getKey(); String cfName = entry.getValue().getColumnFamilyName(); offHeapMemUsedInBytes += (Long) probe.getColumnFamilyMetric(keyspaceName, cfName, "MemtableOffHeapSize"); offHeapMemUsedInBytes += (Long) probe.getColumnFamilyMetric(keyspaceName, cfName, "BloomFilterOffHeapMemoryUsed"); offHeapMemUsedInBytes += (Long) probe.getColumnFamilyMetric(keyspaceName, cfName, "IndexSummaryOffHeapMemoryUsed"); offHeapMemUsedInBytes += (Long) probe.getColumnFamilyMetric(keyspaceName, cfName, "CompressionMetadataOffHeapMemoryUsed"); } return offHeapMemUsedInBytes / (1024d * 1024); } }
ColumnFamilyStoreMBean cfsProxy = entry.getValue(); if (!cfstoreMap.containsKey(keyspaceName) && filter.isColumnFamilyIncluded(entry.getKey(), cfsProxy.getColumnFamilyName())) } else if (filter.isColumnFamilyIncluded(entry.getKey(), cfsProxy.getColumnFamilyName())) for (ColumnFamilyStoreMBean cfstore : columnFamilies) String cfName = cfstore.getColumnFamilyName(); long writeCount = ((JmxReporter.TimerMBean) probe.getColumnFamilyMetric(keyspaceName, cfName, "WriteLatency")).getCount(); long readCount = ((JmxReporter.TimerMBean) probe.getColumnFamilyMetric(keyspaceName, cfName, "ReadLatency")).getCount(); String cfName = cfstore.getColumnFamilyName(); if (cfName.contains(".")) System.out.println("\t\tTable (index): " + cfName);