当前位置: 首页>>代码示例>>Java>>正文


Java Strings类代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.util.Strings的典型用法代码示例。如果您正苦于以下问题:Java Strings类的具体用法?Java Strings怎么用?Java Strings使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Strings类属于org.apache.hadoop.hbase.util包,在下文中一共展示了Strings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sourceToString

import org.apache.hadoop.hbase.util.Strings; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:ReplicationLoad.java

示例2: reverseDNS

import org.apache.hadoop.hbase.util.Strings; //导入依赖的package包/类
/**
 * @deprecated mistakenly made public in 0.98.7. scope will change to package-private
 */
@Deprecated
public String reverseDNS(InetAddress ipAddress) throws NamingException, 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;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:TableInputFormatBase.java

示例3: toStringWithPadding

import org.apache.hadoop.hbase.util.Strings; //导入依赖的package包/类
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);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:24,代码来源:KeyValueTestUtil.java

示例4: reverseDNS

import org.apache.hadoop.hbase.util.Strings; //导入依赖的package包/类
private static String reverseDNS(InetAddress ipAddress) throws NamingException, UnknownHostException {
	String hostName = 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);
		reverseDNSCacheMap.put(ipAddress, hostName);
	}
	
	return hostName;
}
 
开发者ID:mini666,项目名称:hive-phoenix-handler,代码行数:25,代码来源:PhoenixStorageHandlerUtil.java

示例5: appendHistogram

