public static String getHostname(Configuration conf, boolean isMaster) throws UnknownHostException { String hostname = conf.get(isMaster? HRegionServer.MASTER_HOSTNAME_KEY : HRegionServer.RS_HOSTNAME_KEY); if (hostname == null || hostname.isEmpty()) { String masterOrRS = isMaster ? "master" : "regionserver"; return Strings.domainNamePointerToHostName(DNS.getDefaultHost( conf.get("hbase." + masterOrRS + ".dns.interface", "default"), conf.get("hbase." + masterOrRS + ".dns.nameserver", "default"))); } else { LOG.info("hostname is configured to be " + hostname); return hostname; } }
/** * Append to a StringBuilder a key/value. * Uses default separators. * @param sb StringBuilder to use * @param key Key to append. * @param value Value to append. * @return Passed <code>sb</code> populated with key/value. */ public static StringBuilder appendKeyValue(final StringBuilder sb, final String key, final Object value) { return appendKeyValue(sb, key, value, DEFAULT_SEPARATOR, DEFAULT_KEYVALUE_SEPARATOR); }
protected static String toStringWithPadding(final KeyValue kv, final int maxRowLength, int maxFamilyLength, int maxQualifierLength, int maxTimestampLength, boolean includeMeta) { String leadingLengths = ""; String familyLength = kv.getFamilyLength() + " "; if (includeMeta) { leadingLengths += Strings.padFront(kv.getKeyLength() + "", '0', 4); leadingLengths += " "; leadingLengths += Strings.padFront(kv.getValueLength() + "", '0', 4); leadingLengths += " "; leadingLengths += Strings.padFront(kv.getRowLength() + "", '0', 2); leadingLengths += " "; } int spacesAfterRow = maxRowLength - getRowString(kv).length() + 2; int spacesAfterFamily = maxFamilyLength - getFamilyString(kv).length() + 2; int spacesAfterQualifier = maxQualifierLength - getQualifierString(kv).length() + 1; int spacesAfterTimestamp = maxTimestampLength - Long.valueOf(kv.getTimestamp()).toString().length() + 1; return leadingLengths + getRowString(kv) + StringUtils.repeat(' ', spacesAfterRow) + familyLength + getFamilyString(kv) + StringUtils.repeat(' ', spacesAfterFamily) + getQualifierString(kv) + StringUtils.repeat(' ', spacesAfterQualifier) + getTimestampString(kv) + StringUtils.repeat(' ', spacesAfterTimestamp) + getTypeString(kv) + " " + getValueString(kv); }
protected static String toStringWithPadding(final KeyValue kv, final int maxRowLength, int maxFamilyLength, int maxQualifierLength, int maxTimestampLength, boolean includeMeta) { String leadingLengths = ""; String familyLength = kv.getFamilyLength() + " "; if (includeMeta) { leadingLengths += Strings.padFront(kv.getKeyLength() + "", '0', 4); leadingLengths += " "; leadingLengths += Strings.padFront(kv.getValueLength() + "", '0', 4); leadingLengths += " "; leadingLengths += Strings.padFront(kv.getRowLength() + "", '0', 2); leadingLengths += " "; } int spacesAfterRow = maxRowLength - getRowString(kv).length() + 2; int spacesAfterFamily = maxFamilyLength - getFamilyString(kv).length() + 2; int spacesAfterQualifier = maxQualifierLength - getQualifierString(kv).length() + 1; int spacesAfterTimestamp = maxTimestampLength - Long.valueOf(kv.getTimestamp()).toString().length() + 1; return leadingLengths + getRowString(kv) + Strings.repeat(' ', spacesAfterRow) + familyLength + getFamilyString(kv) + Strings.repeat(' ', spacesAfterFamily) + getQualifierString(kv) + Strings.repeat(' ', spacesAfterQualifier) + getTimestampString(kv) + Strings.repeat(' ', spacesAfterTimestamp) + getTypeString(kv) + " " + getValueString(kv); }
/** * Set the user filter regex * @param regex the user filter * @return the quota filter object */ public QuotaFilter setUserFilter(final String regex) { this.userRegex = regex; hasFilters |= !Strings.isEmpty(regex); return this; }
/** * Set the namespace filter regex * @param regex the namespace filter * @return the quota filter object */ public QuotaFilter setNamespaceFilter(final String regex) { this.namespaceRegex = regex; hasFilters |= !Strings.isEmpty(regex); return this; }
String reverseDNS(InetAddress ipAddress) throws UnknownHostException { String hostName = this.reverseDNSCacheMap.get(ipAddress); if (hostName == null) { String ipAddressString = null; try { ipAddressString = DNS.reverseDns(ipAddress, null); } catch (Exception e) { // We can use InetAddress in case the jndi failed to pull up the reverse DNS entry from the // name service. Also, in case of ipv6, we need to use the InetAddress since resolving // reverse DNS using jndi doesn't work well with ipv6 addresses. ipAddressString = InetAddress.getByName(ipAddress.getHostAddress()).getHostName(); } if (ipAddressString == null) throw new UnknownHostException("No host found for " + ipAddress); hostName = Strings.domainNamePointerToHostName(ipAddressString); this.reverseDNSCacheMap.put(ipAddress, hostName); } return hostName; }
/** * 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(); }
/****************** standard methods ************************/ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(Strings.padFront(builderNode.getOutputArrayOffset() + "", ' ', 3) + ","); sb.append("["); sb.append(Bytes.toString(token)); sb.append("]->"); sb.append(parentStartPosition); return sb.toString(); }
/** * Set the table filter regex * @param regex the table filter * @return the quota filter object */ public QuotaFilter setTableFilter(final String regex) { this.tableRegex = regex; hasFilters |= !Strings.isEmpty(regex); return this; }
String myAddress = Strings.domainNamePointerToHostName(DNS.getDefaultHost( conf.get("hbase.zookeeper.dns.interface","default"), conf.get("hbase.zookeeper.dns.nameserver","default")));
/** * sourceToString * @return a string contains sourceReplicationLoad information */ public String sourceToString() { if (this.sourceMetricsList == null) return null; StringBuilder sb = new StringBuilder(); for (ClusterStatusProtos.ReplicationLoadSource rls : this.replicationLoadSourceList) { 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(); }
public String getPaddedTokenAndOccurrenceString() { StringBuilder sb = new StringBuilder(); sb.append(getBnlIndicator(true)); sb.append(Strings.padFront(numOccurrences + "", ' ', 3)); sb.append(Strings.padFront(nodeDepth + "", ' ', 3)); if (outputArrayOffset >= 0) { sb.append(Strings.padFront(outputArrayOffset + "", ' ', 3)); } sb.append(" "); for (int i = 0; i < tokenStartOffset; ++i) { sb.append(" "); } sb.append(Bytes.toString(token.deepCopyToNewArray()).replaceAll(" ", "_")); return sb.toString(); }
@Override public PDone expand(PCollection<FeatureRowExtended> input) { Write write; if (Strings.isEmpty(errorsStoreType)) { write = new NoOpIO.Write(); } else { write = getErrorStore().create(this.errorsStoreSpec, specs); } input.apply("errors to " + String.valueOf(errorsStoreType), write); return PDone.in(input.getPipeline()); }
if(name.equals(REST_AUTHENTICATION_PRINCIPAL)) { try { String machineName = Strings.domainNamePointerToHostName( DNS.getDefaultHost(conf.get(REST_DNS_INTERFACE, "default"), conf.get(REST_DNS_NAMESERVER, "default")));
StringBuilder sb = Strings.appendKeyValue(new StringBuilder(), "requestsPerSecond", Double.valueOf(getRequestsPerSecond())); Strings.appendKeyValue(sb, "numberOfOnlineRegions", Integer.valueOf(getNumberOfRegions())); Strings.appendKeyValue(sb, "usedHeapMB", Integer.valueOf(this.getUsedHeapMB())); Strings.appendKeyValue(sb, "maxHeapMB", Integer.valueOf(getMaxHeapMB())); Strings.appendKeyValue(sb, "numberOfStores", Integer.valueOf(this.stores)); Strings.appendKeyValue(sb, "numberOfStorefiles", Integer.valueOf(this.storefiles)); Strings.appendKeyValue(sb, "storefileUncompressedSizeMB", Integer.valueOf(this.storeUncompressedSizeMB)); Strings.appendKeyValue(sb, "storefileSizeMB", Integer.valueOf(this.storefileSizeMB)); if (this.storeUncompressedSizeMB != 0) { Strings.appendKeyValue(sb, "compressionRatio", String.format("%.4f", (float) this.storefileSizeMB / (float) this.storeUncompressedSizeMB)); Strings.appendKeyValue(sb, "memstoreSizeMB", Integer.valueOf(this.memstoreSizeMB)); Strings.appendKeyValue(sb, "storefileIndexSizeKB", Long.valueOf(this.storefileIndexSizeKB)); Strings.appendKeyValue(sb, "readRequestsCount", Long.valueOf(this.readRequestsCount)); Strings.appendKeyValue(sb, "cpRequestsCount", Long.valueOf(this.cpRequestsCount)); Strings.appendKeyValue(sb, "filteredReadRequestsCount", Long.valueOf(this.filteredReadRequestsCount)); Strings.appendKeyValue(sb, "writeRequestsCount", Long.valueOf(this.writeRequestsCount)); Strings.appendKeyValue(sb, "rootIndexSizeKB", Integer.valueOf(this.rootIndexSizeKB)); Strings.appendKeyValue(sb, "totalStaticIndexSizeKB", Integer.valueOf(this.totalStaticIndexSizeKB)); Strings.appendKeyValue(sb, "totalStaticBloomSizeKB", Integer.valueOf(this.totalStaticBloomSizeKB)); Strings.appendKeyValue(sb, "totalCompactingKVs", Long.valueOf(this.totalCompactingKVs)); Strings.appendKeyValue(sb, "currentCompactedKVs", Long.valueOf(this.currentCompactedKVs));
/****************** standard methods ************************/ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(Strings.padFront(builderNode.getOutputArrayOffset() + "", ' ', 3) + ","); sb.append("["); sb.append(Bytes.toString(token)); sb.append("]->"); sb.append(parentStartPosition); return sb.toString(); }
@Inject public ErrorsStoreTransform( ImportJobOptions options, Specs specs, List<ErrorsStore> errorsStores) { this.specs = specs; this.errorsStores = errorsStores; this.errorsStoreType = options.getErrorsStoreType(); if (!Strings.isEmpty(errorsStoreType)) { this.errorsStoreSpec = StorageSpec.newBuilder() .setType(errorsStoreType) .putAllOptions(convertJsonStringToMap(options.getErrorsStoreOptions())) .build(); } }
try { if (provider.shouldLoginFromKeytab()) { String host = Strings.domainNamePointerToHostName(DNS.getDefaultHost( conf.get("hbase.client.dns.interface", "default"), conf.get("hbase.client.dns.nameserver", "default")));
StringBuilder sb = Strings.appendKeyValue(new StringBuilder(), "numberOfStores", this.getStores()); Strings.appendKeyValue(sb, "numberOfStorefiles", this.getStorefiles()); Strings.appendKeyValue(sb, "storefileUncompressedSizeMB", this.getStoreUncompressedSizeMB()); Strings.appendKeyValue(sb, "lastMajorCompactionTimestamp", this.getLastMajorCompactionTs()); Strings.appendKeyValue(sb, "storefileSizeMB", this.getStorefileSizeMB()); if (this.getStoreUncompressedSizeMB() != 0) { Strings.appendKeyValue(sb, "compressionRatio", String.format("%.4f", (float) this.getStorefileSizeMB() / (float) this.getStoreUncompressedSizeMB())); Strings.appendKeyValue(sb, "memstoreSizeMB", this.getMemStoreSizeMB()); Strings.appendKeyValue(sb, "readRequestsCount", this.getReadRequestsCount()); Strings.appendKeyValue(sb, "writeRequestsCount", this.getWriteRequestsCount()); Strings.appendKeyValue(sb, "rootIndexSizeKB", this.getRootIndexSizeKB()); Strings.appendKeyValue(sb, "totalStaticIndexSizeKB", this.getTotalStaticIndexSizeKB()); Strings.appendKeyValue(sb, "totalStaticBloomSizeKB", this.getTotalStaticBloomSizeKB()); Strings.appendKeyValue(sb, "totalCompactingKVs", this.getTotalCompactingKVs()); Strings.appendKeyValue(sb, "currentCompactedKVs", this.getCurrentCompactedKVs());