Java Code Examples for org.apache.hadoop.hbase.util.Strings#appendKeyValue()

The following examples show how to use org.apache.hadoop.hbase.util.Strings#appendKeyValue() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: hbase   File: ReplicationLoad.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * sourceToString
 * @return a string contains sourceReplicationLoad information
 */
public String sourceToString() {
  StringBuilder sb = new StringBuilder();

  for (ClusterStatusProtos.ReplicationLoadSource rls :
      this.replicationLoadSourceEntries) {

    sb = Strings.appendKeyValue(sb, "\n           PeerID", rls.getPeerID());
    sb = Strings.appendKeyValue(sb, "AgeOfLastShippedOp", rls.getAgeOfLastShippedOp());
    sb = Strings.appendKeyValue(sb, "SizeOfLogQueue", rls.getSizeOfLogQueue());
    sb =
        Strings.appendKeyValue(sb, "TimestampsOfLastShippedOp",
            (new Date(rls.getTimeStampOfLastShippedOp()).toString()));
    sb = Strings.appendKeyValue(sb, "Replication Lag", rls.getReplicationLag());
  }

  return sb.toString();
}
 
Example 2
Source Project: hbase   File: ReplicationLoad.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * sinkToString
 * @return a string contains sinkReplicationLoad information
 */
public String sinkToString() {
  if (this.replicationLoadSink == null) return null;

  StringBuilder sb = new StringBuilder();
  sb =
      Strings.appendKeyValue(sb, "AgeOfLastAppliedOp",
        this.replicationLoadSink.getAgeOfLastAppliedOp());
  sb =
      Strings.appendKeyValue(sb, "TimestampsOfLastAppliedOp",
        (new Date(this.replicationLoadSink.getTimeStampsOfLastAppliedOp()).toString()));

  return sb.toString();
}
 
Example 3
Source Project: hbase   File: UserMetricsBuilder.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
  StringBuilder sb = Strings
      .appendKeyValue(new StringBuilder(), "readRequestCount", this.getReadRequestCount());
  Strings.appendKeyValue(sb, "writeRequestCount", this.getWriteRequestCount());
  Strings.appendKeyValue(sb, "filteredReadRequestCount", this.getFilteredReadRequests());
  return sb.toString();
}
 
Example 4
Source Project: hbase   File: ServerMetricsBuilder.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
  int storeCount = 0;
  int storeFileCount = 0;
  int storeRefCount = 0;
  int maxCompactedStoreFileRefCount = 0;
  long uncompressedStoreFileSizeMB = 0;
  long storeFileSizeMB = 0;
  long memStoreSizeMB = 0;
  long storefileIndexSizeKB = 0;
  long rootLevelIndexSizeKB = 0;
  long readRequestsCount = 0;
  long cpRequestsCount = 0;
  long writeRequestsCount = 0;
  long filteredReadRequestsCount = 0;
  long bloomFilterSizeMB = 0;
  long compactingCellCount = 0;
  long compactedCellCount = 0;
  for (RegionMetrics r : getRegionMetrics().values()) {
    storeCount += r.getStoreCount();
    storeFileCount += r.getStoreFileCount();
    storeRefCount += r.getStoreRefCount();
    int currentMaxCompactedStoreFileRefCount = r.getMaxCompactedStoreFileRefCount();
    maxCompactedStoreFileRefCount = Math.max(maxCompactedStoreFileRefCount,
      currentMaxCompactedStoreFileRefCount);
    uncompressedStoreFileSizeMB += r.getUncompressedStoreFileSize().get(Size.Unit.MEGABYTE);
    storeFileSizeMB += r.getStoreFileSize().get(Size.Unit.MEGABYTE);
    memStoreSizeMB += r.getMemStoreSize().get(Size.Unit.MEGABYTE);
    storefileIndexSizeKB += r.getStoreFileUncompressedDataIndexSize().get(Size.Unit.KILOBYTE);
    readRequestsCount += r.getReadRequestCount();
    cpRequestsCount += r.getCpRequestCount();
    writeRequestsCount += r.getWriteRequestCount();
    filteredReadRequestsCount += r.getFilteredReadRequestCount();
    rootLevelIndexSizeKB += r.getStoreFileRootLevelIndexSize().get(Size.Unit.KILOBYTE);
    bloomFilterSizeMB += r.getBloomFilterSize().get(Size.Unit.MEGABYTE);
    compactedCellCount += r.getCompactedCellCount();
    compactingCellCount += r.getCompactingCellCount();
  }
  StringBuilder sb = Strings.appendKeyValue(new StringBuilder(), "requestsPerSecond",
        Double.valueOf(getRequestCountPerSecond()));
  Strings.appendKeyValue(sb, "numberOfOnlineRegions",
      Integer.valueOf(getRegionMetrics().size()));
  Strings.appendKeyValue(sb, "usedHeapMB", getUsedHeapSize());
  Strings.appendKeyValue(sb, "maxHeapMB", getMaxHeapSize());
  Strings.appendKeyValue(sb, "numberOfStores", storeCount);
  Strings.appendKeyValue(sb, "numberOfStorefiles", storeFileCount);
  Strings.appendKeyValue(sb, "storeRefCount", storeRefCount);
  Strings.appendKeyValue(sb, "maxCompactedStoreFileRefCount",
    maxCompactedStoreFileRefCount);
  Strings.appendKeyValue(sb, "storefileUncompressedSizeMB", uncompressedStoreFileSizeMB);
  Strings.appendKeyValue(sb, "storefileSizeMB", storeFileSizeMB);
  if (uncompressedStoreFileSizeMB != 0) {
    Strings.appendKeyValue(sb, "compressionRatio", String.format("%.4f",
        (float) storeFileSizeMB / (float) uncompressedStoreFileSizeMB));
  }
  Strings.appendKeyValue(sb, "memstoreSizeMB", memStoreSizeMB);
  Strings.appendKeyValue(sb, "readRequestsCount", readRequestsCount);
  Strings.appendKeyValue(sb, "cpRequestsCount", cpRequestsCount);
  Strings.appendKeyValue(sb, "filteredReadRequestsCount", filteredReadRequestsCount);
  Strings.appendKeyValue(sb, "writeRequestsCount", writeRequestsCount);
  Strings.appendKeyValue(sb, "rootIndexSizeKB", rootLevelIndexSizeKB);
  Strings.appendKeyValue(sb, "totalStaticIndexSizeKB", storefileIndexSizeKB);
  Strings.appendKeyValue(sb, "totalStaticBloomSizeKB", bloomFilterSizeMB);
  Strings.appendKeyValue(sb, "totalCompactingKVs", compactingCellCount);
  Strings.appendKeyValue(sb, "currentCompactedKVs", compactedCellCount);
  float compactionProgressPct = Float.NaN;
  if (compactingCellCount > 0) {
    compactionProgressPct =
        Float.valueOf((float) compactedCellCount / compactingCellCount);
  }
  Strings.appendKeyValue(sb, "compactionProgressPct", compactionProgressPct);
  Strings.appendKeyValue(sb, "coprocessors", getCoprocessorNames());
  return sb.toString();
}
 
