zoukankan      html  css  js  c++  java
  • hbase-java-api002(flush)

    package api;
    
    import java.io.IOException;
    
    import org.apache.hadoop.conf.Configuration;
    import org.apache.hadoop.hbase.HBaseConfiguration;
    import org.apache.hadoop.hbase.client.Get;
    import org.apache.hadoop.hbase.client.HTable;
    import org.apache.hadoop.hbase.client.Put;
    import org.apache.hadoop.hbase.client.Result;
    import org.apache.hadoop.hbase.util.Bytes;
    
    public class FlushEx {
    
        public static void main(String[] args) throws IOException {
               Configuration cfg = HBaseConfiguration.create();
    
    
                HTable table = new HTable(cfg,"xyj");
                
                System.out.println("Auto flush"+table.isAutoFlush());
                
                table.setAutoFlush(false);
    
                Put put1 =new Put(Bytes.toBytes("row4"));
                put1.add(Bytes.toBytes("cf1"),Bytes.toBytes("qual4"),Bytes.toBytes("val4"));
                table.put(put1);   
                
                Put put2 =new Put(Bytes.toBytes("row5"));
                put2.add(Bytes.toBytes("cf1"),Bytes.toBytes("qual5"),Bytes.toBytes("val5"));
                table.put(put2);
                
                Put put3 =new Put(Bytes.toBytes("row6"));
                put3.add(Bytes.toBytes("cf1"),Bytes.toBytes("qual6"),Bytes.toBytes("val6"));
                table.put(put3);
                
                Get get = new Get(Bytes.toBytes("row4"));
                Result result1 = table.get(get);
                System.out.println("result1-->"+result1);
                
                table.flushCommits();
                
                Result result2 = table.get(get);
                System.out.println("result2-->"+result2);
                
    
        }
    }
    //2017-11-25 00:48:50,577 WARN  [main] util.NativeCodeLoader (NativeCodeLoader.java:<clinit>(62)) - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
    //2017-11-25 00:48:50,666 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:zookeeper.version=3.4.5-1392090, built on 09/30/2012 17:52 GMT
    //2017-11-25 00:48:50,667 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:host.name=alamps
    //2017-11-25 00:48:50,667 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.version=1.7.0_65
    //2017-11-25 00:48:50,667 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.vendor=Oracle Corporation
    //2017-11-25 00:48:50,667 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.home=/home/hadoop/jdk1.7.0_65/jre
    //2017-11-25 00:48:50,667 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.class.path=/home/hadoop/workspace/HBase/bin:/home/hadoop/hbase-0.96.2/lib/activation-1.1.jar:/home/hadoop/hbase-0.96.2/lib/aopalliance-1.0.jar:/home/hadoop/hbase-0.96.2/lib/asm-3.1.jar:/home/hadoop/hbase-0.96.2/lib/avro-1.7.4.jar:/home/hadoop/hbase-0.96.2/lib/commons-beanutils-1.7.0.jar:/home/hadoop/hbase-0.96.2/lib/commons-beanutils-core-1.8.0.jar:/home/hadoop/hbase-0.96.2/lib/commons-cli-1.2.jar:/home/hadoop/hbase-0.96.2/lib/commons-codec-1.7.jar:/home/hadoop/hbase-0.96.2/lib/commons-collections-3.2.1.jar:/home/hadoop/hbase-0.96.2/lib/commons-compress-1.4.1.jar:/home/hadoop/hbase-0.96.2/lib/commons-configuration-1.6.jar:/home/hadoop/hbase-0.96.2/lib/commons-daemon-1.0.13.jar:/home/hadoop/hbase-0.96.2/lib/commons-digester-1.8.jar:/home/hadoop/hbase-0.96.2/lib/commons-el-1.0.jar:/home/hadoop/hbase-0.96.2/lib/commons-httpclient-3.1.jar:/home/hadoop/hbase-0.96.2/lib/commons-io-2.4.jar:/home/hadoop/hbase-0.96.2/lib/commons-lang-2.6.jar:/home/hadoop/hbase-0.96.2/lib/commons-logging-1.1.1.jar:/home/hadoop/hbase-0.96.2/lib/commons-math-2.1.jar:/home/hadoop/hbase-0.96.2/lib/commons-net-3.1.jar:/home/hadoop/hbase-0.96.2/lib/findbugs-annotations-1.3.9-1.jar:/home/hadoop/hbase-0.96.2/lib/gmbal-api-only-3.0.0-b023.jar:/home/hadoop/hbase-0.96.2/lib/grizzly-framework-2.1.2.jar:/home/hadoop/hbase-0.96.2/lib/grizzly-http-2.1.2.jar:/home/hadoop/hbase-0.96.2/lib/grizzly-http-server-2.1.2.jar:/home/hadoop/hbase-0.96.2/lib/grizzly-http-servlet-2.1.2.jar:/home/hadoop/hbase-0.96.2/lib/grizzly-rcm-2.1.2.jar:/home/hadoop/hbase-0.96.2/lib/guava-12.0.1.jar:/home/hadoop/hbase-0.96.2/lib/guice-3.0.jar:/home/hadoop/hbase-0.96.2/lib/guice-servlet-3.0.jar:/home/hadoop/hbase-0.96.2/lib/hadoop-annotations-2.2.0.jar:/home/hadoop/hbase-0.96.2/lib/hadoop-auth-2.2.0.jar:/home/hadoop/hbase-0.96.2/lib/hadoop-client-2.2.0.jar:/home/hadoop/hbase-0.96.2/lib/hadoop-common-2.2.0.jar:/home/hadoop/hbase-0.96.2/lib/hadoop-hdfs-2.2.0.jar:/home/hadoop/hbase-0.96.2/lib/hadoop-hdfs-2.2.0-tests.jar:/home/hadoop/hbase-0.96.2/lib/hadoop-mapreduce-client-app-2.2.0.jar:/home/hadoop/hbase-0.96.2/lib/hadoop-mapreduce-client-common-2.2.0.jar:/home/hadoop/hbase-0.96.2/lib/hadoop-mapreduce-client-core-2.2.0.jar:/home/hadoop/hbase-0.96.2/lib/hadoop-mapreduce-client-jobclient-2.2.0.jar:/home/hadoop/hbase-0.96.2/lib/hadoop-mapreduce-client-jobclient-2.2.0-tests.jar:/home/hadoop/hbase-0.96.2/lib/hadoop-mapreduce-client-shuffle-2.2.0.jar:/home/hadoop/hbase-0.96.2/lib/hadoop-yarn-api-2.2.0.jar:/home/hadoop/hbase-0.96.2/lib/hadoop-yarn-client-2.2.0.jar:/home/hadoop/hbase-0.96.2/lib/hadoop-yarn-common-2.2.0.jar:/home/hadoop/hbase-0.96.2/lib/hadoop-yarn-server-common-2.2.0.jar:/home/hadoop/hbase-0.96.2/lib/hadoop-yarn-server-nodemanager-2.2.0.jar:/home/hadoop/hbase-0.96.2/lib/hamcrest-core-1.3.jar:/home/hadoop/hbase-0.96.2/lib/hbase-client-0.96.2-hadoop2.jar:/home/hadoop/hbase-0.96.2/lib/hbase-common-0.96.2-hadoop2.jar:/home/hadoop/hbase-0.96.2/lib/hbase-common-0.96.2-hadoop2-tests.jar:/home/hadoop/hbase-0.96.2/lib/hbase-examples-0.96.2-hadoop2.jar:/home/hadoop/hbase-0.96.2/lib/hbase-hadoop2-compat-0.96.2-hadoop2.jar:/home/hadoop/hbase-0.96.2/lib/hbase-hadoop-compat-0.96.2-hadoop2.jar:/home/hadoop/hbase-0.96.2/lib/hbase-it-0.96.2-hadoop2.jar:/home/hadoop/hbase-0.96.2/lib/hbase-it-0.96.2-hadoop2-tests.jar:/home/hadoop/hbase-0.96.2/lib/hbase-prefix-tree-0.96.2-hadoop2.jar:/home/hadoop/hbase-0.96.2/lib/hbase-protocol-0.96.2-hadoop2.jar:/home/hadoop/hbase-0.96.2/lib/hbase-server-0.96.2-hadoop2.jar:/home/hadoop/hbase-0.96.2/lib/hbase-server-0.96.2-hadoop2-tests.jar:/home/hadoop/hbase-0.96.2/lib/hbase-shell-0.96.2-hadoop2.jar:/home/hadoop/hbase-0.96.2/lib/hbase-testing-util-0.96.2-hadoop2.jar:/home/hadoop/hbase-0.96.2/lib/hbase-thrift-0.96.2-hadoop2.jar:/home/hadoop/hbase-0.96.2/lib/htrace-core-2.04.jar:/home/hadoop/hbase-0.96.2/lib/httpclient-4.1.3.jar:/home/hadoop/hbase-0.96.2/lib/httpcore-4.1.3.jar:/home/hadoop/hbase-0.96.2/lib/jackson-core-asl-1.8.8.jar:/home/hadoop/hbase-0.96.2/lib/jackson-jaxrs-1.8.8.jar:/home/hadoop/hbase-0.96.2/lib/jackson-mapper-asl-1.8.8.jar:/home/hadoop/hbase-0.96.2/lib/jackson-xc-1.8.8.jar:/home/hadoop/hbase-0.96.2/lib/jamon-runtime-2.3.1.jar:/home/hadoop/hbase-0.96.2/lib/jasper-compiler-5.5.23.jar:/home/hadoop/hbase-0.96.2/lib/jasper-runtime-5.5.23.jar:/home/hadoop/hbase-0.96.2/lib/javax.inject-1.jar:/home/hadoop/hbase-0.96.2/lib/javax.servlet-3.1.jar:/home/hadoop/hbase-0.96.2/lib/javax.servlet-api-3.0.1.jar:/home/hadoop/hbase-0.96.2/lib/jaxb-api-2.2.2.jar:/home/hadoop/hbase-0.96.2/lib/jaxb-impl-2.2.3-1.jar:/home/hadoop/hbase-0.96.2/lib/jersey-client-1.9.jar:/home/hadoop/hbase-0.96.2/lib/jersey-core-1.8.jar:/home/hadoop/hbase-0.96.2/lib/jersey-grizzly2-1.9.jar:/home/hadoop/hbase-0.96.2/lib/jersey-guice-1.9.jar:/home/hadoop/hbase-0.96.2/lib/jersey-json-1.8.jar:/home/hadoop/hbase-0.96.2/lib/jersey-server-1.8.jar:/home/hadoop/hbase-0.96.2/lib/jersey-test-framework-core-1.9.jar:/home/hadoop/hbase-0.96.2/lib/jersey-test-framework-grizzly2-1.9.jar:/home/hadoop/hbase-0.96.2/lib/jets3t-0.6.1.jar:/home/hadoop/hbase-0.96.2/lib/jettison-1.3.1.jar:/home/hadoop/hbase-0.96.2/lib/jetty-6.1.26.jar:/home/hadoop/hbase-0.96.2/lib/jetty-sslengine-6.1.26.jar:/home/hadoop/hbase-0.96.2/lib/jetty-util-6.1.26.jar:/home/hadoop/hbase-0.96.2/lib/jruby-complete-1.6.8.jar:/home/hadoop/hbase-0.96.2/lib/jsch-0.1.42.jar:/home/hadoop/hbase-0.96.2/lib/jsp-2.1-6.1.14.jar:/home/hadoop/hbase-0.96.2/lib/jsp-api-2.1-6.1.14.jar:/home/hadoop/hbase-0.96.2/lib/jsr305-1.3.9.jar:/home/hadoop/hbase-0.96.2/lib/junit-4.11.jar:/home/hadoop/hbase-0.96.2/lib/libthrift-0.9.0.jar:/home/hadoop/hbase-0.96.2/lib/log4j-1.2.17.jar:/home/hadoop/hbase-0.96.2/lib/management-api-3.0.0-b012.jar:/home/hadoop/hbase-0.96.2/lib/metrics-core-2.1.2.jar:/home/hadoop/hbase-0.96.2/lib/netty-3.6.6.Final.jar:/home/hadoop/hbase-0.96.2/lib/paranamer-2.3.jar:/home/hadoop/hbase-0.96.2/lib/protobuf-java-2.5.0.jar:/home/hadoop/hbase-0.96.2/lib/servlet-api-2.5-6.1.14.jar:/home/hadoop/hbase-0.96.2/lib/slf4j-api-1.6.4.jar:/home/hadoop/hbase-0.96.2/lib/slf4j-log4j12-1.6.4.jar:/home/hadoop/hbase-0.96.2/lib/snappy-java-1.0.4.1.jar:/home/hadoop/hbase-0.96.2/lib/xmlenc-0.52.jar:/home/hadoop/hbase-0.96.2/lib/xz-1.0.jar:/home/hadoop/hbase-0.96.2/lib/zookeeper-3.4.5.jar
    //2017-11-25 00:48:50,668 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.library.path=/home/hadoop/jdk1.7.0_65/jre/lib/i386/client:/home/hadoop/jdk1.7.0_65/jre/lib/i386:/home/hadoop/jdk1.7.0_65/jre/../lib/i386:/home/hadoop/app/jdk1.8.0_144/jre/lib/i386/client:/home/hadoop/app/jdk1.8.0_144/jre/lib/i386::/usr/java/packages/lib/i386:/lib:/usr/lib
    //2017-11-25 00:48:50,670 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.io.tmpdir=/tmp
    //2017-11-25 00:48:50,670 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.compiler=<NA>
    //2017-11-25 00:48:50,670 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:os.name=Linux
    //2017-11-25 00:48:50,670 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:os.arch=i386
    //2017-11-25 00:48:50,670 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:os.version=2.6.32-358.el6.i686
    //2017-11-25 00:48:50,670 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:user.name=hadoop
    //2017-11-25 00:48:50,670 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:user.home=/home/hadoop
    //2017-11-25 00:48:50,671 INFO  [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:user.dir=/home/hadoop/workspace/HBase
    //2017-11-25 00:48:50,672 INFO  [main] zookeeper.ZooKeeper (ZooKeeper.java:<init>(438)) - Initiating client connection, connectString=localhost:2181 sessionTimeout=90000 watcher=hconnection-0x76a85e, quorum=localhost:2181, baseZNode=/hbase
    //2017-11-25 00:48:50,717 INFO  [main-SendThread(localhost:2181)] zookeeper.ClientCnxn (ClientCnxn.java:logStartConnect(966)) - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)
    //2017-11-25 00:48:50,719 INFO  [main] zookeeper.RecoverableZooKeeper (RecoverableZooKeeper.java:<init>(120)) - Process identifier=hconnection-0x76a85e connecting to ZooKeeper ensemble=localhost:2181
    //2017-11-25 00:48:50,731 INFO  [main-SendThread(localhost:2181)] zookeeper.ClientCnxn (ClientCnxn.java:primeConnection(849)) - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
    //2017-11-25 00:48:50,738 INFO  [main-SendThread(localhost:2181)] zookeeper.ClientCnxn (ClientCnxn.java:onConnected(1207)) - Session establishment complete on server localhost/0:0:0:0:0:0:0:1:2181, sessionid = 0x15ff20c769a001e, negotiated timeout = 90000
    //Auto flushtrue
    //result1-->keyvalues=NONE
    //result2-->keyvalues={row4/cf1:qual4/1511599731428/Put/vlen=4/mvcc=0}
  • 相关阅读:
    telent

    linux系统下部署war包
    CentOS-7.0.中安装与配置Tomcat-7的方法
    ServletContextListener
    JAVA中静态块、静态变量加载顺序详解
    git 查看父分支
    Google Guice 之绑定1
    STM32 Cubemx 配置定时器定时1mS
    项目过程的几点经验总结
  • 原文地址:https://www.cnblogs.com/alamps/p/7895739.html
Copyright © 2011-2022 走看看