import org.apache.hadoop.hbase.util.Strings; //导入依赖的package包/类
private StringBuilder appendHistogram(StringBuilder sb, 
    MetricsHistogram histogram) {
  sb = Strings.appendKeyValue(sb, 
      histogram.getName() + "Mean", 
      StringUtils.limitDecimalTo2(histogram.getMean()));
  sb = Strings.appendKeyValue(sb, 
      histogram.getName() + "Count", 
      StringUtils.limitDecimalTo2(histogram.getCount()));
  final Snapshot s = histogram.getSnapshot();
  sb = Strings.appendKeyValue(sb, 
      histogram.getName() + "Median", 
      StringUtils.limitDecimalTo2(s.getMedian()));
  sb = Strings.appendKeyValue(sb, 
      histogram.getName() + "75th", 
      StringUtils.limitDecimalTo2(s.get75thPercentile()));
  sb = Strings.appendKeyValue(sb, 
      histogram.getName() + "95th", 
      StringUtils.limitDecimalTo2(s.get95thPercentile()));
  sb = Strings.appendKeyValue(sb, 
      histogram.getName() + "99th", 
      StringUtils.limitDecimalTo2(s.get99thPercentile()));
  sb = Strings.appendKeyValue(sb, 
      histogram.getName() + "999th", 
      StringUtils.limitDecimalTo2(s.get999thPercentile()));
  return sb;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:27,代码来源:RegionServerMetrics.java

示例6: TokenServer

import org.apache.hadoop.hbase.util.Strings; //导入依赖的package包/类
public TokenServer(Configuration conf) throws IOException {
  this.conf = conf;
  this.startcode = EnvironmentEdgeManager.currentTime();
  // Server to handle client requests.
  String hostname =
    Strings.domainNamePointerToHostName(DNS.getDefaultHost("default", "default"));
  int port = 0;
  // Creation of an ISA will force a resolve.
  InetSocketAddress initialIsa = new InetSocketAddress(hostname, port);
  if (initialIsa.getAddress() == null) {
    throw new IllegalArgumentException("Failed resolve of " + initialIsa);
  }
  final List<BlockingServiceAndInterface> sai =
    new ArrayList<BlockingServiceAndInterface>(1);
  BlockingService service =
    AuthenticationProtos.AuthenticationService.newReflectiveBlockingService(this);
  sai.add(new BlockingServiceAndInterface(service,
    AuthenticationProtos.AuthenticationService.BlockingInterface.class));
  this.rpcServer =
    new RpcServer(this, "tokenServer", sai, initialIsa, conf, new FifoRpcScheduler(conf, 1));
  this.isa = this.rpcServer.getListenerAddress();
  this.sleeper = new Sleeper(1000, this);
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:24,代码来源:TestTokenAuthentication.java

示例7: TokenServer

import org.apache.hadoop.hbase.util.Strings; //导入依赖的package包/类
public TokenServer(Configuration conf) throws IOException {
  this.conf = conf;
  this.startcode = EnvironmentEdgeManager.currentTimeMillis();
  // Server to handle client requests.
  String hostname =
    Strings.domainNamePointerToHostName(DNS.getDefaultHost("default", "default"));
  int port = 0;
  // Creation of an ISA will force a resolve.
  InetSocketAddress initialIsa = new InetSocketAddress(hostname, port);
  if (initialIsa.getAddress() == null) {
    throw new IllegalArgumentException("Failed resolve of " + initialIsa);
  }
  final List<BlockingServiceAndInterface> sai =
    new ArrayList<BlockingServiceAndInterface>(1);
  BlockingService service =
    AuthenticationProtos.AuthenticationService.newReflectiveBlockingService(this);
  sai.add(new BlockingServiceAndInterface(service,
    AuthenticationProtos.AuthenticationService.BlockingInterface.class));
  this.rpcServer =
    new RpcServer(this, "tokenServer", sai, initialIsa, conf, new FifoRpcScheduler(conf, 1));
  this.isa = this.rpcServer.getListenerAddress();
  this.sleeper = new Sleeper(1000, this);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:24,代码来源:TestTokenAuthentication.java

示例8: reverseDNS

import org.apache.hadoop.hbase.util.Strings; //导入依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:hbase,代码行数:19,代码来源:TableInputFormatBase.java

示例9: loginServerPrincipal

import org.apache.hadoop.hbase.util.Strings; //导入依赖的package包/类
private static Pair<FilterHolder, Class<? extends ServletContainer>> loginServerPrincipal(
  UserProvider userProvider, Configuration conf) throws Exception {
  Class<? extends ServletContainer> containerClass = ServletContainer.class;
  if (userProvider.isHadoopSecurityEnabled() && userProvider.isHBaseSecurityEnabled()) {
    String machineName = Strings.domainNamePointerToHostName(
      DNS.getDefaultHost(conf.get(REST_DNS_INTERFACE, "default"),
        conf.get(REST_DNS_NAMESERVER, "default")));
    String keytabFilename = conf.get(REST_KEYTAB_FILE);
    Preconditions.checkArgument(keytabFilename != null && !keytabFilename.isEmpty(),
      REST_KEYTAB_FILE + " should be set if security is enabled");
    String principalConfig = conf.get(REST_KERBEROS_PRINCIPAL);
    Preconditions.checkArgument(principalConfig != null && !principalConfig.isEmpty(),
      REST_KERBEROS_PRINCIPAL + " should be set if security is enabled");
    userProvider.login(REST_KEYTAB_FILE, REST_KERBEROS_PRINCIPAL, machineName);
    if (conf.get(REST_AUTHENTICATION_TYPE) != null) {
      containerClass = RESTServletContainer.class;
      FilterHolder authFilter = new FilterHolder();
      authFilter.setClassName(AuthFilter.class.getName());
      authFilter.setName("AuthenticationFilter");
      return new Pair<>(authFilter,containerClass);
    }
  }
  return new Pair<>(null, containerClass);
}
 
开发者ID:apache,项目名称:hbase,代码行数:25,代码来源:RESTServer.java

示例10: toStringWithPadding

import org.apache.hadoop.hbase.util.Strings; //导入依赖的package包/类
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);
}
 
开发者ID:apache,项目名称:hbase,代码行数:24,代码来源:KeyValueTestUtil.java

示例11: TokenServer

import org.apache.hadoop.hbase.util.Strings; //导入依赖的package包/类
public TokenServer(Configuration conf) throws IOException {
  this.conf = conf;
  this.startcode = EnvironmentEdgeManager.currentTimeMillis();
  // Server to handle client requests.
  String hostname =
    Strings.domainNamePointerToHostName(DNS.getDefaultHost("default", "default"));
  int port = 0;
  // Creation of an ISA will force a resolve.
  InetSocketAddress initialIsa = new InetSocketAddress(hostname, port);
  if (initialIsa.getAddress() == null) {
    throw new IllegalArgumentException("Failed resolve of " + initialIsa);
  }
  final List<BlockingServiceAndInterface> sai =
    new ArrayList<BlockingServiceAndInterface>(1);
  BlockingService service =
    AuthenticationProtos.AuthenticationService.newReflectiveBlockingService(this);
  sai.add(new BlockingServiceAndInterface(service,
    AuthenticationProtos.AuthenticationService.BlockingInterface.class));
  this.rpcServer =
    new RpcServer(this, "tokenServer", sai, initialIsa, 3, 1, conf, HConstants.QOS_THRESHOLD);
  this.isa = this.rpcServer.getListenerAddress();
  this.sleeper = new Sleeper(1000, this);
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:24,代码来源:TestTokenAuthentication.java

示例12: doPuts

import org.apache.hadoop.hbase.util.Strings; //导入依赖的package包/类
private void doPuts(HRegion region) throws IOException{
  LoadTestKVGenerator dataGenerator = new LoadTestKVGenerator(MIN_VALUE_SIZE, MAX_VALUE_SIZE);
   for (int i = 0; i < NUM_ROWS; ++i) {
    byte[] key = LoadTestKVGenerator.md5PrefixedKey(i).getBytes();
    for (int j = 0; j < NUM_COLS_PER_ROW; ++j) {
      Put put = new Put(key);
      byte[] col = Bytes.toBytes(String.valueOf(j));
      byte[] value = dataGenerator.generateRandomSizeValue(key, col);
      put.add(CF_BYTES, col, value);
      if(VERBOSE){
        KeyValue kvPut = new KeyValue(key, CF_BYTES, col, value);
        System.err.println(Strings.padFront(i+"", ' ', 4)+" "+kvPut);
      }
      region.put(put);
    }
    if (i % NUM_ROWS_PER_FLUSH == 0) {
      region.flushcache();
    }
  }
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:21,代码来源:TestEncodedSeekers.java

示例13: doMain

import org.apache.hadoop.hbase.util.Strings; //导入依赖的package包/类
/**
 * Start up or shuts down the Thrift server, depending on the arguments.
 * @param args
 */
 void doMain(final String[] args) throws Exception {
   processOptions(args);
   // login the server principal (if using secure Hadoop)
   if (User.isSecurityEnabled() && User.isHBaseSecurityEnabled(conf)) {
     String machineName = Strings.domainNamePointerToHostName(
       DNS.getDefaultHost(conf.get("hbase.thrift.dns.interface", "default"),
         conf.get("hbase.thrift.dns.nameserver", "default")));
     User.login(conf, "hbase.thrift.keytab.file",
         "hbase.thrift.kerberos.principal", machineName);
   }
   serverRunner = new ThriftServerRunner(conf);

   // Put up info server.
   int port = conf.getInt("hbase.thrift.info.port", 9095);
   if (port >= 0) {
     conf.setLong("startcode", System.currentTimeMillis());
     String a = conf.get("hbase.thrift.info.bindAddress", "0.0.0.0");
     infoServer = new InfoServer("thrift", a, port, false, conf);
     infoServer.setAttribute("hbase.conf", conf);
     infoServer.start();
   }
   serverRunner.run();
}
 
开发者ID:zwqjsj0404,项目名称:HBase-Research,代码行数:28,代码来源:ThriftServer.java

示例14: TokenServer

import org.apache.hadoop.hbase.util.Strings; //导入依赖的package包/类
public TokenServer(Configuration conf) throws IOException {
  this.conf = conf;
  this.startcode = EnvironmentEdgeManager.currentTimeMillis();

  // Server to handle client requests.
  String hostname = Strings.domainNamePointerToHostName(
      DNS.getDefaultHost("default", "default"));
  int port = 0;
  // Creation of an ISA will force a resolve.
  InetSocketAddress initialIsa = new InetSocketAddress(hostname, port);
  if (initialIsa.getAddress() == null) {
    throw new IllegalArgumentException("Failed resolve of " + initialIsa);
  }

  this.rpcServer = HBaseServerRPC.getServer(TokenServer.class, this,
      new Class<?>[]{AuthenticationProtos.AuthenticationService.Interface.class},
      initialIsa.getHostName(), // BindAddress is IP we got for this server.
      initialIsa.getPort(),
      3, // handlers
      1, // meta handlers (not used)
      true,
      this.conf, HConstants.QOS_THRESHOLD);
  // Set our address.
  this.isa = this.rpcServer.getListenerAddress();
  this.sleeper = new Sleeper(1000, this);
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:27,代码来源:TestTokenAuthentication.java

示例15: ThriftServerRunner

import org.apache.hadoop.hbase.util.Strings; //导入依赖的package包/类
public ThriftServerRunner(Configuration conf) throws IOException {
  UserProvider userProvider = UserProvider.instantiate(conf);
  // login the server principal (if using secure Hadoop)
  securityEnabled = userProvider.isHadoopSecurityEnabled()
    && userProvider.isHBaseSecurityEnabled();
  if (securityEnabled) {
    host = Strings.domainNamePointerToHostName(DNS.getDefaultHost(
      conf.get("hbase.thrift.dns.interface", "default"),
      conf.get("hbase.thrift.dns.nameserver", "default")));
    userProvider.login("hbase.thrift.keytab.file",
      "hbase.thrift.kerberos.principal", host);
  }
  this.conf = HBaseConfiguration.create(conf);
  this.listenPort = conf.getInt(PORT_CONF_KEY, DEFAULT_LISTEN_PORT);
  this.metrics = new ThriftMetrics(conf, ThriftMetrics.ThriftServerType.ONE);
  this.hbaseHandler = new HBaseHandler(conf, userProvider);
  this.hbaseHandler.initMetrics(metrics);
  this.handler = HbaseHandlerMetricsProxy.newInstance(
    hbaseHandler, metrics, conf);
  this.realUser = userProvider.getCurrent().getUGI();
  qop = conf.get(THRIFT_QOP_KEY);
  doAsEnabled = conf.getBoolean(THRIFT_SUPPORT_PROXYUSER, false);
  if (qop != null) {
    if (!qop.equals("auth") && !qop.equals("auth-int")
        && !qop.equals("auth-conf")) {
      throw new IOException("Invalid " + THRIFT_QOP_KEY + ": " + qop
        + ", it must be 'auth', 'auth-int', or 'auth-conf'");
    }
    if (!securityEnabled) {
      throw new IOException("Thrift server must"
        + " run in secure mode to support authentication");
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:35,代码来源:ThriftServerRunner.java


注:本文中的org.apache.hadoop.hbase.util.Strings类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。