Example 5
Source Project: hbase   File: RegionMetricsBuilder.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
  StringBuilder sb = Strings.appendKeyValue(new StringBuilder(), "storeCount",
      this.getStoreCount());
  Strings.appendKeyValue(sb, "storeFileCount",
      this.getStoreFileCount());
  Strings.appendKeyValue(sb, "storeRefCount",
    this.getStoreRefCount());
  Strings.appendKeyValue(sb, "maxCompactedStoreFileRefCount",
    this.getMaxCompactedStoreFileRefCount());
  Strings.appendKeyValue(sb, "uncompressedStoreFileSize",
      this.getUncompressedStoreFileSize());
  Strings.appendKeyValue(sb, "lastMajorCompactionTimestamp",
      this.getLastMajorCompactionTimestamp());
  Strings.appendKeyValue(sb, "storeFileSize",
      this.getStoreFileSize());
  if (this.getUncompressedStoreFileSize().get() != 0) {
    Strings.appendKeyValue(sb, "compressionRatio",
        String.format("%.4f",
            (float) this.getStoreFileSize().get(Size.Unit.MEGABYTE) /
            (float) this.getUncompressedStoreFileSize().get(Size.Unit.MEGABYTE)));
  }
  Strings.appendKeyValue(sb, "memStoreSize",
      this.getMemStoreSize());
  Strings.appendKeyValue(sb, "readRequestCount",
      this.getReadRequestCount());
  Strings.appendKeyValue(sb, "cpRequestCount",
      this.getCpRequestCount());
  Strings.appendKeyValue(sb, "writeRequestCount",
      this.getWriteRequestCount());
  Strings.appendKeyValue(sb, "rootLevelIndexSize",
      this.getStoreFileRootLevelIndexSize());
  Strings.appendKeyValue(sb, "uncompressedDataIndexSize",
      this.getStoreFileUncompressedDataIndexSize());
  Strings.appendKeyValue(sb, "bloomFilterSize",
      this.getBloomFilterSize());
  Strings.appendKeyValue(sb, "compactingCellCount",
      this.getCompactingCellCount());
  Strings.appendKeyValue(sb, "compactedCellCount",
      this.getCompactedCellCount());
  float compactionProgressPct = Float.NaN;
  if (this.getCompactingCellCount() > 0) {
    compactionProgressPct = ((float) this.getCompactedCellCount() /
        (float) this.getCompactingCellCount());
  }
  Strings.appendKeyValue(sb, "compactionProgressPct",
      compactionProgressPct);
  Strings.appendKeyValue(sb, "completedSequenceId",
      this.getCompletedSequenceId());
  Strings.appendKeyValue(sb, "dataLocality",
      this.getDataLocality());
  Strings.appendKeyValue(sb, "dataLocalityForSsd",
      this.getDataLocalityForSsd());
  return sb.toString();
}