You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by sh...@apache.org on 2016/12/30 02:31:07 UTC

[15/42] kylin git commit: KYLIN-2327 enable check-style for test code

http://git-wip-us.apache.org/repos/asf/kylin/blob/3e0edc84/storage-hbase/src/test/java/org/apache/kylin/storage/hbase/common/HiveMiniClusterTest.java
----------------------------------------------------------------------
diff --git a/storage-hbase/src/test/java/org/apache/kylin/storage/hbase/common/HiveMiniClusterTest.java b/storage-hbase/src/test/java/org/apache/kylin/storage/hbase/common/HiveMiniClusterTest.java
deleted file mode 100644
index 2edf11e..0000000
--- a/storage-hbase/src/test/java/org/apache/kylin/storage/hbase/common/HiveMiniClusterTest.java
+++ /dev/null
@@ -1,131 +0,0 @@
-///*
-// * Licensed to the Apache Software Foundation (ASF) under one
-// * or more contributor license agreements.  See the NOTICE file
-// * distributed with this work for additional information
-// * regarding copyright ownership.  The ASF licenses this file
-// * to you under the Apache License, Version 2.0 (the
-// * "License"); you may not use this file except in compliance
-// * with the License.  You may obtain a copy of the License at
-// * 
-// *     http://www.apache.org/licenses/LICENSE-2.0
-// * 
-// * Unless required by applicable law or agreed to in writing, software
-// * distributed under the License is distributed on an "AS IS" BASIS,
-// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// * See the License for the specific language governing permissions and
-// * limitations under the License.
-//*/
-//
-//package org.apache.kylin.storage.minicluster;
-//
-//import java.io.File;
-//import java.io.IOException;
-//import java.sql.Connection;
-//import java.sql.DriverManager;
-//import java.sql.SQLException;
-//
-//import org.apache.commons.io.FileUtils;
-//import org.apache.hadoop.hdfs.MiniDFSCluster;
-//import org.apache.hadoop.hive.conf.HiveConf;
-//import org.apache.hadoop.hive.service.HiveInterface;
-//import org.apache.hadoop.mapred.JobConf;
-//import org.apache.hadoop.mapred.MiniMRCluster;
-//
-///**
-// * This is a test case to verify whether the query can be executed on Hive minicluster;
-// * You need set $HADOOP_HOME environment parameter before run it;
-// * @author shaoshi
-// *
-// */
-//public class HiveMiniClusterTest extends HiveJDBCClientTest {
-//    public static final File HIVE_BASE_DIR = new File("target/hive");
-//    public static final File HIVE_SCRATCH_DIR = new File(HIVE_BASE_DIR + "/scratchdir");
-//    public static final File HIVE_LOCAL_SCRATCH_DIR = new File(HIVE_BASE_DIR + "/localscratchdir");
-//    public static final File HIVE_METADB_DIR = new File(HIVE_BASE_DIR + "/metastoredb");
-//    public static final File HIVE_LOGS_DIR = new File(HIVE_BASE_DIR + "/logs");
-//    public static final File HIVE_TMP_DIR = new File(HIVE_BASE_DIR + "/tmp");
-//    public static final File HIVE_WAREHOUSE_DIR = new File(HIVE_BASE_DIR + "/warehouse");
-//    public static final File HIVE_TESTDATA_DIR = new File(HIVE_BASE_DIR + "/testdata");
-//    public static final File HIVE_HADOOP_TMP_DIR = new File(HIVE_BASE_DIR + "/hadooptmp");
-//    protected HiveInterface client;
-//
-//    protected MiniDFSCluster miniDFS;
-//    protected MiniMRCluster miniMR;
-//
-//    //@Before
-//    public void setup() {
-//        super.setup();
-//        startHiveMiniCluster();
-//    }
-//
-//    protected void startHiveMiniCluster() {
-//        //Create and configure location for hive to dump junk in target folder
-//        try {
-//            FileUtils.forceMkdir(HIVE_BASE_DIR);
-//            FileUtils.forceMkdir(HIVE_SCRATCH_DIR);
-//            FileUtils.forceMkdir(HIVE_LOCAL_SCRATCH_DIR);
-//            FileUtils.forceMkdir(HIVE_LOGS_DIR);
-//            FileUtils.forceMkdir(HIVE_TMP_DIR);
-//            FileUtils.forceMkdir(HIVE_WAREHOUSE_DIR);
-//            FileUtils.forceMkdir(HIVE_HADOOP_TMP_DIR);
-//            FileUtils.forceMkdir(HIVE_TESTDATA_DIR);
-//        } catch (IOException e1) {
-//            e1.printStackTrace();
-//            System.exit(1);
-//        }
-//
-//        System.setProperty("javax.jdo.option.ConnectionURL", "jdbc:derby:;databaseName=" + HIVE_METADB_DIR.getAbsolutePath() + ";create=true");
-//        System.setProperty("hive.metastore.warehouse.dir", HIVE_WAREHOUSE_DIR.getAbsolutePath());
-//        System.setProperty("hive.exec.scratchdir", HIVE_SCRATCH_DIR.getAbsolutePath());
-//        System.setProperty("hive.exec.local.scratchdir", HIVE_LOCAL_SCRATCH_DIR.getAbsolutePath());
-//        System.setProperty("hive.metastore.metadb.dir", HIVE_METADB_DIR.getAbsolutePath());
-//        System.setProperty("test.log.dir", HIVE_LOGS_DIR.getAbsolutePath());
-//        System.setProperty("hive.querylog.location", HIVE_TMP_DIR.getAbsolutePath());
-//        System.setProperty("hadoop.tmp.dir", HIVE_HADOOP_TMP_DIR.getAbsolutePath());
-//        System.setProperty("derby.stream.error.file", HIVE_BASE_DIR.getAbsolutePath() + "/derby.log");
-//
-//        // custom properties
-//        System.setProperty("hive.server2.long.polling.timeout", "5000");
-//
-//        HiveConf conf = new HiveConf();
-//
-//        /* Build MiniDFSCluster */
-//        try {
-//            miniDFS = new MiniDFSCluster.Builder(conf).build();
-//
-//            /* Build MiniMR Cluster */
-//            int numTaskTrackers = 1;
-//            int numTaskTrackerDirectories = 1;
-//            String[] racks = null;
-//            String[] hosts = null;
-//            miniMR = new MiniMRCluster(numTaskTrackers, miniDFS.getFileSystem().getUri().toString(), numTaskTrackerDirectories, racks, hosts, new JobConf(conf));
-//            JobConf jobConf = miniMR.createJobConf(new JobConf(conf));
-//            System.out.println("-------" + jobConf.get("fs.defaultFS"));
-//            System.out.println("-------" + miniDFS.getFileSystem().getUri().toString());
-//            System.setProperty("mapred.job.tracker", jobConf.get("mapred.job.tracker"));
-//        } catch (IOException e) {
-//            e.printStackTrace();
-//            System.exit(1);
-//        }
-//    }
-//
-//    //@After
-//    public void tearDown() {
-//        if (miniMR != null)
-//            miniMR.shutdown();
-//
-//        if (miniDFS != null)
-//            miniDFS.shutdown();
-//
-//        super.tearDown();
-//    }
-//
-//    protected Connection getHiveConnection() throws SQLException {
-//        return DriverManager.getConnection("jdbc:hive2:///", "", "");
-//    }
-//
-//    public static void main(String[] args) throws SQLException {
-//        HiveMiniClusterTest test = new HiveMiniClusterTest();
-//        test.runTests();
-//    }
-//}

http://git-wip-us.apache.org/repos/asf/kylin/blob/3e0edc84/storage-hbase/src/test/java/org/apache/kylin/storage/hbase/steps/MockupMapContext.java
----------------------------------------------------------------------
diff --git a/storage-hbase/src/test/java/org/apache/kylin/storage/hbase/steps/MockupMapContext.java b/storage-hbase/src/test/java/org/apache/kylin/storage/hbase/steps/MockupMapContext.java
index d5c3f60..d953d9c 100644
--- a/storage-hbase/src/test/java/org/apache/kylin/storage/hbase/steps/MockupMapContext.java
+++ b/storage-hbase/src/test/java/org/apache/kylin/storage/hbase/steps/MockupMapContext.java
@@ -47,267 +47,275 @@ import org.apache.kylin.engine.mr.common.BatchConstants;
  * 
  */
 @SuppressWarnings({ "rawtypes", "unchecked" })
-public class MockupMapContext {
+public class MockupMapContext implements  MapContext {
+
+    private Configuration hconf;
+
+    private Object[] outKV;
 
     public static Context create(final Configuration hconf, String metadataUrl, String cubeName, final Object[] outKV) {
 
         hconf.set(BatchConstants.CFG_CUBE_NAME, cubeName);
 
-        return new WrappedMapper().getMapContext(new MapContext() {
-
-            @Override
-            public boolean nextKeyValue() throws IOException, InterruptedException {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public Object getCurrentKey() throws IOException, InterruptedException {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public Object getCurrentValue() throws IOException, InterruptedException {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public void write(Object key, Object value) throws IOException, InterruptedException {
-                System.out.println("Write -- k:" + key + ", v:" + value);
-                if (outKV != null) {
-                    outKV[0] = key;
-                    outKV[1] = value;
-                }
-            }
-
-            @Override
-            public OutputCommitter getOutputCommitter() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public TaskAttemptID getTaskAttemptID() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public void setStatus(String msg) {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public String getStatus() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public float getProgress() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public Counter getCounter(Enum<?> counterName) {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public Counter getCounter(String groupName, String counterName) {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public Configuration getConfiguration() {
-                return hconf;
-            }
-
-            @Override
-            public Credentials getCredentials() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public JobID getJobID() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public int getNumReduceTasks() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public Path getWorkingDirectory() throws IOException {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public Class<?> getOutputKeyClass() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public Class<?> getOutputValueClass() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public Class<?> getMapOutputKeyClass() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public Class<?> getMapOutputValueClass() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public String getJobName() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public Class<? extends InputFormat<?, ?>> getInputFormatClass() throws ClassNotFoundException {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public Class<? extends Mapper<?, ?, ?, ?>> getMapperClass() throws ClassNotFoundException {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public Class<? extends Reducer<?, ?, ?, ?>> getCombinerClass() throws ClassNotFoundException {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public Class<? extends Reducer<?, ?, ?, ?>> getReducerClass() throws ClassNotFoundException {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public Class<? extends OutputFormat<?, ?>> getOutputFormatClass() throws ClassNotFoundException {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public Class<? extends Partitioner<?, ?>> getPartitionerClass() throws ClassNotFoundException {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public RawComparator<?> getSortComparator() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public String getJar() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public RawComparator<?> getGroupingComparator() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public boolean getJobSetupCleanupNeeded() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public boolean getTaskCleanupNeeded() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public boolean getProfileEnabled() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public String getProfileParams() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public IntegerRanges getProfileTaskRange(boolean isMap) {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public String getUser() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public boolean getSymlink() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public Path[] getArchiveClassPaths() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public URI[] getCacheArchives() throws IOException {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public URI[] getCacheFiles() throws IOException {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public Path[] getLocalCacheArchives() throws IOException {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public Path[] getLocalCacheFiles() throws IOException {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public Path[] getFileClassPaths() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public String[] getArchiveTimestamps() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public String[] getFileTimestamps() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public int getMaxMapAttempts() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public int getMaxReduceAttempts() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public void progress() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public InputSplit getInputSplit() {
-                throw new NotImplementedException();
-            }
-
-            @Override
-            public RawComparator<?> getCombinerKeyGroupingComparator() {
-                throw new NotImplementedException();
-            }
-        });
+        return new WrappedMapper().getMapContext(new MockupMapContext(hconf, outKV));
+    }
+
+    public MockupMapContext(Configuration hconf, Object[] outKV){
+        this.hconf = hconf;
+        this.outKV = outKV;
+    }
+
+    @Override
+    public boolean nextKeyValue() throws IOException, InterruptedException {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public Object getCurrentKey() throws IOException, InterruptedException {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public Object getCurrentValue() throws IOException, InterruptedException {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public void write(Object key, Object value) throws IOException, InterruptedException {
+        System.out.println("Write -- k:" + key + ", v:" + value);
+        if (outKV != null) {
+            outKV[0] = key;
+            outKV[1] = value;
+        }
+    }
+
+    @Override
+    public OutputCommitter getOutputCommitter() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public TaskAttemptID getTaskAttemptID() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public void setStatus(String msg) {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public String getStatus() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public float getProgress() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public Counter getCounter(Enum<?> counterName) {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public Counter getCounter(String groupName, String counterName) {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public Configuration getConfiguration() {
+        return hconf;
+    }
+
+    @Override
+    public Credentials getCredentials() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public JobID getJobID() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public int getNumReduceTasks() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public Path getWorkingDirectory() throws IOException {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public Class<?> getOutputKeyClass() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public Class<?> getOutputValueClass() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public Class<?> getMapOutputKeyClass() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public Class<?> getMapOutputValueClass() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public String getJobName() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public Class<? extends InputFormat<?, ?>> getInputFormatClass() throws ClassNotFoundException {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public Class<? extends Mapper<?, ?, ?, ?>> getMapperClass() throws ClassNotFoundException {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public Class<? extends Reducer<?, ?, ?, ?>> getCombinerClass() throws ClassNotFoundException {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public Class<? extends Reducer<?, ?, ?, ?>> getReducerClass() throws ClassNotFoundException {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public Class<? extends OutputFormat<?, ?>> getOutputFormatClass() throws ClassNotFoundException {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public Class<? extends Partitioner<?, ?>> getPartitionerClass() throws ClassNotFoundException {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public RawComparator<?> getSortComparator() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public String getJar() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public RawComparator<?> getGroupingComparator() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public boolean getJobSetupCleanupNeeded() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public boolean getTaskCleanupNeeded() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public boolean getProfileEnabled() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public String getProfileParams() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public IntegerRanges getProfileTaskRange(boolean isMap) {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public String getUser() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public boolean getSymlink() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public Path[] getArchiveClassPaths() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public URI[] getCacheArchives() throws IOException {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public URI[] getCacheFiles() throws IOException {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public Path[] getLocalCacheArchives() throws IOException {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public Path[] getLocalCacheFiles() throws IOException {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public Path[] getFileClassPaths() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public String[] getArchiveTimestamps() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public String[] getFileTimestamps() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public int getMaxMapAttempts() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public int getMaxReduceAttempts() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public void progress() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public InputSplit getInputSplit() {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public RawComparator<?> getCombinerKeyGroupingComparator() {
+        throw new NotImplementedException();
     }
 }